How to set global variable to command??

0 favourites
  • 6 posts
From the Asset Store
In this game you will command the character by voice command.
  • Hello I want to set global variable to command to set on the other layout

    I have variable name "GLOBAL_MONSG" set to ""choose(1,2,3,4,5,6,7)"" I just want to random monster to spawn in layout battle

    in layout battle I have variable name "RandomMonster" and set to "GLOBAL_MONSG" because I set it to command to random but it doesn't work. How can I set monster to random in previous layout before I go in battle? Please Help me ! Thank you.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • When you put "choose(1,2,3,4,5,6,7)" inside quotation marks as you have, it is no longer an expression, but a string.

    I don't think you can have an expression inside a variable. Are you trying to have the random number picked when you go into the next layout? Or have the next layout pick the random number?

    You can:

    1. Use an action to set your GLOBAL_MONSG variable to choose(1,2,3,4,5,6,7), in which case a random number whole number between and including 1 and 7 will be stored in the variable. Then you can set RandomMonster to GLOBAL_MONSG and get the same number.

    2. Use a function that returns "choose(1,2,3,4,5,6,7)", and have your action set your RandomMonster variable to your function output.

  • When you put "choose(1,2,3,4,5,6,7)" inside quotation marks as you have, it is no longer an expression, but a string.

    I don't think you can have an expression inside a variable. Are you trying to have the random number picked when you go into the next layout? Or have the next layout pick the random number?

    You can:

    1. Use an action to set your GLOBAL_MONSG variable to choose(1,2,3,4,5,6,7), in which case a random number whole number between and including 1 and 7 will be stored in the variable. Then you can set RandomMonster to GLOBAL_MONSG and get the same number.

    2. Use a function that returns "choose(1,2,3,4,5,6,7)", and have your action set your RandomMonster variable to your function output.

    I tried to set GLOBAL_MONSG variable to choose(1,2,3,4,5,6,7) but it only random for me for one time in battle, I want to random new monster every battle too.

    I don't understand the second method

  • If you want new random every battle, why not just set RandomMonster to choose(...)?

    I guess you want to set a list of which monsters you can choose from before going into the battle. In that case I would create an array - Start with a width of 0, and then push to fill it with the possible choices, then in the battle layout set RandomMonster to Array.At(floor(random(Array.Width)).

    That's the first thing I could think of, there might be an easier way, maybe someone else could chime in.

  • If you want new random every battle, why not just set RandomMonster to choose(...)?

    I guess you want to set a list of which monsters you can choose from before going into the battle. In that case I would create an array - Start with a width of 0, and then push to fill it with the possible choices, then in the battle layout set RandomMonster to Array.At(floor(random(Array.Width)).

    That's the first thing I could think of, there might be an easier way, maybe someone else could chime in.

    Yes I want to set before go to battle layout

    I dont set RandomMonster To choose(..) because it have many battle with different random monster

    Okay. I understand but i want to set random "Orb" too, I use number to set random orb and it isnt start with 0 and like 0,1,2,3,4,...

    I dont know what to do now maybe I will set all in battle layout.

  • In my example I run the for each

    and my enemys are in this case just another frame from the animation (but can be whatever you want)

    system for each objEnemy | set animation frame to > choose (0,1,2,3)

    https://www.dropbox.com/s/y4ixsuyuzo0pj ... .capx?dl=0

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)