#mod_development

1 messages · Page 29 of 1

fringe cape
#

that would be sick as

signal frost
#

You can already do that with doors

fringe cape
#

Never did that

signal frost
#

Put a rubbish bin behind a door and you can't open it, is that what you mean?

fringe cape
#

O_O

#

I will try it out later

#

Thanks

signal frost
#

I can't access another player's inventory via client-side code, can I? I'll need to make a server request and get the server to ask the client, right?

signal ibex
#

You can run your server and games in nosteam mode and test it fast

#

So you can also use -debug and update the code or use the debug console to check stuff fast

#

But I have no idea if it's clientside when in multiplayer

signal frost
#

Yeah I'm doing that at the moment, just wondering if anyone knew off the top of their head

signal ibex
#

Ahh okay 😄
I almost had to try that before, but things went a different route

signal frost
#

I'm pretty sure each client doesn't know what the other ones have in their inventory

summer rune
#

how can i get my own player/character obj?

fierce rock
#

imagine necromorphs in pz

signal frost
#

Oh for fuck sake hahahaha

#

lua arrays start at 1

#

You have no idea how long that's taken me to debug

gilded hawk
#

So, I was trying to get if an item is a medical item or not, and I did this

item:getScriptItem().Medical

In the java files, Medical is a boolean, but for some reason It's not accessible from the lua 😦

Does anyone know a way around this?

signal frost
#

Do you mean the item's category, or are you saying there is a flag called medical that some items have?

tame mulch
gilded hawk
#

I had to find a weak workaround by doing this

function MxAcceptItemFunction.MedicalOnly(container, item)
    -- print(tostring(item:getScriptItem().Medical)) -- Apparently this does not work :-/
    return item:getStringItemType() == "Medical" or item:getDisplayCategory() == "FirstAid"
end
tame mulch
gilded hawk
# tame mulch This item have any medical word in script?

The antibiotics has the Medical = TRUE flag, and the display category to FirstAid

    item Antibiotics
    {
        DisplayCategory = FirstAid,
        Weight    =    0.1,
        Type    =    Food,
        DisplayName    =    Antibiotics,
        Icon    =    Antibiotics,
        ReduceInfectionPower     =   50,
        CustomContextMenu   =   Take,
        CantBeFrozen = TRUE,
        Tooltip = Tooltip_Antibiotics,
        Medical = TRUE,
        WorldStaticModel = Antibiotics,
    }

I'm not sure if I understood the question tho

tame mulch
#

Only by some hack 😄

gilded hawk
#

Well, it's not amazing, but thank you anyway

tame mulch
# gilded hawk Well, it's not amazing, but thank you anyway

You can try get Medical value of Item Script Object by this:

-- For find index of variable
local v1 = item:getScriptItem()

local num = getNumClassFields(v1)
for i=0, num-1 do
print(getClassField(v1, i), " --", i)**
end

-- For get value
local field = getClassField(v1, YOURINDEX)
local medical = field:get(v1)
print(medical)
gilded hawk
#

Truly interesting, I will try it ASAP

#

