Variable issues

This is kinda a repeat topic, since it goes over something I already have a topic on. However, this is an issue entirely of it’s own. I’m attempting to make a combat system using a methos suggested be StephenHart in my other topic.

I posted this error in there, but I figured I might get a quicker response making a newer topic instead of waiting for someone to stumble on that one.

This is the error.

1 Like

It’s because choice script hates negative values. You can work around this limitation to use negative values, but I suggest you don’t as it will cause more issues along the way.

What I usually do to represent negative values is shift the 0 to another location. For example, 50 for neutral (zero). 0-49 negatives and 51-100 positives.

3 Likes

Thanks! With 50 as the neutral value, I can make it work.

Yeah, you can do *create neg_value "-5" (or *create neg_value 0-5) if I remember correctly, and it’ll “work”. But it’s semantically horrifying, so the above solution is probably better, where it works.

2 Likes

Honestly, I didn’t realize I was setting it to a negative value. I was attempting to set it to subtract 5 from the standard agility variable of 15. So instead of changing agility from 15 to 10, I was changing it from 15 to -5.

Apologies. I should have tested the code before I posted it :anguished:

As others have said, initialisation has to be a non-negative number, just that some numbers have to be more positive than others.

1 Like

Another trick I have found is to use startup.txt to simply declare the variables with value 0. I then have an init function to set the values, in which *set foo - 5 will work.

It does involve double-handling which is a downside although even that can be useful in obscure circumstances where you want to compare the effects of two sets of values via two different init functions.

2 Likes

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.