#mod_development
1 messages ยท Page 167 of 1
honestly caring about how hard it is to cheat with your mod is waste of brainpower
just code assuming nobody cheats
ez
same with splitscreen
Making mod support splitscreen is like making 7 PZ players happy
So just don't bother

So many ways to ruin a server.
Also, you have options if your mod is used on a server for protection against theft.
i think mb i could create a table of player ids or smth that have already told the server they have spawned in n that would be the best i could do security wise
You can request the server to send part of the code for a mod on the workshop and have the workshop copy be incomplete.
ANybody know what exactly this does? This isn't for objects is it?
declaration: package: zombie.scripting.objects, class: MannequinScript
so I have this function doSomething in shared. It's possible that it will be called from any of client, server, or shared. When doSomething is called I need to send a command to client side so I use sendServerCommand from there. But right now it feels like the client is not notified when sendServerCommand is called.
In shared I have this:
function doSomething()
print("DEBUG: doSomething")
sendServerCommand("ModGuardian", "popup", {
config,
textID,
})
end```
In client I have this:
```lua
local function OnServerCommand(module, command, data)
print('WTF:')
print(module)
print(command)
print(data)
end
Events.OnServerCommand.Add(OnServerCommand)
I can see "DEBUG: doSomething" in the log, but not the WTF debug
and no error of course
@red tiger ?
Tab 16 spacing? Are you mad?
nah I use regular tabs, just discord is adding crap
That should work.
well it simply doesn't ๐
It's how you listen for server commands.
Is it Event or Events? Would fail if you called something that doesn't exist.
module, command, data.. that's right.
it's Events from what I can see in other mods
Don't worry.. I gaslight myself every time I look at Lua code.
It's a language feature.
same for me ๐
I have to learn Lua again every time I need to read/write Lua code
I know you can send server commands to either everyone or a player specifically.
so that should be fine.
testing in singleplayer?
You can look at my ModLoader as it implements the event and command.
oh... looool
server commands don't work in singleplayer
damn it ๐
even though client commands do... u_u
In singleplayer the Java API for sending commands is not ran.
@bronze yoke could you explain the difference between sendClientCommand and sendServerCommand?
You can replace the command function in Lua so it'll work in singleplayer..
maybe I can use sendClientCommand
the name refers to the sender
_G.sendServerCommand = function() .. end
the player arg for client commands is to specify a specific split screen player as the sender, for server commands it's to specify a recipient
Then you can triggerEvent('OnServerCommand', ..);
thx, that's helpful. So if I call sendClientCommand from code in shared I can get notified in my client code?
Working on PIpeWrench has fucked me up so much. I know the dumbest stuff you can do with Kahlua..
no, clients never receive client commands and vice versa
Yes. You can however fake it.
if you want a client message to relay to other clients you have to ping it off the server
so how could I notify client from shared?
you'd have to handle it differently for client and server if it has to run on both
so maybe something like this:
if isClient() then
sendClientCommand()
else
sendServerCommand()```?
other way around but yeah basically
like this? I updated the code
It's not hard to fake the process on singleplayer.
yeah, you'd need something on the server to relay the server commands as client commands though
You'd be bouncing and triggering the event based on a state check
oh damn, pz is a f*cking nightmare ๐
yeah, my singleplayer support is usually just calling event handlers directly
PZ has warped my brain.
I also see people in here linking your events repo instead of Umbrella. 
xD
Yeah I'm whining.. so what?
the md file linked earlier? i've been out with my girlfriend so i didn't get a chance to respond to that
All good, really.
the human readable md version isn't in the stubs repo because i wanted to keep it slim
so it's not in umbrella either, though it's linked in the stub readme
Oh yeah.. link that up if you want.
Also add your donation or info in there, unless you don't want to.
on my way home now so i'll do that when i'm next at my computer
i gotta add the md to the github action at some point too
I'm trying to figure out the best way to get every time as it's spawned in on game load, as I want to change icons on some of them, but I'm not coming up with any good solutions. Any suggestions on what event hooks or what not are a good place to start looking?
how can i get the player's current profession?
iirc player:getDesc():getProfession()
is it correct to assume this?
if getCore():getGameMode() ~= "Multiplayer" then
print("we are in singleplayer mode")
end```
i think so! usually if not (isClient() or isServer()) is used but i don't think it matters
thx for confirming. Now I'm wondering how someone would detect coop mode
but do people really play coop?
do you mean splitscreen? there's something like getnumactiveplayers
You can be in a state where isClient() and isServer() are both false.
anyone know how i can get the players current cell?
i tried player:getCell() but it doesn't seem to work
isn't there a global getCell(x, y, z)?
just getCell()
all the object/square/etc get cell methods are redundant, there is only ever one cell so they all point to the same thing
player:getCell() probably should work too, i think there is one for that
yeah, i meant that i was confused why that didn't work
getRooms() returns a list of RoomDefs, but roomSpotted wants an IsoRoom
oh, should i just use :getIsoRoom() then?
yeah, try that
i wonder if there's a more direct way to get them from the building but that should work
wtf it's erroring at this part now
nvm it decided to work randomly lol
ty
server:
local function handleClientRequest(module, command, player, args)
if module == "PrisonerProfession" then
if command == "OnSpawned" then
local rooms = player:getBuilding():getDef():getRooms()
for i = 0, rooms:size() - 1 do
local room = rooms:get(i)
if room then
room = room:getIsoRoom()
local cell = player:getCell()
cell:roomSpotted(room)
end
end
end
end
end
Events.OnClientCommand.Add(handleClientRequest)```
client:
```lua
local PrisonerProfession = {}
PrisonerProfession.OnSpawned = function()
sendClientCommand(getSpecificPlayer(0), "PrisonerProfession", "OnSpawned", {})
Events.OnPlayerUpdate.Remove(PrisonerProfession.OnSpawned)
end
Events.OnPlayerUpdate.Add(PrisonerProfession.OnSpawned)```
Hey, albion, I was bored and decided to include an easter egg in my mod based on our conversation. In the neurodivergent mod I made an unused trait icon called trait_albion for Pinkie Pie 
omgg :D
I just see you in here always being helpful, plus I used to watch MLP myself and was bored so I decided to do a little sprite art 
that's so cool, thank you!
Does anyone know how to use the media\lua\client\DebugUIs\TextureViewer.lua and how to access in ingame? I can't figure how which debug tool uses it
Like, what are these files?
they sound like they might be related to the f11 menu
thank you so much! ๐
yes, that seems to be what it is
np
if you double click a cached texture in the callstack it might preview it like that
A texure using getTexture?
Oh oops. I asked for help in modelling instead of here
Hey guys, does anyone have any idea why these new animations I added are overwriting the standard ones?
<?xml version="1.0" encoding="utf-8"?>
<animNode>
<m_Name>Slinkytrying</m_Name>
<m_AnimName>Bob_WindowStruggleLoop</m_AnimName>
<m_deferredBoneAxis>Y</m_deferredBoneAxis>
<m_SyncTrackingEnabled>false</m_SyncTrackingEnabled>
<m_StopAnimOnExit>true</m_StopAnimOnExit>
<m_SpeedScale>1.06</m_SpeedScale>
<m_BlendTime>0.27</m_BlendTime>
<!--<m_SpeedScale>0.80</m_SpeedScale>
<m_BlendTime>0.20</m_BlendTime>-->
<m_Conditions>
<m_Name>OpenWindowOutcome</m_Name>
<m_Type>STRING</m_Type>
<m_StringValue>struggle</m_StringValue>
</m_Conditions>
<m_Events>
<m_EventName>WindowOpenAttempt</m_EventName>
<m_Time>End</m_Time>
<m_ParameterValue></m_ParameterValue>
</m_Events>
<m_Events>
<m_EventName>WindowAnimLooped</m_EventName>
<m_Time>End</m_Time>
<m_ParameterValue>struggle</m_ParameterValue>
</m_Events>
<m_Events>
<m_EventName>WindowStruggleSound</m_EventName>
<m_Time>Start</m_Time>
<m_ParameterValue></m_ParameterValue>
</m_Events>
</animNode>
I've renamed everything in these folders... super confused as to why these are the default anims now
Oh shit you are right!
YEeeeeeeeeeeeeeeah. I can preview textures now!
I've still been having a problem for a little bit. I'm trying to randomly roll stat boosts on a trait, and my script kinda works, I can randomly addXP but when I try addXPBoost it gives me errors. I've been fussing with it for a while and don't know what I'm doing wrong. If anyone could help I would really appreciate it. If not, that's okay. I can provide more code but the last line is what's giving an error. 
player:getTraits():add("SpecialInterest")
SpecialInterest:addXPBoost(Perks.Mechanics, 1)```
what type is SpecialInterest?
also what's the error you're getting?
oh have you tried Perk.Mechanics instead of Perks.Mechanics?
I'm getting the error "attempted index: HasTrait of non-table: null at KahluaThread.tableget line:1689"
SpecialInterest is a trait I made using ProfessionFramework. I was going off one of the guides on the modding wiki on adding traits that said that's how you add xp boosts, "trait:addXPBoost(Perks.[perk], #)"
cause it seems Perks is not exposed:
$ grep -R setExposed| grep Perk
zombie/Lua/LuaManager.java: this.setExposed(PerkFactory.class);
zombie/Lua/LuaManager.java: this.setExposed(PerkFactory.Perk.class);
zombie/Lua/LuaManager.java: this.setExposed(PerkFactory.Perks.class);
zombie/Lua/LuaManager.java: this.setExposed(IsoGameCharacter.PerkInfo.class);
it means your player variable is null
Okay. Thank you very much for the help. I have no idea where it's getting the player variable as null or how to fix it. 
@faint jewel Hey man, I got this error while moving a cardboard box:
LOG : General , 1686005302236> 39,795,204> Placing item of type furniture_storage_02_27
LOG : General , 1686005302239> 39,795,207> Need item of type Base.CardboardBoxCarry
LOG : General , 1686005302246> 39,795,213> ERROR: addToItemRemoveSendBuffer parent=zombie.characters.IsoPlayer@391d2767 item=zombie.inventory.types.InventoryContainer@4ccc53ad
LOG : General , 1686005302246> 39,795,214> -----------------------------------------
STACK TRACE
-----------------------------------------
Callframe at: removeItemOnServer
function: placeMoveable -- file: VisibleMoveablesExtensions.lua line # 74 | MOD: Skizot's Carryable Everything
function: placeMoveableViaCursor -- file: ISMoveableSpriteProps.lua line # 1536 | Vanilla
function: perform -- file: ISMoveablesAction.lua line # 161 | Vanilla
ERROR: General , 1686005302247> 39,795,214> ExceptionLogger.logException> Exception thrown java.lang.reflect.InvocationTargetException at NativeMethodAccessorImpl.invoke0 (Native Method).
ERROR: General , 1686005302247> 39,795,214> DebugLogStream.printException> Stack trace:
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)```
try getPlayer():HasTrait
I'm sorry for asking silly beginner questions, but my girlfriend's not here to help me right now. I tried adding the line and it didn't change anything, I don't know if I added it wrong or in the wrong spot or something. 
I'm new to modding and very sheepish about asking for help here since I'm so inexperienced but my girlfriend insists I should ask when I need help 
Well can't really tell you unless you show the code
local chance_of_SpecialInterest = starting_chance + 95
local roll = ZombRand(100) + 1
local SpecialInterestRoll = roll <= chance_of_SpecialInterest
if player:HasTrait("Fishing") and SpecialInterestRoll and player:HasTrait("SpecialInterest") then
player:getTraits():add("ExtraSpecialInterest")
ExtraSpecialInterest:addXPBoost(Perk.Fishing, 1)
print("Extra Special Interest Fishing")
return
elseif player:HasTrait("Fishing") and SpecialInterestRoll then
player:getTraits():add("SpecialInterest")
SpecialInterest:addXPBoost(Perk.Fishing, 1)
print("Special Interest Fishing")
end```
This was my original code
and I wish I had a girlfriend I can ask help with coding, lucky you ๐
Yeah, she's great, but unfortuantely her expertise with lua and Zomboid coding is limited, and she's busy with FF raiding 
I can't see the call to getPlayer() in this code
I removed it when I got the error because I wasn't sure if I typed it write or put it in the right spot, got embarrassed and didn't want to look dumb if i did it wrong 
I had it between these lines initially since these were where the error was happening and I thought this is where I needed to call. Sorry, I'm embarassed of my spaghetti code player:getTraits():add("ExtraSpecialInterest") ExtraSpecialInterest:addXPBoost(Perk.Fishing, 1) and between these two player:getTraits():add("SpecialInterest") SpecialInterest:addXPBoost(Perk.Fishing, 1)
well being dumb or inexperienced are 2 different things IMHO
try this:
local player = getPlayer()
local starting_chance = player:HasTrait("Lucky") and 10 or 5
local chance_of_SpecialInterest = starting_chance + 95
local roll = ZombRand(100) + 1
local SpecialInterestRoll = roll <= chance_of_SpecialInterest
if player:HasTrait("Fishing") and SpecialInterestRoll and player:HasTrait("SpecialInterest") then
player:getTraits():add("ExtraSpecialInterest")
ExtraSpecialInterest:addXPBoost(Perk.Fishing, 1)
print("Extra Special Interest Fishing")
return
elseif player:HasTrait("Fishing") and SpecialInterestRoll then
player:getTraits():add("SpecialInterest")
SpecialInterest:addXPBoost(Perk.Fishing, 1)
print("Special Interest Fishing")
end```
Still got the same error. I started the function way up above with local player = getSpecificPlayer(0) is that a problem?
should work as well
@pliant yarrow I doubt you're getting the same error though, can you show me?
no it's a different one
the first one was about trying to call HasTrait() on something that was null, now the error is about trying to call addXPBoost() on something that is null
so now the problem is your SpecialInterest variable being null
Ah, thank you, sorry for my mistake
what is the type of SpecialInterest?
I don't see where you assign a value to SpecialInterest
So I made the Special Interest trait with Profression Framework, and was going off this page from the modding wiki but I don't know if the Profession Framework works with this format.
https://github.com/MrBounty/PZ-Mod---Doc/blob/main/How to make a custom trait.md
I tried this
name = "UI_trait_SpecialInterest",
description = "UI_trait_SpecialInterestdesc",
icon = "trait_SpecialInterest",
cost = 0,
profession = true,
exclude = {
},
})```
Again thank you very much for your help
@pliant yarrowWhy do you need ProfessionFramework? You can add a trait in vanilla
I only used it because this is part of a larger mod that uses it to add items on spawn and daily functions tied to traits and such
ok
I can make the special interest traits vanilla I just need to know how to make them hidden
Anyway the documentation you posted uses TraitFactory.addTrait not ProfessionFramework.addTrait
Anyone know some good mods for context menu examples?
Yeah, I'm gonna probably change these two traits to vanilla traits and see if it should work. I should be able to make things work from here. I appreciate all your help and patience.
Like I said, this was part of somebody else's mod I am patching and adding on to because they don't have time for it anymore and I got their permission to develope the mod
btw the two code snippets you pasted are in the same file right?
@pliant yarrow Try this:
local SpecialInterest = ProfessionFramework.addTrait('SpecialInterest', {
name = "UI_trait_SpecialInterest",
description = "UI_trait_SpecialInterestdesc",
icon = "trait_SpecialInterest",
cost = 0,
profession = true,
exclude = {
},
})
print("DEBUG:",SpecialInterest)```
then search for DEBUG: in your console.txt
can you simulate 2+ clients in debug mode?
not that I know of, you'll probably have to connect with DEBUG mode to a server, and then have two clients connect to it
alright
steam wont throw a fit if both instances have the same ip right?
I doubt it
otherwise people playing in the same house couldn't be playing the same game
yeah but they generally have different steamids
oh, you asked about IPs, not steam IDs ๐
and please let us know the answer to that question ๐
will do
basically 5% of players are randomly given an "immune" trait
or it can be chosen for 16 points
the twist is
immune players brains can be harvested with specialty equipment to make cures
loool ๐
yep
how can you know if someone has the immune trait ?
blood test
do you have to inspect their body? ๐
So
nice
You can either just test their brains while they're dead (very cheap)
or
alive blood test (takes longer)
your options are basically
-Quarantine a bit person and wait
-Blood test
-just see if their brain works
so the immune player has to agree to the blood test? (Assuming he's alive of course)
Yeah and I might add prisonerr support
so you can do it on restrained ones
idk tho
but why would a player submit to a blood test then? ๐

So
im making it for an RP server
of mine
10 years later and 60-70% of the pop starts in military/gov controlled safezone
and the gov can uh
harvest brains
threat of getting shot I guess
also
I will probably make it so head injuries don't allow brain harvesting
well between threats of getting shot and getting my brain harvested I would always choose the threat of getting shot ๐
but only a small section of people are immune
ah yeah, true
hum, so what would entice a player to choose this trait?
yep
the trait is overall beneifical but
it carries the risk of having your brain harvested
also considering adding a minor treatment
where you can take immune blood to delay turning
without killing them
so you're injecting yourself with immune blood and it will slow down zombification?
also it needs specialty equipment to do all this
yeah
hum but does it work in the tv show? I kind of remember that no
Its just inspired
ok
that we know of
Ye
maybeeee
this is my first zomboid mod
just kidding
๐
nice!
and if you touch it by mistake you have to press space many times to get a chance to push yourself out of the electricity, with very low chance of succeeding for each try ๐
the only thing that I have no idea how it could be done is to animate the fence tiles so that it looks like there's electricity going through
night all
Have a good night, thank you so much for the help 
Omg
Bro you rock!
This also serves as a tool for clothing modders
Is this out?
Still hoping one of you has any ideas about this
#mod_development message
I'm gonna be going to bed soonish, any help would be absolutely poggers. Otherwise this is kind of killed in the crib

man what the heck
anyone know if there are any proper ways to detect when a new character is created? i was originally just using OnGameStart but that wont work in multiplayer, i tried OnCreateLivingCharacter and OnCreateSurvivor but those only fire once, if i try and create a character after that on the same save/world they don't fire again.
You have mods that are enabled
This doesnt happen to me cuz i test using host button
I saw the post but i dint understand the situation
Sure, what do you need to know?
I saw you posting about similar issues in the past and tried to glean something from it, but no dice haha
Do you have the x files? For animation
Im not sure i have done anything with windows yey
Did you overwrite the animaton? If you did it should work
Of it didnt then there a problem with the anim file
To check if its loaded i use animation viewer
So the x-files are currently the same. The idea I had was increasing the speed scale (and blend speed) for certain animations, and if there was an TimedAction that used one then to replace it. Said animation should only trigger if player has a trait
Currently the standard animations are being overwritten by the faster animations, and I'm not sure why. I tried to name them differently. Do I have to copy and rename the x-files too?
Ideally only the players with the trait would have some animations sped up
what im doing atm is logging all players with that rait when with oncreateplayer and then iterating through it and seeing if the name matches the corpse name, its a pretty bad solution and if anyone else has idea lmk
You have to modify the blend time
Or the time action maybe
You can probably store moddata on the corpse with onzombiedeath
Then retrieve it
I think i've done that--take a look:
<?xml version="1.0" encoding="utf-8"?>
<animNode>
<m_Name>Slinkystart</m_Name>
<m_SpeedScale>1.06</m_SpeedScale>
<!--<m_SpeedScale>0.80</m_SpeedScale>-->
<m_AnimName>Bob_WindowStruggle_Start</m_AnimName>
<m_deferredBoneAxis>Y</m_deferredBoneAxis>
<m_Looped>false</m_Looped>
<m_SyncTrackingEnabled>false</m_SyncTrackingEnabled>
<m_BlendTime>0.27</m_BlendTime>
<!--<m_BlendTime>0.20</m_BlendTime>-->
<m_Events>
<m_EventName>WindowAnimLooped</m_EventName>
<m_Time>End</m_Time>
<m_ParameterValue>start</m_ParameterValue>
</m_Events>
</animNode>
Filename for the above is "Slinkystart.xml". The commented out lines are the original sections
<m_BlendTime>0.01</m_BlendTime>
try
see if it works
<m_SpeedScale>8</m_SpeedScale>
you can modify it without restarting the game
just tweak it from there
It does change in the middle of the game
So when I open a window now it's insanely fast haha
I just wish it would only do that after checking if I had a specific trait. As of right now, all players get the faster animations despite the rename
read comments the for exact issue, would be helpful if anyone had ideas of how i can accomplish this (detecting character creations / spawning in both MP/SP)
i'm gonna get to bed and check in in the morning
Could you give me an example?
(This is my fist zomboid mod)
writing/reading moddata I mean
ok nvm OnCreatePlayer is properly firing, just my code to get zombies to spawn in the building is only working for the first spawn for some reason
fuck im stuck here
that's prolly not the best idea tbh cuz if you see electricity going through your fences you're probably wasting it lmao
A quiet buzzing hum would be good enough imo
Nice one, the x files ๐
Haha ye idk what else to call it
๐
It will be part of my update for the transmog mod. Will be out soon.
If that doesnt work then i would tweak the animation file itself
Sorry ughh you know how to use moddata?
Yea I figured it out forgot to put it in here sorry
I consider this a tool so thank you
Have you checked true actions?
Microscope model done
Microscope and brain items done
Lua immune trait and random chance of getting it
And the extraction surgery process
Zomboid modding is pretty accessible
@woven brook i see you've been working hard ๐
Really depends what you're trying to achieve. Some stuff can take an insane amount of time
I bet yeah
Definitely gonna make the mod very configurable for server owners
Since its basically an MP exclusive mod
Also
If anyone has ideas lmk
Nice one! Youre doing great keep it up!
What are you trying to search?
Hello, is there any chance to implement a couple of ammo types for weapons (for example, default and incendiary) and get the type of loaded-in gun ammo from the Handgun object?
Yes define the ammotypes with / inbetween them in the script for your weapon
In this case, maybe you know how I can get the type of ammo loaded in a particular HandWeapon object? I don't think weapon:getAmmoBox() will return the correct value...
It will load the best ammo itself but youโd have to probably write to the guns moddata what ammo is currently in
I see... Okay, thanks for the advice!
@tame mulch Hello mate, there seem to be a regression with sendServerCommand() in single player mode. In previous versions it was possible to trigger code in client using
Events.OnServerCommand.Add(function()
-- do something
end)``` but it's not working anymore, the event is not triggered in client code and the handler not called. I confirmed this with multiple modders who realized their mod was not working properly anymore in single player. Any clue about this?
Only server can send command. In other cases the send command function just does nothing.
just saying there's a regression, code that was working before does not anymore
Does anyone know what happens if set the damage value to 0 in the OnWeaponHitCharacter event? Especially with firearms? Will it still create a wound on the character, but no damage?
Can confirm this
Confused me a lot
Any clue what's the priority order for require() when you have same filenames in server/shared/client?
for example let's say I have:
media/lua/server/MyMod.lua
media/lua/shared/MyMod.lua
media/lua/client/MyMod.lua``` and from another mod I do: `require("MyMod")`, which one would be loaded?
Hi. Strange that this works before in SP
really? Hum maybe we misunderstood each others when talking with other modders. There's so many different reason it coudl work or not depending on where is your code (client/shared/server) and from the different game modes (single, multi, coop etc)
@tame mulch so what would be a good way to trigger client code from server and shared?
in a way that would work in single/multi player/coop games?
basically what I need exactly is to be able to trigger the display of a popup from server, client, and shared
but UI libs can't be required from shared or from server from my own testing
As idea, do on client and server same function for popup. Like on client:
func
if not isClient() then
bla bla bla
on server:
sendServerCommand
so the isClient check is for SP, and the sendServerCommand for MP, correct?
Can anyone confirm there are actually 5 seasons in PZ?
- Spring
- Early Summer
- Summer
- Autumn
- Winter
Yep
ok thx, will try that
@weary matrix
#mod_development message
You can not require a file until the appropriate folder is loaded. Usually requires cache the result, so I assume the earliest file will be returned if you use the same name.
thx โค๏ธ
I wish we could pin that message though
also I can confirm it seems correct, because if I put my popup code in client, and call it from shared (at a later time) then it seems to be working properly
at least for SP
bump
Also server folder is not loaded on Main Menu.
Has there been anyone who has look into making a world-changing mod? I'm not saying a breakthrough but more so a mod or a pack of mod that helps to change the entire era/world of the game?
Like having it more to be a fallout-like game with the world looking to be a wasteland or such
I know its kinda normal for some modding community to do that with some other games out there
@weary matrix
--- return false in SP, true in MP as a client, false in MP as a server
isClient()
--- return false in SP, false in MP as a client, true in MP as a server
isServer()
--- return true in SP, true in MP as a client, false in MP as a server
not isServer()
isClientOrSinglePlayer = not isServer()
isServerOrSinglePlayer = not isClient()
isClientOnly = isClient()
isServerOnly = isServer()
isSinglePlayerOnly = not isClient() and not isServer()
isCoopHostOnly = isCoopHost()
Hi Evergreen!
just different formatting
didn't realise that was there
well we never repeat enough 
this is vanilla code.. i wonder why its written this way
ISWorldObjectContextMenu.onWalkTo = function(worldobjects, item, player)
local playerObj = getSpecificPlayer(player)
local parent = item:getSquare()
local adjacent = AdjacentFreeTileFinder.Find(parent, playerObj)
if instanceof(item, "IsoWindow") or instanceof(item, "IsoDoor") then
adjacent = AdjacentFreeTileFinder.FindWindowOrDoor(parent, item, playerObj)
end
if adjacent ~= nil then
ISTimedActionQueue.add(ISWalkToTimedAction:new(getSpecificPlayer(player), adjacent))
end
end
ISWorldObjectContextMenu.onWalkTo = function(worldobjects, item, playerNum)
local playerObj = getSpecificPlayer(playerNum)
local bo = ISWalkToCursor:new("", "", playerObj)
getCell():setDrag(bo, playerNum)
end
did it overwrite iteself or am i missing the point
Looks like overwrite
The dmg has been delt at this point and the wound is already there of any
getClipType() iirc
Or was it
getAmmoType()
Not sure anymore
Thanks for the answers, much appreciated!
you need a check in the animation xml for a variable that you set when the player has the trait
<m_Conditions>
<m_Name>CondName</m_Name>
<m_Type>BOOL</m_Type>
<m_BoolValue>true</m_BoolValue>
</m_Conditions>
```then in code, you control this variable with ``player:setVariable("CondName", true)`` - it should be fine to just set the variable when a player with the trait spawns
animations aren't something i work with, i've just helped a few people debug them before, so apologies if something in here is incorrect
i think the condition can be a bool, float or string - if this is supposed to be like species specific animation system you might want to use a string species name instead of a bool
Hello, i'm searching info on LUA script for Generator. But i don't find file related to it. I'm searching in server file.
Anyone have an idea where i can find it? Thx in advance for help.
generators aren't written in lua, they're java
I have--they use completely new animations which circumvents the whole issue haha
ok thx. So it's hard to interact with it for change range for exemple?
this is valid. I'll see about this--thank you!
https://cdn.discordapp.com/attachments/1113449675031318608/1115680224965820436/image.png
Crossposting bc idk where this is better to be posted at, sorry
has anyone who has dealt with clothing masks run into this issue of these particular spots not being hidden when using <m_masks> in the .xml file?
as far as i remember genny range is an hardcoded number
There are methods available for the gen but may not offer all you need.
When the generator is started it updates the squares around to set the electricity value on each of them. So maybe it's possible to hook into the action of starting the generator and adding the electricity value on a bigger range. But must not forget to remove the electricity value when turning off the genie.
Also that wouldnt effect the fuel consumption outside the vanilla range i think.
Ok thx. I will look into it.
I think the solar array mod is also a good place to look into.
watch out for edge cases like when a square you need to turn off is actually still supposed to be powered by something else
No, Immersive Solar Arrays don't change the range either.
Hello there, what is the best way to broadcast a message to all current clients from the server ? (if it auto broad casts to all future clients it is even better)
I want the message to be displayed on screen of all users, not an internal sendServerCommand if I can avoid it.
idk if there is anything like that
i'd imagine it working like:
when the message is broadcast, sendservercommand to display that message now on all clients, and add that message to a cache
when a player joins, sendclientcommand to ask for the server to send any cached messages to that client
thanx
Not sure if this is the correct place to post this... but...
I have been struggling to find a good mod that allows All Weapons or All Bags to have attachements. Slings Mod didn't work for all guns, Noir's didnt work for all bags, Two Weapons on Back only worked for Vanilla bags... soo...
I updated this mod to include all modded bags and useable for all weapons - works great!
if anyone wants to test it out and let me know if I have any bugs or duplicates I'd appreciate it! 
(I only updated it to include more bags from mods, I do not deserve credit for development of this mod. The original dev abandoned it.)
[Solved and answered below] How does everyone here test their mods for multiplayer? Is it possible to run two instances of the game from one account and test on a private server? Or do you all recruit friends and a server? I've never played multiplayer but I'd like my mods to support it at least.
Forgot to search post history for answer. Doing that now.
I also need to know the answer for this
you run two instances of the game in non-steam mode
Sup
How to test for multiplayer on Windows
- The Mod you want to test must be in the Mods folder of your Zomboid Directory (since we'll be testing with the -nosteam flag, the workshop folder will be ignored).
- My Zomboid folder is located at C:\Users[username]\Zomboid\mods
- The folder you copy must be the one that immediately contains the media folder. The game apparently doesn't dig through nested folders to find eligible mods otherwise.
- open the command prompt (win+R and type "cmd.exe" or any of the other dozens of ways to get the command prompt open)
- navigate to where the zomboid EXEs are. For me its:
- cd "C:\Program Files (x86)\Steam\SteamApps\common\ProjectZomboid"
- execute one of the exes (32 or 64) to be the server host:
- start ProjectZomboid64.exe -nosteam -debug
- From the main menu, host a server. Click "Manage settings" in the host game menu. Click "Edit Selected Settings" and click "Mods" from the INI list. Add any mods you need to test from the "Add an installed mod to the list" drop down. Save this configuration change. Back up through the configuration settings and click "Start" to launch the server. Create your admin character as necessary
- execute a non -debug instance for your non-admin player:
- start ProjectZomboid64.exe -nosteam
- From the main menu click "Join" to join a server. Fill in the account name and account password fields and save this server. IP and port settings should be correct for local play.
- click "Join Server" on your newly favorited 127.0.0.1 server. Create your character as necessary
- If you need to see your second character you can use the following teleport command:
- press tab, t, or enter to open the multiplayer chat window
- type /teleport "playerTwoName" to jump the admin to player two.
- if you would prefer to bring them to you, use /teleport "PlayerTwoName" "AdminName"
- Test your mod to your heart's content
@trim mist I pieced it together from other comments in the past. This should get you where you need to go.
If anyone has feedback or criticism of my multiplayer testing walkthrough above, please let me know. I'd like to make sure everything is both explained well but also as streamlined as possible.
The fact that none of us can pin posts here should be a war crime.
pins were superseded by the wiki page
It's obvious that people come here before going there.
well, the wiki page is a pin, so anyone who doesn't find something on there wouldn't be looking at the pins anyway
for my post above: https://pzwiki.net/wiki/Multiplayer_guide ๐คทโโ๏ธ
I'll add what I've written above to the wiki as well
Like I've said, we need a discord bot that has assignable commands to respond with set text for players to be properly directed to the wiki or other sites with relevant information.
If you write a map for showing where things are that's awesome.. except people still need a kiosk to get the map.
=)
Roller Coaster Tycoon wisdom.
God damnit.. Now I need roller coasters in PZ.. And trains.
All the park guests are zombies.
My submenus onselect method is executing whenever the context menu is opened, any ideas?
its running harvestbrain whenver the menu is opened \
wrong screenshot
one sec
Imagine a queue line full of idle zeds in PZ.
I fucking love this idea but I wouldn't even know where to start
This idea is too funny.
Heres my code
local subMenu = ISContextMenu:getNew(context);
context:addSubMenu(option, subMenu);
if equipped then
if body:isZombie() == false and equipped:getType() == "Scalpel" then
subMenu:addOption("Harvest Brain", body, harvestBrain(body, playerInv,playerObj,equipped))
end
end````
you need to pass a reference to the function
Control AI of zeds. Find a way to manipulate spatial coordinates and velocities of vehicles. Create chains of vehicles. Create tiles for TileZed and interpret them in-game as segments of coordinates to lerp the vehicle's coordinate positions. Play world sounds of screaming zombies at vehicle coordinates.
harvestBrain(body, playerInv,playerObj,equipped) just calls the function and passes the return value as an argument
Oh
try subMenu:addOption("Harvest Brain", body, harvestBrain, playerInv, playerObj, equipped)
Thanks.
Crazy ideas can make you crazier when you find out how easy it is to block it into practical feats.
I almost built a server as a modded RCI model for simulating Sim City in PZ.
alright first part of the mod is done ๐
ty albion
you are deranged
!
but
do it
Stay far away from my GitHub org.
I fell into the niche here for making tools for modding PZ.
Very cool
The API is mid.
i don't think i've ever heard anyone say that before LOL
Who sold you this idea?
I've also worked with lua for like 30k lines so yea
i mostly agree but it is definitely not the common sentiment
They're clearly trying to harm you.
Also, if you want EmmyLua support, use Umbrella.
https://github.com/asledgehammer/Umbrella
my only public repo is my worst project ๐
anyway
Not sure why people are so crazy about merge conflicts.
if anyone has some ideas for this mod lmk
Git makes merge conflict resolution so easy to handle.
It's not Git. It's the project planning.
I've been posting this a lot lately but here you all go https://www.reddit.com/r/ProgrammerHumor/comments/129q4l9/me_relearning_git_every_week/
basic process is:
-5% of players (configurable) are immune and you can also pick it as a trait for 16 points
-People can be blood tested to see if they're immune
-Once a player dies you can harvest their brain with a scalpel and then convert that to cures at a powered lab station if they're immune
theres some more depth to it but thats the basics
i'll take a video here
git submodule update --remote
Already kills people.
Oh BTW fun fact: You can clone the wiki tree in your GitHub repository by adding .wiki.git to the end of your clone URL. (Replace .git)
Your wiki is its own repo.
Learning Git is like learning a commercial-grade Lathe, but for a programmer.
:D
Unfortunately I'm the Git guy for my work ATM. (People ask me when they can't figure out something)
very early but the harvesting process + immunity system started https://medal.tv/games/project-zomboid/clips/1cUMt0prgYZ4YU/d1337NYk37WI?invite=cr-MSxOdDUsMTU3OTExNDEs
Watch wip and millions of other Project Zomboid videos on Medal, the largest Game Clip Platform.
also a temp brain model I guess
My thing about the zomboid api is I can't find what's available to me. I wanted to get the length of the array that held all body parts and I spent a day trying everything I could think of. Eventually I found getPlayer():getBodyDamage():getBodyParts():size(). How was I supposed to know that the size method existed? I can't find any documentation anywhere. I've been digging through the javadocs just to get a better understanding of the object structure but it doesn't appear to be 1:1 to the exposed lua structure.
If I want to burn a body part, the javadocs list /zombie/characters/BodyDamage/BodyPart/setBurned() but to do it in lua it's GETcharacter/GETbodydamage/GETbodypart/setburned(). I had to figure that out through trial and error. Size() isn't mentioned in any docs I can find.
Community guides exists. Umbrella also helps by mapping these API out in EmmyLua typings.
:size() isn't a zomboid thing, it's a java thing
just googling arraylist (and other java types) should come up with docs for them
Java objects also use 0-indexing while Lua tables uses 1-indexing.
This isn't a real Lua environment. It's simulated.
didn't realize I could use java like that in lua. I'm still in the middle of my lua class and have extremely limited java knowledge.
Java objects requires .new() where Lua pseudo-classes use :new()
Kahlua is a simulated Lua 5.1 in its own code in Java Runtime Environment.
It isn't full 5.1 but this is the version used when last updating Kahlua2.
That information should help you somewhat.
curious, what makes it 'simulated'?
It imitates the execution and interpretation of Lua script in a virtual machine.
I say this because Lua has a strong standard of using the original engine written and compiled in C.
Kahlua is a reverse engineering of Lua, meaning that it uses none of the standard builds.
re: umbrella. I'm currently using https://github.com/demiurgeQuantified/PZEventStubs but I'm now noticing that this project encourages the use of umbrella. I'll get that configured later.
Kahlua also supports unsupported features and syntactic patterns that Lua doesn't.
that makes sense ๐
That's because Umbrella is a collaborative project between me, albion, and Omar.
I wrote the portion that covers the Java API for PZ.
And this uses umbrella
yeah, i'm actually the author of PZEventStubs
Which is a CLI tool
I'm glad that other people are making tools.
I'm beginning to notice how tight-knit but active this community is
Also if you want to go off the deep end, you can mod PZ in TypeScript.
Umbrella is a game changer. At this point i started making mod in lua again.
I've seen that but I'm fine with lua for now. It makes me uncomfortable to write code in a txt file for some reason. ๐ Or maybe I just completely misunderstood what I was looking at. I saw what looked like typescript or lua code in a txt and noped right out

