Does it require changing up something in different parts of the game files, or am I just missing some flag from my script file? Ngl it's my first time ever actually trying to do something like that so I just went and edited my local "clothing_bags" script file. I did manage to successfully add the item, give it a texture, make it a container but I can't figure out for the love of god how to make it wearable on other parts of the character than the back. I tried CanBeEquipped = Neck, but then I wouldn't get any equip actions in the context menu, tried it with a Clothing = True but that didn't do anything, but when I changed it back to CanBeEquipped = Back it does work as intended so I suppose I'm missing something silly 
#mod_development
1 messages · Page 229 of 1
ooh thanks ill look into that
I have no idea I'm not familiar enough with clothing mods
Okay, thank you anyways 
np
can't share with others thats probably why i couldn't put
never used before but ill now ty
Once you get the hang of it it's not too hard
Use Github Desktop and you can link your mods to it to easily have a follow of all the changes you make on your mods
Here's how I do it for example:
https://github.com/SirDoggyJvla/Susceptible-Overhaul/tree/main

btw will it work if folder is private or it must be a public
Good question
I can test that out
what settings should I use to export my clothing into fbx?
You need 2 clothing items to swap between them to equip and get that context menu.
bruhhh
wuut
How did you put a png in there ?
lmao there's no way your account got insta suspended
after that
how long ?
bruh
some vanilla systems (especially lua) aren't ready until OnGameBoot fires, and it leaves room for other mods to mess with your code (e.g. variables for settings) before it actually runs; it also means you can have some confidence that your code will run after *most* modded code when that's useful
OnGameBoot fires every time lua is reloaded, so you don't need to restart the game to trigger it
Hi all, hopefully a quick question, how possible is it to add custom attributes to items, like would I be able to add a value such as quality or chance of breaking that can be set on item crafting/creation, and on a similar note would values similar to a frozen value/bar but for a custom attribute instead, or is this not possible within the lua
you can add any arbitrary value to an item's script, any attribute the game doesn't recognise will be added to the item's default moddata
Didn't knew that, good to know
-- in the item script
item MyItem {
myCustomValue = 5,
}
-- accessing it in lua
item:getModData().myCustomValue
you can add these to existing items with DoParam but this doesn't work great because only newly spawning items will have the default moddata added
But if you do it via script files every items get updated ?
no
old items will never have their moddata changed by this, it's not 'default' if it overrides existing items
would it be possible to display these custom values on the item tooltip?
Most likely yeah
it is possible, not nearly as simple though 😅 you can hook into tooltip drawing code and add your own stuff there
by the way, if the value isn't something that can change per instance of the item, it's a bit wasteful to do this as it'll store the value separately for every single instance - it's a lot cheaper to just have a table in lua storing the values per item type:```lua
local myValues = {
["MyModule.MyItem"] = 5,
["MyModule.MyOtherItem"] = 10,
}
myValues[item:getFullType()]
no idea what you're actually trying to do with this so i don't know which one is better for your case
it was per instance, had two things in mind, one was chance something would break when used, the other was a system similar to pickle items individually in a large container, so would make an item “pickled” when submerged long enough, and to have a longer spoil time while it remains pickled, but shorter if it is removed
might not do the second one, just something I was thinking about
thanks for the help though, it’s something to get me started
thanks for the clarification 😄
So I need to equip another necklace first, to then get the equip option in the context menu for the item I'm trying to add?
Assuming the CanBeEquipped = Neck part is correct, that is
Also hi Elyon 
It's better to see how other mods have done it, it's easier. Look at Brita's Armor or AuthZ
Actually
big brain idea
not sure why I haven't thought of that 
And why you need a necklace with a container
why not haha
Also make like a keyring visible you know would be amazing 👀
i have a question
how hard it's to make a lua file, that Reads all clothing made from such material, and makes a repair recipe
Example: Leather jackets
So any leather jacket will appear in this recipe and can be fixed. it's possible?
Perhaps check the rip clothing craft ?
but how i will do to repair the clothing especific?
Aaah you want a crafting recipe that fixes holes in clothing ?
Yes, I want a recipe to repair the complete outfit if it has any materials. So people don't have to repair hole by hole
This involves my mod, that if the person stays close to the sewing table they can do this
hmm
Interesting
Well you need to trigger a custom function that checks for the clothing within the player inventory (select a specific clothing or do it for every clothing) and then find how to repair holes in clothing
hey folks, how can I override a vanilla recipe? I copied over the Refill Propane Torch recipe and added Override:true, but it is not replacing the original, it creates a duplicate in the menu.
Refill Blow torch*
i asked this earlier today and was given a lead but it didnt pan out. Does anyone know if you can make an item, in this case a Wooden Sewing Needle to break after a certain ammount of uses? or just break randoming when using it?
if you search the discord you might find a way to remove a vanilla recipe with lua. you can remvoe the original recipe then just add your own
Alright, I have spent like 40+ hours trying to spawn a tree... Like, I can "make" a tree with brush tool by selecting the trunk and leaves, but its not a proper tree... The leaves are supposed to be "attached" to the main sprite, and some internal data is set to track the season/etc.
I have dug through the java.. extensively. This system is extremely complex (yet kind of simple at the same time) and I think I have an idea of how all the pieces work together:
ErosionMain, ErosionChunk, NatureTrees, ErosionData.
I have gone so far as setup a build environment, make java mods, add a new lua function, and try to manually call into the appropriate functions to get the game to "plant a tree" properly (like I say make a dogwood here, growth stage 4) and it puts the trunk and appropriate leaves on.. but I just can not figure it out..
My current lua:
function createTree(square, type)
if isClient() then
local x, y, z = square:getX(), square:getY(), square:getZ()
sendClientCommand("WL_Utils", "createTree", {x, y, z, type})
return
end
if not square then return end
local tree = IsoTree.new(square, type)
tree:initTree()
square:transmitAddObjectToSquare(tree, square:getObjects():size())
forceSquareUpdate(square)
end
if isServer() then
Events.OnClientCommand.Add(function(module, command, player, args)
if module == "WL_Utils" then
if command == "createTree" then
local square = getCell():getGridSquare(args[1], args[2], args[3])
createTree(square, args[4])
end
end
end)
end
--- Assume called with
createTree(getPlayer():getSquare(), "e_dogwood_1_3")
And the java mod:
public class GravyLua {
@LuaMethod(
name = "forceSquareUpdate",
global = true
)
public static void forceSquareUpdate(IsoGridSquare gs) throws Throwable {
ErosionMain em = ErosionMain.getInstance();
if (gs != null && gs.chunk != null && gs.getZ() == 0) {
IsoChunk ch = gs.getChunk();
Chunk chMd = ch.getErosionData();
ErosionData.Square gsEd = gs.getErosionData();
ErosionWorld world = getWorld(em);
world.validateSpawn(gs, gsEd, chMd);
world.update(gs, gsEd, chMd, getETicks(em));
}
}
private static ErosionWorld getWorld(ErosionMain em) throws Throwable {
Class<ErosionMain> cls = ErosionMain.class;
Field fld = cls.getDeclaredField("World");
fld.setAccessible(true);
return (ErosionWorld)fld.get(em);
}
private static int getETicks(ErosionMain em) throws Throwable {
Class<ErosionMain> cls = ErosionMain.class;
Field fld = cls.getDeclaredField("eTicks");
fld.setAccessible(true);
return fld.getInt(em);
}
}
I just... I pray someone can help me. I will pay you...
If I could just figure how how a tree is initially seeded... in the java I will go from there
Have you checked 10 Years Later - Less trees ? It does the opposite, it removes trees but who knows
I have.... the most frustrating bug I've come across in a long while, and nothing I have done has fixed it or mitigated it.
Basically, this is stemming from a weather controller, where right now the only event is manually called
When it starts, it creates a "modded" weather period and adds in various stages, and this will work after waiting a while, maybe starting other random weather, but not if the world has just freshly started (even after a minute or two)
No matter what sanity checking I do (ranging from checking if the climate controller is even valid), even specifically adding the supposedly missing strength values to the custom stages, this will crash the world without fail if fired off within a few minutes of loading
last thing I can think of doing is maybe starting a vanilla weather period and turning around and killing it before starting this if the current session is under a certain time, but thats just rediculous
setMutualExclusive It's only on create menu?`
yeah, trait object is mostly just for create menu
please tell me, does anyone know how I can tie two UI windows between two players, so that when one of the players closes his window, the second player’s window also closes? And please explain what the player means after the IGUI, since the player’s name is not displayed in the game
function Window:onAnswerRequest(button)
if button.internal == "NO" then
print("123")
print("123")
print("123")
end
if button.internal == "YES" then
print("1234567890")
print("1234567890")
print("1234567890")
end
if button.internal == "OK" then -- CANCEL BUTTON
print("00098")
print("00098")
print("00098")
end
end
Events.OnServerCommand.Add(function(module, command, args)
if command == 'TradeRequestReceived' then
local playerObj = getPlayerByOnlineID(args[1])
local modal = ISModalDialog:new(getCore():getScreenWidth() / 2 - 175,getCore():getScreenHeight() / 2 - 75, 350, 150, getText("IGUI_Window_Request", playerObj:getDisplayName()), true, nil, Window.onAnswerRequest);
modal:initialise()
modal:addToUIManager()
modal.requester = playerObj;
modal.moveWithMouse = true;
elseif command == 'TradeRequestSent' then
local clickedPlayer = getPlayerByOnlineID(args[2])
local modal = ISModalDialog:new(getCore():getScreenWidth() / 2 - 175,getCore():getScreenHeight() / 2 - 75, 350, 150, getText("IGUI_Window_SentRequest", clickedPlayer:getDisplayName()), nil, true, Window.onAnswerRequest);
modal:initialise()
modal:addToUIManager()
modal.recipient = clickedPlayer;
modal.moveWithMouse = true;
end
end)
if state1 then
elseif state2 then
elseif state3 then
elseif state4 then
end
if i have state3 and state4, it's trigger only state3, right?
yeah
but if i have state1 and it's trigger first and create state2
if state1 then
state2 = true;
elseif state2 then
elseif state3 then
elseif state4 then
end
state2 be triggered?
First time modding, I'm folloing this guide (https://github.com/Konijima/PZ-Libraries) to setup the development env and I have a question :
The guide use JDK 17 does this still holds ?
I believe Konjima's guides are too old now. We suggest using VS code and the addon Umbrella made by Albion for PZ autocompletion
Oh wait that's for decompiling ?
yes
Beautiful java is better imo, it renames variables based on type https://github.com/quarantin/beautiful-java
the konijima guide is very old and getting increasingly impractical to follow
iirc it doesn't work in newer versions of intellij without some configuration
and if you're doing it for the type stubs it generates they're significantly worse than umbrella's which don't require you to manually generate them
imo umbrella + beautiful java (or even any generic java decompile tool really) replaces capsid completely
for starters I want to modify the vehicle framework for me and my friends, but as i checked the lua documentation there aren't any lua events that deal with what i want (?) unless i am mistaken. what i aim to do is modify vehicle behavior on zombie collision such as speed, damage, conditional damage based on body work, etc (bespoke tweaks's)
so if i want to do these am i correct in setting up a workspace to decompile the game?
Does it ? I don't have my variables named after their types with my BJ decompile
There's a mod that already does that
Probably the same at least
yeah vehicle behaviour is java stuff, i recommend using beautiful java or some standard java decompiler over this guide still
could you send me the mod ?
it's not really a good place to dive into modding though, almost nobody does java modding so you won't be able to find much documentation or help
I can't rn
recompiling seems like a unicorn guide
Not sure if I'll be able to find it back tbf I don't use it
this explains a lot.
So what's the recommended steps to develop a java mod ?
The IntelliJ's compiler is bad
Compared to cjr
I've just compared both of them and IntelliJ seems to assign variable names like var01, var02 and so on
Is there no official decompiler from Project Zomboid?
Yeah, which isn't that bad tbf
That would be like asking the devs to give us their house lmao xD
Well that's just how modding works
Give the tools to people to steal their work, sure go on lmao
By decompiling java source it's more easy to create client sided cheats
Unless your going to start obfuscating code
Doesn't make it less an issue that giving the tools to decompile your code means giving half the tools to steal your game
?
No not that
no, that's some dota crap that decided to use the same name as us a year later
You could always obfuscate the code
not that we own such a generic name but it's a real pain 😅
Install Lua, then ctrl shift P > addon manager > seafch Umbrella
And use encryption keys which only PZ can decompile it during run time
That'd kill modding
it's kind of a waste of time
Well yeah ofc but what's the point of givibg a fucking decompiler if it's to make it unreadable ??????
honestly this wouldnt be that much of an issue if lua modding had more access to tweaking a lot more in the game rather than just having to go through a lot of decompiling effort
the game has a lua interface to most of its api, all you need to cheat is an injector
? Your saying sharing the decompiler which PZ uses is basically stealing the game source code and logic
restructuring the game's networking so that security is actually remotely possible is a much better solution than just trying to slow down hackers with obfuscation
What we are doing now is also decompiling the game source code to understand or modify it in a way it's never intended by the devs
i think the game's netcode needs restructuring either way
nearly everything is client auth, cheaters are basically omnipotent
Yeah basically that
Need to move to server sided auth
Game has no anticheat, I don't know if it even has some sort of authentication with steam when using cracked clients
i think anyone serious about modding should decompile, you're very limited when you can't actually see what the api does, but java edits and recompiling is almost never done and you're not likely to find any resources regarding it
do you know any mods I can look up as reference ?
Project zomboids netcode is fucked lol
I think with vanilla pipebombs/molotovs the player who throws them has to look at them till they land
And if they throw them but get killed before it lands nothing happens
lmao
Also if you throw it out of a car the explosion will visually happen on the car where it got thrown from
I feel like a little image on the GitHub clarifying this would spare a lot of new people trouble when trying to install Umbrella. I've seen several people get this wrong. I know the instructions are clear if you follow them but it is human to think you recognize a process when the words sound very similar to a process that you are familiar with following.
Just my two cents
Which are figurative and therefore actually worth 0 cents
i don't really know how we'd demonstrate it
Hi all, does anyone know why when I use :setSprite on my Iso object it seems to lose collision and context menu items, like using setsprite seems to be turning it into nothing but a sprite as far as the game is concerned, was using tchernolib so tried to update spritename by the update function in the but it had no visual effect, so tried using setSprite and getting this
anyone have any ideas what I'm missing?
edit: using setSpriteFromName instead seems to work 🤷
Good afternoon guys! I was looking how campfire is defined so I can take a idea for a new container that will be able to burn, but i am no able to find where campfire is defined... anyone knows?
declaration: package: zombie.iso.objects, class: IsoFire
Perhaps
Check the java of isCampfire() and what it access
Perhaps it links to another IsoObject
As far as I know there is no way (thankfully) to join steam servers with non-steam (pirated or -Dzomboid.steam=0)
Im actually going to test that rn
edit: you can trick pz into thinking you're running a steam copy but since pz uses steam lobby api for server browsing/connecting, I don't think it will let you :D)
thanks! i will take a look
Screenshot showing both in VS Code in both searches and tell them it's not the one on the left, it's the one on the right
That's how I do it at least
@bronze yoke you look like u know this game better than devs xd
i want to add the civilian bullet vest and beret to the ranger outfit have tried to change xml but not working ?
does anyone here want to make mods exclusively for my server for a wage?
That's called a commission and we have a server where you can ask for that
Click that and it leads you to an invite to the server
i dont want to commision the mod i want employ someone to make mods for us
And you can ask there anyway
You can even make a post in #project to shard your plans
thanks but im not after sharing ideas im simply after what i said, im looking for someone to work for me on mods exclusively for my server and be paid a weekly wage
And you can ask that in the server lmao
Also if you plan on doing such a thing I suggest you open a legal business for this kind of things
Anyway you can ask for modders, commissions or more, on the link I sent so you do yours
yeh thanks for your help, I will just stick to the relevant places and keep asking people
im not joining a modders server. the modder will be joining my server
Bro the link I sent you is more than relevant it's the modding Discord 
theres multiple modding discords stop spamming an ad for 1 you wqant me to join
You can tell modders to then join your server lol
+like just let it go its nothing to do with you
do you have to keep commenting on everything
An ad ??? Ok you do yours man lol, there isn't many other modding servers
i want to use the tool pz discord has given me to search i dont want to join some modders discord run by a modder , no offence
Hello, new to modding, I want to make a mod that will reset the water/power timer and the radio/TV Shows as if it was day 1, independently of the game calendar, so the time and seasons would still go on, but the water, power, radio, and TV shows will reset periodically, can you throw me into the right direction?
why not 
just wanted to try and do something fun

