Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Memorize Event Positions, Events will always be where you left them
BigEd781
post Dec 6 2008, 04:18 PM
Post #1


No method: 'stupid_title' found for `nil:NilClass'
Group Icon

Group: Revolutionary
Posts: 1,829
Type: Scripter
RM Skill: Undisclosed




Memorize Event Positions

By Biged781


Intro
For those who do not like that the positions of their events reset when the player exits and enters a map, this script will automatically memorize their positions for you. Just drop it into the materials section and your events will always appear where they left off. You can enable and disable this behavior by turning a switch ON or OFF.

Bug Fixes / Enhancements
-> Added a way to disable the effects of this script for certain events.
-> Fixed a bug that would have occurred with encrypted game files.
-> Ended reliance on the file system, greatly reduces chances of bugs (thanks wora wink.gif)

Configuration / Use
Just plop it into the "Materials" sections, should be no problems. To turn the script on and off, find this part of the script:

CODE
#-----------------------------------------------------------------------
  # * Set this to the switch number that you will
  #   use to turn this script ON or OFF.
  #   ---------  
  #   Set to switch id "1" by default.
  #
  MOVE_EVENTS_SWITCH_ID = 1


You can modify this constant,

CODE
MOVE_EVENTS_SWITCH_ID


to equal the id of the switch that you would like to use. If this switch is ON, the events on each map will memorize their positions at all times. If you turn this switch OFF, they will return to their default positions. Note that only the maps that are loaded after the switch is turned ON or OFF will be affected, i.e., the current map positions will be saved, but the events will not be moved.

--------------------------------
To disable the effects of this script at the event level, add a comment to the event with only the text "no mem", without the quotes.




Script
CODE
#-----------------------------------------------------------------------
#                       Memorize Event Positions
#                               BigEd781
#-----------------------------------------------------------------------
class Game_System
  
  alias :eds_old_pre_mem_intialize :initialize
  def initialize
    eds_old_pre_mem_intialize
    @event_pos_data = {}    
  end
  
  def save_event_position_data(map_id, data)
    @event_pos_data[map_id] = data
  end
  
  def get_event_position_data(map_id)
    return @event_pos_data[map_id].nil? ? [] : @event_pos_data[map_id]
  end
  
end

class Game_Event < Game_Character

  def comment?(comment)
    unless @list.nil?
      @list.each { |line|
        next if line.code != 108                              
        return true if line.parameters[0].upcase == comment.upcase }      
    end    
    return false
  end  
  
end

class Game_Map
  
  alias :eds_old_pre_mem_setup :setup
  def setup(map_id)    
    save_positions if $game_switches[1]
    eds_old_pre_mem_setup(map_id)    
    restore_positions  if $game_switches[1]
  end
  
  def save_positions
    return if @events.nil? || @events == { }        
    data = []
    @events.values.each { |event| data += [[ event.id, event.x, event.y, event.direction ]] }      
    $game_system.save_event_position_data(@map_id, data)    
  end
  
  def restore_positions    
    return if @events.nil? || @events == { }        
    $game_system.get_event_position_data(@map_id).each { |data|  
    event = @events[data[0]]  
      unless event.nil? || event.comment?('no mem')
        x, y, direction = data[1], data[2], data[3]
        event.moveto(x, y) unless event.pos?(x, y)
        event.set_direction(direction)
      end
    }    
  end
  
end


Compatibilty / Issues
I don't not know of any issues currently, but this system writes out the event's locations to a file when maps are left, and reads that file back in to position the events when a map is loaded. Also, there are many edge conditions to yet be found so there will probably be some bugs. I will fix them as soon as they are posted. Compatibility with other scripts should be 100%.


__________________________
`
Give me teh codez!!!


I am the master debator!
Go to the top of the page
 
+Quote Post
   
Warder
post Dec 6 2008, 05:29 PM
Post #2


Level 31
Group Icon

Group: Revolutionary
Posts: 750
Type: None
RM Skill: Undisclosed




Hey, this is a pretty cool script. There have been times when I've wished I had something that would do this. Thanks for making it. smile.gif
Go to the top of the page
 
+Quote Post
   
woratana
post Dec 6 2008, 05:52 PM
Post #3


Looking for scripter to hire? PM me *O*
Group Icon

Group: +Gold Member
Posts: 1,038
Type: Scripter
RM Skill: Undisclosed




Nice~^^ I wrote this in XP half a year ago, and it's my first script! >_>/ Btw, does this script memorize @direction (It seems like it doesn't) ? And have you tested it on encrypted project? The other issues I see are that the process of getting/saving data could make a short pause for big maps, and data in text file can be edited to cheat game easily.


