This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-02-22 16:07:53

Sanchu
Scratcher
Registered: 2010-02-03
Posts: 5

Building new block

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

 

#2 2010-02-22 22:13:56

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: Building new block

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)


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#3 2010-02-23 01:58:00

Sanchu
Scratcher
Registered: 2010-02-03
Posts: 5

Re: Building new block

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

 

#4 2010-02-23 09:46:40

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: Building new block

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?


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#5 2010-02-23 10:16:57

bigreader
Scratcher
Registered: 2007-08-14
Posts: 100+

Re: Building new block

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!)


I'm currently taking a break from Scratch.
Zing - now even easier to install!

Offline

 

#6 2010-02-23 13:00:46

Sanchu
Scratcher
Registered: 2010-02-03
Posts: 5

Re: Building new block

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

 

#7 2010-02-24 00:05:11

billyedward
Scratcher
Registered: 2008-01-03
Posts: 500+

Re: Building new block

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.


"I'd love to change the world, but they haven't released the source code yet."
Check out the latest version of Streak --> http://billy.scienceontheweb.net/Streak

Offline

 

#8 2010-02-24 09:56:57

Sanchu
Scratcher
Registered: 2010-02-03
Posts: 5

Re: Building new block

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

Offline

 

#9 2010-02-26 23:49:45

billyedward
Scratcher
Registered: 2008-01-03
Posts: 500+

Re: Building new block

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.


"I'd love to change the world, but they haven't released the source code yet."
Check out the latest version of Streak --> http://billy.scienceontheweb.net/Streak

Offline

 

#10 2010-02-28 14:25:34

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Building new block

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.


nXIII

Offline

 

Board footer