I'm starting an event command... 'Select Item'
Then I store the item id in a variable. I want to check if the item selected was 'Sword'. How do I do this?
I don't know how to access the id of the 'Sword' item. Do I have to store it in another variable, then compare the two variables?
Thanks.
EDIT: Never mind. I completely forgot that every item has an id that is accessible in the Database/Items menu.
Hey, how did you actually do a check though? Is there a command to check for which ID (item) was selected?
Oh perfect! Going to try this as soon as I can!
Thanks for the help!
Got this working beautifully, so thank you for that!
I was wondering what I could do with this line of code: "$dataItems[$gameVariables.value(10)].name == "item_Name""
to modify it, such that if the player presses the Escape key while 'Select Item' is being used.
I'm getting an "null name" error since I click the Escape key before making a selection of an item (thus not giving a name to the variable which is searching for the ID of the item).
Is there a way to recognize the escape key (WHILE being in item select)?
The way I handled that is... at the top you first set your variable (where you store your item) to -1... or some dummy value that indicates a selection hasn't been made.
When a valid selection is made the variable will be 0 or greater. When cancel is hit the variable stays at -1.
So after the select item command, you use a conditional branch... and select your variable and set condition >= constant 0.
And then you put all your code that you want to run after a valid selection under that conditional branch.
If you hit cancel, your variable stays at -1 and it should skip over the whole branch.
This doesn't seem to be working for me. I have multiple items being selected from and I want the player to choose of the 7 or 8 choices of items to give. Each item will affect a meter in a different way.
I have it set up in order of logic:
set variable to -1
Select Item
If Button is Cancel (keeps variable @ -1, can include break loop)
If variable >= 0, then perform all the gamedata code and item code)
This doesn't seem to work though, and still gives me name null.
Right idea, just change your condition to "variable > 0" and I think it should work out. 🙏
($dataItems[0] is null, which explains the error. 😅)
Also, you don't need to set the variable value beforehand: it should set it to 0 if you don't pick an item, or the item ID if you do. ^_^
Perfect! Just got it fixed and working! Appreciate the help!
Ah, caethyril is right. I'm still a noob at this. No need to set the variables in advance... and cancel sets the variable to 0, so we need >0 as the condition.
Yea! Checks out!
No worries, I appreciate your help either way!
Ah so just checking the values together and seeing if the ID number matches? Gotcha! Thanks for the advice!