Modding Help Getting an object to check the tiles around it?

Discussion in 'Starbound Modding' started by Shreddys, Jul 24, 2018.

  1. Shreddys

    Shreddys Phantasmal Quasar

    Hello, I have a couple questions regarding scripting.

    Is there a way to get an object to check the tiles that are adjacent to it? To see if they are occupied and, if so, to also get their ID.

    Also, is there a way to get a tile to check the ID of a tile in the background?
     
    Last edited: Jul 24, 2018
  2. bk3k

    bk3k Oxygen Tank

    You can get an object to check these things. Start with the \starbound\doc\ folder. In particular look at the world table.

    Tiles though aren't scripted, and I think that would be a performance nightmare if they where. Think how many tiles are loaded at once!

    Tiles can check for other tiles - including specific IDs - via rule sets. But rules are only checked in a 2d grid, so they won't be checking another layer. Or rather if the engine includes any provision for this, there is no indication in the vanilla assets. I suppose if it was supported, it would look something like

    Code:
          {
            "matchAllPoints" : [
              [[-1, 1], "NotRail"],
              [[0, 1], "NotRail"],
              [[1, 1], "NotRail"],
              [[-1, -1], "NotRail"],
              [[0, -1], "NotRail"],
              [[1, -1], "NotRail"],
              [[0, 0, -1], "NotRail"]  //probably won't work!
            ],
            "haltOnMatch" : true,
            "pieces" : [["H", [-4, -4]]]
          },
    
    That last check would (in theory) look directly behind the representative piece. Those match coordinates are in tiles, not pixels FYI. But the offset for "pieces" is in pixels.
     
  3. Shreddys

    Shreddys Phantasmal Quasar

    Well, adding an extra entry to the array didn't work, as expected, so I'll have to find a workaround for that idea.

    I was kind of hoping I could dissect the "requiredLayer" or "Interactions" functions found in the lua files to find what I was looking for, but I guess those are hard coded in C?

    Oh, do you know where I could find the mechanics behind the "anchors" function for objects? Or if it is even possible to add more options other than top, bottom, left, and right. I'm trying to make an object that can also be attached to tiles in diagonal and change appearance to match.
     
  4. bk3k

    bk3k Oxygen Tank

    I expected that wouldn't work, but figured if there even was such an option, that's how it would work. At least if I was coding it, that's how I'd make it work.

    Are we currently talking tiles or objects. Everything for handling tiles is hard coded in C++
    Objects can define their own "renderLayer" if you want (information in link provided just below this), and you can define onInteraction(). Without defining this function, it will simply pass the data (as if not scripted at all) so you could consider that optional.

    The anchors are also hard coded on the C++ side. But you can find some good info about using them here.
     

Share This Page