Jump to content

Recommended Posts

what am i missing im working for more than 1 hour to fix that i'm trying to make an stackable item. I don't have any idea what the heck is the problem???? i checked existed items with stackable tag and i copied everything they have(about stacking) but it still crash!

 

here is the item.lua

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

local function fn()
	local inst = CreateEntity()
	
	inst.entity:AddTransform()
	inst.entity:AddAnimState()
	inst.entity:AddNetwork()
	
	MakeInventoryPhysics(inst)
	
	inst:AddTag("antique_stone")
	inst:AddTag("kitsuraitem")
	inst:AddTag("nosteal")
	
	inst:AddComponent("stackable")
    inst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEM
	
	inst:AddComponent("inspectable")
	
	inst.AnimState:SetBank("antique_stone")
	inst.AnimState:SetBuild("antique_stone")
	inst.AnimState:PlayAnimation("idle")
	
	if not TheWorld.ismastersim then
		return inst
	end
	
	inst:AddComponent("inventoryitem")
	
	inst.components.inventoryitem.atlasname = "images/inventoryimages/antique_stone.xml"
	
	inst.components.inventoryitem.keepondeath = true
	
	return inst
end

return Prefab("common/inventory/antique_stone", fn, assets)

and here is the error

[00:03: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: 394D2CD8
      inst = 100961 -  (valid:true)
   stacksize = 1
scripts/class.lua:30 in () ? (Lua) <23-32>
   t = table: 394D2BE8
   k = stacksize
   v = 1
   p = table: 394D2828
   old = nil
scripts/components/stackable.lua:17 in (field) _ctor (Lua) <14-19>
   self =
      _ = table: 394D2CD8
      inst = 100961 -  (valid:true)
   inst = 100961 -  (valid:true)
scripts/class.lua:181 in (local) cmp (Lua) <171-184>
   class_tbl = table: 394D21C0
   arg = nil
   obj = table: 394D2BE8
scripts/entityscript.lua:540 in (method) AddComponent (Lua) <529-551>
   self (valid:true) =
      GUID = 100961
      Transform = Transform (1328BB78)
      inlimbo = false
      persists = true
      actionreplica = table: 394D1018
      event_listening = table: 394D1658
      event_listeners = table: 394D1310
      actioncomponents = table: 394D1270
      Physics = Physics (30FE3048)
      lower_components_shadow = table: 394D1158
      spawntime = 0.46666669100523
      Network = Network (1327C858)
      entity = Entity (5571CCB8)
      AnimState = AnimState (1327C838)
      components = table: 394D12E8
      replica = table: 394D0FC8
   name = stackable
   lower_name = stackable
   cmp = table: 394D21C0
../mods/Kitsura/scripts/prefabs/antique_stone.lua:21 in (field) fn (Lua) <8-41>
   inst = 100961 -  (valid:true)
scripts/mainfunctions.lua:300 in () ? (Lua) <289-331>
   name = antique_stone
   prefab = Prefab antique_stone - 

[00:03: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:540 in (method) AddComponent (Lua) <529-551>
    ../mods/Kitsura/scripts/prefabs/antique_stone.lua:21 in (field) fn (Lua) <8-41>
    scripts/mainfunctions.lua:300 in () ? (Lua) <289-331>

im leaving the full error file (client and save)

server_log.txt client_log.txt

Edited by AkaiNight
13 hours ago, Monti18 said:

I think you need to add the component stackable after 


if not TheWorld.ismastersim then
	return inst
end

otherwise you get errors like these.

i tried to fix it like forever and the problem is.... i feel stupid

thanks

  • Like 1

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