It has happened to me before. I setup the properties i'm going to use in the beginning of the game to make sure they will exist when the time comes to check them!
Makai Object Variables
JS Plugin Releases (RMMV)It has happened to me before. I setup the properties i'm going to use in the beginning of the game to make sure they will exist when the time comes to check them!
I will be using this to lessen the number of variables I actually have to keep track of. Thanks, mate!
Is it possible to store game's normal variable value to plugins variable property?
Using "Variable ID 1>set>random 200-400" and store (add/set) the outcome to the variable created by this plugin command?
Using "Variable ID 1>set>random 200-400" and store (add/set) the outcome to the variable created by this plugin command?
Not sure if i understood the question but i'll attempt to answer it:
When you have a variable as an object variable, you cannot assign values to it as normal. But you can store the value of another variable. So, for example,
1) you can setup variable 1 to hold a property called "random", with a value of 0
2) then set variable 2 to the random number you want
3) store the outcome to variable 1's "random" property
That would be:
1) maka.objVar.setProp(1, "random", 0)
2) Variable 2 -> set -> random 200-400
3) maka.objVar.setProp(1, "random", $gameVariables.value(2))
You could skip step 1, since the property will also be created by step 3, but i always like to initialize whatever i'm going to use beforehand.
Then you can show it by \VOBJ[1:random]
Instead of adding to total sum "1+2=3"
this script command just add value after the first value "1+2=12"
Is this how it suppose to work?
Hey man, let me check it out one moment and i'll get back to you.
Hey, I just checked it, and you're right, it's a bug i missed with the plugin command. Instead of
Plugin Command - > NewVarProp: 55 xxx 1
please use instead:
Script - > maka.objVar.setProp(55,"xxx",1)
until i fix this. With this change, the rest should add the numbers correctly.
I'll contact again once it has been fixed. Thanks for telling me!
When this going to be fixed? And will adding values to objects created by plugin command before the fix will work? I just rewrote my game to use plugin command objects instead of regular variables and would take half a day to change them to script command 🙂
I've already fixed the plugin command, i'm just testing it now, I'll update the plugin command in a couple of seconds, sorry about the trouble, i'm still a junior in JS :s
One suggestion.
Add an entry that you can add a number or variable to object using
maka.objVar.changeProp("add", $gameVariables.value(2), 55, "xxx");
or
maka.objVar.changeProp("add", 2 , 55, "xxx");
🙂
Great plugin. Makes default variables unnecessary in most cases.
I just made a quick fix, it's version v1.3b now. Can you please re-download the plugin and verify that it has been fixed?
Yes. It's fixed now. Thank you for your hard work 😍
Great ! I'm glad the plugin has helped you!
Just as a note,
Code:
maka.objVar.setProp(55, "xxx", 1)
is the same as
Code:
$gameVariables.setValue(55,{xxx: 1})
and
Code:
maka.objVar.getProp(55, "xxx")
is the same as
Code:
$gameVariables.value(55)["xxx"]
Also, when i use this plugin with scripts, i ALWAYS do this:
Code:
var a = maka.objVar;
a.setProp(55, "xxx", 1);
So that i can type commands faster (but these must be on the same script).
I mostly made this plugin to simplify this process, to include arrays as properties (far more useful once you get into it) and to enable you to show them in a text easily.
Also, in my opinion this should work far better with scripts, since you can have variable properties "xxx1"all the way to "xxx100" (100 properties!) and you can simply alter ALL of them by using:
Code:
var a = maka.objVar;
for(var i=1; i<=100; i++){
a.changeProp('add', 1, 55, "xxx"+i);
}
This would add 1 to all properties of variable 55 from "xxx1" to "xxx100". I thought it was a cool thing to mention here.
Just as an example of why you would need something like that: Imagine if you had a city with a 100 people inside, and you wanted to mention that each one of them had age, and, each turn, all of them aged by 1 year. So you could use "age1" instead of "xxx" in the example above to imply "age of person 1". Then you could have chances of them falling ill if they're older, or producing more goods if they're younger, etc.
Makai, you're the same guy who made that Steam tutorial about object variables right?
How to make a variable hold more than 1 value (aka Fun with Object variables)
Are you forbidden from linking that to this thread? I think it helps users understand more about the inner workings of your plugin.
Before I read your tutorial I never even thought about using object variables. After that I can't imagine making an RMMV game without one. I find nested object variables so much more intuitive to use than nested array variables. Plus you can add new objects on the fly unlike when using arrays wherein you need to keep track of what goes into which index.
Thanks a lot for the tutorial! Great help for noobs just starting to learn javascript.
How to make a variable hold more than 1 value (aka Fun with Object variables)
Are you forbidden from linking that to this thread? I think it helps users understand more about the inner workings of your plugin.
Before I read your tutorial I never even thought about using object variables. After that I can't imagine making an RMMV game without one. I find nested object variables so much more intuitive to use than nested array variables. Plus you can add new objects on the fly unlike when using arrays wherein you need to keep track of what goes into which index.
Thanks a lot for the tutorial! Great help for noobs just starting to learn javascript.
Thanks! Yeah I wrote that guide.
I can't imagine making a project without them either. Since then I've come up with more versatile ways of setting up objects and reading from them but I can't really make a simplified plugin like this one for them - they would require some editting. If you want to learn more, send me a private message and I'll guide you through there! 🙂
Original thread: https://forums.rpgmakerweb.com/threads/makai-object-variables.114287/