I made a drink inventory using a list. The inventory will include water, milk, tea, coffee, and beer in it when I finish it. But right now I've slammed into a mental wall.
In addition to the milk as being a drink, I want it possible for the milk to turn into cheese. Cheese, of course, is not a drink, but a food.
My problem: I don't know how to delete a "milk" item from my list when the item could be ANYWHERE. As far as I know, the list blocks almost all include the need to fill in what number, in this case, the "milk" item is in.
For example, I need something to go in this script:
when [milk into cheese button] clicked if < [Drinks v] contains [milk]> delete (1) of [Drinks v] endI'll need something different than the "delete 1".
Offline
what you have is a good start, but I suggest using some kind of method to go through all of the list items and delete them if necessary. For example,
if <[drinks v] contains [milk]> set [# v] to [1] repeat until <not <[drinks v] contains [milk]>> if <(item (#) of [drinks v]) = (milk)> delete (#) of [drinks v] end change [# v] by (1) end endThis will go through all the items in the list until there is no more milk!
Last edited by LS97 (2012-03-19 14:21:05)
Offline
Use this.
if <[drinks v] contains [milk]> set [counter v] to (0) repeat until <(item (counter) of [drinks v])=[milk]> change [counter v] by (1) end delete (counter) of [drinks v] else say [There is no milk in the inventory.] for (2) secs endor
if <[drinks v] contains [milk]> set [counter v] to (0) repeat until <not <[drinks v] contains [milk]> > change [counter v] by (1) if <(item (counter) of [drinks v]) = [milk]> delete (counter) of [drinks v] end endI have not tested it, but it should work.
Last edited by trinary (2012-03-19 14:25:56)
Offline
trinary wrote:
Use this.
if <[drinks v] contains [milk]> set [counter v] to (0) repeat until <(item (counter) of [drinks v])=[milk]> change [counter v] by (1) end delete (counter) of [drinks v] else say [There is no milk in the inventory.] for (2) secs endorif <[drinks v] contains [milk]> set [counter v] to (0) repeat until <not <[drinks v] contains [milk]> > change [counter v] by (1) if <(item (counter) of [drinks v]) = [milk]> delete (counter) of [drinks v] end endI have not tested it, but it should work.
I think I'll try the first one. The second one looks like it will delete all of the milk, which I don't want to do. Either way, thanks!
Offline
LS97 wrote:
what you have is a good start, but I suggest using some kind of method to go through all of the list items and delete them if necessary. For example,
if <[drinks v] contains [milk]> set [# v] to [1] repeat until <not <[drinks v] contains [milk]>> if <(item (#) of [drinks v]) = (milk)> delete (#) of [drinks v] end change [# v] by (1) end endThis will go through all the items in the list until there is no more milk!
If you want to delete 1 milk:
set [stop v] to [0] if <[drinks v] contains [milk]> set [# v] to [1] repeat until <(stop) = [1]> if <(item (#) of [drinks v]) = (milk)> delete (#) of [drinks v] set [stop v] to [1] end change [# v] by (1) end end do other stuffif you don't need to continue the script just use stop script instead of setting stop.
Last edited by Splodgey (2012-03-28 09:30:18)
Offline
Thanks everybody!
when gf clicked go to [computer v broadcast [open scratch v] and wait broadcast [start programming v] think [inventory working!] for (2) secs say [YAY!!] for (2) secs forever broadcast [program] end
Offline
Unite wrote:
Well, It looks like your done here! Thanx Splodgy, Trinary, and LS97
Are you just trying to get your post count up? You really didn't need to post this. And that's Splodgey.
jedidiahzhu wrote:
Thanks everybody!
when gf clicked go to [computer v] broadcast [open scratch v] and wait broadcast [start programming v] think [inventory working!] for (2) secs say [YAY!!] for (2) secs forever broadcast [program v]
Fixed the scratchblocks.
Last edited by Splodgey (2012-03-28 09:31:44)
Offline
Unite wrote:
Well, It looks like your done here! Thanx Splodgy, Trinary, and LS97
Thanks for your Report requesting a topic close - however we usually prefer to hear that from the topic owner
Offline
Paddle2See wrote:
Unite wrote:
Well, It looks like your done here! Thanx Splodgy, Trinary, and LS97
Thanks for your Report requesting a topic close - however we usually prefer to hear that from the topic owner
yes please, I think this forum is no longer needed.
Offline
jedidiahzhu wrote:
Paddle2See wrote:
Unite wrote:
Well, It looks like your done here! Thanx Splodgy, Trinary, and LS97
Thanks for your Report requesting a topic close - however we usually prefer to hear that from the topic owner
yes please, I think this forum is no longer needed.
I think you need to report the first post...
Offline
Splodgey wrote:
jedidiahzhu wrote:
Paddle2See wrote:
Thanks for your Report requesting a topic close - however we usually prefer to hear that from the topic owneryes please, I think this forum is no longer needed.
I think you need to report the first post...
Yup, that always helps. Closing.
Offline