#mod_development
1 messages · Page 366 of 1
Oh... Maybe actually have happyness have a chance to drop massively (even into unhappyness) the more ingredients you add if your cooking skill sucks
And ideally some kinda UI so you don't need to rightclick a million things and use the context menu 1000 times in 5 minutes
But yea.. like an actual reason to level cooking would be nice. and to clean yourself before cooking
That sounds possible, but also like a massive amount of work once you think about the separate components needed
If you register a new character trait via CharacterTrait.register(), you then need to define it via a character_trait_definition{}.
Do you need to do the same for registering a new ItemType? Can't find any examples of that, but I'm quite new to this.
I'm having trouble registering a new type, and then using it in a item definition via ItemType = foo (getType() returns null). Are those two things even referring to the same kind of "Item Type", or is that overloaded and I'm just not aware of the different kinds?
EDIT: I think these are different kinds of types
neat, vanilla added the getting wet if you drive in the rain with no windshield
if (vehicle != null && ClimateManager.getInstance().isRaining()) {
VehiclePart windshield = vehicle.getPartById("Windshield");
if (windshield != null) {
VehicleWindow window = windshield.getWindow();
if (window != null && window.isDestroyed()) {
float val = ClimateManager.getInstance().getRainIntensity();
val *= val;
val *= vehicle.getCurrentSpeedKmHour() / 50.0F;
how did i not notice that
Summer car added it to B42.12, dunno if it existed then TBH, didn't get around to adding it to B42.13 port since stats changed.
you may be confused on what an ItemType is, it's not really the same concept
you actually explicitly don't want to add new ItemTypes, they just error if an item uses a custom one 😅 i'm not really sure why they made them registries at all
they're not really a useful idea for mods even if they did work so it's not a big deal either way
added?
it's been there since b41 😅
Oh.. Guess I added it redundently then.
Thanks! Glad I got confirmation. I found some vanilla scripts that hinted at that.
Where is the zombie folder in 42 build? How do I decompile Zomboid in the new build?
does beautifuljava not work with 42.13.1? keeps saying my zomboid path is invalid but it had no problem on earlier builds
i dont understand the mods with different cars, i mean dosnt it just change the model of it
kinda usless
but maybe im just stupid
There are other ways, but that tool is by far the easiest way to do it.
thanks
Hello. Is it possible to change the property of a single object? As I understand it, the set and unset methods of the propertycontainer class change all objects.
What's your goal here ?
I'm wondering if it's possible to remove the "streetlight" property from a single lamppost.
So the light doesn't activate ? Is that why you want to do that ?
Overall I don't think removing tile properties is a good idea
Might cause problems for mods that use those
I'm just curious if this is possible or not. I understand that it's probably not. I wanted to do something like connecting to a generator without replacing the sprite.
HEY IAM BACK!
Noice welcome back
is there a simple way to inhibit or reduce a lot the hysteresis between the [player to cursor] direction and the animation angle ?
You mean like your head turns but your body only rotates later at bigger angle deltas ?
yes
Are you not using a custom animation already ?
Making your own animations and XML should allow you to handle that with fine control
Yeah usually. But for now I am controlling the player, not animations.
Your solution will be the animation here tho, I'm fairly convinced of it
For the horse mod we have custom turning animations and we don't have a single problem with that hysteresis
You're still on animations, I am not interested in that for now. I'll use IsoPlayer.getLookAngleRadians
But for your boat you'll need animations at some point ? The reason I'm pushing so much for animations is that you'll most likely have to do some AND I know for a fact this is a solution that works really really well from the horse mod and the bicycle mod Alex made
time to test on b42 again
I am currently exploring another path, without animation (more precisely, stuck in the "Sit" animation).
so body locations changed again ?
i better turn off all mods and fix 1 mod at a time this is gonna be pain in tha arse
well clothing is fixed ok
so next issue is when i open the item spwaner it errors
and no base or mods show
Verify you don't have an error earlier in your logs
If it errors, read the error too, it can help understand what the problem is
Make sure your items are well defined
fast teleport move ?
ill try to recreate the error
Read the errors in the console directly
Also sometimes to show the full log you need to click play in the debug menu or it won't show the full detail
example mods ?
Maybe the game only shows all if there's only the module Base that exists
i unloaded the mod and tried again it showes "all" and "base"
Your scripts must be wrong then
I might be missing something, but there is IsoPlayer.setTurnDelta which determines the turning speed for the player. And in B42 you can also instantly set the player facing direction with IsoPlayer.setTargetAndCurrentDirection if you want finer control
I suggest using my VSCode extension to see if you made a mistake in the syntax possibly
its bothered by the display name
If you hover your cursor on it it'll tell you why
Do note the extension is still being actively worked on and not every single parameters and script blocks might be documented yet
But the majority of it should be fine
It'll tell you when it doesn't recognize a parameter or when one is deprecated
If you hover it should tell you the problem too
Those are the ones I documented as Deprecated
any plan for deprecation messages?
Wdym ?
usually deprecated objects should have a message associated saying what to use instead
Rn I use the description
'Type' parameter in 'item' block is deprecated: use ItemType instead.
But I just thought a replacement link yea
I think I need to expand the deprecated message
- name: Type
deprecated: true
description: This parameter was replaced by `ItemType` in Build 42.13.
- name: DisplayName
deprecated: true
description: This parameter was removed in Build 42.13, naming an item should be
done with a translation entry. See the
[wiki](https://pzwiki.net/wiki/DisplayName) page for more information.
Currently that's what it looks like
It's done in the description for the most part, but yea it's a good idea to directly have it in the deprecation message
the usual implementation of this is just to let deprecated also take a string instead of a boolean
another complain is using item instead of itemtype
so deprecated: Use ItemType instead.
Should I have the string be the parameter to replace or text about it ? I feel like it'd be best to use a link to a parameter instead
And the description does the job of the detailed explanations
Like here if I do a text describing for DisplayName saying "Use translations instead.", then people will think that's a parameter
Wdym ?
the convention is deprecation messages just say what to do instead, and that's not always a link so it's best to just keep it as a simple string
Like I said, it's still in active development and feedback is more than welcome
The problem is that this main deprecation feature when saying what to use instead is not for experienced modders because they will most likely already know about these or know what the text saying what to use instead is about, like if Elictra here is told to use translations, they already know what we're talking about right ? But if users that are new to modding or not confortable with it get that message,, it'll be like I said and they won't know what this is about or what 'translations' are or how it works, or to find info about it
That's why I've put it in the parameter description, because when you hover that parameter to get info, it gives you the error message AND right under you have the description of that parameter
fixed it
So while I agree with having a message to what to use instead, in the case of DisplayName, I really am not sure that's a good idea
you can put exactly the same information you would've put in the description in the deprecation message, i don't see the issue
I believe one issue I had with such error mesages is that you can't format them as markdown, so links would be thrown in there kind of in a ugly way
tbh its great that it tells you where is the issue to begin with

iam already half way done
are there scalable versions of DrawTextureAngle available for UI Elements ? (I found none)
yea XD
literally im yesterday, btw
does b42.13 mp change the way players health is monitored? Before only the client's player health mattered and the client decided when death occurs, but now it seems it's somewhere else too?
It's the server that handles the player stats
Consider that anything that could be modified by clients to cheat is not server sided so clients don't handle anything regarding these
so this recently changed?
Of course, with MP release for B42
In SP it's the same thing
I mean than before
Since there's no concept of client server
so I should adjust player health on both client and server folders?
No
You should adjust it server side only
And the folders don't specifically mean server / client side
my lua files were in the client folder before
Refer to this:
https://pzwiki.net/wiki/Lua_(API)#Load_order
still not working. For example, onPlayerUpdate I'm doing player:getBodyDamage():RestoreToFullHealth() and it works fine in singleplayer but no mater which folder I put this lua in, it doesn't work on a server
The folder doesn't matter
That's not how this works
You did not read what I sent 😅
Only the client folder is not loaded server side, else every folders are loaded by both sides
I did, but it didn't sink in
yeah I got that
So that means your OnPlayerUpdate will run both sides anyway. And when you modify the player stats you need to sync them
Not with commands
But with specific functions used to sync
I do syncs and my mod worked fine before b42.13 (my mod is https://steamcommunity.com/workshop/filedetails/?id=3338664412)
No shit your mod worked fine before B42.13 since MP wasn't a thing 💀
mp was a thing in 41
MP B41 IS NOT B42 MP
There's a reason MP wasn't added on release of B42, they were reworking it, and that's part of what they reworked
When such things are handled client side, players can make hacks to modify those freely
So those were moved server side
That means you need to change how you handle all of this
When you run player health modifications server side you also need to trigger a sync
so I've tried adding a basic code server side player:getBodyDamage():RestoreToFullHealth() during onPlayerUpdate, how do I trigger a sync?
I'm looking for the function I haven't made a list of them yet
@LuaMethod(name = "syncBodyPart", global = true)
public void syncBodyPart(BodyPart bodyPart, long syncParams) {
if (GameServer.server && bodyPart.getParentChar() instanceof IsoPlayer parentChar) {
INetworkPacket.send(parentChar, PacketTypes.PacketType.BodyPartSync, bodyPart, syncParams);
}
}
@LuaMethod(name = "syncPlayerStats", global = true)
public void syncPlayerStats(IsoPlayer player, int syncParams) {
if (GameServer.server && player.isExistInTheWorld()) {
INetworkPacket.send(player, PacketTypes.PacketType.SyncPlayerStats, player, syncParams);
}
}
Possibly one of these
still, death occurs on the client even with my server code, so thats the client thinking it should die I guess
Tbh your mod does something very obscur for the game, so roadblocks could happen
I'm very aware, but it was the only method I could get the concept to work
What I'm surprised is that the player object disappears when you die no ?
no, I catch death before it happens
I actually simulate death at a threshold like 10% of actual health, then fake UI to show 10% health as being 1%
You probably need to use the second one
ok I'll check it out, need to figure out the syncParams
sync params ?
I don't need to pass them in the call? syncPlayerStats(IsoPlayer player, int syncParams)
or just player
@bronze yoke wtf ? Why does it passes bits ?
Wait that looks insanely cursed, ok that might not be what needs to be used for health
bit flags
you don't need to do that anymore, that's older api seemingly
you can just pass the CharacterStat instead
Probably not that you need to use
At least I don't see any enums for CharacterStat related to health, only infection
yeah those aren't characterstats
to send health stuff there's statics for the bit flags on PlayerHealthPacket that i'm not sure why they don't just use instead
that's what i use
What do you use exactly to update the player health ?
I need to make a list of every syncing functions here
me? In my mod proper I set the generalhealth then remove anything like infections but I leave bleeding (but reduce the time to 0) so other players can bandage the downed player up before reviving.
No I'm asking albion
Project Zomboid mod that allows digging out basement areas. - demiurgeQuantified/Excavation
What about a full heal of the player like he does ?
@quiet fulcrum
what does full heal cheat do?
I'll check it out for inspiration thanks. I'd rather not do a full heal though, I prefer to keep wounds but just halt death so the reviver has to bandage up someone before reviving and the newly revived still has a lot of injuries to deal with
I thought you were doing a full heal actually
I am trying to call a function from a lua class from another lua file of my mod. Specifically, the function ISCharacterScreen.updateAvatar(self, ...). How can I call an instance in my mod's lua so that I am able to call the function?
I know from another situaion that smth like MainScreen.instance.charCreationProfession:resetTraits() can work but I am not able to see how this carries over to my current situation.
Are you trying to run it on an existing menu ?
Good question...
What are you trying to do here ?
Does anyone know how the new buttons at the bottom of the inventories work?
I'm running zero mods but I can't seem to make them do anything
Nevermind, figured it out. Pretty confusing definition of "type" here from the player perspective
I have created an experimental generic Java mod loader. I made it to enable getting the Furry Mod working on 42.13.1. I'm really looking for someone from Indie Stone to tell me if it is OK or not.
I have placed it here: https://gitlab.com/wolfjackal-dev/furrymodloader
not the first to make a java loader so you may not have any problem
most used is https://github.com/pzstorm/storm
But still Java mods rely on basic edit and loading modified class
Never seen Storm anywhere before
But yea there's plenty of projects
Most recent one is Leaf
Has a lot of potential
Unofficial MP was one
And there is a lot of private fork
Every 6 months someone came with a new one, at the end, nobody use it as SP players don't care with java mod unless it's for better perfs
And on MP, no host let you install it ^^
The unofficial MP project a Java mod loader ?
nobody use it as SP players don't care with java mod unless it's for better perfs
I don't agree, we've seen plenty of example of mods being Java mods and yet used a lot
The Furry mod is one, the body shape mod is one, My Summer Car is a very recent one
This isn't niche
https://steamcommunity.com/sharedfiles/filedetails/?id=3559765660
and a lot don't really requier a java loader, or toolchain
you just need to add a path in your PZ_CLASSPATH and that's it
Yes, but the problem is that not enough people actual do Java mods to justify the need for a loader. But also when there's an update for a Java mod, you need to manually update it
That's the point of those Java loaders, to not need manual installation besides a single tool. That's also why I consider Leaf good because it has an easy installer and directly loads Workshop mods
yep but still, all actual java mods didn't really use loader
I just say that's its not the first and will not be the last
So there is no problem to post this here
At the end it will be another project like this on github
I can count at least 4 to 5 project since B41
none of them are really used
Oh yea it's definitely fine for sure
I just want to call ISCharacterScreen.updateAvatar(self, ...) manually in my code. This is the function which updates the character's in-game avatar from the character info screen. So I want to update it manually.
The whole system how they update the avatar in multiplayer seems to be different from how they do it in singleplayer now. I do not really understand what's is going on exactly in MP so I am just trying around. Updating it manually might be the easiest fix for me (but possible that it still don't work...)
If you need to catch the character screen instance, then just decorate the actual menu creation, store its instance somewhere for later use
Or directly hook to the function that calls this avatar update
Pretty sure this is unmaintained—I remember it from b41 but it didn't look like there was any activity last I checked (which was a few months ago tbf, but it was years without activity)
that's why there is so many private fork
How can I store the instance? Just hooking the new() function and then somehow storing the o?
or taking the self from the create function?
Yup
Store the o
Ok thanks! But I think I just found smth else by trial and error:
print("TEST_OUTPUT charScreen exists")
ISCharacterInfoWindow.instance.charScreen:updateAvatar()
end```
The lua ISCharacterInfoWindow.lua seems to be the only one which creates the char info screen via the `new()` constructor. So that's pbbly also a way of doing it.
Hah, funny, didn't know that existed. Looks like I re-implemented by accident.
it's cool anyway, from a dev perspective I also prefer to implement my own project even if something already exist
is that funny ? 🧟♂️
https://www.youtube.com/watch?v=OG_Rjx1Kwdw
L'arcade ZomboShooter fut le plus gros carton de Fun Xtreme en 1993.
Les livraisons sillonnaient déjà le Kentucky quand tout a basculé. Hélas, l’apocalypse ne faisait pas partie de notre plan de gestion des risques, le service client est définitivement hors ligne.
Si vous mettez la main sur l’un de ces camions, considérez son contenu c...
i doubt storm even works without modification in b42, there's no standard of any kind for java modding
a couple mod loaders get made a year but nobody makes any mods with them, and if they do they're very niche mods that don't get any attention
For french speaking people: 100%
Im starting to need leaf as the last file I edited is 4000 lines to change 2 functions lol
getCapacity/setCapacity -_-
Java mods are also very unpopular on Steam, so many people feel obligated to tell you that they won't install a Java mod.
No its just people are....
deletes several comments on his mod because of above
And thats why Summer car actually is standalone from the java mod, Realistic Car physics
and infact, people playing without realistic car physics can play on the same server as people without.
Plus it basically rewrites car physics from scratch to actually be.... car-based.
In theory you can ask people to alter there PZ classpath...
But given the number of people who can't copy a folder, I don't dare tell people to edit a carefully formated configuration file.
In multiplayer, does anyone know how to make the in-game avatar sync'ed with the player's clothing when I equip clothing on server via the command player:setWornItem(bodyLocation, clothingitem)? I tried all the following commands:
sendEquip(player)
sendHumanVisual(player)
syncItemFields(player, item)
syncVisuals(player)```
also all of them together in that particular order. Nothing worked for me. The avatar is completely out of place when it comes to sync for me.
What's the emoji for "I'm laughing because the alternative is crying"?
Also, great work on realistic Car physics and when I never put aside time to actually Play a proper game of Zomboid I'm keen to try out Project Summer Car.
That's where I don't agree and there's clear proof they can be popular
Nothing is stopping you from making a script to do it
It's a json file you need to edit
Thanks! means a lot :0
I guess. Just not sure what kind of script and if steam might puke at it or something.
steam lets you upload exes, it does not care whatsoever what you upload
-_- scary.
as far as valve is concerned if you upload a virus it's the game's fault for running it, not theirs
lol
If you can upload arbitary java files that the game executes then security is a not a concern.
Could be worse though; at a previous job we had a web application so badly designed that the penetration testers described it as "SQL injection as a service"
I know this isn't a popular question, but is there any chance we could develop some sort of mod that allows characters to fight bare-handed? (in b.42) I'm talking about something balanced, nothing overly OP. A series of punches or kicks that can slow down, stun, and knock down zombies (without killing them!), an alternative to pushing (which I've been sick of for 10 years), with the appropriate penalties.
is it that impossible to achieve?
Is there anyone willing to make something similar to the "Brutal Handwork" mod, but without bugs and slightly more accurate?
You could do it ?
If only I could... ^^'
My English sucks, so I apologize. I'm not a native English speaker. I wanted to ask if anyone was capable of achieving such a feat. Apparently, it seems very difficult.
It's not THAT difficult, there's already proof it's doable with the brutal handwork mod
It doesn't work.....
Not in B.42
The idea I wanted to propose was to use a hand-to-hand combat system, obviously by those capable of it with the appropriate skills, that could only slow down and temporarily knock out the zombies, but not directly disable them.
I'm gonna do a mod like that at some point soon, just gotta get through the other mods I'm working on first lol
Of course it doesn't work you need ro update its file structure and possibly some few things in the code
But updating mods isn't that hard
Really? 😮 Can you satisfy my curiosity? Actually, two. I've seen online that punch animations (at least 6 or 8, counting the left and right punches) are theoretically already available, like those used in the Brutal Handwork mod. Why can't they be used as easily as the other weapon animations? Second question: would it be possible to make kick animations as well? Or is it too difficult?
I don't think it's as easy as you say, with all due respect, Dhert has been unable to solve the problem of his mod for about 2 years
The problem is that when unarmed you can't actually attack, you can only push. So to make a punch while unarmed you have to essentially replace the push with your own punching animations. Weapon animations run on a completely different logic and you have access to stuff like crits and alternative attacks.
Theoretically you can make any sort of punch or kick, or even combos.
The video is as far as I got when I worked on it last, basically just a proof of concept.
I stopped because the player rig I used (paddlefruit's) had a bug, but that has been fixed now so when I have time I will revisit this mod
I plan for it to be a full hand-to-hand combat mod, with different techniques and fighting styles, that has skills and unlockable moves, including combos and stuff
Wonderuful! Yes, I understand... in fact, this alternative combat system could be created, activating it with a specific button of our choice, so as to differentiate it from the basic one used for pushing, etc.
It would be truly unique
I'm not saying it's easy but I've seen first hand what the animation system can do and I'm fairly certain it is doable, and like I said that mod already did it tho I'm not familiar how he did it, I know it's still doable
We can see that rotation bone bug very clearly here haha
I think the ctrl key for alt attack was the right way from brutal handwork
Haha yuuup 😄
if i wanted to decrease all melee damage what would it be? local function modifyMeleeDamage(baseDamage) doesn't seem to work.
No idea what that function is but you'd have to modify the item stats directly
thank you. so it's impossible to set a multiplier for melee damage that would affect all melee weapons without setting specific values for each individual weapon, right?
Nop not to my knowledge
Pinned comments would be lovely... but then again, not like anyone reads those
You can already pin discussions anyway
And people will still not read those yea
Yeah, but if you could just pin comments though
I HAVE so many "bug" discussions, but noone even uses them and all reports (around 95%) goes into comments
I do believe there is a way, b42.13 introduced a bunch of stuff for us to use. I'll be home soon, I can show you
look into CombatConfig on the javadocs https://demiurgequantified.github.io/ProjectZomboidJavaDocs/zombie/combat/CombatConfig.html
That's it yeah, I haven't played with it yet but it looks like it should work
👀
i have a big issue
my tattoo parlor mod relies on creating custom body locations and moves it to the top of the render under bandages
now the way b42 handles it is very unpleasent
It's still doable I believe
@winter bolt probably knows how
they added a function for it
group:getOrCreateLocation(name)
group:moveLocationToIndex(name, 0)
is it me or fbx animations are not reloaded anymore ingame with the new PZ version ?
I haven't heard of anything like that
@thin swan can probably confirm that's still a thing
They are yeah, but it doesn't show in the log anymore that they reload
Do you do something else than replacing the file ? because mine are not replaced, but they are once I restart the game.
No nothing special, just copy-paste and replace
and you hav played the animation before replacing it ? 🙂
@thin swan are sounds even synced in MP when issued by the client?
definitely something weird with it -- this has never worked for me, even in b41
Im doing it in java, but iv been able to create BaseSoundEmitter's and load them up with sounds
and adjust volume/pitch
playSound should be networked
because in my experience you basically always don't want it to be and have to use playSoundImpl instead to get around it 😅
actually, i suppose it would make sense if b42 doesn't let clients network sounds anymore
yeah definitely
if you use playSound yes, but then other players can't control the volume of the sound emitted from the player with the emitter, so it plays at maximum volume
sorry. I also got it ok when I call the animations from true dancing, but not when I was doing it from the animation viewer
Probably I just messed up again
Iv been using playSoundImpl, but you also have to multiply the volume by the sound settings in the game because the master settings don't work automatically?
(no, I have no clue what the Impl means)
and I pass it a null object too soooo shrugs
wtf does the Impl mean?!?
implementation
eli5?
it's typically considered an antipattern to do this, but it's the actual implementation of playing sound, playSound just calls it and then does networking stuff
Yea pretty sure when I looked into the game code they used Impl more then playsound so I went with Impl lol
or maybe thats just how all the car sounds are done
recipe works in sp but not mp, any idea why? It creates the base.Mov_Jukebox
yeah a better name would just be playSoundLocal
you wouldn't necessarily not have internal functions for the implementation of things like that but when you do it would always be private
works fine in singleplayer, makes the noise like the action starts in MP and then just fails to do anything
even in admin
@bright fog yep I think im just going to disable comments
people are too stupid and demanding, 90%+ of the bug reports are due to other mods and im sick and tired of trying to reproduce shit.
Finally you got your brain back 
and all the comments are 'derp how do I do thing thats in bolt 42point font in the mod description?'
it took you this long? 😅
See https://steamcommunity.com/sharedfiles/filedetails/?id=3564950449 for my last couple comments
I had hoped some peple would at least be like "cool mod! I love it!" or give useful feedback on fuel consumption and shit but my god its like pulling teeth just to get a user to admit to how much fuel they actually used between two points, and if they are using realistic car physics or not.
Literally faster just to test shit myself.
yeah you can't let yourself get stuck in the whirlpool of that bullshit
as soon as the comments stop being useful to you just turn them off
Bro literally complains about me locking his thread and no investigation after I try to reproduce his stupid bugs clearly caused by another mod that extends PSC and was much higher in the callstack.
I have an insubstantial resource that's collected on zombie deaths - I don't want players to be able to interact with it, so the amount is stored in mod data on a special item they have to have in their inventory.
I want to be able to use this resource in crafting items, so I think the best approach would be to use onTest and onCreate in the recipe to first check that the special item has enough of the resource, and then update the special item to remove the used resource after the craft, respectively.
Does that make sense, or am I missing a simpler approach?
Sounds good. You could maybe use 'usages' of the item to make it automagic? (though I dunno if the game is currently bugged on using usages of items properly or not)
(usages like how lighters/matches have them)
plus might show how much of the resource you need in the crafting UI better.
Ah, I was wondering about a way to indicate "fullness". That might be ideal, I'll look into it. Thanks!
I'll pay someone to finish developing a mod I've already started, I just don't know how to wrap everything up. It's a clothing mod. If you are intrested plz dm me
If it works the same as item condition and other item related stuff like attachments applied on a weapon, they use signed bytes, so any value above 127 doesn't get saved when you exit the game. It might be the same for usage, so just double check that
The unofficial Zomboid modding Discord has a commissions channel. You probably want to give a bit more info when you post there, so it's clear how much work needs to done.
Brave of you to throw this type of message in public discord, your DMs will get swatted with scammers and bots.
I said the C word once in 20 diggity 9, and they are still sending me scam dms.
they get upset for some reason when I tell them people pay me.
Ummm there are some insane cursed thing about usage like... its stored as a FP value but rounded to int or something...
I forget exactly I just remember becoming violently ill upon reading the sourcecode.
nice thank you.
When in multiplayer, it may happen that the server finishes a TimedAction's complete() function before the client finiishes perform()?
Hello!, im new to project zomboid modding, i would like some basic code snippets including some basic commands that i can use (for example, a script that makes the player constantly nauseous) so i can reverse-engineer something
if this is too much to ask, could anyone point me in the right direction?
Hoping Omar's infinite wisdom will make a grand appearence again, but I'm overriding a game function where the player creates a faction. I need to figure out how to pass the ISOPlayer that initiated the command, but I'm at a bit of a loss on how or where I would get the ISOPlayer.
Lua Code:
LuaEventManager.AddEvent("OnCreateFaction")
local _createFaction = Faction.createFaction
function Faction.createFaction(name, owner)
local faction = _createFaction(name, owner)
if not faction then
return
end
triggerEvent("OnCreateFaction")
print(owner)
return faction
end
for the code snippet you're after, it'd just be the following line;
local player = getPlayer()
player:getBodyDamage():setInfectionLevel(100.0) -- 0.00 to 100.00
honestly, the best way to start is by reading the wiki page on modding, which gives you a few pointers and tutorials. at the bottom of most of the modding pages is the Navigation section, which details all the articles related to modding
thank you
PZ modding is thankfully pretty easy, esp when it comes to player stats. you could randomise every player stat every second if you wanted to
as well, you should write down what your mod does, itll help you out with the programming later as well :)
Hey, someone know where i can find this function :
OnCreate = ItemCodeOnCreate.onCreateFlier, ?
I need to improve it haha
There's also the new top part of pages which links to pages
ooo, sweet, im sure boi will survive with what we have tho :))
Yea but I need to improve navigation on the modding wiki
Overall I suggest checking the main Modding page first
This is the main sequence yes, in MP. the server completes first and that causes the client to perform.
Any suggestions why my custom vehicle part install/uninstall TimedAction is instantly rejected ("state" : "Reject") in mp, but works fine in sp and with vanilla parts (B42.13)?
Do you have an isValid?
Um. Not sure what that is
I assume for the TimedAction. I haven't really used them yet, but do you need to configure custom TimedActions for non standard vehicle parts in mp?
Like function MyCustomAction:isValid()
This seems to be required now
You can just have it return true, or set some conditions that makes it true which will make it proceed with the action
Also, do you have the actions .lua files in lua/shared? This is also required now since timed actions run on the server
Nope. Haven't done any TimedActions for this. How should it interface with the vehicle part script? I thought all the parts were handled automatically by some generic action
OOOooooh, sorry I misunderstood, I thought you were making a custom action. But you just have custom vehicle parts that you're trying to attach just using the vanilla action, right?
Yes. That's right
That's a bit trickier then, I can take a look soon and see if there's any specific conditions that needs to be met
It runs fine in sp, just "add action" and "remove action" printed once. In mp it does multiple cycles of start and remove action with the remove state being "Reject". I have the install and uninstall test set to constantly return true. (Also I can't change the part condition in mp using the mechanics cheat, unlike other parts)
Ok I figured out what was causing the problem. I add the parts during startup to all vehicle scripts, and it seems to result in invalid TimedActions for them... Anyway thanks for you help! Might need to do them manually then
For some reason, having setGodMod(true) only works when debug is enabled, is there anyway around it?
Most likely not no
It's locked behind anti cheat measures now
What's your goal ?
Im making a mod that lets you use one of the ingame dices and roll the dice to get a positive or negative effect, getting god mode would be one of the positive effects for a short time (1 ingame hour)
Anyone knows a better way for me to make a "constant pain code"? I keep getting errors, my plan was to make a pain which forces you to constantly be on painkillers. (lua/client)
What error are you getting, and what version are you working on?
you are getting errors because some of these functions don't exist, are you using ai?
Not really sure where to ask this, but this seems to be where anyone would know. Can anyone help me with how to move a vehicle by cheat? (Or whether it's even possible?) I have a really nice truck that phased into my basement from a bug and I'm trying to get it back out, as it will be a pretty long walk to get a new car.
I've tried to use the command console in debug. I got the vehicle by using getPlayer():getNearVehicle(), but :setPosition(x,y,z) doesn't work as the vehicle phases out (presumably to where I want it) in one frame but comes right back the next frame.
Hey, someone know where item icon is in the media folder ? Didnt find it in the texture folder
is there any getPlayerFromUsername() equivalent on the server side? getPlayerFromUsername() doesn't return anything when used on the server, and using getPlayerByUserName() just results in an "attempt to call nil value" error
Hmm, someone knows if there is allready some API for all the atmospheric stuff in B42 (Oxygen, Gasmask, fumes etc..)
Hoping Omar's infinite wisdom will make a grand appearence again, but I'm overriding a game function where the player creates a faction. I need to figure out how to pass the ISOPlayer that initiated the command, but I'm at a bit of a loss on how or where I would get the ISOPlayer.
Lua Code:
LuaEventManager.AddEvent("OnCreateFaction")
local _createFaction = Faction.createFaction
function Faction.createFaction(name, owner)
local faction = _createFaction(name, owner)
if not faction then
return
end
triggerEvent("OnCreateFaction")
print(owner)
return faction
end
im working on b42.13. im new in coding mods for zomboid but it looks like the "setpainlevel" didnt work!
plus, i dont think my logic is working. i want the pain to fade in as the time goes by but im pretty sure my code is trying to make it constant
owner ?
Returns a string, not an ISOPlayer
Is that a client sided function ?
Although thinking about it, I could probably make a function that uses a username as an arg and find it that way
I believe so, it triggers when you create a faction in Multiplayer
Oh wait, it's in my server folder
You need to know when that triggers for you to properly mod that in
It triggers the moment you click Create Faction after supplying a name, I can confirm it does that because the OnCreateFaction trigger can be called elsewhere
well TIL :o
That doesn't give any indication of which side it triggers
If that's the receiving end of the player creating a function, then it's server sided, if it's the function that sends the info to the server then it's client sided
You need to go read what that function does to understand which side it triggers on
that makes sense, ill dig a little deeper then. Thanks Sim!
the string is the username, use getPlayerFromUsername(owner)
@bright fog Man its nice waking up to NOT another list of bugs due to other mods and people who can't read the FAQ nevermind the mod description

We used to be able to change tile definitions when the game loads. Of course 42.13 doesn't like this command, has this changed or been removed? properties:Set(IsoFlagType.container)
related methods were renamed https://demiurgequantified.github.io/ProjectZomboidJavaDocs/zombie/core/properties/PropertyContainer.html
LOL! Thank you, it's literally Set vs set... 🙂
There was a massive recapitilization for B42.13
95%+ of porting realistic car physics was just me renaming variables
I understood Val to get and Is to has... I had no idea they changed Set to set and UnSet to unset. crazy, thakfully find and replace is my friend.
Thank you guys for bludgeoning into my head. Took a minute to sink in.
most of the affected objects weren't API, that's a java modder issue
Yea but im'a still whine about it. I even had to rename various vector3f's that are only used as temporary storage!
I was like ".... but why?"
I know items are server controlled now, will they or have they implemented a command to add an item to a player from the client as before? Perhaps a command that the client initiates and the server responds to it? So far I have been doing it with client server send commands but it seems redundant for every mod to do that.
no
Well after decompiling and check that gas mask system myself a bit to understand what it´s actually protects me from, I am a bit dissapointed. Had hope they had somehow...allready a bit more in it , or well.. maybe I expected simply some atmospheric system but thinking of it, I think, they never really talked much about it in their blogs...eh well..time for my bed.
Best you'll find is the additem cheat menu that only works if your admin
yea iv never bothered to use em 🙁 might be cool with mods that add infection by air
but prob just annoying
Like basically they don't want you giving clients unfettered access to create any item they want.
because.. that is exactly the kinda thing cheaters exploit to create any item they want.
by having item creation be based on timed actions that are run (moreso) server side, the server can verify you have the items/materials/conditions/etc required to do <X> and only reward you with <Y>
also makes it harder to cheat on things like skill passes/fails, etc.
I get it, until I learn that system I will figure out a way to make it work for now. 🙂
yea, the nice thing about timed actions though is they do the 'networking' for you
the constructor gets 'replicated' from client onto the server, and then your complete() function gets executed on the server for you.
It changed timed actions from 'Why do I have to create another one of these stupid things for everything I do' to 'oh, yea, a simple timed action will take care of all the networking and half the syncing stuff for me'
plus timed actions just feel better
the ability to have a sound, animation, item held in your hand, etc and the actual action to take at least SOME time, even if its like a token 2 second delay, just makes it feel like your character is really doing a thing vs you just clicking a UI
i still think they're awful to work with and 99% boilerplate
it's just nice that you don't also need the commands boilerplate on top of that anymore
Sure, they could have been implimented a bit better but oh well.
at least they have some 'magic' to them now
and give people a more standardized way to impliment secure actions
it's not really 'standardised' it as much as it's made it possible at all
genuinely trying to make anything remotely secure in b41 was a complete waste of time, the client could do anything and any new exploit your mod exposed was not as bad as the exploits already available
When it comes to anti cheat, have the TIS devs said anything about whether they want to expand their anti-cheat system further?
Currently they make anything which requires stats or objects changes and creating to only be allowed server side
Is adding an item to the backpacks of zombies possible through a distribution file similar to the (procedural or suburbs distribution file) or does it require a more bespoke lua function?
Yes
I never remember where tho
When writing stuff to the player's modData only on client-side when in MP, they won't be stored permanently and will be lost when the client player logs out from the game?
Yes
no
In b41 player mod data is stored on client. In b42 it's stored on server, so if you modify it on client you need to synchronize it using player:transmitModData()
Hi everyone!
I'm trying to build a mod for the first time. I'm a bit confused how I suppose to add a trait.
I followed the pzwiki modding guide and also took a look how mods, like MoreTraits, do it, but I missing something when I try to build it from scratch
Any suggestion?
Never mind, it was just a typo 🤦♂️
transmitModData sent by a client will be rejected by the server, if you want it to be stored you need to make the change on the server
So I am trying to manually send my modData to server. The modData is a nested lua table where the data are all strings and integers. Strange thing is that when receiving the command from client, the server says the args are nil.
Here is my code from client:
sendClientCommand(player, "rasBodyMod", "createPlayerOnServer", {modData = data})```
My code on server:
```local function onClientCommand(mod, command, player, args)
if mod == "rasBodyMod" then
if command == "createPlayerOnServer" then
print("TEST_OUTPUT ", args) -- outputs "nil" !!!!
local data = player:getModData().RasBodyMod
if (not data) or (not data.ModVersion) then
data = args.modData -- error because index modData of non-table: null!!!
end
sendServerCommand(player, "rasBodyMod", "createPlayerOnClient", {modData = data})
end
end
end
Events.OnClientCommand.Add(onClientCommand)```
Is there anything obvious I am doing wrong here? I think sending nested tables with only primitive data works in other situations for me.
i can't see anything right away
the issue probably isn't to do with the contents of the table, invalid pairs just aren't sent so at worst you should be getting an empty table
Its strange since I can reproduce the error whenever I run the code. And it is not "args = {}" but literally "args = nil"....
ah, i see
if args is empty, nil will be sent
if player:getModData().RasBodyMod returns nil then your table would be empty
so that's likely it
Ahhh! That makes sense! So it is pbbly only a pure lua issue since a table with {key = nil} will simply not be created?
and yes... in that situation, it is indeed possible that data is nil, so...
it does creates an empty table, but sendClientCommand just ignores empty tables
i didn't actually know about that behaviour, will have to write it down somewhere or it'll get me too 😅
Good to know. So I should add some general if args == nil checks to my server code to prevent bad client-cheaters from generating server errors. XD
Also, when trying to store the modData on server, is it necessary to do it "field-by-field"? In my above code on server, I just do
data = tableComingFromClient```
This does not seem to work currently. Maybe I have do it field-by-field instead? Smth like
```data["key1"] = tableComingFromClient["key1"]
data["key2"] = tableComingFromClient["key2"]
-- and so on ...```
?
local data = player:getModData().MyMod = create a new local variable called data, and set its value to player:getModData().MyMod
data = tableComingFromClient = change the value of the local variable called data to tableComingFromClient
you're not changing the table when you do that, only which table the variable has
so, then
data.MyMod = tableFromClient```
should do the trick?
yes
Stupid mistake by me. lol. Should have known and have used it 1000s of times correctly. But MP modding is so complicated for my mod. So I am a bit mentally exhausted at times...
Any guidance on reporting bugs found from modding? I reported a CTD bug that occurs whenever aiming a gun at a zed who has has zed:setSkeleton(true) and it was moved to a "mod help" forum. I have another I need to report and just need some steer
A CTD ?
Crash to desktop
Really ?
I suppose my mod is a bit fucked lol ?
https://steamcommunity.com/sharedfiles/filedetails/?id=3351438259
lol. Ye. It will be.
That's recent
Also I'm surprised they moved your report to "mod help" forum
Because modding bug reports don't get moved like that, I've made a few without any problems
What did your post look like ?
I had to put a big fat warning on mine and make the "skeletons" option default to false https://steamcommunity.com/sharedfiles/filedetails/?id=3532685233
I have mod that calls zed:setSekeleton(true) If a player subsequently aims a gun at them, it then causes an exception access violation inside PZBullets.dll A couple of different users have reported this. Attached is one of the users dumps. ChatGPT review of the users dump-> https://chatgpt.com...
That's your bug report ????
Maybe was just the wrong format or someone assumed I was complaining about a bug
You didn't even follow their template mate 😅
with a mod
Version: [42.12.3] Mode: [main menu] Server settings: [N/A] Mods: [Controlled example mod to reproduce bug] Save: [doesn't matter] Current system: Linux Mint 22.2 (was present in 22.1 from my knowledge) Reproduction steps: 1- Create a simple example mod 2- Define a mod.info file for your mod, pla...
This is how you report a modding bug 😅
True, but it also states mods have to be disabled... so... meh.
Yes but when you know what you're doing and how to do control tests, it's fine
Often in my bug reports here I mark it as a controlled example mod used
And I provide the full mod in the report
Usually it's a few lines of Lua and it's enough
In your case it's extremely easy to make such an example code
Sure. Makes sense. Ill go make sample mods to demonstrate the issues
Problems with your report:
- you don't follow their template
- you don't provide a simple controlled code to trigger the bug
- you provide a log file that doesn't give any info on the problem (you're supposed to give your console.txt)
All right dood. Ill be way more vigilant in reporting bugs
I just saw too but you don't even provide steps to reproduce, and you provided a fucking chatgpt chat log ???? 😭
Geezus man, I was just trying to help
My bad
Don't sweat it, Ill not report any other issues without a full example installation and detailed walkthrough to repro.
Hope this is sufficient to simply demonstrate both. Ill update the other links and remove the chatgpt link in hopes it dries your tears! https://github.com/PhunZoider/PhunBugs
@trim yacht why do you use saveGame in the first place ?
To save the game before shutdown. Is there a better method to save the game that I am unaware of?
Why would you do that ?
Its part of a mod that triggers a controlled shut down the server in the event a mod updates. Many hosts will auto restart or others use cron or other services to restart the server which in turn updates the servers modlist so your players can connect
Yea so that's udderly up to date or whatever it's called that you're readding ?
where should i start with making a mod that just rotates rifles attached to the back to have their bore up
:o had no idea this existed. thank ya 👽
I have an item that, onCreate, gets some mod data generated for it to hold a custom property. This is fine when the player crafts it, but what about when it's spawned as loot in the world? Does onCreate get called then, too? edit, it does, according to the wiki: "...when the item spawns."
Aside: is there a better way to track some custom property for an item - a read-only value that just needs to be looked up by certain custom lua actions? Or is mod data The Way?
mod data is the way
I just went into a barricaded house when trying a pseudo playthrough for mod testing. I think I've heard about those.. good times.
wdym?
That's RBKateAndBaldspot.java
Since pre-defined custom building adjustments are done via "Random Buildings" but restricted to only being possibel in one location.
And they are hardcoded in Java because why should it be easy to add more content via lua scripts when you can hard-code it all into custom java classes instead?
Is there a good place/resource to learn PZ Mod Making? I know the JavaDocs and LuaDocs exist just... idk reading documentation never has worked for me, i need to more follow a guide to be able to understand it, like its all well so say:
isoObject
IsoObject ISBuildPanel::isoObject
but this doesn't really tell me much
The wiki
Hello,
I have questions.
This line work in B41 : player:getStats():getAnger()
But it don't work on B42.
why ?
what is the same line in B42 ?
Has the mod structure been changed in build 42.13?
Not the file structure per-se, but there's been some significant changes.
For example items used to be set up to use Type = Weapon, in b42.13 it's now required to be ItemType = base:weapon
There's a few other things like that, but the file structure for mods is the same.
You can check the documents here for more info https://discord.com/channels/136501320340209664/1448602571810803785
Am i right in thinking that adding the registry.lua file in media will automatically convert identifiers?
or am i dumb?
Come up with a mod idea, find a mod that does a similar thing, see how they did it, make your own mod. (don't just copy-paste code, write it out yourself so you learn & also aren't just stealing code)
Not guarantees that the mod you look at is the best way to do things, but it's a way to do things.
Seems to follow standard lua rules, except it gets loaded first. If you need to refer to your added registry thingy later in lua you can define a global variable:
NEPONFIRETRAIT = CharacterTrait.register("nep:onfire")
So when the file is loaded if calls NepOnFireTrait = CharacterTrait.register("nep:onfire") and stores the return value in NEPONFIRETRAIT
ok kool... i wish i could fully grasp what that all means, lol
so... i don't need to change anything in the script files?
looking through all the pdf's, theres a lot of changes to do
The scripts are all changed too lol
You need to use registries.lua if you need to make any new "registries" but not for using existing ones.
The syntax for (almost) everything is a bit different, since you're now refering to "registries" instead of arbitary text:
ItemType = base:weapon,
Categories = base:smallblunt,
Tags = base:hammer;base:ballpeenhammer;base:smithinghammer;base:hastoolhead;
In theory DisplayName is no longer used and is instead read from the tranlation files, in practice you can still use it and it will be the name for en_US.
The best reference is the vanilla definitions.
It's not in theory, it's a fact that DisplayName is no longer a thing
it's still functional:
I was suprised when I tested a mod and it was fine without adding the translation files.
Obviously I should add the translation stuff so it doesn't break in the future when they actually remove it, butt I have so many other things I need to fix up I'll probably forget and not do that until everything breaks.
I believe I had checked and it wasn't there in the Java ?
People had issues with DisplayName not working anymore so i'm surprised about what your saying
Bcs before it was getting obsolete and in B42.13 I'm fairly certain it was removed ?
My Lewis gun mod still shows item names without it. ¯_(ツ)_/¯
If you search decompiled B42.13.1 for "DisplayName" it's in Item.java
Maybe they added it back in 42.13.1 after realizing it was going to break too many mods without a good reason?
It wouldn't break mods that's the thing
Soooo I must be missremembering that's weird
"break" as in "WHY DOES UR MOD SAY item_base.NepLewisGun PLZ FIX???!?!!"
Do note, items without translations will end up with 0 weight... Because uhhhhhhhh.... We're in the universe where giving something a name is what gives it weight.. yeeeep... don't think about it.
No really, we're also in the universe where thinking about it too hard gives you a stroke.
displayname never stopped working afaik
what's funny about this is i've looked over the code for it a couple times and i can't work out why it works 😅 it seems like it should always be overridden by the translator, but obviously it isn't
lol
What is the thing with some recipe mods not working in MP anyway?
I don't even get how thats possible.
one of the causes is for some reason only module base works in multiplayer
... of course it does.
man am I ever glad I don't follow best pratice but lazy pratice instead.
for all the modders TIS hires, it sure would be nice if one of them made a test mod that had to be validated as working by Q/A whenever they change stuff.
or just.. impliment stuff like namespaces
Isn't there like, 5 different bugs with namespaces now?
if you press escape and select quit while in the Animation Viewer, the Animation Viewer is hidden by a "black quit screen" but quit is not yet engaged letting you (at least me) think the game is stuck. In fact it is not, the quit sequence is just waiting for the Animation Viewer to be exited: press escape to get rid of the black screen, click exit and then the quit sequence continues.
Hi, can anyone tell me how to fix this problem? When I attach the trailer to the car, the trailer starts moving at a distance, not with the car.
Don't be like me, and rage Alt+F4 
did you attach it with a rope ?
Yes, I connected it to the car.
You must have 'trailer' in the base.trailerthingy name of the trailer for it to act like a trailer
else it tows like a car.
(not the translated name, but the ingame script name)
Where can I check it?
post your cars .txt file
module Base
{
vehicle ModernCarLightsCityLouisvillePD
{
zombieType = Police,
specialKeyRing = Base.KeyRing_EagleFlag,
model
its the part after vehicle
it has to say vehicle McTrailerFace or something. has to have 'Trailer' in it (case sensative?)
(yes, that is literally how the game detects trailers... and there are checks for it all over the codebase)
{
vehicle vehicle_trailer_LastPresident
{
neverSpawnKey = true,
mechanicType = 1,
offRoadEfficiency = 0.8,
engineRepairLevel = 4,
playerDamageProtection = 0.8,
model
{
file = Vehicles_TrailerAdvert,
scale = 1.82,
offset = 0.0 0.6813 0.1813,
}
The trailer is specified
Sorry, my translator may not be showing the translation correctly
if (!this.getScriptName().contains("Trailer") && !vehicleB.getScriptName().contains("Trailer")) {
I hope your not translating that file lol.
"Trailer" not "trailer"
Thanks
thats what im trying to do, however it doesn't seem like there is a mod that does what im trying to do, or at least a functioning mod. The closest I can find that has parts of what I want is the Working Air Conditioners mod, as that connects to Power (either grid or gen) however I cant figure out how they are doing it 😂
has anyone yet found a way to reliably set the infection level echaracter stat to a specific number? the set function for it gets overridden for some reason due to the infection timer, and the only way i can change the infection level is to set the infection timer to -1, wherein the infection level resets to 0. if you set the timer to 0, the player instantly dies. i cant figure out any other numbers that actually do anything. has anyone figured out how this works because its kinda a black box for me
infection time is literally the timestamp that the player became infected
instead of accumulating infection level the game just calculates how long it's been since the player got infected and sets their infection level based on that
-1 means they were never infected, 0 means they were infected at the very start of the game -- this kills you because it's likely several days ago and you would have died of infection by now
ohhh my god that makes so much sense
how is the timestamp saved? hours, minutes, etc?
Heh, always thought it was weird there was 'everyone is infected' setting for infection
Hi all, working on a little mod right now, and I need some help figuring out if I can create a new fragment shader, replacing the car fragment shader, and then pass it arbitrary parameters from lua. I've been looking for a bit into how other mods might do it, but so far I have not seen any that do specifically what I want. I decided to come to this discord server to see if anyone else has tried this, or if it is not possible at all with the functionality that we are given
I do know I can replace the car shader
However, I would like to do that, and then also pass it new float/vector parameters (no new textures or anything)
you cannot add uniforms
well crap.
Yea you'd need to poke at the java
that's kind of what I was assuming... Unfortunate...
what effect where you trying to add?
Essentially the idea was to be able to have car parts maintain their own colour vector and then when being attached to a car, they would be a different colour from the base car.
You can always biggy bag on the already existing variables. Very limited and a little jank, but I do it with my license plate mod
that is what I was going to think about next hahah
Ahhhh.... Kinda pain though lol
yeah, I am sure it would be
Not too many people swap car doors and stuff around either
yeah i actually looked into exactly that but couldn't see a way to do it
Yeah, that is true in most cases, unless you're using another mod that spawns vehicles without doors/hoods/etc (project summer car)
Ok guilty as charged...
I was able to pass the shader 48 bits without negatively affecting anything
hmmmm.........
Could be more if you try harder, but that was enough for me
Mental note, never shrink a window past oblivian size.
Nope. Haven't finished it
oh okay
That one uses UI
48 bits would be enough for a colour
gotcha. I just searched up license plate and hoped to find your thing hahah
yea in 8bit int
could manage to do a colour in 24, so you would get two colours with 48
TBF if you don't mind 256 color pallette you could fit... 6 colors in 48bits?
did you try passing more?
would I be able to ask to see some of that code btw? I am curious what you piggyback off of
it should be enough room for 16 bit colour
Not yet. I used it for 7 characters and few bits for different sizes and color modes
ah
IIRC the opengl space is something like 2048 uniforms (or was it 2048 bytes of uniforms? something like that)
so if it handles bigger types it might handle MUCH bigger types.
The vehicle color is passed as vector3 of 32 bit floats while you only need 16 bits of float for displaying 8bit color... So you can make the rest anything without it showing
it is certainly not just 2048 bytes, textures are uniforms
ahhhh, okay makes sense...
actually, I wonder, are you allowed to make more visible components than the vanilla vehicles have? Eg. 6 doors, 8 doors, etc etc
You can make custom parts with models
They disappear when you remove them, but they can't have separate overlays. You have to use one of the existing mask segments
Yes. But if I remember correctly the removed part array was handled in java. If you pass the part condition other way, then you could make it work. Just add new mask colors to the shader and handle them the same way
Power is weird. (And also changed since I last dealt with it). What is your mod going to do?
power is probably the most egregiously hardcoded system in the game
yeah exactly
okay hmm
Community server I play on wants to to have AC Radios, like radios powered via the Grid or Generators, so like being able to take a ham radio and idk adding 1 electrical scrap to turn it into an ACRadio [Ham name] would be nice then then it just has the placeable tag and not moveable or whatever it is. Like i can find in the javadocs hasElectricy() so I should be able to do square:hasElectricty() for a power check but its the converting. A lot of the powered radio mods just do UseBattery = FALSE as I assume they look at the TVs code and see that, but they dont actually do a power check or anything else so a hidden battery is there and just drains away so once the "Powered Radio" stops working you have to change the batteries out lol
idk like i'd like to look at some more usecases for coding, sure i could look at mods themselves, but idk reading the few mods ive looked at none of it makes sense to be lol
is it normal that a call to myIsoGridSquare:getS() returns nil ? is this interface obsolete ?
According to TIS' new API doc from their website, we can use item:syncItemFields() to sync the item's weight we manipulated on server-side with the client. Can anyone confirm that this works as intended? Because for me, it seems to not work.
it is not unusual for a square to not have another square to its south (e.g. it is part of the second story of a building) if that's the problem you're having
in that case it would be expected to return nil
it was at level 0, loaded and my character was around.
I must have messed something up but I do not know why.
Anyway I use getCell:getGridSquare and all is good.
it's possible that it just doesn't work properly anymore, i have used it in the past but not any time in the last year at least
So what you really need is for me to fix Plug Your Radio In. 😛
Recent changes to the way power works broke the mod (it's now a "hide the battery from the UI" mod) and I need to figure out a fix for that
we tried your mod and then Powered Radios which both dont work
i wonder if a fix could be as simple as setting battery life to infinite some how while inside Radios
I feel like the fix is making it recharge the battery (and not allow you to remove it if its been recharged? at least not till dead) when plugged in?
though that might make a lot of batteries harder to get...
When the battery is inside a radio there is no battery object. There is just the radio. When you take the battery out you get a new battery object.
So the fix needs to find where the radio charge is getting updated and do something there
Since setIsBatteryPowered() no longer works properly
Or do what I did for nutrition, just do the exact opposite.
ie, if it discharges at 0.4 units per minute when on, you just charge it at 0.4 units per min when on.
And how exactly do you charge it? That still required finding a way to edit the radio's charge AND fidning where that gets changed normally
Or record its current charge in some backup mod data, and once that charge is stored, ignore the vanilla charge
Again, how do you ignore it?
Oh, that'll likely be the mod data. one second.
That is handled in java.
do you know the class name?
dumb name lol.
isBatteryPowered is how I managed this previously, but that no longer works.
Not going to argue there. 😛
It does radios/CD players/TVs.
Hmmm
float pdmod = this.powerDelta - this.powerDelta % 0.01F;
this.setPower(this.powerDelta - this.useDelta * (float)diff);
if (p > 1.0F) {
p = 1.0F;
}
if (p < 0.0F) {
p = 0.0F;
}
this.powerDelta = p;
}```
is DeviceData exposed to LUA?
Yes.
yea, so id try setPower
public void setInitialPower() {
this.lastMinuteStamp = this.gameTime.getMinutesStamp();
this.setPower(this.powerDelta - this.useDelta * (float)this.lastMinuteStamp);
}
looks vaugely useful too?
setPower(1) should presumably fully charge the battery?
also i assume CarBatteryCharger code is hard coded? considering it doesn't specify what batterys can be used?
That still needs a trigger to call it
on everyhour? shrugs
Or just hook any of the LUA that radios call?
on every tick 😉
...which then requires me to track every radio in the world
track the radios someone entered the UI of?
The current hooks are when you access the UI
It does some tests and then calls setIsBatteryPowered()
Except for some reason teh power drains evern when isBatteryPowered is false.
yea its not listening to it.
I don't wantto keep track of all radios (which would likely be a performance issue to, checking hundreds of radios to see which are loaded and going through teh power checks for each of them)
looks like it should still be listening to setIsBatteryPowered though
I know! And the save/load for the variable is in the object
Nope.
Hmm.
So whatever the issue is, it's not obvious.
If it was MP only having issues then it woudl be some sort of syncing the DeviceData object issue
yea
I can't see any reason isBatteryPowered isn't working. (java code seems OK)
can you randomly log that its still set properly after you set it?
Good plan
At least I can see how to sync the client w/ server for MP: devicedata:setVolume(devicedata:getVolume())
since the sync function is private butting setting volume will force a sync
No, wait, that does not send isBatteryPowered so MP will need it's own event handler AAARGH
...but I'll fix SP first
the game already tracks all loaded radios
you just have to loop over the list every so often
thanks, I'll look ionto that as a shortcut - defiitel ybetter for performance if the game already tracks nearby radios
meanwhile I sync fluid containers by just deleting them and recreating them
(not nessecarly in that order)
That sounds easier than actually syncing them lol
If they didn't want me to sync fluid containers this way, they should have A: given me working fluid container sync for objects in a car trunk, and B: not given me a handy dandy function to copy the entire fluid container
That would be a hassle for radios, because you would need to copy all the data on stored channels/current channel/volume/battery life/etc
I'm not sure how much that will happen automagically, and it's worse because radios can be inventory items or ISO world items
Hi! Why don't my game files have all the car textures, but only a few?
who got lua soup
what?
who be doing ontick
cars get dynamically tinted too
also check the .pack file viewers/extractors
Mostly people who shouldn't, but there are legitimate reasons to use ontick. But you need to be careful careful and add appropriate limits and/or "only run every X ticks" type stuff to avoid performance issues.
im kinda annoyed there is no realtimesecond callback
minute is.. kinda iffy based on timescale
lua is only my enforcement layer i run 0 game logic on it 
i learned from five m days
its better to do event based
Hiya peeps.
For modData, does that sync for all MP players?
My mod does a check on buildings and then marks them off as complete and saves to modData. Would that persist for other players, so that those buildings would be already marked as complete?
there may be specific stuff with buldings, but generally modData can be shared by calling the associated transmitModData method (name may vary depending on the object type).
if the object is changed server side, the transmit function should be enough.
if the object is changed client side, I do not know.
oh, ok. Yea i think it's being changed server side.
IsoBuilding & BuildingDef have no mod data though ..
my mod's debug logs has building numbers, so "building 1 checked...", not sure if that numbering is used "globally" tho. but i think PZ creates the building numbering..
It basically finds a valid building, checks for valid walls, runs a chance for spawning there, then when all rooms are checked it marks the building as complete and stores to modData.
This is so the same building is only processed once, and lots of items arent spawning.
another quick question:
is this correct:
I think you need to use the ItemTag stored in the mod's registries.ua.
but how do i make it compatible with another mod?
it used to work just looking for the tag, which was the same for both mods
No, the parameter is not a string - it has to be a registry entry
for a custom registry, that means the only (sane) way to get the registry object is to assign it to a global variable when it gets created.
registries.lua:
NEPONFIRETRAIT = CharacterTrait.register("nep:onfire")
Then in a script:
if player:hasTrait(NEPONFIRETRAIT) then
Also I meant to reply to @robust locust since I was agreeing with Tchernobill and giving more info. Oops.
oh...
Same thing for hasTag, vanilla stuff is already in exported java thingies so you can do item:hasTag(ItemTag.CUT_PLANT) but there is no equivilent to get a registry entry thatt you added. You'd think there would be a getRegistyEntry(string namespace, string name) but... nope.
I was somehow using this, and it was working in it's own mod
GWH = GWH or {}
GWH.Tags = {}
-- Helper to register and store
local function registerTag(tagName, key)
GWH.Tags[key] = ItemTag.register(tagName)
end
-- Register custom tags for GWH mod
registerTag("GWH:VanillaAcoustic", "VanillaAcoustic")
...
anyone knows if exist a b42.13 mod to allow sleep fast forward in multiplayer games?
It already does that in vanilla when everyone is sleeping
in B42.13.1, I started sleeping with one character while the other was awake. when I disconected the awake one, the sleept one continued to sleep and the server stayed as gamespeed 1.
Is there something to do to synchronize the variables of my player in MP ? (those set by setVariable & clearVariable client side)
Tbh, my current impression is that around 90% of the new sync commands do not work for me (for example when changing, item stats on server, sync it with the client afterwards via the new sync commands).
Is it possible to sync manullay? Just sending a sendServerCommand to client and then manually adjust the properties on client?
If i have 1 mod adding custom tags, and another mod that references those, I dont need to register the tags for both, right?
there is, but please don't use it 😅
you don't, it will actually error if you do
that would probably explain the error im getting 🫠
so in the items script, the tag property would then just be "Acoustic", rather than "mod:acoustic".... and in the "parent" mod it has the full "mod:Acoustic"....?
both need the full thing
all those I tried worked. indicate here one that failed to get help.
how? which modname do i use then?
whatever you registered the tag with
my modnames are GWH and HMW.
GWH is registering the tag.
In HMW, I put
item.....
Tag: GWH:...
?
the name of the mod doesn't matter, it's just the string you gave it when you registered the tag
the only problem im seeing in only registering the tag for 1 mod and not the other is if they only use the mod that isn't registering it... as it isnt dependant on the other that is registering it
can anyone point me to any code example of making a server command like "/foo 123"?
i need them to work independantly
If you can't make one mod require the other, can you put a separate tag in each and just check for either tag in your code?
With check to see if the global is nil, which means the other mod is not active
I tried this on server (and in the middle of a game, not on first tick):
item:setActualWeight(0)
item:syncItemFields()```
On the client, the player inventory still shows the item's original weight, so it is not synced for me. Instead of `syncItemFields()`, I also tried `sendItemStats(item)` and I also tried to combine each of them with `item:setCustomWeight(true)` and `sendClothing(player, item:getBodyLocation(), item)`. Nothing worked for me.
Maybe it is the case that those sync commands can only be used in a TimedAction? Because I use them elsewhere.
item:setActualWeight(weight);
item:setWeight(weight);
item:setCustomWeight(true);
I already tried setCustomWeight(true), but only before I used the commands. Is it necessary to put it after????
before.
are those items in player inventory ?
if so: sendEquip(self.character)
Omg! I already tried so many variants but just not this particular combination!
Yes, they are in player inventory. Some items might be equipped, others are not.
as a reference, you will find good exemples in ISUnequipAction. for the wieght, I did it for MakshiftRaft but I think I was lucky first time
I think I alreay looked at this action but I probably didn't notice that the ordering is important. I'll give it a try now.
I am not sure for the ordering, but I'm sure it works in the end 😉
Order seems to be a thing, cause
item:setActualWeight(weight);
item:setWeight(weight);```
with the `setCustomWeight` doesn't work for me.
sendServerCommand could be tempting as it is a one solution for all problems. but there will be bad surprises / side effects over time in addition to more code in your mod
My code uses the manual send commands quite a lot already. Except for those special predefined sync-commands, it seems to run quite well. (But was a hell to implement and test everything.)
Does anyone know how I can spawn modded items into my character in debug mode or something??
I want to make sure this looks right, but it's a rare item.
Changing the order does still nothing for me. Also tried the sendEquip command. Nothing.
In debug mode and then in the in-game debug menu, you have the ItemList option. There you can spawn any item to your player inventory.
yeah, you're right, the effect is spread only once I drop the item on ground
So after removing the item from your inventory? And then the weight change applies?
yes, when dropped on ground.
i dont know. i've gotten so confused lol
Acoustic = ItemTag.register("GWH:Acoustic")
is this even correct?
i've managed to break it even more lol
you can 'safely' init a tag like this```lua
if not ItemTag.get(ResourceLocation.of("GWH:Acoustic")) then
Acoustic = ItemTag.register("GWH:Acoustic")
end
🙃 for each tag?
it does kind of sound like you should maybe just have two separate tags if the mods aren't dependent on each other, but i don't know what they do
Hmm... so the vanilla system is somewhat weird, maybe buggy by itself.
There are also similar constructions in the vanilla TimedAction ISClothingExtraAction. For me, this action is already bugged in the vanilla game. So maybe their API function are just not working properly at the moment.
mod 1 adds wall hanger for guitar, with logic to attach/detach vanilla or custom guitar
mod 2 adds custom guitars
mod 1 is doing
if item:hasTag("GWH:Acoustic") then
mod 2 was using Acoustic tag (pre update), which allowed it to be used in mod 1
mod 2 also used that tag in a recipe that doesn't require mod 1.
I think checking if mod 1 is active, if so don't register tag, if it isnt then register tag
... is that a thing
i tried:
but that didn't seem to work
to check for the tag you need the ItemTag object that you registered
not the string name
you may try to duplicate the item, suppress the old, change the weight of the new and add the new.
Okay, so I added all the items from my mod, but when I equip them in my hand there is no model in my characters hand, and there is no attack animations when I swing or anything.
Where should I start looking to fix this?
Thanks for the tip about the debug menu! It's very helpful.
im not entirely sure what you mean. I'm registering this:
registerTag("GWH:Acoustic", "Acoustic")
and using this:
Is it possible to have both GWH:Acoustic and HMW:Acoustic tags? would that count as the same tag?
yes and no
i just realised that i should be using this:
if item:hasTag(GWH.Tags.Acoustic) then
i cant stick an "or" in there and check for HMW.Tags.Acoustic too?
you can
if item:hasTag(GWH.Tags.Acoustic) or item:hasTag(HMW.Tags.Acoustic) then
thanks! im sure i tried that, maybe i missed something
its not erroring now, yay. but something is not working properly, but that's another issue
sweet it's all working now, thanks for your help!!!
Just can confirm that I observe the exact same behavior.
My current suspicion is that the data are transferred to the client correctly but the client just doesn't update the ui and thus showing the old values. But not sure, I'll do some more testing.
Hey guys. I'm wondering how to get PZ to detect a mod I'm working on. Currently I'm running the game through Proton on my linux installation, but I can certainly go with the linux build. That said, /home/<username>/.local/share/Steam/steamapps/compatdata/108600/pfx/drive_c/users/steamuser/Zomboid/mods/<TestMod>/ but it doesn't show up when I click on "Mods" in game.
It's got the "Mod.info" as well
In most cases, those problems are due to wrong folder structure. The PZ wiki explains how to set up your folders correctly.
Okay, I'll check it out more thoroughly
btw do you use proton for better performance or stability?
No actually I was just using it rn because I couldn't get native linux version to view the file
but Im having issue with both seeing it
I'm looking at a workshop mods folder structure and it does seem a little different than what i had
I'mma immatate that and also check the wiki and see what's up as well.
I do find the linux version to be running slightly better, perhaps its just placebo tho
Yes there is, and that was one of the reasons for TchernoLib, you Alzheimer! 🤯 
Okay. According to the Wiki, they suggest you develop mods with the "Workshop" thing, but I don't want to upload mine yet. I'm not even close to that stage
I may have missread that
No, you can just put your mod to your Zomboids/mod folder. Just make sure you have the correct folder structure. When in your Zomboid/mods folder, you mod's folder structure should look like this:
-myModName
----- B42
----- common
The mod.info file goes to the B42 folder. The common folder must always be present, even when empty.
In case you just mod for a newer version like 42.13, you can replace the B42 folder with a B42.13 folder (or you can make mods for several versions, then game the automatically chooses the version most closely to it's actual version). But default way is to just use a B42 folder.
that's modding for b42 btw. modding for b41 is a bit different.
Right on, that's sortta what I was figuring out as I was going through the whole Wiki. I suppose, if I have it done correctly, my mod will show up along with all the steam workshop mods that I've subscribed to. I just have to have the folder structure correct
Put the files in the "cache" folder the wiki mentions, rather
no. no need for a cache folder.
But also don't forget to adjust your folder structure again when you upload your mod cause the Workshop folder requires a different folder structure.
Right on. I think I'm sortta kinda getting it. But I will point out that https://pzwiki.net/wiki/Mod_structure at the very top
They specifically mention that using the "Zomboid/mods/" folder is not recommended for mod development
regardless, if I have the folder structure correctly implemented, I will see the mod listed along with the steam workshop stuff right
There is nothing wrong with working in the Zomboid/mods folder.
right on ;p
the reason we recommend working in the workshop folder is just because you're gonna have to move there eventually anyway
a lot of people mess up at that stage (in particular, if you don't delete the version in mods, you are going to have big problems) so we just try to skip the whole hassle
but as long as you're aware of that, there is no actual issue with developing in mods
right yeah, I suppose just make it hidden then start working from there
I saw that option and was like ahhhh there we go
not sure if this is something you guys know by now
im just dropping this info
i was trying to remove a contextmenu option and it used to be easy
it was
context:removeOptionByName(getText('theOptionYouNeedToRemove'))
but for b42
this worked after trying some other (stuff didnt work)
context:removeOptionByName(Translator.getRecipeName("RollOneDice"))
note the recipe entry in this example
Recipe_RollOneDice = "Roll One Dice"
you don't have to upload at all until you're done, the game will load your mods in workshop the same as if they were in mods, it just saves you from potentially messing up when you are ready to upload
right right, I think I get it now. I'll watch a few guides because that initial versioning and all that is a bit of a hastle given I'm on linux so everything seems a bit different, the wiki explicitly says use the "cache" folder and others telling me not to. I'll get it either way, thank you
I suppose if I start the game and there are no mods to choose from, I'm putting them in the right location, I've just got something wrong with the folder structure and whatnot
Means you made a mistake in the mod structure
Okay cool.. atleast I know that I'm in the right place. Just finding WHICH folder I needed to be messing with was the hard part 😛
erm... 😛 doesn't seem right but whatevers gotta live with my mistakes
if you don't see the mod at all, that means mod.info is in the wrong place
you may be in the right folder with the wrong structure or in the wrong place entirely
no, I see no mods at all! like, nothing is there to choose from.
but when I remove my test mod and run the game again, all the workshop mods I'm subbed to are back
Bcs your mod has wrong mod.info
gotcha
This isn't a b41 vs b42 thing—the reason you had to use getRecipeName is that getText only works for a subset of string categories (which does not include the Recipe_ strings)
Since there are only a few exceptions like this, I went ahead & made a list of global/Translator functions for them. Unless I've missed something, all strings other than these categories just use the regular getText functions:
DynamicRadio → getRadioText
EvolvedRecipeName → getItemEvolvedRecipeName
ItemName → getItemNameFromFullType
Items (outdated, unused) → getItemText
Moveables → Translator.getMoveableDisplayName, Translator.getMoveableDisplayNameOrNull
MultiStageBuild → Translator.getMultiStageBuild
Recipe → getRecipeDisplayName
RecipeGroup → Translator.getRecipeGroupName
Just to make sure I'm putting stuff in the right folder I've done a "git clone" of https://github.com/Project-Zomboid-Community-Modding/pzmc-template into /home/<name>/Zomboid/mods/ but I'm not seeing it within my mod list. Is it because this template hasn't been updated to the newest patch? Or are you simply not going to see it for some reason or the other
Does anyone know why I might have 1 hand and 2 hand weapons that when I pick them up they have no model and cannot be used as a weapon?
this is structured for the workshop folder, not the mods folder
ahhhhhh right on
OOOOOOOOOH kay. I figured it out now. This template just showed up within my mod list after I registered it as "unlisted" and that's where I'll be messing with it from now on. thank you all for the help. I guess I should have watched a few guides on this first but ALAS we're good
@bronze yoke @bright fog I said I'd let y'all know when I make this public (which I also said would be a few weeks ago, then forgot 😅): https://steamcommunity.com/sharedfiles/filedetails/?id=3652613566
Unfortunately didn't get around to making a documentation site yet, but loosely explained what's in it on the repo (linked on the mod page as "contribute"). As mentioned, pretty much intended for use in my other mods, but if you do take a look please do lmk thoughts
nice! excited to look through this when i get a chance
awsome thank you
How do we addXP in multiplayer? there seems to be no remaining LUA that adds XP in multiplayer
and GameServer.addXp(player, Perks.Strength, 10) doesn't seem to work...
(addXp of non-table: null)
nm its just addXp
Neat, I figured out how to override all containers capacity in SP/MP
including player, fridges, stoves, backpacks, etc.
now I just need to figure out all the typical container types...
this is a totally sane number of sandbox options right?
opps 2nd one should be floor capacity.
Just do high level categories (bags, player inventory, vehicle storage, world storage) and then add a blacklist and/or whitelist for people to type extra types into.
...not that users will have any idea what the internal names of things are...
i just slap this i my body locations file and put numebrs on it?
You probably want to iterate through the bodylocations to find the thing you want to be before/after and use that to get the number.
Unless you want to be at the very top of the body location list for some reason.
0 is beneath everything
Also, you need to register the body location in media/registries.lua before you can use it.
registries:
NEPBODYLOC_CLBFYS_REAR = ItemBodyLocation.register("nep:stockingbow_rear")
lua files:
local newBodyLocation = group:getOrCreateLocation(NEPBODYLOC_CLBFYS_REAR)
<optional: call moveLocationToIndex here>
0 is under bandges no ? or under skin?
well its a tattoo so yea it should be under everything but skin
under bandages not skin
In this case it's at the bottom of the error:
That's a tag right ? You need to use a custom module for these
ok so how? eg.iam dum
?
?
The error is in your registry
Fix your tag, or I guess it's a body location, registries
And properly reference the same IDs then in the scripts
its still complains
try tables
luautils.stringEnds = function(String, End)
return String:sub(-End:len()) == End;
end
something nil
where you call luautils.stringEnds?
try put print before check
print(tostring(item))
print(tostring(item:getBodyLocation()))
whats that have
i think better to use something like that:
local allowedLocations = { -- your slots list
["base:belt"] = true,
["base:back"] = true,
["base:butt"] = true,
["base:holster"] = true
}
function myfunc()
local bodyLocation = item:getBodyLocation()
if bodyLocation and allowedLocations[bodyLocation] then
--
end
end
if im not worng - inventoryitemfactory not work on 42b
now it's instanceItem
the fun thing this was working befor .13
so i guess the bodylocations are now working?
nope
wouldnt they show here if they worked?
maybe this is why its nill
what ya cookin up?
Hiya, does anyone know if buildings have any individual id's or numbers that identify it? I need to store modData that is used by all players so that the same buildings dont get processed more than once.
So its marked as complete by 1 player, the building is then ignored by anyone afterwards that loads the building?
Currently my mod stores it as building 1, 2, 3... so on, but im not sure if the numbering is decided by which buildings are loaded first near the player.
If it has some global serial numbering or something, then i can be certain that building is listed as the same for everyone
actully now it works but dosen't
i think its trying to get the body location as a string and not an object ?
Gonna cross post from the PZ modding server as well just in case:
Heya folks! I've been havin' some issues here in regards to getting some custom VHS tapes to actually spawn in the world. I've got a custom item that functions as a VHS tape, but has its own skin and has a tape it plays - you can choose the tape via debug menu. The issue I'm facing is that the item just does not spawn in the game whatsoever. Is it due to it using a custom MediaCategory? Would anybody know of a way to resolve the issue of it not wanting to spawn? Loot Zed shows it as having a 90% chance of spawning and I have rerolled the tables several times to no avail.