The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: shintashi on December 29, 2010, 04:00:27 AM

Title: Snippet Request: Coordinate Adjustment?
Post by: shintashi on December 29, 2010, 04:00:27 AM
I would like to be able to adjust the X & Y coordinates of a stationary event graphic, preferably using the event>script option if that's possible. For example, making a small adjustment to where torches or tiny NPCs appear.
Title: Re: Snippet Request: Coordinate Adjustment?
Post by: Deity on January 03, 2011, 02:36:38 AM
Hay,
I've written something that could help you.
class Game_Character
  attr_accessor :adjust_x
  attr_accessor :adjust_y
  alias initialize_adjust initialize unless $@
  def initialize
    initialize_adjust
    @adjust_x = 0
    @adjust_y = 0
  end
end
class Interpreter
  def adjust_graphic_coordinate(x=0,y=0)
    get_character(0).adjust_x = x
    get_character(0).adjust_y = y
  end
end
class Sprite_Character
  alias update_adjustment update unless $@
  def update
    update_adjustment
    self.x += @character.adjust_x
    self.y += @character.adjust_y
  end
end


Just type adjust_graphic_coordinate(x,y) into the Script command of any event and the graphic will change the position.
x and y can be negative too.

Deity
Title: Re: Snippet Request: Coordinate Adjustment?
Post by: shintashi on January 05, 2011, 01:53:59 AM
That's spiffy actually, though the autorun/parallel process is tricky.