Changing Event Images with Variables

NeptuneTron

Warper
Member
Joined
Jan 13, 2018
Messages
2
Reaction score
1
First Language
English
Primarily Uses
RMMV
Is anyone aware of a way to use scripting to change the image of an event? Specifically, I need to be able to designate the image for the event using a variable. Any ideas?
 

glaphen

Veteran
Veteran
Joined
Jan 13, 2019
Messages
104
Reaction score
24
First Language
English
Primarily Uses
RMMV
I use this for all my events.
Code:
var varId = $gameVariables.value(7);
var tId = $gameVariables.value(varId);
var eId = $gameVariables.value(5);
var ttId = $gameVariables.value(eId);
var eeId = $gameVariables.value(6);
$gameMap.event(eeId).setImage('Enemy' + ttId, tId);
If I remember right eeId is enemy ID, 'Enemy' is picture name then the + adds the variable to the end of it and tId is index of picture.
 

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,314
Reaction score
315
First Language
German
Primarily Uses
RMMV
It is not with Script but i just wanted to mention it in case it helps:
Create several Eventpages and mark a Variable as Page Condition.
Page1 variable1 = 0
Page2 Var1 = 1
page3 Var1 = 2
...
Every Eventpage can have its own Character Graphic.
When you change the Variable, the Eventpage will change automatically.
 

Eliaquim

Raze: The Rakuen Zero's Guardian!
Veteran
Joined
May 22, 2018
Messages
907
Reaction score
361
First Language
Portuguese - Br
Primarily Uses
RMMV
Hi there!
You can change through script call the image of the event:
Code:
$gameMap.event(2)._characterName = "characterimage"
Also, you can change the current index that the event is using in this image:
Code:
$gameMap.event(2)._characterIndex = X
The first one must be a string(a word inside quotes), that has to be the name of an image that it is inside your img/character folder.

In the second one, you have to replace the X for a number of 0 to 7.


So, to use variables to change the images, you can set a variable value to a string through the script call field(without the file extension) in Control Variable operation. Then, you use this script call:
Code:
$gameMap.event(2)._characterName = $gameVariables.value(x);
And to change the index, you only have to set a number value from 0 to 7 in any variable you want, then you call the script call:
Code:
$gameMap.event(2)._characterIndex = $gameVariable.value(x);
I do not test changing maps to see if the image still prevails.
Hope it helps!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Oh, stop with the Melodrama...

...Listen to it instead!

anybody else like getting baked whilst coding?

When you go to the beach watch out for coconuts. Coconuts are more dangerous than sharks. Fact.
Try to get into pixelart again, so far its a sucess.
Also finally found a useful pixeltutorial which helps a lot.
♫ Anyone knows an ant can't move a rubber tree plant, but he's got high hopes, he's got high hopes, he's got high apple pie in the sky hopes ♫

Forum statistics

Threads
93,617
Messages
913,996
Members
123,185
Latest member
Disaffect
Top