Hello, all. I'm trying to show a different image depending on which map you are on. For example, if you are on map 43, then I want to show the image "minimap_43.png". To do this I'm using:
Script : $gameScreen.showPicture(15, "minimap_$gameMap._mapId", 0, 0, 0, 100, 100, 255, 0)
but I get the error: "Failed to load: img/pictures/minimap_$gameMap._mapId.png", so it looks like it's interpretting "$gameMap._mapId" literally. I've tinkered with it a bit, but I'm at a loss. Anyone know what I'm doing wrong?
Thanks!
Problem showing picture using "gameMap._mapId" as part of image name
● ARCHIVED · READ-ONLY
-
-
As currently wrriten, this is a String literal (meaning, it's literally a string)
Code:Javascript has no idea that you want the inside to have variable content, it just thinks it's a string."minimap_$gameMap._mapId.png"
You can use template strings to make it have variable content:
Code:`minimap_${$gameMap._mapId}.png`
Or if you're using an old version of MV that doesn't support modern Javascript, look up string concatenation for Javascript. -
Thanks so much for the super fast reply! It's working now.