ozubon

surströmming?
Veteran
Joined
Oct 16, 2018
Messages
178
Reaction score
170
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,934
Reaction score
4,847
First Language
EN, FR
Primarily Uses
RMMZ
This is actually quite helpful. Simple, but practical. I like it.
 

pasunna

Veteran
Veteran
Joined
Feb 3, 2019
Messages
531
Reaction score
278
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
2,043
Reaction score
1,519
First Language
Portuguese - Br
Primarily Uses
RMMZ
Hi!
I think the link is wrong. It is redirecting to ozu_File.js
 

KotoYama

Veteran
Veteran
Joined
Apr 20, 2019
Messages
358
Reaction score
51
First Language
Spanish
Primarily Uses
RMMV
Damn, this is huge! Thank you so much :0 What a brilliant plugin!
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

Ami
need a time to not open my MV,still addicted with new vegas

i wonder what addiction effect behind playing new vegas too much,maybe INT & Science gone worse in many days :D
cdjensen94 wrote on Kaliya's profile.
Are you the one who develops Kaliya's Visual Map Enhancements. If so I desperately need some help. I bought the plugin back a few months. I've only started using it recently.
Cause MP Damage instead of HP, Localization Plugin for Translation | RPG Maker News #112

Here in Fla were are seeing crazy covid spikes and some vaccinated getting bad infections. I had a mild fever on Thurs but it went down fast. How is everyone else doing. Hopefully you are all well. :)
Wish I was better at art, specifically that I was faster at it, bc this one NPC took Several Days to complete! It's gonna take So Extremely Long to do all of the art for my game, never mind writing it... Anyways, here's my gorgon, Hopernica Sthyxis!

57b88732c7abbcd84981dacf624a98495af61fcc.gifv

Forum statistics

Threads
113,832
Messages
1,077,783
Members
147,892
Latest member
rosefinch
Top