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.

Short bug-fix script

I need a script that automatically multiplies all MAP X and MAP Y variables by 32.

This is so I won't have to multiply each of my event coordinate variables by 32 to counter the fact that 'show picture @ variable' commands search for pixel coordinates and not tile coordinates.
 
Well... you can do it with events...
but if you want a script, ok.
Paste this above Main:
Code:
Coordinate_Vars = [4, 5, 6, 7]

class Interpreter

  def fix_coordinates
    Coordinate_Vars.each_index { |i| $game_variables[i] *= 32 }
  end
end

The array in the first line holds all the variable ids, so you have to edit them.

And... when you want to "fix" all variables, use this in Call Script:
Code:
fix_coordinates

Hope I undertood you :)
 
Oh... I got the error, try this code:
Code:
Coordinate_Vars = [4, 5, 6, 7]

class Interpreter

  def fix_coordinates
    Coordinate_Vars.each { |x| $game_variables[x] *= 32 }
  end
end
 

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