I have made my game so that when the Burger Sprite is touching is touching the plate, the variable for the plate which shows the calorie value goes up by 600 and when it is taken off the plate it decreases by 600. However when I put the Burger on the plate the calorimeter reading keeps increasing past 600 eventually going into the millions by adding 600 repeatedly because of the forever function. I have tried using broadcasts but they broadcast forever and the same effect happens. I have also had some success with stop script but that doesn't allow me to add other foods to the plate. Could you please suggest a solution?
Offline
Perhaps on the plate sprite, you can have these scripts:
when gf clicked forever set [calories v] to [0] if <touching [burger v]?> change [calories v] by [600] end if <touching [fries v]?> change [calories v] by [400] end if <touching [salad v]?> change [calories v] by [300] endThis way the "calories" variable (or whatever you want to name it) will constantly be updated based on if it is touching the different foods.
Offline
Very simple.
When gf clicked forever if <[touching sprite Burger? v]> change [calories v] by [600] if <[calories v] > [600]> set [calories v] to [600] stop script end
Offline
Lucario621 wrote:
Perhaps on the plate sprite, you can have these scripts:
when gf clicked forever set [calories v] to [0] if <touching [burger v]?> change [calories v] by [600] end if <touching [fries v]?> change [calories v] by [400] end if <touching [salad v]?> change [calories v] by [300] endThis way the "calories" variable (or whatever you want to name it) will constantly be updated based on if it is touching the different foods.
That won't work because it will forever change by 600 without stopping as long as the burger is on the plate. He is trying to explain that that's happening. 8)
Offline
when gf clicked forever if <touching [plate]?> change [calories] by (600) wait until <not <touching [plate]?> > change [calories] by (-600) end end
Offline
MoreGamesNow wrote:
when gf clicked forever if <touching [plate]?> change [calories] by (600) wait until <not <touching [plate]?> > change [calories] by (-600) end end
Sorry but this does not work. When the burger is taken off the plate it keeps decreasing forever.
Offline
DaScratcher101 wrote:
Very simple.
When gf clicked forever if <[touching sprite Burger? v]> change [calories v] by [600] if <[calories v] > [600]> set [calories v] to [600] stop script end
I have tried this, however I couldnt find a red sensing function and it did not change the variable. Sorry, any other suggestions?
Offline
sidthekoala wrote:
MoreGamesNow wrote:
when gf clicked forever if <touching [plate]?> change [calories] by (600) wait until <not <touching [plate]?> > change [calories] by (-600) end endSorry but this does not work. When the burger is taken off the plate it keeps decreasing forever.
Then you either wrote that script out wrong or there's another script somewhere else that's interfering.
Offline
RedRocker227 wrote:
sidthekoala wrote:
Sorry but this does not work. When the burger is taken off the plate it keeps decreasing forever.
Then you either wrote that script out wrong or there's another script somewhere else that's interfering.
Make sure the "change [calories] by (-600)" is inside the if-statement.
P.S. I just viewed the block-thing in internet explorer for the first time, and it doesn't look nearly as good as on firefox and/or chrome. On the other hand, I'm using using a PC to view the Scratch website for the first time. Wonder what the problem is.
Offline
sidthekoala wrote:
DaScratcher101 wrote:
Very simple.
When gf clicked forever if <[touching Burger? v]> change [calories v] by [600] if <[calories v] > [600]> set [calories v] to [600] stop script endI have tried this, however I couldnt find a red sensing function and it did not change the variable. Sorry, any other suggestions?
That's what I meant. Try it now.
Offline
RedRocker227 wrote:
sidthekoala wrote:
MoreGamesNow wrote:
when gf clicked forever if <touching [plate]?> change [calories] by (600) wait until <not <touching [plate]?> > change [calories] by (-600) end endSorry but this does not work. When the burger is taken off the plate it keeps decreasing forever.
Then you either wrote that script out wrong or there's another script somewhere else that's interfering.
I tried this again and deleted the variable and made it again. It seemed as if it was corrupt somehow. Anyway, it's working now. Thank You very much.
Offline