Sign in to follow this  
s1m13

containerwidget.lua29: attempt to index local 'widget' (a nil value)

Recommended Posts

s1m13    8
Posted (edited)

Hey devs,

I have a new mod: https://steamcommunity.com/sharedfiles/filedetails/?id=1755351523

It's running fine as long as there are no Caves - and I don't know why. My mod includes a custom container which is defined this way:

	local compostpileparams =
	{
		widget =
		{
			slotpos = {	
				Vector3(0,32+4,0),
				Vector3(-(32+4), -(32+4),0), 
				Vector3((32+4), -(32+4),0),
				Vector3(-(32+4), -(64+32+8+4),0), 
				Vector3((32+4), -(64+32+8+4),0)
			},
			animbank = "ui_compostpile1c6x3",
			animbuild = "ui_compostpile1c6x3",
			pos = Vector3(200, 0, 0),
			side_align_tip = 100,
			buttoninfo =
			{
				text = "Fill",
				position = Vector3(0, -170, 0),
			}
		},
		acceptsstacks = false,
		type = "cooker",
	}
	
	function compostpileparams.itemtestfn(container, item, slot)
		return composting.IsCompostIngredient(item.prefab) and not container.inst:HasTag("burnt")
	end
	
	function compostpileparams.widget.buttoninfo.fn(inst)
		if inst.components.container ~= nil then
			BufferedAction(inst.components.container.opener, inst, ACTIONS.COMPOST):Do()
		elseif inst.replica.container ~= nil and not inst.replica.container:IsBusy() then
			SendRPCToServer(RPC.DoWidgetButtonAction, ACTIONS.COMPOST.code, inst, ACTIONS.COMPOST.mod_name)
		end
	end
	
	-- "can 'Fill' be clicked?"
	function compostpileparams.widget.buttoninfo.validfn(inst)
		local num = 0
		for k,v in pairs (inst.components.container.slots) do
			num = num + 1 
		end

		return inst.replica.container ~= nil and num > 2
	end

	inst:AddComponent("container")
	inst.components.container:WidgetSetup("compostpile", compostpileparams)
    inst.components.container.onopenfn = onopen
    inst.components.container.onclosefn = onclose

I also tried using

inst.components.container:WidgetSetup("cookpot") 

which doesn't change a thing...

When clicking the container, I receive the following stacktrace:

[00:11:35]: [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) Open (Lua) <24-143>
   self =
      callbacks = table: 6C6BE580
      slotsperrow = 3
      inst = 101081 -  (valid:true)
      focus = false
      children = table: 6C6BE3F0
      focus_flow_args = table: 6C6BE4E0
      focus_target = false
      isopen = false
      owner = 100182 - wickerbottom (valid:true)
      open = false
      can_fade_alpha = true
      inv = table: 6C6BE670
      parent = 
      name = Container
      bgimage = Image - :
      focus_flow = table: 6C6BE3A0
      enabled = true
      bganim = UIAnim
      shown = true
   container = 100113 - compostpile (valid:true)
   doer = 100182 - wickerbottom (valid:true)
   widget = nil
scripts/screens/playerhud.lua:262 in (upvalue) OpenContainerWidget (Lua) <259-264>
   self =
      fireover = FireOver
      sandover = SandOver
      beefbloodover = BeefBloodOver
      parent = screenroot
      overlayroot = overlays
      sailing_alpha = 0
      handlers = table: 80C97630
      mindcontrolover = UIAnim
      enabled = true
      under_root = under_root
      eventannouncer = EventAnnouncer
      name = HUD
      flareover = FlareOver
      focus_flow = table: 80C97338
      bloodover = BloodOver
      storm_root = storm_root
      over_root = over_root
      callbacks = table: 80C96DC0
      popupstats_root = popupstats_root
      sanddustover = UIAnim
      inst = 100184 -  (valid:true)
      focus = true
      children = table: 80C97018
      heatover = HeatOver
      focus_flow_args = table: 80C97360
      focus_target = false
      vig = UIAnim
      controls = Controls
      owner = 100182 - wickerbottom (valid:true)
      clouds = UIAnim
      can_fade_alpha = true
      iceover = IceOver
      fumeover = FumeOver
      is_screen = true
      storm_overlays = storm_overlays
      shown = true
      gogglesover = GogglesOver
      sailing_vig = UIAnim
      root = root
   container = 100113 - compostpile (valid:true)
   side = false
   containerwidget = Container
scripts/screens/playerhud.lua:272 in (method) OpenContainer (Lua) <266-274>
   self =
      fireover = FireOver
      sandover = SandOver
      beefbloodover = BeefBloodOver
      parent = screenroot
      overlayroot = overlays
      sailing_alpha = 0
      handlers = table: 80C97630
      mindcontrolover = UIAnim
      enabled = true
      under_root = under_root
      eventannouncer = EventAnnouncer
      name = HUD
      flareover = FlareOver
      focus_flow = table: 80C97338
      bloodover = BloodOver
      storm_root = storm_root
      over_root = over_root
      callbacks = table: 80C96DC0
      popupstats_root = popupstats_root
      sanddustover = UIAnim
      inst = 100184 -  (valid:true)
      focus = true
      children = table: 80C97018
      heatover = HeatOver
      focus_flow_args = table: 80C97360
      focus_target = false
      vig = UIAnim
      controls = Controls
      owner = 100182 - wickerbottom (valid:true)
      clouds = UIAnim
      can_fade_alpha = true
      iceover = IceOver
      fumeover = FumeOver
      is_screen = true
      storm_overlays = storm_overlays
      shown = true
      gogglesover = GogglesOver
      sailing_vig = UIAnim
      root = root
   container = 100113 - compostpile (valid:true)
   side = false
scripts/components/container_replica.lua:290 in (method) Open (Lua) <276-297>
   self =
      ondetachclassified = function - scripts/components/container_replica.lua:106
      acceptsstacks = true
      _numslots = 0
      _isopen = false
      issidewidget = false
      _cannotbeopened = net_bool (3D9C6D08)
      classified = 101080 - container_classified (valid:true)
      inst = 100113 - compostpile (valid:true)
   doer = 100182 - wickerbottom (valid:true)
scripts/components/container_replica.lua:95 in (field) fn (Lua) <87-101>
   inst = 100113 - compostpile (valid:true)
   self =
      ondetachclassified = function - scripts/components/container_replica.lu
[00:11:35]: [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) Open (Lua) <24-143>
    scripts/screens/playerhud.lua:262 in (upvalue) OpenContainerWidget (Lua) <259-264>
    scripts/screens/playerhud.lua:272 in (method) OpenContainer (Lua) <266-274>
    scripts/components/container_replica.lua:290 in (method) Open (Lua) <276-297>
    scripts/components/container_replica.lua:95 in (field) fn (Lua) <87-101>
    scripts/scheduler.lua:177 in (method) OnTick (Lua) <155-207>
    scripts/scheduler.lua:371 in (global) RunScheduler (Lua) <369-377>
    scripts/update.lua:178 in () ? (Lua) <157-236>

I tried to understand the container:WidgetSetup routines (same with container_replica) but I cannot see how this may be a problem with Caves... Maybe it's because of the multi-server setup... 


Can someone help me? Thanks in advance :)

compsting-together.zip

Edited by s1m13
add mod zip

Share this post


Link to post
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

Sign in to follow this