Remember Event Position

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,042
Reaction score
13,678
First Language
English
Primarily Uses
RMMV
$game_map.events[@event_id].save_pos


@event_id is the 'current' event.


But if you're doing this as a move route, you can just add save_pos as a script call (in the move route).
 

chigoo

Void Walker
Veteran
Joined
Aug 15, 2012
Messages
136
Reaction score
18
First Language
English
Primarily Uses
RMMV
oh so I use this as $game_map.events[@event_id].save_pos. and i knew about the move route thing. This will really come in handy for my game. I can just spawn events once in a random location and keep them there for good.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,042
Reaction score
13,678
First Language
English
Primarily Uses
RMMV
As long as the next time you return to the map, the same events get spawned with the same event id.


If you have any kind of conditions that will cause events to get spawned in a different order, that won't work.
 

chigoo

Void Walker
Veteran
Joined
Aug 15, 2012
Messages
136
Reaction score
18
First Language
English
Primarily Uses
RMMV
nope they will always have the same event ID. I haven't even seen a script or know a way to change event IDs
 

Darc_The_Hero

Villager
Member
Joined
Mar 2, 2014
Messages
16
Reaction score
0
First Language
English
Primarily Uses
Problem solved.

king.png
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,242
Reaction score
7,619
First Language
German
Primarily Uses
RMMV
I'm not sure what I'm doing wrong... here's a video and a screenshot of the event list.
Your event saves the position of the king-event, not the positions of the guard-events.
You should have done it the way I told you in the other post, not looking here for the solution of other players, because the save_pos() command can be used in several ways.


See attached picture for the correct solution in your case

save_pos.png
 

Darc_The_Hero

Villager
Member
Joined
Mar 2, 2014
Messages
16
Reaction score
0
First Language
English
Primarily Uses
I must have missed that, thank you.

Fixed.
 

rivalhyuu

Warper
Member
Joined
Feb 27, 2014
Messages
3
Reaction score
0
First Language
English
Primarily Uses
Hi, it's my first time to use the scripts, so I don't have an idea how to copy and paste your script to the script and where to paste it.. How do you do it in a way that the game will still work?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,042
Reaction score
13,678
First Language
English
Primarily Uses
RMMV
Hi rivalhyuu, welcome to the forum.


Scripting is an advanced topic, so if you're new to the engine, I suggest you don't spend too much time looking at scripts - at least not until you've familiarized yourself with the event editor.


To add a script, you open the Script editor (F11 or click the script icon on the toolbar - I can't tell you what it looks like as I don't have it in front of me).


In the list on the left, scroll down until you see Materials and Main.


Click on the row BELOW Materials (if you haven't added any other scripts, it'll say something like Insert Here).


Press the Insert button to insert a new slot.


In the script name box at the bottom of the list, type in a name for the script - this doesn't have to be what the scripter called it - it's just for your own reference (make sure you do this, as it will help with debugging issues or locating scripts later).


Then in the empty panel on the right, paste the script itself.


ALWAYS check the comments (green text at top of scripts) to see if it requires you to do any customizing or reserve any switches or variables. If it does require that and you don't do it, your game will not behave the way you expect it to, and it can be difficult to figure out why.
 

rivalhyuu

Warper
Member
Joined
Feb 27, 2014
Messages
3
Reaction score
0
First Language
English
Primarily Uses
Thanks! Btw the script you have there's very useful.
 
Last edited by a moderator:

Imagine

Warper
Member
Joined
Apr 27, 2014
Messages
4
Reaction score
1
First Language
English
Primarily Uses
Great script, well done mate! :)
 

Candacis

Pixel Pusher
Restaff
Joined
May 2, 2012
Messages
1,645
Reaction score
2,537
First Language
German
Primarily Uses
I could have needed this script in my face contest entry. Well, glad I found it now. This is an amazing script! Thank you very much for sharing.
 

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,078
Reaction score
2,654
First Language
Greek
Primarily Uses
RMMZ
This script is a fantastic idea.

It can actually make our life simple.

It is really hard to do this with eventing, it might work wrong and also it might create extra lag if needed for many events.

Thanks Shaz!

A thanks goes also to Celianna for recommending that to someone. It's how I learned about it.
 

JAD94

The lunar knight
Veteran
Joined
Feb 18, 2014
Messages
662
Reaction score
189
First Language
English
Primarily Uses
RMMV
Ah Shaz you're the best. Been looking for a script like this for a while!
 

Nataxinus

Villager
Member
Joined
Apr 14, 2015
Messages
11
Reaction score
0
First Language
Danish
Primarily Uses
I've made some modifications to this script. Now you can use it by default and control exceptions with single events or entire graphic sheets. Saves some time.

