I've 2 problems, I want to create a system inventory, so I have created an image which contains 48 places for items, and I want to say "If you have more than 48 items, you can't take this one !". Si I tried many things ...
Here's my code :
Code: Select all
if hero.inventory[48] ~= nil then
canGetItem = false
else
canGetItem = true
end
Y second problem is that the player doesn't get only 1 item but a random number with this code :
Code: Select all
if collisionPlayer(hero, musicSheet) == true then
musicSheet.isVisible = false
if canGetItem == true then
table.insert(hero.inventory, musicSheet)
end
end
I tried to replace the table.insert by :
Code: Select all
hero.inventory[hero.inventory.i] = musicSheet
hero.inventory.i = hero.inventory.i+1