constantly get an ingame variable to have a script variable value

Status
Not open for further replies.

c0rp53

Villager
Member
Joined
Dec 4, 2015
Messages
5
Reaction score
0
First Language
Spanish
Primarily Uses
Hello guys, it may be something super simple but I'm just starting to understand scripting so I can't make it work.

I'm using Dekita's stats script

I need an ingame variable to constantly update and get the value of a script variable value, in this case an ingame variable to be always equal to a stat value.

how should I code it?

thanks in advance!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,715
First Language
English
Primarily Uses
RMMV
Linked Variables has been created just for this reason.


You just may not be able to use it to condition an event page, because that only happens when the map is triggered to be refreshed, and only a few things do that.
 

c0rp53

Villager
Member
Joined
Dec 4, 2015
Messages
5
Reaction score
0
First Language
Spanish
Primarily Uses
Linked Variables has been created just for this reason.

You just may not be able to use it to condition an event page, because that only happens when the map is triggered to be refreshed, and only a few things do that.
Wow! Thank you very much! It seems to be exactly what I was looking for. About the condition, will I be able to condition directly with the script variable just like Im already doing? In that case the topic can be closed.
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
Conditional Branch using a script call should work with script's variables.

Depending on why you want the stats params to be constantly placed into a set of game variables, the script Shaz provided only update when you do a map transfer (changing map), a good way to reduce lag compared to constant update. But if any info changed within the map, it will not get updated until the next map transfer. That's why you shouldn't use the game variables in the conditional branch as the stored variables will not change/update within the same map.

edit:

oops, it's map refresh, so it will work in the same map, just not right away but until the next refresh. but the reason not to use the variables in conditional branch is the same.
 
Last edited by a moderator:

c0rp53

Villager
Member
Joined
Dec 4, 2015
Messages
5
Reaction score
0
First Language
Spanish
Primarily Uses
I intend to use it for message purpose mostly. If it only updates when I change map, wouldnt it be the same as doing parallel process event with "set variable 1 equal to param 0" in every map?

I understood from the acript description that the variable updates when you're about to use, like mentioning it in a message.

Anyway, what if I modify Dekita's script to call Shaz's update everytime the user open the distribute screen? Could that be possible?

Edit: now that's interesting, may I ask when does the map refresh? Just for curiosity.
 
Last edited by a moderator:

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
If you are only using it for messages, it will be easier to call a common event to update the variables before the message.

This way you only need the update before a message is displayed, saving a lot of resources than having it running all the time.

As for Shaz's script, you can force an update by calling:

$game_map.refreshThat's also the answer to

Edit: now that's interesting, may I ask when does the map refresh? Just for curiosity.
map is refreshed whenever that is called.
 
Last edited by a moderator:

c0rp53

Villager
Member
Joined
Dec 4, 2015
Messages
5
Reaction score
0
First Language
Spanish
Primarily Uses
Thank you both, this topic is solved now.
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
You're welcome!
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,434
Reaction score
7,713
First Language
German
Primarily Uses
RMMV
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,715
First Language
English
Primarily Uses
RMMV
I'm not following the line of discussion here. None of the above is applicable. You do not need to refresh the map and you do not need to call a common event to update the variable.


The script lets you allocate a variable to a script call, and every time you want to access that variable, from anywhere (including another script, as long as it uses the $gameVariables.value(n) method), it will run the script call and return the result.


So it should work with other scripts, unless they do something weird to access the variables.


The variable will ALWAYS show the latest information. The thing I was saying about map refresh is that EVENTS are not checked on every single frame to see which page should be active - that only happens when something flags the map as needing to be refreshed. So depending on the script call you're allocating to the variable, it may or may not be able to be used as a condition on the event page (in the event conditions section). Using it in a conditional branch will ALWAYS work.


If you want to discuss this further to gain a better understanding, just report the thread and we'll reopen it for you.
 
Last edited by a moderator:
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

On my journey of character rework: I had this character, she was meant to be just a princess that joins your party. And at long term she was just uninteresting... So I tweaked her to be a rebel agaisn't the royalty before meeting up with the party.

Quick tip for any other ametuer pixel artists! When trying to create a colour palette, enabling Antialiasing can speed up the process of creating different shades! Just place your lightest colour and your darkest colour next to each other, select both pixels, and stretch it out!
Revolutionizing the JRPG Industry: Knocking on Doors.

Take that, murderhobos.
Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.

Forum statistics

Threads
106,054
Messages
1,018,580
Members
137,843
Latest member
Betwixt000
Top