ozu_Self – No-Frills Self-Variables

ozubon

surströmming?
Veteran
Joined
Oct 16, 2018
Messages
178
Reaction score
167
First Language
English
Primarily Uses
RMMV
ozu_Self 1.0
by ozubon

Introduction

This is a self-variable or event variable plugin using mere 13 lines of code. Self-variables are saved with the game save, and persist through maps.

Self-variables? What?
Instead of using game variables for every event you can give the event its own variables. All those times you make new game variables for single events and your game variables list gets longer and... bloated..er... This, like other self-variable plugins seeks to address that. When you think about it, why shouldn't events have their own variables?

How to use
Code:
* ===========================================================================
* Self-variables
* ===========================================================================
* A self-variable looks like this:
*
*       self(this)[Variable id]
*
* Now that you know that, all you have to do is come up with a variable id
* and set it to something!
*
* Let's say you want to set self-variable 1 to 9001
* Put this in a script call:
*
*       self(this)[1] = 9001
*
* Bonus:
* You can have variable id's with names instead of numbers, but they gotta
* be in quotation!
*
*      self(this)["garlic cloves"] = 10
*
* ===========================================================================
* Conditional branch
* ===========================================================================
* This uses standard javascript operators, but don't panic, it's easy!
*
* To check if self-variable 1 is indeed 9001, put this into the conditional
* branch script box:
*
*      self(this)[1] == 9001
*
* Don't use one lonely equal sign, one means set; two means compare!
*
* Here's some other operators:
*
*      Greater than: >                    Less than: <
*      Greater than or equal to: >=       Less than or equal to: <=
*      Not equal to: !=                   Equal and equal type: ===
*  
* This will return true because garlic cloves is more than 9:
*
*      self(this)["garlic cloves"] > 9
*
* ===========================================================================
* Math
* ===========================================================================
* These are the assignment operators:
*
*      Set: =                             Mod: %=
*      Add: +=                            Subtract: -=
*      Multiply: *=                       Divide: /=
*  
* So, to add 3 to garlic cloves you do this:
*
*      self(this)["garlic cloves"] += 3
*
* Given that garlic cloves was 10, it is now 13!
*
* Bonus: MV's own modulo always return positive, if you want ot use it
* it's a little extra finger work (or whatever you type with):
*
*      self(this)["garlic cloves"] = self(this)["garlic cloves"].mod(5)
*
* ===========================================================================
* Other events' variables
* ===========================================================================
* To access other events' variables all you have to do is replace "this" with
* the id of the event. Let's say you want to set event 2's variable 3 to 4:
*
*      self(2)[3] = 4
*
* Or check in a conditional branch if it is 4:
*
*      self(2)[3] == 4
*
* ===========================================================================
* Events on other maps
* ===========================================================================
* You can also access variables on events on other maps, to do that you
* specify the map id after the event id:
*
*      self(Event id, Map id)[Variable id]
*
* Let's say you want to set event 8 on map 7's potato variable to 6:
*
*      self(8, 7)["potato"] = 6
*
* Or check in a conditional branch if it is 6:
*
*      self(8, 7)["potato"] == 6
*
* ===========================================================================
* Setting game variables to event variables
* ===========================================================================
* Simply, set a game variable using Control Variables with script operand:
*
*      self(this)[Variable id]
*
* Some examples:
*
*      self(this)[40]
*      self(3)["pebbles"]
*      self(1, 2)["quarks"]
*

Terms of use
You don't have to credit me but I'd appreciate it!
For commercial use, you gotta credit me!

Plugin
https://raw.githubusercontent.com/ozubon/tidbits/master/ozu_Self.js
Right-click link -> Save As

Credit
ozubon
 
Last edited:

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,416
Reaction score
4,479
First Language
English
Primarily Uses
RMMV
This is actually quite helpful. Simple, but practical. I like it.
 

pasunna

Veteran
Veteran
Joined
Feb 3, 2019
Messages
528
Reaction score
248
First Language
thai
Primarily Uses
RMMV
edit...
never mind didn't see there are scrolls able in my tablet -....-

-----------
hi where to put the code
note tag comment or script call
 
Last edited:

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,418
Reaction score
669
First Language
Portuguese - Br
Primarily Uses
RMMV
Hi!
I think the link is wrong. It is redirecting to ozu_File.js
 

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

Latest Threads

Latest Profile Posts

Besides my Might and Magic inspired project, I have always wanted to make a Fire Emblem-like game. Time is the culprit... Between life, composing music packs, and working on a game can it be done!? The tactical plugins for MV work quite well based on what I have tested.
Yaaay! My second public script is out and approved! A VX Ace Final Fantasy IX styled Throw Script!

I look forward to all the constructive feedback I get but most importantly I hope everyone who ends up using it enjoys!

Yaaaay! Making scripts is fun lol. :D
When you're lost out therrrrre and you're alllll alone, ahwahwah waitin, to carry you hooooommmme, uhhheverywhere you look! (someone hit me with those backing vocals)
X.X cant focus... too many thing want do... help!
Day 2 of teaching MV, student can move cat across the map.

Forum statistics

Threads
100,525
Messages
976,816
Members
132,080
Latest member
nwr
Top