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

#1 2009-12-20 18:05:14

avatarl8
Scratcher
Registered: 2009-01-01
Posts: 11

Very advanced question.

I am working on this project that requires me to set a variable to two different thing. I have been working with scratch for a long time and I know that you can't do this.

In coding I am trying to say:
( I am going to do it in text because it is really long)

When I revive Start
Forever
Forever If Problem > 2 and Problem Time = 0
If Problem = 3
Set Problem 2 to 4 OR 5
If Problem = 4
Set Problem 2 to 5 OR 3
If Problem = 5
Set Problem 2 to 3 OR 4

What is the easiest way to take out those OR s and put something else in. I will think on it but it is a hard topic. My I release the beta for my game I will post the link so you can see what I am using the script for.

Offline

 

#2 2009-12-20 18:14:41

cds56
Scratcher
Registered: 2008-05-02
Posts: 500+

Re: Very advanced question.

that code is impossible


http://img192.imageshack.us/img192/909/meowdevlogo.pnghttp://i32.tinypic.com/pucti.png

Offline

 

#3 2009-12-20 18:16:40

avatarl8
Scratcher
Registered: 2009-01-01
Posts: 11

Re: Very advanced question.

No it isn't but I would have to add like 10 variables to make it work. I am asking if anyone knows an easier way. The way I posted I know won't work. I am looking for a way to say that but in a different way.

Offline

 

#4 2009-12-20 18:21:20

hmnwilson
Scratcher
Registered: 2007-07-04
Posts: 1000+

Re: Very advanced question.

Use a list. It's like a variable, but it can hold multiple numbers at a time. Go to the Variables tab, and select "Make a list". You can then add all the numbers using the new blocks it gives you.


I'm taking a break from Scratch until 2.0 comes out. Any messages sent between then and now probably won't be read - sorry.
(Oct. 20, 2011)

Offline

 

#5 2009-12-21 07:06:45

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Very advanced question.

Yeah, if you use a list, you can set multiple "variables"

Offline

 

#6 2009-12-21 13:00:29

avatarl8
Scratcher
Registered: 2009-01-01
Posts: 11

Re: Very advanced question.

I guess I didn't make things clear. All the code is doing is picking between 2 things to set the variable. Either 3 or 4, 4 or 5, and 3 or 5. I can do two of them with the pick random but the 3 or 5 one I can't cause I don't want it to be 4. The list won't help me their cause it will do the same thing.

Here is the screen shot of what I have I just need to fix the middle one somehow.
http://i233.photobucket.com/albums/ee175/avatarluke/untitled-11.jpg

Last edited by avatarl8 (2009-12-21 13:01:32)

Offline

 

#7 2009-12-21 13:37:36

samurai768
Scratcher
Registered: 2009-07-21
Posts: 1000+

Re: Very advanced question.

This is kinda complicated, but if it's really important you can use this method.
1.Make a list called "Problem 4 Useable Numbers" (Or something random, it doesn't matter  tongue )
2.Add 3 and 5 to the list, then make a variable called "RP" (Random Picker)
3. Use this script:
if Problem equals 3
set RP to pick random 1 to 2
set Problem 2 to item RP of Problem 4 Useable Numbers
end if

I hope that helped  smile

Offline

 

#8 2009-12-21 16:01:06

avatarl8
Scratcher
Registered: 2009-01-01
Posts: 11

Re: Very advanced question.

Never mind I found an easier way of doing it.
Here it is:

http://i233.photobucket.com/albums/ee175/avatarluke/untitled-12.jpg

This is one of the most challenging programs I have ever made.
What this script is doing is creating a random problem when a timer goes off. I have 14 scripts for one sprite.

ok, now I have to tell all of you what this script is for. I am making a game where you own an internet provider company. You have to keep your cable lines up and running so your customers are happy. You keep your server running and they are happy. That script was for the problem two. There can only be problems with your company at a time. You have to fix it. That script randomly picks a problem to occur after 10 secs has elapsed from the first problem starting. It has taken me a few days to get this far so thanks for the help with little speed bump.

Last edited by avatarl8 (2009-12-21 16:09:24)

Offline

 

#9 2009-12-24 03:28:19

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

Re: Very advanced question.

OK, so here's how you use 'pick random' to get 3 OR 5:
((pick random (1) to (2) )*2)+1.
What this does, is make it either 1 or 2. Then, it doubles it, to be 2 or 4.
Finally, it adds one, to be 3 or 5.
To get other ### or ### formulas:
Use (pick random (1) to (2) ), always with one and 2.
Multiply it by the difference between the two numbers.
Then add the difference between the difference between the two numbers, and the lowest number.

In this case, 5-3=2, so we multiply by 2. (since 5 & 3 are the numbers, 2 is the difference)
3-2=1, so we add 1. (since 3 is the lowest number, and 2 is the difference)

Another example:
If we want 6 OR 10:
We start with (pick random (1) to (2) ).
6-10=4. So, we multiply it by 4: (pick random (1) to (2) )*4
6-4=2, so we add 2: ((pick random (1) to (2) )*4)+2.

As you can see, if it is first one, then 1*4=4, and 4+2=6...
If it is initially 2, then 2*4=8, and 8+2=10!

Hope this helps.

Last edited by billyedward (2009-12-24 03:29:06)


"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-01-01 16:34:07

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Very advanced question.

Id just use a list and trial and error. But the ones already suggest are good aswell.


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#11 2010-01-18 21:26:31

antman76
Scratcher
Registered: 2008-07-01
Posts: 7

Re: Very advanced question.

you could also just pick random 3 to 4(3 or 4)

Offline

 

Board footer