Self Variables

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,079
First Language
English




This plugin introduces the concept of "Self Variables" for your events.

Similar to Self Switches, each event can hold its own set of self-variables, which you can use to keep track of things like how many times you've interacted with the event, or the last position of the player that this event has seen, or anything else that you would like each event to keep track of on their own.

An event can have as many self-variables you want as long as you find an appropriate name for them.

Unlike self-switches, which only hold a true or false value, self-variables can hold any kind of information. Because you can access them using script calls, they can be used in conditional branches and other parts of your event to create intricate events that interact with the player or the game itself!
 
More information and downloads available at HimeWorks
Self-variables can also be accessed using Custom Page Conditions, allowing you to create page conditions based on self-variables.
 
Last edited by a moderator:

Ghost of Christmas Kloe

Ghost of a Princess Seagull
Veteran
Joined
Nov 15, 2015
Messages
1,504
Reaction score
914
First Language
English
Primarily Uses
N/A
This is super awesomely cool! I love it, now I can have many, many, many variables!!  BD
 

Capri

Villager
Member
Joined
Mar 30, 2014
Messages
7
Reaction score
1
First Language
German
Primarily Uses
Is this like Iavra Self Variables script? I'm tempted to use yours for better compatibility with your other scripts. But can I access self variables from another map?
Also, if I clone an event with EST's "Clone Transform Delete Event" script, would it clone the self variables, too? (I'll assume it won't, but I think it would be a nice feature...)
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
860
First Language
German
Primarily Uses
It should not be compatible with Hime's custom page conditions (but with mine). Other than that, it does exactly the same, without plugin commands.


/edit: I see, the page condition plugin has been altered to use my way, instead, so it does work ^^


Both self variable plugins might be incompatible, btw, as we are using the same class name.
 
Last edited by a moderator:

Ghost of Christmas Kloe

Ghost of a Princess Seagull
Veteran
Joined
Nov 15, 2015
Messages
1,504
Reaction score
914
First Language
English
Primarily Uses
N/A
Both self variable plugins might be incompatible, btw, as we are using the same class name.
Thats probably ok though, since two self-variable plugins on one project is rather excessive so most people would use one or the other!
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,079
First Language
English
Is this like Iavra Self Variables script? I'm tempted to use yours for better compatibility with your other scripts. But can I access self variables from another map?


Also, if I clone an event with EST's "Clone Transform Delete Event" script, would it clone the self variables, too? (I'll assume it won't, but I think it would be a nice feature...)
1. It's similar. I think the biggest difference is I haven't implemented ways to operate on them as numbers.


2. Self-variables are stored globally, so they can be accessed from outside of the event, but I would not recommend doing that because "self" variables are meant to be private to each event.


The reason why they are not stored with the event (despite being "self" variables) is because events are not stored in savefiles by default.


3. Because they are stored globally (and not with the event itself), it won't be cloned with the event (though that depends on how the event cloning works as well)

It should not be compatible with Hime's custom page conditions (but with mine). Other than that, it does exactly the same, without plugin commands.


/edit: I see, the page condition plugin has been altered to use my way, instead, so it does work ^^


Both self variable plugins might be incompatible, btw, as we are using the same class name.
Didn't notice there was already a self-variables plugin. I see that you have implemented functions for manipulating the variables as well without having to do it all through scripts, which is more user-friendly.
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,079
First Language
English
Plugin has been updated to allow you to specify event ID and map ID in the script calls.

This allows you to have an event operate on other events' self-variables.

Usage is similar

Code:
// set self-variable "my variable name" to 3, for current eventthis.set_self_variable("my variable name", 3)// set self-variable "my variable name" to 3, for event 4this.set_self_variable("my variable name", 3, 4)// set self-variable "my variable name" to 3, for event 4, on map 5this.set_self_variable("my variable name", 3, 4, 5)
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,079
First Language
English
Just wanted to mention that self-variables can be used in move routes now using the same script calls.
 

Blue001

Veteran
Veteran
Joined
Jan 13, 2014
Messages
231
Reaction score
111
First Language
English
Primarily Uses
RMMV
Is there a text control for displaying a self variable in a message???


Like /sv[''] or something?
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,079
First Language
English
Is there a text control for displaying a self variable in a message???


Like /sv[''] or something?


That would be somewhat complex, since a self-variable requires three pieces of information


1. A map ID


2. an event ID


3. a variable ID


Some other issues come to mind.


1. it probably isn't useful to *hardcode* a map ID or event ID, because you probably want different events to say different things based on what their own self-variables are (otherwise you would probably just use a regular game variable).


2. Even if hardcoding the ID's are ok, when a message is being displayed, it would need to know *which* event called the message, and there's no guarantee that a message was displayed due to an event (because a message can be displayed by any object, and not just the "show text" command)


What do you think of these two problems?
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
860
First Language
German
Primarily Uses
From Window_Message (which is the part that translates escape codes), it's not possible to know, which event triggered the message. You have 2 options:


- Add a new property to Game_Message, that gets set by the interpreter, that requested the message. Could lead to some side effects, though, since the message lifecycle is somewhat complex.


- Create the escape code with 3 parameters, so you can uniquely identify the self variable. More to write for the user, but trivial to do.
 

Blue001

Veteran
Veteran
Joined
Jan 13, 2014
Messages
231
Reaction score
111
First Language
English
Primarily Uses
RMMV
What do you think of these two problems?


