Twine version is 2.7.1.0. Very new so sorry if this is a simple question. I am trying to update a variable when the player takes an item to track an inventory system but I’m getting the error that “A (set:) operation can’t have changers like (if:) attached.
Changers placed just before hooks, links and commands will attempt to attach, but in this case it didn’t work.”
my code looks like:
(set:$HandSpace to 2) ```
and then:
``` [Take the candle (if:$Handspace > 0) (set:$Candles to it + 1) (set:$HandSpace to it - 1)] ```
Obviously there's some dialogue and other parts etc but it seems to just be the variables that aren't working and I'm not sure why this operation wouldn't be possible.
@Parils (and @n-n in regards to a “Link with Setter”)
A couple of points:
1: The triple back-quote ``` markers use by this forum’s Code Block markup need to be place at the start of an otherwise empty/blank line…
eg.
```
your code between the two lines that only contain the markers.
```
2: Many Harlowe macros (like (for:) and the (if:) family) need to be associated with a Hook.
eg. (if: $variable is "value")[content to process if the condition is true]
3: One of three “link” macros are generally used to create what’s knows as a “Link with Setter”, which you use depends on:
if a Passage Transition should also occur.
if the link can be selected multiple times without a Passage Transition occurring.
3a: The (link-reveal-goto:) macro is used if a Passage Transition is wanted.
(link-reveal-goto: "Pick", "Start")[(set: $handspace to it - 1)]
3b: The (link-repeat:) macro is used if multiple selections within the current Passage is wanted.
(link-repeat: "Add one to counter")[(set: $counter to it + 1)]
3c: The (link:) macro (aka (link-replace:)) is used in most other use cases.