Also @tame mulch, do you know if createNewScriptItem works at all?
I was using it for my transmogV2 (https://github.com/mxswat/pz-Transmogv2) mod, but apparently it just does not work, which is truly sad since I handicaps my ability to generate script items at run time

GitHub

Contribute to mxswat/pz-Transmogv2 development by creating an account on GitHub.

tame mulch
gilded hawk
tame mulch
gilded hawk
gilded hawk
# tame mulch Interesting mod 🙂

Yes, it really is.

I based my new transmog mod on his code, https://github.com/mxswat/pz-Transmogv2/blob/master/Contents/mods/Transmogv2/media/lua/shared/~Transmogv2.shared.lua

As you can see on line 92 (65 in the diff), I used to have createNewScriptItem https://github.com/mxswat/pz-Transmogv2/commit/3fa4ac408bd90afeac279a79aa4c6b6c9da0b5dc

But, since createNewScriptItem is not really working, I had to fall back in limiting this mod to

  • generate items,
  • reboot game
  • and then you get the transmog item

If createNewScriptItem worked, I could skip the reboot game (and server) part

tame mulch
gilded hawk
# tame mulch What exactly you want do by this mod?

This mode does the following;

  • It generate a new file TransmogItems.txt
  • Then it loops through all the Type = Clothing that the game has, for each item it does two things:
    • generates a new Clothing item that has no stats or weight, this new item is what I call cosmetic item.
    • it generates a recipe to convert the original item, into a cosmetic item

The result is in the screenshot, it basically allows for transmog in zomboid (but this time with MP sync compared to my old mod: https://steamcommunity.com/sharedfiles/filedetails/?id=2768901065&searchtext=transmog)
As you can see the player is wearing a cosmetic beret, but is also wearing a military helmet, the cosmetic beret was generated from the vanilla beret at runtime.

#

Let me know if I explained myself poorly

winter bolt
#

yeah the game works backwards from the clothingtem file i think for some reason

shadow geyser
#

yep, thats why you can't use vanilla clothingItems for your own items unless you intend to replace them

gilded hawk
signal frost
#

Does anybody know of mods that show off sending items from one player to another? I've tried a few different ways including appropriating the trading code and haven't had much luck as of yet

gilded hawk
#

Is it possible to move the crafting context menu option under a submenu in the context menu? 🤔

vast nacelle
# gilded hawk Is it possible to move the crafting context menu option under a submenu in the c...

I believe it should be able to if you overwrite this vanilla function in ISInventoryPaneContextMenu.lua
Line 2730: ISInventoryPaneContextMenu.addDynamicalContextMenu = function(selectedItem, context, recipeList, player, containerList)
Save off the vanilla function, use the original context to make a submenu, and then send that new submenu context down into the vanilla call instead of the one you started with.

gilded hawk
#

Sounds like a good idea, thank you

summer rune
#

i can reference a base function and override it like so:

local ISCraftingUI_populateRecipesList = ISCraftingUI.populateRecipesList

function ISCraftingUI:populateRecipesList()
  -- my logic
  -- ....

  -- og call
  ISCraftingUI_populateRecipesList(self)
end

but what can i do if i have 2x ISCraftingUI.populateRecipesList ? like the vanilla lua function and a mod function with absolutely the same name.

How can i specify which function i want, from which origin?

bronze yoke
#

i don't think you can, it will grab the vanilla function if your mod loads before the other mod, and the other mod's one if that loads first

summer rune
#

can i not say something like local x = require "blabla/mod"
and then reference the function?

bronze yoke
#

i think that would work!

summer rune
#

yeah but how 😄

bronze yoke
#

it wouldn't help you get the vanilla one though

quasi geode
#

that require wont really do much in this case

#

its also unneeded

quasi geode
bronze yoke
#

i was assuming that the other mod doesn't replace it correctly, or this probably wouldn't be a question

#

but yeah, if the other mod does the same thing with calling the original, all three will run

summer rune
#

yes it is not correctly replacing the function. therefore i want to reference both vanilla and the mod function and use it in my mod

quasi geode
#

well if its not replacing it correctly then theres going to be conflicts, incompatibilities and broken bits regardless

#

if its not correct (referencing and calling the original) then its probably completely replaced it (and duplicated its code), so firing both is no longer practical. You'll have to pick one or the other

#

it will basically come down to load order at that point...load first, grab the original.. load second: grab the overwrite

#

if you really want both reference, load first, grab the original...then grab the overwrite later (on event triggered delay or similar)

summer rune
#

so i can not load last and choose?

quasi geode
#

not likely. if you load last, the other mod has probably replaced the function...the original maybe stored in a local variable (if they bothered to save it at all)...but its unlikely you'll beable to access it (unless they shoved it into another variable inside ISCraftingUI)

#

if they stored it in a local variable, then you cant access it....if they didnt store it at all then its basically gone. best option is to load first if you really want to pick and choose

summer rune
#

thanks that helped. ok so i have to copy both codes and mix and match them.

#

in order to beat the chaos, i have to make more chaos 😄

fossil parcel
#

Where are item icons stored?

tame mulch
fossil parcel
#

thanks!

hollow current
#

I know how to add translations -- but how exactly do I translate an item's name?

final ridge
#

Q: Is it possible to use moveables(furniture/tiles) in crafting recipes yet? is there fancy way of doing it, or is it not impossible? thanks

hollow current
hearty dew
# summer rune so i can not load last and choose?

You can load a file before the other mod's file runs, capture the function before it is modified, and also load a file after the other mod's file runs, and do whatever you want with their implementation

#
-- OtherModId_OverwriteISCraftingUI.lua

function ISCraftingUI:populateRecipesList()
  -- my logic
  -- I hate the original ISCraftingUI.populateRecipesList implementation, so not gunna call it! muhaha!
end```
```lua
-- !!_MyModId_preOtherModId_CaptureOriginal.lua

MyModIdNamespace = MyModIdNamespace or {}
MyModIdNamespace.ISCraftingUI_populateRecipesList = ISCraftingUI.populateRecipesList
-- zz_MyModId_postOtherModId_OverwriteISCraftingUI.lua

function ISCraftingUI:populateRecipesList()
  -- my logic
  -- ....

  -- og call
  MyModIdNamespace.ISCraftingUI_populateRecipesList(self)
end```
#

There may be an issue whereby a third mod modified the same function after !!_MyModId_preOtherModId_CaptureOriginal.lua but before OtherModId_OverwriteISCraftingUI.lua is loaded, so you may want to adjust the filename so it loads to as close as possible to before OtherModId_OverwriteISCraftingUI.lua

#

PZ loads lua files in alphabetical order, so you have that to manipulate the load order

velvet vortex
#

any good guides for modding/importing custom models like clothing, helmets, backpacks, etc

hearty dew
fossil parcel
#

It was a model problem after all, heh.

#

Anyways... It's fixed now. I also added a crafting recipe and fancy sound effects while I was at it.

#

Thank you for taking the time of your day to try and help me out.

winter bolt
#

oh weird what was causing it

fossil parcel
#

I think I botched the UV map or something like that

#

I just took a spiffo head from the game files and modified it a bit

#

now it works

winter bolt
#

nice

fossil parcel
#

Not gonna dwell on it, I'll just thank the computer gods that it somehow works.

mighty wedge
#

anyone know how to make custom poses?

random finch
#

What is the best way to make a sound heard across the map (for both players & zeds)? There seems to be a cap on sound/radius?

#

PlayWorldSound​(java.lang.String string, boolean boolean1, IsoGridSquare square, float float1, float float2, float float3, boolean boolean2)

ruby urchin
mighty wedge
#

is there an early draft i can read?

ruby urchin
#

Not for the moment, I'm just in the introduction

mighty wedge
#

ah ok 😦

#

well lmk when u finish it cause id probably need the help

pine fiber
#

Is this code part still valid ?

buildUtil.getWoodHealth(self)

vast veldt
#

Re: player:getXp(), I have a couple of questions:

  1. Can I reduce the player's XP? Trying to call setXPToLevel(perk,level) works when increasing the level, but does not reduce it if the level is higher.

  2. The AddXPNoMultiplier(perk,amount) method seems to imply it will apply the provided XP without adjustment due to the multiplier. But the amount actually applied doesn't seem to be the amount provided. e.g. If I say AddXPNoMultiplier(farming,100), starting from zero, I don't necessarily end up at 100 xp.

For example, I gave 100 xp to "Fitness", starting from Zero. I ended up with 100 xp. Using exactly the same method call, I then gave 100 xp to "Lightfoot", starting from Zero. I ended up with 32.5xp.

What else could be affecting the XP actually given?

astral dune
#

is there any sneaky way in Lua to get access to a local variable?

hearty dew
#

In what context?

astral dune
#

Everything in lua/server/VehicleCommands.lua is stored in a local variable, but I'd like to use them

#

If this was java, I'd use reflection or something to get into a private variable anyway, just wondering if there is something similar in lua or if I have to just straight up overwrite the whole file in order to fix it

hearty dew
#

Oh, that's rude. The least they could have done was return Commands at the end of the file so that you could require Vehicle/VehicleCommands to use it 😅

#

I can't think of a way to get at that. If you could load a file prior to that, maybe you could do something tricky with setfenv. But idk if you can even load a mod lua file prior to vanilla lua files

astral dune
#

If I have a matching file with a matching name in my mod it will just override it, right? Not great for intercompatibility, I know, but I'm not particularly worried about that atm

hearty dew
#

That's definitely the case between mods. I believe it also works that way to override vanilla lua files, yes

astral dune
#

time to hackerman this sh*t then

#

looks like they do the local commands thing in a bunch of places. Not a bad design choice, but nasty for modding imo

hearty dew
#

Mm. If they'd just add at the end of the files the linelua return Commands

In your mods, you could dolua local VehicleCommands = require("Vehicle/VehiclesCommands") VehicleCommands.doCommand(blah)

astral dune
#

I want to override the commands, more than use them, tbh

hearty dew
#

That's an option that doesn't pollute the global table and also enables mods to access those function

#

You would be able to override them as well

#
local VehicleCommands = require("Vehicle/VehiclesCommands")
local og = VehiclesCommands.doCommand
VehiclesCommands.doCommand = function(...)
  -- ...
  og(...)
end```
#

I think overriding the entire file is probably the easiest option with how it is atm though

astral dune
#

well, I tried overriding the file, still get the attempted index of non-table error, but if I go to the lua file in debug mode it shows my changes. Weird

hearty dew
#

You can check console.txt to see which files are loaded in which order

astral dune
#

it seems to recognize that I'm overriding it and loads my version instead without ever trying to load the vanilla one

hearty dew
#

And you changed the local Commands = ... to Commands = ...?

astral dune
#

initially, ya

#

I'm trying the requires thing atm

hearty dew
#

Mm, make sure the new VehiclesCommands.lua file loads before the file that uses them. (require will do that for you)

astral dune
#

does the require have to be at the top?

hearty dew
#

no, it's just a regular function

astral dune
#

maybe I need to require("server/Vehicle/VehicleCommands") or something, local VehicleCommands = require("Vehicle/VehicleCommands") results in nil

hearty dew
#

server/ shouldn't be there

astral dune
#

also its Vehicles, that might be it too

hearty dew
#

Do you return Commands at the end of the file?

astral dune
#

ya

hearty dew
astral dune
#

vehicle:getId() vs vehicle:getID() is what got me yesterday. They're both valid functions that do different things, lmao

#

got it. Had to put if isClient() then return end at the top of the file to keep it from trying to load clientside

magic nymph
#

Does anyone know of a mod that adds an extra option to the context menu of an item?

I want to learn how to do this and would like to see how it's done.

astral dune
#

the refurbish mod adds a refubish option to the context menu of pretty much any item, probably a good one to look at

magic nymph
#

Thanks, I'll look into it 🙂

glad ridge
#

Is there a way to do: if i'm holding a certain item, my transfer speed increases in lua?

astral dune
#

Bummer, there doesn't seem to be any event or other way to tell when a vehicle has hit a zombie

#

or even when a vehicle has taken damage in general, aside from when it hits anything that isn't a zombie/player

#

I don't suppose there is any way to listen for a particular packet?

hollow current
#

maybe there's an event to tell when a zombie has taken damage?

#

I am not sure

astral dune
#

there is, but only from a weapon

hollow current
#

oh

#

yee I am not sure if there's another way around this

astral dune
#

doesn't seem to be. Bit of an oversight on the devs' part to leave vehicles like this, but from what I understand they've only recently been reworked

analog totem
#

How do item tagging works for recipes?
I added the canopener tag to the kitchen knife and overided the item. It shows the knife in the recipe droplist but it doesnt recognize that I have the knife on me

undone elbow
#

When a player opens a world container, I need to create a modData property to an item in that container. How to sync it with server?

fossil parcel
#

Haha, me again. How can I assign an icon to a custom clothing item? Seems to be a question mark no matter what I do.

hearty dew
hearty dew
#

It adds vanilla context menu entries on items. Most mods do it similarly

boreal crow
astral dune
boreal crow
#
function MSGTweaks_RecipeCodes.OnCreate.ConvertToMetalLow(items, result, player)
    MSGTweaks_RecipeCodes.ConvertToMetal(items, player, false)
end

function MSGTweaks_RecipeCodes.OnCreate.ConvertToMetalHigh(items, result, player)
    MSGTweaks_RecipeCodes.ConvertToMetal(items, player, true)
end

function MSGTweaks_RecipeCodes.OnGiveXP.ConvertingToMetalLow(recipe, ingredients, result, player)
    player:getXp():AddXP(Perks.MetalWelding, 20)
end
function MSGTweaks_RecipeCodes.OnGiveXP.ConvertingToMetalHigh(recipe, ingredients, result, player)
    player:getXp():AddXP(Perks.MetalWelding, 40)
end```

Why do these reward `5`, and `10` experience?
bronze yoke
#

xp math is weird, xp is quartered by default

#

+75% on the character creation screen means 25%+75%

#

so someone who starts with one point gets the xp you actually put in, for some reason

undone elbow
# hearty dew If there is a function associated with that circumstance, you can make your own ...

You can make your own (simple or complicated) event system, e.g.: ```lua
local MyEventSystem; MyEventSystem = {
data = {},
Add = function(type, fn)
if not MyEventSystem.data[type] then
MyEventSystem.data[type] = {}
end
MyEventSystem.data[type][fn] = true
end,
Trigger = function(type)
for fn in pairs(MyEventSystem.data[type]) do
fn()
end
end,
}

MyEventSystem.Add("custom_event", function()
print('hi')
end)

MyEventSystem.Trigger("custom_event")```

sour glen
#

Are there any mods out that let you paint or write on boxes for organization?

undone elbow
#

Which is better to use: vehiclePart:getModData() or vehiclePart:getInventoryItem():getModData() ?

hearty dew
#

Someone early had said mod data doesn't persist on inventory items, but does on vehicle parts. So presumably the former is better if you intend for the data to persist, but I haven't tested personally

astral dune
#

I used part:getModData() and it persisted, for what its worth

undone elbow
#

But what if I uninstalled the part? How to get the modData if it's already an item?

wooden lodge
#

Is there a way to just... copy a bag with it's contents?

undone elbow
meager lion
#

I doubt its possible but are we able to override java classes as well?

magic nymph
#

I figure I can't override java methods, either way, but I was hoping that maybe it was exported to lua

#

Hmm, actually, I might be able to do it. There's a line In LuaManager and, if it's what I think it is, then it might be possible.

this.setExposed(BodyDamage.class);

#

Or maybe I don't need to override it at all, depending on how the context menu items work. If it allows me to include a pointer to a function, I should be fine.

wooden lodge
#

I guess not. oof zombie

ruby urchin
magic nymph
#

Add option. Basically, I want to make it so that I can take half or all of the Vitamins since the default amount is so minuscule that it becomes tedious having to press "Take Pills" over and over and over.

ruby urchin
#

Probably this can help you

Events.OnFillWorldObjectContextMenu.Add(OnFillWorldObjectContextMenu)
    local function OnFillWorldObjectContextMenu(player, context, worldObjects, test)

        local contextMenuList = context:getMenuOptionNames();
        if contextMenuList["OptionaNameHere"] then
            local testOption = context:addOption("Test", "Blabla", animal, nil)
           
        end

    end
end

Events.OnFillWorldObjectContextMenu.Add(OnFillWorldObjectContextMenu)
magic nymph
#

Thanks, looking at it now

#

In the following line, is this where I would check for the item name?

if contextMenuList["OptionaNameHere"] then

astral dune
#

the more I look at the code the more I kinda cringe. Why does InventoryItem have a getSuspensionCompression method, for example? Serious refactoring is needed, lmao

ruby urchin
# magic nymph In the following line, is this where I would check for the item name? > if con...

that returns all options of a specific context, but better try with this

ISInventoryMenuElements = ISInventoryMenuElements or {};
ISInventoryMenuElements.YourContextMod = function()
    local self = ISMenuElement.new()
    self.inventoryMenu = ISContextManager.getInstance().getInventoryMenu()

    self.createMenu = function(item)
        local source = getPlayer();

        if item:getName() == "blablalba" then
            self.inventoryMenu.context:addOption("Test", item, self.equipContainer, source);
        end
    end

    return self
end
mighty wedge
#

is it possible to change the fire rate of a weapon?

astral dune
#

Well this is weird, there are lots of variables in the vehicles that do nothing. For example the gearRatios in the vehicle scripts aren't used. Also, the EnginePower you see in the mechanics menu does nothing, you can set it to whatever you like but it changes nothing, your engine power is actually the engineForce in the vehicle script. I don't think that value can be changed easily either

#

I want to be able to change the vehicle's handling and strength, but its not going to be easy. Best I can think of is to make the vehicle lighter and the tires stickier to give the impression its more powerful, but then collisions get really weird

#

Wish the vehicle code wasn't a mess

ancient grail
#

does anyone know what get() function i can print to get the server time?

fierce rock
sinful nimbus
#

Just wondering if anybody has made or is working on a "mountable weapon" mod (like a tripod). That would preferably work in tandem with Brita's Weapons. Would be great to mount a minigun, or even just a m16 with a 60 round mag to a stationary position like covering a gate. If not I'm def tempted to make it myself.

young orchid
#

best mod for adding 2 weapons on back/backpack without the need to install 3 mods to achieve this?

plucky junco
#

Hi guys, i'm trying to add a stats to the player when they make a recipe. I want the player to use the lighter to do those tricks, so right now I wrote a recipe that does require only the lighter, the result of the recipe is the lighter itself but I made a "oncreate" function that take it away. I would like to ass a -5 stress to the recipe using the function, but i'm not that good. Anyone can help?

#

function Removestress (items, result, player)
player:getInventory():Remove("7ippoclassic");

end

#

this is the simple function i'm using now

#

as I said I would like to add a -5 stress to it

ancient grail
hollow current
#
function Removestress (items, result, player)
  local currentStress = player:getStress()
  player:setStress(currentStress - 5)
end```
#

not sure though

plucky junco
plucky junco
hollow current
#

sure

#

if it doesn't work, try changing player to its object first

#

like this:

function Removestress (items, result, player)
  local playerObj = getSpecificPlayer(player)
  local currentStress = playerObj:getStress()
  playerObj:setStress(currentStress - 5)
end```
plucky junco
hollow current
#

Client

plucky junco
#

yeah it crash 😔

vast nacelle
#

There should be a getStats() call, like
playerObj:getStats():getStress()

magic nymph
dim geode
#

If they don’t do a PvP overhaul someone should make a mod to better the combat with firearms and melee.

Example: being able to have a hot key while you’re holding a weapon to duck for cover next to the wall you’re standing by/sandbags etc.

I know someone has modded prone into the game but they should chunk it in with this idea. Being able to shoot while prone and while crouching would be nice.

Also.. the stun lock mechanic is the dumbest thing I’ve seen.. just have your movement speed reduced instead of not being able to fight back at all, increase the blood loss as well. I hate having to empty 12 bullets into my victim to finish the job.

Also do something with the head tracking so I don’t have to stand on a persons face to do crit damage while smacking my baseball bat on the cement above my victim

hollow current
#

Is there a way to make a container accept only one kind of an item?

vast nacelle
#

@hollow current You can add an AcceptItemFunction property to containers

#

Set up a function like in media/lua/server/Items/AcceptItemFunction.lua
Then use that function name as the value for the property

hollow current
#

Thanks!

pine fiber
#

To modify a subscribed mod from a dedicated server, is it enough to just upload the modified files of the mod to replace them with the old ones or is it necessary to go through a complete copy of the mod to upload on the workshop on steam?

dim geode
#

Also someone fix vehicle PvP you can just shoot through vehicles like they don’t exist and that doesn’t make sense..

hollow current
#

is there a way to check what kind of water container the player is using? (Sink/Toilet/etc)

ancient grail
#

so that whatver result will get deleted and u wont have to delete it from the oncreate

plucky junco
#

and it's not working now either

plucky junco
ancient grail
#

ye sorry bout that im on mobile when i typed it

final ridge
#

Q: Is it possible to use moveables(furniture/tiles) in crafting recipes yet? is there fancy way of doing it, or is it not impossible? thanks

ancient grail
ancient grail
#

including its category

plucky junco
final ridge
plucky junco
#

StressChange = -5, this is on the cigarettes

ancient grail
#

yep u could change the item ur doing

#

what exactly is the item ur doing

#

if your modifykng the vanilla u can use itemtweaker

weak sierra
#
local zones = ScriptManager.instance:getAllZones()
#

that's line 14

#
function: 0_UdderlyVehicleRespawn_Core.lua -- file: 0_UdderlyVehicleRespawn_Core.lua line # 14 | MOD: Udderly Vehicle Respawn

ERROR: General     , 1664556193217> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: Object tried to call nil in 0_UdderlyVehicleRespawn_Core.lua at KahluaUtil.fail line:82.```
bronze yoke
#

getScriptManager()?

weak sierra
#

tried that first

#

swapped over to ScriptManager.instance when that said this already

#

gonna try calling it with . instead of : real quick

bronze yoke
#

hey wait

#

you're using the old docs

weak sierra
#

i use both

bronze yoke
#

getAllZones() isn't on the .65 one

weak sierra
#

why

#

why would that be gone

#

:|

#

ugh

#

i've been trying to figure out how to get zones for a cell

#

for ages

quasi geode
#

dont use the old docs

weak sierra
#

i actually thought those were newer but incomplete

quasi geode
#

thats from like 7 years ago

weak sierra
#

since they didnt specify a version and were on the official site

bronze yoke
#

they're ancient

weak sierra
#

so

#

my other approach to getting zones is well within the newer docs and doesn't work

#
    local zones = getWorld():getMetaGrid():getCellData(cellX * 300, cellY * 300)["vehicleZones"]
    print("[UdderlyVehicleRespawn] Found "..zones:size().." zones in cell "..cellX..", "..cellY..".")
    local vehicleZones = {}
    for i=0, zones:size()-1 do
        local zone = zones:get(i)
        if instanceof(zone, "VehicleZone") then
            table.insert(vehicleZones, zone)
        end
    end
    return vehicleZones
#

apparently it just returns nothing every time, if i recall, but it's been a week or so since i ran that iteration

#

reverts all changes and tests

#

i thought writing a vehicle respawn mod would be hard but i never imagined it'd be hard because there's no way to get zones

#

:P

#

there's tons of functions, they are just all broken

hollow current
#

Is there any sort of list where I can find all possible animations?

weak sierra
#
    local zones = getWorld():getMetaGrid():getCellData(cellX * 300, cellY * 300)["vehicleZones"]
#
STACK TRACE
-----------------------------------------
function: GetZonesForCellAt -- file: 0_UdderlyVehicleRespawn_Core.lua line # 173 | MOD: Udderly Vehicle Respawn
function: RespawnVehiclesClient -- file: 0_UdderlyVehicleRespawn_Core.lua line # 250 | MOD: Udderly Vehicle Respawn

ERROR: General     , 1664558909993> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: attempted index: vehicleZones of non-table: null at KahluaThread.tableget line:1689.
ERROR: General     , 1664558909993> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: attempted index: vehicleZones of non-table: null```
#

that is line 173

hollow current
bronze yoke
#

from what i can gleam it's not finding the meta cell

weak sierra
#

yeah

#

or maybe im keying into something wrong

bronze yoke
#

maybe you don't need to multiply the co-ordinates? as a complete guess

#

i'm honestly not clear on how cells work, as soon as my code needs to work with them i just go and find a different way to do it lol

#

but i see 'getCellDataAbs()' which could mean absolute co-ordinates, which would imply that the normal one isn't in normal co-ordinates?

weak sierra
#

fair i'll try that

#

i know how cells work but it's hard to know what the args are for what

#

also i don't know why i was keying into it like a damn table

#

musta been burned out when i wrote this

velvet copper
#

Is there a mod that lets me pick up doors from other building, and place them in a door frame I built?

weak sierra
#

yup i had big stupid when i wrote that a week or so ago

#

don't write code when you're tired

#

or distracted, or burned out

#

it's just bad

#

xD

#

field not accessible it seems, im guessing, by the null

#

will try the reflection stuff

weak sierra
#

ugh

#

LOG : General , 1664563046487> UDDTST: Found 0 zones for cell 36x33.

#

LOG : General , 1664563127937> UDDTST: Total zone count: 30
LOG : General , 1664563127937> UDDTST: Found 0 zones for cell 36x33.

#

ok so

#

there's zones just not vehicle zones

#

is there something wrong with doing this:

#
vehicleZones = {}
for i=0, zones:size()-1 do
    local zone = zones:get(i)
    if instanceof(zone, "VehicleZone") then
        table.insert(vehicleZones, zone)
    end
end```
#

so they're all vehicle zones

#

yet instanceof ain't workin

#

guessin "VehicleZone" doesn't cut it

#

they return as "zombie.iso.IsoMetaGrid$VehicleZone"

#

if i print them as string..

#

guess ill try "zombie.iso.IsoMetaGrid.VehicleZone"

random finch
#

I can only get sounds to be heard upto 10 tiles from players away no matter what the volume/range is. Zeds do hear the sound, and at a long distance. Any ideas?
I.E.:PlayWorldSound("PZ_ChopTree1", true, getPlayer():getCurrentSquare(), 6000, 6000, 6000, true) ;

Using PlayWorldSoundServer doesnt seem to produce any sound.

elfin stump
sour glen
#

If you add a vehicle mod with more vehicles to an excisting game. Will the new vehicles spawn? or do you have to restart

pearl prism
sour glen
#

@pearl prism Thank you

calm acorn
#

AH HA! So your the reason i cant use sandbox options with loot

elfin stump
calm acorn
#

looks like OnLoadMapZones fires off about 100 lines later

#

i submitted a suggestion asking if sandboxoptions can be loaded before OnPreDistributionMerge or OnInitWorld because im having to relay on a lua config for my mod.

#

I have seen a lot of other mods using one of those three events when messing with loot i suspect it would really be a saving grace for when mod options stops working

elfin stump
#

Yep I had to deal with the same problem - can you tell me what file this is in? I would like to understand it better.

calm acorn
#

zombie/iso/IsoWorld.java

elfin stump
#

As far as I can tell it is not supported to enter loot table information via the sandbox because of this issue - that suggestion is a good one.

calm acorn
#

well the funny thing is, on new game creation and new server creation the first instance of the world has access to those variables

elfin stump
#

Awesome I will take a look at that. It looks like you found the root cause of my problem. The issue I was having was that sandbox works the first time to teh first setting just fine, after that, the load order is bad and it won't update until after distribution.

#

Yep thats right. same thing.

calm acorn
#

so if you are only testing your mod by starting it up and shutting it down you never catch it breaking on the restart/reload

elfin stump
#

Yep that is exactly the same behavior I had. Works perfect the first time, load order breaks it every time after, only if sandbox is involved.

#

@willow estuary ^ Tagging you because Xyberviri found where the sandbox loot table bug is that prevents us from using sandbox for loot tables reliably.

#

@calm acorn I had been battling this for awhile before I honed in on it being a load order issue but I never jumped into the java to find it. Good find!

summer rune
#

any easy way to remove an item from the loot table / distribution table?

hollow current
hearty dew
summer rune
#

so just using table.remove on the distribution table? what is the table that holds all the base vanilla items? or do i have to itterate over several tables?

hearty dew
#

There are multiple tables for different loot placements. There is one for items that spawn in containers, one for items that appear on zombies (clothes, etc), one for attachments on zombies (gun on back, scissors/crowbar in back, etc). One for vehicles. Depending on what exactly you're trying to do, you may need to look at more than one

#

They all contain base vanilla items

summer rune
#

is there a wiki page listing all the different tables?

#

just the names, not the contents

hearty dew
#

Idk about a wiki, but here are at least a few of them

#
ProjectZomboid/media/lua/shared/NPCs/ZombiesZoneDefinition.lua```
That one is for items/clothes on zombies
summer rune
#

thanks a lot. appreciate all those detailed answers.

hearty dew
#

There might be a way to delete an item that'd be easier if you simply want the item removed from the game. If so, hopefully someone familiar with it chimes in

summer rune
#

actually yeah my problem is twofold. i want to remove some items completely form the game, like some mods add a lot of stuff. but we only want a handful. but then some vanilla base items should be sold in our own shop system, but not be found in containers around the world.

#

i tought i beat both use cases just modifying the distribution

hearty dew
#

In that situation, it sound worthwhile to write a function that iterates those tables and removes references to items you specify

summer rune
#

cool. alright. that was my preferred way as well.

#

thanks again. 🔥

astral dune
astral dune
#

So I lied earlier, engine power DOES matter, but only in reverse

#

anyone know if there is somewhere I can report an issue like that?

pine fiber
astral dune
#

do they get mad if you imply you've decompiled the code to find the issue?

random finch
#

nope

astral dune
#

actually now that I say that, I should probably see about decompiling a newer version so I'm not misled

meager lion
#

Does anyone know what the int value is for in this method?
IsoGridSquare():getLightLevel(int int1);

hearty dew
#
    public float getLightLevel(final int n) {
        return (this.lighting[n].lightInfo().r + this.lighting[n].lightInfo().g + this.lighting[n].lightInfo().b) / 3.0f;
    }```
#

        this.lighting = new IsoGridSquare.ILighting[4];```
How it is initialized in the ctor
meager lion
#

So it's the color index of the rgb. Now to figure out where to get said index from lol

hearty dew
#
    void cacheLightInfo() {
        final int playerIndex = IsoCamera.frameState.playerIndex;
        this.lightInfo[playerIndex] = this.lighting[playerIndex].lightInfo();
    }
    
    private int renderFloorInternal(final Shader shader) {
        final int playerIndex = IsoCamera.frameState.playerIndex;
        final ColorInfo colorInfo = this.lightInfo[playerIndex];
        final IsoGridSquare camCharacterSquare = IsoCamera.frameState.CamCharacterSquare;
        final boolean bCouldSee = this.lighting[playerIndex].bCouldSee();
        final float darkMulti = this.lighting[playerIndex].darkMulti();```
meager lion
#

I assume getPlayerNumber() is the winner then

#

Thanks for the info 🙂

random finch
#

Is anyone aware of a way to play a sound that can be heard by players beyond 10 tiles away? You can set the distanceMax in the script of an item, but I am looking for a way to set distanceMax dynamically. Seemingly range only applies to zed hearing range which can be changed dynamically,

undone elbow
#

How to get all nearest players with specific player on the server?

ancient grail
ancient grail
elfin stump
random finch
elfin stump
#

That is for player, one folder back in AnimSets looks like it has all animations in there

undone elbow
#

getOnlinePlayers() vs getConnectedPlayers() ? What is better?

zealous wing
#

Question: Is there a way I can remove the heat requirement from a specific item in regards to using heat as a requirement for a recipe? I'd like to just have it so that the oil only needs to be hot here, and not the breading.

#

Any help would be appreciated.

elfin stump
weak sierra
#

never seen that in vanilla

ancient grail
ancient grail
elfin stump
#

Yeah I don't think it is vanilla either, I don't know if I have ever seen (Hot) as a requirement - is that a vanilla thing or from another mod? It seems like it would just be a requirement in the recipe.txt but I am not sure if that is a modded requirement or one that is available in vanilla.

ancient grail
#

but you can GetModData() i think im not realy sure how to use that tho

#

xyberviri just gave it to me earlier as part of a code

elfin stump
#

I think you can call GetModData() on just about anything and and use it to store variables. So like
playerModStuff = player:GetModData()
playerModStuff.something = "1"
playerSomething = playerModStuff.something

#

I think it works kind of like that

weak sierra
#

sapph's cooking has it, i think it's a newer vanilla feature tho

#

the hot thing

pine fiber
#

The window element doesn't have health data like a door or a wall? I can't find any information

magic nymph
#

Anyone know what defines "low quality?" I'm guessing the weapon's condition is low, but just want to make sure.

-- meat cleaver & some others low weapons (Hand Axes..) in the back AttachedWeaponDefinitions.meatCleaverBackLowQuality = { chance = 5, weaponLocation = {"MeatCleaver in Back"}, bloodLocations = {"Back"}, addHoles = true, daySurvived = 0, weapons = { "Base.MeatCleaver", "Base.HandAxe", }, }

-- Better weapons in the back AttachedWeaponDefinitions.meatCleaverBack = { chance = 1, weaponLocation = {"MeatCleaver in Back"}, bloodLocations = {"Back"}, addHoles = true, daySurvived = 20, weapons = { "Base.Machete", "Base.HandAxe", }, }

calm acorn
bronze yoke
#

i think in that file it just refers to how good the weapon is

ancient grail
undone elbow
#

How to update mod data of all items in washer after it finished its work?

magic nymph
bronze yoke
#

yeah, the 'higher quality' weapons are the better weapons that only spawn later

magic nymph
#

By higher quality, do you mean better condition?

bronze yoke
#

no, the file's comments often say 'low quality' or 'high quality', what they're referring to is the type of weapon

#

in your example, the second definition has a machete

magic nymph
#

There's different types of Hand Axes and Meat Cleavers?

#

Ah ok

#

Thanks

craggy geode
#

I have a client side lua script that I wish to add to my local dedicated server. When I upload this script to my server's directory it does not work and I cannot see the script when pressing f11 while in the server. My server side lua script works but where do the client side scripts go?

pine fiber
#

(Maybe it is not the same with a local dedicated server...)

craggy geode
pine fiber
#

I'm not sure what I was saying. It's the folder to use with local mod in a solo game.

#

And I only have a dedicated server based on linux

craggy geode
bronze yoke
#

dedicated servers use that directory too

pine fiber
bronze yoke
#

yeah, just place them in that directory

pine fiber
#

maybe just if you set a non-steam dedicated server no?

#

if I try to overwrite a mod, I can just upload it to this folder and add it to the mod list without going through the steam workshop?

bronze yoke
#

yeah that's all you need to do

pine fiber
#

hmm cool, thank you

#

It will be downloaded by players too like a workshop mod?

bronze yoke
#

honestly i've never used it for anything but local testing, so i don't know

pine fiber
#

see if there is already mods like that on workshop and see how they are made

astral dune
#

From what I understand, you can access the file system from the zomboid lua, but its sandboxed a bit. Do you have access to the scripts folder?

undone elbow
#

item:setDirtyness() doesn't really work. I do item:setDirtyness(50) but it drops to previous value in washer even in singleplayer. Does anybody know how to fix that?

bronze yoke
#

you might need to trigger OnClothingUpdated after setting the dirtiness

#

triggerEvent("OnClothingUpdated", player)

hidden compass
#

Is there any way to check the map status (Visited, Known) on the Lua side?

I found those Setter methods (setVisistedIn~, setKnownIn~) in "zombie.worldMap.WorldMapVisited", but there didn't seem to be a Getter method. And "isCellVisible" or "hasFlags" methods that may be useful are not public.

Any ideas?

astral dune
#

well thats good news, I may be able to salvage my mod concept after all

#

I want to flesh out the engine mechanics, but its going to require me to be able to make vehicle scripts on the fly

#

hopefully new scripts can be loaded at runtime too

drifting ore
#

Yall r nerds

wooden lodge
#

Is there a command or a way

#

To make someone get the flu/cold?

fierce cipher
#

For someone who has 0 experience with lua, how hard would it be to create a simple food mod with craft recipes?

undone crescent
undone elbow
#

How to attach a model to character body part? (it's not an equipped item)

lost fog
#

some 1 who make mod's for project zomboid make zombie child

small topaz
#

Hi! I have two questions:

  1. Is it possible to check whether a specific mod is active?

  2. Given a string, is it possible to find out whether this string denotes a body location?

small topaz
undone elbow
#

attaching any 3d model to any part of the character model

small topaz
undone elbow
small topaz
#

but anyway, I think your trick no. 1) might also work fine for my case

undone elbow
#
  1. e.g.
if getModInfoByID("rasBodyMod") then
small topaz
undone elbow
#

Not sure if it's cleanest. I've just found an answer in the game code)

#

sec

#

BodyLocations may be added by modders.

small topaz
# undone elbow BodyLocations may be added by modders.

this is exactly the pojnt. i am currently working on better compatibility for my body mod with the clothing redux mod (the problems you mentioned in the discussion section). the redux mod adds a new body location and in order to treat it properly, I need to find out whether this mod is active or even better, whether the name it gives to the new body location does indeed refer to a body location....

#

but using this getModInfoByID is definitely one option I can work with

undone elbow
#

"Belt" is your string 🙂

small topaz
undone elbow
#

I've tested it before post)

small topaz
shadow geyser
# hollow current Thanks so much!
if getActivatedMods():contains("CraftHelper41") then

is a better way to do it, since the contains function explicitly returns a true false value. the getModinfoByID probably will technically work, but this way is more explicit

ancient grail
#

whats the difference with getCell():getGridSquare(x, y, z) and getPlayer():getSquare() and getPlayer():getCell()

bronze yoke
#

cells are a 300x300(?) area

ancient grail
hollow current
#
function BatteryJumpstarter_JumpstarterTimedAction:perform() -- Trigger when the action is complete
    local chance = ZombRand(1,100) --Generate a random number between 1 and 100
    local ui = getPlayerMechanicsUI(self.character:getPlayerNum());
    self.item:Use()
    if chance <= 75 then
        ui:startFlashGreen()
        self.part:getInventoryItem():setUsedDelta(0.05)
    else
        ui:startFlashRed()
    end
    ISBaseTimedAction.perform(self);
end```
This script is supposed to change the usedDelta of a battery that is currently installed in a vehicle. Visually, it does change it, but it actually doesn't change. When starting the vehicle or uninstalling the part, it resets back to what it was originally. Any idea what may cause this?
#

p.s.: This is a MP issue. Script works fine in SP

bronze yoke
#

is it a client script?

hollow current
#

the script is in client folder, if that's what you mean

bronze yoke
#

yeah it's only changing it on the client

hollow current
#

so, should I copy and paste the same files and put in server folder?

bronze yoke
#

i'm not sure, i think timed actions are client only

#

you'll need to use sendClientCommand() and have a function on the server that changes the battery usedDelta

hollow current
#

Any specific tutorial on how to set a function up that can be used with sendClientCommand?

bronze yoke
#
local function OnClientCommand(module, command, player, args)
    if module == 'BatteryJumpstarter' and command == 'functionThatChangesTheBattery' then
        functionThatChangesTheBattery()
    end
end
Events.OnClientCommand.Add(OnClientCommand)```
#

if you have multiple you usually want to keep the commands in a table and index them based on the command argument but i think you only need one command

#

and then on the client you just go sendClientCommand('BatteryJumpstarter', 'functionThatChangesTheBattery', {})

hollow current
#

Well, the item being used with the battery gets charged from a generator, which increases its usedDelta and decreases the getFuel of the generator, so I assume I will have to set up client commands for those too, right?

shadow geyser
#

yes, although the generator might already have a command for it or a function for syncing data, so id check for that first

bronze yoke
#

i'm unusure, you should test that, but if that's the case then you just want to go

local Commands = {}

function Commands.Function()
end

function Commands.AnotherFunction()
end

local function OnClientCommand(module, command, player, args)
    if module == 'BatteryJumpstarter' then
        Commands[command]()
    end
end
Events.OnClientCommand.Add(OnClientCommand)```
#

if you start needing arguments it gets a bit more complicated but i don't think you will

hollow current
#

I'll try messing with that, thanks so much, both of you!

#

I assume, since I am adding a client command anyways, it's better to change self.part:getInventoryItem():setUsedDelta(0.05) to the client command, making it work for both sp and mp?

ancient grail
#

anyone knows how acces the whitelist via modding? like to make functions that readd the whitelist of a person droped from the list when he died but after a cooldown

hollow current
# bronze yoke i think so!

One more thing. I am not sure why I am getting an error at the last end here

function Commands.increaseUsedDelta(part)
    part:getInventoryItem():setUsedDelta(0.05)
end

--function Commands.AnotherFunction()
--end

local function OnClientCommand(module, command, player, part)
    if module == 'BatteryJumpstarter' then
        Commands[command]()
    end
end
Events.OnClientCommand.Add(OnClientCommand)```
#

nvm i think i may know why

#

Am I passing the part argument correctly? It doesn't look like I am

function BatteryJumpstarter_JumpstarterTimedAction:perform() -- Trigger when the action is complete
    local chance = ZombRand(1,100) --Generate a random number between 1 and 100
    local ui = getPlayerMechanicsUI(self.character:getPlayerNum());
    self.item:Use()
    if chance <= 75 then
        ui:startFlashGreen()
        sendClientCommand('BatteryJumpstarter', 'increaseUsedDelta', {self.part})
    else
        ui:startFlashRed()
    end
    ISBaseTimedAction.perform(self);
end```

```lua
local Commands = {}

function Commands.increaseUsedDelta(part)
    print(part)
    part:getInventoryItem():setUsedDelta(0.05)
end

local function OnClientCommand(module, command, player, part)
    if module == 'BatteryJumpstarter' then
        Commands[command]()
    end
end
Events.OnClientCommand.Add(OnClientCommand)```
dim hill
#

Hey @nimble spoke could you confirm that Anomalous Rain isn't supported in MP currently?

bronze yoke
#

oh, arguments are passed as a table

#

so in this case, you'd want to use Commandscommand

hollow current
#

hmm no luck, returns part as nil

nimble spoke
bronze yoke
#

i wrote something for night that worked with vehicles, let me check what i did there

hollow current
#

Soo what'd be the best way to approach this

#

oki

bronze yoke
#

i think we sent the vehicle's getId() as the argument and then used getVehicleById() on the server

#

you could send the part's id too but i think you're always changing the battery so it's not necessary

hollow current
#

sth like this?

---timed action function
function name:perform()
  local vehicleId = self.part:getVehicle():getID()
  sendClientCommand('BatteryJumpstarter', 'increaseUsedDelta', {self.vehicleId})
end

--clientCommand
function Commands.increaseUsedDelta(vehicleId)
    local vehicle = vehicleId:getVehicleById()
    local part = vehicle:getPart() ---What's the function to get the Battery Part?
    part:getInventoryItem():setUsedDelta(0.05)
end```?
bronze yoke
#

getPartById('Battery')

#

and i think it's 'getId()' not 'getID()' (they return different values)

hollow current
#

seems like most errors are fixed and the clientCommand is being sent, except that vehicleId is being passed as nil for some reason

--Timed Action
function BatteryJumpstarter_JumpstarterTimedAction:perform() -- Trigger when the action is complete
    local chance = ZombRand(1,100) --Generate a random number between 1 and 100
    local ui = getPlayerMechanicsUI(self.character:getPlayerNum());
    self.item:Use()
    if chance <= 75 then
        ui:startFlashGreen()
        local vehicleId = self.part:getVehicle():getId()
        sendClientCommand('BatteryJumpstarter', 'increaseUsedDelta', {self.vehicleId})
        --self.part:getInventoryItem():setUsedDelta(0.05)
    else
        ui:startFlashRed()
    end
    ISBaseTimedAction.perform(self);
end

--Client Command
local Commands = {}

function Commands.increaseUsedDelta(vehicleId)
    local vehicle = vehicleId:getVehicleById()
    local part = vehicle:getPartById('Battery')
    part:getInventoryItem():setUsedDelta(0.05)
end

--function Commands.AnotherFunction()
--end

local function OnClientCommand(module, command, player, vehicleId)
    if module == 'BatteryJumpstarter' then
        Commands[command](vehicleId[1])
    end
end
Events.OnClientCommand.Add(OnClientCommand)```
#

Rest of locals seem to be defined fine

bronze yoke
#

that's really odd! i can't see a meaningful difference between some of my tested code and yours

hollow current
#

oki prolly found the issue

#

one min

#

alright ye I was being dumb and passing self.vehicleId instead of vehicleId

#

Although now the error is being thrown at local part = vehicle:getPartById('Battery') 🤦‍♂️

bronze yoke
#

what's the error?

hollow current
#
function: OnClientCommand -- file: ClientCommands.lua line # 15 | MOD: Battery Jumpstarter

LOG  : General     , 1664637020755> Object tried to call nil in increaseUsedDelta
LOG  : General     , 1664637020781> creating new sourcewindow:
ERROR: General     , 1664637031683> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: Object tried to call nil in increaseUsedDelta at KahluaUtil.fail line:82.
ERROR: General     , 1664637031683> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: Object tried to call nil in increaseUsedDelta
    at se.krka.kahlua.vm.KahluaUtil.fail(KahluaUtil.java:82)
    at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:973)
    at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:163)
    at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1980)
    at se.krka.kahlua.vm.KahluaThread.pcallvoid(KahluaThread.java:1812)
    at se.krka.kahlua.integration.LuaCaller.pcallvoid(LuaCaller.java:66)
    at se.krka.kahlua.integration.LuaCaller.protectedCallVoid(LuaCaller.java:139)
    at zombie.Lua.Event.trigger(Event.java:64)
    at zombie.Lua.LuaEventManager.triggerEvent(LuaEventManager.java:214)
    at zombie.spnetwork.SinglePlayerServer.receiveClientCommand(SinglePlayerServer.java:229)
    at zombie.spnetwork.SinglePlayerServer.mainLoopDealWithNetData(SinglePlayerServer.java:183)
    at zombie.spnetwork.SinglePlayerServer.update(SinglePlayerServer.java:171)
    at zombie.GameWindow.logic(GameWindow.java:238)
    at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
    at zombie.GameWindow.frameStep(GameWindow.java:764)
    at zombie.GameWindow.run_ez(GameWindow.java:680)
    at zombie.GameWindow.mainThread(GameWindow.java:494)
    at java.base/java.lang.Thread.run(Unknown Source)```
#

tried changing it to lua function Commands.increaseUsedDelta(vehicleId) local vehicle = vehicleId:getVehicleById() print(vehicle) --local part = vehicle:getPartById('Battery') --part:getInventoryItem():setUsedDelta(0.05) end

#

apparently the error is with the local vehicle

#

The function I am using is correct, no?

bronze yoke
#

oh! it should be getVehicleById(vehicleId)

hollow current
#

🤦‍♂️

#

of course

#

Alright, that does fix everything finally

#

I'll just follow the same steps for the other functions

#

I really appreciate the help and time. Thank you so much!

bronze yoke
#

of course ^u^ i'm glad it's working for you now

bronze hornet
#

Hey guys, could someone point me in the right direction of retrieving an up-to-date list of all available Lua functions/methods within the current game's version?

bronze yoke
bronze hornet
bronze yoke
#

that's the one of most interest yes

hollow current
#
function Commands.rechargeJumpstarter(item)
    local currentDelta = item:getUsedDelta()
    item:setUsedDelta(currentDelta+0.2)
end

local function OnClientCommand(module, command, player, args)
    if module == 'BatteryJumpstarter' then
        Commands[command](args[1])
    end
end
Events.OnClientCommand.Add(OnClientCommand)```

```lua
function BatteryJumpstarter_GeneratorTimedAction:perform() -- Trigger when the action is complete
    sendClientCommand('BatteryJumpstarter', 'rechargeJumpstarter', {self.item})
    
    self.sound = self.character:playSound("beep")
    local fuel = self.generator:getFuel()
    self.generator:setFuel(math.floor(fuel+0.5)-1)
    ISBaseTimedAction.perform(self);
end```

Any idea why this doesn't change the UsedDelta of the item?
#

it looks like item is being passed correctly. The command returns print(item) and print(item:getUsedDelta()) correctly

#

but setUsedDelta doesn't seem to be doing anything

bronze yoke
#

have you tested that doing it clientside doesn't work in multiplayer? i think the client is still authoritative over items

hollow current
#

hmm no I haven't, i'll give it a go

bronze yoke
#

otherwise, it's the same problem as the vehicle where you can't pass the object itself (you're essentially creating a clone of its data and sending it to the server, not referencing the same object)

hollow current
#

is there some kind of an "Id" to pass instead for inventory items?

bronze yoke
#

no :( from what i've heard referencing specific instances of items is very difficult, if not impossible?

hollow current
#

Well that'd suck. Let's hope it works clientside in mp

#

Well, that's rather weird. The function that was set up earlier to mess with the car battery, works in SP but not MP

#

Not the same issue, but now it doesn't even change the battery charge, not visually or technically

bronze yoke
#

hmm... perhaps vehicles behave differently on the server

hollow current
#

Would anyone be able to confirm if that's the case?

bronze yoke
#

vehicle:transmitPartUsedDelta​(part)

hollow current
#

I don't think the client command is being executed at all, not even a print function works. Would it have anything to do with file names maybe?

bronze yoke
#

are you using dedicated or co-op?

hollow current
#

dedicated

#

hosted locally tho

bronze yoke
#

if you're using the in-game console to check for the prints, that can be unreliable

#

if it's the server console/log they're not showing up in that is different

hollow current
#

lemme check if it shows in the server console

#

ye shows in server console. function is definitely being executed

bronze yoke
#

the client still runs server code so some prints from there will show up, but OnClientCommand never fires on the client so you wouldn't see those in-game

hollow current
#

By the way, is there some kind of a definitive guide that covers everything/such common issues?

bronze yoke
#

not that i know of, but i'm not familiar with a lot of the community resources

hollow current
#

most if not all guides I have come across are either outdated, not completed, or just not very well put together

bronze yoke
#

i've considered writing my own documentation but i bet it'd just end up outdated and incomplete too

hollow current
#

I bet it won't be that hard to maintain if it was done by a number of modders, rather than each one individually working on his own

hollow current
bronze yoke
#

oh good ^u^

hollow current
#

One more question, I am not sure if its a server issue or a mod issue, but the server sound effect seem to work fine in SP (even though it throws a warning at me that the sound effect was not found, yet it is played anywyas), but not MP. Somehow, different sound effects are not being played in MP server too, like failure to start the engine or exiting/entering the vehicle

bronze yoke
#

unfortunately i don't have any experience with that

hollow current
#

Ah np then, I'll try messing around more with it. Anyways, really appreciate it once again, thanks!

#

And oh, the other issue, attempting to change inventory item used delta via client command, it seems like its not needed

#

it indeed works with normal client functions in MP

bronze yoke
#

at least sometimes things can be simple LOL

hollow current
#

hahaha yea thankfully

mighty wedge
#

anyone know anything ab changing weapon firerates

ancient grail
#

is there a way to print all banned account ?

ancient grail
undone elbow
#

How to detect that main menu is opened while playing?

magic nymph
#

I'm trying to fix a mod and I have a question.

The mod adds a callback to Events.OnDeviceText.

I've checked the function signature and it's correct, but here it is, anyway:

function RadioWavs.OnDeviceText(_interactCodes, _x, _y, _z, _line, _source)

You can double check the signature here: https://pzwiki.net/wiki/Modding:Lua_Events/OnDeviceText

The problem is, the first parameter being sent to the function is always nil.

Anyone know what's going on and how to fix it?

bronze yoke
#

a new parameter was added

#

function RadioWavs.OnDeviceText(_guid, _interactCodes, _x, _y, _z, _line, _source)

magic nymph
#

Thanks, gonna try it out

bronze yoke
#

the wiki is outdated on that one, i was going to update it but you have to like, contribute it to github or something...?

magic nymph
#

It fixed the error, but the mod still doesn't work. 😦

I've seen people use a line-by-line debugger in game, do you know how to bring it up? I figure you have to start the game with -debug, but I don't know where to go from there. EDIT: it's F11 key, but it doesn't display any mod files.

astral dune
#

is it possible to "consume" an event? As in prevent any other event listeners after yours from seeing the event? Is it possible to make sure your listener fires first?

random finch
#

Anyone know how to make sounds heard by players over 10 squares away?

shadow geyser
shadow geyser
errant bluff
#

Is it possible that when you open an object it has X chances of giving you certain objects?
For example a <Bag of unknown seeds>. and when you right-click on the object, you get an Open bag action.

shadow geyser
errant bluff
bronze yoke
#

doesn't expanded helicopter events have something like that?

errant bluff
#

with the boxes?

shadow geyser
errant bluff
hollow current
#

How viable would it be to control the order of an option you added to a context menu?

#

I.e. make it the first/second/last option?

hearty dew
#

Should be able to control to some degree whether it is first or last by performing your manipulation of the context object before or after calling the original implementation that fills out the context menu options

#

Going to depend on order of lua files that are loaded, which you can control too somewhat bc they are loaded alphabetically

hollow current
boreal crow
#

Uh is it possible I can break the default recipes by adding my own?

#

I just logged into my Multiplayer server with my new mod, and I can't seem to open a tin of soup lol

shadow geyser
#

make sure the name of the file you have that is adding recipes, isn't name the same as the files vanilla uses, it might be replacing the file that adds the open tin of soup recipe

hearty dew
boreal crow
#

@shadow geyser Oh I think it is because I used a mod structure to start my mod, and it was called scripts/recipes.txt by default, so I kept it like that lol

#

I just renamed it so let's see, I guess thats the issue

hollow current
# hearty dew I presume you are overriding a function to add to an existing content menu, righ...
ISRenameEverything = {};

require "ISInventoryPaneContextMenu"
ISRenameEverything.createMenu = function(player, context, items)
    local canBeRenamed = nil;

    for i, v in ipairs(items) do
        local item = v;
        
        if not instanceof(v, "InventoryItem") then
            item = v.items[1];
        end
        
        canBeRenamed = item;
    end

    if canBeRenamed then
        context:addOption(getText("ContextMenu_renameButton"), canBeRenamed, ISRenameEverything.onRenameItem, player);
    end
end

This what I am using to add a context option

boreal crow
#

I have a very weird situation, I restart my game after turning off my mod - but it's still there when I reload and continue my save, even though it's disabled in mod loader

hearty dew
#

In what way do you need to control the order then? I misunderstood

hollow current
#

The option is being added to the top of the context menu, can the option be instead moved to the bottom?

astral dune
#

there are events for before the context menu is populated, and after

hearty dew
#

Which context menu, ISInvPaneContextMenu?

hearty dew
hollow current
#

ye, the one that appears when you right click an item in your inventory

astral dune
#

are we adding stuff to the context menu without using the events?

hearty dew
#

So using that event, you can't control it too well. What you could do instead possibly is override the ISInvPaneContextMenu functions to add the context option earlier than the event allows. I'd have to look at the code to see how to do that

#
    triggerEvent("OnPreFillInventoryObjectContextMenu", player, context, items);
#

Can you use that event to insert at top? (if that's what you are looking to do) @hollow current

hollow current
astral dune
#

I wasn't aware that was possible, but I did context menu stuff before I really knew what was going on

shadow geyser
#

if you want to remove a mod from a save, you need to go to the save in the load option from the main menu, then at the bottom there should be a mods option, there you can remove mods

hollow current
ancient grail
hollow current
#

what's the event name for that?

astral dune
#

onpostfillinventory etc

hearty dew
hearty dew
shadow geyser
#

OnFillInventoryObjectContextMenu adds it to the end, but if you have other mods loading afterwards, then they will add their stuff to the end as well

hollow current
#

I will try that, thanks guys!

hollow current
#

oh never mind I think i figured it out

hearty dew
#

nono, just use that string as the event name

#

I copied it from the code that triggers the event in the vanilla source code

#

bc lazy

#

If some other mods are adding entries after yours, you can try renaming your lua file that adds the event handler to zz_myfilename.lua to influence the lua load order (which will affect the order the events are registered)

hollow current
#
ISRenameEverything = {};

require "ISInventoryPaneContextMenu"
ISRenameEverything.createMenu = function(player, context, items)
    local canBeRenamed = nil;

    for i, v in ipairs(items) do
        local item = v;
        
        if not instanceof(v, "InventoryItem") then
            item = v.items[1];
        end
        
        canBeRenamed = item;
    end

    if canBeRenamed then
        context:addOption(getText("ContextMenu_renameButton"), canBeRenamed, ISRenameEverything.onRenameItem, player);
    end
end

ISRenameEverything.onRenameItem = function(item, player)
    local modal = ISTextBox:new(0, 0, 280, 180, getText("ContextMenu_label"), item:getName(), nil, ISRenameEverything.onRenameItemClick, player, getSpecificPlayer(player), item);
    modal:initialise();
    modal:addToUIManager();
end

function ISRenameEverything:onRenameItemClick(button, player, item)
    if button.internal == "OK" then
        if button.parent.entry:getText() and button.parent.entry:getText() ~= "" then
            item:setName(button.parent.entry:getText());
            local pdata = getPlayerData(player:getPlayerNum());
            pdata.playerInventory:refreshBackpacks();
            pdata.lootInventory:refreshBackpacks();
        end
    end
end

Events.OnFillInventoryObjectContextMenu.Add(ISRenameEverything.createMenu);```
#

That's full code

#

I think it should it

ancient grail
#

how do i create a custom table with data and be able to store itpermanently unless j delete the data and how do i delete them

basically i need it to hold specific steamids

shadow geyser
#

store them in the global moddata

hollow current
#

Any idea what could be messing with you not being able to barricade/unbarricade? I have a mod causing the issue. The timed action of barricading/unbarricading happens but nothing actually changes. Items don't get consumed, and it doesn't barricade not does it unbarricade. Not sure what's causing that issue

hearty dew
gilded hawk
#

How can I check if the game is in debugmode?

bronze yoke
#

never used it before, but probably getDebug()

boreal crow
#

What is the easiest way to show some sort of message to the player after completing an action?

gilded hawk
boreal crow
#

Like, let's say I cut up a car hood and get 2 small metal sheets, and 1 metal sheet - how would I say something like
** You gained XSmall Metal Sheets andY Large Metal Sheets

hearty dew
#

over the player's head?

hearty dew
bronze yoke
#

oh yeah, getDebug() is actually a member of core, not globalobject

#

so use isDebugEnabled()

hollow current
# hearty dew What was the issue?

I had named my client commands file the same as the vanilla file, so it was overriding it and causing issue with all client command actions

shadow geyser
hollow current
#

It's like the 3rd time I forget and do the same thing. Thankfully was able to debug it quicker. The first time took me almost half the day to find out why half of the items in game were missing lol

bronze yoke
#

in general, you should avoid generic file names, as even if you don't override vanilla you still might override another mod

hearty dew
#

Mm, I generally follow the pattern of

mymodid_filename.lua```
Or if I need the file to load early or late (to muck with other mods):```
!!_mymodid_filename.lua
zz_mymodid_filename.lua```
bronze yoke
#

i tend to use modname.lua, or modname/file.lua if i have enough files to justify that

ancient grail
#

how do you send a command that deletes the whole file or atleast all the entry once its read?

shadow geyser
#

what are you trying to achieve with this?

weak sierra
#

do getRandomSquareInZone and GetRandomUnseenSquareInZone require the square(s) to be loaded to be picked?

#

cuz both are returning nil squares for me for zones that are potentially not loaded presently

hollow current
shadow geyser
weak sierra
#

ugh

#

im trying to get a square in a zone though, so i dont have coordinates

#

guess i can get X/Y/Width/Height and pick a random spot

#

then load it

boreal crow
#

My mod isn't giving the player items after completing the recipe, it works in SP

#
function MSGTweaks_RecipeCodes.ConvertToMetal(items, player, high)
    local itemValueType = MSGTweaks_RecipeCodes.GetMetalValueType(items)
    local skillPoints = math.floor(player:getPerkLevel(Perks.MetalWelding) + (player:getPerkLevel(Perks.Mechanics) * 0.25))
    local metalPoints = 1

    if (itemValueType == 2) then
        metalPoints = metalPoints + 1
    end

    if (high) then
        metalPoints = metalPoints * 2
    end

    if (skillPoints >= 7) then
        metalPoints = metalPoints + 1
    end

    local smallMetalSheet = 0
    local largeMetalSheet = 0

    for i = 1, math.max(1, metalPoints) do
        local size = ZombRand(0, skillPoints)
        if size >= 5 then
            largeMetalSheet = largeMetalSheet + 1
        else
            smallMetalSheet = smallMetalSheet + 1
        end
    end

    if (smallMetalSheet > 0) then
        player:sendObjectChange('addItemOfType', { type = 'Base.SmallSheetMetal', count = smallMetalSheet })
    end
    if (largeMetalSheet > 0) then
        player:sendObjectChange('addItemOfType', { type = 'Base.SheetMetal', count = largeMetalSheet })
    end
    --log("Item Value Type: " ..tostring(itemValueType).. " points: "..tostring(metalPoints)..", " ..tostring(skillPoints))
end

function MSGTweaks_RecipeCodes.OnCreate.ConvertToMetalLow(items, result, player)
    MSGTweaks_RecipeCodes.ConvertToMetal(items, player, false)
end

function MSGTweaks_RecipeCodes.OnCreate.ConvertToMetalHigh(items, result, player)
    MSGTweaks_RecipeCodes.ConvertToMetal(items, player, true)
end
#

guaranteed to give 1 metal, but it isn't giving anything

#

works in my Singleplayer

hearty dew
#

I don't know what the issue is, but my guess is the player:sendObjectChange calls may be on the wrong client/server side

#

I'd debug it by manually calling those functions to figure out how/where it should be called to get the desired effect

real urchin
#

Hey guys sorry quick question, if I want to edit a vanilla tile with TileZed how should I go about doing that?

Unless i'm reading this wrong: https://theindiestone.com/forums/index.php?/topic/21951-the-one-stop-tilezed-mapping-shop/
that guide is more for creating a new map than editing just a simple tile.

ancient grail
# shadow geyser what are you trying to achieve with this?

basically I need store username and steamids of players that dies
it is compiled on a serverfile
then when it hits friday all of the stored name is read and deleted from the file.
basically this is a mod for a hardcoreserver that babs the player until friday

#
local rawtimestring = tostring(Calendar.getInstance():getTime())
print(rawtimestring) 
if string.find(rawtimestring, "Fri") then 
print("Unbannning IDs")
print("get all ids from table")
print("remove id from table")
end

 
 function BanDeath()
 local addbanid = getSteamIDFromUsername(getPlayer():getUsername())
print(addbanid)
SendCommandToServer(string.format("/banid " .. addbanid))
print("add id to a table")
print("write it on a file")
 end
 
Events.OnPlayerDeath.Add(BanDeath)
#

and this is what i have so far

and a few reference scripts on saving and loading from files

but this is the first time in modding that involves saving and loading from file
and i havent tried doing the k, v or any other functions that get the contents one by one

#

so im really lost i just kept on looking at the references and hoping to be able to make em fit

#

i think it might be possible to to use sandboxvar instead to hold the ids?

ancient grail
weak sierra
#

it's not hard

ancient grail
gilded hawk
bronze yoke
#

oh wow! well done

gilded hawk
bronze yoke
#

every time i saw you talking about it in here i was thinking 'there is no way this will ever work' LOL

gilded hawk
ancient grail
#

im getting nuts with this readfile thing. i should give it a rest i guess and try again tom

ancient grail
#

i got it i think
but this is a client side reference tho

#
function BanDeath.flushEntries()
local rawtimestring = tostring(Calendar.getInstance():getTime())
print(rawtimestring) 
if string.find(rawtimestring, "Fri") then 
print("Unbannning IDs")
SendCommandToServer(string.format("/unbanid " .. addbanid))
print("remove id from table")
end

 
 function BanDeath()
 local addbanid = getSteamIDFromUsername(getPlayer():getUsername())
print(addbanid)
BanDeath.writeSaveFile();
SendCommandToServer(string.format("/banid " .. addbanid))
 end
 
Events.OnPlayerDeath.Add(BanDeath)

--WIP way to delete the entries 

function BanDeath.readSavedDeathFile()
    local retVal = {};
    
    local saveFile = getFileReader(BanDeath.savefile, true);
    local BanList = 0
    local line = saveFile:readLine();
    while line ~= nil do
        if luautils.stringStarts(line, "BanList=") then
            BanList = tonumber(string.split(line, "=")[2])
        elseif BanList == ENTRY_BanList then
            local s = luautils.split(line, ":");
            retVal[s[1]] = s[2];
        end
        line = saveFile:readLine();
    end
    saveFile:close();
    
    return retVal;
end

function BanDeath.writeSaveFile(options)
    local account = getFileWriter(BanDeath.savefile, true, false); -- overwrite
    account:write("BanList="..tostring(ENTRY_BanList).."\n")
    for key,val in pairs(options) do
        account:write(key..":"..val.."\n");
    end
    account:close();
end

pine fiber
signal frost
#

If I have a UI panel listening to an event, should I manually unsubscribe from that even when I close the ui?
I'm looking at the way the trade panel works as an example, and it doesn't appear that IS are doing it, so I'm assuming it's all good

mystic meteor
#

I'm looking to change some stats on guns via lua instead of overwriting them via the script files. I'm using ItemTweaker for it, but it seems to only be editing fresh items, not pre-spawned ones. How can I make sure the existing items get affected too?

#

if anyone has suggestions, please ping me - I might miss it otherwise

signal frost
# mystic meteor Digging into the code, ItemTweaker doesn't do anything special, and I thought it...

I'm pretty sure once an item is spawned in, it's stats are stored somewhere. Items don't look up their stats once they've been created, they just are. Evidence for this is that you can alter the weight/damage/whatever via the 'Edit Item' option in debug/admin mode and that specific instance of that item will have the altered stats, but others of it's kind will not. I imagine Item Tweaker alters the 'template' that new items copy when created by the factory, but does not loop through every item in existence and retroactively change them, and if it did that would probably cause a lot of issues. @mystic meteor

ancient grail
vast nacelle
shadow geyser
shadow geyser
shadow geyser
# mystic meteor if anyone has suggestions, please ping me - I might miss it otherwise

easiest way, would be to have a table storing the modifications somewhere, then using a OnEquipPrimary function, to modify the stats whenever the player equips it. this ensures that the weapon will have the correct stats whenever the player tries to use it. Then if you want you can also run the changes on equipped items, whenever you modify the stats in general, which will then ensure that cornercase is covered.

ancient grail
timber yew
#

Hey guys, i have a suggestion for a useful mod; how about multitool in PZ? A rare complex tool, that can act like a knife, can opener, screwdriver and mb something more. It should be really rare, bc it makes things way more easy imo.

ancient grail
#
-- for testing
function BanDeath.KillMe()
getPlayer():setGodMod(false);
getPlayer():getBodyDamage():setOverallBodyHealth(0)
print(getPlayer():getUsername() .. " Commited Suicide")        
end
--writes ban data
function BanDeath.DoBan()
--BanDeath.writeSaveFile();
local banlist = ModData.getOrCreate("banned");
local banDataName = getPlayer():getUsername();
local banDataId = getSteamIDFromUsername(getPlayer():getUsername());
table.insert(banlist, banDataName, banDataId)
-- for k,v  in banlist do
SendCommandToServer(string.format("/banid " .. banDataId))
print"BanDeath:writes " .. banDataName .. banDataId )
end

-- triggers every friday IRL
function BanDeath.CheckBan()
local rawtimestring = tostring(Calendar.getInstance():getTime())
print(rawtimestring) 
if string.find(rawtimestring, "Fri") then 
BanDeath.UnBan()
end
end
--read ban data
function BanDeath.UnBan()
local banlist = ModData.getOrCreate("banned");
local banDataName = getPlayer():getUsername();
local banDataId = getSteamIDFromUsername(getPlayer():getUsername());
table.insert(banlist, banDataName, banDataId)
for k,v  in banlist do
SendCommandToServer(string.format("/unbanid " .. banDataId))
print"BanDeath:reads " .. banDataName .. banDataId )
BanDeath.FlushBan()
end

function BanDeath.FlushBan()
--deletes ban data
banlist = {}
end

Events.OnPlayerDeath.Add(BanDeath.DoBan)
Events.OnGameBoot.Add(BanDeath.CheckBan)
Events.OnLoginState.Add(BanDeath.CheckBan)
Events.EveryDays.Add(BanDeath.CheckBan)

i havent tested i really hope i nailed it!
thanking xyberviri and Robot ex140 for the help

boreal crow
#

At least according to this error, it's client-side

weak sierra
bronze yoke
weak sierra
#

those folders have caused so much confusion

#

i wish they didn't exist

#

xD

boreal crow
#

Yeah, I assumed because it is in a server folder, the server is executing it

weak sierra
#

and yet somehow some things work in shared but not client, etc.

#

because of loading order

#

so it really can throw people

boreal crow
#

I got it working now, but damn was that weird to debug

#

It worked in SP with

player:sendObjectChange('addItemOfType', { type = 'Base.SheetMetal', count = largeMetalSheet })```
#

but obviously SP runs that code server side

#

and not the case for MP

weak sierra
#

what does that do

#

add somethin to container?

boreal crow
#

adds an item, with a specific amount of those items

#

I changed it to:

weak sierra
#

there's already a built-in command for that u know

#

AddItems("Base.SheetMetal", 2)

boreal crow
#
--- Add Items to the Character Inventory
function addItemsToPlayer(player, itemName, itemCount)
    log("Adding Item: ".. itemName .." x"..tostring(itemCount))
    player:getInventory():AddItems(itemName, itemCount)
    --for count = 1, amount do
    --    player:getInventory():AddItem(item)
    --end
end

function MSGTweaks_RecipeCodes.ConvertToMetal(items, player, high)
    if isServer() then
        log("Called Server Side -> ConvertToMetal")
    end
    local itemValueType = MSGTweaks_RecipeCodes.GetMetalValueType(items)
    local skillPoints = math.floor(player:getPerkLevel(Perks.MetalWelding) + (player:getPerkLevel(Perks.Mechanics) * 0.25))
    local metalPoints = 1

    if (itemValueType == 2) then
        metalPoints = metalPoints + 1
    end

    if (high) then
        metalPoints = metalPoints * 2
    end

    if (skillPoints >= 7) then
        metalPoints = metalPoints + 1
    end

    local smallMetalSheet = 0
    local largeMetalSheet = 0

    for i = 1, math.max(1, metalPoints) do
        local size = ZombRand(0, skillPoints)
        if size >= 5 then
            largeMetalSheet = largeMetalSheet + 1
        else
            smallMetalSheet = smallMetalSheet + 1
        end
    end

    if (smallMetalSheet > 0) then
        addItemsToPlayer(player, "SmallSheetMetal", smallMetalSheet)
    end
    if (largeMetalSheet > 0) then
        addItemsToPlayer(player, "SheetMetal", largeMetalSheet)
        --player:sendObjectChange('addItemOfType', { type = 'Base.SheetMetal', count = largeMetalSheet })
    end
    --log("Item Value Type: " ..tostring(itemValueType).. " points: "..tostring(metalPoints)..", " ..tostring(skillPoints))
end
boreal crow
weak sierra
#

ah

#

it's a wrapper

#

with random

#

yeah

#

u can run that on the client - that's how recipecode works

#

the only thing stopping users from cheating is the lua checksum/etc.

bronze yoke
#

for the time being items are controlled by the client, so you don't need to worry about doing it on the server

weak sierra
#

a few things have to run on the server, like vehicle spawn-in

boreal crow
#

and vehicle mechanics is also server side

weak sierra
#

yeah most vehicle things

boreal crow
#
if numParts > 0 then
            player:sendObjectChange('addItemOfType', { type = 'Base.EngineParts', count = numParts })
        end```
#

this is the default code for taking engine parts

#

so I referenced that for my recipe, assuming it was serverside too lol

weak sierra
#

understandable mistake

#

i made similar mistakes when i started

boreal crow
#

Oh well it works now, so thankfully no more issues 🤞

weak sierra
#

assuming X when not X because i looked in the wrong spots

#

is very common

boreal crow
#

Just hopefully not too many people sub'd to my mod before I fixed it lol

weak sierra
#

O_o

#

always good to test on MP before releasing

#

unless ur very sure

bronze yoke
#

me, clueless: 'there's no way this mod wouldn't work in mp! i don't need to test it!'

boreal crow
#

Well it worked perfectly in SP, so I was like OK add to Steam and test on my friends MP, and then yeah - received 0 items

weak sierra
#

for that kind of testing i release unlisted and test it with that

boreal crow
#

I had no reason to think adding the item would suddenly break on an MP haha, but next time I will test no matter what lol

weak sierra
#

then make it public

#

when it works

boreal crow
#

Oh that's a good idea

weak sierra
#

it will make it less noticed if u keep it unlisted for long tho

boreal crow
#

I have 45 subscribers already, to a broken mod (now fixed)

bronze yoke
#

yeah if i've had a mod unlisted for ages for testing i just reupload it for the actual release

weak sierra
#

cut OR weld it into metal plates?

#

oh

boreal crow
#

cut is level 8 metal working

weak sierra
#

i guess u mean cut with a torch'

boreal crow
#

Yeah lol

weak sierra
#

for weld

#

yeah

boreal crow
#

cut with torch (weld, because easier) is lv. 4 metalwelding

#

and cut with saw is lv. 8

#

🤷‍♂️

weak sierra
#

wish there were Recipe.GetItemTypes entries for car parts so that all car mods that add custom parts would already be set up in them

#

i use a mod that adds a similar feature to car parts for breakdown

#

on my serv

boreal crow
#

Yeah that would be nice, I wish some of the item data in this game was easier to parse

#
function MSGTweaks_RecipeCodes.GetItemTypes.EyeProtection(scriptItems)
    addExistingItemType(scriptItems, "Glasses_SafetyGoggles")
    addExistingItemType(scriptItems, "Glasses_SkiGoggles")
    addExistingItemType(scriptItems, "Glasses_SwimmingGoggles")
    scriptItems:addAll(getScriptManager():getItemsTag("WeldingMask"))
end
--[MSGTweaks_RecipeCodes.GetItemTypes.ConvertsToMetal]
function MSGTweaks_RecipeCodes.GetItemTypes.ConvertsToMetalLow(scriptItems)
    --- Trunk Lid
    addExistingItemType(scriptItems, "TrunkDoor1") -- Standard
    addExistingItemType(scriptItems, "TrunkDoor2") -- Heavy
    addExistingItemType(scriptItems, "TrunkDoor3") -- Sports

    --- Car Doors
    addExistingItemType(scriptItems, "FrontCarDoor1") -- Standard
    addExistingItemType(scriptItems, "FrontCarDoor2") -- Heavy
    addExistingItemType(scriptItems, "FrontCarDoor3") -- Sports

    addExistingItemType(scriptItems, "RearCarDoor1") -- Standard
    addExistingItemType(scriptItems, "RearCarDoor2") -- Heavy
    addExistingItemType(scriptItems, "RearCarDoor3") -- Sports
end

function MSGTweaks_RecipeCodes.GetItemTypes.ConvertsToMetalHigh(scriptItems)
    --- Van Style Doors
    addExistingItemType(scriptItems, "RearCarDoorDouble1") -- Standard
    addExistingItemType(scriptItems, "RearCarDoorDouble2") -- Heavy
    addExistingItemType(scriptItems, "RearCarDoorDouble3") -- Sports

    --- Hood
    addExistingItemType(scriptItems, "EngineDoor1") -- Standard
    addExistingItemType(scriptItems, "EngineDoor2") -- Heavy
    addExistingItemType(scriptItems, "EngineDoor3") -- Sports
end
#

for my mod, sports/standard are treated equally, but heavy duty gives more metal - so I did this weird check:

function MSGTweaks_RecipeCodes.GetMetalValueType(items)
    for i=0,items:size() - 1 do
        local item = items:get(i):getType()
        --log(" + " .. tostring(item))
        if string.match(tostring(item), "Door") and tonumber(string.sub(tostring(item), -1)) ~= nil then
            return tonumber(string.sub(tostring(item), -1))
        end
    end
    return 1
end```
#

if it returns 2 then it's a heavy duty vehicle part lol

weak sierra
#

since it's only two types u could have just made it be "IsHeavyDutyPart" and return true or false

#

<_<

#

is there really no field for this?

boreal crow
#

Yeah, I just made it integer based because I was going to seperate them into categories, but I wanted to keep it more simple after talking

#

I couldn't find it, they're all just called Car Hood

#

and such

weak sierra
#

rename them -> profit

#

lol

boreal crow
#

Is there a double door for sports btw, or is that a placeholder lol

#

can't think of a sports car that would have double rear doors lol

weak sierra
#

i.. don't think so?

#

but mods could potentially use

boreal crow
#

I shoved it in anyway

weak sierra
#

afaik only heavy has the double doors in use

boreal crow
#

I think you're right yeah

#

Also I deleted my original mod and lost my DALLE image sad

#

Really nice to make interesting mod preview images

sterile abyss
#

How do i get a player name?

gilded hawk
gilded hawk
weak sierra
#

can use it to make tiles and textures too :p

#

but instead i wasted all my starter credits making a cow programming at a computer

#

oh well :)

