Jump to content

I'm blind as a bat


Recommended Posts

So an embarrassing problem. Using the log armor spriter project i decided to make my own custom armor but with a container component, so it works as a backpack. Things are going well for host but when a client opens the backpack the game sends me this error:

[00:01:30]: [string "scripts/widgets/containerwidget.lua"]:29: attempt to index local 'widget' (a nil value)

Heres the armor with the container component:

 

local assets ={	Asset("ANIM", "anim/armor_littleredannie.zip"),    Asset("ATLAS", "images/inventoryimages/armor_littleredannie.xml"),    Asset("IMAGE", "images/inventoryimages/armor_littleredannie.tex"),}local function onequip(inst, owner)    owner.AnimState:OverrideSymbol("swap_body", "armor_littleredannie", "backpack")    owner.AnimState:OverrideSymbol("swap_body", "armor_littleredannie", "swap_body")    inst.components.container:Open(owner)    endlocal function onunequip(inst, owner)    owner.AnimState:ClearOverrideSymbol("swap_body")    owner.AnimState:ClearOverrideSymbol("backpack")    inst.components.container:Close(owner)endlocal function fn()	local inst = CreateEntity()    	inst.entity:AddTransform()	inst.entity:AddAnimState()	inst.entity:AddSoundEmitter()    inst.entity:AddMiniMapEntity()    inst.entity:AddNetwork()    MakeInventoryPhysics(inst)    inst.AnimState:SetBank("armor_littleredannie")    inst.AnimState:SetBuild("armor_littleredannie")    inst.AnimState:PlayAnimation("anim")    inst.MiniMapEntity:SetIcon("armor_littleredannie.png")    inst:AddTag("fridge")    inst:AddTag("nocool")        inst.foleysound = "dontstarve/movement/foley/backpack"    if not TheWorld.ismastersim then        return inst    end    inst.entity:SetPristine()        inst:AddComponent("inspectable")        inst:AddComponent("inventoryitem")	inst.components.inventoryitem.keepondeath = true	inst.components.inventoryitem.imagename = "armor_littleredannie"    inst.components.inventoryitem.atlasname = "images/inventoryimages/armor_littleredannie.xml"	inst.components.inventoryitem.cangoincontainer = true    inst:AddComponent("equippable")    inst.components.equippable.equipslot = EQUIPSLOTS.BODY        inst.components.equippable:SetOnEquip(onequip)    inst.components.equippable:SetOnUnequip(onunequip)    inst:AddComponent("container")    inst.components.container:WidgetSetup("backpack")    MakeHauntableLaunchAndDropFirstItem(inst)    return instendreturn Prefab("common/inventory/armor_littleredannie", fn, assets)

 

I've made custom backpacks before so I'm trying to compare the two but being blind as the bat I can't spot whats off about this one in particular. Any help is appreciated.

Link to comment
Share on other sites

@rons0n,

I notice that there is no

    if not TheWorld.ismastersim then		inst:DoTaskInTime(0.1, function() inst.replica.container:WidgetSetup("backpack") end)        return inst    end

Did you edit the containers.widgetsetup to acknowledge your prefab?

 

If not, the widget is nil.

Link to comment
Share on other sites

@DarkXero, Yup that was the trick. can't believed I overlooked that. Thank you! One more thing though, I hope you don't mind another simple question.

 

Awhile back I asked you to give complete immunity to tentacles for my Sakura ghost:

	local self = inst.components.combat	local old = self.GetAttacked	function self:GetAttacked(attacker, damage, weapon, stimuli)		if attacker and attacker.prefab == "tentacle" then			return true		end		return old(self, attacker, damage, weapon, stimuli)	end

 

Now I'm asking if its possible to add on complete immunity to real-players attacking it?

 

 

Link to comment
Share on other sites

@DarkXero, my mention isn't working and im too lazy to write it out. But thanks! I had assumed it needed attacker but I left it as HasTag("player") instead. Silly me.

 

Allwell, thanks for helping me this past week. (and Even longer than that actually)

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