Self Variable Script for RM VX Ace

Tsar CUBE

Villager
Member
Joined
Aug 24, 2013
Messages
9
Reaction score
1
First Language
Russian
Primarily Uses
Hi

I spent the last two days looking for a script that allows creation or use of self variables in events. It's useful for creating growing plants on farms etc.

All the stuff I found so far has broken links or is for MV...

There was one script on these forums called PK8's Self Data Suite. But all the links are dead as well.

Does anyone have a copy of the above script? Or at least something similar?
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@Tsar CUBE I have put a copy in my dropbox. You can get it here.
As my dropbox is fairly full, please post to tell me when you've dl'd it so that I can delete it.
 
Last edited:

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,492
Reaction score
408
First Language
German
Primarily Uses
RMMV
If i remember correctly Another Fen made one for the German Community, but the Website went down forever, here the Script without the Big Info explanation which is lost now.
Self Variables Script for Events:
Code:
class Game_System
 
  def self_variables(map_id, event_id)
    if map_id > 0 and event_id > 0
      # Erstelle Self-Variables-Hash wenn noch nicht vorhanden:
      @self_variables ||= Hash.new
      @self_variables[map_id] ||= Hash.new
      @self_variables[map_id][event_id] ||= Hash.new(0)
    else
      # Bei ungültiger Map-/Event-ID gebe einen leeren Hash zurück:
      Hash.new(0)
    end
  end
end


class Game_Interpreter
 
  def self_variables(event_id = @event_id)
    $game_system.self_variables(@map_id, event_id)
  end
end


class Game_Event

  def self_variables
    $game_system.self_variables(@map_id, @id)
  end
end
Self Variables Script for Actors:

Code:
class Game_Actor < Game_Battler
 
  def variables
    @variables ||= Hash.new(0)
  end
end


class Game_Interpreter
 
  def actor_variables(actor_id)
    actor = $game_actors[actor_id]
    actor != nil ? actor.variables : Hash.new(0)
  end
 
  def member_variables(member_index = 0)
    actor = $game_party.members[member_index]
    actor != nil ? actor.variables : Hash.new(0)
  end
end

Here some Examples of the Script and in General:

$game_system.self_variables([ID of your Map], [EventId])[Self Var Name/Number] = 1234

$game_system.self_variables([$game_map.map_id], [1])[Villager Gold] = 1234

Iam not sure about the brackets [] , long time not used this and never realy did so in the past. But its an awesome Script.

The moment you assign something to a Self Variable thats the moment it gets created. So no need for any previous Setup.
The Variables also get Safed in the Safefiles as far as i know, so no known Bugs or Problem known. But i dont have any more code examples. the call for the seccond one i dont have but should be no problem to paste something together with the available infos.
 
Last edited:

Tsar CUBE

Villager
Member
Joined
Aug 24, 2013
Messages
9
Reaction score
1
First Language
Russian
Primarily Uses
@Kes

I grabbed it!! Thanks a million!!!! I thought it was lost forever! :kaojoy:

@Bex Thank you too!! This is probably a very noob question but "$game_system.self_variables([ID of your Map], [EventId])[Self Var Name/Number] = 1234" sets the self variable? Is there an example of how to check in a condition branch whether that variable is above or below a certain number?
 

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,492
Reaction score
408
First Language
German
Primarily Uses
RMMV
1.
You could use inside of the Conditional Branch the Scriptline:
$game_system.self_variables([$game_map.map_id], [1])[Villager Gold] == 1000
or
$game_system.self_variables([$game_map.map_id], [1])[Villager Gold] >= 1000

This == or >= or <= is a condition, equal, equal or more, and equal or less. only < and > should also work.
+= is adding something to the Variable but the previous mentioned ones are for Conditional Branches

2.
If you want to use it inside the Eventcommand Script on Eventpage3 than i believe it was:
If $game_system.self_variables([$game_map.map_id], [1])[Villager Gold] >= 1000
"insert code to happen if yes"
else
"insert else stuff"
end

Iam not a Scripter and mostly very bad with Syntax, so you are lucky that i had to use this a few Times or partialy still have those Lines on my PC.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
How Bex wrote the syntax is correct, but it's unnecessary because the scripter already made a method in Game_Interpreter to simplify a thing.

So instead of goes like this
Code:
$game_system.self_variables([ID of your Map], [EventId])[Self Var Name/Number] = 1234
You can go by this in script command
Code:
self_variables[id] = 123
Where ID is variable id (you can put anything on it. Be a number, or a letter, or event a word)

If you want to access other event's self variable (assume in same map), you can go by this
Code:
self_variables(event_id)[id] = 123
 
Last edited:

Tsar CUBE

Villager
Member
Joined
Aug 24, 2013
Messages
9
Reaction score
1
First Language
Russian
Primarily Uses
@Bex @TheoAllen Thank you two so much! I think I get the idea of how it should work now, the examples will be a great reference :kaojoy:
 

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,492
Reaction score
408
First Language
German
Primarily Uses
RMMV
Thx TheoAllen, i didnt know that. Big thanks for sharing.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
However, the script is not flawless. In default switch, variable, self switch, the map refreshed as soon as those value changed. In this script, it doesn't. It's because it doesn't have signal to refresh the map like default script do. So, if you're using another script that let you use self variable as page condition, it won't change as soon as the self variable value changed. Take this as consideration. Idk how self data suite gonna handle this, maybe also consider to use that script instead, or maybe another scripter will fix this?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
It wouldn't take much to fix this. Just a command to set the refresh flag for the map in each variable/self switch/whatever that can be changed, just like Ace does it for variables and switches.
 

Tsar CUBE

Villager
Member
Joined
Aug 24, 2013
Messages
9
Reaction score
1
First Language
Russian
Primarily Uses
Hmm, well I guess I will give it a try with this basic script first. If it doesn't work for what I'm planning I'll just try the self data suit. If neither works I guess it'll be back to the drawing board for me :kaoswt:

Edit: The basic script you guys posted seems to work well so far.
 
Last edited:

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,492
Reaction score
408
First Language
German
Primarily Uses
RMMV
Thanks for the explanation. But it never occured to me to use Self Variables for Eventpageconditions, always triggered a Selfswitch when needed in those cases,
Common Event or other Map Event controlled the Damage for the Self Variables for Monster HP, the Events used a Event ID Pointer to safe me the work of making all that conditional branches.

For Plant Growing is also a good Idea and it safes you from probably a dozen tons of repetitive workload.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,864
Messages
1,017,056
Members
137,573
Latest member
nikisknight
Top