omnikeith

Veteran
Veteran
Joined
Jan 7, 2015
Messages
34
Reaction score
1
First Language
English
Primarily Uses
I want to use a if then statement in the move route of an event to chance the graphic of the event and have it run once so the graphic changes when it switches to an event page and then you can trigger it with the action button. I will have many of these events all wit their own self variables from the self data script i found and all will change the graphic differently. I DO NOT WANT A TON OF PUBLIC VARIABLES for each event as they would all need one per graphic per event so like 15 x 50 variables is too much. so far i have this:


(self_metadata("CropType") == "Wheat") ? set_graphic("$Wheat", 0) : nil


I tried a bunch of different ways including...


if (self_metadata("CropType") == "Wheat") then set_graphic("$Wheat", 0) end


what to do...
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,789
Reaction score
15,916
First Language
English
Primarily Uses
RMMV
In your move route, use a script command:


set_graphic("$Wheat", 0) if self_metadata("CropType") == "Wheat"


I'm not familiar with the self data script you're using, so everything after the if is based on the assumption that you have looked up the correct way to test the value of the CropType metadata.  What I am sure of is that, as a one-liner in a move route's Script command, the command has to come first, and the condition after.
 

omnikeith

Veteran
Veteran
Joined
Jan 7, 2015
Messages
34
Reaction score
1
First Language
English
Primarily Uses
I had to finagle it a bit. the self_metadata call couldn't be referenced so i used the global reference version and got it to work: 


set_graphic("$Wheat", 0) if $game_self_metadata[["Forest_of_Yeldarb", "Plot01", "CropType"]] == "Wheat"


Edit: It didn't work after all. and it isn't trowing any errors...
 
Last edited by a moderator:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,789
Reaction score
15,916
First Language
English
Primarily Uses
RMMV
Where are you putting this command?  If you put it on the event and then make another page active, then the sprite that's on the other page will be shown.  You need to execute this script call AFTER the new page is active.
 

omnikeith

Veteran
Veteran
Joined
Jan 7, 2015
Messages
34
Reaction score
1
First Language
English
Primarily Uses
I got it to work. I was using the map and event names not the ids. the new code is:

set_graphic("$Wheat", 0) if $game_self_metadata[[7, 1, "CropType"]] == "Wheat"
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,789
Reaction score
15,916
First Language
English
Primarily Uses
RMMV
haha!  It took a while, but you feel good when it's finally working :)
 

omnikeith

Veteran
Veteran
Joined
Jan 7, 2015
Messages
34
Reaction score
1
First Language
English
Primarily Uses
now i need a piece of code that outputs the id of the current event that is activating the move route. like:

set_graphic("$Wheat", 0) if $game_self_metadata[[7, this.event_id, "CropType"]] == "Wheat"



But obviously this.event_id doesn't work.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,789
Reaction score
15,916
First Language
English
Primarily Uses
RMMV
If you're doing it inside a move route, just try @event_id instead.  Steam won't let me open Ace because it thinks it's already running, so I need to reboot before I can check it for you, and I can't reboot because I'm uploading something that's going to take a while.


If @event_id doesn't work, try @id instead.


You can also use $game_map.map_id instead of 7, so you don't have to hardcode the map id.  This makes it easier to copy/paste the same event onto the same or other maps, without having to change things.
 

omnikeith

Veteran
Veteran
Joined
Jan 7, 2015
Messages
34
Reaction score
1
First Language
English
Primarily Uses
@id and  $game_map.map_id worked. Thanks so much. I had been working on this for a while. new code is:

set_graphic("$Wheat", 0) if $game_self_metadata[[$game_map.map_id, @id, "CropType"]] == "Wheat"
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,789
Reaction score
15,916
First Language
English
Primarily Uses
RMMV
Do you have a link to the metadata script?  I can give you a small script to add, which will make that whole $game_self_metadata[[$game_map.map_id, @id, "CropType"]] a whole lot easier to type - it'll be more like metadata("CropType") is all you need to enter.  In fact, the script may already have an easier way to access it.
 
Last edited by a moderator:

Latest Threads

Latest Profile Posts

would anyone here be interested in rough concept art for the main protagonist of my game that might get changed later? :kaoswt2:
I guess I have no idea how to properly upload a custom font lmao. The menu fonts are too damn small.

Font_Size.PNG
Dev be like: "I'll make the character goes amnesia so I could explain the world and the lore better and immersive to the players"

Forum statistics

Threads
124,435
Messages
1,163,632
Members
163,249
Latest member
Daniel377373
Top