Linked Variables

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,654
Reaction score
13,265
First Language
English
Primarily Uses
RMMV
Linked Variables

2015.11.11

by Shaz

Introduction

This plugin allows you to link variables to commands, so the command is evaluated and returned as the value of the variable. This allows you to use a variable in a conditional branch rather than a script call, or perhaps a series of commands to obtain a value and then check if it meets the condition (for example, "what is the region code of the tile where the player is standing?", which would take 3 event commands plus the conditional branch).

How to use

Add to your plugins folder (file name is not important, but I use LinkedVariables.js). There are no parameters to set.

You can either modify the script to add all the commands you want to link to variables, or you can set them up via plugin commands. Plugin commands remove the need to edit scripts, but mean the commands will be saved in each save file, and therefore could be manipulated by the player.

To set up links via the script, locate this section and add your commands in the appropriate format (the example below results in the party leader's HP being available through variable 1) - the example is commented out, but obviously you would not have comments on your lines:

Code:
//===========================================================================
// Add variable commands here to build with the game rather than in save file
// eg:
// variableLinks[1] = '$gameParty.leader().hp' 
//===========================================================================
To set up links via a plugin command, enter the plugin command in the appropriate format:
Code:
LinkVariable 1 $gameParty.leader().hp
Plugin
Download from pastebin

Credit

- Shaz

Terms

- free for use in commercial games

Notes

- this may not be reliable when used as a condition on an event page, as the conditions are only checked when a map refresh is requested. Only some actions that happen in a game cause this kind of refresh.

Feel free to post the kind of information you want to link to a variable below, and whether you'd like to link it in the script or via a plugin command, and I (and others) will tell you the appropriate command to use.
 
Last edited:

Ramiro

Now with an army of Mecha-Ralphs!
Veteran
Joined
Aug 5, 2015
Messages
860
Reaction score
366
First Language
Spanish
Shaz, I love this idea, and its pretty interesting.

As a suggestion, maybe another good plugin parameter would be:

UnlinkVariable <id>to remove the link attached.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,654
Reaction score
13,265
First Language
English
Primarily Uses
RMMV
You could possibly just do

Code:
LinkVariable 1
and it might put null in there. Might have to test it.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,418
Reaction score
671
First Language
Portuguese - Br
Primarily Uses
RMMV
Hi Shaz!
I was looking into your plugin, and i really like this ideia.
I understand correctly, if i'm use it and change the script to link my variables, i dont need to use control variables anymore, right?
I try to use that an make as the follows:

So i go to check if the variable 4 is equal to the leader hp:
◆Change HP:Entire Party, - 10
◆Text:None, Window, Bottom
: :\V[4]

But i get the result 0.

I do it right? Or this pherhaps this plugin dont work anymore?
RM MV 1.6.1

[EDIT] Nevermind... i'm dumb xD uhauahuahahahua
It worked now!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,654
Reaction score
13,265
First Language
English
Primarily Uses
RMMV
lol! Love it :D

The sad thing is, it would have taken me an embarrassing length of time to figure out what you did wrong!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

ESAMarathon on Twitch, now streaming "Eat Girl". Yep, that's the title of a game... Apparently it's a Pacman knockoff.... Which is of course the only logical conclusion one would get from a name like "Eat Girl". :kaopride: I can't believe anybody would think anything else! :kaoback:
Super stoked i just finished my first town in my project, by finished i mean i can always add more decorative aesthetics and the NPCs don't talk yet but the mapping is complete and all the important chess pieces are present!
My brain: Hey, I have an idea how to make the transition to the main story quest in The Wastes more natural!
Me: Good!
My brain: You need to remake the hotel you start out in, it's not realistic enough.
Me: Ok... This was unexpected, but I can do it.
My brain: Now make each hotel floor 5 times as large to match the main part. Oh, you also need to make a bunch of new npcs to fill in the space on these maps.
Me: Crap.
Should be able to release Haxe MV/MZ next weekend.
It look that somehow MZ tracks are messed up (for example battle4 is obviously a theme, castle2 is a ship, ship1 is a scene and so on..). Maybe they just named them after with some ambiguity.

Forum statistics

Threads
100,617
Messages
977,828
Members
132,227
Latest member
YourBaka
Top