How do I add an instance with iid=0?

0 favourites
From the Asset Store
Add SubRip (SRT) subtitles to your videos in Construct 3
  • Dear, excuse me for having IID like 11.445, i know that means that i should sit silenced in my corner.

    But as a beginner, i think i have to right to ask you a beginner question.

    How is this 'hack' different from running trough the list in the other way ... like

    For "index" from sprite.count to 0

    pick nth loopindex("index")


    for each (ordered by sprite.iid, ascending)


    for last one

    pick all

    pick nth (-1)

    or any expression like

    pick all

    sprite(sprite.count - 44).x

    As in my beginners opinion, the difference only seems a warning about future support.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That function is run when a top level event is reached, so the objects get destroyed and new objects added to the instance lists then. Without the hack can you access new objects by iid immediately after? If that works then something else is done behind the scenes to make that possible. Maybe instead of that second loop use "type.stale_iids = true;", so new iids are generated by the runtime instead. Untested but it seems to do that with families.

    Without the hack, Sprite.IID will return the last IID (the object created). Sprite(N).IID will always return 0 (even if you do a Pick All sub-event).

    Without the hack, you can pick Nth instance after creating one (in a sub-event), as long as you do a Pick All to select all instances.

    With the Hack, Sprite.IID will return wrong IID after creating a new object at front. It returns the IID as if it is at the back. However if I add to CreateObject in system.js:

    if( window["createAtFront"])
    				inst.iid = 0;[/code:kj8e0x4j]
    then it returns 0.
  • Seems like Pick All will exclude any newly created Objects, with or without the hack. A bug?

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