RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu
  • Welcome to The RPG Maker Resource Kit.

Variables giving me a problem... [resolved]

Started by taichi556, September 11, 2008, 09:26:54 PM

0 Members and 1 Guest are viewing this topic.

taichi556

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

modern algebra

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]

taichi556

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..