Code:
#--------------------------------------------------# Remember Event Position 1.0#--------------------------------------------------## Author: Shaz## Description: This script lets you set the position and direction#              where an event will appear next time the map is#              loaded.  Events will appear in this new position#              rather than the place they were put during design.##--------------------------------------------------## Installation: ## Copy into a new script slot in the Materials section##--------------------------------------------------## Use:## Examples below show syntax for an Event Command on an Event Tab.#   You can use @event_id for the current event, or specify an event number.# To execute from within a Set Move Route command, omit the#   $game_map.events[@event_id]. part, and just use save_pos() and forget_pos().## To tell an event to move to its current position the next time# the map is loaded, execute the following in a script call:#   $game_map.events[@event_id].save_pos()## To tell an event to move to a particular position (not its# current position) the next time the map is loaded,# execute the following in a script call:#   $game_map.events[@event_id].save_pos(1, 2, 8)# - the above will move the event to x=1, y=2, facing up## To tell an event to forget its previously remembered position# and go back to its default position the next time time map# is loaded, execute the following in a script call:#   $game_map.events[@event_id].forget_pos()#--------------------------------------------------# I, Nataxinus has made modifications to this script# I do not own it etc. etc.#--------------------------------------------------# This requires some knowledge of ruby.# You can now choose to remember event# positions by default. You can specify exceptions# if you're using this new feature. You can also# specify exceptions for whole graphic sheets.# I have specified graphic sheets from the RTP# so you might want to change that if you're# not using RTP.# Configure my module to use the new# features of the script. # Follow the instructions listed there.#--------------------------------------------------module Nataxinus  module RememberEventPos    # Set to true if you want to save the event positions by default, set to    # false otherwise.    USE_DEFAULT = true    # The exceptions to the default. Use map id's as keys and insert the event    # id's that belong to that map. For example to make event 1 and 2 at map 1     # exceptions, and event 9 at map 2:     # 1 => [1, 2], 2 => [9]    EXCEPTIONS = {}    # You can add the graphic file names that you don't want to automatically    # save the position of.    EXCEPTION_GRAPHICS = ["!Door1", "!Door2", "!Door3", "!$Gate1", "!$Gate2",     "!Other3", "!Switch1", "!Switch2", "", "$Text", "$Text2"]  endendclass Game_System  alias shaz_mem_position_gs_init initialize  attr_accessor :event_positions  def initialize    shaz_mem_position_gs_init    @event_positions = {}  endend# Check to ensure $game_system.event_positions exists (save files created# prior to this script being added would not have it initialized)class Game_Map  alias shaz_mem_positions_gm_init initialize  def initialize    shaz_mem_positions_gm_init    $game_system.event_positions = {} if !$game_system.event_positions  endendclass Game_CharacterBase  attr_accessorendclass Game_Event    include Nataxinus::RememberEventPos    alias shaz_mem_position_gcb_init initialize  def initialize(map_id, event)    shaz_mem_position_gcb_init(map_id, event)    if $game_system.event_positions.has_key?([map_id, @id])      mvx, mvy, mvdir = $game_system.event_positions[[map_id, @id]]      moveto(mvx, mvy)      set_direction(mvdir) if mvdir      @stop_count = 0      refresh    end  end  def save_pos(x = @x, y = @y, dir = @direction)    $game_system.event_positions[[@map_id, @id]] = [x, y, dir]  end  def forget_pos    $game_system.event_positions.delete([@map_id, @id])  end    alias save_event_pos_update update  def update    save_event_pos_update    if @page      return if EXCEPTION_GRAPHICS.include?(@page.graphic.character_name)    else      return    end    if EXCEPTIONS[$game_map.map_id]       if USE_DEFAULT && !EXCEPTIONS[$game_map.map_id].include?(@id)        save_pos       end    elsif USE_DEFAULT      save_pos    end  endend 
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,295
Reaction score
11,710
First Language
English
Primarily Uses
RMVXA
I am trying to tell an event to move to a particular position (not its current position) the next time the map is loaded.  I am having to do this via an event on another map.  I have used this script call:

$game_map.events[290, 4] .save_pos(14, 3, 8)

290 is the map_id, 4 is the event_id.  For the position to move to, I have had to guess 8, as this is an object, not a sprite, so does not actually have an up/down/left/right orientation.

I get the error message:

wrong number of arguments (2 for 1).

Could you tell me what's wrong with my script call?

thanks.
 
Last edited by a moderator:

♥SOURCE♥

Too sexy for your party.
Veteran
Joined
Mar 14, 2012
Messages
693
Reaction score
410
Primarily Uses
Hey there! Try the following instead:

Code:
$game_system.event_positions[[290, 4]] = [14, 3, 8]
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,042
Reaction score
13,678
First Language
English
Primarily Uses
RMMV
ALL events have a direction. If you mean this event uses a spritesheet where you check Direction Fix to stop it turning because all the sprites are different, then your direction will be as follows:


Rows 1 or 5: 2


Rows 2 or 6: 4


Rows 3 or 7: 6


Rows 4 or 8: 8


And yes, you can only use $game_map.events to refer to events on the current map. This is why you got an error. SOURCE's answer is spot-on.
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,295
Reaction score
11,710
First Language
English
Primarily Uses
RMVXA
Thanks for the clarification of $game_map.events

This isn't on an 8 row sprite sheet, but a B-E tilesheet and it's on row 15.  So I'm still unclear what I should do about direction.
 

♥SOURCE♥

Too sexy for your party.
Veteran
Joined
Mar 14, 2012
Messages
693
Reaction score
410
Primarily Uses
Thanks for the clarification of $game_map.events

This isn't on an 8 row sprite sheet, but a B-E tilesheet and it's on row 15.  So I'm still unclear what I should do about direction.
Don't worry, it won't do anything with the direction if the graphic is from the tilesheet. :)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts



Made another map, this one even has a cool moving waterfall. I'll have an animated GIF later whenever I'm done adding stuff. :LZSwink:
Back here again?! RPG MAKER, I can't quit you. :kaosigh:
um... why didn't anyone tell how easy it is to add motions to Sideview battlers? I literally copied the last one, changed the name and index, said where it should play, and boom... I've got intro motions.
Lately when I listen to 1970s songs, I always think that the "real world" is still at mid 70s. What we experience now is a futuristic dream. With this point of view, even 80s and 90s looks super futuristic. :D

Forum statistics

Threads
105,539
Messages
1,014,477
Members
137,222
Latest member
kubet88net
Top