v6 Variable Guide

Get started with the upcoming AAO version 6.

Moderator: EN - Forum Moderators

User avatar
Enthalpy
Community Manager
Posts: 5169
Joined: Wed Jan 04, 2012 4:40 am
Gender: Male
Spoken languages: English, limited Spanish

Re: Enthalpy's v6 Variable Guide

Post by Enthalpy »

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
Mertens
Posts: 5
Joined: Wed Jul 15, 2020 3:14 am
Gender: Male
Spoken languages: Español, Inglés

Re: Enthalpy's v6 Variable Guide

Post by Mertens »

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
User avatar
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

Post by Tiagofvarela »

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
Assume I have a variable named theory. Here's what I do:
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
User avatar
drvonkitty
Posts: 567
Joined: Sat Apr 14, 2012 12:25 am
Spoken languages: English

Re: Enthalpy's v6 Variable Guide

Post by drvonkitty »

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.
Image

Image
User avatar
TimeAxis
Posts: 389
Joined: Fri Jan 01, 2021 8:27 pm
Spoken languages: English
Contact:

Re: Enthalpy's v6 Variable Guide

Post by TimeAxis »

drvonkitty 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.
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 as

Code: Select all

x + 1
It should look like this:
Image
Image
Question Arcs (Threads Coming Eventually)
ImageImageImageImage
Gaiden Episodes
Champion of Turnabouts ★
HALLOWEEN HERO
Other
Phoenix Wright: Ace Attornauts
The Curious Case of the Phantom Limousine (Coming Eventually)
The Imposter's Turnabout (Coming Maybe)
User avatar
drvonkitty
Posts: 567
Joined: Sat Apr 14, 2012 12:25 am
Spoken languages: English

Re: Enthalpy's v6 Variable Guide

Post by drvonkitty »

TimeAxis wrote: Wed Apr 13, 2022 10:08 pm -snip-
I see, so I have to press the scary button that I've never pressed before, got it :side:

Thank you!! Just tested it and it works perfectly!
Image

Image
User avatar
TimeAxis
Posts: 389
Joined: Fri Jan 01, 2021 8:27 pm
Spoken languages: English
Contact:

Re: Enthalpy's v6 Variable Guide

Post by TimeAxis »

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:

Code: Select all

((what_to_do = 'decrease') & obj_points - 1) | ((what_to_do = 'increase') & obj_points + 1) | obj_points
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:

Code: Select all

0 | false | 1
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:

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
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.
Image
Question Arcs (Threads Coming Eventually)
ImageImageImageImage
Gaiden Episodes
Champion of Turnabouts ★
HALLOWEEN HERO
Other
Phoenix Wright: Ace Attornauts
The Curious Case of the Phantom Limousine (Coming Eventually)
The Imposter's Turnabout (Coming Maybe)
User avatar
Enthalpy
Community Manager
Posts: 5169
Joined: Wed Jan 04, 2012 4:40 am
Gender: Male
Spoken languages: English, limited Spanish

Re: v6 Variable Guide

Post by Enthalpy »

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
Post Reply