I'm working on an RPG, and of course I have an inventory list and all. So I was wondering, how would I get one of the items to be deleted at some point, like a health potion disappearing once you drink it?
Offline
Ok. So Lets Say We Have This List:
1.Sword
2.Shield
3.Potion
4.Bow
5.Quiver
First check if the potion's there:
<[items v] contains [Potion]>Use
Delete [4 v] of [Items v]The list will then be
Last edited by hello12345678910 (2012-01-30 19:38:22)
Offline
I knew that, but thanks anyway for replying this soon. What I want to know is how to make the game find out where the potion is in the list, in order to then use that process to delete it.
Offline
Leo_the_Lion wrote:
I knew that, but thanks anyway for replying this soon. What I want to know is how to make the game find out where the potion is in the list, in order to then use that process to delete it.
Sorry. Try this:
set [itemtofind v] to [Potion] set [count v] to [1] Repeat (length of [items v]) if <(item (count) of [items v]) = (itemtofind)> set [itemposition v] to (count) end change [count v] by (1)the position of Potion will be set to Itemposition
set [itemtofind v] to [Potion] set [count v] to [1] set[length v] to (length of [items v]) set [end v] to (0) repeat until <<(count) = (length)> or <(end) = (1)>> if <(item (count) of [items v]) =(itemtofind)> set [itemposition v] to (count) end change [count v] by (1) set [end v] to (1)
Last edited by hello12345678910 (2012-01-30 19:58:52)
Offline
Thanks, very helpful! This is really going to come in handy A LOT.
Offline
Leo_the_Lion wrote:
Thanks, very helpful! This is really going to come in handy A LOT.
Yes, Your welcome. it can be used to search anything, and can also be used to do things to every item of the list individually. it also can be used for other things too, its a useful skill to learn.
Offline