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

#1 2011-11-06 01:54:29

TVflea
Scratcher
Registered: 2010-08-14
Posts: 1000+

Scripting fail

So, I have this script that is supposed to work, but doesn't.
http://www.freeimagehosting.net/t/27dea.gif
Larger size

Does anyone know why?

Last edited by TVflea (2011-11-06 01:55:25)


-iNetMaster-'s not dead, get used to it. ! big_smile .
http://is.gd/YrQzXX

Offline

 

#2 2011-11-06 01:08:52

mattb777
Scratcher
Registered: 2011-07-15
Posts: 1000+

Re: Scripting fail

You don't set No. back to 0. You are basically making No. stay what it is when Reset is broadcasted. That is a pretty advanced script, though.

I don't know if I'm right. I almost never use super-complicated scripts.


I'm back  big_smile

Offline

 

#3 2011-11-06 02:54:11

TRocket
Scratcher
Registered: 2009-08-18
Posts: 1000+

Re: Scripting fail

TVflea wrote:

So, I have this script that is supposed to work, but doesn't.
http://www.freeimagehosting.net/t/27dea.gif
Larger size

Does anyone know why?

I think you need to set No. To 1
Otherwise you are trying to read item 0 of a list


http://i.imgur.com/1QqnHxQ.png

Offline

 

#4 2011-11-06 08:10:51

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Scripting fail

The problem, I believe, is in the 'repeat until' blocks.
"No" seems to be a number variable (always set to numbers, and increased by one each time).
However, in the 'repeat until' blocks, you are asking whether "No" (let's say, the number 3) is equal to the value of the last item in the list (for example, "What's up").

In this case, 3 is not equal to "What's up". Try, instead of "item last of list", using "length of list".

Offline

 

#5 2011-11-06 08:19:50

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Scripting fail

I'm pretty sure you can put just move the "<change [No.] by (1) >" in the beginning of the loop, and eliminate the "reset" broadcast.  Since all that does is restart your search, you could just set No. to zero again.  Also, if I'm reading what you want to do right, you don't want "repeat until No. == last item of list".  You want "repeat until No. == length of list

Code:

Repeat Until( No. == length of [list] )
{
      change No. by 1
      if( item (No.) of [list] == answer )
      {
            ask (item [No. + 1] ) and wait
            set [No.] to ( 0 )
      }
}

Last edited by MoreGamesNow (2011-11-06 08:20:24)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

Board footer