Change Event Graphic via Script Call

Greetings, and thanks for taking your time to read through this!


I have following 'problem': I am trying to change an event's graphic at runtime depending on the current in-game time.


I already thought about simply using a second event page, but the variables that the graphic depends on are too 'complex' to put into the conditions. I am also well aware that there is a premade function for that, but I would really prefer to use my own script for it.


Ideally, I would be looking for a method like:


#This is pseudo code! It WON'T work and solely exists to represent my idea of how the command could look
$game_map.changeEventSprite(event_id, sourcesheet, sprite_id)
#where:
# event_id: simply the ID of the event (wow)
# sourcesheet: name of the file I take the sprite from
# sprite_id: ID of the sprite on the sourcesheet that will be used




There probably already is a thread about this, but I couldn't find it. So if any of you know of an existing one that concerns the same topic, please provide me with a link ^^


EDIT: To prevent confusion, I am only looking for a method to change the Sprite. I already scripted the required flow-control.


EDIT: I have found the method I was looking for:


$game_map.events[id].set_graphic("character_name", character_index)




I would greatly appreaciate any solutions or workarounds! ^^


~Crowley
$gamePlayer._characterName = "NameOfSpriteSheet";
$gamePlayer._characterIndex = spriteIndex;
$gameMap._events[eventId]


🙂 hope this is helpful, the last line just simply is access to events. replace it with $gamePlayer to access events, rather than the player.
I am quite sorry, but I don't really understand the code you provided.


If I am not mistaken, the '_' are in between game and player (game_Player) rather than at the beginning of the method. Furthermore, if I am understanding that right (which I probably am not), your code would manipulate some global variables that aren't even linked to the specific event. I also believe that Ruby is one of the programming languages that don't use ';' to seperate lines.


I would very much like an example so I can understand it (sorry for being so dim)


~Crowley
the code above changes the player's graphic. Your request was to change an event's graphic, so that code is of no use to you.


Note, if you change an event's graphic via a script call, that change will not be saved if you leave the map and return - it will have reverted to the original graphic on the active page.
ohh, I'm sorry I was posting in JavaScript I coulda swore this was for MV! goes to show don't post when tired T_T ignore everything I said xD it's invalid. lol sorry bout that, I'd post the solution but it seems you've already found it. good luck on your project! 🙂  

Original thread: https://forums.rpgmakerweb.com/threads/change-event-graphic-via-script-call.59378/