Well, is there a script you can call from an event to save one of it's self variables into a global variable, so we can just use \v[#]?
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,079
First Language
English
From Window_Message (which is the part that translates escape codes), it's not possible to know, which event triggered the message. You have 2 options:


- Add a new property to Game_Message, that gets set by the interpreter, that requested the message. Could lead to some side effects, though, since the message lifecycle is somewhat complex.


- Create the escape code with 3 parameters, so you can uniquely identify the self variable. More to write for the user, but trivial to do.


Yes, my first thought was to provide 3 parameters, but then I was thinking "what if they wanted each event to display a message using their own self-variables?"


And then things just went downhill from there.


I am not a fan of the way the message is designed, since it treats Game_Message as a global variable. So if you had an event call a common event (which does not have self-variables), things won't go well.

Well, is there a script you can call from an event to save one of it's self variables into a global variable, so we can just use \v[#]?


You could do that with a script call


$gameVariables.setValue(2, this.get_self_variable("SomeVar"))


Which sets your "SomeVar" self-variable into game variables 2.


Then you can use \v[2] in your message.


I might actually just go with this kind of thing


\vs["SomeVar", 3, 10]


Which means self-variable "SomeVar" from event 3 on map 10, to avoid having to do that manual setting.


It means you won't be able to just copy-paste the event and have it work automatically, but it's still better than nothing.
 
Last edited by a moderator:

mimi-min

Will draw for food.
Member
Joined
Apr 24, 2016
Messages
16
Reaction score
8
First Language
English
Primarily Uses
RMMV
Plugin has been updated to allow you to specify event ID and map ID in the script calls.


This allows you to have an event operate on other events' self-variables.


Usage is similar



// set self-variable "my variable name" to 3, for current eventthis.set_self_variable("my variable name", 3)// set self-variable "my variable name" to 3, for event 4this.set_self_variable("my variable name", 3, 4)// set self-variable "my variable name" to 3, for event 4, on map 5this.set_self_variable("my variable name", 3, 4, 5)


I'm not sure I understand correctly, I'm getting confused with all the numbers. Is it possible to explain it in a different way, maybe using *A*, *B*, *C* for the "eventId" in this example? Sorry, I'm kind of slow.


Would it be possible to alter an event's variables based on an event Id that's passed through using a variable? Like grabbing the event Id from the object to the player's left, passing that through and causing it's "color" variable to 4.


Edit: Never mind, I think I got it after separating it out in notepad. So it goes like this, right?


this.set_self_variable("my variable name", x, y, z)


Where x is the value, y is the event id and z is the map id? Don't know why I'm asking, I'm sure that's probably it. It seems obvious now. ^^;


Thank you for the awesome plugin!
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,079
First Language
English
I'm not sure I understand correctly, I'm getting confused with all the numbers. Is it possible to explain it in a different way, maybe using *A*, *B*, *C* for the "eventId" in this example? Sorry, I'm kind of slow.


Would it be possible to alter an event's variables based on an event Id that's passed through using a variable? Like grabbing the event Id from the object to the player's left, passing that through and causing it's "color" variable to 4.


Edit: Never mind, I think I got it after separating it out in notepad. So it goes like this, right?


this.set_self_variable("my variable name", x, y, z)


Where x is the value, y is the event id and z is the map id? Don't know why I'm asking, I'm sure that's probably it. It seems obvious now. ^^;


Thank you for the awesome plugin!


Yes.



Basic usage is just


this.set_self_variable("var name", value)

This assumes you're working with "this" event, which is the one that's making the script call.


However, if for some reason you wanted "this" event to access other events, you would specify the Id of the event, and the map that event is on.


Note that you could have "this" event send its own value to other events.
 
Last edited by a moderator:

Kanoonoo

Todd George Kelly
Member
Joined
Jun 10, 2016
Messages
18
Reaction score
2
First Language
English
Primarily Uses
Question:


If I want to set a self variable to the current value of a global variable, can I do this and how?
 

Raen Andaleio

Veteran
Veteran
Joined
Aug 3, 2014
Messages
99
Reaction score
18
First Language
German
Primarily Uses
I get the error "TypeError - Cannot read property 'setValue' of undefined".


My code:


this.set_self_variable("regrow", 1);


When I try to use the code from the tutorial video


var oldVal = this.get_self_varialbe("talk_count") || 0;


I get "TypeError - Cannot read property 'value' of undefined".
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 2)

Latest Threads

Latest Posts

Latest Profile Posts

Did you know that we use robotic spy animals to learn about how different species behave in the wild? We're only a step away from robotic spy humans, and then Terminator. :p
Not being able to do a commission/request after all and having to give back the money is so heartbreaking.

Sometimes I'm just way too eager to help people out and suddenly find myself in a very deep hole because I'm not gonna be able to finish it. I really hope I don't come across as unprofessional to these people and in general. =n="
Learning Action Sequences!
ANY FEEDBACK APPRECIATED!

Online Platformer TEST DEMO 0.1 - 4 simple Maps. Just jumping test. (I still have 2 minor problems to fix).
So ms store had an idea to nuke the the entire app when the file integrity is slightly broken.

Forum statistics

Threads
98,044
Messages
948,793
Members
129,307
Latest member
kayahowayarshh
Top