0 votes
by (120 points)
Im new in twine
i want to set the $personality by choices
Slap the personality will be rude
help the personality will be good
hide the personality will be shy

and i want to set choices to each personality
Rude
[[Slap with wood]]

[[Attack with knife]]
Good
[[Say sorry]]
[[Bribe]]

thank you for the help

2 Answers

0 votes
by (6.2k points)
(link: 'Slap the noob.')[(set: $rude to it +1)]
(link: 'Help the noob.')[(set: $good to it +1)]
(link: 'Hide from the noob, becoming yourself another noob!')[(set: $shy to it +1)]

You can also put the (goto:) macro inside the link if you want it to take the player to a passage.

by (159k points)
edited by

@cj
Remember to initialise (assign a default value) all story variable within your project's startup tagged special passage.

If your project doesn't have such a Passage yet simply create a new Passage and name it whatever you like (I name mine StoryInit for historical reasons), then assign this new passage a startup Passage Tag (all lower case letters)

The variable initialisation for @Deadshot's above suggestion would look something like

(set: $rude to 0)
(set: $good to 0)
(set: $shy to 0)

 

by (6.2k points)
If you don't initialise a variable then start using it, it will default to 0.
by (63.1k points)
This is an undocumented feature of Harlowe's engine. While I wouldn't expect it to change, you shouldn't rely on it. Also, that's not really what happens. The value isn't 0, it's undefined. Harlowe replaces undefined values with 0s when a command using an undefined value is run. This is fine for the most part, but uses processing power you don't need, and relies on the engine to pick up your slack and correct your errors. It also only works with numbers, so you need to initialize every other type of value anyway. Initializing your numbers too is just a good idea.

In general, Harlowe has a lot of features designed to massage errors into something runnable, but not having errors in your code in the first place is always the best way to approach it.
0 votes
by (159k points)

You could use Setter Links like those suggested by @Deadshot to assign a String value to your $personality story variable.

1. Initialise $personality to it's default value within your project's startup tagged special passage.
(I will assume the default is an empty String value, you may want to use a different default value)

(set: $personality to "")


2. Use Setter Links to change the value of $personality

(link: "Slap related option")[(set: $personality to "rude")]
(link: "Help related option")[(set: $personality to "good")]
(link: "Hide related option")[(set: $personality to "shy")]

 

...