sterile abyss
#

What's the code for teleporting a player?

gilded hawk
#

I'm having an issue with CanBeEquipped I made a new item, but I can't equip it for some reason 😦

item Bag_TransmogBag
    {
        DisplayCategory = Bag,
        Type = Container,
        DisplayName = Transmog Outfits Bag,
        ClothingItem = Belt,
        CanBeEquipped = TransmogBag,
        WeightReduction    =    100,
        Weight    =    0,
        Capacity    =    0,
        Icon    =    Duffelbag,
        OpenSound   =   OpenBag,
        CloseSound   =   CloseBag,
        PutInSound   =   PutItemInBag,
        RunSpeedModifier = 0.95,
        CanHaveHoles = false,
        ReplaceInSecondHand = Bag_DuffelBag_LHand holdingbagleft,
        ReplaceInPrimaryHand = Bag_DuffelBag_RHand holdingbagright,
        WorldStaticModel = DuffelBag_Ground,
        SoundParameter = EquippedBaggageContainer DuffleBag,
    }
local group = BodyLocations.getGroup("Human")
group:getOrCreateLocation("TransmogBag")

Why can't I equip it 😦

boreal crow
weak sierra
#

so did i, i literally used 49 of them making this

#

the first bunch were exploratory to understand the platform

#

