Jump to content

Recommended Posts

I dunno why, but some prefabs in me old Jenny Wakeman mod seem to be giving me errors...

 

The robofood she makes crashes upon crafting, giving me this error

Spoiler

[00:01:15]: [string "scripts/components/stackable.lua"]:4: attempt to index field 'stackable' (a nil value)
LUA ERROR stack traceback:
scripts/components/stackable.lua:4 in (field) ? (Lua) <3-8>
   self =
      _ = table: 68057F58
      inst = 100995 -  (valid:true)
   stacksize = 1
scripts/class.lua:30 in () ? (Lua) <23-32>
   t = table: 680581D8
   k = stacksize
   v = 1
   p = table: 68057E68
   old = nil
scripts/components/stackable.lua:17 in (field) _ctor (Lua) <14-19>
   self =
      _ = table: 68057F58
      inst = 100995 -  (valid:true)
   inst = 100995 -  (valid:true)
scripts/class.lua:181 in (local) cmp (Lua) <171-184>
   class_tbl = table: 680575D0
   arg = nil
   obj = table: 680581D8
scripts/entityscript.lua:523 in (method) AddComponent (Lua) <512-534>
   self (valid:true) =
      GUID = 100995
      Transform = Transform (32643AC0)
      inlimbo = false
      persists = true
      actionreplica = table: 68053110
      event_listening = table: 68053390
      event_listeners = table: 680533B8
      actioncomponents = table: 68052D00
      Physics = Physics (32644100)
      lower_components_shadow = table: 68052E40
      spawntime = 0.20000001043081
      Network = Network (32643AE0)
      entity = Entity (55DC8AE0)
      AnimState = AnimState (32643980)
      components = table: 68053160
      replica = table: 68053138
   name = stackable
   lower_name = stackable
   cmp = table: 680575D0
../mods/workshop-450532927/scripts/prefabs/vegetableoil.lua:39 in (field) fn (Lua) <13-64>
   Sim = Sim (25FDC5D0)
   inst = 100995 -  (valid:true)
   trans = Transform (32643AC0)
   anim = AnimState (32643980)
scripts/mainfunctions.lua:146 in () ? (Lua) <135-177>
   name = vegetableoil
   prefab = Prefab vegetableoil - 

[00:01:15]: [string "scripts/components/stackable.lua"]:4: attempt to index field 'stackable' (a nil value)
LUA ERROR stack traceback:
    scripts/components/stackable.lua:4 in (field) ? (Lua) <3-8>
    scripts/class.lua:30 in () ? (Lua) <23-32>
    scripts/components/stackable.lua:17 in (field) _ctor (Lua) <14-19>
    scripts/class.lua:181 in (local) cmp (Lua) <171-184>
    scripts/entityscript.lua:523 in (method) AddComponent (Lua) <512-534>
    ../mods/workshop-450532927/scripts/prefabs/vegetableoil.lua:39 in (field) fn (Lua) <13-64>
    scripts/mainfunctions.lua:146 in () ? (Lua) <135-177>

 

any reason why? Any other stackable item for me other mod characters doesn't give this issue.

 

let me know of a fix.

 

Spoiler

local assets=
{
	Asset("ANIM", "anim/vegetableoil.zip"),
	
		Asset("IMAGE", "images/inventoryimages/vegetableoil.tex"),	
    Asset("ATLAS", "images/inventoryimages/vegetableoil.xml")
}

local prefabs =
{
	"spoiled_food",
}
local function fn(Sim)
	local inst = CreateEntity()
	local trans = inst.entity:AddTransform()
	local anim = inst.entity:AddAnimState()
												inst.entity:AddNetwork()
    MakeInventoryPhysics(inst)
    
 --   inst:AddTag("honeyed")
    
    inst.AnimState:SetBuild("vegetableoil")
    inst.AnimState:SetBank("honey")
    inst.AnimState:PlayAnimation("idle")
    
    inst:AddComponent("edible")
    inst.components.edible.foodtype = "GEARS"
    inst.components.edible.healthvalue = TUNING.HEALING_SMALL
    inst.components.edible.hungervalue = TUNING.CALORIES_MED
    --inst.components.edible.sanityvalue = TUNING.SANITY_MED

    inst:AddComponent("fuel")
    inst.components.fuel.fuelvalue = TUNING.MED_FUEL
    
    
	MakeSmallBurnable(inst, TUNING.MED_BURNTIME)
    MakeSmallPropagator(inst)

    inst:AddComponent("stackable")
    inst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEM

    inst:AddComponent("tradable")

    inst:AddComponent("inspectable")
	
										inst.entity:SetPristine()
	
    if not TheWorld.ismastersim then
        return inst
    end
    
--	inst:AddComponent("perishable")
	--inst.components.perishable:SetPerishTime(TUNING.PERISH_SUPERSLOW)
	--inst.components.perishable:StartPerishing()
	--inst.components.perishable.onperishreplacement = "spoiled_food"
    
    
    inst:AddComponent("inventoryitem")
	inst.components.inventoryitem.atlasname = "images/inventoryimages/vegetableoil.xml"

	   MakeHauntableLaunchAndIgnite(inst)
    
    return inst
end

return Prefab( "common/inventory/vegetableoil", fn, assets, prefabs) 

 

Link to comment
https://forums.kleientertainment.com/forums/topic/71420-stackable-bug/
Share on other sites

most components have to be added after the lines:
 

    if not TheWorld.ismastersim then
        return inst
    end

there are only a few exceptions, like "talker" component.
 

The best would be to open the lua file of any game item that has the component you are looking for, and look how it is done there ;) You have to do this for all components this item is using, not only stackable.
(if it is before or after these lines)
 

Edited by Serpens

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