Self Variables?

Mistral

Villager
Member
Joined
Jul 14, 2012
Messages
18
Reaction score
4
First Language
French
Primarily Uses
RMMV
Hi!

I guess the title is self-explanatory. Is there a way to have self variables? Using regular variables isn't really effective and rather time consuming when you have multiple events that works the same way. I'd like to just copy them without worrying about changing a bunch of variables each time, and risking to forget some or see errors arise.

So yeah, is it possible or does it need a plugin?
 
Last edited by a moderator:

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
856
First Language
German
Primarily Uses
It's possible, but needs a plugin. I currently don't have access to MV or my test project and i'm pretty sure some one else will have come up with a script before i get home, but i can do this in ~8 hours ^^
 

Mistral

Villager
Member
Joined
Jul 14, 2012
Messages
18
Reaction score
4
First Language
French
Primarily Uses
RMMV
That would definitely be awesome of you if you could do it! But don't worry, I'm in no rush at all, take as much time as you need :')
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
28,954
Reaction score
6,666
First Language
German
Primarily Uses
RMMV
Just keep in mind that you can't condition self-variables directly in the editor, you'll always need a script line to access them. That is because the editor doesn't know them itself, they will only exist in the game engine - similiar to PK8's self-data-suite of Ace (that is incompatible to MV)
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
856
First Language
German
Primarily Uses
Just calling back that i'm basically finished and adding a whole bunch of plugin commands to make it easier to interact with the container, so you don't everytime have to write

Code:
$gameSelfVariables.setValue([mapId, eventId, key], value);
 

Mistral

Villager
Member
Joined
Jul 14, 2012
Messages
18
Reaction score
4
First Language
French
Primarily Uses
RMMV
@Andar - Yeah, I know. To be honest, I kinda hoped it would work with Tsukihime's Custom Page Conditions, but now that you mention it I'm afraid it's not gonna be the case.

@Iavra - That's awesome! And it's nice to add them, even if it doesn't bother me that much to use script calls. Thank you for doing it so quickly!
 
Last edited by a moderator:

MuteDay

Mutation Engine
Veteran
Joined
Oct 19, 2015
Messages
253
Reaction score
39
First Language
English
@Andar - Yeah, I know. To be honest, I kinda hopped it would work with Tsukihime's Custom Page Conditions, but now that you mention it I'm afraid it's not gonna be the case.

@Iavra - That's awesome! And it's nice to add them, even if it doesn't bother me that much to use script calls. Thank you for doing it so quickly!
it will be able to be used with custom page conditions, just use a script call and a conditional branch using the script option, although takes a small understanding of programming, but very small here is image

of how i do it using vlue's quest system

quest with page condition.png

as you can see with script calls you can easlily do pretty much anything :)
 

Mistral

Villager
Member
Joined
Jul 14, 2012
Messages
18
Reaction score
4
First Language
French
Primarily Uses
RMMV
Just as i hoped then! That's what I did when I was still working on a VXAce project, I shouldn't be too lost. Thanks for the heads up!
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
856
First Language
German
Primarily Uses
So, i haven't included everything you can do with regular variables (to be exactly, the "Game Data" option. I might do, if there's enough interest, though).

The plugin is here: http://pastebin.com/fGnQBBPB

Parameters

@param Container Name@desc Name of the self variables container. Default: $gameSelfVariables@default $gameSelfVariables@param Plugin Command@desc Name of the plugin command to manage self variables. Can't control whitespaces. Default: SelfVariable@default SelfVariableHow to UseAdds self variable to the game. These work similar to self switches and are uniquely identifies by a map id, an event id and a key (any string without whitespaces). This documentation assumes, that the plugin parameters "Container Name" and "Plugin Command" are set to their default values.

Basic access to self variables is done via script commands:

Code:
$gameSelfVariables.setValue([mapId, eventId, key], value);$gameSelfVariables.value([mapId, eventId, key]);
To access a self variable of the current event, the following script command can be used:
Code:
$gameSelfVariables.get(this, key);
Self Variables can also be modified via plugin commands. The following operations are available:
Code:
=   Sets a self variable to a given value.+   Adds a given value to a self variable.-   Subtracts a given value from a self variable./   Divides a self variable with a given value.*   Multiplies a self variable with a given value.%   Sets a self variable to the remainder when dividing it with a given value (mod).
To apply one of these operations, one of the following commands can be used:
Code:
SelfVariable key operation value             // Invokes an operation with a given value.SelfVariable key operation v[value]          // Invokes an operation with the value contained in a given variable.SelfVariable key operation self[value]       // Invokes an operation with the value contained in a given self variable.SelfVariable key operation (value1 ~ value2) // Invokes an operation with a random integer between 2 values.SelfVariable key operation "value"           // Evaluates the given expression as an integer and invokes the operation with it.
Further plugin commands are:
Code:
SelfVariable key abs                         // Sets a self variable to its absolute value.
 

MuteDay

Mutation Engine
Veteran
Joined
Oct 19, 2015
Messages
253
Reaction score
39
First Language
English
Just as i hoped then! That's what I did when I was still working on a VXAce project, I shouldn't be too lost. Thanks for the heads up!
your welcome, and hope it helps you get your game out faster :)
 

Mistral

