GameSalad

I'm new, please help me for a script, I need help !

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 ;)

Comments

  • 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 ;)

  • johnnymagnejohnnymagne NorwayPosts: 97Member, PRO

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

  • SocksSocks London, UK.Posts: 12,324Member, BASIC

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

  • johnnymagnejohnnymagne NorwayPosts: 97Member, PRO

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

  • tatiangtatiang Posts: 10,614Member, Sous Chef, PRO, Senior Sous-Chef
    edited February 2

    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.

    What about random(1,3).."56"

    B)

  • Thanks you very much, I will do it

  • SocksSocks London, UK.Posts: 12,324Member, BASIC

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

    :smile:

    @tatiang said:
    What about random(1,3).."56"

    What about 356 + random(-2,0)*100

  • jamie_cjamie_c ImagineLabs.rocks Posts: 5,271Member, BASIC

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

  • SocksSocks London, UK.Posts: 12,324Member, BASIC
    edited February 2

    @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

  • SocksSocks London, UK.Posts: 12,324Member, BASIC
    edited February 2

    . . . or

    156 +random(0,2)*100

  • AdrenalineAdrenaline Posts: 434Member

    Is this how you reach 12,000 posts?

    :smile:

  • @Adrenaline said:
    Is this how you reach 12,000 posts?

    :smile:

    Haha, amazing

  • and thanks every body

  • SocksSocks London, UK.Posts: 12,324Member, BASIC

    @Adrenaline said:
    Is this how you reach 12,000 posts?

    :smile:

    No, that would be . . .

    random(0,0)+12,000

  • SocksSocks London, UK.Posts: 12,324Member, BASIC
    edited February 3

    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

  • 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 ;)

  • ToqueToque Posts: 709Member, PRO

    Google "gamesalad mod function"
    https://stormystudio.com/math-functions-reference-for-gamesalad-2/

    C'est une fonction mathématique.

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

    Script. nous disons Rules in Gamesalad.

    Pardon moi Canada French.

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

  • Braydon_SFXBraydon_SFX Dallas, TexasPosts: 8,765Member, Sous Chef, PRO, Bowlboy Sidekick

    Merged these two threads. Let's remember to keep each topic in one thread, please. :)

  • @Braydon_SFX said:
    Merged these two threads. Let's remember to keep each topic in one thread, please. :)

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

  • @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

  • Braydon_SFXBraydon_SFX Dallas, TexasPosts: 8,765Member, Sous Chef, PRO, Bowlboy Sidekick

    @warloparthur@gmail.com said:

    @Braydon_SFX said:
    Merged these two threads. Let's remember to keep each topic in one thread, please. :)

    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. :)

  • ok ;)

  • SocksSocks London, UK.Posts: 12,324Member, BASIC
    edited February 4

    @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)

    ?

  • 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 ;)

  • SocksSocks London, UK.Posts: 12,324Member, BASIC
    edited February 4

    @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 ?

  • @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 ;)

  • ArmellineArmelline Posts: 4,340Member, 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.

  • @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

Sign In or Register to comment.