Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Edit in game variables with script?

Hey guys, I'm trying to use an event spawning script, and I want it to spawn an event with an X and Y value of a game variable. Here's what I got:

Code:
lis = [['ABS'],['ID 8'],

['Behavior 5'],['Sight 8'],

['Sound 8'],['ClosestEnemy true'],

['HateGroup [0]'],

['Aggressiveness 3'],['Speed 4'],

['Frequency 4'],['Trigger 0'],

['Respawn 0']]

Event_Spawner::monst_abs

(x=$game_system.variables[58], 

y=$game_system.variables[59],

'SS',lis,true,1,255,false,'')

The only thing I'm having a problem with this script is the x=$game_system.variables[58] and y=$game_system.variables[59]. When I try to run the script it says "variables" is an undefined method... The error message I get is:

NoMethodError occurred while running script.
undefined method 'variables' for #<Game_System:0x39b5958

Why does it say that? And how can I fix it? Thanks for any advice.
 
Thanks Pokemaniac, I did find this out too however I still couldn't get it to work. So I just kind of gave up on it. The problem seemed to be that the game wanted the x and y variables all on the same line as Event_Spawner::monst_abs. But there is no way it could all fit on one line in the script command of the event. Its so silly that they actually bothered to put an area limit there. But I can work around it.
 
What regi said is basically it, however I'd put it this way: As long as you end the line with an operator of any sort, the interpreter (in this case Interpreter... heh) will jump to the next line. Common scripting style usually puts four spaces/two tabs in front of a line continued in this fashion, but that's obviously up to you.

What I'm not sure of is if that will work in the Call Script command... it might, but I simply don't have any idea. Just in case, or if you don't want to do random line skips and prefer something more readable, you can do what Pokémaniac suggested and just split the line in individual local variables... like so:
Code:
a = 'very very long text line of fucking doom'

b = 'is very long... trust me!'

c = 'No way you'd ever be able to fit this into a single Call Script command.'

p a + ' ' + b + ' ' + c
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top