Code in a txt file?
ah yeah ok
Sorry to interrupt, but I have what I hope to be a quick question.
I've been poking through the PZ .classes to make some changes for lighting and I can't immediately find the corresponding .jar files except for top-level jars. In fact, not just for lighting but for any jars outside of those hosted on ../ProjectZomboid/
Does this mean I'm not decompiling the project correctly? It seems like all these .class files I'm seeing are supposed to be rolled into a lower-level .jar (eg: ../ProjectZomboid/zombie/iso/somekindofLighting.jar), or is that a misinterpretation of the java structure?
It's possible to mod the game's java but it is not the mainstream thing here. Mods discussed here are Lua mods. Lua mods can be uploaded to the workshop (without requiring custom installation instruction). I doubt you get a lot of support when it comes to java modding as this is just not the popular thing here. But there are some java nerds in the room that may be able to help
That's kinda what I figured. I wanted to tweak the visual radius like the 360* workshop mod does, and that also requires circumventing the typical Workshop mod route.
Oh yeah java mods can be dope as hell.
i'm not really familiar with how java operates, but my experience with pz has always indicated that the game does just run the loose .class files, if that's your question
I don't have time to help people do java mods but I'm one of the oldhats here.
That's wild
I've modded PZ's Java code for nearly 10 years.
There's a few of us but we're sort of closed off as a community.
Well, I'm pleased to meet you
Minecraft forge was great
I wish we had something similar but i doubt we are heading that way anytime soon.
added this page to the wiki https://pzwiki.net/wiki/Testing_Mods_in_Multiplayer and linked to it from https://pzwiki.net/wiki/Modding#Advanced_level
I did write a Bukkit for PZ servers.
Minecraft has Jeb. We have Jab. ๐
I mean.. I do have the unreleased Crowbar project.
It isn't trying to be forge. It's trying to add missing modding features.
Allows me to do things like this:
Lets just add javascript scripting engine?
blurry bg
I'd be all over that ngl
I can't tell you how many times I've run into things that haven't been exposed. or wanted to do things not possible at all in lua
like changing the vision cone, etc.
@red tiger was there any protection in place with minecraft java mods? Or there could have been "virus" like mods anytime
I recently offered TIS to have my ShaderProfile API to manipulate Shader Uniforms from Lua but they declined for vague reasons.
I might release it as a mod.
Latter.
i'd use it
If that's what the people want then that's what I work on.
I'm mean that's what I'm trying to mimic. The aforementioned mod pretty much changes calculateVisionCone() function in zombie/iso/lightingjni.class to just be
return 2.0;
I'd like to take a shot at mimicing it too, but .class files are locked
I would love to do that but also. I wanna put like a divot of darkness in the middle
so I really wanna mess with it lol
it's honestly not as useful to me now as it was when you were first working on it, i'm not really in the graphics department and the project i did have use for it on is pretty much dead
and outside of myself i have no clue how in demand it is
but shader control really seems like something we should have
You would see a revolution in PZ modding if this feature became public consumption.
I wouldn't be able to come up with the ideas that people would come up with if they had this in their toolset.
I don't sit well with myself holding onto the tool, which is why I offered it to the official game.
Now that I know that they don't want it, I can feel better releasing it in some capacity.
Shader would do cool drug effect etc
in other fun news, I added said variable, the animations were still overwritten, and when I tried to change them to point to different animations (which were just renamed anim files) the game crashes on launch. SO I think I'm done with my little selectively-quicker animations trait
the animation system seems complex
i wash my hands clean of it. for now at least
I'm wondering if the dev have special tools that we don't for example software to manage animation xml and zedscripts etc but would be dope to have better tools instead of manually typing every by hand.
In the past i wanted to make a software for managing txt script but got tired.
Shaders can revolutionize the game if controllable.
I would love to have access to said tools, if they exist
Is there ever like. an AMA thing the devs do?
Why not simply make them yourself?
Jab has one for the txt script files
I would love to ask them some questions
Cause im working on mods, sometimes tools but thats not where my fun is at
I paused work on my vscode extension but: https://marketplace.visualstudio.com/items?itemName=asledgehammer.zedscript-vscode
pzpw and pzstudio was really just so i can make my modding more comfortable.
All i'd want to work on is mods
And that's why you work on mods.
I haven't launched PZ to work on actual mods in about a year.
There's been a couple times for some HTML UI engine mod.
But it was so brief.
GTA Modding is great, you can use C#, Lua or JS to create mods. And they included CEF for making html,css,js UI.
Problem with modding gta is that the game is empty.
PZ has everything. so when you create a mod, it really just add more to the game instead of making the game.
Downside of pz modding is lack of access to many things in java and the fact that we are stuck to using lua only. But we don't care cause the game is just dope.
I like to break things in fun ways.
How would I create a simple bolt action rifle?
no clue but you can download the tileset and search for it
anyone knows if it's possible to install mods on a server without going through the workshop? Same as when you put mods in ~/Zomboid/mods basically
@bronze yoke any clue?
the server uses the user directory too
oh nice, guess this is new cause I remember trying a while ago and it was not working
do I need any specific server options?
you do need to list the mods in the server ini
settled on doing a microscope
if you meant to get it to use that directory, it should already be using it, though you can tell it to go wherever you want with -cachedir
thx
just downloaded a public domain one
same with the brain model
nice, so what else do you need?
honestly idk
looking for ideas
currently the process is just
kill immunes
extract brain
turn into cure at a powered lab station
but that seems a little too simple
You're taking the Last Of Us approach I see
well I made a mod to throw corpse out of windows and it has >1M subscribers, so don't tell me about mods being too simple
๐
is that a spoiler
Wait throw corpses is your mod? Thanks for that!
I threw a corpse out a window as recently as today!
haha! Glad you like it! ๐
Yeah, and it was great to relax with some Project Zomboid afterwards
Does anyone know how to make a simple gun mod? Is there a good tutorial?
0:00 Intro
0:29 Video Start
1:00 Start Blender
1:22 Using a background image
2:04 Using photoshop to edit the background image
2:52 Adding the edited background image to blender
3:26 Adding the cube mesh
3:46 Quick start with the cube
4:56 Importing a finished 3d Model from the internet
5:56 Moding the imported model
6:47 ADD NOTE ABOUT MAGAZIN...
I havenโt watched it, but whatevs
don't think there's up-to-date tutorial about it, except maybe to create the 3d model, but the rest probably won't work. I would check one of the numerous gun mods that already exist
I don't wanna steal code
Is there someone who has a template or something?
I'm not talking about stealing code, just read the code to understand how they do it, then code your own
I think you'll find that using other mods as a reference will become really necessary
lord knows I referenced the other big trait mods a lot
they don't own the ideas of how they did it, and they certainly don't own api calls or the script formats - you can definitely check other mods without copying them
@wet dune have you done programming before?
Ok, then yeah you should be fine by using an existing an existing mod as a template
I'm making a basic overhaul zomboid server
Basically turning it from zombie survival to war simulation
All I'm doing is removing zombies and stamina for now
It sounds like youโd be better off importing existing weapon packs or other requisite mods and spending time working through integration than building from the ground up
But hey the development is part of the fun I guess
Is there a way to remove all weapons from spawning except one?
probably yes, just override distribution
Check out this video. It covers a fair bit of all the relevant stuff related to making a gun mod
Including spawning rates
Hey co` do you do any amount of Java modding for PZ?
I made a java mod loader a while back, not sure it's still working though
lol
Maybe you can advise, I had this question earlier but didnโt really get an answer:
I've been poking through the PZ .classes to make some changes for lighting and I can't immediately find the corresponding .jar files except for top-level jars. In fact, not just for lighting but for any jars outside of those hosted on ../ProjectZomboid/
Does this mean I'm not decompiling the project correctly? It seems like all these .class files I'm seeing are supposed to be rolled into a lower-level .jar (eg: ../ProjectZomboid/zombie/iso/somekindofLighting.jar), or is that a misinterpretation of the java structure?
How can I check for an object at a specific tile?
Somebody responded and said they thought that PZ just executed the .class files directly but that seems like an uncommon way for a game to do things. It might be true but Iโm not sure yet
Like an NPC or dropped item?
Placed
Oh, dang, I donโt know then
oof
i tried
isobjectpicker.pick and picktarget
no luck
oh better idea
I make it an appliance
and you "cook" the brain
now
does anyone know some good appliance modding examples?
or vanilla files I should look at
Looking for help instantiating a Java class from Lua. Basically I want to copy a vehicle's data so I'm hoping there's a way to make a new BaseVehicle instance and copy the values in from an existing vehicle instance.
did you try to iterate the result of getSquare():getObjects() and similar methods?
I know there's a command for server admins, like addvehicle or something like that, I would start digging from there
thanks, i'll see what comes up through that route
@harsh current Maybe you could try this project of mine: https://github.com/quarantin/beautiful-java/
a few methods can't be decompiled but it's a limitation of intelliJ decompiler
Hey co`, I hate to be a bother but I have a question about something you brought up yesterday if that's alright 
You said perks isn't exposed and I'm still getting an error assigning a perk boost and I was wondering if I was missing something because I don't know why it's not working
SpecialInterest:addXPBoost(Perk.Fishing, 2) is giving TraitFactory$Trait.addXPBoost> invalid perk passed to Trait.addXPBoost trait=Special Interest perk=null
Thanks, I didnโt realize IntelliJ had such limitations. Iโll take a look when I get home
should be Perks.Fishing
I tried that and it was doing nothing, and then I thought co` said it was Perk but I may be mistaken
hum looking an vanilla code, it seems it's using Perks not Perk. Not sure how that would work though because Perks is not exposed
it isn't exposed in the usual manner
not through the class exposer, the table is added to the lua environment elsewhere
interesting, can you tell me where to look?
zombie.character.skills.CustomPerks
in initLua()
they are the exceptions but there are a few things exposed like this
Anyone know if there's a way I can stop tripping when running through trees?
or at least, does anyone know of an event that fires? OnObjectCollide doesn't seem to fire on a character colliding with a tree
So I'm still a little lost, I don't know how to set Perks to be exposed 
Okay, then I'm confused why the xp boost isn't showing up in game. Do I need to do separate code to display the change in level visually? It doesn't appear to raise the level or xp boost at all.
when does the code run?
on character creation. I take it you need to assign stats to traits on boot?
My idea was to avoid creating a bunch of unnecessary traits so on character creation it would roll an XP boost assigned to one trait
oh, so the issue there is that traits kind of don't exist
after you create your character your traits are just a list of trait names, stuff like xp boosts are just applied to the character when you create them
so if you change the trait after creating the character, it won't do anything to the character
I gathered that from making the picky eater traits, but the XP boost code seemed contingent on a trait. So this is impossible then I think.
oh, no, it's actually pretty easy
player:getXp():setPerkBoost(Perks.Fishing, 2)
you might want to add it to their existing perk boost
it'd be annoying if you already had a higher boost and this replaced it
local playerXp = player:getXp()
local fishingBoost = playerXp:getPerkBoost(Perks.Fishing)
playerXp:setPerkBoost(Perks.Fishing, fishingBoost + 2)
hmm, i see a get/setPerkBoost on IsoGameCharacter, but the javadoc doesn't have it...?
it's apparently public and everything
that would be slightly tidier to use
oops... that's on XP
i never use javadoc
same file ๐
oh ya
XP being a class inside a class
didn't know you could have classes inside an other class in java.
Thank you. That all works. Thank you so much everybody. 
thx, I guess I need this for my obfuscator
tried to check in java, but all I can find is this:
@LuaMethod(name = "getMouseX", global = true)
public static int getMouseX() {
return Mouse.getXA();
}
...
public static synchronized int getXA() {
return x;
}
luckily you got your answer ๐
Umbrella is updated. Names are exposed.
Cool project though.
If you can't decompile via FernFlower, use JAD as a secondary.
(Use JD-GUI)
how do you get a trait when inside a game?
what do you mean?
like when im in a game and you get a trait like underweight overweight etc do you know how to make it
second wind
I'm confused--are you asking how to make a new trait? or assign yourself one when you're already in game?
no im saying a tait in the inside pz for a year a staving with a underweight
like a trait in the game with future of the game
player:getTraits():add("MyTraitName")
any ideas why this is throwing an error?
local y = worldobjects[1]:getY()
local z = worldobjects[1]:getZ()
local e = getSquare(x, y, z):getObjects()
if e:size() > 0 then
for i, ii in pairs(e) do
print(ii)
end
end```
line with pairs
error is "Expected a table" but it should be one
if you panic how do i make it so if you panic for a certain time you get a trait
This makes more sense. I think if you take a look at the more traits mod (and the dynamic traits mod) you might be able to piece together a solution
I've tried for i = 1, e:size() do print(e[i])
but e[i] is always nil
have you checked the output of e:getObjects()?
You might need to drill down further in the data. For example it might be the lua equivalent of a class, but there might be a straight-up table of objects you can use inside
have you been running the game in debug mode?
yea
Give a trait a trait
Omg that is somesort of inception right there
Badonn i will send you dm
have you been able to take a look at the object in the... break screen or whatever it's called? lol
debug screen?
What key?
oh
the
yeah
one sec
How do I do that @trim mist ?
im in the break screen
I'm having a brain fart, i'll take some screen caps
alr
for i = 0, e:size() - 1 do
print(e:get(i))
end
e is an ArrayList, not a table
ty
This is extremely helpful! I didn't realize the current variables were displayed at breakpoints like that!
@bronze yoke completely unrelated to anything that's been discussed recently but your learn to read mod is one of my favorites. I'm only just NOW noticing there's a recipe to write your own learn to read mag. Doesn't help me as a solo player but it makes total sense that you could put together some learning materials for a fellow survivor in MP. Just wanted to say thanks for putting together a mod that has improved my enjoyment of this game. ๐
oh thank you so much! ^_^
Gonna be honest the lab station model is just a microsope I scaled horribly wrong ๐
And I thought
Eh good enough
Looks sciencey, right?
I mean I could see the microscope shape but it's convincing enough ๐ I only recognized it because I know you mentioned using a microscope as a mesh earlier.
lolll
I had a cool idea
Where
Using normal brains in the cure machine
Sends out counterfeit cures
You might be closing in on what caused the Knox Virus in the first place ๐
something something mad cow disease
So if you โaccidentallyโ put a non immune brain in there then well
Wont do shit
Sell em to the guy across the street
Kidnap the wrong person?
No worries just make a fake cure!
oh thats a great fucking idea
I make infected brains give infection
If you put them in
And then you can put cures/infections in food
That is a great idea
anyone know how to make a copy of an instance of a java class from lua by chance?
If you figure it out, lemme know. I'm pretty sure that's impossible
damn. i think i actually need to extend a java class to get what I want. that may also be impossible though
extending is impossible
well damn, i guess i have to replicate ISVehicleMechanics then. that's about 1500 lines to sort through
yes but what i really need is a copy of a vehicle instance
if i can't do that, i can reference the original, but have to modify the above Lua class to modify the outputs from the vehicle instead of just extending the vehicle and modifying the getters
xy problem again and again, just say what u really want to do
copy a vehicle and modify the values to input into ISVehicleMechanics
i.e. skew the values to simulate foggy memory, allowing the player to open the vehicle mechanics view away from the vehicle (that part i have working to some extent already)
why do u want to copy vehicle instead cache the actual object of one
my first thought was to copy the vehicle and modify the values of it, or extend it to do so
my backup option currently is to replicate ISVehicleMechanics to work with a custom type i make
because if i cache the actual object and change values it will change the original vehicle
i want to change the values that appear in the vehicle mechanics view without affecting the actual vehicle
i want to make a "memory" skill that lets you see vehicle (and other container) details remotely but with missing details based on the memory skill level
ideally from the minimap, but initially from a context menu option that doesn't require bing next to the thing
that's exactly what u should have said instead of ur first question about class copy
https://xyproblem.info/
Asking about your attempted solution rather than your actual problem
you don't need to copy a whole file of vehicle mechanics menu, u can just create copy of it (not file but by derive method) and override functions that handles vehicles parts
cache actual vehicle object and use it as usually
i actually tried asking about that route first and was told you can't do that
for example I found only 4 functions that handles vehicle parts: ISVehicleMechanics:initParts(), ISVehicleMechanics:recalculGeneralCondition(), ISVehicleMechanics:renderCarOverlay(), ISVehicleMechanics:getMouseOverPart(x, y)
there's more to do than just override 4 functions but actually it's easy to be done
I have a feeling I already know the answer is no but I figured I'd check here just in case. I'm trying to create a sandbox variable for a trait cost. However I think I need an event to actually adjust the trait cost before the user selects it. My code so far:
- loads the trait into the game OnGameBoot โ
- Player adjusts trait value on sandbox screen โ
- I try to adjust the trait cost and reinitialize the trait between the sandbox screen and the character trait screen ๐ฅ
My problem is that I need something to trigger the reinitialization and I don't know if any events occur between the sandbox page and the trait screen. None of the events here https://pzwiki.net/wiki/Modding:Lua_Events really stood out as usable.
since the ui is lua you don't really need an event, you can just hook one of the related functions
i didn't realise you could just reinitialise the trait like that... i had a bunch of annoying code trying to accomplish the same thing
actually might still be necessary, not sure if it would have actually helped with the problems i was facing, but still definitely better to reinitialise it
can you recall which mods make use of that annoying code? Or did that not get published? I'd like to take a look at what you did and I have no idea how to use hooks yet.
it wasn't published because i couldn't get it quite right and then lost interest
i did it by hooking the metatable for getCost() - but if you can just reinitialise the trait that isn't needed
the issue i had was that the trait list wouldn't re-sort itself, and if the price went from positive to negative it would stay in the wrong list
which might not be an issue in your case but it was in mine
i think i got the sorting working...?
oh I have no idea if I can reinitialize the trait. Honestly I think it's 50/50 if calling the Init function again might just make a second trait...
i checked after you mentioned it and it does
lol
I'll stick with hooking GetCost(). It'll be a good learning opportunity for me.
Thanks!
Anyone have any idea why zombies won't highlight or get an outline?
that highlighted bit in the middle is the important part. These commands all run, no error
even aiming at a zombie doesn't show any change in their outline
iirc it's updated every frame so lua can't really do anything to it
did u try OnInitWorld event?
does anyone know if there's a guide somewhere for editing zone zombie clothing? im working on adding some new hats to the game and im not sure where to start, i have the textures made already and everything i just don't know how to get them to spawn on zone-specific zombies
At face value that seems like it would trigger after character creation. I need to adjust trait values after the sandbox page and before the character creation page. I'll check it out and see if I can figure out when it triggers.
well you struck my curiosity so i took another look at it and i got it working properly this time
OnCreateLivingCharacter seems like would it trigger after character creaction
OnInitWorld seems like would it trigger literally while/after loading into world after start the world
at least I hope but in pz usually name of smth do not correspond to reality

