How do I write that every number is valid

0 favourites
  • 7 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • I have the "state_1" "state_2" 3, 4... and want that a expression reach then without I want to write a code line for every one. So I want to know what to write to "state_every number", so if is state_1 or state_2 the expression will run for every state_x.

    Theres some think I can write in x ?

    Tagged:

  • If you want to check if a variable contains any state, you can do this:

    If left(CurrentState, 6)="state_"

    If you need to check states in a loop:

    Repeat 10 times
    	If CurrentState= "state_"&loopindex
    
  • I apreciatte the help!

    I try "state_", but dont work.

    To show better:

    (object)player // (condition)when animation "ID_atack_1" ends // (object)weapon // (action)destroy

    So the player can have more than one type of atack ( atack_0, atack_1...), and at the end of every atack I need to destroy the weapon object tha is created when atacking. So for the condition I need to know to say every atack_x:

    (object)player // (condition)when animation "ID_atack_X" ends // (object)weapon // (action)destroy

    I dont know if I undertand the loop sugestion very well( and this give me some ideas even for other situations :) ), but for begine I'm searching this term solution if this is possible.

  • If you need a condition to check if any "attack_x" animation has ended you can do this:

    Player On any animation ended
    System compare two values: left(Player.AnimationName,6)="attack"
    

    .

    If you need to know the number (x) of current attack animation, you can do something like this:

    Set AttackNumber to int(tokenat(Player.AnimationName, 1, "_"))
    If AttackNumber=1 : Weapon1 destroy
    If AttackNumber=2 : Weapon2 destroy
    ....
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I realy apreciate the help, and like to learn about you say here:

    Player On any animation ended

    System compare two values: left(Player.AnimationName,6)="attack"

    Maybe I'll do by this way if dont find a therm (or make a variable that store various numbers to put there), but I still need to find a therm, word,that I can write in the place of x that mean "every number" (or even other thing like every word, blank space or other think after _) is valid. See it'll be usefull to know, and in the project I'll be more simple.

  • Well, if you are looking for an event On animation "attack_*" is finished, there is no such thing. The only option is to use On any animation finished and then compare animation name with left() or some other expression.

  • dop2000 I am currently using what I learned from what you wrote and this served the project very well.

    That was a great addition.

    I would like to leave this update and say that I appreciate the contact and attention.

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