Jump to content

SGrabbitking_bunnyman incorrectly sets name of stategraph as "bunnyman"


hoxi
  • Pending

This can lead to issues or even crashes with mods because the stategraphs are very different, but both will process post inits using "bunnyman".

Aside from fixing the issue, maybe there's something you can do with these functions to automatically catch cases like these in the future?

local function LoadStateGraph(name)
    if StateGraphs[name] == nil then
        local fn = require("stategraphs/"..name)
        assert(fn, "could not load stategraph "..name)
        StateGraphs[name] = fn
    end

    local sg = StateGraphs[name]

    assert(sg, "stategraph "..name.." is not valid")
    return sg
end

function EntityScript:SetStateGraph(name)
    if self.sg ~= nil then
        SGManager:RemoveInstance(self.sg)
    end
    local sg = LoadStateGraph(name)
    assert(sg ~= nil)
    if sg ~= nil then
        self.sg = StateGraphInstance(sg, self)
        SGManager:AddInstance(self.sg)
        self.sg:GoToState(self.sg.sg.defaultstate)
        return self.sg
    end
end

Or maybe even stategraph.lua, within the StateGraph class constructor itself.


Steps to Reproduce
  • Make a mod script that adds a stategraph post init of any kind using "bunnyman".
  • Notice how it will run for SGrabbitking_bunnyman too, potentially leading to issues or even crashes.



User Feedback


There are no comments to display.



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

×
  • Create New...