Event Spawners and MoveTo commands

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?
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.
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.
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.
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
@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
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.
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!​

😉 Just make sure they will not come back to slap the hell out of your face. 😀

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
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)
Dang. That simple, eh?

Original thread: https://forums.rpgmakerweb.com/threads/event-spawners-and-moveto-commands.146240/