but some 40 were def all this..

#

used my last credit to attempt to generate a fuel tank sprite but didn't know it was the last one

#

result was not good enough

thorn cipher
#

what does 'rolls' mean ?

weak sierra
#

it rolls the dice for the item multiple times

quasi geode
# thorn cipher

each entry in the items table has <rolls> chances to spawn.

weak sierra
#

you can also increase this for just one item by entering it in the list multiple times

#

though that can result in multiple spawning

#

where rolls cannot afaik

quasi geode
#

rolls can spawn mutliple times last i checked

thorn cipher
#

Thanks! How would i guarantee an item appears but just once?

#

Rolls = 1

quasi geode
#

ya

thorn cipher
#

And 100 for each item?

weak sierra
#

if u want it to always spawn definitely

#

then yeah

thorn cipher
#

Gotcha

#

Thank you both 🙂

elfin stump
#

Anyone know of an event that triggers the first time someone opens a container? - I am not looking for OnFillContainer - that triggers the first time someone sees the container.

mystic meteor
#

huh. I just got a timeout, I think for mentioning five people in one message. Bah.

mystic meteor
#

huh. Where's the list of all the events? I thought they were in the lua files somewhere, but apparently I'm wrong.

vast nacelle
mystic meteor
#

Good enough start, thanks.

