Jump to content

Recommended Posts

I'm trying to get my follower to act as a container the same way chester does. I got it to work when I play on a server alone, but I'm getting this error when I try to play with my sister and one of us tries to click on the follower to open the container:

Quote

[00:02:21]: [string "scripts/widgets/containerwidget.lua"]:29: attempt to index local 'widget' (a nil value)
LUA ERROR stack traceback:
    scripts/widgets/containerwidget.lua:29 in (method) old_container_open (Lua) <24-132>
    ../mods/workshop-365119238/modmain_segments/containerwidgetfunction.lua:21 in (method) Open (Lua) <20-60>
    scripts/screens/playerhud.lua:191 in (upvalue) OpenContainerWidget (Lua) <188-193>
    scripts/screens/playerhud.lua:201 in (method) OpenContainer (Lua) <195-203>
    scripts/components/container_replica.lua:204 in (method) Open (Lua) <190-211>
    scripts/components/container_replica.lua:58 in (field) fn (Lua) <56-59>
    scripts/scheduler.lua:194 in (method) OnTick (Lua) <168-225>
    scripts/scheduler.lua:406 in (global) RunScheduler (Lua) <404-412>
    scripts/update.lua:166 in () ? (Lua) <150-223>
    
[00:02:33]: Force aborting...

Can anyone help me with this error?

EDIT: It seems to only crash when someone other than the host tries to open a followers container menu.

Edited by beforeidecay96

I remember having this problem with my chest mod, and this is what I was told to do, I guess you can try it.. :

local containers = GLOBAL.require("containers")
local oldwidgetsetup = containers.widgetsetup

containers.widgetsetup = function(container, prefab, data)
    prefab = "PUTCONTAINERNAMEHERE" --replace with ur container prefab name
    oldwidgetsetup(container, prefab, data)
end

8 minutes ago, Aquaterion said:

I remember having this problem with my chest mod, and this is what I was told to do, I guess you can try it.. :

local containers = GLOBAL.require("containers")
local oldwidgetsetup = containers.widgetsetup

containers.widgetsetup = function(container, prefab, data)
    prefab = "PUTCONTAINERNAMEHERE" --replace with ur container prefab name
    oldwidgetsetup(container, prefab, data)
end

Where am I supposed to put it at? Modmain?

3 minutes ago, Aquaterion said:

yea sorry forgot that part

Your code will broke some container else like cookpot.

Put this code to your prefab file in local function fn(Sim)

if not TheWorld.ismastersim then	
   inst.OnEntityReplicated = function(inst) 
      inst.replica.container:WidgetSetup("chester") 
   end	
   return inst
end

Or you can use this in modmain:
 

local containers = GLOBAL.require("containers")
local oldwidgetsetup = containers.widgetsetup
containers.widgetsetup = function(container, prefab)    
	if not prefab and container.inst.prefab == "yourcontainername" then        
		prefab = "chester"    
	end    
	oldwidgetsetup(container, prefab)
end

 

Edited by zUsername
18 minutes ago, Aquaterion said:

yea sorry forgot that part

It worked! Thank you so much for your help! And thanks to zUsername as well! I really appreciate you both taking the time to help me~ ^w^

Alright, I thought it fixed the crock pot container issue, but it really didn't. :( The crock pot still acts like a chest. I tried using both of zUsername's codes they gave me, but it still doesn't work. Maybe I'm just putting them in wrong...

Can anyone help me?

Edited by beforeidecay96

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