Correct. OnInitWorld happens immediately after the game determines possible spawn locations. Or at least it does with Pillows Random Spawns on. Pillows is probably calling OnInitWorld as well.
Anyone have an idea what the result 15 error means? Trying to upload a mod
is this an existing workshop item?
I found this https://partner.steamgames.com/doc/features/workshop/implementation#uploading_a_workshop_item which mentions it might have logged the error to Steam\workshopbuilds\depot_build_<appid>.log Can you confirm or deny if this log file exists?
I don't have much in that log file personally
@novel barn so about OnInitWorld did u test that it actually triggers after characters creation?
I'll turn off all my other mods and try to isolate where it gets called
I really should have been in bed 20 minutes ago though. Gonna check this and call it.
well, it is now a part of Zombie Contagion's trait module https://steamcommunity.com/sharedfiles/filedetails/?id=2868937948 if you would still like to analyse it
YES! That's why I stuck around hahaha
it's also on my github if you don't want to go through the steam crap
cos I checked java code and OnInitWorld should be called exactly before character creation phase
wdym? that's not what i'm seeing at all
this is not an existing item no, is there something I'm missing? Also I don't see any log file generated
in workshop.txt do u have id=...?
cos by ur screen I see what u trying to UPDATE existing workshop item
instead creating new one
you have left the id of another item in your workshop.txt
oh wait, it's valid for mp
fwiw I changed my traitInit call to the OnInitWorld event and the trait is not found in the selectable traits menu. I would suspect that OnInitWorld happens after the traits screen
Ohhh interesting. ๐ค I guess MP really was a mess for them to get running
Oh should I omit that?
seems I found part of code for singleplayer character creation but it won't work for second character creation (after death of first) so albion method will be fine
Thanks for updating this! I'm looking through it now and there's a lot going on that I don't understand. My Lua class covers metatables next so I'll finish that section and see if it helps make some of this out. Sometimes I just need to bang my head against it for a few hours or days before it clicks. It'll be really constructive for me to have the class on metatables and then a PZ reference to study.
yea, remove it
I appreciate you looking into it!
re github: Is the workshop synced to your github in any way (is that possible?) or do you just use github to version your code (among other uses)
literally the main reason I'm here right now.
it is possible to sync them but it's annoying and requires a bot steam account (with their own paid copy of zomboid, i believe)
my github account is sparse because all my contributions were tied to my former employer in a private repo. Now it looks like I've never done anything
chuck has done it and it sounded like a massive pain
Yeah I'm happy to just hit upload in the UI. /shrug
Alright if I don't stop now I'm going to lose track of time and the sun'll be up. Good night everyone! Thanks for all the help today! ๐๏ธ
Hello there, is there a way to get color selection from sandbox options ?
Hey, just realized TIS added getUrlInputStream. Any one tried to use it? I'm wondering what happen in case of network errors (timeouts, invalid domain/name, url etc). Any clue?
@tame mulch Hi, I would love to have a way to parse JSON from Lua, without having to implement a JSON parser myself. A global @LuaMethod like parseJSON(String JSONData) that would return a Lua table would be awesome. Have you guys ever discussed this?
I think for this will need create another json parser or create translator from java object to kahlua table. lua json parser not enough?
I'm pretty sure I saw something like that in DislaikLib, used by Dogs mod
guess it would be enough but if everyone is embedding their own JSON parser it will make a lot of wasted space
Hey all. I had this mod idea and was just curious if it was possible to make, but I doubt it.
There's this game called The Long Drive. The gameplay is pretty simple. You have this randomly generated road in front of you, and points of interest that generate along the way where you can stock up on fuel, food and junk to make your car cooler. I think it would work really well with PZ gameplay, where the POIs would be guarded by zombies and loot was really scarce and stuff, but I guess the main challenge would be the randomly generated road and POIs. I don't think it's possible but I haven't researched it one bit. Figured it would be quicker to ask for a big no here. Thanks!
It is feasible, as the tiles can be generated ingame. But PZ is not made for this purpose so there will be a lot of work. There also will be loading time but I guess for this type of game, it is expected.
Thank you!
hum, trying to embed some text with a youtube link in a ISPanelJoypad object, but it seems my link is stripped from the text :/
any clue how to fix this?
can ayone think of some sciency-ish vanilla model?
Is there a guide I'm missing that covers setting up a VSC workspace, or is IntelliJ the only real option?
I use vscode
Thank you!
So I have this Lua code:```lua
self.richText = ISRichTextPanel:new(x, y, self.width - x, self.height - padY - btnHgt - padY - y)
local message = getText("UI_ModGuardian_Youtube_Link") .. " TEST "
self.richText:setText(message)
in shared/Translate/EN/UI_EN.txt I have this:
UI_ModGuardian_Youtube_Link = "https://www.youtube.com/watch?v=5yFPuinN4wI"
But the panel is missing the link, I can see the "TEST" part though. Any clue how to make it so that the link is displayed properly?
if I do this then it's working properly:
local message = "https://www.youtube.com/watch?v=5yFPuinN4wI" .. " TEST "```
but I'd like to keep the link in Translate if possible
FINALLY
embed fail
Watch Untitled and millions of other Project Zomboid videos on Medal, the largest Game Clip Platform.
Going through the boilerplate mod practice- is there a specific reason why a recipe with no reagents is uncraftable?
recipe Create TestItem
{
Result:TestItem=1,
Time:5.0,
Category:Cooking,
} ```
I see it in the crafting menu and all
There's somewhere a check that stops it if there's no required items.
Ahhh gotchya- I wasn't sure if I was just doing it improperly or if that was intended- thank you
Is the translated line in first line?
Anything else you can say about that file?
If the getText returns "" that probably means there's an issue adding the text
you mean the shared/Translate/EN/UI_EN.txt file?
Can you try it without any special characters
hum, I don't think I have any special character. Here's the full content for this file:
UI_EN = {
UI_ModGuardian_Title = "ModGuardian"
UI_ModGuardian_Text_PlayerBlacklist = "The author of %1 decided to blacklist you from using his mod."
UI_ModGuardian_Text_ServerBlacklist = "The author of %1 decided to blacklist your server from using his mod."
UI_ModGuardian_Text_ExclusiveServer = "The author of %1 decided to make his mod exclusive to a list of servers but yours is not allowed."
UI_ModGuardian_Text_Modpack = "The author of %1 doesn't want his mod in a modpack. You can still use this mod outside of a modpack, or you can create a Steam workshop collection as per: https://www.youtube.com/watch?v=5yFPuinN4wI"
UI_ModGuardian_Warning = "Your game won't work until you uninstall this mod."
UI_ModGuardian_Youtube_Link = "https://www.youtube.com/watch?v=5yFPuinN4wI"
}
special characters, you mean like UTF-8? Or do you mean non alphanumeric characters?
You can test things fast by printing the value in console, change text in file, reload with Translator.loadFiles and print again. I think that's the right command.
PS: I can get that text in console so it's not that
If there was no translation you would get the string "UI_..."
You mean you tested print(getText("UI_ModGuardian_Youtube_Link")) and you get the link?
yes, I added it to my translation file.
weird
can someone make a mod that add a wooden katana , bokuto into the game ?
Anyone tried to use getUrlInputStream()? It's returning a DataInputStream object. I'd like to call the method readFully() but it requires a byte array. So I guess I'm fucked right? Also most of the methods can trigger some IOException, so is there a way to catch those exceptions?
you should ask @ancient grail
that is if you're willing to pay for it of course
What is your use case? If you just need all of the bytes then you could just call readByte repeatedly (less than ideal & less efficient, of course, but same result)
yeah of course I could do that if there's no other way. How about catching the exceptions then?
You can just wrap the entire thing in a pcall
hum last time I checked pcall was not implemented, maybe my memory is wrong though. Do you know for sure pcall is usable within pz?
Hey guys, I'm trying to write a little mod that allows me to craft a weapon, and it keeps chucking up an error and I'm not entirely sure how to fix it :/
also pcall would catch errors in Lua, but would it catch a Java exception?
There's certainly an implementation in kahlua, so unless it was intentionally taken out for some reason it should
What's the error?
On second thought, though: the BufferedReader class is exposed. Maybe it would be possible to create an instance of that with the stream
it's funny how people think errors are useless ๐
How do I do the thing where I embed the text, instead of just sending a massive wall of text?
```lua
-- code here
```
Or send the file, but the code fence works better for mobile
This message was regarding your question btw @weary matrix โ I haven't done it myself so unsure whether it'd work
It says it's related to ISCraftAction