mystic meteor
#

found it, it's in the java. zombie/Lua/LuaEventManger.java

gilded hawk
#

How can I check if the mod is running on a server instead of a client? 🤔

bronze yoke
#

isServer()

gilded hawk
bronze yoke
#

more specifically:

gilded hawk
#

Is there a way to make a delayed call? 🤔
Like calling a function after X second? 🤔

steel delta
#

I've been making really good progress on my vaccine mod, I do need to save the state of the players immunity level, is there any way for mods to save data when the game is closed, so it can be retrieved after loading the same save?

bronze yoke
shadow geyser
shadow geyser
gilded hawk
#

I need to make a delayed call, so that the main mod I have can check if the optional mod is preset, and if it is present then it has to do a different thing

shadow geyser
steel delta
#

IsoPlayer moddata, what function would I need to call to add data there?

bronze yoke
#

can't you just use getActivatedMods():contains()?

gilded hawk
#

The issue is the optional mod requires the main mod so it will be loaded after main one, and by the time the main one as been loaded the code would have run

shadow geyser
#

no it should be fine

bronze yoke
shadow geyser
#

the getActivatedMods():contains() checks which modid's are active for that save, so it doesn't need to be loaded already

steel delta
#

amazing @bronze yoke - That's exactly what I need.

bronze yoke
gilded hawk
#

