Ok, im working on a game, and I want a mouse to follow a set path. Iv made the path and stored it in a list.
But when I have the mouse seperate the two values its very slow.
http://img404.imageshack.us/img404/7702/mousescripts.gif 
Is there anyway to speed this script up?
The bottom script is something i made to make path. Its not that important.
The obvious one would be to have the values in two seperate items, but is there a way to do this without using two items?.
Offline
Kingdaro wrote:
Trust me, I've been searching the forums for ages on how to "Speed up scripts" in your case, and I'd have to say the only way to do it is to use multiple scripts.
I was meaning to streamline it, metaphoricaly.
Offline
Well, since you know that the x and y positions are going to be at max 4 characters long, couldn't you store all positions in a list like this:
[XXXX|YYYY] [XXXX|YYYY] [XXXX|YYYY]
So the position (-23,167) would be stored as this:
[-023|0167]
That way you could just use a couple of join(|) blocks to read each index like so:
set x_read_from_index to (join items 1,2,3,4) of list set y_read_from_index to (join items 6,7,8,9) of list //Using string 'join' blocks here but I don't want to write them out...you know what I mean
Scratch would read "-007" as "-7" I believe so there is no further coercion needed.
Also I think it would be faster if the variable ":level" wasn't being checked against long strings...I've never verified this but it seems like a test against an integer would be much faster.
Last edited by fullmoon (2010-05-30 16:19:44)

Offline
Here's an example of what I'm talking about:
http://scratch.mit.edu/projects/halfbaked_fullmoon/1087656
It's actually quite speedy. I removed the bar in between the x/y coordinates because the online player was having a problem with it.

Offline