Indirect Reference (Expression Engine)

Learn how to use AAO by reading tutorials, and seek help from the AAO community.

Moderator: EN - Forum Moderators

Post Reply
User avatar
RashFaustinho
Posts: 16
Joined: Fri Jun 03, 2016 11:34 pm
Gender: Male
Spoken languages: English

Indirect Reference (Expression Engine)

Post by RashFaustinho »

Hi, I'm searching a suggestion on how to use the Expression Engine in this situation!

In the game I'm building, i'm implementing a sort-of Dating Sim mechanic where the main character can decide which characters to spend time with, and increase his relationship with them.

To do this, I'm creating a variable for each character, with an hidden "score" that shows the level of friendship with the MC.
(example: Athena variable, value of 2)

Now, like Persona 5, I wanted to implement "free time" spaces, where the player can freely chose which character he should raise as a friend.

To do this, i created a variable called "FreeTime", asked a question with 4 options, and depending on the result, I stored the name of the character the player wants to spend time with in the "FreeTime" value (example: FreeTime variable, value: Athena)

Now, is there a way to tell the game to do this?
1) Check FreeTime Variable
2) Add 1 to the Variable whose name is equal to the Value of the FreeTime Variable

So, using my example, it would be:
Check FreeTime: FreeTime = Athena
Add 1 to "Athena" variable

Is this possible to do without using a bajillion of frames?
User avatar
Enthalpy
Community Manager
Posts: 5170
Joined: Wed Jan 04, 2012 4:40 am
Gender: Male
Spoken languages: English, limited Spanish

Re: Indirect Reference (Expression Engine)

Post by Enthalpy »

I don't think you can, but this should be an easy problem. What we'd need to add is a way to go from a string that specifies a variable name to the value of the variable named by that string...

I'll consider this to be included in the next AAO update or two.
[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
AceAttorneyMaster111
Posts: 468
Joined: Sat Sep 27, 2014 6:46 pm
Gender: Male
Spoken languages: English, français, un poco de español, עברית
Location: USA

Re: Indirect Reference (Expression Engine)

Post by AceAttorneyMaster111 »

In the meantime, it shouldn't take a bajillion frames to do this, I think you would only need two frames for each response plus the "check the value of FreeTime" frame. That frame should redirect to all of the other options based on what the response is. At each of those frames, you can increment the relevant variable and then at the next frame, redirect to where you want the dialog to continue.
User avatar
RashFaustinho
Posts: 16
Joined: Fri Jun 03, 2016 11:34 pm
Gender: Male
Spoken languages: English

Re: Indirect Reference (Expression Engine)

Post by RashFaustinho »

I noticed just now that if I use the expression check on variable's name, and set just "FreeTime" as expression, the game automatically picks the value of FreeTime as the name of Variable.

That might solve the problem about the variable's name itself, the only thing I need to understand now is how to tell him to add 1 to the score.

Isn't there a way to write "add 1" in a generic way, without writing "variable+1" in the expression engine?
In the meantime, it shouldn't take a bajillion frames to do this, I think you would only need two frames for each response plus the "check the value of FreeTime" frame.
It could (potentially) take a lot of frames, depending on how many characters will be implemented in this dating-sim-like mechanic.
Obviously, the easier is this to set-up, the more characters I would add.
User avatar
Enthalpy
Community Manager
Posts: 5170
Joined: Wed Jan 04, 2012 4:40 am
Gender: Male
Spoken languages: English, limited Spanish

Re: Indirect Reference (Expression Engine)

Post by Enthalpy »

That's what I was trying to say. It is specifically that task that I don't think AAO supports right now.

I would like to see that change, but it won't happen overnight, sadly.
[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
User avatar
RashFaustinho
Posts: 16
Joined: Fri Jun 03, 2016 11:34 pm
Gender: Male
Spoken languages: English

Re: Indirect Reference (Expression Engine)

Post by RashFaustinho »

I see, mmmh.

I'm thinking of a workaround right now, since Indirect Reference is not possible, maybe I can use a temporary variable to "store" the character's score, and then update it at the end.
That would take 1 or 2 additional frames per character at most.

Something like

Frame 1: Pick a character (store FreeTime value)
Frame 2: Set Temporary Score (TempScore Variable = That character value) 1 additional frame per char
Frame 3: Add or reduce by 1 TempScore, depending on choices.
Frame 4: Set the character's variable equal to TempScore (using "FreeTime as expression" as the name of the variable)

I'll try this one.

EDIT: Ok, this seems to work just fine, so I'll take it.
Thanks for the answers!
User avatar
Jofe
Posts: 14411
Joined: Fri Jun 10, 2011 1:44 am
Gender: Male
Spoken languages: Français [100%], English [70%]

Re: Indirect Reference (Expression Engine)

Post by Jofe »

Maybe I'm misunderstood what you want, but I think you can.

I made a quick exemple:

In the editor:

Image

Frame 2 et 4 are only here for the exemple, to show that the calculation was successful.

I define the original variable in the frame 1.

Frame 1:
Spoiler : :
Image
I With "Define new variables" advanced mode, I made the calculation in frame 3.

Frame 3:
Spoiler : :
Image
Ingame, it look like that.

Image

After the frame 3, +1 was added to the variable "athena".

Afterwards, you just have to trigger the events you want depending on the value of the variable. And avoid that the message is replayed if it is not wanted, otherwise it will add "+1" to the variable each time the message is replayed.
Image Image Image Image Image
User avatar
RashFaustinho
Posts: 16
Joined: Fri Jun 03, 2016 11:34 pm
Gender: Male
Spoken languages: English

Re: Indirect Reference (Expression Engine)

Post by RashFaustinho »

That couldn't ve been used only if I wanted to create a setup specific for each character, which I didn't want to.

The reason I cannot use "Athena" directly is because there are other characters, that variable changes with the choises of the player (that's the reason there was a "FreeTime" value to begin with), and this mini-game i'm planning is a bit complicated, it's not just adding a +1 (I know I described it like that, but still, it was to get to the point), but there will be a calendar system, a way to lose points, stuff like that.

It's not a problem anymore though, with the setup I wrote earlier I managed to find a good way to archive what I'm trying to accomplish:
RashFaustinho wrote:I see, mmmh.

I'm thinking of a workaround right now, since Indirect Reference is not possible, maybe I can use a temporary variable to "store" the character's score, and then update it at the end.
That would take 1 or 2 additional frames per character at most.

Something like

Frame 1: Pick a character (store FreeTime value)
Frame 2: Set Temporary Score (TempScore Variable = That character value) 1 additional frame per char
Frame 3: Add or reduce by 1 TempScore, depending on choices.
Frame 4: Set the character's variable equal to TempScore (using "FreeTime as expression" as the name of the variable)

I'll try this one.

EDIT: Ok, this seems to work just fine, so I'll take it.
Thanks for the answers!
Post Reply