So you could use the prebuilt Health system if you’d like but just know that comes with a number of other things. Like the HP stat is percent-based, can’t go above 100 natively.
https://docs.textadventures.co.uk/quest/score_health_money.html
Anyway, though this question is really code-centric, I’ll tell you the basics you need to know with Quest (Quest is VERY friendly to new coders). There are certain attribute names that you can’t use (ex. “game”), but I have never had a problem with using “weight” - granted, I have never used the Inventory Limits feature in any of my projects so that may affect things if you are using it.
Attributes are just little pockets of information on what is called the parent object. They can store Boolean (true/false), String (a line of text), Integer (a whole number), Script (essentially a little function). This is a basic if/else.
In Quest, you’re going to do a lot of [Setting an attribute] and a lot of if/else statements. In this example, we tested to see if the object messyFloor’s presumably Boolean attribute cleanliness was true or false. Notice that neither true nor false are in quotation marks; that is because they are hard-coded, unlike strings. If we were testing for Strings on a String attribute, it might look like:
Take a look at this more on-the-nose example.
Let me explain: we have a character whose object name is fatty1. They have an Integer attribute called hunger that can be used to determine if they will eat when prompted (such as when you use the “feed” command, or whatever verb you program). The object fatty1 also has a stomach Integer attribute, used to aggregate the value of the Integer attribute of the object food1 and any other food they consume.
They - like all objects - have a display name under the String attribute alias. When combining strings, we use Print [expression], add String attributes and custom strings in quotes and add them together with + signs. We can make Print [expression] output a regular quotation mark ( " ) by adding a backslash ( \ ) before the mark, indicating that it is supposed to be printed like regular text.
You’ll also notice I used a few operators you might not recognize. When setting attributes or testing using if/else, <= means “greater than” in Quest, just like in math. Meanwhile, += means “add the right side of this equation to the attribute on the left side.” It’s called recursion. So:
thisAttribute += otherAttribute
is equal to:
thisAttribute = thisAttribute + otherAttribute
That’s the breakdown. For now, I recommend you emulate the simplest things about that:
- Set attributes
- Test for value of those attributes using If/Else
- Print messages and/or set other attributes based on test
There are more nuances but that will generally do everything you need at the start. Funny enough, Quest is what brought me into coding when I knew nothing at all, so it’s not a lost cause if it feels overwhelming. Just do the stuff that makes sense to you. The documentation is there when you need it.