Modding Help Why is this weaponability not working?

Discussion in 'Starbound Modding' started by EclipticWulf, May 22, 2017.

  1. EclipticWulf

    EclipticWulf Scruffy Nerf-Herder

    First off, here it is:

    {
    "animationParts" : { },
    "animationCustom" : {
    "sounds" : {
    "fire" : [ "/sfx/melee/swing_shortsword.ogg" ],
    "fire2" : [ "/sfx/melee/swing_spear.ogg" ]
    }
    },

    "ability" : {
    "name" : "Critter Skinning",
    "type" : "critterskinning",
    "scripts" : ["/items/active/weapons/melee/meleecombo.lua"],
    "class" : "MeleeCombo",

    "comboSteps" : 1,

    "flashTime" : 0.15,
    "flashDirectives" : "fade=FFFFFFFF=0.15",

    "swooshOffsetRegions" : [
    [-1.0, -0.25, 2.5, 2.0],
    [0, -0.5, 2.5, 1.0]
    ],

    // cooldown time multiplier for steps after the first, compounded per combo step
    "comboSpeedFactor" : 0.9,

    "edgeTriggerGrace" : 0.25,

    "fireTime" : 0.625,
    "baseDps" : 7.5,

    "damageConfig" : {
    "damageSourceKind" : "skinning",
    "statusEffects" : [ ],
    "knockbackMode" : "facing",
    "timeout" : 0.5
    },
    "stepDamageConfig" : [
    {
    "baseDamageFactor" : 1.0,
    "knockback" : 1
    },
    {
    "baseDamageFactor" : 1.0,
    "knockback" : 1
    }
    ],

    "stances" : {
    "idle" : {
    "armRotation" : -90,
    "weaponRotation" : -10,
    "weaponOffset" : [0, 2.25],

    "allowFlip" : true,
    "allowRotate" : true
    },
    "windup1" : {
    "duration" : 0.05,
    "armRotation" : -15,
    "weaponRotation" : -60,
    "weaponOffset" : [0, 2.25],

    "allowFlip" : true,
    "allowRotate" : true
    },
    "fire1" : {
    "duration" : 0.2,
    "armRotation" : -135,
    "weaponRotation" : 40,
    "weaponOffset" : [0, 2.25],

    "allowFlip" : true,
    "allowRotate" : true
    },
    "wait1" : {
    "duration" : 0.3,
    "armRotation" : -135,
    "weaponRotation" : 40,
    "weaponOffset" : [0, 2.25],
    "allowRotate" : true,
    "allowFlip" : true,
    "twoHanded" : false
    },
    "windup2" : {
    "duration" : 0.1,
    "armRotation" : -135,
    "weaponRotation" : 40,
    "weaponOffset" : [0, 2.25],
    "twoHanded" : false,
    "allowFlip" : true,
    "allowRotate" : true
    },
    "fire2" : {
    "duration" : 0.3,
    "armRotation" : 0,
    "weaponRotation" : -90,
    "weaponOffset" : [0, 2.25],
    "twoHanded" : false,
    "allowFlip" : true,
    "allowRotate" : true
    }
    }
    }
    }


    Anyway, can anybody tell me why this isn't working? (The damage source kind already exists by the way.)
    When I assign a weapon to this weaponability, it does go through but the weapon does not function at all. It's not even held correctly.

    When I look in the log, I see this:

    ...

    [22:09:26.631] [Error] Exception while calling script init: (LuaException) Error code 2, [string "/items/active/weapons/weapon.lua"]:283: bad argument #1 to 'for iterator' (table expected, got nil)
    stack traceback:
    [C]: in ?
    [C]: in for iterator 'for iterator'
    [string "/items/active/weapons/weapon.lua"]:283: in function <[string "/items/active/weapons/weapon.lua"]:282>
    (...tail calls...)
    [string "/items/active/weapons/melee/meleeweapon.lua"]:15: in function <[string "/items/active/weapons/melee/meleeweapon.lua"]:5>
    [0] 7ff67f504403 Star::captureStack
    [1] 7ff67f50318e Star::StarException::StarException
    [2] 7ff67f4d7a91 Star::LuaEngine::handleError
    [3] 7ff67f6a683d Star::LuaEngine::callFunction<>
    [4] 7ff67f6a9ee1 Star::LuaFunction::invoke<Star::Variant<Star::Empty,bool,__int64,double,Star::String,Star::LuaTable,Star::LuaFunction,Star::LuaThread,Star::LuaUserData> >

    ...


    Can anyone tell me what's wrong? I have a weaponability that's pretty much identical, the only difference is the name, type, and damageSourceKind - and that weaponability works just fine. If I assign that weaponability to this weapon, then the weapon works - so something is obviously wrong with this weaponability...or I'm just missing something. Thanks for any help again!
     
  2. G.Xyon

    G.Xyon Space Kumquat

    Can we see the weapon you're assigning the weaponability to? When the error is traced down, it seems to be trying to assign the weaponability to the primary ability of the weapon, but is unable to. Did you double-check that the weapon accepts both abilities, and that both abilities are identical (save for the minor changes you're attempting to do)?

    I also assume the weaponability has been properly listed in the weaponabilities.config, correct?
     
    EclipticWulf likes this.
  3. bk3k

    bk3k Oxygen Tank

    Instead of getting directly to the problem, I want to work backwards til getting to it, and why that is. First I don't recommend to only provides snippets of logs. Some information in there might be more useful than you think. But from what you posted, that's telling you that on line 283 of
    /items/active/weapons/weapon.lua

    Code:
    function getAbility(abilitySlot, abilityConfig)
      for _, script in ipairs(abilityConfig.scripts) do
      require(script)
      end
      local class = _ENV[abilityConfig.class]
      abilityConfig.abilitySlot = abilitySlot
      return class:new(abilityConfig)
    end
    
    In the first line of that function, you're trying to iterate something that isn't a table. Specifically it got nil instead and that goes back to this.

    Code:
    function getPrimaryAbility()
      local primaryAbilityConfig = config.getParameter("primaryAbility")
      return getAbility("primary", primaryAbilityConfig)
    end
    
    It probably does come back to patching the ability into /items/buildscripts/weaponabilities.config because without doing that, the build scripts can't do their thing properly. In the weapons you see something like

    Code:
      "primaryAbilityType" : "shortswordcombo",
      "primaryAbility" : {
        "fireTime" : [0.5, 0.67],
        "baseDps" : [6.5, 7.5],
        "damageConfig" : {
          "damageSourceKind" : "<elementalType>shortsword"
        }
      },
    
    Note that doesn't tell where to FIND the ability named "shortswordcombo" so that you can get the configuration data from it. The data under "primaryAbility" is only configuration data - to supplement or replace the ability's own properties. It needs the main file, and weaponabilities.config acts as a lookup to find exactly that.
     
    EclipticWulf likes this.
  4. MetaFace

    MetaFace Guest

    This is a lua issue, dealt with it before, so take the lua for the ability and where the value originally said the previous type (for example if the weaponability type was "swordcombo" then in the lua file the function names would need to be changed from "swordcombo" to your "critterskinning" name). This will solve SOME issues, but not all unless I'm wrong.
     
    EclipticWulf likes this.
  5. EclipticWulf

    EclipticWulf Scruffy Nerf-Herder

    Edit: Never mind, I did, just didn't remember I made it...well done.

    Edit already: Out of my own stupidity, I guess I just never remembered making the .patch file. Seems I did, just never added this weaponability to it.

    Seems everything is working, so thank you all.
     
    Last edited: May 22, 2017

Share This Page