Else Condition not working

0 favourites
  • 5 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Hi thanks in advance for taking the time to read and help me. I am trying to figure out why this else condition is not working. I want my player to basically create an object on his item slot when he has a slot available. If he does not I want him to create it on the map. I've used the debugger and tested and found that the issue must be with the else statement it self, because it shows the correct amount of slots full and everything works but this piece.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • can you explain a bit more about your logic how it should work? is hard to debug without looking at your project.

    What your events do at the moment is

    1-Pick all the "Empty" slots that are not "onlyonce" >>>> and set empty to false and onlyonce to true

    The question is if you send one axe in the function why are you setting all the slots that picks the conditions? shouldnt you pick just one slot?

    Check on the Debug and make sure there is at least one slot that have:

    -Empty = true

    -onlyonce = false

    So the else can Run when the slotfull is = 6

    If you still cannot find the issue share a small demo to look at it.

  • Better to share the project here so someone can debug that

  • Are you sure the layer "main" exists? Because otherwise it won't spawn.

  • Else when used with object conditions may not do what you want.

    Sprite: x<100
    — do something
    Else
    — do something else. No sprites are picked

    One possible solution is to use the system compare condition instead of object conditions so you take picking out of the situation. Bear in mind this would work because there’s only one player object.

    So from this

    Compare: obj = “axe”
    Player: slotfull<6
    — place in inventory
    Else
    Compare: obj = “axe”
    Player: slotfull=6
    — place on ground

    To this

    Compare: obj = “axe”
    Compare: Player.slotfull<6
    — place in inventory
    Else
    Compare: obj = “axe”
    Compare: Player.slotfull=6
    — place on ground

    But there are other ways to structure it. You don’t always need an else. I’d probably go for something like this

    Compare: obj = “axe”
    — Player: slotfull=6
    — — place on ground
    — Player: slotfull<6
    — — place in inventory
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)