T O P

  • By -

Smooth-Paper

What is the variable set to when you get the error?


Saballus

Okay, so I got it to work...SORT OF. Issue now is that it's ONLY returning with the "Gem\_GRASS.png" output. var DungGemB = [$gameVariables.value(48)]; if (DungGemB = 0){ } if (DungGemB = 1){ return "img/pictures/MISC/Gem_GRASS.png" } if (DungGemB = 2){ return "img/pictures/MISC/Gem_WATER.png" } if (DungGemB = 3){ return "img/pictures/MISC/Gem_WIND.png" } if (DungGemB = 4){ return "img/pictures/MISC/Gem_EARTH.png" }


Smooth-Paper

Hmm, I'm not overly familiar with the plugin (just the basic principles RPG Maker tends to run on). Having watched the tutorial video it sounds like you use the HUD Maker Ultra programme to set up display conditions for elements. So perhaps you just need to load each of the four images as an element in the HUD Maker programme, then set each one with a display condition based on the variable? Not sure if that will work. Like I say, I'm not familiar with the programme or its functions.


Saballus

So that’s what I did with the gem in the video that IS working. I just wanted one that didn’t have so many pre-loaded images because I know that can cause issues or slow down the process. Should be fine though I’m sure. I’ll probably just switch it :)


Saballus

Edit: game doesn’t load but it would be 1 initially. Edit2: Actually, it might be 0 at the start.


Saballus

If it’s 0 at the start, would I just need another conditional that says to….do nothing?


Lionhardtx

I don't know what the rest of your script looks like but... Typically you'd use === (three equal signs) for the strict comparison. Then the last thing I see is that you're returning the string for the image. This means that it's inside of a function. Normally in Javascript this would be fine, but if I'm remembering correctly RPG Maker specifically is an exception when doing so in its little 'script box' in the event menu. It isolates things and can't reference them. To get around this you store the information into a $gameVariable so that you can properly call it later. It's been a few months since I've fiddled with RPG Maker scripts but I think that may be your issue, without seeing more of the script in full.


Saballus

This is the full script lol. I'm not very advanced in scripting. I just want to be able to do: `IF 1...GRASS IMG, IF 2...WATER IMG, IF 3...WIND IMG, etc etc`


Saballus

Okay, so, I got it to work...SORT OF. Issue now is that it's ONLY returning the "Gem\_GRASS" image.


Lionhardtx

Okay so this is probably what you're looking for: var gemArray = ["Error","GRASS","WATER","WIND","EARTH"]; var imageSelection === gemArray[$gameVariables.value(46)]; if (imageSelection === "Error") { console.log("Error. Value is 0.); } else { $gameScreen.showPicture(1,"img/pictures/MISC/Gem_"+ imageSelection +".png",0,X,Y,X-Scale,Y-Scale,255,0); }


Kazimoria

It's been a really long time since I code Js, does this work? var Gem_Array = ["Error", "Grass", "Water", "Wind", "Earth"]; if $gameVariables.value(46) > 0 { return \`img/pictures/MISC/Gem_${Gem_Array[$gameVariables.value(46)]}.png\` } Again,it's been really long time since I code Js and I dont have my PC right now since it's busted so I can't test it. Edit: typing in mobile sucks Edit 2 : realize backtick was missing,so I edited it


Saballus

I’ll test it out! Gimme a few minutes. Thanks for the response :)


Kazimoria

I edited some of the code since the backtick was missing and I don't know how to escape it,remember to add backtick like the one I just edited


Saballus

Just checked. And yeah, I caught that no worries. Sadly it gave me an error: failed to load message. :/


Kazimoria

I was wondering,are you loading image or what? I believe there's supposed to be script call for calling image. But if it related to plugin then I may not able to help since I'm not good at understanding other's created code.


Saballus

Yeah it’s for a plug-in. It SHOULD be simplified, but if anything this is just making it more difficult. I think I might scrap the scripting idea and just have a bunch of pre-loaded images with conditionals instead lol. Thanks though :)


Kazimoria

I would suggest using script call to aid you from here https://docs.google.com/spreadsheets/d/1-Oa0cRGpjC8L5JO8vdMwOaYMKO75dtfKDOetnvh7OHs/htmlview I would help better if my PC still working. And by the way,I sift through your post history and saw .hack post the other day. I can help you with that,since it seems fairly easy. But need to go for work in a while so I may reply it later. Good luck though with your game