Modding Help Custom Light Fixture doesn't respond to switch

Discussion in 'Starbound Modding' started by Campaigner, Feb 20, 2015.

  1. Campaigner

    Campaigner Giant Laser Beams

    Hello, I'm trying to make a wired light, and I'm hitting a wall; I can wire the light, but it doesn't turn on or off. It's permanently on.

    I copied the bunkerceilinglight2 file, and changed some parts around to make it wired. Here's what I have so far;

    Code:
    {
      "objectName" : "campworks_monsterceilinglight",
      "rarity" : "Common",
      "description" : "A metallic ceiling lamp.",
      "shortdescription" : "Metal Ceiling Lamp",
      "race" : "human",
    
      "category" : "light",
      "price" : 600,
      "lightColor" : [229, 229, 10],
      "pointLight" : true,
      "pointBeam" : 0.3,
    
      "apexDescription" : "A metallic ceiling light.",
      "avianDescription" : "A colourful ceiling light.",
      "floranDescription" : "Safe light, not fire. Floran like.",
      "glitchDescription" : "Bored. A light fixture.",
      "humanDescription" : "A device you attach to your head, and... wait, no, it's just a light.",
      "hylotlDescription" : "An uninteresting ceiling light.",
    
      "inventoryIcon" : "campworks_monsterceilinglighticon.png",
      "orientations" : [
        {
          "image" : "campworks_monsterceilinglight.png:<color>.<frame>",
          "imagePosition" : [-13, -16],
          "frames" : 1,
          "animationCycle" : 0.3,
    
          "spaceScan" : 0.1,
          "anchors" : [ "top" ],
          "lightPosition" : [0, 0],
          "pointAngle" : 270
        }
      ],
    
      "scripts" : [ "/objects/wired/light/light.lua" ],
      "scriptDelta" : 60,
     
      "interactive" : false,
    
      "inboundNodes" : [ [0, 0] ]
    
    }
    
    The log shows no errors, so I have no clue what's wrong. Here's the original bunkerceilinglight2 file;

    Code:
    {
      "objectName" : "bunkerceilinglight2",
      "rarity" : "Common",
      "description" : "A metallic ceiling lamp.",
      "shortdescription" : "Metal Ceiling Lamp",
      "race" : "human",
    
      "category" : "light",
      "price" : 500,
      "lightColor" : [229, 229, 210],
      "pointLight" : true,
      "pointBeam" : 0.3,
    
      "apexDescription" : "A metallic ceiling light.",
      "avianDescription" : "A colourful ceiling light.",
      "floranDescription" : "Safe light, not fire. Floran like.",
      "glitchDescription" : "Bored. A light fixture.",
      "humanDescription" : "A device you attach to your head, and... wait, no, it's just a light.",
      "hylotlDescription" : "An uninteresting ceiling light.",
    
      "inventoryIcon" : "bunkerceilinglight2icon.png",
      "orientations" : [
        {
          "image" : "bunkerceilinglight2.png:<color>.<frame>",
          "imagePosition" : [-4, -24],
          "frames" : 1,
          "animationCycle" : 0.3,
    
          "spaceScan" : 0.1,
          "anchors" : [ "top" ],
          "lightPosition" : [0, -2],
          "pointAngle" : 270
        }
      ]
    }
    
    What do I do to make it able to be turned on and off?
     
  2. Code:
    function setLightState(newState)
      if newState then
        entity.setAnimationState("light", "on")
        entity.setSoundEffectEnabled(true)
        if entity.hasSound("on") then
          entity.playSound("on");
        end
        --TODO: support lightColors configuration
        entity.setLightColor(entity.configParameter("lightColor", {255, 255, 255}))
      else
        entity.setAnimationState("light", "off")
        entity.setSoundEffectEnabled(false)
        if entity.hasSound("off") then
          entity.playSound("off");
        end
        entity.setLightColor({0, 0, 0, 0})
      end
    end
    That script uses animations. Make sure you have a .animation file that corresponds with a "light" state that can be set to "on" or "off".
    The actual Light should be turning on and off regardless of this being there or not.
     
  3. Campaigner

    Campaigner Giant Laser Beams

    Odd, the original object didn't have an animation file. I had to go remake it to get it to work, but copying a torch's file setup worked. Got a few small issues, but I can work those out. Thanks!

    EDIT;

    Scratch that, I'm totally stumped with this part too.

    I redid the object by copying the tarlight files. The way it looks to work is that it covers one of the images with the off version when activated. That makes sense enough, but unfortunately this isn't working the way it should. My object has an "open" and "closed" version, and is shaped like a venus fly trap. It just overlaps the images, which is not correct.

    Is there something I need to do to hide one layer?
     
    Last edited: Feb 20, 2015

Share This Page