Modding Help Has the way animations work with .lua changed?

Discussion in 'Starbound Modding' started by Pinchy, Dec 27, 2013.

  1. Pinchy

    Pinchy Subatomic Cosmonaut

    My mod no longer animates or is interactable:

    Did you replace object.setInteractive with entity.setInteractive?

    This is the .lua code I use to set the animation loop that plays when the object is placed and interaction:

    function initializeObject()
    object.setInteractive(true);
    object.setAnimationState("beaconState", "active");
    end

    The code from the ironbeacon is now:

    function init(args)
    entity.setInteractive(true)
    if not goodReception() then
    entity.setAnimationState("beaconState", "idle")
    else

    entity.setAnimationState("beaconState", "active")
    end
     
  2. The | Suit

    The | Suit Agent S. Forum Moderator

    Yes - you need to change object to entity now
     
  3. Pinchy

    Pinchy Subatomic Cosmonaut

    Thanks, this fixed it.

    Now I just need to make the animation reset to the active loop. Here's my code:

    function main()
    if self.initialized == nil then
    initializeObject();
    self.initialized = true;
    end
    end

    function initializeObject()
    entity.setInteractive(true);
    entity.setAnimationState("skreeState", "active");
    end

    function onInteraction(args)
    entity.setAnimationState("skreeState", "skree");
    entity.playSound("skreeSounds");
    end



    As you can see the object sets itself as interactive and starts the active animation when placed. When used it plays the skree state animation and skreeSounds, I need to make it reset back to the active state after the skree state has finished, but I don't know how.


    Animation file:

    {
    "animatedParts" : {
    "stateTypes" : {
    "skreeState" : {
    "default" : "idle",
    "states" : {
    "idle" : {
    "frames" : 1,
    "cycle" : 0.15
    },
    "active" : {
    "frames" : 20,
    "cycle" : 0.9,
    "mode" : "loop"
    },
    "skree" : {
    "frames" : 212,
    "cycle" : 12
    }
    }
    }
    },

    "parts" : {
    "skree" : {
    "properties" : {
    "centered" : false
    },

    "partStates" : {
    "skreeState" : {
    "idle" : {
    "properties" : {
    "image" : "<partImage>:default.default"
    }
    },

    "active" : {
    "properties" : {
    "image" : "<partImage>:default.<frame>"
    }
    },

    "skree" : {
    "properties" : {
    "image" : "<partImage>:skree.<frame>"
    }
    }

    }
    }
    }
    }
    }
    }




    Another feature I wanted to add is a speech bubble above the object that appears during the skree state with the sound.


    I think i came close to this, but don't know what ? to use the in .lua:

    {
    "objectName" : "skree",
    "rarity" : "Legendary",
    "objectType" : "wire",
    "description" : "Skree",
    "race" : "generic",
    "category" : "tools",
    "printable" : "false",
    "price" : "100",
    "apexDescription" : "Description",
    "avianDescription" : "Description",
    "floranDescription" : "Description",
    "glitchDescription" : "Description",
    "humanDescription" : "Description",
    "hylotlDescription" : "Description",

    "inventoryIcon" : "skreeicon.png",
    "orientations" : [
    {
    "dualImage" : "skree:<color>.<frame>",

    "imagePosition" : [-8, 0],
    "frames" : 20,
    "animationCycle" : 2,

    "spaceScan" : 0.1,
    "anchors" : [ "bottom" ]

    }
    ],

    "animation" : "/assets/objects/wired/skree/skree.animation",
    "animationParts" : {
    "beacon" : "skree.png"
    },
    "animationPosition" : [-8, 0],

    "scripts" : [ "/assets/objects/wired/skree/skree.lua" ],
    "scriptDelta": 5,
    "skreeSounds": [
    "/assets/sfx/objects/skrees.wav"
    ],

    "skreeDialog": {
    "default": [
    "Skree!"

    ]
    }
    }

    The .lua code:
    sayToTarget("skreeDialog", stateData.sourceId);
     

Share This Page