i am making a game where i would like to be able to make items that can only get in the players inventory by passing over the item also im not to sure i know how to make a inventory
Offline
When gf clicked Delete [all] of [list v] Forever If <touching [sprite you want it to touch v] > Add [item name that player just touched] to [list v] Hide End End
Last edited by numberonegamers (2013-01-15 19:25:25)
Offline
that will help with keys and such but i want to be able to also get the items from the inventory
Offline
i also think i have a way of doing it will this work
[ scratchblocks ]
when gf clicked
if touching < sprite 1 >
brodcast [ inventory ]
hide
Offline
pigswithguns wrote:
that will help with keys and such but i want to be able to also get the items from the inventory
I answered the exact same question in the Spanish forum. What you need to do, is determine what particular item the player wants, and check every single item in the list, to see if it's what the player asked for. If so, something happens and the item can then be deleted. Here's one way to go about it:
when I receive [use item v]
ask [Which item?] and wait //see what item the player wants
set [i v] to [1] //reset iterator variable.
repeat (length of [Backpack v]) //for each item in the Backpack...
if <(item (i) of [Backpack v]) = (answer)> //if it's the one the player wants...
if <(item (i) of [Backpack v]) = [food]> //check if it's this particular item,
broadcast [food v] //do the respective action,
delete (i) of [Backpack v] //and delete it (it's a consumable)
end
if <(item (i) of [Backpack v]) = [magic ball]> //example of non-consumable
broadcast [magic ball v]
end
stop script //we found what we wanted, so we break the loop
end
change [i v] by [1] //if it isn't the item we want, check next item
end
say [You don't have that item!] for (2) secs //this will happen only if the loop isn't broken; i.e. we didn't find the item
Offline