In vanila pz how are .ini files loaded and parsed? I'm struggling to save data to files at the moment
Nvm I found a nice json library to help me use JSON https://gist.github.com/lvzixun/80e5b900b82059ebf5d7
you can save in global mod data and in other instance related mod data. This covers most use cases associated to saves. you can use getFileWriter for non save-related stuff (e.g. CharacterSave mod).
Yeah sadly. the moddata is not available in the menu, so I'm using file writer
On server, getFileWriter output will be located at Lua folder. Not sure about client.
same
Is there a way to add dynamic translations? If not, I will make an api for it
I am just asking because I didn't see any on the workshop and there'd be no point in me reinventing the wheel
What do you mean by dynamic translations? Adding a string translation from Lua?
(sending this message to reply, because I always forget to do so)
Having translations that change dynamically and are not static definitions
I asked recently a similar question and got no answer. if you make an api for it it'd be welcome.
Can you give an example?
for example tranlsation strings in a pool to be selected at random (so for example the moodle description translations aren't always the same)
That's already doable I'm fairly certain lol
You can always randomize the choice within a table of strings
I see. I think generally that's done by appending a number & using randomization to determine the number
true it is already doable but I don't see a reason not to have an api where it's not having to be implemented differently in every mod
I only thought of this because I hate how static the text seems for the ui
ok sorry that's not what I requested then. I want to change dynamically translation for vanilla keys.
I'm unsure the Translator class exposes enough to make that feasible with just Lua, although I'm not at my home computer to confirm
So without a Java mod you could override the getText functions and it'd work Lua-side, but wouldn't be able to affect the Java getText calls
can you elaborate? I am not sure what this means
I could make the api work for vanilla translations too if thats what you mean
I checked it and found nothing. I want to apply it to Java side getText calls. That's why I was so repidly involved in the topic 😉
If it works for Translator.getText called Java side without Java mod, I'm in. But afaik this is not gonna be a thing.
If it were up to me I'd tear it all up and replace it with http://projectfluent.org
Write a converter for the project zomboid translation files to ftl, boom. But I imagine that'd be a hard sell to the devs
as in calling getText() would result also in dynamic translations?
I think Tchernobill is talking about dynamically overriding vanilla strings, if I'm not mistaken. Like we can override them in translation files
if thats so vanilla can have dynamic translations too then I don't see why just overriding them and letting mods specify what to override with would be a bad option?
as in getText would result in different translation depending on prior actions.
I could just override getText on the lua side then to my own implementation then right?
or am I missing the whole point ;-;
It wouldn't affect Java-side calls
oh well I don't think there's a way to directly affect java stuff from lua side unless it's reflected (in some way im not sure how)
Yep, which is the problem
getText('VanillaKey1') --returns 'Text1_1'
--modded code modifies the association translation in the current language
getText('VanillaKey1') --returns 'Text1_2'
so that the same key returns a different translation based on a variable (among other things)?
so something like this as an example?
local isDead = false
getText("Vanilla_IsDead") -- returns "I am not dead!"
isDead = true
getText("Vanilla_IsDead") -- returns "I am dead :("
I am like 99% sure I am just so bad that im missing the point entirely
not sure why I can't piece it together
I can imagine a setText('VanillaKey1', 'Text1_2') call between the two example getText calls given, rather than being based on variables directly
(setText being a made-up function, with a name derived by analogy to getText)
why would you want it to directly effect java side calls anyway?
For the same reason you'd want to affect Lua-side calls
I don't see there being a point besides having vanilla game translations be dynamic (like "Extremely Heavy Load" moodle) but then you'd just be able to do that on lua side anyway
To change the text that's retrieved. Take, for example, the sneeze and cough text that appears when the player is sick. The calls for these are hardcoded in Java
the text I want to modify is called java side 🙂
is there like any example I can work with
from the game preferably like a test string or something
See the last message I sent
I don't remember the exact string name but if you search “Cough!” you'll find it in the translations
wait you mean literally hardcoded like there is no way to change the translation for it? or do you mean the key is hardcoded
in that exemple 'Text1_2' could be another translation key to keep translation properties. that'd be what I'd need.
You can override the translations in a translation file, but otherwise no
you can change the translation, but not the key and the getText java side cannot be overriden.
but what is stopping you from overriding it? (the translation not the key)
As in, doing so in a translation file?
Nothing is preventing that, but that wouldn't be dynamic
yes but that'd fall more towards the lua side which is 100% doable
I mean the key is hardcoded, to be clear
it would just be one text change, I want it to channge it for another one that will not always be the same
There are Translator.getText calls Java-side
meanwhile I found another fun PZ interaction: https://youtu.be/R6IQCkmYSiE
And you, what's your last own discovery in PZ ?
Teleportation is real confirmed
taking this example, would would the deciding factor be that changes the key to return a different translation?
Hello all, I have a quick question I hope someone can help me with.
I have 4 recipes that use wallets to search for money within them, and then returns an empty wallet upon searching, depending on the wallet that was used.
When I right click on the group of wallets to run the recipe, I have to click 4 separate times on the same pile, as they are 4 different wallets.
Is there a way to run the script on the entire batch of wallets in one click instead of having to do it 4 total times?
Appreciate any advice, thank you!
like an "Open All" button?
Yes, I suppose that would be the case here. All the wallets are piled together under the item name "Wallet", but their are 4 variants, Wallet, Wallet2, Wallet3, etc. So when it gives the option to run the recipe, it only runs it on one set of wallet types at a time, instead of all of them.
You can identify it is a group of items instead of a single item and then apply yourself the composite pattern
That's what was in the back of my mind, but have not delved deep enough into zomboid coding to know which direction I need to take to get to that result.
function yourfunction(playerNum, context, items)
local nbItems = 0;
local item = nil;
for i,v in ipairs(items) do
item = v;
if not instanceof(v, "InventoryItem") then
item = v.items[1];
end
nbItems = nbItems + 1;
--apply your action to 'item' here
end
end
Events.OnFillInventoryObjectContextMenu.Add(yourfunction);
Thank you Tchernobill.
So I will run this function from the recipe onCreate, and then within this function, run my own script?
also tchernobill if you don't mind could you explain more about the translation stuff? I want to know what you want to see if it'd be possible.
There's a few routes I believe I could take, and if it has some use cases then id be glad to help if I can
this function will run every time you right click an item in your inventory (line 14 registers event callback)
so all you need to do I think is check if your wallet is the item being clicked (where they wrote the comment) and do whatever you want after that (run the wallet search code for each wallet)
Thank you aoqia, appreciate the help!
I did nothing, tchernobill was 99% of the help 😭
Well, I am very grateful for both of your help and insight.
Does anyone know why player:setZombieKills does not seem to work in MP?

Is there a way around this?
Have you looked in the java ?
You definitely should
any guides on decompiling the java? I plan on looking at the game code myself
Beautiful Java is your go-to
ty
please tell me, does anyone know how I can tie two UI windows between two players, so that when one of the players closes his window, the second player’s window also closes? And please explain what the player means after the IGUI, since the player’s name is not displayed in the game
function Window:onAnswerRequest(button)
if button.internal == "NO" then
print("123")
print("123")
print("123")
end
if button.internal == "YES" then
print("1234567890")
print("1234567890")
print("1234567890")
end
if button.internal == "OK" then -- CANCEL BUTTON
print("00098")
print("00098")
print("00098")
end
end
Events.OnServerCommand.Add(function(module, command, args)
if command == 'TradeRequestReceived' then
local playerObj = getPlayerByOnlineID(args[1])
local modal = ISModalDialog:new(getCore():getScreenWidth() / 2 - 175,getCore():getScreenHeight() / 2 - 75, 350, 150, getText("IGUI_Window_Request", playerObj:getDisplayName()), true, nil, Window.onAnswerRequest);
modal:initialise()
modal:addToUIManager()
modal.requester = playerObj;
modal.moveWithMouse = true;
elseif command == 'TradeRequestSent' then
local clickedPlayer = getPlayerByOnlineID(args[2])
local modal = ISModalDialog:new(getCore():getScreenWidth() / 2 - 175,getCore():getScreenHeight() / 2 - 75, 350, 150, getText("IGUI_Window_SentRequest", clickedPlayer:getDisplayName()), nil, true, Window.onAnswerRequest);
modal:initialise()
modal:addToUIManager()
modal.recipient = clickedPlayer;
modal.moveWithMouse = true;
end
end)
script stealing (i dont know anything)
Need to use client-server commands if they're on different computers.
Out of curiosity, are you doing something with the player to player trade menu? Looks like a trade request.
thanks, no, this is not a trade menu, this request is needed for mutual request between players
burryaga has good advice
so I think I'd be able to make this work but mods that aren't using the api for example would not be able to access the changed translations
Does anyone know how I can prevent the player from pressing the right mouse button during ISModalDialog, like in vanilla with the trade system, but without changing the vanilla worldobjectcontext code?
Hi guys! I'm trying to avoid repeating recipes over and over, for example if I wanted to add Sliced Fruit to the game:
- I currently have to manually enter all the fruits in the recipe, for example "Peach/Pineapple/Cherry/"etc.. Can I create a collection somewhere, and call it Fruits? (or if I wanted to add custom items that aren't Fruits in the game files, for example Tomato) Something similar to
[Recipe.GetItemTypes.SharpKnife]I seeFoodType = Fruits,in them but I can't seem to get them that way.
(That would help me so I can just modify the collection when I need to add items, instead of having to check the whole list one by one, everywhere I use it)
- (This is probably a no) is there a way for a recipe to return the ingredient used? seeing the code block:
recipe Slice Fruit
{
Peach/Pineapple/Cherry/Grapes,
keep [Recipe.GetItemTypes.SharpKnife]/[Recipe.GetItemTypes.Saw]/Axe/HandAxe/AxeStone/WoodAxe/MeatCleaver,
Result:Mymod.SlicedFruit,
Sound:PZ_FoodSlicing,
Time:80,
Category:Cooking,
OnGiveXP:Recipe.OnGiveXP.Cooking3,
AllowRottenItem:false,
}```
SlicedFruit is a generic object, but I'd like it to be Sliced Peach, Sliced Pineapple, etc. Do I have to create the recipe block over and over and just make it with the specific fruit? or how can I grab the ingredient used for the recipe, see that it's a Peach, for example, and then replace SlicedFruit with SlicedPeach
you can create a custom GetItemTypes lua function to return whatever items you want, and you can use an OnCreate function to implement custom functionality such as changing the result item based on the source
that's exactly what I need! I'm super new to lua, are there resources where I can look into this further?
the best way is to look in media/lua/server/recipecode.lua to see how the vanilla ones work
i've documented most recipe lua functions here but i didn't realise until now that i neglected to include GetItemTypes https://github.com/demiurgeQuantified/PZEventDoc/blob/develop/docs/Events.md#recipe_oncreate
iirc GetItemTypes just passes an arraylist of strings, which you're expected to insert the full types of applicable items to
thank you! I'll have a look
Does anyone know how I can prevent the player from pressing the right mouse button during ISModalDialog, like in vanilla with the trade system, but without changing the vanilla worldobjectcontext code?
Hey guys! Does one of you know where I can find vanilla item icons?
they're in the UI texture packs
if you're just looking for a specific one or something it's a lot easier to grab them off the wiki than to extract it
Great idea, I will just do that, thank you!
Does anyone know how I can prevent the player from pressing the right mouse button during ISModalDialog, like in vanilla with the trade system, but without changing the vanilla worldobjectcontext code?
Hi all, does anyone know how i'd go about configuring/creating a tile so that it can be placed inside a container for distribution, like how the antique oven can be found in warehouse crates (I know very little about tiles and moveables so assume I know nothing)
how load priority for lua?
for example (all this overwrite same aspect):
name_mod1
folder/lua/server/c.lua
name_mod2
folder/lua/server/npcs/a.lua
name_mod3
folder/lua/server/traits/b.lua
i mean... like... load mod priority have weights for this or last lua overwrite all, like !!overwriter3000.lua or zzzzMyMod.lua
the mod order set by users has no affect on lua, lua files always load in alphabetical* order
if they all overwrite the same thing whichever one loads last will overwrite whatever the previous files did
folder does not affect? if both on server but in another folders?
files load shared -> client -> server, all files from that folder will load before any files from the next
and all vanilla files load before modded files
if a mod overwrites a vanilla file, it will take that file's spot in the normal vanilla file load order, and iirc the mod set to load last takes priority
by this i mean vanilla shared -> modded shared -> vanilla client -> modded client not e.g. vanilla shared client server then modded shared client server
hmhmmhmh....
name_mod1
folder/lua/server/a.lua
name_mod2
folder/lua/server/npcs/a.lua
mod2 overwrite a.lua in mod1?
total (same name)
no, it would have to be in the same subdirectory
the full path after client/shared/server is what's considered
okay, but if they rewrite same part
name_mod1
folder/lua/server/a.lua
name_mod2
folder/lua/server/npcs/z.lua
z.lua overwrite this part?
yeah
understrood, thanks
it also uses the path for sorting (so server/a.lua -> server/a/z.lua -> server/b.lua )
wait...
braincrack
b.lua overwrite part of another code, yep?
okay, im understood
writes it down in notes
Reason: Bad word usage
can someone remind me how to add requirements to the mod info?
Does anyone know how to play mp3 or music stuff using RakVoice?
(long long1, long long2, byte[] byteArray, long long3) - what's that about ;-;?
I can use RakVoice.SetChannelsRouting to create a custom radio channel but idk how to send sound to them
Does anyone know how I can prevent the player from pressing the right mouse button during ISModalDialog, like in vanilla with the trade system, but without changing the vanilla worldobjectcontext code?
Does anyone have a good comprehensive modding guide for vehicles? I would like to edit the property of a trunk of my custom vehicle.
Hi everyone. This is code from VHS first aid mode: { text = "RM_1536de5b-09ea-4fec-9c34-fc34d42e7351", r = 0.80, g = 0.50, b = 0.00, codes = "BOR-1" }, -- You are watching, KY Medical Frontline!
I see diffrent for every other dialog
why
and how and from where did he/she get this numbers from?
that looks like a GUID generator thing. https://www.guidgenerator.com/. i know its used for clothing, from quickly looking it seems like they are using it for translatsion purposes. if you go into that mods shared/translate into the recorded media_eng txt you can see what they match up to
Free Online GUID / UUID Generator
bascially to translate the text into other languages
its just a random generator with so many possibilitys its almost impossible for two of the same strings to be generated ensuring theres no fuck up between mods and stuff
so GUID is not necessary for VHS right ?
Possibly not I guess
that make sense cuz this mode offers in more language
im not 100% sure, ive never seen it used for that before, only clothing. im assuming they just used it to make sure their translations wont conflict with any other mods
Yeah I see what they did here
Basically used GUID (but not mandatory in this case) to make sure their lines are unique from other mods
He could have given a unique them to all of them I think and it would have most likely worked
yeah, could have put like anything there realy
But at least using that, they are sure that their variable names won't get overwritten by another mod
tho they could have just done:
modNameVHSNameLineNumber_N
and increment that
and would most likely have still been unique
Does anyone have a working and/or updated version of WordZed? I'm looking to make a radio mod and the original seems to be gone from the forums.
might be a long shot but does anyone know why WorldObjectSprite wouldn't be reading my tile properly from my pack or .tiles file
pulling it in to item like this
{
Type = Moveable,
Icon = ElectricKiln,
Weight = 25.0,
DisplayName = Electric Kiln,
DisplayCategory = Moveable,
WorldObjectSprite = hiemsk_tiles_3,
}```
that is the correct tilesetname
as I am using hiemsk_tiles_2 in a lua file fine
but when I try place the item (hovering over place I want to place it, not yet placed) I get this error a lot on loop
ERROR: General , 1713272923911> ExceptionLogger.logException> Exception thrown java.lang.reflect.InvocationTargetException at GeneratedMethodAccessor570.invoke.
ERROR: General , 1713272923912> DebugLogStream.printException> Stack trace:
java.lang.reflect.InvocationTargetException
at jdk.internal.reflect.GeneratedMethodAccessor570.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
...
Caused by: java.lang.NullPointerException: Cannot read field "offsetX" because "<parameter1>" is null
at zombie.ui.UIElement.DrawTexture(UIElement.java:316)
When I do place it the tile has no sprite in game
I'm really not sure what I am doing wrong, have been taking apart other mods and can't see whats different
hiemsk_tiles_3 is the name of the tilesheet, but the various tiles in it have the index appended to the end of it. for example here
I got a question about using OnCreate in recipes. ive been searching the discord and found a method to do what i want, but im curious if theres a better way. currently i have seperate functions to do the same thing for diferent weapons, the code uses oncreate to set the weapons condition back to its max and the code works. but im wondering if i could generalize the function and use 1 function for all the weapons i have insatead of making a new function for each weapon.
the name of the tilesheet is just hiemsk_tiles with the _3 being the apended part
baically trying to figure out if i could pull the item being used in the craft and repair that, instead of having to specify which weapon to repair. so i can use one function for all the repair recipes
Did you put tiledef= with a valid number and pack= in mod.info ?
I believe so atleast, got this
tiledef=hiemsk_tiledef 3482```
and I am using other tiles from the same sheet within lua files
you might have already seen this (sorry if you have and I don't know much about the topic) but it sounded like someone was asking about something similar earlier but about slicing fruit
#mod_development message
maybe the replies to that can help
oh yeah i know that, but what im trying to do is have the same function for all the recipes. the recipes for the items will be diferent for each item. its just the lua function to repair those items that im trying to generalize, not the recipe that calls the function
just trying to figure out if instead of specifying in the function to check for a particular item, i could change it so that it only checks the first item used in the craft or something
very new to lua coding so, not sure whats possible
might be worth just testing to see if the items in the items array always come through in a certain order, in that case could you just use a certain index in the array
or if they are all your custom items you could give them all a certain tag and check for that rather than the item type, not sure I understand what exactly you need to do though tbh
if I understood correctly what you want to do, you can use this
function Recipe.OnCreate.SlapMWGeneralRepair(items, player)
local itemToRepair = nil
local repairableItems = {
["SlapMW.BladeOfBlue"] = true,
["SlapMW.OctoSword"] = true,
-- add other repairable item full types here
}
for i = 1, items:size() do
local item = items:get(i-1)
if repairableItems[item:getFullType()] then
itemToRepair = item
break
end
end
if itemToRepair then
local condition = itemToRepair:getConditionMax()
itemToRepair:setCondition(condition)
end
end
would that repair all items listed or only if that item was used in the recipe?
actualy assigning them tags and using lua to check for that tag could work. but the problem would be i only want the item used in the recipe to be repaired
the first item it finds in the items list
unless i'm mistaken only the items used in the recipe come through in the items list
then that would be perfect, ill test it out. thanks!!
I guess you won't repair 2 items from the repairableItems table in the same recipe
they could just do the repair within the loop if they wanted to repair them all right, and remove the break
no i dont wna repair them all, only the weapon that was right clicked in the repair
I think first one should be fine then
basically the vanilla fixign system reverts the weapons stats on repair. so if we hand out event items which stats we have changed it gets reverted
so im making a recipe that requires the weapon + other items that we will hand out during events to fix the event weapons
so the recipe i have has an oncreate to set the durability back to its max
but i didnt wana have like 20-30 seperate functions that all do the same thing if i could generalize it more to one function
have no idea what I changed but its working now, thanks for the help
I remade my pack, and restarted the game instead of just loading lua, so not sure what the problem was but it seemed to fix it
this works, thanks again for the help. and thanks to everyone who took the time to answer me!
its possible to get hit bodypart on target from OnWeaponHitCharacter?
Good question, if you find out I'm interested
The issue I think is that there isn't anything that checks body part hit and shit like that, it just randomly choses a body part to hit I belive or some shit like that
bruh... i want to improve armor absorb system
but wait...
in 42 devs want create normal stuff for armor, like real armor, yep?
okay... nvm...
Uh
The issues is that there's no way to properly add a limb targeting system so sadly I don't think it will change
Currently the game targets logical areas the zombies and players should hit depending on their attack types
Hello! I'm very new to this and I'm trying to make a mod that creates boxes with food at manually defined coordinates.
I have been seeing several mods how they define some things.
But I have a problem with this code, where do I put the file with the coordinates that I need to use?
yeah...
i have another method if you would want to see it, i used it for creating batteries for my vapes, and works well
and it puts it all under one function
You could technically overwrite the current damage limb system and add aiming possibilities
hmmmhmmmm.....
Interesting, how and where?
@echo lark if you wanted to have it all in one function you can do this as well, where it checks to see what item it is first then uses that item for the output
this part was also for a randomize feature
The easy way:
- manage yourself damages done to the players and zombies, add keybinds for specific target areas
The hard way:
- Java modding

pov
XD
function UseVapeB(items, result, player)
local stats = player:getStats();
local bodyDamage = player:getBodyDamage();
local char = player;
print ("Aww yeah, that's the stuff!");
stats:setStress(math.max(((stats:getStress()) - (0.15)),0));
bodyDamage:setUnhappynessLevel(math.max(((bodyDamage:getUnhappynessLevel()) - (8.0)),0));
--xx Smoker Trait
stats:setStressFromCigarettes(math.max(((stats:getStressFromCigarettes()) - (0.15)),0));
char:setTimeSinceLastSmoke(math.max(((char:getTimeSinceLastSmoke()) - (3)),0));
local r = ZombRand(8)+1;
if r == 1 then
char:Say("Tastes just like strawberrys!")
elseif r ==2 then
char:Say("This stuff is amazing!")
elseif r ==3 then
char:Say("So much better than the stuff iv made!")
elseif r ==4 then
char:Say("Strawberry liquid is the best!")
elseif r ==5 then
char:Say("Tastes so good and takes the edge off!")
elseif r ==6 then
char:Say("*Cough* Hit that one too hard *Cough*")
elseif r ==7 then
char:Say("*Cough* That was so dry... *Cough*")
stats:setStress(math.max(((stats:getStress()) + (0.15)),0));
bodyDamage:setUnhappynessLevel(math.max(((bodyDamage:getUnhappynessLevel()) + (8.0)),0));
for i=0, items:size()-1 do
local item = items:get(i)
if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.RedVape") then
char:getInventory():AddItem("VapeMod.RedVapeBurnt", item:getUsedDelta());
item:getContainer():DoRemoveItem(item);
end
if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.BlueVape") then
char:getInventory():AddItem("VapeMod.BlueVapeBurnt", item:getUsedDelta());
item:getContainer():DoRemoveItem(item);
end
if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.GreenVape") then
char:getInventory():AddItem("VapeMod.GreenVapeBurnt", item:getUsedDelta());
item:getContainer():DoRemoveItem(item);
end
if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.GoldVape") then
char:getInventory():AddItem("VapeMod.GoldVapeBurnt", item:getUsedDelta());
item:getContainer():DoRemoveItem(item);
end
end
end
end
``` @echo lark found a cleaner part of my code if you want to try to make that repair thing a single function
This has to be one of the worst shit I've ever looked at
You could probably fit all this within hmmm 3 lines lmao
Bro your indentation is completely wrong
That's the worst part xD
how are you going to put that on 3 lines 0.o
the indentations where for my self, as i have a hard time reading my ends
Ok so first off, optimization on your method, you are doing a bunch of useless checks here
local item = items:get(i)
if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.RedVape") then
char:getInventory():AddItem("VapeMod.RedVapeBurnt", item:getUsedDelta());
item:getContainer():DoRemoveItem(item);
end
if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.BlueVape") then
char:getInventory():AddItem("VapeMod.BlueVapeBurnt", item:getUsedDelta());
item:getContainer():DoRemoveItem(item);
end
if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.GreenVape") then
char:getInventory():AddItem("VapeMod.GreenVapeBurnt", item:getUsedDelta());
item:getContainer():DoRemoveItem(item);
end
if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.GoldVape") then
char:getInventory():AddItem("VapeMod.GoldVapeBurnt", item:getUsedDelta());
item:getContainer():DoRemoveItem(item);
end
this is wrong because it's impossible for your item to be multiple types right ?
Can it be VapeMod.GoldVape and VapeMod.BlueVape at the same time ?
those are dif items
That's not an issue of the code not working
Exactly
So your item when it checks one of those getFullType conditions, it can't be the other 3
all 4 vapes use this same function
local item = items:get(i)
if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.RedVape") then
char:getInventory():AddItem("VapeMod.RedVapeBurnt", item:getUsedDelta());
item:getContainer():DoRemoveItem(item);
elseif item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.BlueVape") then
char:getInventory():AddItem("VapeMod.BlueVapeBurnt", item:getUsedDelta());
item:getContainer():DoRemoveItem(item);
elseif item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.GreenVape") then
char:getInventory():AddItem("VapeMod.GreenVapeBurnt", item:getUsedDelta());
item:getContainer():DoRemoveItem(item);
elseif item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.GoldVape") then
char:getInventory():AddItem("VapeMod.GoldVapeBurnt", item:getUsedDelta());
item:getContainer():DoRemoveItem(item);
end
First off so you don't do all those other useless checks for nothing
there are 4 vape liquids and 4 vapes, so there are 4 other functions that look like that, and they need to check to see what vape called the function
If one triggers, there's no point checking the others since it can't be the others for a single item
okay but then how do you get it to check the other vapes if you only put one in
wdym only put one in ?
Your item can't be multiple getFullType() right ?
Can it ?
You said no, it's either Red, Blue, Green or Gold no ?
correct
So then if it's one of those, it can't be the others ?
item get Module not req here... yep... its strange...
if i take that part out the code string breaks though
iv tried and it didnt work
only time it worked was with that part in there
Next, don't check item:getModule() == "VapeMod" everytime, check it once
local item = items:get(i)
if item:getModule() == "VapeMod" then
if (item:getFullType() == "VapeMod.RedVape") then
char:getInventory():AddItem("VapeMod.RedVapeBurnt", item:getUsedDelta());
item:getContainer():DoRemoveItem(item);
elseif item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.BlueVape") then
char:getInventory():AddItem("VapeMod.BlueVapeBurnt", item:getUsedDelta());
item:getContainer():DoRemoveItem(item);
elseif item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.GreenVape") then
char:getInventory():AddItem("VapeMod.GreenVapeBurnt", item:getUsedDelta());
item:getContainer():DoRemoveItem(item);
elseif item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.GoldVape") then
char:getInventory():AddItem("VapeMod.GoldVapeBurnt", item:getUsedDelta());
item:getContainer():DoRemoveItem(item);
end
end
that part checks to make sure its under my mod not the item
This way instead of doing 8 checks, you went to 1 + 1 min max + 4
Yes and I'm not removing it, instead I'm making sure you don't check it 4 TIMES but one 1 TIME
That reduces the charge on the program
Less stuff to process, better performances
i think you lost me a bit there
How to explain that a different way hmm
could just wright out the code how you think it should look
If I don't explain it to you I'm just doing your job lmao
dont look into zRe Armor absorb system xD im ashamed with my spaghetti coding
You need to understand it to make your next codes better

like do you mean
elseif item:getModule() == "VapeMod" and (item:VapeMod.BlueVape")

i learn from seeing, not just from talking about it, i had someone show me all of this from scratch and i picked up on it over time
Yeah I get it, that's why I'm trying to find a way to show it x)
local item = items:get(i)
if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.RedVape") then
char:getInventory():AddItem("VapeMod.RedVapeBurnt", item:getUsedDelta());
item:getContainer():DoRemoveItem(item);
end
if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.BlueVape") then
char:getInventory():AddItem("VapeMod.BlueVapeBurnt", item:getUsedDelta());
item:getContainer():DoRemoveItem(item);
end
if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.GreenVape") then
char:getInventory():AddItem("VapeMod.GreenVapeBurnt", item:getUsedDelta());
item:getContainer():DoRemoveItem(item);
end
if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.GoldVape") then
char:getInventory():AddItem("VapeMod.GoldVapeBurnt", item:getUsedDelta());
item:getContainer():DoRemoveItem(item);
end
This is your original code and this is is what it does:
- get the item from the list
2.1 Checks if is your module
2.2 If passes then checks itemRedVape
3.1 Checks if is your module
3.2 If passes then checks itemBlueVape
4.1 Checks if is your module
4.2 If passes then checks itemGreenVape
5.1 Checks if is your module
5.2 If passes then checks itemGoldVape
So you have 5 steps that you run through
But within those 5 step you go up to 9 steps if your item is in your module
so what your saying is even if its the redvape its still checking the other ones?
EXACTLY
so how do you get it to stop checking after it gets the right one
And the elseif makes sure that if one of those passes, it doesn't check the others since they will be false for sure
The elseif
here
Here the steps are:
- get item from list
- check if module
if item is not in module, it stops here
if it's in module continue steps:
3. checks a first time the item is RedVape
if passes it stops the code here and that's 3 steps
else continue for check for other type
repeat
I need more context here, make sure you don't put an end between each elseif and the original if, only one at the end
tbf you can just copy my code
lol very ture XD
one sec let me fix the block and ill send a ss
@bright fog
i think i have to many ends now >.<
thank you for showing me that XD
also sorry for coming off hostile XD i got defensive, this was my first mod i ever made by my self lol
Reason: Bad word usage
@echo fiber now my way of showing off
local itemType = {
["VapeMod.RedVape"] = "VapeMod.RedVapeBurnt",
["VapeMod.BlueVape"] = "VapeMod.BlueVapeBurnt",
["VapeMod.GreenVape"] = "VapeMod.GreenVapeBurnt",
["VapeMod.GoldVape"] = "VapeMod.GoldVapeBurnt",
}
local r_s = {
"Tastes just like strawberrys!",
"This stuff is amazing!",
"So much better than the stuff iv made!",
"Strawberry liquid is the best!",
"Tastes so good and takes the edge off!",
"*Cough* Hit that one too hard *Cough*",
"*Cough* That was so dry... *Cough*",
}
function UseVapeB(items, result, player)
local stats = player:getStats();
local bodyDamage = player:getBodyDamage();
local char = player;
print ("Aww yeah, that's the stuff!");
stats:setStress(math.max(((stats:getStress()) - (0.15)),0));
bodyDamage:setUnhappynessLevel(math.max(((bodyDamage:getUnhappynessLevel()) - (8.0)),0));
--xx Smoker Trait
stats:setStressFromCigarettes(math.max(((stats:getStressFromCigarettes()) - (0.15)),0));
char:setTimeSinceLastSmoke(math.max(((char:getTimeSinceLastSmoke()) - (3)),0));
local r = ZombRand(8)+1;
char:Say(r_s[r])
if r == 7 then
stats:setStress(math.max(((stats:getStress()) + (0.15)),0));
bodyDamage:setUnhappynessLevel(math.max(((bodyDamage:getUnhappynessLevel()) + (8.0)),0));
for i=0, items:size()-1 do
local item = items:get(i)
if itemType[item:getFullType()] then
char:getInventory():AddItem(itemType[item:getFullType()], item:getUsedDelta())
item:getContainer():DoRemoveItem(item)
end
end
end
end
np we all start somewhere ! Also I'm the one who started a bit aggressive perhaps haha
Anyway this is how you go from a 30 line code to only 10, this also greatly optimizes the code since you don't have to go through if statements for each types
I haven't made the function local indeed but you should
Or store it in a module
-- file module.lua
local yourModule = {}
return yourModule
-- other file
local yourModule = require "module"
function module.yourFunction()
-- do stuff
end
-- another file again
local yourModule = require "module"
-- run function defined in other file
local function exampleFunctionToRunModuleFunction()
module.yourFunction()
end
What I did is instead of doing if statements for each types and shit, you just access the result directly
When you start getting massive if statements like that, it's the best way to use dictionaries
okay i can try that XD might not look pretty at first
if im not wrong, local function not call from recipe
if im not wrong he use item from recipe
Is it a recipe function here ?
But yeah for recipe functions they need to be global
look like that
Yeah
it is a recipe function
yeah then keep it global
what part needs to be globle?
This is a dictionary and is stored localy in the file so it can be accessed within the function
function UseVapeB(items, result, player)
this
keep it written like that
o yea it is
don't do:
local function UseVapeB(items, result, player)
yeah
i wrote what you did step by step to make sure i understood where everything went and what called what
Good to do that
its been awhile... print just goes to the console right
to show its running that part
also should be done re wrighting it does this look right
i recomend made global function name more unic
something with your tag and mod name
(about prints)
I suggest keeping those for debugging only but remove them the moment you post the mod
AND I BEG YOU, DON'T PUT THEM BEHIND A CHECK TO VERIFY YOU ARE IN DEBUG MODE
Remove EVERY SINGLE PRINT you have besides those that can happen like on mod load (for example I do a print to say I overwrite a specific function from a mod)
The reason you remove your prints is to:
- not clog the player's consoles (a print every single tick is just a fucking no)
- performance reasons (they can actually lag the game very hard depending on the print frequency)
- for modders who use your mod in debug mode, they will end up with print spams out of fucking nowhere for no fucking reasons (you can tell I hate modders who do that shit)
like function zReVapeMod_UseVapeB for example
true
id need someone to walk me threw that one XD
but Sir Doggy i will make sure to remove the prints if i ever publish this mod
The prints are useless for EVERYONE but yourself and modders who might fuck around with your mod (and that's their problem, they'll add their own prints to things they want to study anyway)
its been done for years but never desided to publish it
Just change the name of the function to be something more unique
i assume just due to the fact of other mods might have it
and you dont want a clash of functions
exactly
is there a quick way to comment a block of code out
in lua
--[[
code here not read
]]
yeah
thank you so much
or select the whole thing and CTRL + another key depending on your IDE

ops
need to clear
Greetings,
First time modding. Past few days I have been trying to create a mod that aims to reduce the speed reduction when driving a car and hitting a zombie. I was learnt about player:isDriving() and player:getVehicle(). Additionally I think the class I want to modify is Class BaseVehicle.HitVars (https://projectzomboid.com/modding/zombie/vehicles/BaseVehicle.HitVars.html#calc(zombie.characters.IsoGameCharacter,zombie.vehicles.BaseVehicle))
But I don't know if that is correct, could anyone give me some help ?
declaration: package: zombie.vehicles, class: BaseVehicle, class: HitVars
From what I understand,
the method calc(IsoGameCharacter target, BaseVehicle vehicle) calculate the hit speed based on what it hit and then set the vehicle speed
public void calc(IsoGameCharacter var1, BaseVehicle var2) {
var2.getLinearVelocity(this.velocity);
this.velocity.y = 0.0F;
if (var1 instanceof IsoZombie) {
this.vehicleSpeed = Math.min(this.velocity.length(), 10.0F);
this.hitSpeed = this.vehicleSpeed + var2.getClientForce() / var2.getFudgedMass();
} else {
this.vehicleSpeed = (float)Math.sqrt((double)(this.velocity.x * this.velocity.x + this.velocity.z * this.velocity.z));
if (var1.isOnFloor()) {
this.hitSpeed = Math.max(this.vehicleSpeed * 6.0F, 5.0F);
} else {
this.hitSpeed = Math.max(this.vehicleSpeed * 2.0F, 5.0F);
}
}
- Code from the BaseVehicle
@bright fog so i think the code is broken a bit, its not putting the burnt vapes in my inv or removing the good vape
so it checks to see if its the right vape, (i think) but its not giving or taking the vapes
im not sure... how to do that...
but maybe u can check in mod "controlled impact"
https://steamcommunity.com/sharedfiles/filedetails/?id=2690802166
and do something like that but for speed
like when vehicle get damage, get current speed, set current speed minus small delta
Nice
that's mine:
--[[ ================================================ ]]--
--[[ /~~\' |~~\ ~~|~ | ]]--
--[[ '--.||/~\ | |/~\/~~|/~~|\ / | \ /|/~~| ]]--
--[[ \__/|| |__/ \_/\__|\__| \/ \_| \/ |\__| ]]--
--[[ \__|\__|_/ ]]--
--[[ ================================================ ]]--

Does it say the text at the very least ?
i like it
it says the text yes
and is correct for each flavor used
but it wont use the code for removing and adding the burnt vape
It's supposed to give the burnt vape if it's r == 7 right ?
when it does hit the burnt vape call i get an error
What's the error ?
how do i look at the error
!console
Help the people helping you by posting your console.txt from %UserProfile%\Zomboid.
For hosted servers, please also post the coop-console.txt from the same folder.
Read it
o dear god
Check the line where you have an error
k one sec
You need to learn how to read errors or you can't mod properly
According to (https://projectzomboid.com/modding/zombie/vehicles/BaseVehicle.html) , I can't set the engine speed. there is only setRegulatorSpeed(float regulatorSpeed)
declaration: package: zombie.vehicles, class: BaseVehicle
idk how to find it........ anywhere i see errors in it, it looks like something thats not what im looking for
getCurrentSpeedKmHm()
Reason: Bad word usage
But how to set the current speed ?
try too print tostring getRegulatorSpeed()
whats it is
isn't that the rpm ?
im not sure
Don't search for "Error", search for "Stack trace" (ideally case matched and written exactly like that)
Thanks
ItemContainer.new is to create a new ItemContainer
But how do you remove it when I don't need it?
to be a little pedantic, while this is cleaner code, it is slower
an if statement is one of the cheapest things possible
tables are more efficient when they replace huge if trees, but just four if statements is going to be faster
as long as nothing references it, it will be deleted by garbage collection, you don't need to explicitly do something to delete it
Is it ?
table accesses are fast but not faster than an if statement, and your code redundantly accesses the table twice + gets the item's full type twice so there's an extra speed loss there
true
local item = items:get(i)
if itemType[item:getFullType()] then
char:getInventory():AddItem(itemType[item:getFullType()], item:getUsedDelta())
item:getContainer():DoRemoveItem(item)
end
``````lua
local item = items:get(i)
local newItemType = itemType[item:getFullType()]
if newItemType then
char:getInventory():AddItem(newItemType, item:getUsedDelta())
item:getContainer():DoRemoveItem(item)
end
```i would optimise this way
fixed all the errors 😄 lol time to put the mod back away, but its 100% done now lol probs wont post it though idk who would want a vape mod
you are right yes here, usually I would have done that but wasn't too focused on it
but in this case there's few enough cases that an if statement would probably be faster, the table solution is just cleaner + more extendable
Yeah I see
I can setParent(nil) to unreference it?
@bright fog thank you again for you help today, i put you in the credits of the readme lol, not like its getting posted but
yea i went back to the first one you did
the other one wasint reading the items correctly
No, you're right that CPUs are very good at optimizing simple conditional checks rather than direct table access which involves calculating a hash of the key and then looking up the value. Maybe it's the JIT compiler optimization fault
OOF
Surely I'm not clicking that shit
Send a github link so we can see what's inside before
yeah, definitely something very strange about lua that these end up like that, i found that the table access was only slower than *one* if statement, and even then it was marginal
this was tested on a standard lua compiler so results in zomboid might be different
You're saying accessibg one value in a 1000-length table takes longer than 1000 if-else branches??
Seems highly unlikely and counterintuitive to me...
no, only shorter if statements are faster
(though longer if statements would usually be compiled to something faster anyway, which is why you're always told to benchmark instead of theorising about speed)
I see
table accesses have an amount of overhead that should make them slower than a couple simple evaluations
but it seems that logic doesn't carry over to lua
classic
Congrats, glad you solved it.
hello there, is there a mod that inserts flawlessly new build option in the MetalWelding building context menu ? It looks as difficult as adding to Carpentry is easy.
Can't just get option by name and get its submenu somehow from there?
This exists but Idk if it will help:
function ISContextMenu:getSubMenu(num)
return getPlayerContextMenu(self.player):getSubInstance(num)
end
If you have the submenu you could just addOption to it all day I'd imagine.
thanx
in the script for a recipe, what line do i add to make the recipe hidden from the crafting menu?
Can't say for sure whether that works, so feel free to let me know.
Never tried adding to existing submenus.
Submenus are ISContextMenu instances, so it should work. Fairly sure I've done so
Hi ! I would like to make a very small mod that act like Braven's Erase Map Mod, but to only forget the "visited" zones, not the whole map, because I want the map already known. But I still want that players "forget" the areas already visited on the map on death.
would it be something like WorldMapVisited.getInstance():
clearKnownInCells(0,0,65,52)
Or WorldMapVisited.getInstance():clearVisitedInCells(0,0,65,52) ?
is it possible to get ontest to only check the first item? im trying to get so the craft is only possible if the first items condition is < 5 but every time i do it the 2nd item in the recipe is grayed out as if its checking that items condition to or something
just make your ontest check the type of the item too
e.g. if item:getFullType() == "Base.Hammer" and item:getCondition() > 5 then return false end
hmm i was trying to do it based off of the items tag using hastag to avoid having a seperate ontest for each items recipe
you can always do something like this if you want multiple types```lua
local validItems = {
["Base.Hammer"] = true,
["Base.Wrench"] = true,
}
function myOnTest(item, result)
if validItems[item:getFullType()] and item:getCondition() > 5 then
return false
end
return true
end
a tag for one recipe is kind of overkill
probably yeah, but i was giving the items a unique tag anyways so i could use it for other things in the future, they are gonna be unique event items that the admins will edit the stats on, i have a recipe for each weapon set its condition to max using oncreate (since the fixing method of repairing resets the stats to default). so i was just trying to get a ontest so the recipe only shows if the items condition is below 5. so i figured if i could make the function check for the tag i could avoid having a like list of items if i manage to make lots of event weapons
kind of like how SOMW uses SReward tag to stop the stats of the honored weapons from reverting onswing
So would the multiple IF be faster or not in this case than the dict ?
multiple if is never faster
Confirmed ?
that was the result of a benchmark i did with an online lua compiler
i ran it a dozen times and got about the same results each time
So interesting
With any amount of IF or table sizes ? (tho table size doesn't change ?)
table size shouldn't really matter, and i found that *one* if is very marginally faster than a table access
i'll test a larger table but hash maps should be O(1) anyway
So don't make a table for a literal single conditional variable... lol I would sure hope not.
technically speaking if your first if statement catches 99.99999...% of cases it would be faster than using a lookup table
but don't optimise around stupid bullshit like that
ah ok, i think i understand that enough to understand. ive already defined a table for those items for the recipe.OnCreate i have so ill just use that method instead. thanks for the help!
got around to trying it out, not really
lua is lua i suppose
Got the MetalWelding submenu insertion with: ```lua
myfunc = function(player, context, worldobjects, test)
--hide some protection against: test==true / invalid inputs..
local buildMWOption = context:getOptionFromName(getText("ContextMenu_MetalWelding"))--get the option --I depend on translation but have no choice afaik. anyway vanilla protects it so it is a valid key
if not buildMWOption then return end
local subMenuMW = context:getSubMenu(buildMWOption.subOption)--get the menu
if subMenuMW then
addMyOwnOptionToMetalWeldingSubMenu(subMenuMW, player)
end
end
Events.OnFillWorldObjectContextMenu.Add(myfunc) --entrypoint
The mod will come tomorrow, I'm exhausted tonight. https://youtu.be/dkK9ndCLGqs
Build Roof Mod for project Zomboid
link to come
https://steamcommunity.com/sharedfiles/filedetails/?id=
You can now build roof from the ground.
You need a wall frame or a wall to sustain the roof.
Does anyone know how I can prevent the player from pressing the right mouse button during ISModalDialog, like in vanilla with the trade system, but without changing the vanilla worldobjectcontext code?
I've never tried this, but I do believe you can attach onRightMouseUp and onRightMouseUpOutside to that object, so you may in theory be able to do this:
local yourModalInstance = ISModalDialog:new(x, y, . . . .)
-- use whatever your inputs really are in the line above
function yourModalInstance:onRightMouseUp()
-- do nothing
end
function yourModalInstance:onRightMouseUpOutside()
-- do nothing
end
Give it a shot and let us know how it goes because I honestly don't know if it'd work or not. I barely touch KBM.
hmm, thanks, let's try it now
Might also need to bind Down I guess?
👆
meaning onRightMouseDown and onRightMouseDownOutside
Same way
To fully block it
got it
In fact I guess for the sake of clean code...
I could recommend...
local yourModalInstance = ISModalDialog:new(x, y, . . . .)
function yourModalInstance:blocked()
-- do nothing
end
yourModalInstance.onRightMouseUp = yourModalInstance.blocked
yourModalInstance.onRightMouseUpOutside = yourModalInstance.blocked
yourModalInstance.onRightMouseDown = yourModalInstance.blocked
yourModalInstance.onRightMouseDownOutside = yourModalInstance.blocked
that would in theory also work.
Whichever notation you prefer.
Could also make that do-nothing function a local function I guess since it's garbage anyway to further simply how that looks.
local function blocked() end
local yourModalInstance = ISModalDialog:new(x, y, . . . .)
yourModalInstance.onRightMouseUp = blocked
yourModalInstance.onRightMouseUpOutside = blocked
yourModalInstance.onRightMouseDown = blocked
yourModalInstance.onRightMouseDownOutside = blocked
I suppose there's no reason this wouldn't also work for the same reasons
not working, maybe I can return a ISWorldObjectContextMenu.createMenu function, like in vanilla?
but from my code
Not sure. What exactly is the context? You just have a modal dialog box open and don't want players to open context menu while they're in it?
the ui only eats mouse events that actually land on the ui
one player can send another player an offer, the second player has a window with an offer to accept or not, I'm trying to make sure that during this window both players cannot call the context menu
now its look like:
if command == 'TradeRequestSent' then
local clickedPlayer = getPlayerByOnlineID(args[1])
modal = ISModalDialog:new(getCore():getScreenWidth() / 2 - 175, getCore():getScreenHeight() / 2 - 75, 350, 150, getText("IGUI_SentRequestto:" .. " " .. clickedPlayer:getDisplayName()), nil, true, WindowUI.onAnswerRequest);
modal:initialise()
modal:addToUIManager()
modal:removeChild(modal.ok);
modal.moveWithMouse = true;
else
local playerObj = getPlayerByOnlineID(args[1])
modal = ISModalDialog:new(getCore():getScreenWidth() / 2 - 175,getCore():getScreenHeight() / 2 - 75, 350, 150, getText("IGUI_RecieveRequestby:" .. " " .. playerObj:getDisplayName()), true, nil, WindowUI.onAnswerRequest);
modal:initialise()
modal:addToUIManager()
modal.moveWithMouse = true;
end
Does anyone know which soundbank the zombie death noise is stored in?
I figured onRightMouseOutside might get caught anyway. 😦 Sad day.
Based on what albion is suggesting, I'm not sure there's an easy way to stop the context menu from opening during that time without decorating something that I'd be thrown into a well and left to die for helping you decorate -- especially if you want it to prevent gamepad players from doing it, too. Why exactly are you trying to prevent opening of context menu at that time? What's the issue with opening the context menu at that time?
to avoid mistakes and inconsistencies, I understand, thank you for your time
If you explain why you need to prevent it, we may be able to think of other ways to achieve the same goal, but it's hard to speculate without knowing more. Sorry! I wouldn't judge you for going for it, but it's a big decision and I wouldn't make it lightly.
I want to make these windows perfect, the easiest way to do this is to make it impossible to right click and create a table like for the trade menu in vanilla, the bugs are that when the player can be sent an infinite number of requests with the window already open, the player can start send requests in response, which will drive the UI windows crazy and they will start to behave like crazy, being created by another player, not closing when necessary and the data (maybe for some, small errors terrify me), but I didn’t want to explain due to the fact that these errors you may consider these errors not requiring solutions and tell me not to pay attention, but I have never worked on the UI part before, so it’s not clear to me how to implement this as efficiently as possible and how to generally implement some ideas about the UI part
I don’t even know how to connect the code of modal windows and the instance table together
What exactly is the window you hope to perfect? The vanilla trade window or your own custom window for a different purpose?
Can you just tell your code not to spawn a second window if one exists, and not to allow a second request to be sent if they never receive a response from the first request?
e.g., if MyWindow.instance then return else createMyWindowInstance() end, in pseudocode?
And similarly, if MyUtilityModule.sentRequest[player] then return else sendRequest(player) end?
(This would assume you would have a table of sent requests to other players, and you would clear them as the responses came back, good or bad. Also assumes you destroy the instance when you close the UI.)
(Again, this is pseudocode above just to give an idea of what could be done.)
thanks, I'm trying to implement this now
Good luck!
lol, create workaround with moddata.
For example:
You context menu function should contain something like this
if not secondcharacter.getModData().MyTradeRequestLol or secondcharacter.getModData().MyTradeRequestLol == 0 then
context:addOption(blablabla)
end
after you send request, change moddata for second character to 1
it's block spam request
after player push cancel - it's change moddata back to 0
or nil (nvm)
table.insert(ProceduralDistributions.list.ArmyHangarOutfit.items, "EHE.Vest_PilotSurvivalVest");
table.insert(ProceduralDistributions.list.ArmyHangarOutfit.items, 3);
same as
table.insert(ProceduralDistributions.list["ArmyHangarOutfit"].items, "EHE.Vest_PilotSurvivalVest");
table.insert(ProceduralDistributions.list["ArmyHangarOutfit"].items, 3);
?
There's some key sybtax you can't .key
I believe whenever you have - you have no choice but to write it in ["key"]
yeah most weird characters won't work
. can't work for obvious reasons, neither does $
- can't be in it because it isn't distinguishable from an actual subtraction
t.a-t.c could be interpreted as either t.a - t.c or t["a-t"].c
it can't start with a number either
but numbers can be present, just not the first character
I know that bcs Susceptible makes a list of hazmats and gasmasks via the item ID and some mod have - in the item ID so I need to refer to them with the [] method
god damn... i wanna change soundbanks on days gone + left 4 dead + something else...
ou ou ou ou! dying light!
the java documentation is a bit confusing 😵💫 can anyone tell me which event or method ingame is responsible/called during a car collision?
im still new to pz modding btw
nothing is called or triggered in lua during a car collision
:(
the best you can do is to check the car's health periodically to see when damage has occurred
that'd be incredibly unoptimized. maybe i can do a routine that stores x amount of last vehicle health and speed into a table
that runs in a tick
would that be too much (?)
that's what i was suggesting
it's not ideal but there isn't really a better way to do it
damn ok thanks
yes i was studying that mod
me and @vague bay where wondering if there was another way to do it
but thx
actually there's a thought
OnPlayerGetDamage has a specific damagetype for being in a car crash
🤔
but afaik playerdamage from a car crash happens if its like an incredibly highspeed crash right
and only on static objects
i don't know the exact conditions but it's not all crashes for sure
alright ill look into it, ty
Hi ! I would like to make a very small mod that act like Braven's Erase Map Mod, but to only forget the "visited" zones, not the whole map, because I want the map already known. But I still want that players "forget" the areas already visited on the map on death.
would it be something like WorldMapVisited.getInstance():
clearKnownInCells(0,0,65,52)
Or WorldMapVisited.getInstance():clearVisitedInCells(0,0,65,52) ?
Actually how are custom events made ?
I know some frameworks add custom events for other mods to use but was curious how they did it
Like can you add an Event ?
yeah
LuaEventManager.AddEvent("MyEvent")
triggerEvent("MyEvent", ...)
personally i prefer using home grown callbacks since the lua -> java -> lua ping pong is a little unnecessary
but from my testing the overhead isn't all that significant so do whatever
Hmm
Are parameters set on trigger event ?
Has anyone managed to use redis/mysql on a lua mod or is json files the only way to go currently? I assume java modding would do the trick but that would require others to download the mod files and patch the game, not viable.
Uh redis mysql ?
yeah, you just pass stuff to it
events don't have set signatures at all
Redis or Mysql is what I mean of course.
they just *usually* pass the same things so it seems like they do 😅
No idea what that is
Yeah I see
Redis is an open-source, in-memory data structure store used as a database, cache, and message broker. It excels in speed and efficiency for real-time applications, supporting various data structures like strings, hashes, lists, and more.
MySQL is a popular open-source relational database management system known for its reliability, scalability, and robust SQL support. It's widely used in web applications for data storage and retrieval, offering features like transactions, indexing, and replication.
I know you can use json files but its tedious....
And what do you plan on doing with those exactly lol ?
Talk with external services like discord bots and/or websites etc
I can do it with json files but its not ideal because of all the reading and writing... Also the message broker function is something I miss a lot 😩
Reason: Bad word usage
Reason: Bad word usage
On what do you intend to use it?
is this the correct way to add keybind ?
bind = {}
bind.value = "MOGrTrigger";
bind.key = Keyboard.KEY_G
table.insert(keyBinding, bind)
copied it from another mod but it doesn't work for me
Hi! When I make a new food item, how do I tell the game that it should display a new icon when the food item is rotten? So as in vanilla, it should have a normal icon when fresh or stale and a rotten-version of the icon when it is rotten.
Every method in the java doc are exposed to lua
Also I believe this method doesn't do what you think it does
That probably is used to damage things the vehicle hit perhaps ?
However you could probably make a java decoration to link a lua function to the triggering of the method (even within the java)
(all of this is done via lua)
that'd be useful to what we are doing actually (probably) the game still allows us to modify vehicle damage when modifying world parameters, regardless. ty
Is it possible to mod the loading screen (the black one with text, before you can click to enter the world, which ends with "this is the story of your death" or something like that) ?
java decoration(?)
yup it's possible
Search for custom loading screens
let me find that back, someone showed me that a while ago
(do you know what a decoration is ?)
you might have heard it referred to as hooking in other spaces
Thanks a lot !
Java hooking is a bit tricky in theory
while it's correct that the javadocs only display methods that are exposed to lua, keep in mind that they do show some classes that aren't exposed
no unfortunately not
so you'll never have half a page be unhelpful, but sometimes you'll have an entire page that is 😔
Example Norby007 gave me a while ago
i just wish there was an api for running over zombies its so tedious 😭 im trying to find the simplest methods of getting it, me and mogr thought of an idea of triggering an onobjectcollide and run a condition if it was a zombie character id + the players vehicle id
turns out zombies touching a car don't trigger onobjectcollide
then running them over doesnt actually trigger anything in the output log
now my 3rd attempt is finding which class is responsible for adding ur car kill counts to player stats, maybe it'd have a good pointer for me to study via java code
ill read it in a sec, ty
looks a bit tricky at first but once you understand how it works
hooking is the practice of replacing a function with a new function that calls upon the original, so that your code is called when that function is, but the original functionality isn't actually lost
I'll write an example
it's not as useful for java methods as strictly speaking what you're hooking isn't the java method but lua's reference to it, so your hook isn't actually triggered by calls from java, only calls from other lua scripts
but sometimes it is very handy
-- file 1
function yourFunction(variable) --needs to be accessible from elsewhere, so stored in a module or stored in global
-- does some stuff
return stuff
end
-- file 2
local old_yourFunction = yourFunction -- store first version
function yourFunction(variable) --replace first version
-- do your own stuff, so alter variable for example or do a call elsewhere
return old_yourFunction(variable)
end
That way if a mod rewrites the original function for example, it doesn't matter and it will still work
Also you can do stuff like run code AFTER the original that way:
-- file 1
function yourFunction(variable) --needs to be accessible from elsewhere, so stored in a module or stored in global
-- does some stuff
stuff
end
-- file 2
local old_yourFunction = yourFunction -- store first version
function yourFunction(variable) --replace first version
old_yourFunction(variable)
-- do stuff after the original runs
end
not if you return ^^
yeah, the main utility is either to use other functions being called as triggers for your code, or to mess with the arguments/return values of a function
yup
Sadly cant hook into a function directly
I used it once or two already
wdym ?
Like in the middle of a function
Not before or after but directly in the middle
You'd have to replace the original in this case, which usually means possible incompatibilities with mods that also do it
Sadge
it's right construction:
require 'Items/ItemPicker'
require 'Items/Distributions'
require 'Items/ProceduralDistributions'
require 'Items/SuburbsDistributions'
require 'Vehicles/VehicleDistributions'
local zReVehicle_InstrumentalDistr = {
['MetalWelderTruckBed'] = 'items',
['CarpenterTruckBed'] = 'items',
['ConstructionWorkerTruckBed'] = 'items',
['PainterTruckBed'] = 'junk',
['SurvivalistTruckBed'] = 'items',
}
-- "LabItems.ChHydrochloricAcidCan" "LabItems.ChSodiumHydroxideBag" "LabItems.ChSulfuricAcidCan"
for k, v in pairs(zReVehicle_InstrumentalDistr) do
if v == 'junk' then
table.insert(VehicleDistributions[k].junk.items, "LabItems.ChHydrochloricAcidCan");
table.insert(VehicleDistributions[k].junk.items, 1.8)
table.insert(VehicleDistributions[k].junk.items, "LabItems.ChSodiumHydroxideBag");
table.insert(VehicleDistributions[k].junk.items, 1.8)
table.insert(VehicleDistributions[k].junk.items, "LabItems.ChSulfuricAcidCan");
table.insert(VehicleDistributions[k].junk.items, 1.8)
else
table.insert(VehicleDistributions[k].items, "LabItems.ChHydrochloricAcidCan");
table.insert(VehicleDistributions[k].items, 3)
table.insert(VehicleDistributions[k].items, "LabItems.ChSodiumHydroxideBag");
table.insert(VehicleDistributions[k].items, 3)
table.insert(VehicleDistributions[k].items, "LabItems.ChSulfuricAcidCan");
table.insert(VehicleDistributions[k].items, 3)
end
end
?
I think that is what we need. We trying to change reduction in speed when hitting a zombie. So I guess we need to change the function that runs when vehicle collide with zombie. Problem is we don't know it's name
it's definitely not called from lua so you wouldn't really be able to do much with that method
interesting way to handle adding loot, looks fine to me at first glance
theres multiple methods that mention char hits in base vehicle, but pinpointing the exact one is the issue atm
we can probably make a robust code that mitigates speed if we figure out a good collider logic
is this the correct way to add keybind ?
bind.value = "MOGrTrigger";
bind.key = Keyboard.KEY_G
table.insert(keyBinding, bind)
copied it from another mod but it doesn't work for me

- Class GameKeyboard
isKeyDown(int key)
Why is key an int ?
How to lookup the int for the G keybind ?
I made it, editing the UI_Intro1, UI_Intro2 and UI_Intro3 vars in Translate files 😉
👌
give me a sec I think I saw a list somewhere
couldn't find it
But keys are linked to numbers
something like Keyboard.KEY_G
also you can use input. smt if you dont wanna use a int but I dont remember
👌
thank you
I found BaseVehicle.HitVars which has attributes like hitSpeed and vehicleDamage
I can acess BaseVehicle class with vehicle = player:getVehicle() but how do I change the value of vehicleDamage which is member of HitVars subclass ?
declaration: package: zombie.vehicles, class: BaseVehicle, class: HitVars
Guess I can't
What about the calc method ? can I override it ?
public static class HitVars {
private static final float speedCap = 10.0F;
private final Vector3f velocity = new Vector3f();
private final Vector2 collision = new Vector2();
private float dot;
protected float vehicleImpulse;
protected float vehicleSpeed;
public final Vector3f targetImpulse = new Vector3f();
public boolean isVehicleHitFromFront;
public boolean isTargetHitFromBehind;
public int vehicleDamage;
public float hitSpeed;
public void calc(IsoGameCharacter var1, BaseVehicle var2) {
var2.getLinearVelocity(this.velocity);
this.velocity.y = 0.0F;
if (var1 instanceof IsoZombie) {
this.vehicleSpeed = Math.min(this.velocity.length(), 10.0F);
this.hitSpeed = this.vehicleSpeed + var2.getClientForce() / var2.getFudgedMass();
} else {
this.vehicleSpeed = (float)Math.sqrt((double)(this.velocity.x * this.velocity.x + this.velocity.z * this.velocity.z));
if (var1.isOnFloor()) {
this.hitSpeed = Math.max(this.vehicleSpeed * 6.0F, 5.0F);
} else {
this.hitSpeed = Math.max(this.vehicleSpeed * 2.0F, 5.0F);
}
}
this.targetImpulse.set(var2.x - var1.x, 0.0F, var2.y - var1.y);
this.targetImpulse.normalize();
this.velocity.normalize();
this.dot = this.velocity.dot(this.targetImpulse);
this.targetImpulse.normalize();
this.targetImpulse.mul(3.0F * this.vehicleSpeed / 10.0F);
this.targetImpulse.set(this.targetImpulse.x, this.targetImpulse.y, this.targetImpulse.z);
this.vehicleImpulse = var2.getFudgedMass() * 7.0F * this.vehicleSpeed / 10.0F * Math.abs(this.dot);
this.isTargetHitFromBehind = "BEHIND".equals(var1.testDotSide(var2));
}
}
if I understand correctly the calc method is resposible for calcuating the hitspeed and setting vehicleSpeed
When overriding modded traits is the loadorder important or what is there to consider?
mod load order doesn't affect lua load order, files load alphabetically
so unless you're modifying something outside of the lua, load order shouldn't matter
you probably want your file to load after the original mod's does but you can do that by just making the name later alphabetically (e.g. by prefixing the name with Zs)
server/a.lua -> server/a/z.lua -> server/b.lua
last overwrite (C) albion
So the lua file that overrides it just has to be alphabetically later than the file being overridden?
Uh
Depending on what your override is doing & when it needs to be available, it may be ideal to choose an appropriate event and apply the changes there
It has to happen basically at the same time so Events.OnGameBoot.Add(function)
Hey y'all. How are yall? It's been a long time since I've been here.
yo
Hey @frank elbow
setMaxHitCount doesn't change hitcount persistently, is it hard coded?
Hey, welcome back 😄
How are you?
I'm currently recovering from a major brain surgery.
I'm doing well! & oh, I hope you have a swift recovery
Thanks! It's not cancerous.
Hopefully I can get back into things with pz modding.
Heck yeah, glad to hear it
I did make major progress on my 2nd anti-cheat before all of that. Will find the code and continue working on it.
Hey @tame mulch You guys ever consider forwarding API wrapper calls for Bitwise operations? There's also a fancy Java AES library that would be great for Luanet encryption.
This would've saved me around 20 days of writing a bitwise ops emulator purely in Lua 5.1.
My solution is actually good because it's handled on the dynamic runtime level where interception hacking couldn't reroute or compromise encryption math.
It's very slow but it's also secure which is epic.
A built-in bit32 implementation would be very welcome
Understandably not prioritized, though. JSON built-in would also be handy
Welcome back just in time to prepare for b42:)
I so agree.
I'd like to see a more expansive, open approach to the server-side of PZ over time.
It's actually really good that I was pushed as far as I was to need to implement a bitwise ops library emulation because the whole point is for security.
I'm sort of breaking the game in a way to fix and improve on it.
Oh @frank elbow I have made progress on Rosetta.
I'm currently working on a bootstrap 5 web application that will give the ability to write in custom third-party documentation for Lua.
This rendered from some of that progress. =)
Sooo yeah. I'll try to get that web app done and then get to work on ISUI documentation.
I'm working on a Little mod that adds drain stats when Reading, based on the variable minutesperpage of the Sandbox options. I was wondering if it should be better to tie it to onplayerupdate or ontick events, server workload wise. Any Idea ?
How often do you need your code ran?
If you tick you are hitting every tick. If your player updates and the code isn't needed to be ran all the time then this works.
If you ever plan on writing code that needs to run periodically, look at the slowest options for updates first. If this doesn't work, then put it on something that updates more frequently and / or consistently.
does anyone have any idea about what:
variable:addXPBoost(Perks.MAX, 10);
does this raise all perks to 10? I don't recognise this MAX field
I need the code to run everytime a player is Reading.
If there's an associated event that fires when you need this code ran then use that. OnTick should be a last resort.
State-monitoring is boring code anyways. =)
Has anyone made a mod adding electrical wiring for things or is it all still based on range from a generator?
Ok so onplayerupdate is better than ontick for this one.
Yeah. Good call.
but OnPlayerUpdate call on every player on tick?
OnTick just on tick?
nope?!
Does it? I don't recall it does but I'm rusty.
The point of having events is to filter when something happens so I'd be concerned if this is a deprecated, redundant tick event.
Dropping this here in the void in-case anyone needs a handy JSON library for PZ Lua.
@frank elbow
just create event onTick with print("This is OnTick") and OnPlayerUpdate("This is OnPlayerUpdate")
and see in -dubug
how offen this events call
Also as a reminder: The wiki isn't fully accurate with events.
It'll get whackier with 42.
Albion has worked against the problem.
She does the documentation for Lua events for Umbrella.
So if you need insight for documentation from things like JavaDocs and Lua events, you can use Umbrella in vscode to get documentation in IntelliSense when calling API.
I didnt get a shit of this 😂
If you use vscode go to your extensions and grab umbrella.
Or wait one sec.
You need lua-server extension
But yeah typings for Lua are available. <3
I'm a self-taught in modding and lua/java programing
16 years of it here.
=)
What is vscode ? I use notepad++ to code my mods
Umbrella replaces a burdensome old library called Capsid that forced you to compile your own typings from Java without any human documentation.
same 
Yeah PZ has a huge notepad++ community.
I've slowly worked on y'all to get to vscode. =D
Appreciated, but I just yanked a json.lua off github with baked-in copyright info for my purposes
Font rendering in vscode is a big deal.
Nice!
The problem is those usually break with Kahlua so I had to modify the one I posted to work.
I still can't believe that I can make a fucking uint32 work in Lua 5.1 in Kahlua. It's so wild.
I broke myself figuring this out.
I only needed to JSON encode primitives, but break with kahlua how? Not encoding objects correctly?
It has to do with core lua functions.
I think something like evaluate was bugging up because it didn't exist. os.time as well
Ah, that. I did have to replace next but that's about it
Yeah.
You're fine then.
People will trip on that issue because most here follow instructions for more simple code solutions on mods.
(Content mods)
So if someone needs it that exists.
Heck yeah
I want modders to know just how powerful they are when they can take the wheel on documenting code that needs help.
=)
For real and being serious, so much discussion here are largely the same questions that would be answered with modest documentation from a few minutes of contributions over time.
I'm going to target the ISUI / UI Lua libraries so that it can get a good head-start.
@frank elbow Here's that bitwise op lib
This one might be dated not sure. Will need to grab my flashdrive for the current one. You can see it though.
It is now possible to build a roof from the ground level https://steamcommunity.com/sharedfiles/filedetails/?id=3225244443
King!
added support for your mod
I'm not sure how else I could let them choose whether to be floor or ceiling
You're fast
maybe put into roofing a copy of all floor including the offset ?
👀
Not thumpable ? You added an option for that ? Nice
Is that an admin thing tho ?
Hmm, I don't think it would be too good for performance a copy of all the floor objects, I'll stick with ticking the option
Yes, since the release, it's a sandbox option and when active, players can enable/disable it and admins have persistent access to it, regardless of the sandbox.
hey if i'm doing procedural distributions for a true music addon
and i have for example this:
table.insert(ProceduralDistributions.list["OfficeDesk"].items, 0.01);
0.001 would make it even rarer right?
can i make it even more rare than 0.001? because i got about 600 tapes and they still seem to be spawning a lot
Nice, I know your mod but I haven't played normally since a least the release of your mod lol
I haven't played normally in like half a year or so . I've just been working on it
yeah exactly like me with my mods lol
That value isn't absolute but is the base chance which in turn gets affected by loot rarity settings and other factors but making it 0.001 should definitely reduce the amount of items
Since its a double you wont be running out of decimal places when the maximum is 17^-324 in java
i set it to 0.00007
seemed to work fine on apocalypse preset