Would OnGameBoot work on server too? 🤔

bronze yoke
#

the require would be kind of weird actually don't do that

bronze yoke
gilded hawk
#

Alright, I'll give it a look, thanks mate

steel delta
#

Is there any onHour, onDay, events, or should I just use the OnTick event. I only want my function to trigger either each hour or each day since OnTick would be overkill.

Is there anywhere I can go or any function I can call to get a list of all Events available to mods for the game?

bronze yoke
#

EveryHours and EveryDays

steel delta
#

awesome, thanks so much

reef pagoda
#

So you know how zombies have a small chance to resurrect if left to rot?

Is it possible to have the zombie act differently when it does? For example, have it become a sprinter?

summer rune
#

if i want to replace a function of a vanilla lua file Fishing/BuildingObjects/FishingNet.lua do i have to recreate the same folder structure or can i simply put it in lua/server/patches/FishingNetPatch.lua and import the function and replace it?

shadow geyser
#

kind of depends. if the file is using some local tables, you need to replace the file entirely. if not, and you only want to replace some function, you can just replace the function. there are some other cornercases too though. like for example, if the function you are replacing is being put into a event handler, you need to manually remove the old one and add in the new one. replacing the function doesn't work

#

UI also is like that

glacial flicker
#

Is anyone currently working on a mod that changes the behavior of zombies to "swim"?

