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

#1 2013-02-09 09:15:11

shadowmouse
New Scratcher
Registered: 2013-02-03
Posts: 100+

Problem in BYOB

I am trying to make a level select screen but use variables to set all the levels icons out at a certain distance apart. I am using the script:

when gf clicked
set [how many levels v] to [10]
add (object [allSprites v]) to [placer v]
delete (1 v) of [placer v]
go to x: (-210) y: (150)
script variables (a) (b) (c) (d)
set (a) to [-180]
set (b) to [150]
set (c) to [1]
set (d) to [0]
repeat until < (d) = [1] >
run ( go to x: (a) y: (b) of (item (c) of [placer v] )
if < < (a) = [210] > and < (b) > [-150] > >
set (a) tp [-210]
set (b) to ((b) - (60))
else
if <(a) = [210] >
stop script
else
set (a) to ((a) + (60))
end
end
if <not < (c) + (how many levels)>>
set (c) to ((c) +(1)
else
set (d) to [1]
end
end
the run doesn't work in scratchblocks but it says run (the script go x sad a) y sad b)) of item (c) of [placer v].
When I play this script in stops working and I have identified the problem as the  item (c) of [placer v] block that is put in the second input of the ([x position v] of [sprite 1 v]) Is there anything else that I can do that would work?

Offline

 

#2 2013-02-09 09:18:12

shadowmouse
New Scratcher
Registered: 2013-02-03
Posts: 100+

Re: Problem in BYOB

the bit with the smilies was meant to say

go to x:(a) y:(b)

Offline

 

#3 2013-02-18 03:15:46

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: Problem in BYOB

Well, first, are you thinking that after the ADD ... TO (PLACER) block you've added several items, each of which is a sprite?  You've actually just added one item, a list of sprites, and when you do the DELETE you're deleting the entire list.

If I'm understanding the intent correctly, PLACER should be a variable, not a global list, and you should SET (PLACER) TO ... to get the list of sprites.

I think that explains the crash.  But also, I think that you want to say

RUN [ (GO TO X: ( ) Y: ( ) ) OF (ITEM ...) ] WITH INPUTS (A) (B)

because the variables A and B aren't going to be accessible to the other sprite.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

Board footer