Jump to content

Character/pet help, chester type clone


Recommended Posts

Hi, again, second time being here.
 

So for a character i'm building i want her to have some pets, but i also want them to be like chester, where someone can store things in them. And while i'm usually good at finding the code and reconfigure it to match the rest, i can't seem to find how chesters storage works...

 

here's what i got for the companion in general: modinfo - moby.luamodmain - moby.luacreaturebrain.luacrystal.luamoby.luamoby_none.luacreature.luaSGcreature.lua (feel free to tell me of anything I've missed)

(I'm not sure what you'll need so have it all!)

(And yes, i know that modinfo/main shouldn't have the name in there, its there just to help me)

Link to comment
Share on other sites

The creature.lua file is for the pet prefab right? I didnt see a container component added so I would have added these things from the chester code..

So in the MakeMinion function where the commponents are added:

    inst:AddComponent("container")
    inst.components.container:WidgetSetup("chester")
    inst.components.container.onopenfn = OnOpen
    inst.components.container.onclosefn = OnClose

I believe adding this line in local assets is needed too:

    Asset("ANIM", "anim/ui_chest_3x3.zip"),

and then just need to put in these functions it looks for:

local function OnOpen(inst)
    if not inst.components.health:IsDead() then
        inst.sg:GoToState("open")
    end
end

local function OnClose(inst)
    if not inst.components.health:IsDead() and inst.sg.currentstate.name ~= "transition" then
        inst.sg:GoToState("close")
    end
end

however I'm not sure what you're basing the pets off of, if it isn't chester for example then it may not have those open and close states/animations. You can always just remove that line and add something like a sound being played, like so:

local function OnOpen(inst)
    if not inst.components.health:IsDead() then
         inst.SoundEmitter:PlaySound("dontstarve/wilson/chest_open")
    end
end

local function OnClose(inst)
    if not inst.components.health:IsDead() then
       inst.SoundEmitter:PlaySound("dontstarve/wilson/chest_close")
    end
end

Hope it helps.

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...