Villager
Member
Joined
Jul 14, 2012
Messages
18
Reaction score
4
First Language
French
Primarily Uses
RMMV
Thank you so much! It works as intended, for the most part at least. Well, there're two things I can't get to work. 

First, I don't know if I'm doing something wrong (which might be the case) but no matter what I try, plugin commands don't work. I did the following : http://i.imgur.com/6RHtjoP.png and the first condition is met but not the second, and -10 is printed to the console each time. I'm probably doing something wrong but I can't for the life of me figure what.

The second problem is in relation to Tsukihime's Custom Page Conditions, which I mentioned earlier. It does work with a regular variable ( with the variable and script command of the conditional branch) but when I do this it doesn't. I guess it's because the two are not compatible, sadly (or I'm doing doing something wrong again). (and the first page of the event is this one, which works )

That said, if you don't have the time to work on compatibility between the two, I'll totally understand, especially since you've already done a wonderful job doing this whole plugin D: (which I thank you again for!)
 
Last edited by a moderator:

MuteDay

Mutation Engine
Veteran
Joined
Oct 19, 2015
Messages
253
Reaction score
39
First Language
English
with page conditions try >10 and see if that works, i would test this but currently my game is broke due to new plugin
 

MuteDay

Mutation Engine
Veteran
Joined
Oct 19, 2015
Messages
253
Reaction score
39
First Language
English
ok fixed mine, so now ill be able to test it and see how it works
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
856
First Language
German
Primarily Uses
First, I don't know if I'm doing something wrong (which might be the case) but no matter what I try, plugin commands don't work. I did the following : http://i.imgur.com/6RHtjoP.png and the first condition is met but not the second, and -10 is printed to the console each time. I'm probably doing something wrong but I can't for the life of me figure what.
Remove the '' in the plugin commands, so
SelfVariable 'meow' + 1becomes
Code:
SelfVariable meow + 1
Regarding Hime's plugin: The "get" function only works as long as "this" refers to the Game_Interpreter instance, so it won't work in this case. I'll try to find a better way to get the current event./edit: I don't think there's an easy solution, so you probably have to replace these "get" calls with "value" and build the keys :/

//edit: This should do the same thing as Hime's Custom Page Conditions, but is compatible to my plugin (and everything else that relies on "this" in script commands): http://pastebin.com/qn7XJkmL
 
Last edited by a moderator:

Mistral

Villager
Member
Joined
Jul 14, 2012
Messages
18
Reaction score
4
First Language
French
Primarily Uses
RMMV
( I planned on replying sooner but got caught up with work and chores D: )

@MuteDay - It doesn't work either D:

@Iavra - I was sur I did test it without, but did not have any result either. So I tested it and printed the results to the console and it kinda works, except for the addition and subtraction, it seems.

Concerning the page condition, I almost missed your last edit :') It works like a charm! Thank you so much for taking the time to do this, it's really kind of you to help me.

And last thing I totally forgot earlier. There's an error when trying to save (with a fresh project without other plugins nor saves) : this. (I feel bad reporting all those errors, I wish I could resolve them myself D: )
 

MuteDay

Mutation Engine
Veteran
Joined
Oct 19, 2015
Messages
253
Reaction score
39
First Language
English
lol dont feel bad, thats why you have a whole community of coders to fix the bugs you are getting
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
856
First Language
German
Primarily Uses
The issues should be fixed now: http://pastebin.com/fGnQBBPB


What changed:


- Parameters weren't converted to integers and while this doesn't matter for other operations, "+" on strings will concat them. That's why "6 + 2 = 62".


- The "-" was recognized as a special character by the regex, so i had to escape it.


- I forgot to return the JSON object, after adding $gameSelfVariables to the save contents <.<


/edit: I also increased the performance of my string-to-number conversions by using a 0 bit-wise shift (value >> 0) instead of parseInt(value). Although this shouldn't really matter, unless you are modifying a lot of self variables.


I officially released this plugin (along with the port of Customt Page Conditions) here: http://forums.rpgmakerweb.com/index.php?/topic/51106-iavra-self-variables/
 
Last edited by a moderator:

Mistral

Villager
Member
Joined
Jul 14, 2012
Messages
18
Reaction score
4
First Language
French
Primarily Uses
RMMV
Everything works perfectly! I can't thank you enough for the work you've done. The community is lucky to have such patient and skilled members. Thank you again!
 

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

Latest Threads

Latest Profile Posts

Either I just had one of those dreams where you think you're awake, or I have time traveled. I woke up at 6:58am this morning, heard my father leaving for work, laid back down, now its 1:16am.
So the overhaul on my project has been going great, I like this version of the project a lot more. It's more contained and less overly ambitious for what I can achieve given my constraints on time, money, and skills in advanced programming. I'm going to wait till my project is mostly finished to begin working UI polish again. I'm going to learn how to use LUNA MV to polish the project.
last time i used this site i was a different gender.. wow rlly makes u think... anyway transing ur gender is pretty cool and theres hair growing on my feet now 10/10
I should have listened to RPGMAKER Meme thread. I should have backed up my data. The Orphan of Time, my WIP, is completely gone, all those hours of work are completely gone :(
God what was my life before smartphones (I had a grandma's phone before wednesday)

Forum statistics

Threads
93,381
Messages
911,850
Members
122,884
Latest member
yPhangon
Top