v6 Variable Guide
Moderator: EN - Forum Moderators
- Enthalpy
- Community Manager
- Posts: 5217
- Joined: Wed Jan 04, 2012 4:40 am
- Gender: Male
- Spoken languages: English, limited Spanish
Re: Enthalpy's v6 Variable Guide
I've done some minor grammar and clarity fixes.
[D]isordered speech is not so much injury to the lips that give it forth, as to the disproportion and incoherence of things in themselves, so negligently expressed. ~ Ben Jonson
Re: Enthalpy's v6 Variable Guide
i wonder... how do I add something to a variable? I tried doing "Var = Var + 1" in the advanced mode but it changes the value to the expression, I also tried this "'Var' + 1" but it changes the value to "NaN" or something, then I tried it without the '' and like this (cause i saw someone saying it in the spanish version of this) "xpr = Var + 1" and it sometimes changes the value to false and others to the "var + 1"
What should I do? I do not understand what's wrong
What should I do? I do not understand what's wrong
- Tiagofvarela
- Posts: 357
- Joined: Thu Jun 26, 2014 7:16 pm
- Gender: Male
- Spoken languages: English, Portuguese
- Location: Portugal
Re: Enthalpy's v6 Variable Guide
Assume I have a variable named theory. Here's what I do:Mertens wrote:i wonder... how do I add something to a variable? I tried doing "Var = Var + 1" in the advanced mode but it changes the value to the expression, I also tried this "'Var' + 1" but it changes the value to "NaN" or something, then I tried it without the '' and like this (cause i saw someone saying it in the spanish version of this) "xpr = Var + 1" and it sometimes changes the value to false and others to the "var + 1"
What should I do? I do not understand what's wrong
https://i.imgur.com/wvk8YlU.png?1
A Laggy Turnabout ★
A Batty Turnabout ★
A Tricky Turnabout ★
Upcoming: A Worldly Turnabout, A Courtly Turnabout, A Clumsy Turnabout, A Needy Turnabout
A Batty Turnabout ★
A Tricky Turnabout ★
Upcoming: A Worldly Turnabout, A Courtly Turnabout, A Clumsy Turnabout, A Needy Turnabout
- drvonkitty
- Posts: 580
- Joined: Sat Apr 14, 2012 12:25 am
- Spoken languages: English
Re: Enthalpy's v6 Variable Guide
Hey, been brushing up on variables and returned to this guide, but I had one question that I haven't been able to figure out. Apologies if this is a noob question—I've never been good with the variables!
Let's say I have a variable X, and I want to modify that variable by adding 1 to it. So let's say on Frame 1, I define x = 0. Then, on frame 2, I want to add 1, so x = 1. Then frame 3, add 1, x = 2, so on and so forth. Is that possible?
My goal is to simplify investigation variables by combining multiple into one universal variable. The standard method is to define several variables, let's say "CrimeScene1, CrimeScene2, CrimeScene3" that we define with each examine, and then testing to make sure all of them equal 1. Instead, my idea is to have just one variable, "CrimeScene", and add 1 for each successful examine. Then, we hide the frame that adds 1 once we've completed that examine (so you have to complete each examine). That way we just test for "CrimeScene = 3" instead of the longer combination of several variables.
Let's say I have a variable X, and I want to modify that variable by adding 1 to it. So let's say on Frame 1, I define x = 0. Then, on frame 2, I want to add 1, so x = 1. Then frame 3, add 1, x = 2, so on and so forth. Is that possible?
My goal is to simplify investigation variables by combining multiple into one universal variable. The standard method is to define several variables, let's say "CrimeScene1, CrimeScene2, CrimeScene3" that we define with each examine, and then testing to make sure all of them equal 1. Instead, my idea is to have just one variable, "CrimeScene", and add 1 for each successful examine. Then, we hide the frame that adds 1 once we've completed that examine (so you have to complete each examine). That way we just test for "CrimeScene = 3" instead of the longer combination of several variables.
Re: Enthalpy's v6 Variable Guide
Yes, you can do this. You have to turn on Advanced mode, then check the "Load from runtime expression" box in the Variable value field, then whenever you want to add 1, you'd define x asdrvonkitty wrote: ↑Wed Apr 13, 2022 8:48 pm Hey, been brushing up on variables and returned to this guide, but I had one question that I haven't been able to figure out. Apologies if this is a noob question—I've never been good with the variables!
Let's say I have a variable X, and I want to modify that variable by adding 1 to it. So let's say on Frame 1, I define x = 0. Then, on frame 2, I want to add 1, so x = 1. Then frame 3, add 1, x = 2, so on and so forth. Is that possible?
My goal is to simplify investigation variables by combining multiple into one universal variable. The standard method is to define several variables, let's say "CrimeScene1, CrimeScene2, CrimeScene3" that we define with each examine, and then testing to make sure all of them equal 1. Instead, my idea is to have just one variable, "CrimeScene", and add 1 for each successful examine. Then, we hide the frame that adds 1 once we've completed that examine (so you have to complete each examine). That way we just test for "CrimeScene = 3" instead of the longer combination of several variables.
Code: Select all
x + 1
- drvonkitty
- Posts: 580
- Joined: Sat Apr 14, 2012 12:25 am
- Spoken languages: English
Re: Enthalpy's v6 Variable Guide
I see, so I have to press the scary button that I've never pressed before, got it
Thank you!! Just tested it and it works perfectly!
Re: Enthalpy's v6 Variable Guide
I've discovered a small wrinkle with the "Using & and | to set variable values" trick detailed here, and figured I should share it so that other people don't run into the same problem.
Essentially, it boils down to the fact that a value of 0 (even if it comes about as a result of a calculation) will be treated as "false" when evaluating these statements, meaning a value can never be set to 0 unless you're clever about it.
For example, let's say we had a variable called obj_points, and if a variable called "what_to_do" is set to 'decrease', we want to decrease "obj_points" by 1, but if it's set to 'increase', we want to increase it by 1. Otherwise, we don't want it to change. It would look something like this:
This seems like it should work, but when obj_points is set to exactly 1, it won't work. It'll never go down to 0. That's because it's reading the statement as:
And internally, 0 and false are treated as the same thing, so it will only ever execute the "1", side, which leaves your obj_points the same.
There is one way around this, however. You need to account for every non-zero possibility on the left, and then put the 0 assignment on the far right. The result would be something like this:
Now it will set the value to 0 whenever it's supposed to be set to 0. You just have to make sure you cover all the possibilities, or else you could get situations where it's defaulting to 0 and you don't want it to.
Essentially, it boils down to the fact that a value of 0 (even if it comes about as a result of a calculation) will be treated as "false" when evaluating these statements, meaning a value can never be set to 0 unless you're clever about it.
For example, let's say we had a variable called obj_points, and if a variable called "what_to_do" is set to 'decrease', we want to decrease "obj_points" by 1, but if it's set to 'increase', we want to increase it by 1. Otherwise, we don't want it to change. It would look something like this:
Code: Select all
((what_to_do = 'decrease') & obj_points - 1) | ((what_to_do = 'increase') & obj_points + 1) | obj_points
Code: Select all
0 | false | 1
There is one way around this, however. You need to account for every non-zero possibility on the left, and then put the 0 assignment on the far right. The result would be something like this:
Code: Select all
((what_to_do = 'decrease') & obj_points - 1) | ((what_to_do = 'increase') & obj_points + 1) | (!(what_to_do = 'decrease' | what_to_do = 'increase') & obj_points) | 0
- Enthalpy
- Community Manager
- Posts: 5217
- Joined: Wed Jan 04, 2012 4:40 am
- Gender: Male
- Spoken languages: English, limited Spanish
Re: v6 Variable Guide
Updated the expression engine function to discuss str_to_upper, str_to_lower, and player_health.
[D]isordered speech is not so much injury to the lips that give it forth, as to the disproportion and incoherence of things in themselves, so negligently expressed. ~ Ben Jonson
- Enthalpy
- Community Manager
- Posts: 5217
- Joined: Wed Jan 04, 2012 4:40 am
- Gender: Male
- Spoken languages: English, limited Spanish
Re: v6 Variable Guide
Updated the expression engine function to discuss the expressions added in the latest update. Descriptions adapted from those by TimeAxis.
[D]isordered speech is not so much injury to the lips that give it forth, as to the disproportion and incoherence of things in themselves, so negligently expressed. ~ Ben Jonson