slender cedar
#

Can I suggest a mod here?

#

I think having like aristocratic outfits from colonial times and also having muskets and powder weaponry would be pretty cool

drifting ore
#

does anyone have a good modpact for single player?

weak sierra
#

easy way out is to prefix the mod that must come first with something like 0_, and prefix the one that must come later with something like Z_

#

mind the path does matter, so folders and such change things alphabetically

#

if you can't choose the name of the stuff in one of the mods

#

then u can do something like

#

ModName = ModName or {}

#

on both

#

and store stuff in there to call in the one that runs later

#

cause it to execute via an event to ensure it runs after everything loads if u dont wanna mess with names

hearty dew
#

On coop-host, does the server and client lua code run in the same environment? Or separated (separated variables, etc)?

shadow geyser
hearty dew
weak sierra
#

yeah if i had known about those features when i wrote my stuff i might have gone about things that way

#

but u dont always have a choice when patching others' mods

#

so it's important to know the other things you can do

hearty dew
#

Mm, if you need funny business to load before or after another mod loads its lua files, pz loads the lua files in alphabetical order, so you can rename your files accordingly

#

Can then override functions, muck with metatables, all kinds of goodness

carmine lintel
#

Need mod suggestions just got the game

mystic meteor
mystic meteor
#

@weak sierra So I'm looking through my options, and I haven't been able to find the event you suggested, for when an inventory container is opened. What would that event be?

