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:
I'll need something different than the "delete 1".whenmilk into cheese buttonclickedifDrinks ▼containsmilkdelete1ofDrinks ▼
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,
This will go through all the items in the list until there is no more milk!ifdrinks ▼containsmilkset# ▼to1repeat untilnotdrinks ▼containsmilkifitem=#ofdrinks ▼milkdelete#ofdrinks ▼change# ▼by1
Last edited by LS97 (2012-03-19 14:21:05)
Offline
Use this.
orifdrinks ▼containsmilksetcounter ▼to0repeat untilitem=counterofdrinks ▼milkchangecounter ▼by1deletecounterofdrinks ▼elsesayThere is no milk in the inventory.for2secs
I have not tested it, but it should work.ifdrinks ▼containsmilksetcounter ▼to0repeat untilnotdrinks ▼containsmilkchangecounter ▼by1ifitem=counterofdrinks ▼milkdeletecounterofdrinks ▼
Last edited by trinary (2012-03-19 14:25:56)
Offline
trinary wrote:
Use this.
orifdrinks ▼containsmilksetcounter ▼to0repeat untilitem=counterofdrinks ▼milkchangecounter ▼by1deletecounterofdrinks ▼elsesayThere is no milk in the inventory.for2secsI have not tested it, but it should work.ifdrinks ▼containsmilksetcounter ▼to0repeat untilnotdrinks ▼containsmilkchangecounter ▼by1ifitem=counterofdrinks ▼milkdeletecounterofdrinks ▼
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,
This will go through all the items in the list until there is no more milk!ifdrinks ▼containsmilkset# ▼to1repeat untilnotdrinks ▼containsmilkifitem=#ofdrinks ▼milkdelete#ofdrinks ▼change# ▼by1![]()
If you want to delete 1 milk:
if you don't need to continue the script just use stop script instead of setting stop.setstop ▼to0ifdrinks ▼containsmilkset# ▼to1repeat untilstop=1ifitem=#ofdrinks ▼milkdelete#ofdrinks ▼setstop ▼to1change# ▼by1do other stuff
Last edited by Splodgey (2012-03-28 09:30:18)
Offline
Thanks everybody!
whenclicked
go tobroadcastopen scratch ▼and waitbroadcaststart programming ▼thinkinventory working!for2secssayYAY!!for2secsforeverbroadcastprogram
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!
whenclicked
go tocomputer ▼broadcastopen scratch ▼and waitbroadcaststart programming ▼thinkinventory working!for2secssayYAY!!for2secsforeverbroadcastprogram ▼
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 owner![]()
yes please, I think this forum is no longer needed.
I think you need to report the first post...
Yup, that always helps. Closing.
Offline