__________________________
Check out my NEW blog!!!



MVP (Most Valuable Poster) Award 2008


Go to the top of the page
 
+Quote Post
   
BigEd781
post Dec 7 2008, 04:07 PM
Post #4


No method: 'stupid_title' found for `nil:NilClass'
Group Icon

Group: Revolutionary
Posts: 1,829
Type: Scripter
RM Skill: Undisclosed




Good eye wora, I'll add saving direction. Encrypted projects will probably...fail. I could just save the text files in the working directory I suppose. If someone really wants to cheat by editing the files, I don't know that I really care. I tested with a max of 100 events, but I have a pretty nice machine. I would hope that reading in a simple text file would not take a long time, but I could try it out on my old laptop to be sure.

EDIT: Added directional saving. more to come...


__________________________
`
Give me teh codez!!!


I am the master debator!
Go to the top of the page
 
+Quote Post
   
woratana
post Dec 7 2008, 05:34 PM
Post #5


Looking for scripter to hire? PM me *O*
Group Icon

Group: +Gold Member
Posts: 1,038
Type: Scripter
RM Skill: Undisclosed




My idea is to save it in $game_system or other class that will be stored in save file, because it won't affect other save files~^^


__________________________
Check out my NEW blog!!!



MVP (Most Valuable Poster) Award 2008


Go to the top of the page
 
+Quote Post
   
BigEd781
post Dec 7 2008, 05:41 PM
Post #6


No method: 'stupid_title' found for `nil:NilClass'
Group Icon

Group: Revolutionary
Posts: 1,829
Type: Scripter
RM Skill: Undisclosed




That's a good idea. For now, it will work with encrypted games (it just saves the files in the working directory). I will do it in Game_System though, that is a much safer solution. be back soon...

EDIT: Oh yeah, you can disable the effects of this script on events now by adding a comment to it.

EDIT2: No more reliance on .txt files, using Game_System to store data now. Greatly reduces chances of bugs cropping up (thanks Wora wink.gif)


__________________________
`
Give me teh codez!!!


I am the master debator!
Go to the top of the page
 
+Quote Post
   
woratana
post Dec 7 2008, 09:08 PM
Post #7


Looking for scripter to hire? PM me *O*
Group Icon

Group: +Gold Member
Posts: 1,038
Type: Scripter
RM Skill: Undisclosed




Your welcome >_>//


__________________________
Check out my NEW blog!!!



MVP (Most Valuable Poster) Award 2008


Go to the top of the page
 
+Quote Post
   
lahandi
post Dec 10 2008, 10:46 PM
Post #8


Level 8
Group Icon

Group: Revolutionary
Posts: 111
Type: Artist
RM Skill: Skilled





This script is very usefull for boulder pushing event.
Thanks mate!



__________________________
Go to the top of the page
 
+Quote Post
   
irbis
post Oct 18 2010, 11:40 AM
Post #9


Level 3
Group Icon

Group: Member
Posts: 30
Type: Writer
RM Skill: Beginner




okey so where the hell is
"#-----------------------------------------------------------------------
# * Set this to the switch number that you will
# use to turn this script ON or OFF.
# ---------
# Set to switch id "1" by default.
#
MOVE_EVENTS_SWITCH_ID = 1"

inside the script? maybe i gone blind but i cant find it
Go to the top of the page
 
+Quote Post
   
Kread-EX
post Oct 18 2010, 11:47 AM
Post #10


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




Yeah, it's not in. Just add it at the very top of the script and replace all occurences of $game_switches[1] by $game_switches[MOVE_EVENTS_SWITCH_ID].


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   
irbis
post Oct 21 2010, 02:43 AM
Post #11


Level 3
Group Icon

Group: Member
Posts: 30
Type: Writer
RM Skill: Beginner




ahhh thank you Kread!
Go to the top of the page
 
+Quote Post
   
Philip
post Feb 2 2011, 08:38 PM
Post #12


Nura (The Jade Ring)
Group Icon

Group: Revolutionary
Posts: 327
Type: Developer
RM Skill: Masterful




This is kudos for an absolutly simple but amazing script!! The block pushing puzzles will never be the same LOL!!! Cool cool cool... downloading.

Please. You know the rules. Don't necropost. ~Kread


__________________________
"If your mind goes blank don't forget to turn off the sound." Unknown Author

Phil


Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th June 2013 - 10:50 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker