Jump to content

Crash (valid:false)


Recommended Posts

I got strange crash in my mod:

../mods/Optimizer/modmain.lua:651 in (method) DropLoot (Lua) <619-663>   self =      trappable = true      chanceloottable = rock1      inst = 314456 - rock1 (valid:true)      droppingchanceloot = true   pt = (5.48, 0.00, -653.70)   prefabs = table: 2D8001B8   arr = table: 2D7FCD68   k = flint   v = 1   loot = 314494 - flint (valid:false)

​It is very strange, because I checked variable "loot" before using.

local loot = self:SpawnLootPrefab(k, pt)if loot then

​How is it possible?

More code:

7338210.png

Full crash text:

[11:23:48]: [string "scripts/components/inventoryitem_replica.lu..."]:151: attempt to index field 'classified' (a nil value)LUA ERROR stack traceback:scripts/components/inventoryitem_replica.lua:151 in (method) SetPickupPos (Lua) <145-153>   self =      _cannotbepickedup = net_bool (32253390)      inst = 314494 - flint (valid:false)      _iswet = net_bool (32250B00)   pos = nilscripts/components/stackable.lua:6 in (field) ? (Lua) <3-8>   self =      _ = table: 3208A770      inst = 314494 - flint (valid:false)   stacksize = 1scripts/class.lua:30 in () ? (Lua) <23-32>   t = table: 32090008   k = stacksize   v = 1   p = table: 320936E0   old = 1../mods/Optimizer/modmain.lua:651 in (method) DropLoot (Lua) <619-663>   self =      trappable = true      chanceloottable = rock1      inst = 314456 - rock1 (valid:true)      droppingchanceloot = true   pt = (5.48, 0.00, -653.70)   prefabs = table: 2D8001B8   arr = table: 2D7FCD68   k = flint   v = 1   loot = 314494 - flint (valid:false)scripts/prefabs/rocks.lua:91 in (field) onwork (Lua) <87-100>   inst = 314456 - rock1 (valid:true)   worker = 314475 - shadowmeteor (valid:true)   workleft = -14   pt = (5.48, 0.00, -653.70)scripts/components/workable.lua:132 in (upvalue) old_WorkedBy (Lua) <123-143>   self =      onwork = function - scripts/prefabs/rocks.lua:87      lastworktime = 40960.768802937      inst = 314456 - rock1 (valid:true)      savestate = false      destroyed = false      _ = table: 2C51B0B8   worker = 314475 - shadowmeteor (valid:true)   numworks = 20../mods/Cannibalism18/modmain.lua:731 in (method) WorkedBy (Lua) <730-770>   self =      onwork = function - scripts/prefabs/rocks.lua:87      lastworktime = 40960.768802937      inst = 314456 - rock1 (valid:true)      savestate = false      destroyed = false      _ = table: 2C51B0B8   worker = 314475 - shadowmeteor (valid:true)   numworks = 20   arg = nilscripts/prefabs/shadowmeteor.lua:77 in (field) fn (Lua) <29-136>   inst = 314475 - shadowmeteor (valid:true)   shakeduration = 0.91   shakespeed = 0.026   shakescale = 0.65   shakemaxdist = 52   x = 2.0027265548706   y = 0   z = -653.15411376953   scorch = 314491 - burntground (valid:true)   launched = table: 2D81A1F8   ents = table: 2D800488   i = 1   v = 314456 - rock1 (valid:true)   work_action = table: 069108F8scripts/scheduler.lua:187 in (method) OnTick (Lua) <161-217>   self =      running = table: 06F698C0      waitingfortick = table: 06F71EA0      tasks = table: 06F673E8      waking = table: 31C43190      attime = table: 06F723B0      hibernating = table: 06F71D38   tick = 1228823   k = PERIODIC 314475: 0.330000   v = true   already_dead = falsescripts/scheduler.lua:398 in (global) RunScheduler (Lua) <396-404>   tick = 1228823scripts/update.lua:162 in () ? (Lua) <146-219>   dt = 0.033333335071802   tick = 1228823   i = 1228823[11:23:49]: QueryServerComplete no callback

 

Link to comment
Share on other sites

It's not that the loot didn't exist. It's because somehow the item didn't have a classified.

I see it was because of a flint result of a rock getting worked on by a meteor.

 

Can you try spawning a boulder and spawning shadowmeteor on it until it breaks? See if it reappears.

Link to comment
Share on other sites

I think it does not matter what code includes SpawnLootPrefab.

 

Because:

loot = 314494 - flint (valid:false)

just after

local loot = self:SpawnLootPrefab(k, pt)

 

So variable loot is not nil, but is not valid for some reason.

SpawnLootPrefab uses SpawnPrefab

and SpawnPrefab uses TheSim:SpawnPrefab(name), so core function returns existing invalid object.

 

And THAT is very strange. I think I should use now:

if loot and loot:IsValid() then

​every time after using SpawnPrefab function. Should I?

And it seems that it is very rare error. Wolrd exists over 6700 days.

Link to comment
Share on other sites

@Maris, try doing this:

- Go in your server

- Write in console

print(SpawnPrefab("flint"):IsValid())

and see if it returns true or false.

 

I also noticed that in SpawnLootPrefab there is a if loot:IsAsleep() then, so maybe there are some C side implications as to what may cause that false?

 

You can also try going to the position:

(5.48, 0.00, -653.70)

and see what's in there.

 

@Isosurface,

local arr = {	flint = 1,}for k, v in pairs(arr) do	print(type(k), k, type(v), v)	print(type(tostring(k)), tostring(k))end

outputs

string	flint	number	1string	flint
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...