RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
How do I call a Game Variable in a Script?

0 Members and 2 Guests are viewing this topic.

***
Rep:
Level 70
RMRK Junior
The short version.  Im screwing around with a script where I have to set some of the variables by the script.
player.variable = 1 as an Event Script.  How do I set a Game Variable to that value?  I tried player.variable = $game_variables[x] where X is the ID of the Game Variable.  \v[99] also only works for displaying that as text as far as I can tell...
Heretic's Vehicles XP (Boat and Magic Carpet)

Heretic's Collection XP Ver 2.3 - Updated to include Dynamic Lighting, Moving Platforms, Vehicles, and much much more!

**
Rep:
Level 82
$game_variables[VARIABLE_ID] = VALUE

***
Rep:
Level 70
RMRK Junior
$game_variables[VARIABLE_ID] = VALUE

Thats what I thought.  I just want to temporarily override what I am calling a user defined variable...

message.text_speed = $game_variables[99]

I doubt this has anything to do with it, but the script window keeps putting the [99] on a new line.  When I try to run it, I get:

Quote
Script 'Multiple Message Windows SDK' line 1176: NoMethodError occured.
Undefined Method `-' for #<Game_Variables: 0xSomeCrap @data=[]>

/scratches_head
Heretic's Vehicles XP (Boat and Magic Carpet)

Heretic's Collection XP Ver 2.3 - Updated to include Dynamic Lighting, Moving Platforms, Vehicles, and much much more!

*
Rep:
Level 82
Common problem with using the Script... call under Advanced.

Each line is separately processed as its own line. Try something like:

Code: [Select]
var = $game_variables[99]
message.text_speed = var

Shortening the line length by creating variables with smaller names is pretty much the quick and easy (probably the only) way to deal with that issue.

(Why do I always feel like it's the end of the world and I'm the last man standing?)

***
Rep:
Level 70
RMRK Junior
So if the script doesn't all fit on the same line, it doesn't compile the variable or class names the same way?  Like its inserting a \r or \n character between $var[x] and $var\n[x] are not the same?

Thats one Goofy bug but thanks for letting me know!
Heretic's Vehicles XP (Boat and Magic Carpet)

Heretic's Collection XP Ver 2.3 - Updated to include Dynamic Lighting, Moving Platforms, Vehicles, and much much more!

*
Rep:
Level 82
Only for the Event based Script called (under the Advanced section of the Event Commands list).

If you mean in the actual scripts database section, there shouldn't be any issue regarding how long each line is, as long as each line is its own statement (this isn't completely true, but for simplicity's sake it's a good thing to follow).
(Why do I always feel like it's the end of the world and I'm the last man standing?)

***
Rep:
Level 70
RMRK Junior
Only for the Event based Script called (under the Advanced section of the Event Commands list).

If you mean in the actual scripts database section, there shouldn't be any issue regarding how long each line is, as long as each line is its own statement (this isn't completely true, but for simplicity's sake it's a good thing to follow).

It was an Event Based Script...
Heretic's Vehicles XP (Boat and Magic Carpet)

Heretic's Collection XP Ver 2.3 - Updated to include Dynamic Lighting, Moving Platforms, Vehicles, and much much more!

**
Rep:
Level 71
RMRK Junior
You can also escape the line-feed character that the editor puts in for you...

message.text_speed = \
$game_variables[99]

just make sure there are no spaces after the backslash