Project Zomboid

Project Zomboid

Driving Cars Mod - MP & 3D Models
StryfeKhaos 18 Dec, 2016 @ 7:41pm
New issue
With the last update, I am now getting exceptions on car spawn:

1482116833737 function: SpawnCars -- file: DriveCarsServer.lua line # 173
java.lang.RuntimeException: attempted index: 1.0 of non-table: null
at se.krka.kahlua.vm.KahluaThread.tableget(KahluaThread.java:1549)
at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:473)
at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:163)
at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1727)
at se.krka.kahlua.vm.KahluaThread.pcallvoid(KahluaThread.java:1672)
at se.krka.kahlua.integration.LuaCaller.pcallvoid(LuaCaller.java:53)
at se.krka.kahlua.integration.LuaCaller.protectedCallVoid(LuaCaller.java:81)
at zombie.Lua.Event.trigger(Event.java:37)
at zombie.Lua.LuaEventManager.triggerEvent(LuaEventManager.java:83)
at zombie.iso.IsoChunk.doLoadGridsquare(IsoChunk.java:1239)
at zombie.network.ServerMap$ServerCell.RecalcAll2(ServerMap.java:302)
at zombie.network.ServerMap$ServerCell.Load2(ServerMap.java:179)
at zombie.network.ServerMap.preupdate(ServerMap.java:682)
at zombie.network.GameServer.main(GameServer.java:705)

I did a full wipe, removed all Steam files for the dedi server tool and the game, plus wiped the entire UserData\Zomboid directory to make sure it was completely clean.

It looks like some of the functions and variables defined in DriveCars.lua are not visible in the scope that DriveCarsServer.lua runs in.

First I added:
local CarList = {"yellowcamero", "whitepickup", "greenjeep"};
to SpawnCars before CarList was used.

After multiple other exceptions, I added the following functions to DriveCarsServer.lua:
StrReplace
AbsoluteValue
IsIn
getTextFor

New cars spawn now spawn. I verified that there were no more right click errors, and taking items from cars worked. I didn't verify driving, as I haven't found any non-broken cars with gas yet. :)

Also, SpawnCars will throw exceptions when running the server in 'softreset' mode
(-Dsoftreset as a parameter), even with these fixes. While reseting, it looks like 'square:transmitModdata();' isn't a valid call to make. I don't know if there's a flag to check before calling this, like some kind of 'IsServerDataResetting' or what.
Last edited by StryfeKhaos; 18 Dec, 2016 @ 7:42pm
< >
Showing 1-7 of 7 comments
StryfeKhaos 18 Dec, 2016 @ 7:48pm 
Driving worked as well.
nolanritchie  [developer] 19 Dec, 2016 @ 1:23pm 
i see. i didnt realize server lua and client lua files cant share global vars or functions. i updated a fix for this, try and let me know
StryfeKhaos 19 Dec, 2016 @ 2:46pm 
Exception in CarsLoading.lua now when SpawnCars is called, maybe because CarList isn't defined in CarsLoading.lua?
StryfeKhaos 19 Dec, 2016 @ 2:57pm 
Sorry, it wasn't CarList, it was on line 117:
cBag:setTexture(getTextureFor("DriveCarsMP."..CarBaseType .. tostring(RandomDirection)));

I don't think getTextureFor is defined in any script in the server Lua directory.
Last edited by StryfeKhaos; 19 Dec, 2016 @ 2:57pm
StryfeKhaos 19 Dec, 2016 @ 4:18pm 
I just commented out that line and it seemed to work. I don't think the world item object on the server side needs the texture?
Last edited by StryfeKhaos; 19 Dec, 2016 @ 4:23pm
nolanritchie  [developer] 19 Dec, 2016 @ 5:17pm 
that line just gives the cars a random direction when they spawn. but anyway, i think i corrected these things. updating now
StryfeKhaos 20 Dec, 2016 @ 7:34am 
Yes, seem to be working now! That makes more sense about the random direction. Still trying to decipher the PZ events and API.


Last edited by StryfeKhaos; 20 Dec, 2016 @ 8:11am
< >
Showing 1-7 of 7 comments
Per page: 1530 50