Help on twine

Hello! I decided to make another game, and this is what I need help with :

  • How do I implement weight counter (shows your weight)
    -How do i make stuff occur when you have more/less weight
    -how do I make random encounters?

Thanks!

1 Like

I’m not sure which version of Twine you’re using, so this is a bit generalized:

  1. Making a weight counter is pretty easy. For example, a basic weight counter would look like this:

You currently weigh $weight pounds

“$weight” being whichever value you track weight with (Though you can name it anything you want. I use $lbs myself to save space).

  1. Have a code line in the event that adds or subtracts a certain number from $weight. Here is an example for Harlowe, since I’m not entirely sure what the code is in the other versions:

(set: $weight to $weight + X)

X is whatever amount of weight you want the character to gain from a certain event or action. It doesn’t need to be a specific number, either. You can make the amount of weight gained random by typing “(random: min, max)” where X would go (min and max being the minimum and maximum amount of weight you want the character to gain from the event).

  1. This is the tricky one, in my personal opinion. The way I did it, basically set the game to do a coin toss, repeating the coin toss until it lost (in which case the coin toss it lost decides the event) or reached the end of the chain (which triggers the rarest event by default). There are probably more optimal ways to do it, but I haven’t figured it out myself.

If you want, you can download my game (I’m not sure if I’m allowed to link it here or not, but you can look up The Lipomancer’s Ruins on this forum) and slap it into your Twine editor to look around at the inner workings to get a better understanding of how Twine games (in Harlowe, at least) work. Its inner workings are a bit messy, but it got the job done. All you need to do to look into it is open up Twine and click “Import from file” to get access to the inner workings.

Heck, you can just rip the whole thing apart and put it back together as your own game if you want. I don’t mind making the jobs of other up-and-coming devs together.

Good luck and happy Twining.

1 Like

Thanks!
Also, since i forgot what twine i use, i use twine 2.0 and im using the one that twine give you first (didnt change anything)

1 Like

i just downloaded your game and my head hurts looking at all this code, but ill try checking every code,

1 Like

NEW QUESTION!
So, like i figures out how to filp a coin, and set weight + add or decrease it,
and my question is, how to change the storyline from the coin flip
this is what i mean,
IF coin = Heads, you proceed to live as a girl, after 10 passages : a BOY confess to you
IF coin = Tails , you live as a boy, so like after 10 passages : a girl confess to you

thanks again!

sorry if i keep asking questions

1 Like

The most obvious way I thought of is making a value for whether you are a boy or girl (we’ll call it $sex in this case). When it comes to the point where you decide whether you’re a boy or girl you use the function (set: $sex to (either: 1,2)). For the moment we’ll assume 2 is female and 1 is male. From then on, whenever there is any event that would be affected by this result, you’ll use the function “(if: $sex > 1)[Girl event] (else:)[Boy event]”.

Of course, you can also add an “Other” option by using the functions (set: $sex to (either: 1,2,3) and (if: $sex > 1)[(if: $sex > 2)[Other Event] (else:)[Girl Event]] (else:)[Boy event]. But I’d that point, I’d recommend just letting the player choose and setting $sex to a specific value depending on what they choose.

Alternatively, if you don’t care about optimization or are making a fully linear story, you can have completely separate branches for all this stuff. It’s simpler and easier, but you’ll have to make sure that you don’t accidentally cross the paths.

EDIT: The spaces between the brackets and the (else:)s are just there to keep the formatting from kicking in, you don’t need those.

thanks again, so let me pull out my list of questions.

-How do I make a choice change depends on you weight ($weight thing)
so like in 100-200 the choice is resist the food
and in 200< it is gobble the food
-Like in your game, how do i make the ending appear after i earned it
-How do i make “ending passage” change based on weight (ex : (situation, to escape you have to 300 weight points for de devil or something) you click continue, the devil comments on your weight, if weight 100-200, you do thing and leave fatter than before, wobbling outside| If weight 200< you cant leave because you immobile)
-How do i make dialogue change based on weight points, like [[ask helper]]
if 200 wg, it says, you are fat “name” you should try to lose some weight. if 200< it says, my god “name” you are obese, you should totally lose some weight, forces you to lose some weight"
-how do i make word appear and disappear and then make it a choice
(ex : “text : do you want to get fat?”
add another text :do you want to go thin| and when the thin dialogue appears (not a choice) the fat one becomes an option.

that’s all for now, sorry if it is confusing, im trying to make my best game yet!

1 Like

Most of those things can be done with the following function:

(if: $weight > number)[Too fat event] (else:)[Too skinny event]

To use a few of your questions as an example

(if: $weight > 200)[You gobble the food up.] (else:)[You resist the urge to eat the food.]

(if: $weight > 149)[(if: $weight > 199)[My god, Name, you’ve become really fat.] (else:)[Maybe you should lose some weight, Name.]]

As for making a word appear or disappear, that depends on what the parameters are that you want. If you want the words to only appear if a value is over a certain number (such as weight or some other score (like the boy or girl thing from above)) you can use the function

(if: $value > target)[ [[Option]] ]

Target being any number of your choice.

The double brackets being a hyperlink. You can also use this function to make an option only appear under a certain score by using “<” instead of “>”.

More complex examples can be found all over the code in TLR, especially in the battles and random events, so you can look over those to get a better idea on how to make it work.

I’m not sure how you can make custom names in this game, though, so I can’t help you in that department.

Edit: And remember to have a pre-init passage to set all your values before the player starts the game, otherwise the game may have a chance of breaking.

Yooo tysm, really tho, thanks for your support, im gonna try to make my best game yet!

1 Like

I wish you good luck on your endeavors and hope to see your game when it comes out.

1 Like