Changing Event Graphic on Specific Page through Script Call?

Is there a way to change event graphic on a specific page through Script Call?

I am dynamically creating events which randomize the Event Graphic. Issue is when Self Switch Activates and the Page changes, his graphic changes too. I am using Mog Event Sensor to activate self switch D.

2.png
1.png
If you just use the provided commands, it will only change the image on the active page, and when you change variables, switches, self switches, etc and it activates a new page the image will be reset. But if you go to the source, where it's pulling the page data from, and change it there, then it should stay that way for that page, as long as you're on the map. If you leave the map and return later, obviously, it will be reset to what you saved in the editor. If you want the change to stick, you're going to have to start looking at plugins to include this stuff with the save data.

If you want to change the image on page 5 (remembering that arrays start at 0 so the index will be 4), I think it would be something like this (in a script call):

Code:
var img = $dataMap.events[this.eventId()].pages[4].image;
img.characterName = "Actor1";
img.characterIndex = 0;
1585995785851.png


I tried your code, which gives me this. It could be possible as I am spawning events from other map using Galv's Event Spawner, the specific event doesnt have a proper ID.

I first tried it on the parallel process of the spawned event, which gave me this message. I then tried it on the spawner itself, which gave me the same message.
1585996009463.png

1585996032577.png


EDIT: I realised my code was wrong. Ive changed it according to @Shaz .
Still the black screen though :C
1585996482162.png
It could be possible as I am spawning events from other map using Galv's Event Spawner, the specific event doesnt have a proper ID

It probably will have an id by the time it's spawned, but it probably won't be in $dataMap. It depends on what the event spawner plugin does. If it has the source map permanently loaded, there might be a way to refer to it, but in that case, it probably WILL continue from map to map, at least until you close the game.
It does have an ID. Can't we acess event's pages from $gameMap?

Original thread: https://forums.rpgmakerweb.com/threads/changing-event-graphic-on-specific-page-through-script-call.119798/