How do I prevent unwanted triggering of event?

0 favourites
  • 11 posts
  • Hello everybody!

    This is my pseudo code:

    system every int(random(1,3)) seconds > set position to int(random(0,2))

    • position = 0 > create object from family at some coordinates
    • position = 1 > create object from family at some coordinates
    • position = 2 > create object from family at some coordinates

    It all works great except on start of layout it is all triggered at once and 3 objects are created instead of only one. Afterwards it works as intended.

    Can someone help? What am I missing?

    Thank you!

  • Anyone?

  • I can not confirm, works well for me.

    With this code I have an other problem, its nearly impossible that position is 2!

    I need to do set position to int(random(0,3)), because if not:

    0 - 0,999999 is 0

    1 - 1,9999999 is 1

    2 - 2 is 2

    Or is this intended?

    ------------------------------------------------------------------------------------------------

    You have already added some to layout in editor?

    Seems to be the only possibility...

    Or thats not all code.

  • Thanks, I'll try and let you know if it works.

    This is only a small portion of code, the part that doesn't work as planned.

    As I said, it works great except it creates 3 objects the first time.

  • If you only want to generate four random numbers you could also use the choose expression. It's exactly like random.

    Example:

    choose(0,1,2,3)

  • Nice, I didn't know that. I'll definitely try it.

  • I still can't figure it out.

    I created the example so you can see the problem: dropbox.com/s/wxf921vulxlgw1k/example.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Those are the three objects you have in the layout. You should destroy them 'On start of layout', or put them in a separate Misc layout.

  • Those are the three objects you have in the layout. You should destroy them 'On start of layout', or put them in a separate Misc layout.

    YES!

    Thanks a lot!

  • I asked for this in first post.

  • :? I asked for this in first post.

    Hmmm... Yes you did. Sorry, I didn't understand it correctly

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