Hi everyone,
my current strategy game has a lot of variables and many are dependent on other ones.
A example would be food production, where the food per day = (number of farmers + additional production per farm)*productivity, rounded to the nearest integer.
Is there an easy way to do this? Possibly some script or something?
Thanks.
An easier way to take care of maths?
● ARCHIVED · READ-ONLY
-
-
What is exactly your problem? What do you mean by easier?
-
Well right now I have to go to Control variables, control variables, control variables...
I'm wondering if there is a way to just write it out normally like in any other programming software.
For example in game maker I'd just open a script and write it and it would work. Here the only way I know how to do it is create a common event/event, then place a lot of game progression - control variables commands. -
control variables : script, and then enter the formula into the script line - you can also access other variables from there.
or use the event's script command to enter a multiline-script that is used to calculate a result and store that result in a variable before closing that small script (all data is erased if not stored outside the event's script command) -
Great, thanks.
I've also noticed that by typing simply variable 1 = 1/2 I get 0 when referring to it in a message box.
Does that mean that the variable is actually equal to 0 and that all variables are rounded down or that simply the message box will round them down? -
Variables in Ruby do not have a type the way they do in virtually every other programming language.
Although everything in Ruby is an object, Ruby runs on what is called "duck typing." This means "An object is of type X if it responds to the function I am trying to do"
Some key functions that are useful:
to_i - Converts the variable to an integer
to_f - Converts the variable to a floating point number
to_s - Converts the variable to a string
So, if you really want to assign the value 0.5 to the variable, and print it as a floating point number, you need to make sure Ruby sees the values as floating point numbers, not integers (the default):
$game_variables[1]=(1.0/2.0) -
Hmm... alright.
How do I reference existing variables in the 'script' call of Control Variables?
I made simple variables 001:oNE, 002:TWO, etc and set them to their relative values.
How do I simply set the variable 006:TEST to ONE+TWO? (Using the script call)
I think I should be able to work it out from there, thanks a lot! -
This is an invaluable script reference posted by Archeia:
http://forums.rpgmakerweb.com/index.php?/topic/25759-script-call-collection-for-vxace/
In Ruby, any variable name beginning with a $ is a global variable.
In the script calls you don't reference the game variables/switches/etc by name, but just by their ID, which is their array position.
You can store whatever you'd like into the variables and the variables will be saved with the game. This can include custom classes, Hashmaps, etc. But, if you do, you will probably be using only script calls to manipulate or display their contents. -
I can't believe I didn't find it before, thank you!
This will make things much easier :) -
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.