#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Posts: 23Member

Hello, I'm scripting a game but I can't resolve a problem: I want to change tree cubes randomly from place: one with the X 56 another with the X 156 and another with the X 256 But they can't be on the same place, so I don't know how change their place randomly and every one have hiw own place, please help me, and sorry for my English, I'm french. Thank's therefor

• Posts: 23Member

I'm scripting a game but have a problem: I want to change the X from an actor to 156 or 256 or 356 and I want do that randomly, but when you choose the random function you can only put a minimum and a maximum, and I don't wanna change the X to for example 223, it must be 156 or 256 or 356. There is also no functions that express the word 'or' I guess, so thank's to help me and sorry for my English, I'm French

• NorwayPosts: 112Member

Put the tree values in rows in a table, and use the random function on the tree rows to get your randox x

• London, UK.Posts: 12,821Member

(random(1,3)*100)+56

• NorwayPosts: 112Member

Ehem, of course use the brilliantly simpler solution of @Socks ...

• Posts: 11,297Member, Sous Chef, PRO, Senior Sous-Chef
edited February 2017

I would have gone with (random(6,8)-5)*1000)/10+560/((mod(random(1,4),1)+10)...

...but I agree @Socks' method is simpler.

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

• Posts: 23Member

Thanks you very much, I will do it

• London, UK.Posts: 12,821Member

@tatiang said:
I would have gone with (random(6,8)-5)*1000)/10+560/((mod(random(1,4),1)+10)...

@tatiang said:

• ImagineLabs.rocks Posts: 5,426Member, BASIC

@socks and @tatiang, STOP IT! There is only supposed to be ONE way to do things!!!

• London, UK.Posts: 12,821Member
edited February 2017

@jamie_c said:
@socks and @tatiang, STOP IT! There is only supposed to be ONE way to do things!!!

I nearly forget:

256+random(-1,1)*100

• London, UK.Posts: 12,821Member
edited February 2017

. . . or

156 +random(0,2)*100

• Posts: 522Member

Is this how you reach 12,000 posts?

• Posts: 23Member

Is this how you reach 12,000 posts?

Haha, amazing

• Posts: 23Member

and thanks every body

• London, UK.Posts: 12,821Member

Is this how you reach 12,000 posts?

No, that would be . . .

random(0,0)+12,000

• London, UK.Posts: 12,821Member
edited February 2017

Change A to random(0,2)
Change B to mod(A+(random1,2),3)
Change C to 3-(A+B)

Move to / Spawn:

Cube 1 to A *100+56
Cube 2 to B *100+56
Cube 3 to C *100+56

• Posts: 23Member

thanks you very much, but I don't understand what mod(...) is, can you explain, I want to understand what I do, other side it isn't usefull to just do what you say

• Posts: 1,158Member, PRO

C'est une fonction mathématique.

Socks Il est mathimatics dieu. Les gens ne comprennent pas. Haha.

Script. nous disons Rules in Gamesalad.

• Posts: 23Member

Haha merci beaucoup, je vais faire ca, c'est gentil

• Posts: 9,008Member, Sous Chef, PRO, Bowlboy Sidekick

• Posts: 23Member

@Braydon_SFX said:

Yes, sorry, but it's another subject, so I think it's normal I do two thread, no ?

• Posts: 23Member

@Socks said:
Change A to random(0,2)
Change B to mod(A+(random1,2),3)
Change C to 3-(A+B)

Move to / Spawn:

Cube 1 to A *100+56
Cube 2 to B *100+56
Cube 3 to C *100+56

thank you very much, but I did a little calculation, and I saw it doesn't work

for example:
A=2
B=mod((2+2)/3)
B=1/3
C=3-(2+1/3)
C=2/3

cube 1: 2*100 + 56 = 256
cube 2: 100/3 + 56 = 89.333 (89+(1/3))
cube 3: 200/3 + 56 = 122.666 (122+(2/3))

maybe there is a fault in your calculation, thank's for help me

• Posts: 9,008Member, Sous Chef, PRO, Bowlboy Sidekick

@warloparthur@gmail.com said:

@Braydon_SFX said:

Yes, sorry, but it's another subject, so I think it's normal I do two thread, no ?

It's related so I think keeping it all in one thread is a good idea.

• Posts: 23Member

ok

• London, UK.Posts: 12,821Member
edited February 2017

@warloparthur@gmail.com said:
thank you very much, but I did a little calculation, and I saw it doesn't work

for example:
A=2
B=mod((2+2)/3)
B=1/3
C=3-(2+1/3)
C=2/3

cube 1: 2*100 + 56 = 256
cube 2: 100/3 + 56 = 89.333 (89+(1/3))
cube 3: 200/3 + 56 = 122.666 (122+(2/3))

maybe there is a fault in your calculation, thank's for help me

Your calculation is different to the one I suggested.

For example for cubes 2 and 3 you are dividing 100 by 3 ? There is no division in my suggested calculation ?

Also I'm not sure what this is . . . . B=mod((2+2)/3) . . . ?

My suggestion for B was . . . . . B=mod(A+(random1,2),3)

?

• Posts: 23Member

ok, I begin to understand, and if I have four blocks, X1: 56 X2: 156 X3: 256 X4: 356 than the calculation is A=random(0,3) B=mod(A+random(1,3),4) C=4-(A+B), no ? Thank's for helping me

• London, UK.Posts: 12,821Member
edited February 2017

@warloparthur@gmail.com said:
ok, I begin to understand, and if I have four blocks, X1: 56 X2: 156 X3: 256 X4: 356 than the calculation is A=random(0,3) B=mod(A+random(1,3),4) C=4-(A+B), no ? Thank's for helping me

This . . . . X1 X2 X3 X4 . . . . is 4 values.
This . . . . A B C . . . . is 3 values.

???

Also, if A is 0 and B is 1 then C=4-(A+B) would be 3.

So, for four values, X1, X2, X3 and X4, in this example you would have the three values 0, 1 and 3 ?

• Posts: 23Member

@Socks said:

@warloparthur@gmail.com said:
ok, I begin to understand, and if I have four blocks, X1: 56 X2: 156 X3: 256 X4: 356 than the calculation is A=random(0,3) B=mod(A+random(1,3),4) C=4-(A+B), no ? Thank's for helping me

This . . . . X1 X2 X3 X4 . . . . is 4 values.
This . . . . A B C . . . . is 3 values.

???

Also, if A is 0 and B is 1 then C=4-(A+B) would be 3.

So, for four values, X1, X2, X3 and X4, in this example you would have the three values 0, 1 and 3 ?

haha I don't really understand, so with 4 values, what would it be ? I will understand it if you say me , thanks for helping me

• Posts: 4,590Member, PRO

This has all been quite entertaining, but it's clearly been very confusing for our poor question asker. This project demonstrates an easy to understand (but not very efficient) method, as well as Sock's original, serious method, explaining what it does.

• Posts: 23Member

@Armelline said:
This has all been quite entertaining, but it's clearly been very confusing for our poor question asker. This project demonstrates an easy to understand (but not very efficient) method, as well as Sock's original, serious method, explaining what it does.

Thanks you very much