Anyone know how to make the code for weight gain in quest for textadventures?

I am trying to make a game in quest but I don’t know how to make different foods affect the player, can someone list some codes?

Well, one way is to add an object called “food” and give it a property for .calories, or .size, (integer type attribute) or what have you. Then give the “player” object a .weight or .stomach attribute - or both, nobody’s stopping you. Keep in mind whether you’re thinking about lbs. or kg. or sq. cm. or some completely arbitrary counting system, but whatever it is keep it consistent.

Then give the “food” a verb called “eat” which calls a script for a recursive equation to affect change in the player’s stomach capacity / weight. That would look like, for example:

player.stomach = player.stomach + food.size


player.weight = player.weight + food.calories

But if you want to convert stomach contents to weight over some period of time or at day’s end or something, that will require an algorithm to do that. Call a function when the player sleeps or something.

Also, this question is very open-ended and you can solve it in a variety of ways. It then also depends on what kind of game you’re trying to make, ie. how fast do they gain weight? What setting is it? This is going to change how you want to structure your code. If you don’t think about this then change your mind, you won’t finish your game.

It is also possible to to set certain foods with specific events that can allow for certain things, all while using the If command. Like how Leifwarfer said, you can set it to anything (within reason) while not having to deal with variables. (This can range from creating timers, turnscripts, etc.)

A bit of warning though, depending on what version you are using will make it slightly annoying to utilize variables. Downloaded Quest seems to be easier while online requires a bit more… brute forcing for some weird reason. While it may look daunting, it actually is very fun to see the sort of physics you can allow on to your character or characters.

Here is a related topic: Quest troubles...

1 Like

You can also just make certain actions add to a weight variable which would be set up like: $weight.
Essentially the choice would be in a standalone passage and code would run under it like (set:$weight to ($weight + x))

Thanks guys I hope this will help

Where would I find the recursive equation?

Recursion in this context is just the concept of setting an attribute equal to itself with a modification. So by setting player.weight = player.weight + 1, you are doing recursion. The left side of the equation becomes the result of the right side of the equation.

If you want the player to grow out of clothes, you could - for instance - set a change script on the player’s weight attribute. Whenever you gain weight, you could use if/else statements to print descriptions of the clothes tightening. You could set an integer attribute on the clothes which, when worn, shred by printing a message and destroying/changing the clothing object. Check via the change script if the player exceeds that integer attribute, which could trigger that process. This is not the most efficient way. I mean, there are limitless ways you could approach this, but this is an easy way.

Complete text adventures tend to be a lot more work than people realize even for a simple project. It is important to be interested in how Quest works and read the documentation (even if you just skim for what you need).

Aye, thanks for the help

1 Like