HexMozart88

The Master of Random Garbage
Veteran
Joined
May 15, 2016
Messages
2,534
Reaction score
4,833
First Language
English
Primarily Uses
RMVXA
I've been trying to spawn events and have them able to be moved around using Eshra's Spawn Event script. https://rascripts.wordpress.com/2012/11/07/event-spawning/ Unfortunately, the issue I'm having is that when I use $game_map.events[4].moveto($game_player.x, $game_player.y), it completely ignores the command. I assume because that event does not exist on the map, so the ID breaks or something? But I want to be able to move it around without using a pickup and throw script, and that's the only way I know how. Another thing is how would I reference one instance of the spawned object rather than moving all of them at once?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,320
Reaction score
9,712
First Language
German
Primarily Uses
RMMV
the problem is the ID.
the command should work normally as long as the ID exists.

but the ID is created and assigned by the event spawner, and most likely is not 4.
but there should be a way in the event spawner to get the ID of the newly spawned event into a variable that you can then use.
 

HexMozart88

The Master of Random Garbage
Veteran
Joined
May 15, 2016
Messages
2,534
Reaction score
4,833
First Language
English
Primarily Uses
RMVXA
That was exactly it. There was unfortunately no way to get the exact value from the script, but each event ID is 1 more than the last spawned ID. So what I ended up doing was adding 1 to a variable each time an event was spawned and using that variable in the move route.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,788
Reaction score
1,849
First Language
Spanish
Primarily Uses
RMVXA
create the event and put it into a variable?
Code:
@var = Game_Event.new(args)

a global variable can be shared between script calls.

then on the map itself, grab the events hash, intersect with your variable and find the ID.
OR, create the event, give it a name, and find it on the map, by name.
there's also the object_id property, which is unique.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,320
Reaction score
9,712
First Language
German
Primarily Uses
RMMV
alternatively you can use get location info to get the ID of an event at a specific position
doesn't work with multiple events at one place
 

HexMozart88

The Master of Random Garbage
Veteran
Joined
May 15, 2016
Messages
2,534
Reaction score
4,833
First Language
English
Primarily Uses
RMVXA
@gstv87 Getting an error here. 1648600171614.png

1648600195586.png
1648600351630.png

EDIT: What I did in my previous post seems to work, but only if you do one event at a time.

EDIT 2: So I tried setting it to the event spawn command instead, and now I get this.

1648601103594.png


Edit 3: WE DID IT BOYS.
1648603175499.png
 
Last edited:

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,788
Reaction score
1,849
First Language
Spanish
Primarily Uses
RMVXA
Code:
@var =
only works within the same scope.
across script call blocks, but within the same interpreter block (which the event page is)

if you want to use it across different events, you need $var.
which is what you have with $game_variables[ID]: $[object[index]]

you have no idea how breaking this technique is.
you'll be able to direct an entire scene without ever placing any events on the editor.
 

kyonides

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
482
Reaction score
202
First Language
English
Primarily Uses
RMXP
Here is a small scripting tool that might let you avoid using $game_variables, especially useful if you think you are running out of such in game variables.

Memorize Events at Will!

:wink: Just make sure they will not come back to slap the hell out of your face. :D

XP Version

Ruby:
class Interpreter
  alias :kyon_int_tool_init :initialize
  alias :kyon_int_tool_setup :setup
  def initialize(depth=0, main=false)
    @memo_events = {} if main
    kyon_int_tool_init(depth, main)
  end

  def setup(list, event_id)
    kyon_int_tool_setup(list, event_id)
    @memo_events[@map_id] ||= {}
  end
  def this_map_memo_events() @memo_events[@map_id] end
  def clear_memo_events() @memo_events.clear end
  def clear_map_memo_events() @memo_events[@map_id].clear end
  attr_reader :memo_events
end

Ruby:
class Game_Map
  alias :kyon_map_tool_init :initialize
  alias :kyon_map_tool_setup :setup
  def initialize
    kyon_map_tool_init
    @interpreter.setup_memo_events
  end

  def setup(map_id)
    kyon_map_tool_setup(map_id)
    @interpreter.setup_map_memo_events(map_id)
  end
  attr_reader :memo_events
end

class Interpreter
  def setup_memo_events() @memo_events ||= {} end
  def setup_map_memo_events(map_id)
    @map_id = map_id
    @memo_events[@map_id] ||= {}
  end
  def map_memo_events() @memo_events[@map_id] end
  def clear_memo_events() @memo_events.clear end
  def clear_map_memo_events() @memo_events[@map_id].clear end
end

If you are going to use these events from a custom script, use the following calls:

RM XP
$game_system.map_interpreter.memo_events[MapID][EventID]
$game_system.map_interpreter.this_map_memo_events[EventID]

RM VX ACE
$game_map.interpreter.memo_events[MapID][EventID]
$game_map.interpreter.this_map_memo_events[EventID]


Else if you are editing script commands, use the ones below:

Both Versions
memo_events[MapID][EventID]
this_map_memo_events[EventID]
clear_memo_events
clear_map_memo_events
 
Last edited:

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,631
Reaction score
509
First Language
German
Primarily Uses
RMMV
If the Code is executed by the Spawned Event itself, than i had this Line still on my PC,
used in Eventcommand Moveroute as Script Line. I guess self.id was the Missing Command.
In Move Route Command this Works as Scriptline, not sure if anywhere else.

$game_map.events[self.id].moveto($game_player.x, $game_player.y)

or with Jump effect:

jump($game_player.x - $game_map.events[self.id].x, $game_player.y - $game_map.events[self.id].y)
 
Last edited:

HexMozart88

The Master of Random Garbage
Veteran
Joined
May 15, 2016
Messages
2,534
Reaction score
4,833
First Language
English
Primarily Uses
RMVXA
Dang. That simple, eh?
 

Latest Threads

Latest Profile Posts

So I kinda came back and learned how to mod other RPG Maker games so... Hello everyone!
Captura-de-pantalla-475.png
Version 1.0.1 done! Now finally free time... oh
Capture.PNG
I'm Really proud of how my game over screen looks!
UldJFr1.png
I felt inspired by a piece of art I saw. So I made this.

Wanderer Doge.png

Thought i'd be cool to have like a company introduction. Check it out!

Forum statistics

Threads
123,278
Messages
1,155,421
Members
161,672
Latest member
KenDynasty
Top