I've been looking around trying to find where the attack speed for firearms is defined, but I'm really not sure where it is. Is it tied to the AssaultRifleX animations? And their blend times? Or is there a variable defining the speed of these somwhere? I found a variable called autoShootSpeed in AssaultRifleDefault.xml but I can't find this defined anywhere in the lua
#mod_development
1 messages · Page 505 of 1
Is there any way to export a list of workshop IDs for active mods. Trying to setup a server and I dont want to manually have to add all them
through the in-game editor
I have been looking into the sauce of zomboid, what is this?
in D:\Games\steamapps\common\ProjectZomboid\media\lua\shared\NPCs\MainCreationMethods.lua
ObservationFactory.addObservation("Tough", "Tough", "He looks like he can handle $himselfherself$ in a fight.");
What Observations are?
is helicopter expanded good for first time players multiplayer?
i have the helicopter event set for sometimes vs once for the thrill
Hello I have been trying to see what actually calls the render function on UI elements and other things but I don't see it.
Maybe it says elsewhere in the mod's code if ObservationFactory is not in the base game? If ObservationFactory is in the base game it should be documented and also here's this https://pzwiki.net/wiki/Modding
Hey guys, Im new to PZ and I thought it might be fun to try some modding.
What is the best resource to learn PZ modding? Is it Zomboid-Modding-Guide on GitHub or are there other good resources?
And what types of mods are easy for first timer?
Thanks in advance
Making new items: Easy enough, can see how mods do it.
Making icons: Something that saves images with transparency.
Making models: Maybe blender. It can be .X or .FBX.
Having items automatically appear in the game: Uses Lua, can copy a mod that does this, you may make a mistake and break things if you do it wrong.
Also hey
Authentic Z, it has two mod ids..with spaces, doesnt seem right... can anyone confirm?
You can use Notepad++ with the Lua plugin, or if you want software that tells you your mistakes you could install the huge gigabytes of microsoft visual studio, or Intellj or whatever it's called maybe that does it too.
You could look at code that creates UI windows to see what it does like ISAlarmClockDialog to give just one example.
That's pretty dank
There's also this https://projectzomboid.com/modding/
What types of mods hmm I don't know well maybe you could try adding new items of different sorts and doing things with Lua. It would help to know about coding already.
So, apparently professions framework is not working with clothing 👀
Aha I just had an idea how to find out what calls render on UI elements. I add some buggy code and look at the error message in the console ohhh yeahhh boiiiii
Hey, for the used car mod... do I put al the mod ids in the server list? or just FRUsedCars
Idk if this was answered already but you have to run a 'clientCommand' to the server
like, what is FRUsedCarsFT?
if you're just creating zombies/cars/items its most likely being run through one of the connected clients not actually the "server"
a clientCommand ran through the server (with out a specific player given) will mirror the command to all connected clients
Is it just for me or also other mods have non-working custom profession clothing with professions framework on the latest build?
what was happening to me was it would actually spawn the zombies but the server would identify them as "stale" and instantly delete them
was it updated to work in MP?
I don't know, to be fair, I started modding PZ today
What I don't understand is if any of the Steam Workshop version is really updated at the same version of the github version
workshop versions are currently out of date vs the one on github
Ah okay, cause I was opening an issue there.
Am I supposed to use the GitHub version or the workshop version?
Modding in PZ uses only lua or java too?
And if so what are the different applications for these 2?
Also, unrelated question, how can I unpack the mods downloaded from the workshop so I can look at the code?
Nevermind they are unpacked into steamapps\workshop\content\108600
if you use the github then its going to be more of a pain to publish your mod until the workshop version catches up, since you'd have to actually package the github version with your mod to use its features instead of just adding it as a requirement, which is going to cause incompatibilities and other headache issues. its also potentially unstable atm, theres some features added i havent had time to fully test
and no unpacking needed? just browse to the steam folders and look at the code 🤨
Yeah im dumb I forgot that the mods are simply extracted in the workshop folder
Fair enough, I guess I will add clothes using directly the ClothingSelectionDefinitions
Also, impressive comments in 2ProfessionFramework.lua that was useful to look at
ah well, frameworks are only as good as their documentation XD
But I'm confused by a weird behaviour, I added the NightVision trait (cat'eyes) to my custom profession, but what happened is that the trait was added, but could also be removed, and I was able to duplicate the trait
By removing it I can clone it
add NightVision2, its the profession version (see 3ProfessionTraits.lua)
oh, damn, thanks man. Interesting bug tho 
not so much a bug. pz tracks profession versions of traits differently. for ones that are selectable and exist for professions theres 2 versions (this is vanilla behavior)
I'm wondering why Graceful2, NightVision2 and not GracefulPro, NightVisionPro?
Is it to keep consistency with how they are defined in the pz source?
Oh well you answered while I was writing the question lol
Thanks man
ya its consistancy
Works perfect 👍
man the log does not help with seeing what is making errors from mod
Is there a way to pull, say player 6's xyz?
ohh wow its Fenris_wolf the mod god
no answers yet
Yeah it does only work clientside
Any more Insight on that?
So it would be clientCommand.createHordeFromTo(...)?
Or do you know any other resources i could User asidenfrom the java doc
*use aside from
Dont really know where to start learning especially for mp
this does not seem to contain the inventory data, I also checked player.db files in my server directory. but nothing shows the data is stored there
Actually opening the player.db raw I can see the data. I guess the tables haven't been setup for all data
this is what I do for specific zombies - but you could do the same with another functions - all the client commands do is transmit the parameters
inside the /shared folder
function FUNCTION(PARAM1, PARAM2, PARAM3)
if isClient() then
sendClientCommand("MODULE", "COMMAND", {PARAM1=PARAM1,PARAM2=PARAM2,PARAM3=PARAM3)
else
--DO STUFF
end
end
inside the /server folder
--require the shared file name with out the path or .lua
require "SHARED FILE NAME"
--if isClient() then sendClientCommand(player, module, command, args) end -- to server
--_dataA = player, _dataB = args
local function onCommand(_module, _command, _player, _data)
--serverside
if _module == "MODULE" then
if _command == "COMMAND" then
FUNCTION(_data.PARAM1, _data.PARAM2, _data.PARAM3)
end
end
end
Events.OnClientCommand.Add(onCommand)--/client/ to server
it looks more complicated than it is
I can clean it up a bit
I keep the param names all the same because otherwise it's confusing - but it only cares about the order - so I've used it to transfer strings or tables
the function in shared uses isClient() to flip the function for both sides - if you're a connected client it sends the command - which then gets relayed to the "server" which then sends it to the clients as a client-side FUNCTION call
also means FUNCTION works in single player too
as it fails the client check anyway
I hope I'm getting the explanation right
but it works as intended
Is it possible to require "math" or somehow use math. on Lua for a mod?
I'm trying to generate a random number with my own seed
:p
ZombRand() is made in math.random's place
(I don't actually know why)
Doesn't work the same way if I recall
Crying right now
all player data is stored in players.db, I can see 2 tables using sqllite3 which are of no use. But opening the players.db as raw format I see all the stats, inventory data and what not is there.
Is there a way to modify this data? I can't seem to find a table for this data
All player data is indeed stored inside players.db, but as bytes. In fact, the IsoPlayer instance is saved there. You have to know how to deserialize this data to get what you want, you can get hints on how to do that by looking at the .load method inside the IsoPlayer class IIRC. Since this is a lengthy thing to do, its easier to make each client send its data in a better format to the server via a clientCommand and then store it in a file inside the server (that's what I did on my mod ServerPlayersData).
Also, characters that die will be deleted from the players.db
This is expected results for ZombRand()
@sour island do you know if there is a function to generate a random number with a given seed? :p
Uh
If random wasn't locked out, math.randomseed(seed) would work..
IIRC they implement a cellular automaton for random number generation
that's odd I can't find where ZombRand is defined
inside LuaManager, but its just a call to Rand.Next
Nope!
So the server is not authoritive? the client sends it's inventory data to the server and the server just accepts as true?
There's a reason the devs said don't just let anyone on your servers for a while
I did not check that, but I think so.. there are reported cases of people transfering saves between servers
that could be neat
I guess everyone is playing in good faith then
I wonder if multiple servers could be used for larger maps that hotswap players
than again the mapsize may not matter as MP stuff is supposedly mostly client side?
Like each server handles different parts of the map?
more or less
I think that could get confusing when crossing borders
Yeah the servers would need to know what cell they handle and the neighbouring servers
But I think it gets tricky when a player is in cell x and shoots a zombie that is in cell y
the map is chunk loaded
also server to server wouldn't be for smooth gameplay
but for weird gimmicks probably not zomboid related
another game called SS13 is set on a space station, and floating off the map has a chance to transfer you to one of their other servers entirely
so the station you orbit back to might be one that is different entirely
yeah it would be slow unless the servers were like very very close together or running on same machine
PZ is probably not the game to have this anyway
maybe a java modder in future could pull it off, but it would be very challenging
then it would be a true mmorpg
also with this @lemos - I'm not trying to read data. I'm trying to modify it while player is offline.
does your mod include inventory or health data? I haven't checked. From what I saw in description it was basic information
Ah, I see.. yeah, like we talked, I think the server is not authoritative on this matter D: ... No, my mod does not collect heath nor inventory, but I think at least health would be as easy as one line to add, the inventory not so much.
Just any aspect about the player really
Inventory items, health etc
I see the data in there
but no tables for it
how does one get titanium
@formal stone shouldn't be too hard
modders.. anyone doing some electric heater for heating up base?
u wotm 8
@sour island Looks like I would need the Random class to set a custom seed 😦
Math has only the random()
i wish there was some Metal Gear mods aside from the alert sound n stuff
I wonder why math.random is locked out anyway
like an old sneaking suit or something thats super rare military loot
gives u +1 nimble +1 lightfooted
i could help texture it n stuff
are pi functions locked out
if so, then it's probably a way to keep down resource usage
I mean that's not really something for them to decide
- doesn't stop someone from making a resource drain if they really wanted to
is math random still locked out? I haven't actually tested it for a while
I'm trying to make a special infected mod but I need to have some zombies wear specific things, I was looking at things and it seems like dressInPersistentOutfit might work, but I'm not exactly sure how to use it
does anyone know of a good way to do this?
either that or this "dressInClothingItem"
also please ping me if anyone answers lol
its not that much work to make a simple seed based number gen though if you really need it for a mod
How do I hook to the AddPlayer event?
I downloaded the Java Decompiler but when I try to open any .class files nothing happens. Help?
Cause via Profession Framework I can add a listener to OnGameStart but this is no very usefull if I just want to run the code when the player has spawned
any ideas how to probe the dedicated server for date, time and weather? I want to display that info on a webpage
hey all, is there a mechanism for replicating some arbitrary data from server to client? I have a server-managed value (a score) and want to periodically send it to clients but I'm not able to get that working with sendServerCommand (also tried calling sendClientCommand on server)
not a built in way, I have a couple of patches that expose that information on a HTTP server, but requires patching Java code
can you provide more info on this please?
I build a jar that gets loaded into the server by changing the server startup scripts VM args (-javagent:pz-agent.jar). It'll start a HTTP server on port 8080 with a simple endpoint on /info. Code for it is here if you want to build it: https://github.com/garyttierney/project-zomboid-server/tree/master/game-server-agent/, but it's a bit involved and I don't package it for use right now.
I downloaded the Java Decompiler but when I try to open any .class files nothing happens. Help?
also, do you have a public endpoint I can hit to see the data in action?
They come from the game as strings so don't have an exhaustive list, but normal, sunny, cloud, rain are the ones I've seen in seasonProps. I usually do but my server's offline for a couple hours to do a bit of patching and testing, I can ping you when it's back up
please do
When you mentioend "by changing the server startup scripts VM args" where you referring to this:
https://github.com/garyttierney/project-zomboid-server/blob/master/config/launcher/ProjectZomboid64.json#L26
yep, that's the one
@tacit ermine so if I just run this docker container... it should work?
oh yeah if you have Docker you can just run the container and check it out
Does anyone possibly know what could be causing this error? It happens after death, when I click on "New Character".
I wouldn't run that specific container in production though, it's a bit specific to my setup and has some issues I need to fix
I gotcha, I might just pull your com.github.garyttierney.zomboid.server.api code if you dont midn
any mod support you guys know of for custom radio messages?
I want to integrate scary events before wipe time, and want to warn them through my radio system
sure, feel free, it should be under MIT/Apache 2.0 but I might have forgotten to add license files
@tacit ermine so I understand the kotlin code just fine, but what is the java code doing in the com.github.garyttierney.zomboid.server namespace?
looks like it's all stat stuff? is that for the promethus stuff I saw in the k8s config?
that's the code that installs the bytecode patches with bytebuddy (raises the max player limit, starts the HTTP server on GameServer startup, shuts it down when finished)
and oh yeah it registers an MBean for prometheus
intresting, I assume the promethus stuff isn't needed for what I'm wanting to do though, do you agree? How useful do you find the instrumentation?
yeah, I agree, my server is setup for almost the sole purpose of gathering stats so that's why I have it
my data gets dumped into grafana so I can figure out where I make improvements in hosting
512 players is alot my guy 😆
yeah that's the engine limit
I just raised it to match that, it'll still accept whatever you put in the ini
except it won't reject it if it's >32
is that a RakNet limitation?
gotcha
so I'm looking for the code that starts the :8080 http server
is that all in the MBeanServer? The one that also has the /info endpoint?
Which is the name ID for a fully loaded 9mm magazine? if there is any
ah, and line 16, thanks I missed that. I was staring at this file for longer than I'm willing to admit
this is amazing @tacit ermine thank you very much
o7
realistically you don't even need to patch GameServer, you can just start the HTTP server in premain and let shutdown hooks deal with stopping it
the tech support channel said to parse the server output for "WeatherPeriod", which honestly is probably easier and faster to do. But this... this is what I'm going to do.
it might take a tiny bit longer to shutdown
can you elaborate on this?
this is the entrypoint to the entire thing: https://github.com/garyttierney/project-zomboid-server/blob/master/game-server-agent/src/main/java/com/github/garyttierney/zomboid/server/ZomboidServerPatcher.java#L18
when it loads it patches GameServer so it runs my code before it runs the real zomboid code
but I only did bytecode patches because I was also changing things like the player limit
you could just as well do the server.start() within here
I understand
trying to figure out how I can fork this without starting a whole new repo. I like the docker and prometheus stuff you've got going on, but honestly I'm just not there yet
so I want to strip that stuff out and just work with the http server for nwo
Anyone know if the supurb surviver mod is playable?
all you really need is the game-server-agent folder, that should produce a standalone jar with all its dependencies included if you run the Gradle shadowJar task
look up project humanoid its better but both mods only work in SP so...something to consider
you've helped me far more than I expected
the MBean doesn't do anything by itself and it's just a native Java thing, it's that separate agent (not my own one) I add to the VM args that does the work
so there's no harm in leaving it in, also no harm in just deleting the referencing code
nothing will break
and happy to help 🙂
What is PatchLoadMarker.java for?
it's so Java picks the correct class loader if zomboid is ever ran in a JPMS environment, with package isolated classloaders
if I try to reference the Advice class directly it'll cause the class loader to load the Advice and its dependencies (including GameServer), and then it'll be too late for me to patch it because it's already loaded
Ah alright is it on steam or and I'm perfectly content with single player
Is there a way to apply programatically a bandage to a newly spawned player?
nope only on Aiterons discord
Oh how does on get to this mythical place
So, I didn't manage to make the player spawn with applied bandages, but I found out how to make the player apply bandages automatically on spawn
Events.OnNewGame.Add(function()
local player = getPlayer();
if not player:HasTrait("Injured") then return end -- just return early, save a indentation level
-- Injure the player here just like in CD DA
local Torso_Upper = player:getBodyDamage():getBodyPart(BodyPartType.Torso_Upper)
local LowerLeg_L = player:getBodyDamage():getBodyPart(BodyPartType.LowerLeg_L)
local ForeArm_L = player:getBodyDamage():getBodyPart(BodyPartType.ForeArm_L)
Torso_Upper:setCut(true);
LowerLeg_L:setCut(true);
ForeArm_L:setScratched(true, true);
local item = newInventoryItem("Base.Bandage")
local item1 = newInventoryItem("Base.Bandage")
local item2 = newInventoryItem("Base.Bandage")
ISTimedActionQueue.add(ISApplyBandage:new(player, player, item, Torso_Upper, 10))
ISTimedActionQueue.add(ISApplyBandage:new(player, player, item1, LowerLeg_L, 10))
ISTimedActionQueue.add(ISApplyBandage:new(player, player, item2, ForeArm_L, 10))
end)
looking at ISApplyBandage:perform I think this is what actually makes it bandaged?
self.otherPlayer:getBodyDamage():SetBandaged(self.bodyPart:getIndex(), true, bandageLife, self.item:isAlcoholic(), self.item:getModule() .. "." .. self.item:getType());
I gave a look a that, but i'm not sure about what self.item:getModule() does
👀 🤔 Oh yeah?
self.item:getModule() .. "." .. self.item:getType() = Base.Bandage, best I can tell
Can servers have their loot distribution files directly changed, like without having to use a mod, and without other players having the changed setting?
player:getBodyDamage():SetBandaged(Torso_Upper:getIndex(), true, 0, true, "Base.Bandage"); kinda works, but for some reason the bandage spawns as already diry 👀
what did you set bandageLife to?
To 0
it seems like that's how long before it becomes dirty
if string.match(self.item:getType(), "Dirty") then
bandageLife = 0;
end
Oh so the life is not the time life but the "HP" of the bandage
yeah, looks like each bandage gets a random life based on base power of the bandage + doctor level
item Bandaid
{
BandagePower = 1.5,
}
item Bandage
{
BandagePower = 4,
}
etc.
Ah okay. makes sense
Events.OnNewGame.Add(function()
local player = getPlayer();
if not player:HasTrait("Injured") then return end -- just return early, save a indentation level
-- Injure the player here just like in CD DA
local Torso_Upper = player:getBodyDamage():getBodyPart(BodyPartType.Torso_Upper)
local LowerLeg_L = player:getBodyDamage():getBodyPart(BodyPartType.LowerLeg_L)
local ForeArm_L = player:getBodyDamage():getBodyPart(BodyPartType.ForeArm_L)
Torso_Upper:setCut(true);
LowerLeg_L:setCut(true);
ForeArm_L:setScratched(true, true);
local item2 = newInventoryItem("Base.Bandage")
player:getBodyDamage():SetBandaged(Torso_Upper:getIndex(), true, 10, true, "Base.Bandage");
ISTimedActionQueue.add(ISApplyBandage:new(player, player, item2, ForeArm_L, 10))
end)
Like this I have the best of the 2 world, I have pre applied bandages and the apply bandage animation the moment you spawn
https://steamcommunity.com/sharedfiles/filedetails/?id=2705655822&searchtext=
My first mod guys 🙂
this is the coolest thing ive seen in a while
btw, take note of the sendClient() bit in the original bandage code for multiplayer
Yes I noticed it, I will give it a look, cause I think I need to sync the bandage spawn probably
Thanks
can someone help me please? i cant seem to msg anyone on the tsar server for the true music mod 😦
zamm
you can use the OnNewGame event directly with the framework btw, not just OnGameStart
ProfessionFramework.addTrait('Injured', {
OnNewGame = function(player, square)
-- do stuff
end,
})
screams in pain
actually sorry, the args are (player, square, trait)
had to double check lol
dont really need the trait arg though unless your sharing the same callback function between multiple traits
Hey there, does somebody knows how to make a trait not appear in a MP server when the sleep is not enabled? is used the "not sleepOK parameter as its used for NeedsLessSleep, NeedsMoreSleep and Insomniac but for some reason it did appear 🤔
I have the trait like this:
TraitFactory.addTrait("Nightmares", getText("UI_trait_Nightmares"), -3, getText("UI_trait_NightmaresDesc"), false, not sleepOK);
the arg position used by not sleepOK is basically "disable in MP"...if its true then it should disable (though i havent played with 41 mp to confirm that still works), might be worth checking the value of the variable see what its returning
So I will debug it later but to confirm, it is disabled if the value is true, and enabled if it is false, right?
ya
Got it, will debug it later, thanks!
My friend is trying to join the server but he keeps getting this message https://gyazo.com/2d489e107e6562b58c5bd0589f976d24 Anyone know what this means?
@pearl path it means there's a file on the server that your friend is missing, but that's not the right place to ask about this, you should try #mod_support
thanks
Any clue guys how to hook a function that is declared inside another function?
function.function
hmm guess you're right 😅
lua is tables
all the way to _G
I made a variable initlizer to reuse helicopter objects - probably overkill to reuse objects but I don't actually know or want to look into garbage collectors lol -- but you're able to parse through objects for variables and functions
huh? functions dont index like this. lua will throw a error such as attempt to index global 'x' (a function value) (functions arent tables)
hmm
so how would you do the hooking then?
> x= function() local y=function() return end return end
> x.y()
stdin:1: attempt to index global 'x' (a function value)
guess I could replace the parent function, but I was hoping for a better way
you cant. unless that function (x) is returning the function (y)
replacing the parent is really the only option if y is local
with some magic you maybe can get kahlua to give up the local stack on x...but i'm not going to dig through the kahlua source to figure that one out XD
ah you're right, my bad:
ya... failed to get TESTb there
yeah
but in that example, you typo'd TESTb (the function is defined at Testb) and its also defined as a global (no local keyword) so you could just fetch it normally anyways
@weary matrix is this a vanilla function you're trying to override or your own?
good eye :p
if the function is your own you could have it return a table of functions
vanilla
cause I just made this quick mod to help some server admins: https://steamcommunity.com/sharedfiles/filedetails/?id=2705751144-
now trying to find out how to prevent disassembling but only for vanilla containers
love the picture btw 😂
@quasi geode so basically it's doing this:
function parentFunction()
local self = someObject.new()
function self.theFunctionIWantToHook()
end
return self
end```
So that I should just do this:
```lua
local result = parentFunction()
result.theFunctionIWantToHook = function()
-- my custom code
end
``` right?
ya
I was looking at some Typescript that was transcompiled into Lua and this may work.
function myFunction()
--declaring local things
end
["someString"] = myFunction;
And then in your function you can put
function myOtherFunction()
require("someString");
--your other things
end
The code had something like this
do
local ____export = require("someString")
for ____exportKey, ____exportValue in pairs(____export) do
____exports[____exportKey] = ____exportValue
end
end
ps does not work. requiring a function imports what it returns, not its local namespace
this is fine, since its giving you access to the function (storing it in a table and returning the table)
you could hook the parent function, catch the return result, and hook the function you really want there
Or maybe Lua treats ["myFunction"] the same as myFunction so that bit would be unnecessary for importing another function's local namespace.
@quasi geode sounds even better indeed
@undone crag oh weird I have not received a notification for your message 😮
Hey guys, was wondering do I need extensive knowledge of coding to get started with modding?
@cold ledge I think it's more about determination/motivation than actual knowledge
Oh I think I misread the Lua (transcompiled from Typescript) and it was not exporting a local namespace, it was instead returning a table.
No, knowledge of basic things is enough for a lot of things. For some things if you don't remember how to type them out like in pairs and in ipairs and for i=+, something:size()-1 do you can copy and paste from examples of them.
@undone crag not sure I understand how what you propose does apply to my problem though, but what Fenris_Wolf suggested is the way to go I think
So a mix of fundamental knowledge plus determination
Yes maybe.
Maybe.
Maybe. . . maybe is good
co` why is it you are wanting to use a function declared inside another function? Like is it so the function can have different local variables if it is declared in different circumstances? Is it just because you want the parent function to run at a certain time like on game load instead of when the Lua is all loading?
no, I just need to override the behavior of the inner function (both functions are from vanilla, not from my own code)
Which function plz tell I am interested
self.disassemble in ./client/Context/World/ISContextDisassemble.lua
Oh yeah it returns self :o
Hey that's odd, the code is not mentioning ContextDisassemble anywhere other than in that one place.
which function?
ah
ok
:d
oh yeah in that case you'd just
set self.disassemble = function() blah blah end
though
if you mean on everything created with that function
you'd hook function ISWorldMenuElements.ContextDisassemble()
call the original
and then at the end, you'd override that function
Oh it's going through the functions with loadElements
specifically
function self.disassemble( _data, _v ) is just syntactic sugar
for self["disassemble"] = function(_data, _v)
So you'd edit the table going into loadElements to change the one function in the one function. If the order is changed or one is added or removed the mod may bug from trying to edit the wrong function.
ModNamespace.oldContextDisassemble = ISWorldMenuElements.ContextDisassemble
local new_function = function(_data, _v)
-- your custom code here
end
function ISWorldMenuElements.ContextDisassemble()
local self = oldContextDisassemble()
self.disassemble = new_function
return self
end
though to hook it you'd need to keep a reference somewhere
you can probably rely on the fact that it's always going to be the same function, and only save the first reference?
I'm wondering whether it would be best to replace the whole ContextDisassemble function, or hook something into loadElements and go through the functions in pairs and snag the number that corresponds to the function you want if the lua scripts load in the same order each time.
I feel smoothbrain now D:
this is exactly what "hooking something into" is, basically
ModNamespace.oldContextDisassemble = ISWorldMenuElements.ContextDisassemble
local old_self_disassemble = nil -- if you're not calling the original function, you can skip this
local new_function = function(_data, _v)
old_self_disassemble(_data, _v) -- this too
-- your custom code here
end
function ISWorldMenuElements.ContextDisassemble()
local self = oldContextDisassemble()
if not old_self_disassemble then old_self_disassemble = self.disassemble end -- you can also skip this
self.disassemble = new_function
return self
end
if you're hooking the original this should work
if you just want to override and not hook, you can skip those lines i noted
Hang on are you a tulpa? :OOOO
I was thinking hey that's odd is this a transgender furry and ohhh even tulpas :O
i'm not!
i haven't been asked that in years... 💀
i used to be in the tulpa.im (or was it tulpa.info) irc chat Back In The Day™️
:o
I was interested in tulpas and servitors to try improving my brain's capabilities but what they call "parallel processing" seems legendary and rare or disputed, so having parallel minds for superior multitasking has unknown-to-me acquisition requirements. I kept interested in servitors and a mind palace or method of loci for improved memory and other mind things but what sucks is it would help to have a better mind's eye.
excuse me but I don't understand how the tulpa topic came in 😂
💀 that was the exact same reason i was interested
oh our mutual servers!
unfortunately the reason i gave up on it was aphantasia
anyway, code above should work for hooking or overriding that sub-function
you'll have to hook the outer function, but hooking it means it'll work fine with future tweaks to the function unless some large, breaking change is introduced (like the inner function name changing, or it no longer returning self)
yeah what Fenris_Wolf suggested should do it, same thing I think
💀 i missed that bit
Tulpas are really interesting to me though because your mind can actually do that. You know what this has implications for? I ask religious people and they say they pray and have spiritual experiences, but prayer seems essentially like a tulpa-forcing technique that creates a thing in your mind matching what you thought you were praying to. There will have to be some way of telling a real god apart from a god tulpa that you might get from praying to a non-existant god.
And also transgender people, what causes that? Some say people are born that way some people say people can become like that, well you can actually create a transgender tulpa and switch with it so it shows what the mind is capable of.
And also being gay, sometimes when a gay (or straight transgender) tulpa controls the body it becomes straight for the duration now that's interesting, also some tulpas don't change in that way when they control the body. INTERESTING SIGHTS INTO THE HUMAN MIND
interesting indeed but way off-topic for this channel though 😅
unless you're planning to make a tulpa mod? 😂
it's been so long since i've had someone who's interested in this stuff for the exact same reasons i was. might hop into the discord to talk about it later, but yeah, bit off-topic for here :P
nuu
Hmm actually that could be done. Different mental traits for each one.
One is claustrophobic, hmm actually there may be too few personality traits for it...
could have different players switch between control of one character?
the others are observers while one is fronting
it'd be neat for a multiplayer challenge run, i'd imagine
On multiplayer that could be practical ohh yeaahhhh.
Oh no too much is Java :d
ps I think probably
😔
Those cringelords at Tulpa Central banned me
Anyone familiar with sound emitters in PZ?
getting really weird behavior but then again I'm trying to do something really weird lol
i did play a little around sound emitter, what's up
so it appears looped sounds don't play for non hosts
so I am generating emitters clientside based on the host's requests -- they have IDs to identify them and they're stored in a list -- all is well there
but when I move the emitters around it causes the sound to chop
you make it with?
o.soundEmitter = fmod.fmod.FMODSoundEmitter.new()
o.soundEmitter:setPos(x, y, z)```
storedLooperEvents = {}
function eventSoundHandler:playLooperEvent(reusableID, DATA, command)
if isClient() then
---@type BaseSoundEmitter | FMODSoundEmitter
local soundEmitter = storedLooperEvents[reusableID]
if not soundEmitter and command ~= "drop" then
storedLooperEvents[reusableID] = getWorld():getFreeEmitter()
soundEmitter = storedLooperEvents[reusableID]
end
if soundEmitter then
print("soundEmitter:"..tostring(soundEmitter).." ("..command..")")
if command == "play" then
print("--play:"..DATA)
soundEmitter:playSound(DATA)
elseif command == "setPos" then
print("--x:"..DATA.x..","..DATA.y)
soundEmitter:setPos(DATA.x,DATA.y,DATA.z)
elseif command == "stop" then
print("--stop:"..DATA)
soundEmitter:stopSoundByName(DATA)
elseif command == "drop" then
soundEmitter:stopAll()
storedLooperEvents[reusableID] = nil
end
end
end
end
mhm
This is what the connected players recieve after the commands
the prints go through
and I can hear the sound
but it being severely cutout
moving emitters around don't cause this
so I'm not sure what is
@sour island ill head to bed now, but if you didnt find a solution ill check with you tomorrow
the root issue is looped sounds don't seem to get sent to non-hosts
but it could be that moving emitters don't update sounds to non-hosts
sounds good, gn
later bud
@tacit ermine I stripped that down to just the /info endpoint and got the following exception:
Exception in thread "main" java.lang.ClassNotFoundException: dev.oxymoron.zomboidServerApi.ZomboidServerPatcher
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Unknown Source)
at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(Unknown Source)
*** java.lang.instrument ASSERTION FAILED ***: "result" with message agent load/premain call failed at ./src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 422
FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed
Aborted
Here was the argument - pzexe: vmArg (json) 1: -javaagent:/home/oxymoron/pz-agent.jar
can you pastebin/gist your ZomboidServerPatcher.java
or the output of
jar tf /home/oxymoron/pz-agent.jar | grep ZomboidServerPatcher
if Premain-Class points to the correct class name it might be failing to load ZomboidServerPatcher because a class it depends on isn't present (could be that you have the normal jar instead of the shaded jar with bytebuddy included)
lol sorry @tacit ermine I inspected my compiled .jar and found that it didn't package that code at all
it wasn't even being built. it was just packaging up the dependencies. but now that I am building the files it's failing because zomboid.* dependencies are missing
Any ideas how I can let the compiler find zombie.*
yeah, there's a gradle property you need to set to your zomboid path
you can set that by putting it in gradle.properties
gotcha... So I have a confession to make
I might have switched to maven...
I'll figure it out 😅
I think for maven you'll need to generate a jar for the classes and a fake POM
can do it with mvn install:install-file
which .jar do I need for the zombie.* namespace?
the zomboid classes aren't in a jar, they're just sitting in the root of the game folder
er, unless you're on Linux, then they're in java/
oh wow
ok
thx
so that is what you mean by generating a jar...
oof
@tacit ermine does your pz-agent.jar include the zombie.* namespace in the shadow jar?
gotcha
jar cvf project-zomboid.jar ./**/*.class should be enough from the pz game folder
or from the java subdir if on Linux
developing/compiling on windows
game server and test game server on linux
same jar, just the folders are different on each platform for some reason
JVM installations typically live under /usr/lib/jvm on Linux, binary will be under the specific JVM's bin/ folder
yeah, I know, I'm just supprised javac is there and jar is not
update-alternatives --config jar might let you symlink the correct path into /usr/bin
fixed, thank you 🙂
Only for the dedicated server
@tacit ermine Got all the dependency jazz and whatnot figured out, the .jar is building how I like and it's loaded. Here is my new exception
try relocating net.bytebuddy under a different package with the maven shade plugin
you already have the shade plugin, so just add this to its <plugin> block
<configuration>
<relocations>
<relocation>
<pattern>net.bytebuddy</pattern>
<shadedPattern>dev.oxymoron.vendored.net.bytebuddy</shadedPattern>
</relocation>
</relocations>
</configuration>
ah
I understood
looks like the same exception
pushing so you can see if I did what you had expceted
you're missing the Can-Redefine-Class or whatever it's called option here https://github.com/Oxymoron290/project-zomboid-server/blob/master/pom.xml#L173-L175
Can-Retransform-Classes and Can-Redefine-Classes
I do have my bytebuddy relocated too, think I hit an issue with it
\o/
you are a wizard!
you can extend it with whatever information you want fairly easily. I was going to add a couple things like recent deaths, zombie counter, number of factions, etc.
lol
I'll figure that stuff out another night! This is amazing
you just need to add the dependency in that error to your POM
I just took a second to read it 😅 let me try
it complains on the console log too about another 2 if you want to add those https://github.com/garyttierney/project-zomboid-server/blob/master/game-server-agent/build.gradle.kts#L26-L28
oh. lol I looked for those references while I was building my pom.xml and I figured they were used as part of the stuff I stripped down.
it'd be cool to include the actual date using the thing you linked docs on earlier, I only used world time because I put this together pretty quickly and didn't find the actual date in my 2 minutes of searching
I've been relying on rcon cmds for this server - https://status.oppress.io/
this is gonna be so awesome!
yeah I tried to put stuff together with RCON but it's pretty limited and it doesn't seem like you can even register new RCON commands with lua
same findings here. that was my first route
Honestly I kinda shied away from modifying the java code. I mean I'm a software dev by trade, but patching java code and having to deal with the headache when IndieStone updates didn't sound all that awesome. but You've really helped me see how powerful it can be
I'll probably have questions for you over the next few days to understand really what I've just done, but I'm really greatful for all your help and assistance (And hand-holding)
there's a lot you can do and as long as you're not searching for literal bytecode patterns and TIS don't start obfuscating code it can go pretty smoothly, and of course now you have an entrypoint into the server you can change everything that's only accessible via java
and feel free to ping any time, always happy to help
@dreamy flicker which command you using to get days elapsed + weather?
currently I'm just using what @tacit ermine has - https://github.com/garyttierney/project-zomboid-server/blob/master/game-server-agent/src/main/kotlin/com/github/garyttierney/zomboid/server/api/ZomboidApiServerAdapter.kt
Nater suggested https://zomboid-javadoc.com/41.65/zombie/GameTime.html
Javadoc Project Zomboid Modding API declaration: package: zombie, class: GameTime
ty
Is there overlap/hit events for when an item touches an object?
for example a plank on the floor touching a barrel
or is there no concept of that in the game? 🙂
"Scavenger's Workshop" crafting station, for upgrading bags, making scrap weapons, cooking up bathtub speed, etc.
How do you create a patch for a mod for pz
- Make the fix
- Put it in a mod format
- Make your mod dependent on the original - as in, make the parent mod a requirement to use your mod. - Which is pretty easy
Hey guys, what is the function to pull my character's x,y,z?
I need a lua programmer. Details in personal correspondence
...that caravan looks awesome
Is the firing speed for guns fixed across all of them? Is there any way to change it? SwingTime does nothing, so I think it might be tied to the animation than any of the stats
In WorldEd i can choose to right click open in TileZed. atleast it used too, it doesnt work anymore, why is that?
does anyone know off hand if what the setxxxxxx() property is for adding VHS media to a television signal device?
@teal slate hey, are you around?
trying to execute that code:
ServerOptions.instance.MaxPlayers = new ServerOptions.IntegerServerOption(ServerOptions.instance, "MaxPlayers", 1, maxPlayers, 16);```
so the ServerOptions.instance field is static, but not the ServerOptions.MaxPlayers field, but since the instance is static, the MaxPlayers field should get initialized before main is run right?
yet I'm getting this error when running the code:
Exception in thread "main" java.lang.ExceptionInInitializerError
at zombie.javamods.CustomServerOptions.setMaxPlayers(CustomServerOptions.java:8)
at zombie.javamods.ServerMain.<init>(ServerMain.java:24)
at zombie.javamods.ServerMain.main(ServerMain.java:52)
Caused by: java.lang.NullPointerException: Cannot invoke "org.uncommons.maths.random.CellularAutomatonRNG.nextInt(int)" because "<parameter2>" is null
at zombie.core.Rand.Next(Rand.java:80)
at zombie.core.Rand.Next(Rand.java:91)
at zombie.network.ServerOptions.<init>(ServerOptions.java:48)
at zombie.network.ServerOptions.<clinit>(ServerOptions.java:165)
... 3 more
any clue what I might be doing wrong?
let's see
static initialiser -> instance initialiser -> rand
lemme look at the source for serevroptions
at zombie.network.ServerOptions.<init>(ServerOptions.java:48) oh this isn't the constructor
relatively sure this is the instance initialisation?
let's see
well not sure but if I don't call my setMaxPlayers function then no crash
oh wait
it could be ParseInt failing
if (maxPlayers != null)
CustomServerOptions.setMaxPlayers(Integer.parseInt(maxPlayers));
try logging what Integer.parseInt(maxPlayers) is
ah, wait, if it was failing there it wouldn't return null
it'd raise a NumberFormatException
fwiw, you unfortunately also need to override ServerOptions.getMaxPlayers()
public int getMaxPlayers() {
return Math.min(32, getInstance().MaxPlayers.getValue());
}
eough
yeah it is 64:
HOLY MOSES: 64
i can't tell where this Rand.Next() call is coming from in ServerOptions
public ServerOptions.IntegerServerOption ResetID = new ServerOptions.IntegerServerOption(this, "ResetID", 0, 2147483647, Rand.Next(1000000000));
public ServerOptions.StringServerOption ServerPlayerID = new ServerOptions.StringServerOption(this, "ServerPlayerID", Integer.toString(Rand.Next(2147483647)));
@tacit ermine why? Since getMaxPlayers() is using ServerOptions.instance.MaxPlayers
either of these, maybe
it can't go above 32
see the code Jade posted
it picks whatever's smaller, 32 or whatever ServerOptions.instance.MaxPlayers has
yeah I lost an hour or 2 to that
Rand.Next() isn't called anywhere in this code?? aghh
I do have to wonder, though
Why make a new IntegerServerOption?
the IntegerServerOption has a max, which is private, but the JVM isn't too picky about going behind access levels
ahh
damn so no way to do that without patching I guess... f***
i still can't figure out where the Rand.Next() call in the stacktrace is coming from
public ServerOptions.IntegerServerOption ResetID = new ServerOptions.IntegerServerOption(this, "ResetID", 0, Integer.MAX_VALUE, Rand.Next(1000000000));
is the crash
yeah it is weird
Caused by: java.lang.NullPointerException: Cannot invoke "org.uncommons.maths.random.CellularAutomatonRNG.nextInt(int)" because "<parameter2>" is null
Rand.rand isn't initialized
so Rand.init() hasn't been called
oh wait
which is typically done in GameServer.init() and GameWindow.init()
i think accessing instance might initialise it earlier
so it sounds like you're just doing it a bit too early
but even if I was doing it a bit later my stuff still couldn't work :/
you're welcome to look at how I do it, but I patch the bytecode at runtime with bytebuddy: https://github.com/garyttierney/project-zomboid-server/blob/master/game-server-agent/src/main/java/com/github/garyttierney/zomboid/server/ZomboidServerPatcher.java#L22-L39
then I hook IntegerServerOption https://github.com/garyttierney/project-zomboid-server/blob/master/game-server-agent/src/main/java/com/github/garyttierney/zomboid/server/patches/ChangeServerOptionDefaultsAdvice.java#L9 and getMaxPlayers() https://github.com/garyttierney/project-zomboid-server/blob/master/game-server-agent/src/main/java/com/github/garyttierney/zomboid/server/patches/ChangeServerOptionsGetMaxPlayerAdvice.java#L9
hmm guess I could simply make a one byte patch of the .class before running, should be relatively safe 😅
gotta wonder why no one's tried using mixins with pz 🤔
i asked in there and it would technically be supported
(though i haven't tried; not really familiar enough)
java has mixins? 🤔
do you mean the minecraft modding framework?
it's not just for minecraft
the mixins framework is compatible with basically any java game (or maybe even any java project), i think
as far as i can tell it seems pretty similar to HarmonyLib for Rimworld/Caves of Qud, though it doesn't have the option of writing transpiler patches in IL
(I suppose the equivalent to that for Java would be bytecode patching?)
yeah, no reason you can't use it outside of minecraft for generic bytecode weaving
think the main issue with zomboid would be getting the mods in there in the first place :P
you mean people working on Java mods or just loading them at all?
i feel the steam workshop would probably take umbrage with "lua bootstrapper that copies a .jar from the mod into the classpath"
loading them, yeah
at the point Lua is initialized is way too late for me, so I need to come up with something a bit leaner anyway
oh, i meant "run the mod to copy it into your classpath, then restart the game"
Hi!
Does anybody know if there is a way to randomly get items by category?
I mean, I need a function to return me all items by category, is there any function in the game or should I create my own?
Edit: For example to return all medical stuff in the game
it'd still be inconvenient and awful for servers
yup
but it's the only way i can think of to do java modding via workshop
well, "java modding" and "via workshop", in scare quotes
I think ideally you'd have something that starts up before zomboid, scans enabled mods, and adds them to the classpath
I load javamods 😛
Oh, could probably edit the json to add something like %USERPROFILE%/Zomboid/javamods to the classpath?
🤔
that's how I do it on my server, yeah
@teal slate fyi you can have a .jar in your mods on the workshop (I tried it), only problem is to install the java mod loader itself
you could create an installer that updates the Steam launch options for the game
if you add -pzexeconfig my/own/file.json to the actual Zomboid launch options in Steam it'll load your custom options instead
i figure that moving files into arbitrary places might be considered malicious or potentially malicious by steam
having a .jar there is probably fine
oh i see
the modloader would check in the mods folder
🧐 i see........
and Steam launch options are stored in this text file (one for each steam ID) C:\Program Files (x86)\Steam\userdata\<id>\config\localconfig.vdf, relatively easy to update
ooh that's nice, so far I was copying the ProjectZomboid64 binary and patching the JSON file name 😂
yeah, I went looking to see if that was possible after I found your javamods repo and got the idea of Steam launch options
I do the steam launch option too for singleplayer
the "Good" stuff about steam is their file integrity check doesn't care about extra files in the installation folder 😄
@teal slate @tacit ermine we should make a #javamodding channel 😄
could ask for at the very least a java modding thread in here
not sure TIS would be up for it
fair
i'm not actually planning on doing any java modding, myself
been considering making a lua modding wishlist instead
imo the biggest issue is getter/setter asymmetry
some things have public setters and private getters, or vice versa
yeah that's so annoying :/
heck, some things have public setters and no getters at all
(or vice versa)
wonder how hard it would be to parse the project/javadocs and detect those asymmetries
that wishlist could probably be implemented through javamods though
at least for getters/setters no problem
hmm wondering if I could do it with my BeautifulJava tool
since I already parse all the source code
could make a list of all getters/setters by fully qualified name, then substitute get/set in each for the opposite, and report ones that are missing or have mismatched visibility
kotlin exposes that quite nicely
could probably get property style docs from the java classes with kdoc
indeed
@tacit ermine what if you want the full list?
like to make a bug report to TIS or something
full list of getters and setters?
yes but more specifically the list of asymetric getters/setters, like when you have a public getter but a private setter or vice-versa
anyone know what the setter for AcceptedMediaType is? Tried deviceData:setAcceptMediaType(1); but it doesn't like it
can't find anything on google
@heavy hearth do you have a reference to a Radio instance? If yes you should try to call setAcceptMediaType on this object
hi, i want to do some ui modding, is there any document or tutorial about this topic? thanks
@weary matrix yeah. I'm creating the defice instance with local deviceData = part:createSignalDevice(); and all the other bits work but it doesn't like setAcceptMediaType
function Vehicles.Create.Television(vehicle, part)
local deviceData = part:createSignalDevice();
deviceData:setIsTwoWay(false);
deviceData:setTransmitRange(0);
deviceData:setMicRange(0);
deviceData:setBaseVolumeRange(10);
deviceData:setIsPortable(false);
deviceData:setIsTelevision(true);
deviceData:setMinChannelRange(200);
deviceData:setMaxChannelRange(1000000);
deviceData:setIsBatteryPowered(false);
deviceData:setIsHighTier(false);
deviceData:setUseDelta(0.007);
deviceData:setAcceptMediaType(1);
deviceData:generatePresets();
local invItem = VehicleUtils.createPartInventoryItem(part);
end
Serious answer: there's a lot of reluctance to add more channels, for multiple good reasons, but mainly they cumulatively create more effort and time sink for the management. I pushed for a modding guide workspace channel recently, and the consensus was "if it was to be added, now isn't the right time".
As things are so chaotic right now, and the management has their hands full, I would suggest waiting for things to calm down, maybe a month or two?, before seriously floating that proposal?
(too buy/& disinterested to debate the pros and cons of adding channels RN, but though might be worthwhile advice 🙂 )
@willow estuary thanks, but to be honest I don't expected TIS to create a #javamodding channel, not sure they would want to hear about it at all 😂
@heavy hearth hmm weird, cause there is a setMediaType() method in DeviceData. Maybe it really needs a byte though?
public void setMediaType(byte byte1) {
this.mediaType = byte1;
}
ah. k
@heavy hearth what error do you get?
function: Television -- file: SFDriveVehicles.lua line # 43
Callframe at: addVehicle
function: SpawnVehicle -- file: CheatCore.lua line # 1231
function: worldobjects -- file: ISUICheatMenu.lua line # 364
function: onMouseUp -- file: ISContextMenu.lua line # 90
ERROR: General , 1641220712216> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: Object tried to call nil in Television at KahluaUtil.fail line:82.
ERROR: General , 1641220712216> DebugLogStream.printException> Stack trace:
line 43 is the setAcceptMediaType so must be type casting
is it supposed to be setMediaType, not setAcceptMediaType?
oh right
lol can't see the wood for the trees
thanks for spotting that
yup. that was it. thanks for spotting that one
@heavy hearth if the problem had been only related to the int/byte stuff, then I think it wouldn't throw that error that you tried to call nil
I think it was that setAccept doesn't exist as @tacit ermine pointed out. deviceData:setMediaType(1); works
Hello. I ha ve a problem with a mod I'm trying to make
It works okay in solo
but when I do a host or connect to a local server the client crashes right after chracter creation
@zenith smelt what's the error?
Game instnatly closes
nothing no error
Just closes
"These are the end times" appears and then the game closes
Is it on the right version? I did that before.
When you call getCell() on the server side, what does it returns exactly?
hmm does it work at all?
Does not give an error, at least, but I'm not sure behind the meaning of it...
have you tried to print the returned value?
I have no idea but it just make no sense to me, like what would it be supposed to return? 😮
It does return an IsoCell object
So I have a pretty basic level of programming under my belt. Never have used Java or lua really. Do you guys think making some basic mods is a bad decision?
@flint bolt check the coordinates maybe?
Because right now I’m trying to work on a mod that basically just adds a custom zombie and potentially has certain items on him etc. it seems simple enough
@flint bolt why do you need getCell() in server code anyway?
Not really, especially if it's basic since it can still help you to get into the swing of how you'll be modding, uploading to the workshop and so on.
Multiple mods like Customizable Zombies and others that change the zombie speedType are using this on the server-side. I want to understand why. Tried to get the WorldX and WorldY of the cell, it returns 0 for both
Ok thank you I was just curious because people have been saying the documentation and all that and the wiki are out of date and you’ll probably have to reverse engineer the source code to figure things out
It heavily depends on what mod you're making.
Can't say for certain of the documentation or wiki is out of date, although I for the life of me CAN NOT find the damn code that handles the fitness stuff, so I might have to resort to digging into the source code.
I do know for like making a trait mod I'm working on to remove some of the traits from base game I had to reverse engineer the trait system, aka make the game just rebuild it but without two traits. But that's obviously just for modifying/removing stuff. Not adding new content like items.
How do player ids change when people join and leave a server? Using getSpecificPlayer()
if 12 are connected, then numbers 4 and 6 leave, do the remaining players fill the holes so getSpecificPlayer(10) will now be the 12th (last person to join)
Maybe a bit silly idea as well I was thinking of making a vape mod. Where you can find like vape juice or something to refill it and it runs on batteries. I’m not sure how complicated this would be. I’ve got quite a few ideas running through my head. Just slowly working and figuring everything out
@fleet smelt If it's a client side script, getSpecificPlayer will always be 0 on the client. Unless they're running splitscreen.
oh I see, weird though
What about server side?
Server side uses 'onlineID'.
player:getOnlineID()
getPlayerByOnlineID(int)
That's actually a funny yet interesting idea.
I think the main issue I can likely imagine running across is it's battery part. But otherwise the items, spawn locations and such should be fairly easy.
Though it does sound like it may have a custom animation/models. Which not sure how easy or hard that is.
Awesome. Could a clientside script pull another players info by changing xxxxxxx in getSpecificPlayer(xxxxxxx)?
Thank you for your input! Good luck on your mod
You could even make fat vape clouds
Thanks, although I'm likely about to just put a pin in it since I can't find anything atm, no one seems to know it either and I'm currently not in the mood to start digging through source code.
Hmm, I'm not really sure to be honest. I think you can still do getPlayerByOnlineID clientside, but I'm not sure if you could change another client doing that or if you would need to send a command to the server.
is there a way to disable dropping equipped items on a fall? (OnItemFall)
i can't seem to find the lua code that handles it
I doubt it
Understandable. I’ve just been looking for anything to pull me into that learning mood so I can finally get working in a field I want
I think I've mistakenly been working on something that should be handled by the server :^)
For the few server side things I've had, I've been using the sendClientCommand to do server side stuff and then from the server I'll do sendServerCommand back to the player(s).
#mod_development message
@fleet smelt Actually, now that I think about it, this might help you with what you're trying to do. In this example, I'm calling it from the OnPlayerAttackFinished event and I'm passing the sound radius to the server (player is passed automatically). Then I pass the playerID and the radius back to the client, where I check if the playerOnlineID matches the local player so I can do stuff for everyone except that player.
--client
sendClientCommand("Test", "toserver", {handWeaponSoundRadius = handWeapon:getSoundRadius()})
--server
sendServerCommand("Test", "toclient", {playerOnlineID = player:getOnlineID(), handWeaponSoundRadius = args.handWeaponSoundRadius})
--back on client
local specificPlayer = getSpecificPlayer(0)
if (specificPlayer:getOnlineID() ~= playerOnlineID) then
--do stuff for everyone except the player who triggered the orginal sendClientCommand
end
sounds a lot like you're doing something similar to me
I'm working on something so guns can make you/others around you temporarily hard of hearing/deaf. I want it to work with any modded items (and I'm too lazy to make a manual list) so the hearing protection is calculated by insulation, wind resistance, water resistance, bite/scratch defense, and quality. (Except ear plugs/ear muffs). Not exactly a foolproof system as a lot of these don't even cover your ears, but I figure it's more of a balance thing too.
I've been having more issues with the text above the player's head properly triggering than anything, because as far as I know, there's no easy way to detect when a player equips or unequips something.
https://streamable.com/ohob3m
what are some good mods that make firearm gameplay more friendly?
very very cool
It's mostly done, I'm to the most boring part: testing, setting proper values for hard of hearing/deaf, and making sure there's no performance problems/issues/etc. So progress has been slow lately.
Are custom occupations possible? If so, is there a guide i can follow to make one?
They are possible, there's a mod that provides a framework for it.
My advice would be, download a mod that adds custom occupations and look at how they do it.
https://steamcommunity.com/sharedfiles/filedetails/?id=2216760107&searchtext= this is the mod that provides a framework for it,
thanks man
no problem 🙂
I dont know a mod that uses this mod as an example from the top of my head, but ill try find one
oh nvm
forum has a good guide to using this mod
The Indie Stone Forums
This mod is designed to simply the process of adding new professions, or editing the default ones. As well as simplifying the addition/modification of a profession's skills, traits and known recipes, it also allows for the creation of custom profession starting kits: both items in inventory and o...
Is there a way to draw debug information above a zombie? For example, draw the onlineID of a zombie above its head?
Guys, we need electric heater to base mod!
Delete if not allowed,
However, I would like to "commission" a modder or dev or someone with the know how, to make a small mod for Project Zomboid for me, if anyone is interested in this please reach out 🙂
@pearl prism I am sure I can stack some stuff on the floors and not just seats :]
for a difficult scale from 1-10 how hard would custom ui be to code in zomboid ? never tried to code ui boxes.
I can't get the OnClientCommand lua event to trigger unless I use triggerEvent. I'm connected as an admin to my dedicated server btw.
client script
...
local player = getPlayer();
sendClientCommand(player, "myModule", "test", nil);
triggerEvent("OnClientCommand", "myModule", "test", player, nil);
...
server script
local Commands = {}
local ClientCommands = {}
...
Commands.myModule = {};
Commands.myModule.test = function(player)
print('works');
end
ClientCommands.OnClientCommand = function(module, command, player, args)
print('received '..module..' '..command..' '..tostring(player)..argStr);
if Commands[module] and Commands[module][command] then
local argStr = '';
for k,v in pairs(args) do argStr = argStr..' '..k..'='..tostring(v) end;
Commands[module][command](player, args);
end
end
...
Events.OnClientCommand.Add(ClientCommands.onClientCommand)
it only triggers server side. your client script would never pickup on the event....ie: its triggered on receiving a client command, not sending one
sendClientCommand() doesn't trigger OnClientCommand() on server script ?
hi, what causes my items icon to be blurry in the ui?
it should trigger it for the server only
my items resolution is 16x16
but calling triggerEvent on the client would only trigger things on the client not the server
the sendClientCommand() in my client script isn't triggering Events.OnClientCommand.Add() in my server script though?
only on the client though....client's will still load the scripts in the server directory, but much of the stuff in there will be ignored...like OnClientCommand hooks (unless you force them to trigger)
the event should still be triggering normally on the dedicated server
idk, I'm using OnKeyPress event to debug the events and it never works with sendClientCommand() only wih triggerEvent.
does ValuTech have a logo?
relooking at your server side script it might be throwing a error
ClientCommands.OnClientCommand = function(module, command, player, args)
print('received '..module..' '..command..' '..tostring(player)..argStr); -- <<<< argStr is not defined yet. cant concentrate a nil value
if Commands[module] and Commands[module][command] then
local argStr = '';
for k,v in pairs(args) do argStr = argStr..' '..k..'='..tostring(v) end;
Commands[module][command](player, args);
end
end
im modelling a heater radiator or whatever and im making the valutech version of it
gonna be a plack on the side that says valutech
@old blade i think a picture of a dumpster would be accurate
lol
i was thinking something kinda like this
might make an actual proper logo for this
nope, nothing in logs and I've also tried something really simple to see if OnClientCommand get s triggered with ```
ClientCommands.OnClientCommand = function(module, command, player, args)
print('received ');
end
Events.OnClientCommand.Add(ClientCommands.onClientCommand)
--debugging
local function onKeyPressed(key)
local player = getPlayer();
if key == Keyboard.KEY_Z then
player:addLineChatElement('test');
sendClientCommand(player, "module", "command", nil);
--triggerEvent("OnClientCommand", "module", "command", player, nil);
end
end
if I uncomment triggerEvent it will trigger the OnClientCommand though
@old blade I would use that logo and throw a corporate planned obsolescence theme on it
ill probably end up combining this and something like this
Based on the sendClientCommand shown here, I think this would work as long as it's in the server directory:
local function testOnClientCommand(module, command, player, args)
if not isServer() then return end
if module ~= "module" then return end
if command == "command" then
print("onClientCommand")
end
end
Events.OnClientCommand.Add(testOnClientCommand)
I know a lot of the examples use the 'ClientCommands.OnClientCommand', but if it's only a few commands it really won't matter, as far as performance goes.
For some reason my mods script isn't showing up in the debugger, is there anything obvious I might be missing?
How can I print messages from the server into player's chats, I'm trying to find the code that sends the serverwelcomemessage, I'm sure I'll get there eventually, but if anyone knows off the top of their head that'd be incredible
doesn't work for me either do I need to enable something on my dedicated server ?
besides mod ofc 🙂
Looks like you actually need to remove 'player' from the sendClientCommand(player, "module", "command", nil); line. The player is passed as the 3rd parameter of the OnClientCommand so you'll have access to it either way.
Most of the vanilla code passes player first too, so I'm not sure if that's a side effect of me not using the 'ClientCommands.OnClientCommand' setup exactly the same, or what.
idk, I'm using #mod_development message in my server script and in my client script I'm doing --debugging local function onKeyPressed(key) local player = getPlayer(); if key == Keyboard.KEY_Z then player:addLineChatElement('debug (Z key pressed)'); sendClientCommand('module', 'command', nil); end end
and print("onClientCommand") is never called
Here's exactly what I have in client:
local TestFunctions = {}
TestFunctions.testKeyUp = function(keynum)
local specificPlayer = getSpecificPlayer(0)
if (specificPlayer ~= nil) then
sendClientCommand("module", "command", nil)
print("sendClientCommand")
end
end
Events.OnKeyPressed.Add(TestFunctions.testKeyUp)
And server:
local function testOnClientCommand(module, command, player, args)
if not isServer() then return end
if module ~= "module" then return end
if command == "command" then
print("onClientCommand")
end
end
Events.OnClientCommand.Add(testOnClientCommand)
~~still doesn't work going to try closing everything out ~~
hahaha you make a good point
This rear door would be amazing to see animated, you could see the entire vehicle from the inside. I'm almost redoing my entire model
No, I do most of my initial testing in debug as well. You're starting a dedicated server, right?
yep, with the PZ dedicated server tool from steam.
That's how I installed mine as well. Super weird...
no errors in console.log or the server terminal either
been a hot minute since i worried about these things, but are you sure lua treats ' as equal to "
uh, are you talking about the key == Keyboard.KEY_Z?
no, i'm asking if lua treats ' as equal to "
== equal to and ~= not equal to
😐
' == " ??????????????
you're using ', I've only ever used, and seen " being used in lua
i don't see w/e character you typed
oh wait im dumb now i get it
you can use ' or " but you need to use double quotes to show special chars
Is there any mod that hides tailoring patches?
nice
Guys, I'm creating a car mod, but I'm stuck with a problem. Basically, I want to make the Glove Box unbreakable, because it's the only part that isn't repairable. I'm using Dash Rancher (ingame id: OffRoad) as the test car. I can't make it work. Here is my code:
Events.OnPlayerUpdate.Add(function(player, vehicle, args)
local vehicle = player.getVehicle and player:getVehicle() or nil
if (vehicle and string.find( vehicle:getScriptName(), "OffRoad" )) then
local gb = vehicle:getPartById("PassengerCompartment")
if gb:getCondition() < 100 then
gb:setCondition(100)
end
end
end)
What am I doing wrong here?
My mod is not appearing in the Select Mods menu, and I do not know why, I can provide screenshots
You probably just put your mod on wrong filepath
Should be C:\Users\YourUser\Zomboid\mods
thank you!
(:
Anyone know why my dedicated server isn't reacting to the OnClientCommand event?
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
icon is showing a question mark instead of the icon, how do i fix this?
This is a bittersweet moment when my code actually works
@thin hornet @weary matrix
no more sound skips for looped sounds in MP
in mod/media/textures of the mod, make sure there is an icon named item_Joint.png
or whatever the script has for its icon tag
oh is the i in item supposed to be lowercase?
doesn't have to be
apparently, it still isnt working
what is the item script?
hey guys if I make a mod that turns zombie models into the terminator (T-800) could Skydance Media come after me for copyright?
joint.txt
shamelessly bumping my own question
no I mean what is the item module within joint.txt
this thing?
the whole thing of that item
Item_Joint.png
so i needed to put .png at the end of joint?
no
ah i gotcha
but the icon iteself is a png right?
it is
👍
it works!
sweet!
Where is the tailoring skill coded? Like patches on clothing.
addpatch.lua or something
I'm afraid patch only brings up the patch textures
Anyone worked with the built-in RCON provided at all?
Hi all. Got these earlier from the Brita armor pack. IS there a way to turn them on?
How do I see what are the vehicles ScriptName?
Coobs this is really meant to be for chatting about making mods though. :/
i finished mystique hair and made all Rogue clothing, took me 6h to make her entire outfit 🙂
rogue comes with Boot, Gloves, Suit, Jacket, Functional Belt and Hair separated
I created a weapon but the model doesnt attach to the player correctly, how do I change the offset of a model?
how easy is it to reskin a car?
I just want to make a skin of irl car and put it on an existing ingame car
does anyone know if there will be a new or updated NPC mod coming out?
indie stone is working on it but it will take a while
that's why i asked about a mod
idk lol
I've seen some people talking about 'Project Humanoid' being pretty good. Haven't been able to dig up where to get it though, someones Discord apparently.
ok, thanks. i'll look out for it
yeah apparently its in aiteron's discord
found it. thank you :)
improved my superman suit texture and made a new cape model
Anyone know why for some reason when the mod translates into Russian it... Does this?
It doesn't look anything like it in .txt so did I do something wrong or...?
not sure if this is the same error but i think you have to change the text file's encoder
That would actually make sense, an idea what encoding I should use? (For Notepad++)
Windows-1251 should fix that. :)
Thanks! ^^
Armored Doors and Windows (build 41) keeps updating???
Update: Jan 4 @ 4:04am
Update: Jan 4 @ 3:46am
Update: Jan 4 @ 3:38am
I need some advice on radial menus. my mod is blocking another mod from adding slices to the vehicle menu. I'm using this wrapper block which seems to be what other mods are using
-- Save default function for wrap it
if WWVehicleMenu.UI.defaultShowRadialMenu == nil then
WWVehicleMenu.UI.defaultShowRadialMenu = ISVehicleMenu.showRadialMenu
end
-- Wrap default fuction
function ISVehicleMenu.showRadialMenu(playerObj)
WWVehicleMenu.UI.defaultShowRadialMenu(playerObj)
if playerObj:getVehicle() then
WWVehicleMenu.UI.addOptions(playerObj)
end
end
how do I make it play nice?
I would like to start and try to create some mods with one of my friend. Where can I start?
i'm trying to tweak a mod that adds loot to zombies but i dont even know what this numbers mean
is that 0.5%? is it 50%?
Hey all. Anyone know what happening here?
I can't start my server and I suspect this is the reason
trouble is, I can't ID what mods they are. Both say 0mb with no name.
If you are unable to ID then you need to re-add mods one by one until you find the culprits. The image wont load right on my phone, but my guess is they are mods that have become unavailable on the workshop or were installed manually, the latter meaning you too have to manually install the same exact files.
Broken Workshop mods generally appear as their ID# not their name. At least in my experience. Make sure when you remove mods they are removed from both Workshop and Mods in your server's settings
Are you writing a mod in java?
Any resources on how to do it? I'm knowledgable in lua and java but I think lua is missing a lot of functionality I need
Anyone got any pointers to how I find out when the player is stomping a zombie?
I assume its 50%
Does anyone know how OnlineID() acts when people disconnect?
Full 12 slot server;
slot 1 - John - ID 0 (Java tables start at 0)
slot 2 - Mike - ID 1
slot 3 - Alice - ID 2
slot 4 - Steve - ID 3
..
slot 11 - Greg - ID 10
slot 12 - Jane - ID 11
Suppose Mike, who is ID 1, leaves;
Will that mean Alice and everyone else drops down an ID number?
Or does it mean the next person to join will become ID 1?
Sadly not something I can test with one copy of the game 😦
I assume that it drops down the ID
Is there a "simple" way to change a function defined in a .class file from a lua script? I've heard that changing the .class and recompiling is frowned upon for this game.
Well- There is a way i suppose.
To take the .class files i just learned is not exactly the best you can do- You can have a look into it to get an idea how functions were built. I limit myself to looking at the code structure and trying to replicate it in LUA. Mods with .class may be taken down even so the most you can do is some sightseeing
I just learned that so yeah
Hi, does anyone know if I could add an animal with a new 3D model, without animations(seems to have problems as of right now), and add a simple AI package to that animal type? I've read somewhere that adding new behavior is not possible yet.
Sadly not helpful. I'd like a firm answer.
Also, is there a way to run lua functions from the server without adding them in as commands. The Lua command line allows me to do it seemingly as a client, rather than the server.
AI seems to be possible to implement due to the fact that superb survivors exists, but do not credit me to that 100% since i am not fully sure
And without animations, I assume you create a placebo animation that basically is the same frame
Sorry if it didn't help
As a host you should be able to do so, but I am not sure how- And the ID issue is a logical guess from me
I’m pretty sure Suberb Survivors activates assets that are already in the base game
NPCs used to be a thing, and I think they’re still there somewhere in the game’s files
When i looked through the files it had a folder with AI coding
I don't think that NPC's would work anywhere based on any code left in the base game tbf
Well yeah it does a lot of other things I’m sure
Would clothing be a suitable work around?
Hmm, I'll check that mod out. Maybe I could try adding an NPC with an animal model. The AI should be pretty straightforward since I want the animal to be a chicken and it will have a random wandering around and eating/mating when it is time.
I don't quite understand what you mean by placebo animation. Could you explain it a bit more if it won't be a problem?
i assume there is some code from the NPC's but remembering the main build that had NPC's from my knowledge it didn't seem to have many major functions- It was scripted more than anything
Yeah but they did have all the infrastructure in place to exist in the game world and do things
Placebo animation is just a stupid way to say- An animation that loops itself so you only need a single animation
Huh. I stand corrected. Good to know
The hard part really is getting the thing into the game
And now with multiplayer, having its state replicate properly
Pretty much. With MP it scares me in all honesty
As it should
But it shouldn't take more than a year to develop... I suppose
I know very well AI is difficult to code so i have no expectations in all reality
:/
Doing it from the dedicated server's cmd line returns unknown command.
The lua command box when hosting and playing on a server doesn't seem to run it from the server's perspective.
The complete lack of useful documentation for the base functions is really going to turn me away from developing for this
It seems that what took the devs so long to figure out for multiplayer was making the zombies replicate
Once they add an animal, no matter what it is, we’ve got a foot in the door and we can go crazy with it
I could excuse it for MP still being fresh and not more than a month old but it wouldn't hurt anyone to give some modding help with this
It's not even the MP side of things, there's no useful documentation for any of it (that I can find).
There’s documentation, but it’s all pretty vague
One thing having a list of all Java class items, then learning the way around the janky interaction between lua and java. But there seems to be duplicates of stuff.
I assume yeah- Taking code from Java and translating it into LUA isn't the easiest thing to do
Seems simple enough to access the classes just class:class:class:whatever
Easy enough to iterate and convert that info into lua tables
What isn't easy enough to do is run functions from the server's perspective
I don't think converting from Java is easy enough in my personal opinion
ahh i get it. That could be funny but at least could get the job done 😄
Though having a single frame of animation should work as well
Seems fine. Just impossible to work out what is running from where.
each client should only have access to limited data about the other clients;
server should have access to all, but I can't seem to run functions that use this from the server's perspective.
just a nightmare, and maybe it's just my lack of knowledge, but yeah. need documentation. Why I can't run functions from the server's command line, I have no idea, yet I can run functions from the lua command box in game.
I cannot help you too much but ill try my best
Client-side of course means things that should, in theory, only affect you and stuff
But the fact that you can't run, as a host, a command to effect the entire server is a little strange
Yeah. Client side I can know my own x,y,z. Server should know everyone's x,y,z. But when hosting (through in game) and inviting people, those commands do not allow me to access players other than ID 0; implying the lua commands are being sent on a clientside basis
swapping to my dedicated server, can't run functions because they're not recognised commands. despite the very same lines working fine through the lua command box.
It seems unnecessarily convoluted. And no amount of googling helps find answers.
However, I've got a question that popped into my head. If you have heard about the Authentic animations mod, it adds lots of new animations. Would you happen to know anything about it?
Not really- I don't ever use it
Is there a way to make an item give you lower attack speed for a short amount of time
I was working on an animal mod but got bored
^
lol
not an animal mod lol
count ticks, set attack speed to x at tick 0 (or record the tick when the item was used) (I assume there is some sort of tick system in the game...), set attack speed back to y at tick 0+n
I looked through the files if you need any more info
im pretty sure there's a mod that adds timers that you can use
probably easier than counting ticks
although I guess you should probably use the ingame time
Function LowerSpeedAtk
Lower the speed
wait
restore to default
end
counting ticks, or in game time difference, should literally be as easy as print("Hey World!")
if you do this then you will not factor in the fact that time can pass at different rates ingame
wait might hang the script
you need to count every 10 minutes
Correct- I forgot about that
you'd wanna hook in one of these
I saw that Dreams did time-related coding so if you need a mod that works with time I suppose you can look in there idk
That looks cool
or see how getTime() works. 🙂
Wait also can’t be interrupted
Would the item giving the player exertion suit your purposes?
actually yeah that would work
That should be pretty easy to do
i dont know the command for it tho, im pretty new to this stuff
I don’t do modding at all, sorry for the lack of a specific solution
man its all good
ISFurnaceLightFromKindle.lua
Second function should give you an idea as to what you need to do
Late, but you actually can launch more than 1 instance. You just need to change '-Dzomboid.steam=1' to '-Dzomboid.steam=0' in the bat files that launch the game/server:
\steamapps\common\ProjectZomboid\ProjectZomboid64.bat
\steamapps\common\Project Zomboid Dedicated Server\StartServer64.bat
After you make these 2 changes, you can launch as many instances of zomboid as you want with ProjectZomboid64.bat and join your server (or any non steam servers available.)
Thanks Nater, that'll be very helpful
so i use that?
will do that thanks a lot!
Hey, does anyone have an idea why this seems so blurry?
It doesn't look too blurry, but it may be due to the sprites themselves being blurry
Are they modded or base-game
the 2 sprites above are base game
the gameboy is modded
i made it
but it isnt as krisp as the other ones
That is the sprite issue then
You need to edit the sprite
I can help if you don't know how to do that
i know how to edit but i dont know what to change
You need to get the image to look sharper-
how though. its self made so its very sharp when i open it in photoshop
how small is the sprite
32x32
32x32
ok i think i found the issue
i had rgb-color chosen but i need to choose indexed colors
Can someone give me id of some armour from brittas pack
We haven't seen it so I one to spawn some to test is it even working on server
@weary kernel did you take an image and shrink it down in photoshop?
if you want smth to look pixely after transforming it in photoshop, make sure you select the Nearest Neighbor option
No the Texture is self painted
But the indexed color fixed it
o rlly?
Yes
i would have never thought that
It looks sharp now
I took another mods texture as reference and looked what was different from mine
And indexed color it was
thats good to know
Yes
I haven’t found anything on indie stone forum xD
So probably not many people know
you use that as a guide to where you should begin
function whattime()
-- getTimeOfDay() returns HH.PH where PH is percentage of an hour. Instead of 12:30 meaning half past twelve, it will display 12.5.
-- We split the HH from the part after the decimal, then multiply 60 by the part after the decimal to give us the minutes.
local hh, ph = math.modf(getGameTime():getTimeOfDay())
print(string.format("%02d:%02d",hh,60*ph))
end
This is how I'd skin the cat, which probably isn't the best way.
modf splits the integer from the fraction (which I crudely refer to as the number after the decimal)
In a perfect world, for what you're doing, I'd just compare gameticks, but I'm not sure where to find that :^)
I just checked Authentic Animations and True Actions mods. They both have tons of animations with xml extension
I'll check what coding is included
Hey guys I'm having some trouble adding my own TRUE MUSIC mod, they say I use a custom template, which I have, but I'm completely at a loss as to what I do next to get my own version of it on the workshop, has anyone done this before?
Heres the template they say to use but I don't even know how to upload this to the steam workshop when ive added my new music.
https://drive.google.com/file/d/1PcSW4bwOe0iyJREadgOyrms0zkpHcIOe/view
Google Docs
i wish you could just replace the soundtrack instead of add music into the gameworld
i would want a more sinister STALKER esque soundtrack
oh, dude you know what would be cool is being able to add and control a color filter on your game
so you could make it darker or more bleak
i mean, i could probably achieve it with sweetfx or something but thats not the same
Hey hey.
you could add stuff like an animated film grain, or maybe even a tv filter kinda like hotline miami 2 does it
depth of field would be cool but im not sure how that would even translate into the game
So I need a mod. I'll throw down $100 to anyone who makes it but essentially I just need a way for admins to place down any tile that exists in game including ones from modded texture packs. This would be extremely useful for servers that wanted more control over being able to build
I think there might be a way to do it with the tiles picker
youre godsent ive been wanting something like that
But unsure.