Hi, I am trying to build new block which have combined functionality of other block.
For example jump
untill[some specific height not come| isOnEdge]
turn 15
move 10
turn -15
wait
similarly for coming down.The problem i am facing is regarding wait,can anyone tell me how to use wait:elapse:from block.
when i am using, its waiting but i can't see any changes on screen untill the function is complete.I want it to be performed step by step but its giving final step.
Thanks
Priti
Offline
You use wait like this block:
[blocks]
<wait( any )secsc>
[/blocks]
You may be wanting it to recurse? Just replace wait until with:
[blocks]
<repeat until> anything
your main code
<end>
[/blocks]
Last edited by Greatdane (2010-02-22 22:14:05)
Offline
I am using that only,the function for wait is wait:elapsed:from:
first of all i don't know how i should pass argument in that and secondly when i am passing wait:1 elapsed:Time millisecond from: it making the whole funcion to wait ie i can't see any output untill the final step.
the code what i used is for block walk
[self isOnEdge] whileFalse:[
forward:10.
wait:1 elapsed:Time millisecondClockValue from:0.
].
but this is showing only final position
Offline
I can't really understand what you are saying like that. Is it that in that loop everything doesn't happen until the completion of the last step?
Offline
I think you might be executing the block as "atomic", which will wait until the scripts in the block have finished to update the screen. Try unchecking the box at the top of the block-editing screen to make your block run in realtime. (I'm writing this from my memory of BYOB, so if this doesn't make sense, post back. Hope this helps!)
Offline
sorry i didn't understand what you said.
i think i have confused everyone..i have very basic requirement i want to call wait:elapsed:from(which is method corresponding to <wait( )secsc> )
method inside my code but i don't know how to pass argument.Main objective of my work is to create a new gui in which 2 or 3 block are combined together to create new block .or is there any variable for timer as we have in other language so that i can introduce delay in my code.
Offline
Sanchu wrote:
sorry i didn't understand what you said.
i think i have confused everyone..i have very basic requirement i want to call wait:elapsed:from(which is method corresponding to <wait( )secsc> )
method inside my code but i don't know how to pass argument.Main objective of my work is to create a new gui in which 2 or 3 block are combined together to create new block .or is there any variable for timer as we have in other language so that i can introduce delay in my code.
There is a timer variable.
In squeak, the way to pass arguments to a function is to put them after the quote.
So, if there was an addition function add:to:, we would use add: 4: to: 2 to add 4+6.
To make a block return this, we use ^add:4 to: 6.
Offline
Sanchu wrote:
I want to know what will be the parameter for this function call its not working for me.
wait:10 elapse:0 from:Time:millisecondClockValue
this is the way i am calling but its not working for me.Help me.
Thanks
Priti
Oh, I see what you are doing.
This is a function, not a procedure; it is meant to execute code solely to return a value, not to do anything.
The best solution is to make a wait procedure. I'll reply with this code soon.
Offline
OK, I don't really think you should make this a separate method, because I believe squeak only repaints the world after it has gone 1 complete step or whatever, meaning that no matter what you do, Squeak will wait to repaint you sprite until the method has finished executing. You're better off just making it with already-existing Scratch blocks.
Offline