weak sierra
#

did i suggest one?

#

i don't remember

shadow geyser
#

if you are still looking for an event for opening containers, there isn't one

mystic meteor
weak sierra
#

on player load-in

#

oh

#

yeah

#

eggon does it for trunks

#

poke around this, might only be trunks that can do it idk

#

i think it hooks the UI

#

for container switching in the right pane

mystic meteor
#

yeah, I'm digging through both the java and lua to find where it'd be. I'll update here if I find a good one. At the moment my best thought is actually to use neither and instead hijack the code for OnPreFillInventoryObjectContextMenu

weak sierra
#

not an event

#

but

#

u know

mystic meteor
#

that way whenever they right click on an item it would check that item

weak sierra
#

nothing makes them right click it to go into it

#

so that isn't a good solution

shadow geyser
#

thats actually a great idea

weak sierra
#

u can use an item

#

double-left click

#

drag

#

etc

shadow geyser
#

the stats only matter when the player is looking at them, so the context menu one would work

mystic meteor
#

Nah, but this is meant for hot-adds - and telling them "right click to update your guns" is at least a good option

shadow geyser
#

but you should still use the OnequipPrimary or the secondary one as well

weak sierra
#

why not just hook the function that populates the inventory and throttle your code?

#

then they dont have to do anything

mystic meteor
#

How would I go about hooking it? That is the best choice, but I don't want to overwrite game files and at the moment I only know how to hook events.

weak sierra
#

function Whatever.TheOriginal:Is()

#

--do stuff

#

original(self)

#

end

mystic meteor
#

(I'm also running into the situation that I'm not seeing a great way to blindly edit arbitrary values the same way that can be done on prototypes)

#

but that's likely just me not understanding the interactions between Lua and Java

weak sierra
#

look at the code for the admin/debug item editor screen

#

shud tell u how to go about that

mystic meteor
#

Hm. Good thought.

#

it'd be nice if I could just DoParam on existing items, but that doesn't seem to work...

#

and gotcha re: hooking. So it's easy to override with a copy of the original

shadow geyser
mystic meteor
#

yeah, that's the realm I was poking. had some trouble being sure I was working on the right stuff.

#

It was erroring in that for loop because something was nil

mystic meteor
shadow geyser
#

I just want to say, I really think that just having 2 functions, one in the OnPrimaryEquip event, and one on the OnPreFillContextMenu is a much cleaner solution. OnPrimaryEquip will make sure the stats are correct in any case when the player is trying to use it. and OnPreFillContextMenu will cover all instances when a player is trying to examine a item, so the stats are correct in the tooltip and such.

mystic meteor
#

Yeah. It's probably the cleanest, I'm just really hoping to get ones that don't require equips. I also just realized that I need to flag an item as fixed, so that it doesn't screw up things after an attachment has been added.

shadow geyser
#

hooking into a function is nice, but can be easily overwritten by other mods. ofc if everyone did things properly, and also used hooks it would be fine, but many people do not write mods well, and will just overwrite it

mystic meteor
#

yeah.

#

that's another great argument for using events, frankly

#

if only there was an event for items switching between containers...

shadow geyser
#

even if there was, I don't think you would need it. the other 2 events already cover any player facing points where the stats would need to be correct

mystic meteor
#

well, prefill is only for right clicks. The hover menu would be a better event, but I'm not sure if that's got an event - or at least, not what that event is

shadow geyser
#

like, it doesn't matter if the stats are technically "wrong" while being moved from one container to another, as long as when you are trying to use the weapon it is correct

mystic meteor
#

yeah

shadow geyser
#

oh i see thats a good point

mystic meteor
#

and, worst case, I'll fall back to equipping

#

or hell, slap a custom right-click option for "refresh stats" on it

#

have it fire off with a screwdriver in inventory, remove all the modifications, update stats, re-add attachments

weak sierra
#

in the load order

shadow geyser
#

you can, but then you need to fix it every time another mod comes around

#

much easier to avoid hooking when you can

mystic meteor
#

yeah, it's not a great solution since it's relatively fragile

#

I wonder how viable it is to add custom events from the lua...

shadow geyser
#

take a peek at ISInventoryPane:update() and ISInventoryPane:updateTooltip()

mystic meteor
#

MoriThumbsUpHat thanks

shadow geyser
#

you might be able to hook onto those. although I think they might get executed every tick, so there might be a better function to hook onto somewhere nearby

mystic meteor
#

Probably, yeah. I want this performant. And the more I think about it, the more I think a custom right click option when you have some required tools in hand would be the better option.

#

it's manual, but it gives a performant way to update live saves that also doesn't run into issues with attachments

shadow geyser
#

well, id try the hook, and check if there is any performance issue. you are only checking the item, and you can just a flag short circuit any repeat calls.

mystic meteor
#

how would I store that though?

weak sierra
#

they have to know how to set up their mods

#

or they can come ask about it

shadow geyser
mystic meteor
#

that's a pretty limited way to look at it, server owners and end users are stupid and you want to avoid things thy can break

weak sierra
#

i hook all over my mods and i have never had one complaint

shadow geyser
#

then you are very lucky

weak sierra
#

maybe

mystic meteor
#

probably also not hooking things that are liable to be overwritten

weak sierra
#

it'd have to be popular spots to overwrite

#

eyah

#

tbh if a mod overwrites things it's written poorly

#

if i see that i usually tell them to change their approach

mystic meteor
#

whereas "the code that populates the inventory" is a pretty hot zone

shadow geyser
weak sierra
#

moddata on InventoryItems and vehicles is not persisted, but other moddata is, to be clear

mystic meteor
#

hm. A viable solution then. Still, I have to worry about items with attachments, since the game is just updating their base stats separately

#

can you give me a reference for moddata and how to use it?

weak sierra
#

can programmatically remove the attachments, update stats, then reattach them

#

or just count up the stat changes and add them to ur application

mystic meteor
#

yeah, that's my thought. Part of why I think it being a manual fix is a good idea.

weak sierra
#

i've considered making a mod to do the thing ur talking about for a bit

#

but it's low priority for me

mystic meteor
#

Let me know if you do. I'd hoped ItemTweaker was the solution I needed but it turns out it only works on prototypes.

shadow geyser
mystic meteor
#

Sick, that's hella simple

shadow geyser
#

then you can just manipulate moddata as a normal lua table

weak sierra
#

item:getModData()["thing"] = stuff

mystic meteor
#

AoiHands the worst part of my digging around is that there's so many events for inventory manipulation and none of them do what I want

shadow geyser
#

actually yeah, make sure you are putting yourstuff into your own index in the moddata, incase some other mod is also doing stuff with the moddata

mystic meteor
#

Yeah, the usual code cleanliness, even if it's just variable prefixes

weak sierra
#

im cranky cuz i've been working on vehicle respawn mod all day

#

if u think inventory manipulation is a headache

mystic meteor
weak sierra
#

hehe

#

it's nearing done tho

#

almost..

mystic meteor
#

I hear that. I've got like.... six different java AND lua files open right now, and that's only after closing ones I didn't think were helpful. And the java is in Eclipse because it got hefty enough that I needed cross-file references

#

I can only thank my past self for getting good at file manip for figuring out where keywords are to have made this slightly less of a pain

#

checking - ISUpgradeWeapon = ISBaseTimedAction:derive("ISUpgradeWeapon"); is this creating a new timed action here? And then they override the needed functions?

#

I'm used to inheriting, so I assume this is the logical reverse of that

#

Nevermind, it seems that's setting up the code for removing items, and then the actual context menu information is elsewhere

#

oh, gross! The upgrades are all hard-coded for each one!

glacial flicker
#

Is there a "simple" way to make zombies walk on water?

mystic meteor
#

Right... getting some good research done on this, at the very least I know how to access the part data that I need, even if certain things are going to need to be a hard-coded if-tree in the lua, I could probably implement a custom version of ItemTweaker that worked on generated objects too.

shadow geyser