public

Rpg Maker Developers Group

Simple enough for a child, powerful enough for a developer

2 Followers

MZ How would I change the self-switch of a spawned event, from another spawned event?

BMM Archive · July 15, 2026

Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.

Original Source

  • Original title: MZ How would I change the self-switch of a spawned event, from another spawned event?
  • Original author: fallenlorelei
  • Original date: June 3, 2022
  • Source thread: https://forums.rpgmakerweb.com/threads/how-would-i-change-the-self-switch-of-a-spawned-event-from-another-spawned-event.148200/
  • Source forum path: Game Development Engines > RPG Maker Javascript Plugins > Javascript/Plugin Support

Summary

I am developing a store system with spawned events. The items themselves "spawn" on the counters, and then the NPCs "spawn" at the door, walk to the counter, purchase the item, and then walk away. I am using Pocket Events to spawn the items on the counters. I am using Eli's Self Variables to track what counter they are spawning on. Visustella Events and Movement Core. (I know VS has self variables but they weren't working for me). And KageDesu's ABS plugin to spawn the NPCs. { "lightbox_close": "Close",

Archived First Post

I am developing a store system with spawned events. The items themselves "spawn" on the counters, and then the NPCs "spawn" at the door, walk to the counter, purchase the item, and then walk away.

I am using Pocket Events to spawn the items on the counters. I am using Eli's Self Variables to track what counter they are spawning on. Visustella Events and Movement Core. (I know VS has self variables but they weren't working for me). And KageDesu's ABS plugin to spawn the NPCs.

selfvariablehelp01.PNG

Using "Crystal" as an example, here I'm setting the item's "self variable" (21) to variable 14, which is what counter it's being placed on (1, 2, 3, etc.). This works fine. ✓

Then I spawn an NPC at the shop.

selfvariablehelp02.PNG

They roll a random number, check if that counter has an item or not, then they walk to that counter. I have to use "Move to: x/y" instead of "Move to: event" because the event (the item) is spawned and so it doesn't have an ID. So, not super ideal, but this works fine too ✓

The problem I'm having is that I want the item to disappear after the NPC has walked to it.

selfvariablehelp03.PNG

Right now, the NPC turns on "customerArrived" when they stop walking to the counter. They wait a sec and then they leave the room.

selfvariablehelp04.PNG

Then the "Crystal" item checks if this is the counter the NPC went to, and then erases itself once "customerArrived" is on. Technically, this whole thing works ✓

But! It only works when there's only 1 customer.

I am trying to spawn more than 1 customer at a time. The problem is the second spawned NPC overwrites variable 24 (which counter they're going to) from the first NPC, disabling the page condition from the 1st chosen item. So then the 2nd chosen item "erases" when the 1st chosen item should, and then nothing happens to the 1st chosen item.

I hope that makes sense, lol! Here is a gif of it in practice (all placeholder graphics, pls don't judge lol):
selfvariablehelp04.gif


So what I'd like to do is use self variables/self switches to control the individual spawned item events, from the individually spawned npc events. It's doin me a heckin confuse because they technically don't have event IDs.

Any ideas?

Edit: So I found that the NPC spawn does have this code I can use:
Code:
uAPI.getLastSpawnedEnemy(); - return last spawned Enemy (Game_Event object) or null
But I'm not sure how I would use it...

Downloads / Referenced Files

Log in to download

Log in, then follow the RPG Maker Developers Group to see these download links.

Log in to download
Creator Claims / Removal

If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.

#039#rpg-maker-archive#js-support

Replies (0)

No replies yet.

0 replies 1 view

Log in to reply.

User Avatar