Project Zomboid

Project Zomboid

Random Airdrops [B41/B42]
Custom Loot Table Help
Can anyone give me some help with basic concepts of making one? I know the file is at C:\Users\Username\Zomboid\Lua but its blank. On LeandroTheDev's github page the full example just shows it start with "return {" is that it or does it need to match the file at "SteamLibrary\steamapps\workshop\content\108600\3282789883\mods\Random Airdrops\42\media\lua\server" starting at line 41? I do see something at line 244, does that take care of any special coding and just start the airdroploottable.ini with the "return {"?

Then once I start making the list with the combo function, so lets say it has a base chance of 50, then each item has a chance of 50, does that mean theres a 50% chance for any item in that group to spawn then each item's chance to spawn is 50%? What I want to add is a chance for like an m16 to spawn and if it does I want like a 70% chance for ammo and like a couple entries for mags to spawn (I'm guessing you can add multiple of the same item) Just want to give some variance on how many mags spawn. Or does the quantity modifier solve that? For example if you have a quantity of 10 and a chance of 50 does it do the calculation of 50%, 10 times so on average you'd get 5 mags?

Also if I wanted to include items from other mods do I use the mod id.itemname? So if I want to use a gun from the firearms 42 beta mod do I use something like this: firearmmodbeta.AssaultRifle?

I'll probably have more questions once I get it started but any help is welcomed.
< >
Showing 1-2 of 2 comments
TnT4u 7 Mar @ 8:23am 
Just an update to this:
I edited the AirdropLootTable.ini at C:\Users\Username\Zomboid\Lua. Started it with Return {. All brackets are closed so it shouldn't have to deal with that. I tried testing it in an existing test save using the sandbox options mod to change the setting and I got an error as the save loaded and the few drops I tested were empty. If I were to guess where it says Object tried to call nil, means that it was expecting to see nothing in that file but idk how this code is supposed to read.

STACK TRACE
-----------------------------------------
function: readAirdropsLootTable -- file: airdrop_server.lua line # 254 | MOD: Random Airdrops
function: Add -- file: airdrop_server.lua line # 1022 | MOD: Random Airdrops

LOG : General f:0, t:1741363903369> Object tried to call nil in readAirdropsLootTable
ERROR: General f:0, t:1741363903370> ExceptionLogger.logException> Exception thrown
java.lang.RuntimeException: Object tried to call nil in readAirdropsLootTable at KahluaUtil.fail(KahluaUtil.java:100).
Stack trace:
se.krka.kahlua.vm.KahluaUtil.fail(KahluaUtil.java:100)
se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:954)
se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:173)
se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1963)
se.krka.kahlua.vm.KahluaThread.pcallvoid(KahluaThread.java:1790)
se.krka.kahlua.integration.LuaCaller.pcallvoid(LuaCaller.java:66)
se.krka.kahlua.integration.LuaCaller.protectedCallVoid(LuaCaller.java:139)
zombie.Lua.Event.trigger(Event.java:72)
zombie.Lua.LuaEventManager.triggerEvent(LuaEventManager.java:315)
zombie.world.moddata.GlobalModData.init(GlobalModData.java:55)
zombie.iso.IsoWorld.init(IsoWorld.java:2597)
zombie.gameStates.GameLoadingState$1.runInner(GameLoadingState.java:301)
zombie.gameStates.GameLoadingState$1.run(GameLoadingState.java:251)
java.base/java.lang.Thread.run(Unknown Source)
LOG : General f:0, t:1741363903370> -----------------------------------------
STACK TRACE

This is at the first error the second line before end:
local function readAirdropsLootTable()
print("[Air Drop] Loading air drops loot table...")
local fileReader = getFileReader("AirdropLootTable.ini", true)
local lines = {}
local line = fileReader:readLine()
while line do
table.insert(lines, line)
line = fileReader:readLine()
end
fileReader:close()
airdropLootTable = loadstring(table.concat(lines, "\n"))() or {}
print("[Air Drop] Loot table loaded");
end

This is the second error is at "readAirdropsLootTable":

Events.OnInitGlobalModData.Add(function(isNewGame)
AirdropsData = ModData.getOrCreate("serverAirdropsData");
-- Null Check
if not AirdropsData.OldAirdrops then AirdropsData.OldAirdrops = {} end
if not AirdropsData.SpecificAirdropsSpawned then AirdropsData.SpecificAirdropsSpawned = {} end
readAirdropsPositions();
readAirdropsLootTable();

if SandboxVars.AirdropMain.DefaultAirdropCoordinates then
usingAirdropPositions = deepcopy(airdropPositionsDefault);
else
usingAirdropPositions = deepcopy(airdropPositions);
end
if SandboxVars.AirdropMain.DefaultAirdropLootTable then
usingAirdropLootTable = deepcopy(airdropLootTableDefault);
else
usingAirdropLootTable = deepcopy(airdropLootTable);
end

-- Limpador de airdrop antigo
if not SandboxVars.AirdropMain.AirdropDisableOldDespawn then
print("[Air Drop] Waiting for the first player connect to start removing old air drops")
AirdropsData.RemovingOldAirdrops = deepcopy(AirdropsData.OldAirdrops);
Events.OnTick.Add(ForceDespawnAirdrops);
end
end)
AnimeAss  [developer] 7 Mar @ 10:02am 
Hi, try using this wiki: https://github.com/AnimeSosiska/random-airdrops/wiki

If there'll be any more questions - feel free to ask
If you still getting errors after checking everything by wiki - pls create an issue on github :shyensher:
< >
Showing 1-2 of 2 comments
Per page: 1530 50