[API Question] Planet IDs

Discussion in 'Mod Support' started by cola_colin, October 2, 2014.

  1. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    So I am trying to show a minimap per planet. For various functions I need the function camera.lookAt to work so I can focus whatever position on any planet I want.

    Now I thought these ID are not an issue, the planet list in the top right has a mapping of planet name and ID (they go 0,1,2,...), but I had to realize that alerts use different ids. They seem like random numbers, with one planet having a 0. Others have numbers like 29232, 1219, 4362. These numbers seem constant per planet per map, but I have no idea how to figure them out. Is there some rule to this?

    The funny thing is the function camera.focusPlanet(id) works with the 0,1,2,3 IDs, the lookAt function in turn works with the weird alert ids. The IDs cannot just be interchanged.

    I need a way to figure out the cryptic alert ID of any planet in the current game, preferably not without having to know it beforehand.

    EDIT: Testing a bit shows that the ID seems to be stable even if I change the planet parameters however I want.
    Last edited: October 2, 2014
  2. kerbalweirdo123

    kerbalweirdo123 New Member

    Messages:
    15
    Likes Received:
    7
    How did you get those alert IDs?
  3. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    I put in a console.log into the api.camera method and clicked an alert. The debugger than shows the IDs that was passed in.
  4. masterdigital

    masterdigital Uber Alumni

    Messages:
    438
    Likes Received:
    833
    Every entity in the game (units, trees, planets, projectiles, armies... ) has a unique id. However, these are generated when the game starts. Some entities need to be interacted with *before* the game starts, such as planets and armies. So at various times we had to use an index (o,1,2,3..) instead of an id. Once the game starts, planets and armies can be referenced by either the index *or* the id, so programmers used one or the other at various times in development.
    I'll see if I can make the planet id more accessible.
  5. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Thanks! It would be cool if you could add the id for usage with the lookAt function in the data package that as "celestial_data". I basically need a map PlanetName > id for usage with the lookAt function.
    As an alternative it would also help if you were to add a lookAt2 function (you can probably think of a better name) that accepts the index 0,1,2,3 that the celestial data currently uses for the focus planet method. Since focus planet can deal with that kind of index I would expect that it should not be an issue to add a similar working lookAt method.
  6. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    lookAt takes an object, yes? allow it to use either planet_index or planet_id

    Index might get ambiguous once halleys and annihilators come into play, but if focus planet handles it, that should be okay.
  7. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    I have no idea how destroying a planet affects it, but I do think the index used by focusplanet is fixed all game. Changing it would be a pretty chaotic thing to do?
    But yeah have some way to make lookAt use the index number that works for focusPlanet as well. Should be a simple fix, assuming you have some engine code that has the exposed camera functions, just look at whatever focusPlanet does and reuse it.

    And while you are at it a function "getCameraPosition()" to go the other direction would be appreciated as well.
  8. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    /shameless push, the new PTE does not have the ID yet as far as I can tell :(

    EDIT: omg the spawns are given by planet_index, not by planet entity id. This makes even workaround for what I want pretty hard and cumbersome :S
    Last edited: October 30, 2014
  9. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    [​IMG]
    stuart98, wondible and Raevn like this.

Share This Page