Modding Help JSON <angled brackets> usage?

Discussion in 'Starbound Modding' started by RainbowHannah, Jun 26, 2019.

  1. RainbowHannah

    RainbowHannah Void-Bound Voyager

    I've come across this snippet of code in door.lua:
    Code:
    "partStates" : {
            
                    "doorState" : {
              
                        "open" : {"properties" : {"image" : "<partImage>:open<doorDirection>.<frame>"
    } },
    
              
                        "closing" : {"properties" : {"image" : "<partImage>:close<doorDirection>.<frame>"}
    },
    
              
                        "closed" : {
    "properties" : {
    "image" : "<partImage>:close<doorDirection>.2"}
    },
    
              
                        "locking" : {"properties" : {"image" : "<partImage>:close<doorDirection>.<frame>"}
    },
    
              
                        "locked" : {
    "properties" : {"image" : "<partImage>:close<doorDirection>.2"}
    }
            
                    }
                }
    ..and I noticed the way that they use the angled brackets to seemingly represent a variable. I'm wondering how this works; could I, for example, take
    Code:
    "open" : {"properties" : {"image" : "<partImage>:open<doorDirection>.<frame>"
    and turn it into
    Code:
    "open" : {"properties" : {"image" : "<partImage>:open<doorDirection>.<frame>.<otherState>"
    and have that work? Where does it draw the things it inserts into the brackets from?

    As a secondary question, is there a way to use these in the receiving .frames file to have an animation that differs between the different provided doorDirection, frame, and otherState? Or do I have to manually provide an alias for each combination thereof?

    EDIT: Got my answers on Discord. The first question I can do, the second one I probably can't.
     
    Last edited: Jun 26, 2019
  2. projectmayhem

    projectmayhem Spaceman Spiff

    I dont really understand what your second questions is, but I think you can work what you are wanting with the second part of the question, making an alias. The <otherState> is something defined in the animation file, which i think is what you posted above, not the lua file. Though you may also have to edit parts of the lua to make calls to that new animated state. For example, here is the lua part of the door.lua for closing the door.

    Code:
    function closeDoor()
      if storage.state ~= false then
        storage.state = false
        updateInteractive()
        animator.playSound("close")
        animator.setAnimationState("doorState", "closing")
        updateCollisionAndWires()
        updateLight()
      end
    end
    Like I said, I am not sure what you are wanting to attempt, I may be able to help more knowing that, but basically you would need to change the lua to have different if = then statements to match whatever circumstances you want to trigger your different animations
     
  3. RainbowHannah

    RainbowHannah Void-Bound Voyager

    I'm basically making an addon for the paintgun mod to recolor certain modded objects, including doors. Luckily, I think I've figured out how to implement <otherState> so that it works as expected.

    Unfortunately, there are a total of about 56 different aliases I have to map for each .frames file, which is what the second question was trying to ask. If this were C++, I could create the alias based on the input (if supplied openRight.1.red it would generate the applicable alias from that), but I don't think there's any way to create a construct in JSON that derives the result from the input like that.

    Also, yeah, I made a typo there, the excerpt above was from door.animation, not door.lua.
     

Share This Page