99Instances2Go's Recent Forum Activity

  • That is not how 'creating' works. If i understand you right, i still see no tree.

    I have the impression that you try to pick/select an object and then try to create that object.

    Picking an object in a parent condition has totally no effect on which object is created in the paired action.

    Kinda logical, cant pick a non existing object.

  • Same in both: Sprite.8Direction.MovingAngle.

  • Solution:

    I've sent the UID of all the objects from the family in a array and then I create an event "Pick instance with UID - UID number from the array" from the family.

    It worked perfectly!

    Sure, that somehow works. And next ?

    Are you going to write 4000 events to follow that up? Like ....

    1/ If this .... then pick UID this ... and do this ...

    2/ If that .... then pick UID that ... and do that ....

    3 to 4000/ If something else .. then pick UID something ... and do something else ....

    Should explain what exactly you wanna do.

    At this point i am afraid that you gonna create a vehicle that will overshoot the moon.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Use a function.

    Add Function object.

    Add a separate block of events that starts with 'On function', here goes all the stuff that you want the function to do. I will refer to this as the function block.

    Say we name it "CompareSymbol"

    Function > On function ... Name = "CompareSymbol"

    ____Local variable 'Symbol' <---- not needed, but it is easier for the eyes.

    ____Empty sub event

    __________ action: System > Set value .. Symbol to Function.Param(0) <--- i explain this later

    ____if array at position 0,0 = symbol < --- the local variable

    ____if array at position 1,0 = symbol

    ____if array at position 2,0 = symbol

    __________ action: Function > Set return value ... value = 1

    ____else

    __________ action: Function > Set return value ... value = 0

    Now you have this block only once. And you can call it as many times as you want.

    This action 'Function > Set return value' sets a special system variable. You can access it with an expression.

    The value is there and has meaning direct after calling the function.

    So, lets call the function.

    Any condition that leads to comparing the Symbols.

    ____ Action: Function > Call function .. Name = same as in the 'On function'. In this case "CompareSymbol" .. parameter 0 = "symbol_02"

    ____ Sub event: System > Compare 2 values .. First = Function.ReturnValue .. equal to .. second = 1

    __________actions: do the needed stuff when the array is matching the symbols

    ____ Else

    __________actions: do the needed stuff when the array is NOT matching the symbols

    With the expression 'Function.ReturnValue' you access the value that you have set with that action 'Function > Set return value ... value = 1' in the function block.

    Now. When you call a function, you often have to pass values to the function block. Those are called the parameters. In this example, the function needs the value 'symbol'. We have set 'symbol' to Function.Param(0) in the function block. What is this ?

    When you click the action Function > Call function ... you see that 'Add parameter' line in the UI. Click it to add a parameter. A new field appears to fill in a parameter with in index zero.

    In that field you type the symbol that you want to call the function with. "symbol_01" or "symbol_02" .......

    It is in fact always the same.

    When you set a value in an action, there is (almost always) an expression to access that value.

    Action : On function'... name ="CompareSymbol" .. parameter 0 = "symbol_02"

    Access that parameter with Function.Param(0)

    Action : Function > Set return value ... value = 1

    Access that return value with Function.ReturnValue

    Same as the more common

    Action: Sprite > Set X ... X = 150

    Access that X with Sprite.X

  • But now i only checked only 1 frame. Guess i need to check a range of frames.

    Using an Array (size : how many frames , 1 , 1)

    An Array is just and no more then a way to organize variables that can have more values at the same time.

    System > For .. Name = "aFrame" ... Start = zero ... End = how many frames

    Sprite > Compare frame ... frame = loopindex("aFrame") ?

    _____Sub / System > compare 2 values .. Sprite.Count = Sprite.PickedCount

    ___________Sub / Array > Compare at X .... X = loopindex("aFrame") ... Value =? zero

    _________________sub / System > Pick All (Sprite)

    _______________________action : do your stuff

    ___________Sub / Empty event

    _________________action : Set at X ... X = loopindex("aFrame") ... Value = 1

    _____Else

    __________action : set Set at X ... X = loopindex("aFrame") ... Value = 0

    Else

    _____ if it is needed to capture the exeption

  • Use a sub-sub or a function.

    A function starts picking from scratch. (so, including ever instance again)

    A sub-sub will not change the parent picklist.

    Sprite > Compare frame <--- pick all with a certain frame = Parent Picklist

    System > compare 2 values .. Sprite.Count = Sprite.PickedCount

    ______Just an empty sub event

    ________sub under that empty event ... System > Pick All (Sprite) <------ this is the Sub Picklist / Parent is unchanged when returning to parent level

    ______________action : do your stuff

    Thing is now, be careful with this 'PickedCount'. If you wanna do something when none of them have this frame .... Then the 'Sprite.Count = Sprite.PickedCount' will not ever run. Not as sub, not as second in a parent.

    So just to be complete ...

    Sprite > Compare frame

    System > compare 2 values .. Sprite.Count = Sprite.PickedCount

    ______Just an empty sub event

    ________sub under that empty event ... System > Pick All (Sprite)

    ______________action : do your stuff

    Else

    _____Actions to take care of the exception where the first event will not run.

    Additional. Testing for an animation frame has a dangerous side.

    Say, the animation speed = 20 and it runs at 60 FPS. Then each frame will be there for 3 ticks. (when the animations sync up)

    As a result this condition (above) will be true for 3 ticks in a row.

    Usually you solve this with a 'System > Trigger once while true'.

    Sprite > Compare frame

    System > compare 2 values .. Sprite.Count = Sprite.PickedCount

    System > Trigger once while true

    'Trigger once while true' runs its event once when the paired up condition(s) are true. Then it sits there, and waits. Until the conditions are not true, then it flags its event as executable again.

    But that will not be flawless in the above conditions because of the above explained exception.

    When there i no Sprite with that frame, the condition will not run, the 'Trigger once while true' will also not run.

    As a result it miss out the change in true/untrue for the next tick.

    There is also the possibility of an additional 'thing'. Say, the animations do not run in sync. Then 'this tick' a certain sprite changed frame, while another one is still in the same frame.

    Comes down to this. When Sprite.Count is equal to Sprite.PickedCount this tick it can only run its actions when Sprite.Count was not equal to Sprite.PickedCount in the previous tick.

    Using a Global Variable.

    Sprite > Compare frame

    _____Sub / System > compare 2 values .. Sprite.Count = Sprite.PickedCount

    ___________Sub / GlobalVariable = zero ?

    _________________sub / System > Pick All (Sprite)

    _______________________action : do your stuff

    ___________Sub / Empty event

    _________________action : set GlobalVariable to 1

    _____Else

    __________action : set GlobalVariable to 0

    Else

    _____ if it is needed to capture the exeption

  • MikaelS

    That sounds about right. Cant set them to an expression in the current version of c3.

    That hit me too.

    Got to couple them to a condition.

    Condition ... testing an expression

    _____ set boolean

    Else

    ______unset boolean.

    Got to be careful with the logical part of that condition. The 'else' runs only if its parent did not run. (is false)

    Those conditions that start with 'Is ....' are conditions that return a 'false/true' as result.

    The conditions that pick return a 'false/true' if the picklist is empty.

    Those that start with 'On ....' have no 'else', they are triggers.

    Whats left, is those that start with 'Compare .....'.

    You can compare in two ways.

    Say ...

    Regular way. Comparing two expressions that hold a value (Sprite.x ... 5000 .. pi ... sin(90) ...etc)

    And...

    Using logical expressions.

    Value one = Sprite.x > 50 & Sprite.x < 200

    Value two = 1

    Construct takes '0' as false when using logical expressions. And '1' as true.

    You can also use logical expressions like this.

    Sprite.X = 1? 1 : 0

    Returns 1 if Sprite.X = 1 else 0.

  • Not sure why so complicated. Or use drag&drop or use an boolean together with a position to mouse (every tick).

    If you use drag&drop, it does not need to be disabled. Unless the buildings have a state that does not allow them to move. But i dont see that in your events.

    Now you have all the drag&drop conditions.

    On drag start

    ___ Here you can set the boolean, if you need it

    On drop

    ___ Here you can unset the boolean

    ___ Reposition (snap) if need

99Instances2Go's avatar

99Instances2Go

Member since 12 Feb, 2016

Twitter
99Instances2Go has 2 followers

Trophy Case

  • 8-Year Club
  • Email Verified

Progress

9/44
How to earn trophies