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

#1 2011-03-29 17:04:45

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

<IP | | is hosting mesh?>

Can anyone improve my code

(For panther)

jonnydean1
IP $String$ is hosting mesh?
b
#297BC6
| var1 sFrame server inmesh time timers |
self leaveMesh. time_ self timer. var1_ self stringLength: (t1). var1 > 10 ifTrue: [ self joinMesh: (t1).      (sFrame _ self ownerThatIsA: ScratchFrameMorph) ifNil: [sFrame _ (self ownerThatIsA: OffscreenWorldMorph) frame].     (server _ sFrame workPane scratchServer) ifNil: [inmesh_ false.].     inmesh_ server. var1_ false. inmesh = false ifFalse: [ var1_ true. ]. self leaveMesh. timers_ self timer. time_ timers - time. time < 0.5 ifTrue: [ ^ var1. ] ifFalse: [ ^ false. ]. ] ifFalse: [ ^ false. ].


It works, but its very slow if its not being hosted. Is there a better way?


You can now reach me on Twitter @johnnydean1_

Offline

 

#2 2011-03-29 22:08:35

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: <IP | | is hosting mesh?>

Can you somehow change the timeout?


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#3 2011-03-30 11:18:21

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: <IP | | is hosting mesh?>

Use code along the lines of this:
[code that reports true while detecting] whileTrue: [world doOneCycleNow.].

This will let other processes continue running while the code executes.

Last edited by TheSuccessor (2011-03-30 11:25:10)


/* No comment */

Offline

 

#4 2011-03-30 15:13:04

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: <IP | | is hosting mesh?>

Can either of you have a go at making it please. I would like this block for mesh friend lists, yet I cant use it as its too slow!


You can now reach me on Twitter @johnnydean1_

Offline

 

#5 2011-03-30 16:57:35

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: <IP | | is hosting mesh?>

johnnydean1 wrote:

Can anyone improve my code

(For panther)

jonnydean1
IP $String$ is hosting mesh?
b
#297BC6
| var1 sFrame server inmesh time timers |
self leaveMesh. time_ self timer. var1_ self stringLength: (t1). var1 > 10 ifTrue: [ self joinMesh: (t1).      (sFrame _ self ownerThatIsA: ScratchFrameMorph) ifNil: [sFrame _ (self ownerThatIsA: OffscreenWorldMorph) frame].     (server _ sFrame workPane scratchServer) ifNil: [inmesh_ false.].     inmesh_ server. var1_ false. inmesh = false ifFalse: [ var1_ true. ]. self leaveMesh. timers_ self timer. time_ timers - time. time < 0.5 ifTrue: [ ^ var1. ] ifFalse: [ ^ false. ]. ] ifFalse: [ ^ false. ].


It works, but its very slow if its not being hosted. Is there a better way?

jonnydean1
IP $String$ is hosting mesh?
b
#297BC6
| var1 sFrame server inmesh time timers |
self leaveMesh. time_ self timer. var1_ self stringLength: (t1). var1 > 10 ifTrue: [ self joinMesh: (t1).      (sFrame _ self ownerThatIsA: ScratchFrameMorph) ifNil: [sFrame _ (self ownerThatIsA: OffscreenWorldMorph) frame].     (server _ sFrame workPane scratchServer) ifNil: [inmesh_ false.].     inmesh_ server. var1_ false. inmesh = false ifFalse: [ var1_ true. ]. self leaveMesh. timers_ self timer. time_ timers - time. time < 0.5 ifTrue: [ ^ var1. ] ifFalse: [ ^ false. ]. ] ifFalse: [ ^ false. ].

It works better. ;D
EDIT
Never mind, yours is better.
EDIT
Okay, NOW mine is better.

Last edited by Pecola1 (2011-03-30 17:02:14)


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#6 2011-03-30 16:59:07

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: <IP | | is hosting mesh?>

IP $Number$ is hosting mesh?

FAIL!!!

Numbers cannot have more than 1 decimal place and IP address' do!


You can now reach me on Twitter @johnnydean1_

Offline

 

#7 2011-03-30 17:03:41

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: <IP | | is hosting mesh?>

johnnydean1 wrote:

IP $Number$ is hosting mesh?

FAIL!!!

Numbers cannot have more than 1 decimal place and IP address' do!

That is the only flaw, but with the string insert it works better.


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#8 2011-04-01 16:44:31

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: <IP | | is hosting mesh?>

Bump


You can now reach me on Twitter @johnnydean1_

Offline

 

Board footer