0 Favourites

[Solved] Update post title : sub-events and picked instances

  • My questions seems trivial but couldn't find any rational explanation.

    Look this :

    It's a 2 player board game where tiles are clicked and the id of the tile does something (here tile = 23).

    "spies" is a spyglass that shows the other player. I often use this trick, to get the other player ID by doing a "1 - currentPlayer", wich give "0" for "1" and "1" for "0".

    I used this some other times in the game events (even in this one), but now I want to use it in a condition (on "slots", to retrieve the slot that correspond to the other player), the calcul doen't seem to "work", ie it did not execute the event "spies set Y".

    I did some tries in the condition :

    slots (where) playerID = 1 - currentPlayer => NOT OK
    slots (where) playerID = currentPlayer - 1 => NOT OK
    slots (where) playerID = int(1 - currentPlayer) => NOT OK
    
    slots (where) playerID = currentPlayer - 0 => OK
    slots (where) playerID = currentPlayer => OK[/code:rm1qhsll]
    Any help on this easy strange problem appreciated ^^
    Thanks
    
    PS : 100 events reached
  • (number+1)%2 will turn 1 into 0 and 0 into 1 if that's what you're looking for

  • (number+1)%2 will turn 1 into 0 and 0 into 1 if that's what you're looking for

    Thanks 7soul.

    In fact the formula is ok :

    1 - 0 => 1

    1 - 1 => 0

    And similar to yours.

    The problem I face is not in the formula but in the fact that the condition is not "true" (ie the player slot is not picked).

    It seems I've got a bug in my conception...

    I've got to debug this and come back...

  • Ok, I have a "slots" selected in the loop before, and the code I show here is inside it.

    It is like once an object has been selected in an event/condition, the same type of object can not be selected in a sub-event of the same event.

    IE :

    object -> Pick instance with UID 5 => ok picked

    |__ object -> Pick instance with UID 6 => not picked

    Need to verify this...

  • OMG RTFM <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    "How events works" ... https://www.scirra.com/manual/75/how-events-work

    Picking resets between events

    On the other hand, sub-events (which appear indented) carry on from where its parent event left off. A sub-event will further filter the instances left over by the event that came before it.

    etc.

    I have read it, but now I experienced it, that's not the same <img src="{SMILIES_PATH}/icon_e_wink.gif" alt=";)" title="Wink">

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • To explain picking, you can look at it like a sorting machine.

    Imagine you have 30 different coloured boxes.

    30 - Boxes

    10 - Red boxes

    10 - Blue boxes

    10 - Green boxes

    Pick all boxes - (Will pick 30 boxes)

    Pick Red boxes - (Will pick 10)

    and so on.

    Imagine that each of these boxes have a variable that hold a number from 1 to 3, which are random for all the boxes no matter what color they have.

    If you have an event like this.

    Pick all boxes who have a value of 1 (Lets assume that it pick 8 boxes)

    --- (Sub event) Boxes need to be red (This will pick all red boxes of those 8, so it might pick 2 boxes.)

    --- (Sub event) Pick all Boxes (Will pick all 30 boxes because it is a system command)

  • Thanks nimos100

    I got it know but yes, examples are welcomed to get it better ^^

    And ok for the the "Pick all" command exception, to keep in mind.

    It's a pleasure to use C2... I hope to deliver my game "soon", and cherry on the cake would be a multiplayer local or network game, but I'll post more about the game when it will be more advanced.

    Now let's find a moment to go and buy a license €€

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread sticky
4,517 857,239
Tinimations's avatar
Tinimations
Unread hot topic
1,941 263,220
FlyingRam's avatar
FlyingRam
Unread sticky
1,586 437,254
matriax's avatar
matriax