Modding Help Overlapping Furniture

Discussion in 'Starbound Modding' started by Passerby, Oct 9, 2016.

  1. Passerby

    Passerby Scruffy Nerf-Herder

    So I've been a little annoyed with the amount of pixel real estate my attempts at a kitchen are taking up and thought I'd try solving it.
    Since I didn't find a mod that seemed to address the problem of the 3:4 view furniture using the entire front plane of its placeable area I thought I'd make my own. It seems like a problem that could be solved with a simple and easy mod, something that might work a little like so:
    [​IMG]

    My first thought was just directly modifying the .object files to adjust for the size, but then it cuts off part of the image for every instance of the object, which isn't really what I want. Is there any way to maintain an image greater than the placeable size of the object? Because I know saplings can do this to an extent, so surely there's something that can be done.

    (Barring that I could just make an alternate object which is identical but slightly cropped, but it seems like more of a band aid than a solution.)
     
    Last edited: Oct 9, 2016
  2. Mirau

    Mirau Pangalactic Porcupine

    I would suggest (if you have not already) look into zLayers as well as furniture that adds a covering layer.

    I can't say I know the exact syntax.
     
    Passerby likes this.
  3. The | Suit

    The | Suit Agent S. Forum Moderator

    There actually is quite an easy option.
    You have to create a different image per orientation.

    Take Apex Security Camera as an example - it uses a different image based on if it is attached just to the top, or top left, or top right.

    So if you made an image where it specifically attaches to something to bottom left and bottom right - you can make the image "cut off" while if it only attaches to the "bottom" it uses another.
     
    Mirau, Passerby and AmazonValkyrie like this.
  4. Passerby

    Passerby Scruffy Nerf-Herder

    It's a pretty neat idea. Thanks for pointing me toward the apexsecuritycamera object since the additional "bracket" component can be useful. I've started down the road of trying to recategorize the cabinet's side panel as a "bracket" and put the whole thing into a single frame animation loop, based on the idea that the recategorized bracket might not be beholden to the limitations of the frame size in the .frame file. Do I even need to use the .animation file to define different parts of an object to have different properties though? It feels like I'm overcomplicating this.

    Either way it'd let me set the back (and only the back) to zLevel=0 and should solve most/all my problems. Ideally. This feels awfully convoluted for my uses of it, but hopefully I can easily apply it to other furniture once this is through.


    As a reference to document what I've been doing to anyone who runs into this in the future:
    I tried just changing the frame size from 36 to 24, placing the object, and changing it back to 36. It worked fine for a certain direction, but if three cabinets were lined up in a row then the middle one would get assigned a zLevel lower than the other two. I presume the reason for this is because the x-coordinate defines which cabinet gets zLevel priority and places the subsequent cabinet to be lower (=0, I'd imagine), which is then considered when the next cabinet is applied and is placed a normal level.
    More to the point, as soon as items start getting mixed (like trying to stack Chic Cooking Tables on top of fridges on top of cabinets) then native item loading priority starts to get in the way as well, predictably. Doing this also tends to make a lot of "phantom blocks" that clutter the ship.
    ...on the bright side it also SOLVES pretty much every unremoveable phantom block problem, you just need to force an object with a platform into that space at that level and pick it up once it overlaps with the offending block.


    EDIT: Learning is fun. The placeable area issue has been as simple as just switching each object from spaceScan to a defined space in the .object file, without defining a space for the side wall of each object. The zLevel problems persist after relogging or messing around in files though. For now, the change ends up looking like this:

    "orientations" : [
    {
    "dualImage" : "woodenceilingcabinet1.png:<color>",
    "imagePosition" : [0, 0],
    "frames" : 1,
    "animationCycle" : 0.5,

    "spaces" : [ [3, 0], [2, 0], [1, 0], [3, 1], [2, 1], [1, 1] ],
    "anchors" : [ "background" ],
    "collision" : "platform"

    }
    Thanks to Mackinz' Compact Crops mod for putting me on the right path.

    I'll play around with alternate images for anchors tomorrow, but I feel like some unintended side effects will start to come up if I try to put a sink next to a fridge, like the whole side of the fridge disappearing.
     
    Last edited: Oct 10, 2016
    Mirau likes this.
  5. Passerby

    Passerby Scruffy Nerf-Herder

    After tinkering for awhile I've run into a bit of a wall on this one. I've explored a couple different avenues of layering parts of the furniture separately (renderLayer and zLevel), and while there's potential neither play nice with the platform collision typical of a lot of furniture, which I really need to maintain in order to get it to still act fundamentally like furniture. While I can line the furniture up now, it continues to overlap in weird ways:
    [​IMG]

    In the meantime I've tried using alternate images for anchors as suggested by @The | Suit , but it seems that adjacent objects (ie cabinets) don't qualify as anchors. So while the cabinets work great when they work, they only work against walls or ceilings, which aren't usually present in my setups. I could swap them and make the full 3/4 view cabinet dependent on nearby anchors and use transparent blocks as a bit of illusion work, but it doesn't feel like a real solution I can start applying to other bits of furniture.

    Isn't there some way to split the layers in an object without killing its collision?
     
  6. The | Suit

    The | Suit Agent S. Forum Moderator

    Well walls are the easiest method - for a dynamic single object approach.

    Without walls you need to use Lua and have the object set the state by scanning in preview mode before placing.
    Then set the image state with animator.

    You will also need 3 image states.
    Left center right.
     
    Last edited: Oct 12, 2016
  7. Megumin

    Megumin Guest

    whatever this was... it's looks damn awesome
    #iwantthismod
     
  8. bk3k

    bk3k Oxygen Tank

    I'll show you a neat trick. A cheat for sorts.

    to this
    Code:
    "anchors" : [ "bottom" ],
    
    do this
    Code:
    //"anchors" : [ "bottom" ],
    
    You have magical floating furniture LOL.

    Now as for your collisions, I'll feed you a little LUA code. But first add this in your objects

    Code:
    "platformSpaces" : [ [3,0], [3,1], [3,2] ]
    
    That's based off your "spaces" above and assuming only the top of the objects should have a platform collision. Adjust as necessary for the size of the objects. The name "platformSpaces" isn't special, but it is just the name I've chosen that will be read by the LUA script below.

    Now we're gonna need the script. Make a file named setCollision.lua somewhere. Okay you can actually name it anything you like. But I'm assuming that name

    Code:
    if init then
      setCollision_init = init
    end
    
    init = function(...)
      if setCollision_init then
        setCollision_init(...)
      end
    
      initMaterialSpaces()
    end
    
    initMaterialSpaces = function()
      self.platformSpaces = config.getParameter("platformSpaces")
      self.matTable = {}
      
      for i, space in ipairs(self.platformSpaces) do
        self.matTable[i] = {space, "metamaterial:platform"}
      end
      object.setMaterialSpaces(self.matTable)
    end
    That's it for the LUA. It only runs once so won't hurt your performance. With that you won't have any collisions besides spaces you define(which I assume is the top)

    Also go ahead and pull the "collision" : "platform" as you don't need that anymore. And you're obviously going to need "scripts" : ["setCollision.lua"] in there too. If there is another script already, put this script AFTER it. You could move the lua file elsewhere like a common location since you are likely using it for multiple furniture objects. You just need to point to where ever it is.

    If you're wanting to do something slightly more complicated where collision types are concerned, let me know because that isn't particularly difficult but we'll build the structure in the .object file instead.
     
    AmazonValkyrie likes this.
  9. Yannik_Lo

    Yannik_Lo Void-Bound Voyager

    I would really LOVE to see this as a mod in the workshop!
     

Share This Page