How do you make an object do either of something. For example, when flag clicked, do either move 10 steps or glide to x 0 y 0. If this is impossible then I guess it is a suggestion. If it is a suggetion, tell me If you support.
Last edited by turkey3 (2012-03-14 17:07:11)
Offline
It's possible, there are a few ways to do it.
You will need a variable dedicated just to this
when gf clicked set [variable v] to <pick random [1] to [2]> if <<variable>=[1]> move (10) steps end if <<variable>=[2]> glide to x:(0)y:(0) endYou can also use a list for this
Last edited by MaxFlyboy (2012-03-14 17:56:23)
Offline
An even more efficient way:
when gf clicked if <(pick random [1] to [2]) = [1]> move [10] steps else glide to x: [0] y: [0] end
Offline
bobbybee wrote:
An even more efficient way:
when gf clicked if <(pick random [1] to [2]) = [1]> move [10] steps else glide to x: [0] y: [0] end
Yes that also works, but I usually try to stay away from the if else blocks
Offline
MaxFlyboy wrote:
bobbybee wrote:
An even more efficient way:
when gf clicked if <(pick random [1] to [2]) = [1]> move [10] steps else glide to x: [0] y: [0] endYes that also works, but I usually try to stay away from the if else blocks
Why, though? Chaining if-else blocks is often helpful (if there were many conditions)
Offline
MaxFlyboy wrote:
I am one of those Scratchers who use scratch as a starting point for harder programs, in fact I'm probably going to leave in a month or two
Most programs have if/else functions.
And I think that method was best.
Offline