blazerdrive09 Posted June 22, 2016 Share Posted June 22, 2016 Currently, I am developing a custom mod for Don't Starve together. It is a composter that increases the rate at which things rot inside. I was able to successfully make the a placable structure using animations from another steam mod temporarily just to see if it works before i make my own designs and animations for the composter. The host is able to open it as well and put items in it and it also successfully increases the rate at which things compost inside of it. However, if another person joins the server with the mod installed, and tries to open the composter, or any composter no matter who made it, the client crashes while the host is still able to open it and the server is still able to run. The error seems to be due to a widget or something of that nature I can include a screenshot later. Here is the prefab for the composter: require "prefabutil" local assets= { Asset("ANIM", "anim/cellar.zip"), Asset("ANIM", "anim/ui_chest_3x3.zip"), } local prefabs = { "collapse_small", } local function onopen(inst) inst.SoundEmitter:PlaySound("dontstarve/wilson/chest_open") inst.AnimState:PlayAnimation("open") end local function onclose(inst) inst.AnimState:PlayAnimation("closed") inst.SoundEmitter:PlaySound("dontstarve/wilson/chest_close") end local function onhammered(inst, worker) inst.components.lootdropper:DropLoot() inst.components.container:DropEverything() local fx = SpawnPrefab("collapse_small") fx.Transform:SetPosition(inst.Transform:GetWorldPosition()) fx:SetMaterial("wood") inst:Remove() end local function onhit(inst, worker) inst.AnimState:PlayAnimation("hit") inst.components.container:DropEverything() inst.AnimState:PushAnimation("closed", false) inst.components.container:Close() end local function onbuilt(inst) inst.AnimState:PlayAnimation("place") inst.AnimState:PushAnimation("closed") end local function itemtest(inst, item, slot) return (item.components.edible and item.components.perishable) or item.prefab == "spoiled_food" or item.prefab == "rottenegg" end local function onsave(inst, data) if inst:HasTag("burnt") or (inst.components.burnable ~= nil and inst.components.burnable:IsBurning()) then data.burnt = true end end local function onload(inst, data) if data ~= nil and data.burnt and inst.components.burnable then inst.components.burnable.onburnt(inst) end end local function fn(Sim) local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddSoundEmitter() inst.entity:AddNetwork() local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon( "cellar.tex" ) MakeObstaclePhysics(inst, 1.0) inst:AddTag("composter") inst:AddTag("structure") inst.AnimState:SetBank("cellar") inst.AnimState:SetBuild("cellar") inst.AnimState:PlayAnimation("closed", true) MakeSnowCoveredPristine(inst) inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst:AddComponent("inspectable") inst:AddComponent("container") inst.components.container:WidgetSetup("icebox") inst.components.container.onopenfn = onopen inst.components.container.onclosefn = onclose inst:AddComponent("lootdropper") inst:AddComponent("workable") inst.components.workable:SetWorkAction(ACTIONS.HAMMER) inst.components.workable:SetWorkLeft(1) inst.components.workable:SetOnFinishCallback(onhammered) inst.components.workable:SetOnWorkCallback(onhit) AddHauntableDropItemOrWork(inst) MakeSnowCovered(inst) inst.OnSave = onsave inst.OnLoad = onload return inst end return Prefab( "common/cellar", fn, assets), MakePlacer("common/cellar_placer", "cellar", "cellar", "closed") Link to comment Share on other sites More sharing options...
DarkXero Posted June 23, 2016 Share Posted June 23, 2016 That's because the "icebox" widget setup doesn't propagate to clients. Clients try to use the widget for "cellar" and they don't find any. Add this line so clients can setup the correct widget: if not TheWorld.ismastersim then inst.OnEntityReplicated = function(inst) inst.replica.container:WidgetSetup("icebox") end return inst end Link to comment Share on other sites More sharing options...
blazerdrive09 Posted June 23, 2016 Author Share Posted June 23, 2016 Thanks! It worked, I knew it had something to due with the replica that needs to made for the clients but I couldn't figure out what was causing the problem or what needed to be done or how. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now