I want to be able to calculate and store a percent.. Since the default variables don't hold decimals and can only perform one mathematical operation at a time I figured I would try to use RGSS to perform my calculations and store the resulting percent back into one of the default variables.. This was the line I used to try and store the value:
$game_variables[17]=($game_variables[15]/$game_variables[16])*100
When I do this though I get the following error once the game reaches that line:
nil can't be forced into Fixnum
Anyone know what mistake I made?..
edit: added resolved tag
I take it you are trying to run that with the Event Script command.
It's too long - the interpreter interprets it in the wrong way for your purposes.
Try this:
a = $game_variables[15]
b = $game_variables[16]
$game_variables[17]=(a / b)*100
On the other hand, you could also avoid RGSS totally by just multiplying by 100 before dividing in the events like this:
@>Control Variables: [17] = Variable [15]
@>Control Variables: [17] *= 100
@>Control Variables: [17] /= Variable [16]
Quote from: modern algebra on September 11, 2008, 10:19:23 PM
I take it you are trying to run that with the Event Script command.
It's too long - the interpreter interprets it in the wrong way for your purposes.
Try this:
a = $game_variables[15]
b = $game_variables[16]
$game_variables[17]=(a / b)*100
On the other hand, you could also avoid RGSS totally by just multiplying by 100 before dividing in the events like this:
@>Control Variables: [17] = Variable [15]
@>Control Variables: [17] *= 100
@>Control Variables: [17] /= Variable [16]
Ah yes, I don't know why I didn't think of that. That helps a lot, thanks..