The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Joey_Noob on November 13, 2006, 07:39:25 PM

Title: how could i do this
Post by: Joey_Noob on November 13, 2006, 07:39:25 PM
i have a scene on an airship deck and i need the sky panorama to move like so it looks as if the ship is moving how could i do this
Title: Re: how could i do this
Post by: &&&&&&&&&&&&& on November 13, 2006, 08:59:30 PM
TA'DAH

http://www.phylomortis.com/resource/script/scr040.html

Hope this is what you wanted...
Title: Re: how could i do this
Post by: Joey_Noob on November 13, 2006, 10:04:05 PM
i think i put the script in right but i didn'e get what the "[...]" were for and i got an error saying


Quote" nil can't be coerced into fixnum"
Title: Re: how could i do this
Post by: &&&&&&&&&&&&& on November 13, 2006, 10:07:48 PM
BLIZZARD!

@joey_Noob- wait right here.

BLIZZARD WE NEED YOUR HELP!

I'll be right back...
Title: Re: how could i do this
Post by: Blizzard on November 14, 2006, 10:18:25 AM
Don't forget to credit RPG Advocate and Guillaume777. Although I think it could have been done with less code... Instructions are inside.

#==============================================================================
# Autoscroll script
#------------------------------------------------------------------------------
# Script by RPG Advocate, modified by Guillaume777
# 1
# 2005/12/25
#==============================================================================

class Game_System
 
  #--------------------------------------------------------------------------
  # Adds accessor for $game_system.autoscroll_x_speed and autoscroll_y_speed
  #--------------------------------------------------------------------------
  attr_accessor :autoscroll_x_speed
  attr_accessor :autoscroll_y_speed
 
end

class Spriteset_Map
 
  #--------------------------------------------------------------------------
  # * Change the panorama x-y for new autoscroll values
  #--------------------------------------------------------------------------
  alias g7_as_spriteset_map_update update
  def update
    g7_as_spriteset_map_update # do the normal update
    if @panorama.bitmap == nil then return end # if no panorama then do nothing
      # if custom autoscroll values are set
      if self.autoscroll_x_speed != 0 or self.autoscroll_y_speed != 0
      self.scroll #get new scroll_point values
      @panorama.ox = self.scroll_point_x
      @panorama.oy = self.scroll_point_y
    end
  end
  #--------------------------------------------------------------------------
  # Set scroll point x and scroll point y to reflect autoscrolling
  #--------------------------------------------------------------------------
  def scroll
    w = @panorama.bitmap.width
    h = @panorama.bitmap.height
    self.scroll_frames_x += self.autoscroll_x_speed
    self.scroll_frames_y += self.autoscroll_y_speed
    while self.scroll_frames_x >= 8
      self.scroll_frames_x -= 8
      self.scroll_point_x += 1
    end
    while self.scroll_frames_x <= -8
      self.scroll_frames_x += 8
      self.scroll_point_x -= 1
    end
    while self.scroll_frames_y >= 8
      self.scroll_frames_y -= 8
      self.scroll_point_y += 1
    end
    while self.scroll_frames_y <= -8
      self.scroll_frames_y += 8
      self.scroll_point_y -= 1
    end
    self.scroll_point_x -= w if self.scroll_point_x > w
    self.scroll_point_x += w if self.scroll_point_x < -w
    self.scroll_point_y -= h if self.scroll_point_y > h
    self.scroll_point_y += h if self.scroll_point_y < -h
  end
  #--------------------------------------------------------------------------
  # Returns $game_system.autoscroll_x_speed or 0 if it is nil
  #--------------------------------------------------------------------------
  def autoscroll_x_speed
    return $game_system.autoscroll_x_speed != nil ? $game_system.autoscroll_x_speed : 0
  end
  #--------------------------------------------------------------------------
  # Returns $game_system.autoscroll_y_speed or 0 if it is nil
  #--------------------------------------------------------------------------
  def autoscroll_y_speed
    return $game_system.autoscroll_y_speed != nil ? $game_system.autoscroll_y_speed : 0
  end
  #--------------------------------------------------------------------------
  # Returns @scroll_frames_x or 0 if it is nil
  #--------------------------------------------------------------------------
  def scroll_frames_x
    return @scroll_frames_x != nil ? @scroll_frames_x : 0
  end
  #--------------------------------------------------------------------------
  # Set new @scroll_frames_x
  #--------------------------------------------------------------------------
  def scroll_frames_x=(value)
    @scroll_frames_x = value
  end
  #--------------------------------------------------------------------------
  # Returns @scroll_frames_y or 0 if it is nil
  #--------------------------------------------------------------------------
  def scroll_frames_y
    return @scroll_frames_y != nil ? @scroll_frames_y : 0
  end
  #--------------------------------------------------------------------------
  # Set new @scroll_frames_y
  #--------------------------------------------------------------------------
  def scroll_frames_y=(value)
    @scroll_frames_y = value
  end
  #--------------------------------------------------------------------------
  # Returns @scroll_point_x or 0 if it is nil
  #--------------------------------------------------------------------------
  def scroll_point_x
    return @scroll_point_x != nil ? @scroll_point_x : 0
  end
  #--------------------------------------------------------------------------
  # Set new @scroll_point_x
  #--------------------------------------------------------------------------
  def scroll_point_x=(value)
    @scroll_point_x = value
  end
  #--------------------------------------------------------------------------
  # Returns @scroll_point_y or 0 if it is nil
  #--------------------------------------------------------------------------
  def scroll_point_y
    return @scroll_point_y != nil ? @scroll_point_y : 0
  end
  #--------------------------------------------------------------------------
  # Set new @scroll_point_y
  #--------------------------------------------------------------------------
  def scroll_point_y=(value)
    @scroll_point_y = value
  end
 
end