Jump to content

Need Guidance Debugging A Character Mod Item Ability


Recommended Posts

  

So im using this character mod: https://steamcommunity.com/sharedfiles/filedetails/?id=493284025

I've Attached All Relevant Files to the post

This character has a added armor item that ordinarily creates a leap ability when equipped.

However upon right clicking while armor is equipped the game will crash.

Attached is a log file of the crash. You'll need to open that to follow along with the rest.

The time stamp where i enter a console command to give myself the armor is [00:01:53] (no problems here, no problems equipping the armor in game)

and the time stamp where i right click with the armor on to use the leap ability and the game crashes is [00:02:07] where you can see the following LUA Error:

[00:02:07]: [string "../mods/workshop-493284025/scripts/leapmech..."]:87: attempt to call method 'Get' (a nil value)

I dug through the modded files and the file this error is pointing to is attached to this post as well.

The line its pointing to looks like this on line 87:

inst:ForceFacePoint(data.pos:Get())

here's the entire chunk of code most of it may not be relevant, but the line creating the error is the 2nd break down where it says "local dist", followed by an if statement:

AddStategraphState("wilson", State{
    name = "leap",
    tags = { "doing", "busy", "canrotate", "nopredict", "nomorph" },

    onenter = function(inst, data)
        inst.components.locomotor:Stop()
        inst.AnimState:PlayAnimation("leap")

        local dist
        if data ~= nil and data.pos ~= nil then
            inst:ForceFacePoint(data.pos:Get())
            local distsq = inst:GetDistanceSqToPoint(data.pos:Get())
            if distsq <= LEAP_MIN_DIST_SQ then
                dist = LEAP_MIN_DIST
                inst.sg.statemem.speed = LEAP_MIN_SPEED
            elseif distsq >= LEAP_MAX_DIST_SQ then
                dist = LEAP_MAX_DIST
                inst.sg.statemem.speed = LEAP_MAX_SPEED
            else
                dist = math.sqrt(distsq)
                inst.sg.statemem.speed = LEAP_MAX_SPEED * dist / LEAP_MAX_DIST
            end
        else
            inst.sg.statemem.speed = LEAP_MAX_SPEED
            dist = LEAP_MAX_DIST
        end

        if inst.components.hunger ~= nil then
            inst.components.hunger:DoDelta(-dist / LEAP_MAX_DIST, true)
        end

        local x, y, z = inst.Transform:GetWorldPosition()
        local angle = inst.Transform:GetRotation() * DEGREES
        if GLOBAL.TheWorld.Map:IsPassableAtPoint(x + dist * math.cos(angle), 0, z - dist * math.sin(angle)) then
            ToggleOffPhysics(inst)
        end

        inst.Physics:SetMotorVel(inst.sg.statemem.speed * .5, 0, 0)

        local fx = SpawnPrefab("small_puff")
        if fx ~= nil then
            fx.Transform:SetScale(.3, .3, .3)
            fx.Transform:SetPosition(x, 0, z)
        end
        PlayFootstep(inst)

        if inst.components.playercontroller ~= nil then
            inst.components.playercontroller:Enable(false)
        end
    end,

    onupdate = function(inst)
        if inst.sg.statemem.isphysicstoggle then
            local x, y, z = inst.Transform:GetWorldPosition()
            local angle = inst.Transform:GetRotation() * DEGREES
            local radius = .5
            x = x + .75 * radius * math.cos(angle)
            z = z - .75 * radius * math.sin(angle)
            local ents = TheSim:FindEntities(x, 0, z, radius, { "wall" })
            for i, v in ipairs(ents) do
                if v.components.health ~= nil and v.components.health:GetPercent() > .5 then
                    ToggleOnPhysics(inst)
                    return
                end
            end
        end
    end,

    timeline =
    {
        TimeEvent(.5 * FRAMES, function(inst)
            inst.Physics:SetMotorVel(inst.sg.statemem.speed * .75, 0, 0)
        end),
        TimeEvent(1 * FRAMES, function(inst)
            inst.Physics:SetMotorVel(inst.sg.statemem.speed, 0, 0)
        end),
        TimeEvent(19 * FRAMES, function(inst)
            inst.Physics:SetMotorVel(inst.sg.statemem.speed * .25, 0, 0)
            inst.SoundEmitter:PlaySound("dontstarve/movement/bodyfall_dirt")

            local fx = SpawnPrefab("small_puff")
            if fx ~= nil then
                fx.Transform:SetScale(.3, .3, .3)
                local x, y, z = inst.Transform:GetWorldPosition()
                local angle = inst.Transform:GetRotation() * DEGREES
                fx.Transform:SetPosition(x + .25 * math.cos(angle), 0, z - .25 * math.sin(angle))
            end
        end),
        TimeEvent(20 * FRAMES, function(inst)
            inst.Physics:Stop()
            inst.sg:GoToState("idle", true)
        end),
    },

    onexit = function(inst)
        if inst.sg.statemem.isphysicstoggle then
            ToggleOnPhysics(inst)
        end

        if inst.components.playercontroller ~= nil then
            inst.components.playercontroller:Enable(true)
        end
    end,
})

I just really enjoy this mod and would like it to work as intended again, its also worth noting that this leap ability USED to work before i updated dst im not sure what update broke it though exactly just that it used to work fine.

I tried to fix it myself as this seems like a simple error that is just expecting a value its not getting or something, however I know nothing of modding what exactly I'm looking at, and i know very little of the game code and even less of LUA programming language, which code are game functions, and which are user created modded code. Just hoping someone with a little more knowledge than me can help me out here.

 

Thanks in advance.

 

 

modmain.lua modinfo.lua leapmechanic_guts.lua client_log.txt

 

Edited by HarbourSecrets
redundant files
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...