I am currently making it so you can “select” items on your hotbar. Whenever the player selects any slot from 2-9, it recieves the error “no such node: inv0”. I have 3 nodes for each “slot”, the square around the slot, the sprite of the held item, and the item count for that slot. I am using for loops for this, so i can do something like
function on_input(self, action_id, action)
for i=1,9,1 do
if action_id == hash(i) then
gui.play_flipbook(gui.get_node("inv" .. heldSlot), "inventory icon")
self.guiPos = gui.get_position(gui.get_node("inv" .. heldSlot))
self.guiPos.z = 0
gui.set_position(gui.get_node("inv" .. heldSlot), self.guiPos)
heldSlot = inventory[i]
self.guiPos = gui.get_position(hotbarSlot[i])
self.guiPos.z = 1
gui.set_position(hotbarSlot[i], self.guiPos)
gui.play_flipbook(hotbarSlot[i], "inventory selected")
break
end
end
end
I am setting the “current” selected slot’s square to normal, then setting the new selected slot’s square to an expanded version, and to set the old selected slot, i use gui.get_node(“inv” … heldSlot) to get the previous, set its new values, then set heldSlot to the new held slot. I don’t know why if you select a slot 2-9 it believes that the number is actually 0, as in my for loop, it only goes through numbers 1-9. Can anybody help me?
Also, this is probably very horribly explained. Sorry if thats the case.