#mod_development
1 messages · Page 76 of 1
I appreciate the help, this is my first attempt at classes in Lua, and my setup was getting a bit hard to read without it.
It'd be really awesome if I could autobox some of these 
Hello everyone, I'm new to modding and I can't find a way to ID zombie, I tried ZombieID, getOnlineID() and getkeyID() so far but everything either return nil or -1 am I doing something wrong ?
Search the lua files for movingobject
Or something like that. Im afk i cant check
What ks it youre tring to achieve
🫡
how would i safely remove one of the vanilla professions from the game
you could study what some of the rebalancing mods do there since those affect the starting traits
if there winds up being no easy way to remove it you could do something like set all its values to nothing to effectively remove it, or make it too expensive to ever pick
Hi 👋 I have created a new mug item which is a duplication of the basic mug, without any particular addition except the texture.
How can I get this new mug to have the basic mug recipes? Making coffee, all different types of hot/cold drinks ?
I have added a new evolvedrecipe, I have the recipe in game which takes my new mug but I can't do anything with it. I also tried to change the evolvedrecipe list of the coffee item without success. Any ideas?
@neat hedge At a glance, only IsoGameCharacter (the object of players / zombies) has a "setVariable" function, so I'm not sure about triggering animation events on a vehicle. You may have to work out a pretty original solution there.
And IAnimationVariableMap and AnimationVariableSource
that might not be too hard to work with, provided I can still find a way to give things hurtboxes
But idk how those could tie back to vehicles if vehicles don't have anim variables.
if I can make footfalls have a frame on stepdown where they do absurd damage wherever they step we could probably get cars all squished, but then there's the clipping issues to consider
Again, adding footfalls to a car's motion would require some pretty creative programming, but I suppose you could periodically trigger some sort of event like that as you walked.
what could be done is utilizing both character objects and cars. the car is made invisible and a playermodel rendered over it in its place to handle the actual animations and whatnot, but that's preeeeetty jank
I'm PRETTY sure cars have actual hitboxes since they're able to spaz out like they do sometimes when they clip into certain things so there could be ways to exploit that
Well the player object is used to set and track animations, not the model assigned to the object, so I don't know that finding some janky way to stick a player model on a car would help you use the built-in animation system any better.
Also unsure game would let you
One of the Anonymous users in this server has messed around with detecting vehicle collisions; they could tell you more about that
@neat hedge
Wait for anonymous or albion they should know about cars
I seem to have some trouble with confirming a player's identity.
So I have character Alice, belonging to player Bob logged in as username Charlie, let's say.
When Alice dies and Bob makes a new character, Eve, then I need to confirm that it is still Bob playing Eve, preferably via the username Charlie.
My issue is that player:getUsername() just returns the name Alice and Eve in singleplayer, so it breaks there.
Singleplayer shouldnt have usernames
Ifaik cuz three no need for client nor server related stuff and username is only need for that
Maybe displayname would be more appropriate
Wouldn't people be able to just select a displayname to match someone else?
Singleplayer is single player why would there be someone else?
Create a loca host to solve your issue i think
Local*
I'd prefer having a one-solution-fits-all rather than having to find selection criteria for whether or not the player is in a single-player, split-screen, or multiplayer game right now.
hi there, anyone available to respond to a dumb question thats been making me pull my hairs out?
Cars do have hitboxes, just a single simple rectangular cuboid. Interacting with the actual physics engine is difficult to impossible though. Not even the vanilla code really touches the physics engine much. For example when you collide with something in a vehicle, the java just notices that your velocity changed rapidly, and searches in a radius for what might have been the cause, pretty jank tbh
as for vehicle animations, I don't know if this is what you're actually looking for, but obviously any mod that adds moving doors, hoods etc work with the animation system that vehicles have, good place to look
Sadly the only way right now is to add the new evolved recipe to all items
Hopefully the new update to liquids open up recipes and fluid containers to be a bit less rigid
Let me make a gallon of coffee in my bleach bottle 
Is there a good amputation mod?
That's what I thought 
Thanks you for the reply!
not currently, as the only cure is busted right now iirc
Does someone here has experience with the professions framework? I'm trying to add a profession that automatically adds two traits instead of one.
I tried traits = {"Burglar", "Scavenger"} but that crashes my game and traits = {"Burglar"}, {"Scavenger"} doesn't work
Having a look at the documentation, none of the examples have more than one trait, but the fact that its a table implies you should be able to have more than one
what error do you get?
stupid question of the day: is there any way to init the rcon on single player mode?
For some omnious reason it worked now. What I did was renaming the trait to Scavenger2 and change the line exclude = { "Claustophobic" } to exclude = { "Claustophobic2" }.
I think it was the second one because the professions framework replaces the vanilla skills and prefixes them with a 2
Does it really do that? Sounds like that would break everything
but I haven't worked with it so its just a knee jerk reaction
Also, is there really a typo in the trait and they didn't fix it for the 2 version? lol
it doesnt replace the vanilla ones. the ones with the 2 suffix are 'profession versions' of the vanilla traits (cost no points, cant be manually selected)
shouldnt need to really exclude any of them (like Claustophobic2) since these traits cant be selected anyways and must be manually assigned to professions
Mod Options can generally be found via an appropriately named mod called Mod Options- however sandbox settings can be viewed for specific mods if those mods are enabled when you're viewing said settings on world creation. I believe there's also other mods to edit sandbox settings while a world has already been made, so that's that.
Does anyone know if @hollow shadow's "Scrap Weapons" will add these weapons to the tool tables in the world too, or are they only accessible via crafting?
https://steamcommunity.com/sharedfiles/filedetails/?id=2122265954&searchtext=scrap+weapons
@pseudo ermine
make a patch mod
search folder for distributions
patch mod?
Not really sure where im supposed to ask this but I guess ill ask it here,
Ive seen other servers make it so that you dont get the "Workshop item version is different than the servers" whenever their is a mod update but how?
I assume they make their own modpack
So you would just compile all the mods together in a modpack?
Its frowned upon generally
I mean its really annoying when you have a server with like 100 mods and every hour or so you need to restart because of a mod update
Hey guys I’ve recently started playing PZ and haven’t been able to get a definitive answer I’ve searched online as well but Does anyone know of the most up to date and playable NPC mod, I’m running superb survivors but I keep seeing 2 in 1 and superior Survivors I check the links and they bring me too superb ALSO are there any know GOOD compatible mods that are beginner friendly to run along
ya definitely, just be aware if you make a pack and some of the modders in there don't like it there will be drama
damn
anyone knows what lua libraries can be used in the mods?
does it have all the libs that "regular" lua has or is it limited ?
its more or less standard lua 5.1. "Regular" lua comes with no libraries, so I'm not really sure what you're referring to there
well, I suppose you could consider table , string and math as libraries, they're in there
what i mean is... by default my lua install has the sockets lib
no, nothing non-standard like that
you can fire up the game in debug mode and run something like for n in pairs(_G) do print(n) end if you want to see what's available out of the box
and can i require my own lib placed inside the mod folder? A small lua script to make my life easier with some functions that i use regularly?
yes, for sure. All lua files are loaded by default, and require works as normal
any place in particular in the mod folder structure to place the lib?
or i can just throw it in with the rest of the lua files?
if its stuff you're gonna use all over the place I'd say put it in the shared folder, otherwise you may have access issues
ok, thanks for the info... will give it a try. I have the app working but i dont want to use keypresses so trying to figure out another way to make it work, and i thought about simple tcp/ip comms to send small strings that the mod reacts to
I'm not aware of PZ's lua having any access to the network stack. What are you trying to do?
i made a mod that integrates with twitch... it used keypresses to trigger events in the game. But its very limited, in mp its easier since i use rcon to do whatever i need to and not keypresses since the events are triggered from the server... in single player i dont have that option... at least that i know i cant use rcon in single player
didnt had the time to work on the mod, but now im on vacation so... plenty of time... trying to improve on it and make it more user friendly
hmm, well then you already know more than me, I have no idea how you'd do twitch integration
its quite simple... i made a lib for c# that uses the pubsub endpoint
the lib does all the hard work, the mod only reacts to what the app tells him to do... like send zombies, etc
so the easy part was doing the lib, the hard part is making the mod work the way i want.
the way the mod is right now you need to use a third party app for it to work to send the keypresses
the way i want it to work, you only need the mod and my app to do everything from setting the events on twitch, and serve as middleman between the game and twitch api
so you currently have certain keys mapped to trigger events?
You can leave the pack as unlisted - won't show up unless you link it. And can still be downloaded through the game.
yes
but that means the user has to setup the keys in the game, plus the rewards on twitch, plus the third party app to send the keystrokes that has a limit since the free version of the app doesnt allow more than 10 different "buttons" that trigger the keystroke
so its kind of boring, repetive and not easy to set up
may be able to flange up something with file i/o
when it was for my own use... it was fine... but i was dumb enough to put it on the workshop
i thought about the file thingie... but that opens another big can of worms
i do have a version of it that works that way... but its... not very viable...
also made a version that uses memory, but that can be sometimes detected as cheating... so to future proof it and avoid false cheating flags when the game implements an anti cheat, im trying to figure another way to do it
how did you do it with memory?
it will take some digging in the Java, but I imagine it may be possible to send server command or client command packets. Not sure if there is any encryption involved
well the rcon init is public but i have no way how to make it work
i digged a bit through the java but found nothing that could help me
but im even worse at java that i am with lua 🙂
if you have it working for multiplayer then why not just run a server for singleplayer
thats an option for me, but not for everyone
worst case scenario ill have to keep using the keystrokes and make my own thing in c#
but that means i will have to bang my head to send the correct codes since it uses glfw if im not mistaken
it absolutely is just click host on the main
you have to think that not everyone that streams has the cpu power to host the game and run everything else, hosting a game needs more resources and some machines cant handle hosting, streaming and everything else or whatever else the streamer needs
it really doesnt most games just run an offline server for singleplayer
zomboid hasnt gone this route yet but i expect it to eventually
run it in sp check the task manager, then do the same with a host and check it again
I would just run the hosted server if I was playing solo, far easier to manage
youll see it eats up more resources
and anyway, im a stuborn dude... i want it to work my way 😄
can anyone help me with ui stuff? trying to add Scrollbars but :addScrollBars() doesnt do anything
Speaking of stubborn, I'm really struggling with a mod I'm working on. I'm placing down a moveable and it initiates the object on the client side, but doesn't ever do it on the server side. I've looked at plenty of examples, but I just don't understand it well enough to spot the actual reason why it doesn't. Is anyone familiar enough with the IsoObject system to give me a hand?
if you want scrolling use a scrollinglist
are you transmitting the object?
from the Sobject, correct?
?
Well, when I was looking at some of the vanilla code, it's made up of an Object/System pair on both the client/server side and a map object, right?
self:initNew()
if SBioGasSystem.isValidModData(isoObject:getModData()) then
self:noise("Valid Data")
self:fromModData(isoObject:getModData())
end
self:saveData(true)
end```
function SBioGas:stateToIsoObject(isoObject)
self:toModData(isoObject:getModData())
isoObject:transmitModData()
end```
local isoObject = self:getIsoObject()
if not isoObject then return end
self:toModData(isoObject:getModData())
if transmit then
isoObject:transmitModData()
end
end```
you transmit modData but you never transmit the object anywhere
now i dont know if this is the code to place it down but when you create the object it needs to be transmitted to the server
exactly, but I'm not sure how or where to do this.
where do you create the object
If you have a global object, pretty sure server got the isoObject
Creating the object is done in this style, right?
local javaObject = IsoThumpable.new(cell, sq, spriteName, north, modData)
yes
Is there a good intro to nodding anywhere?
wiki
Alrighty
IsoObject.transmitCompleteItemToServer() has to be related, right?
I thought this was outdated
but seeing as you already have it locally you should be doing that already
i think im gonna go the easy way and use files... maybe make the mod check for file changes and use it to trigger the mod events...
The Indie Stone has this in the code for traps.
if SBioGasSystem.isValidModData(square:getModData()) then
self:noise('moving square modData to object')
self:fromModData(square:getModData())
self:reinitModData(square)
self:toModData(isoObject:getModData())
end```
the comment leads me to believe they don't do it that way anymore
I think they're referring to modData there, not the object itself
ah, ok
indeed refering to modData only
this is indeed pic of client with no data, still confused
how do you know server has problem
because if it's initiated on the server it shows up under GlobalObject ModData
the isoObject?
Anyway, to debug properly you need to have access to logs and print everywhere you are not sure.
isoObjects don't stay loaded
man, I thought I was getting a handle on this, but I guess not :/
So I try to update the battery degrade function and I ended up with this (condition is integer)
degradeVal = degradeVal > 1 and 1 + math.floor(ZombRand(degradeVal * 100) / 100) or math.floor(ZombRand(100 / degradeVal) / 100 ) == 0 and 1 or 0
which is much better than what it used to be and keeps the values from original
-- average of 1M rolls / 10: 5.5 / 3: 2 / 1.6: 1.37364 / 0.9: 0.90082 / 0.033: 0.03280
can I modify it so that when degradeVal is above 1 it averages to that value? I've tried a bunch of alteration but they don't scale well
I get close but with weird results
averages to what value?
please can someone help me with something fairly basic lol. i've tested a million different variations
this function is being called just fine, but the way i've written this. somehow it seems like it never checks again after the original call to check timestamp vs server startup timestamp which is defined as serverStarted. as it's written i just wanted it to restart every minute for testing
function restartsixhr()
print("[Nipdate] Setting Auto Restart...")
local currentTimestamp = getTimestamp()
if currentTimestamp - serverStarted >= 60000 then
restartTime()
end
end
every other part of the block functions, and everything is working. except this portion is just never actually calling restartTime()
and yes i'm incredibly new so i'm probably missing something straightforward.. but hoping this helps push me into new territory of understanding 🙂
just return?
function Nipdate.pollWorkshop()
local fakeTable = {}
if pendingReboot then return end
print("[Nipdate] Checking for outdated workshop items...")
querySteamWorkshopItemDetails(getSteamWorkshopItemIDs(), function(_, status, info)
if status ~= "Completed" then return end
for i = 0, info:size() - 1 do
local details = info:get(i)
local updated = details:getTimeUpdated()
local haveUpdate = false
if updated >= serverStarted then
haveUpdate = true
local modLine = "Mod \""..details:getTitle().."\" ("..details:getID()..") has an update!"
print("[Nipdate] "..modLine)
end
if haveUpdate then
workshopOutdated()
end
end
-- call the Nipdate.restartsixhr function before checking for updates
restartsixhr()
end, fakeTable)
end
if (SandboxVars.Nipdate.RestartDelayMinutes or 5) == 0 then --Only do this if we're in the mode where we only reboot with no users online. Will require a restart of server to initialize this mode.
Events.OnDisconnect.Add(function() Nipdate.pollWorkshop() end)
end
near the bottom there
im super unfamiliar with how to call things properly
gimme a second to read it... was deep in visual studio so my brain is a bit slow right now
no problem at all. thanks for even taking a sec. i'm essentially adding the function to add restarts into an workshop updating script now
it runs perfectly. even my function i'm calling works just fine (not pretty but works) but it's never making it to call the restartTime()
if i remove the math check, it will instantly restart over and over
so i know it works
well it doesnt restart.. i have that built into a loop on my server.bat
getTimestamp() is in seconds, isn't it?
is it?!
i swear was ms but my brain was so slow that i might have just told myself that
yeah i dont see anything wrong
after knowing it was seconds
maybe it was seconds and i been doing other things that made me forget
there is a getTimestampMs or getTimestampMillis or something
is it in s?
the loop is correct so might be the condition
i dont know how the server timestamp works
if its ms or s
i swear was MS but i'm going to test with anon input
thank you for now i shall see. hopefully this will create a one stop shop for mod updates and server auto restarts without needing any scheduler outside of pz
actually when i print it, it comes out in ms. would it use ms to calc seconds just using ms?
its possible that there is a problem with the conditions that determine whether or not the Nipdate.pollWorkshop function should be called.
it's normally called via the math at the bottom
sec
local nextPoll
Events.OnTickEvenPaused.Add(function()
if not restartingNow and restartingAt then
if isServerEmpty() then
print("[Nipdate] Restarting the server now! (Outdated workshop items were detected and server is empty)")
Nipdate.rebootServer()
elseif restartingAt - getTimestamp() <= 0 then
print("[Nipdate] Restarting the server now! (Outdated workshop items were detected)")
Nipdate.rebootServer()
end
return
end
if pendingReboot then return end
-- Don't bother checking for outdated Workshop items if there's no restart delay and the server has players on it
if (SandboxVars.Nipdate.RestartDelayMinutes or 5) == 0 and not isServerEmpty() then
return
end
local timestamp = getTimestamp()
if not nextPoll or timestamp >= nextPoll then
nextPoll = timestamp + ((SandboxVars.Nipdate.WorkshopPollingIntervalMinutes or 1) * 60)
return Nipdate.pollWorkshop()
end
end)
sorry
it does use sandbox vars to change the value but i have it set for both functions
at first glance... i think you have the condition wrong... dunno but i get the idea that for example, if the RestartDelayMinutes variable is not set to 0 and the event listener is not added, the Nipdate.pollWorkshop function will not be called when a player disconnects.
it's set to restart automatically if no players detected, and to initiate a another function if it does detect
i do think you are right. i just can't work out how to get it to check that data on a regular basis without checking it a bajillion times
in not very good with lua but from what i can see you prolly got the condition wrong
gonna run this and see
function restartsixhr()
print("[Nipdate] Setting Auto Restart...")
local currentTimestamp = getTimestamp()
print("Current timestamp: ", currentTimestamp)
print("Server started timestamp: ", serverStarted)
if currentTimestamp - serverStarted >= 60000 then
restartTime()
end
end
it appears to rely on the workshopOutdated and restartsixhr functions to handle initiating a reboot. It is possible that these functions are not behaving as expected, or that there is a problem with the conditions that determine whether or not a reboot should be initiated. But thats as far as i can go atm... my brain is kinda overworked today...
no worries
go with baby steps
1st try just the reboot in case of an update
LOG : General , 1672782439894> 51,853,937> RCON: listening on port 27015
LOG : General , 1672782440780> 51,854,825> [Nipdate] Checking for outdated workshop items...
LOG : General , 1672782440882> 51,854,926> [Nipdate] Setting Auto Restart...
LOG : General , 1672782440882> 51,854,926> Current timestamp: 1672782440
LOG : General , 1672782440882> 51,854,927> Server started timestamp: 1672782437```
if that works, then add the check for players online
I noticed that the Storm Project is no longer being maintained. Is it compatible with the current PZ version>?
omg i think it is seconds
bunch of integers to float, e.g 1 to 5 for 3.2
to print lines from server lua to the log I just need to do noise("some text")
right?
noise prints in debug
lol thank you. im literally a dummy. thank god for print timestamp lol
@drifting ore how are you shutting down the server?
and OnDisconnect doesnt trigger on servers
haha sec
bruh got timedout cuz i wanted to ping 7 ppl
@bronze yoke @sour island @astral dune y'all da real MVPs for encouraging modding and answering questions, cheers to ya
@jagged ingot @fast galleon @agile vigil @drifting stump y'all too ❤️

nice job
also my mod is working! almost exactly how it should just need to fix when it's called. but just watched my first auto restart happen using only in game mod 🙂
well and a loop on the .bat file still of course
no more schedulers controlling my life! lol
nice, how did you fixed it?
looool
so i tjust never waited long enough
so it is seconds...
yes
when i changed to 60 boom
that print told me everything
when i saw the number only go up by like 100 after a few mins
like i said... i didnt see anything wrong with your code... so it could only be one of the conditions...
baby steps helps 🙂
haha so true. sometimes i get so caught up in so many things at once
i just want to remove the call from workshop poll now and set it to call itself i thin
it feels to janky just adding it into another function
better janky and working than pretty and not working
getCore():quit()
youre gonna upload that into the workshop? thats a useful tool to have
yes
i can stop relying on the cron jobs...
let me just clean it up. it's already on workshop just not updated with this
i want to add the sandboxvar
to change the time
yeah what i thought
just using the start loop in bat file
it causes data loss
but this is better than issue rcon commands thru windows scheduler
it doesnt save when you run that
because it kicks everyone
it does
it has more logic
i just havent shared it all tbh. i tried to keep it simple
i can share if you want
no it does more than that
its just how i actually just it down in the end
shut it
the prints and debug
LOG : General , 1672788398169> 57,812,213> RCON: listening on port 27015
LOG : General , 1672788399385> 57,813,428> [Nipdate] Checking for outdated workshop items...
LOG : General , 1672788399581> 57,813,625> [Nipdate] Setting Auto Restart...
LOG : General , 1672789299081> 58,713,124> [Nipdate] Checking for outdated workshop items...
LOG : General , 1672789299284> 58,713,328> [Nipdate] Setting Auto Restart...
LOG : General , 1672789299284> 58,713,329> [Nipdate] Restarting the server (Server empty and 6 hour restart time.)..
LOG : General , 1672789299285> 58,713,329> [Nipdate] Saving...
LOG : General , 1672789299344> 58,713,388> reanimate: saved 0 zombies
LOG : General , 1672789299354> 58,713,399> Saving GlobalModData
LOG : General , 1672789299381> 58,713,424> [Nipdate] Quitting in 15 seconds!
LOG : General , 1672789300083> 58,714,127> [Nipdate] Quitting in 14 seconds!
LOG : General , 1672789301083> 58,715,127> [Nipdate] Quitting in 13 seconds!
LOG : General , 1672789302083> 58,716,126> [Nipdate] Quitting in 12 seconds!
LOG : General , 1672789303085> 58,717,129> [Nipdate] Quitting in 11 seconds!
LOG : General , 1672789304082> 58,718,126> [Nipdate] Quitting in 10 seconds!
LOG : General , 1672789305083> 58,719,127> [Nipdate] Quitting in 9 seconds!
LOG : General , 1672789306083> 58,720,127> [Nipdate] Quitting in 8 seconds!
LOG : General , 1672789307081> 58,721,125> [Nipdate] Quitting in 7 seconds!
LOG : General , 1672789308083> 58,722,127> [Nipdate] Quitting in 6 seconds!
LOG : General , 1672789309082> 58,723,126> [Nipdate] Quitting in 5 seconds!
LOG : General , 1672789310082> 58,724,126> [Nipdate] Quitting in 4 seconds!
LOG : General , 1672789311081> 58,725,125> [Nipdate] Quitting in 3 seconds!
LOG : General , 1672789312082> 58,726,126> [Nipdate] Quitting in 2 seconds!
LOG : General , 1672789313083> 58,727,126> [Nipdate] Quitting in 1 seconds!
LOG : General , 1672789314082> 58,728,126> [Nipdate] Quitting...
LOG : General , 1672789314082> 58,728,126> EXITDEBUG: Core.quit 1
LOG : General , 1672789314082> 58,728,126> EXITDEBUG: Core.quit 3
LOG : General , 1672789314083> 58,728,127> EXITDEBUG: Core.quit 4
lol when im not testing yes
hey guys i just asked chatgpt to make a project zomboid mod for me. Im curious if it got it right.
though i guess it forgot about the model and stuff
still neat
if it works ill stop banging my head and ask the bot for the solution lol
i dont think it will work out of the box like this lol
does object freeze even work
the bot lies a lot, i've asked him for some tips in music production... and he appears to be right, to know what hes talking about, but theres a lot stupid things in the middle
it can give you a blueprint though... but you still need to go through all of it and change like 98% of what the replies
simples questions like... how does this function work ... yeah... but the full code... i doubt it
also it only has potential info from old api functions if i recall
w;hatever was scraped from 2 years ago
the data is from 2021 yes
yeah
i think december or something like that
chatGPT doesn't understand pass-by-reference so its pretty useless making lua code, lmao
yea i'll agree i've gotten way further just asking questions and examining working logic in action lol
well like i said, at least it can give you a few bullet points on what you need to do
how to do it... thats another thing
i will say, using another model, feeding it all the require dataset up front and going over a few examples
it can 100% write a mod just by asking
if its a specialized model it prolly will
a multi purpose one... i doubt that very much
i imagine the stupid things it has on his dataset since they opened it to the public
since its supposed to learn with you as well and "evolve"
this beautiful group of people will get you further than any chat bot lol
but now im curious... gonna sign up and ask him a few things
agree. it was just a fun experiment to see how its progressed
I asked chatGPT if it used any of the conversations people have with it as part of its dataset, and its said no. I wonder if it was lying to me
google and facebok also say they dont use user data
and like i say... if the product youre getting is free... that means YOU are the product
hmm it start by saying what i have to do... but then i ask him for the full code and puff...
but its totally wrong though
haha, what if it's creators dont tell it that they are updating it's data set? 🙂
not technically a lie then!
I pointed out incorrect code to it once, it said "oh ya that's wrong" and explained properly why it was wrong. Then said "try this instead" and gave me the exact same code
not tottaly wrong though
LOL
thats java code
the only real decent chat bot is one that has tha randomizer set to 0
it will repeat itself often but rarely give out there answerrs
at least after halfway decent training
it will work... i think
not in zomboid but...
it does appear to be the right code for a simples tcp/ip listener
i asked him to improve the code and optimize it also display the data received...
-- Load the socket library
local socket = require("socket")
-- Create a TCP server
local server = assert(socket.bind("*", 8080))
local ip, port = server:getsockname()
print("Server listening at " .. ip .. ":" .. port)
-- Accept connections and receive data in a loop
while true do
local client = server:accept()
print("New connection from " .. client:getpeername())
local data, err = client:receive("*a")
if not err then
-- Display the received data
print("Received: " .. data)
else
-- An error occurred while receiving data
print("Error receiving data: " .. err)
end
client:close()
end
this looks like it will work
just need the mystical socket library he made up
and now its repeating himself...
it works on my ide
😄
it works ... ok... im gonna dump one of my scripts and see if he fixes it ahahahha
my favourite convo with it so far went something like
Can you create an object in java without using its constructor?
No you cannot create an object in java without using its constructor, Java objects use constructors to blablabla
Do you know about the java library Objenesis?
Objenesis is a java library that allows you to create java objects without a constructor
Why didn't you mention it before
uh well you see...
and the socket lib is part of the distro i have of lua 5.4
I wish coding would be that easy when i could use magical libraries outta nowhere
magical? This lib is old or the bot wouldnt have it in the dataset... ate least 2 or 3 years old
but even if i ask him to do it without the lib
he keeps using it...
when i asked him why is he using the lib when i asked him not to he simply replies: ok, here is the lua script without using blablabla
and just repeats the same code over and over again no matter how i ask him not to use it
I have the noise line in my functions and I've tried it with or without local function noise(message) SBioGasSystem.instance:noise(message) end in the code and none of my server side luas are printing to debug.
am I doing something wrong?
I just use print and look in the server logs tbh
same... never used noise
is it just print("string here")
yup
or print("String", var)
normal combos apply
im lazy to the point when im modding something thats not server sided i just make the char say when jumping inside the code
i have a question:
does anyone know of like, a testing map for loot distributions?
i feel like a useful thing to have would be a map with just a bunch of every class of container close together and organized so that you can generate worlds and see loot patterns
hmm, none of those are quite what i'm looking for
And you can dig in the LUA, but otherwise- I dont think there is anything like what you are asking. It probably wouldnt be terribly hard to make
ooh also- I got axe? 👁️ 👁️
But while I am here, if I want to add/remove events to the lua event manager, do I need to require any specific files? Or am I just good to put the Events.OnCreatePlayer.Add(exampleFunction); at the end of my code
Hell yeah! Congrats man!!!!

amazing work musicmaniac! that's a hell of a lot of work to be proud of on display
I have a question for modders, no one have made a WWI mod what adds Clothing and guns?
took 3 weeks 
Now that you are free, you wanna help with a cool drug mod? 😅
no now i want to play Imperator Rome 😄
maybe a bit later xd
i could do ur drugs logic actually

Based

Nice job you maniac
if they didnt fix it yet shutting it down that way causes rollbacks
there was already a mod doing what you did and it had those issues
congrats on workshop mod
not the first one for PZ though 
https://steamcommunity.com/workshop/filedetails/?id=2903257067
savegame with a delay before shutdown
I don't think my new journal method works 😦
Doesn't seem to catch addXP decoration if addXP is called in Java - which it is in some cases
hmmm
Might have to use the hook which I was avoiding
I wonder if there's a way to identify java origin'd hook calls 🤔
@willow estuary what do u think about to create #waywo channel? there're #old_showcase for in-game moments and #creativity for arts and etc but no channel for modding things. ppl sends their works in this channel but want to check exactly smth mods showcase instead 95% discussing
🥺
if anything, please change the name of this channel to #mod_development 😩
solved it in a very hacky way
calls from Lua throws the player object in a list
event calls checks, clears, and returns if the player is on the list
chances are they aren't gaining multiple sources of XP in the same frame
maybe I should throw in the perktype just in case
the hookcall also uses the boostmap multiplier as a numerator if ignore boostXP is on
Ye this will prevent those people who uses mods and think they are modders
🧠

so we need
mod_support
mod_development
mod_enduserhell
🤣
hello gents, I'm trying to make the lua recognize different broken glasses for more builds mod
MoreBuild.neededMaterials = {
{
Material = 'Base.Plank',
Amount = 6
},
{
Material = 'Base.Screws',
Amount = 4
},
{
Material = 'Moveables.brokenglass_1_0' or 'Moveables.brokenglass_1_1' or 'Moveables.brokenglass_1_2' or 'Moveables.brokenglass_1_3',
Amount = 1
}
}
but this doesn't seem to work
it only recognize Moveables.brokenglass_1_0 as the materials
and not for the rest of the broken glass
how do I write the function to make it recognize multiple broken glass as materials?
more builds not supporting mutli materials
alright, thank you for the info
man, I just can't get this, sorry for asking you guys over and over about this. I'm working with IsoObjects and my client log shows:
and the server log shows:
LOG : General , 1672810619416> 45,294,966> HomeBioGas: #objects=1
It's like they're not linked but I don't understand why.
i wish i could help you, but i dont know enough to do so, plus... 6am here... damn... the codes eats away the time and i dont even noticed it...
but it finnaly works... only need to finish the gui... good luck bet time for me 🙂
bed...
cant even type anymore...
Twitch api done... mod... 80% done...
mod_showcase
The server makes a server global object and sends the client command to make a client object. Logs have nothing weird here.
Why wouldn't any of the prints I have be running in the functions be returning anything?
function SBioGasSystem:updateBioGas()
print("Starting biogas update.")
for i=1,self.system:getObjectCount() do
local hbg = self.system:getObjectByIndex(i-1):getModData()```
like nothing prints?
Yea, I'm not getting anything from any functions in the console
Also, other objects like the rainbarrel and farming in the logs show found isoObject with a luaObject instead of found isoObject without a luaObject
so, that's why I was assuming I was doing something wrong
are you setting the functions from console to the instance? Or just calling them from console?
neither, the updateBioGas() is set to run hourly.
that's difference between new / existing objects
Events.EveryHours.Add(function()SBioGasSystem.instance:updateBioGas() end)
I just don't want to assume it's working
you should get the top print, otherwise something is obviously wrong
You probably checked already, but are there no stack trace or severe logs on server?
There's one for that function, but this one isn't throwing an error.
print("loading the biogas object")
if not instanceof(isoObject, "IsoThumpable") then
isoObject = newBioGas(isoObject)
end
SBioGasSystem.instance:loadIsoObject(isoObject)
end```
oh cool, that one is working
I really wish sitting in debug wouldn't kick you from the server
Why would the mod I'm referencing have the values under both the GlobalObject Modata and the IsoObject ModData?
What debug mod are you using here? 
the isoObject is where the data is saved and how it transmits between server / client
vanilla
the global object puts / retrieves that data
How do you bring forth that gui? 😮
So, if that's not showing for mine my global object isn't defined and working?
which part?
client global object will have no data until you call updateFromIsoObject
try that or just yourSystem.instance:getLuaObjectByIndex(1?)
yourSystem.instance:getLuaObjectByIndex(1?)
C or S forsystem?
c, for client
no change
is that the number 1 object?
ah by index doesn't call the update, only the getAt does.
try calling the update on the luaObject
I'm not sure how to do that 😦
what you did before + :updateFromIsoObject()
LOG : General , 1672824170943> 58,846,489> Object tried to call nil in console
ERROR: General , 1672824191476> 58,867,022> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: Object tried to call nil in console at KahluaUtil.fail line:82.
probably typo or something, break it into steps
myGloblaObject = CBioGasSystem.instance:getLuaObjectAt(x,y,z)
now you can call anything on that object
this command has update included
awesome
not sure why only have the values are coming through, but that's progress at least
check the fromModData function for that
self.methane = modData["methane"]
self.biowaste = modData["biowaste"]
self.fertilizer = modData["fertilizer"]
self.maxFertilizer = modData["maxFertilizer"]
self.maxBiowaste = modData["maxBiowaste"]
self.maxMethane = modData["maxMethane"]
self.lastHour = modData["lastHour"]
end```
looks fine
ah, they were not on the isoObject
I'm not sure why, they're initialized on the javaObject and the Sobject
I'd check the reverse on server (toModData and maybe your setObjModDataKeys on initSystem)
aight, I have to call it, it's 3am haha. Thanks for your help
I really appreciate it!
nevermind - got it working. switched to using the pop bottle as a base instead of the water bottle, and it worked just fine.
Anyone have an opinion to share regarding the most well developed and bug free shop mod?
How can I find out which mod is giving me errors?
There are too many on my list to try disabling each one by hand
Mine is pretty good - although I think I messed up the on-hand-cash / wallet system. So everyone is stuck with on hand cash at the moment.
immersive
Bahaha right on. Well I am humoring the idea of adding gamepad support to the one I decide I like the best. Kinda wanna investigate cool shop mods but virtually none seem to have gamepad support
Advantage of adding it to yours would be at least you linger here often bahaha
It's not trivially easy but it's not the hardest thing I've ever had to figure out... But it's a bit time-consuming. Links have to be considered manually and focus passed carefully.
And often
My shop code is on my GitHub if you want to collaborate - I can add you as an author on the mod
I also have a unreleased faction banking mod on the GitHub too
It's a companion mod to the shops
I will likely wait for you to get your most recent bug fixed and subscribe to the workshop version to work from there on something that will hopefully change more slowly.
I already have a lot of the code for going from context menu to popups and back to gameplay from my Jumper mod so hopefully that'll help
But yeah definitely nontrivial hence my desire to pick the shop mod carefully first lol probably not gonna do this for any other shop mods
If I get gamepad support added to your shop, expanding to your banking mod will hopefully be relatively straightforward, since it'll be written in the same style.
Well if I can self promote, my shop features are more developed than the others afaik.
You can have more than 1 type of shop, and the shops are tabled in globalModata so you can create connected locations anywhere using any object.
All from in-game UI - eventually I want to make it so anyone (given the right conditions) can make their own shop.
Hey, so is zombies reanimating a mod or is it an optional game rule? Because I had an Idea for a mod that someone else could use, as I have no clue if it's already a mod, and if it's not, Idk how to make mods
It's a feature already
Oh sweet, makes my idea better then
The idea is that if you have a bladed weapon, you can cut the limbs and other parts off of zombies -eg, cutting off the arms and mouth like they do in the walking dead, or slicing off all limbs so that, when the zombies DO reanimate, they can only sit there and do nothing
Obviously, it would take time depending on the weapon - machetes and axes would be faster than a knife, for example. But it could also scale with your weapons skill level too
Once again, this may already exist, but if not, then you can just have this idea
I don't know how to mod for shit lol
was this game written in lua?
I think so? I just googled it and it came up with a bunch of PZ related articles with titles like "Intro to Lua"
check console.txt or coop-console.txt
base is java
oh
Lua is a scripting language, not to get too focused on the technicals.
PZ uses a version of Kahlua which is like a middleman between java and lua
Much of modding is figuring out where it is best to pin your code to. Lua otherwise is very easy.
Any idea why this won't work?
local private = {}
private.refreshContainer = ISInventoryPane.refreshContainer
function ISInventoryPane:refreshContainer()
private.refreshContainer(self)
function hiddeEquippedItems(tecla)
if tecla == 41 then
for k, v in ipairs(self.itemslist) do
if v ~= nil and v.equipped then
self.itemslist[k] = nil
end
end
end
end
end
Events.OnKeyPressed.Add(hiddeEquippedItems)
What you're doing here is declaring a global function (hiddeEquippedItems) within a function (refreshContainer). This means that the function will not exist in the global scope until refreshContainer is called, which means when you try to add it to the OnKeyPressed event, it will not yet exist.
I'm not familiar with the usual conventions for declaring a hotkey, but in general you would be better off separating out the OnKeyPressed event handler
What exactly are you trying to do? I'm assuming you want to trigger the code in the function when refreshContainer is called, but toggle the behavior with a hotkey? If you're trying to track state, you will need a variable to do so
hiddeEquippedItems will never be called because they are in different blocks of code
Since it's global, it could theoretically be called if you called the function that declares it first. That's not a very pleasant pattern, though
should be self.hiddeEquippedItems to call him, so you can do Events.OnKeyPressed.Add(ISInventoryPane.hiddeEquippedItems)
That won't work, since it's not a member of that table (scoping does not work like that in Lua)
that's why you need add self.
That won't work either
Oh, I see what you're saying. Declaring the function on self
That still wouldn't work though, since you'd have to call it manually first
I've seen a few people write in here (this Discord) when trying to commission mods, models, or otherwise. Is there a better place to do that?
I'm thinking of something like the RimWorld Mod Market Discord, where commissioners and modders all meet up to trade money for work.
no afaik, but sounds like a great idea
If I had all the time in the world I'd make the first step 
Hi everyone, I'm still learning, I'm trying to add a new tee shirt with a logo (just the textures). I managed to get the new tee shirt with my logo on it but I have a problem, I seem to be overwriting a tee shirt in game, I'm not sure.
Do you have a mod to recommend that adds new clothes that use clothingsDecals?
Trying to hide equipped items with a keybinding
Was the SMUI stutter fix broken or something? @craggy furnace
If i do this it works
local private = {}
private.refreshContainer = ISInventoryPane.refreshContainer
function ISInventoryPane:refreshContainer()
private.refreshContainer(self)
for k, v in ipairs(self.itemslist) do
if v ~= nil and v.equipped then
self.itemslist[k] = nil
end
end
end
But don't know hot to add a key to trigger it
Now it works, nice
Now i have to find a way to undo it
xd
@robust jetty
if private.isPrivate then ... end
OnKeyPressed:
private.isPrivate = not private.isPrivate
I think DeltaMango and somebody else mentioned something about this.
i don't understand 😅
i was thinking on create a copy of the items and then restore it, but seems more fast yours, if i understand it
What I mean is: on key press change the value of isPrivate and check that in the other function
U mean restore the default values ?
It looked like you wanted two separate functions if you can manage it with one then this not necessary.
it was fixed
ah ok thanks
This doesn't actually help you with your issue, but I wanted to mention you could replace this with Events.EveryHours.Add(SBioGasSystem.instance:updateBioGas)
edit: whoops, no you can't
omg, I thought this doesn't work
actually shit, I just noticed the colon, no it won't work 🤦♂️ my bad
😦
@robust jetty
to add the items back you can call refreshContainers and not remove the items? 🤔
I guess so, because they are not deleted, they just don't show up
Yea, to use self you have to pass it as a function
Like this guide says i store the original to call it if a don't need a custom code, but how do i call it to restore default values?
@fast galleon where are you looking to see what those functions you were showing me last night do?
better to store it it ur personal global table and do this thing
UR_GLOBAL_TABLE.A = UR_GLOBAL_TABLE.A or A
local original_A = UR_GLOBAL_TABLE.A
cos if use way from screenshot then after reload the file it will override ur overrided func instead real original func
vanilla CGlobalObject
Yea… that makes sense
there's also the system and the server files, if you haven't looked at them
Yea, I typically have the media folder open in vs code and a tab open with the Java.
Just wish someone had a diagram somewhere of the relationships between the Server/Client LuaObject and the JavaObject
ah, java has similar named files but most times you don't need them for this system
pz java source in vs code?
You mean something like this
ISInventoryPane.refreshContainer = ISInventoryPane.refreshContainer or refreshContainer
local original_refreshContainer = ISInventoryPane.refreshContainer
function ISInventoryPane:refreshContainer()
original_refreshContainer(self)
function hiddeEquippeditems(keypressed)
if keypressed == 41 then
for k, v in ipairs(self.itemslist) do
if v ~= nil and v.equipped then
self.itemslist[k] = nil
end
end
end
end
Events.OnKeyPressed.Add(hiddeEquippeditems)
end
how do u make it have colors?
😅
No, I have the source open in a browser tab. I have the pz media folder open in vs code so I can look at the lua
ah(
#findinfiles is a lifesaver
no, u need new global table to cache there original func
TABLE.ISInventoryPane_refreshContainer = TABLE.ISInventoryPane_refreshContainer or ISInventoryPane.refreshContainer
local original_refreshContainer = TABLE.ISInventoryPane_refreshContainer
function ISInventoryPane:refreshContainer()
original_refreshContainer(self)
function hiddeEquippeditems(keypressed)
if keypressed == 41 then
for k, v in ipairs(self.itemslist) do
if v ~= nil and v.equipped then
self.itemslist[k] = nil
end
end
end
end
Events.OnKeyPressed.Add(hiddeEquippeditems)
end
@robust jetty
I think I understand, this is the part that is hard for me to understand about all this.
im messing around with the mod since i got the api app done ( apart from the gui ) and trying to figure out how the heck this works on zomboid... after reading a while i think i kinda get how to make it... but still.. trying to create a resizable window to display some text but with a imagem before the text.
local window = ISUI.CreateWindow(100, 100, 300, 300)
window:SetTitle("Minha Janela")
local row1 = window:AddRow()
local image1 = row1:AddImage(32, 32)
image1:SetTexture("image1.png")
row1:AddText("sometext bla bla bla")
window:Show()
is it something like this or not really?
I am having a problem with the mod I'm currently working on. It's a profession mod and I'm utilizing the profession framework.
The console is giving me this error, which is preventing the game from starting properly:
attempted index: getLabel of non-table: null
LOG : General , 1672855775093> -----------------------------------------
STACK TRACE
-----------------------------------------
function: SetProfessionDescription -- file: MainCreationMethods.lua line # 639 | Vanilla
function: doProfessions -- file: 2ProfessionFramework.lua line # 413 | MOD: Profession Framework
ERROR: General , 1672855775094> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: attempted index: getLabel of non-table: null at KahluaThread.tableget line:1689.
ERROR: General , 1672855775094> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: attempted index: getLabel of non-table: null
at se.krka.kahlua.vm.KahluaThread.tableget(KahluaThread.java:1689)
at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:641)
at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:163)
at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1980)
at se.krka.kahlua.vm.KahluaThread.pcallvoid(KahluaThread.java:1812)
at se.krka.kahlua.integration.LuaCaller.pcallvoid(LuaCaller.java:66)
at se.krka.kahlua.integration.LuaCaller.protectedCallVoid(LuaCaller.java:139)
at zombie.Lua.Event.trigger(Event.java:64)
at zombie.Lua.LuaEventManager.triggerEvent(LuaEventManager.java:65)
at zombie.GameWindow.enter(GameWindow.java:753)
at zombie.GameWindow.mainThread(GameWindow.java:491)
at java.base/java.lang.Thread.run(Unknown Source)
LOG : General , 1672855775094> -----------------------------------------
STACK TRACE
-----------------------------------------
function: SetProfessionDescription -- file: MainCreationMethods.lua line # 639 | Vanilla
function: doProfessions -- file: 2ProfessionFramework.lua line # 413 | MOD: Profession Framework
LOG : General , 1672855775094>
LOG : General , 1672855775172> creating new sourcewindow: C:/Program Files (x86)/Steam/steamapps/common/ProjectZomboid/media/lua/shared/NPCs/MainCreationMethods.lua```
It says something about the ProfessionDescription but everything seems right to me? I have already created some traits and there were no such problems. Maybe there is a typo which I just can't see... but I doubt it.
Thats how the profession looks like:
name = "UI_prof_buildercarp",
icon = "prof_buildercarp",
cost = -6,
xp = {
[Perks.Woodwork] = 3,
[Perks.Maintenance] = 1,
},
clothing = {
Eyes = {"Base.Glasses_SafetyGoggles"},
Hat = {"Base.Hat_HardHat"},
Shirt = {"Base.Shirt_Workman"},
TorsoExtra = {"Base.Vest_HighVis"},
Hands = {"Base.Gloves_LeatherGloves", "Base.Gloves_LeatherGlovesBlack"},
FullSuit = {"Base.Boilersuit", "Base.Boilersuit_BlueRed"},
},
traits = {"Buildercarp"},
})```
And thats the corresponding entry in the translation file:
```UI_prof_buildercarp = "Builder",
UI_profdesc_buildercarp = "",```
can someone make sense of the error message?
does anybody know how to get a simplified uv-map in blender? i always end up with a messy unsorted texture with thousands of individuel parts.
it can't find the 'Buildercarp' trait
it wants to add the name of the trait to the profession description
Quick question;
I've managed to make a chat stream that needs to be used in a separate tabID than '1' (the default general tab) in the ISChat.lua, but I can't figure out how to populate/generate a second tabID on chat creation, I know it's possible since admin's have the 'admin chat'. Is it possible for a regular non-admin client to have more than one or even two chat tabs?
Does anyone know how to activate mods just from a collection in project zomboid? Example: I have 500+ mods downloaded but only want to use 40 of them which I’m currently subscribed to and are in a collection. When I go to make a new world, it still shows the 500+ mods downloaded but I want to use just my 40 that I want.
Thanks this helped me find the issue! I was missing a closing bracket before the Buildercarp trait entry lmao
classic
The easiest way would be to; unless you want all 500 downloaded, unsubscribe from all. Then subscribe to just the 40 from the collection. Using the mod-manager mod can help out too.
I tried doing that but it still shows the 500 mods whenever I go to add mods but I’m only subscribed to 40 of them
did you download the mods manually? If you want to use the subscription feature then you can only use the subscription feature, once you manually drop mods in they're there until you manually remove them
Question here. Is it possible to override specific vanilla functions without overriding the whole file itself? If yes how do I do so and which one would I have to overwrite to half the amount of propane used when deconstructing metal items and car wrecks (I want it to only be half when a certain trait is selected)?
I was thinking the function in question might be ISMultiStageBuild:consumeMaterial() in ISMultiStageBuild.lua or it is this one: function buildUtil.useDrainable(item, uses) local count = math.min(uses, item:getDrainableUsesInt()) for i=1,count do item:Use() end return count end
as long as the function is global, you can just rewrite it in your own file:
function sameFunctionName(arguments)
--etc etc
end
in most situations i would find a way to not override the entire function, like this:
local old_function = functionName
function functionName(arguments)
-- run code before
old_function(arguments)
-- run code after
end
in this case, halving the uses before passing it to the old function might be appropriate
I love it when functions return what they produce
Makes overwriting that much easier
I feel dirty jumping in after fillContext menu to remove options
Although I guess/hope it's a list pre-render
biowastecontainer:addItem(item:getReplaceOnUse())
Trying to add an item to a container and it's just throwing an object error? Is it because I'm adding it to the variable instead of the object?
if the variable isn't the object, what is it?
lmao, having different methods that vary by a single capital letter is pure cancer
Now I just need to figure out why half my variables aren't initializing
This is really annoying, I wrote out the logic to do the work in like 2 hours and there's only minor syntax errors.
I have spent hours trying to figure out this stupid object system, haha
dont remember the exact file but if you create a new game and select only those 40 mods in the save folder that file called mod something you have the list of the mods ( ids i think ) that the save loads, you can use that to make the collection... did something similar about a year ago dont remember why, with a little bit of python and the steam api everything is possible using the info on that file
or was it a mod i had that created that file? dont remember very well...
its mods.txt stored in the save folder
that should have the list of the mods that every save loads, use that as base to make the collection
for example %userprofile%\Zomboid\saves\sandbox\nameofthesave\mods.txt
sooo something like that I guess? Sorry I have absolutely no experience with lua or PZ modding. This is the first time I'm trying to get into it
local old_function = buildUtil.useDrainable
function buildUtil.useDrainable_NWO(item, uses)
local count = math.min(uses, item:getDrainableUsesInt())
if (item = "Base.BlowTorch" or item = "Base.WeldingRods") and player:HasTrait("Blacksmithmetal") then
local count = math.min(uses, item:getDrainableUsesInt() * 2)
local count_eff = math.ceil(count / 2)
else
local count = math.min(uses, item:getDrainableUsesInt())
local count_eff = count
end
for i=1,count do
item:Use()
end
return count
old_function(count)
end
bro I feel so bad asking questions here I feel like I'm annoying yall 💀
is there a guide on how to save information from mods input? like if I assign a player a local value of 5 and I want to make it persistent every time he joins?
I'm looking at LUA codes in the folder but I cannot find anything relevant
to saving data, that is
does moddata stay even if mod is disabled? aka if i enable mod with moddata, run it for a while, disable it, play without it, and then enable it again. Will moddata stay?
Basically yeah, save the information to a file on the servers' database
So it's a lua thing to learn to save files right?
I don't have to google it specifically tied to PZ?
keep in mind it only can write to the mod folder
or was it somehwere else? lemme check
i think you can specify where to write the file but by default it writes the file @ %userpfoeil%\Zomboid\Lua
never bothered to much since i only use it for temporary information
@ %userprofile%\Zomboid\Lua
damn my keyboard is drunk today
just use moddata
if it's specific to a player, use (player object):getModData().key = value
moddata is just a table, it doesn't know what mod made what entries
@dull moss @finite owl @winter thunder - Just an FYI I've published the WIP Vampire Mod to the workshop, just thought I'd let you know and thank you for your help (a lot of help!), its very much appreciated - and that goes for everyone on here too, its a great community 🙂 - I'm sure I'll be back soon when I come to the next stage with it haha
Didn't know if this was the place to post the link but if its ok I can
There you go
Congratulations 🙂
Very WIP and all the image are just placeholder, but I thought I'd get it out there to get some feedback/suggestions etc
nice job dude
ez rate up
Thank you, honestly the people here deserve a lot of credit, wouldn't have been able to do it without you
i think almost everyone in here feels that way at some point lol

Hey how do you remove items from players inventory? For some reason when i add bullets instead of getting one i get six bullets
Hm okey this is the error I get.
LOG : Lua , 1672868748239> Loading: C:/Users/xxx/Zomboid/mods/NewWorldProfessions/media/lua/server/BuildingObjects/ISBuildUtil_NWO.lua
Jan. 04, 2023 10:45:48 PM zombie.Lua.LuaManager RunLuaInternal
SCHWERWIEGEND: Error found in LUA file: C:/Users/xxx/Zomboid/mods/NewWorldProfessions/media/lua/server/BuildingObjects/ISBuildUtil_NWO.lua
ERROR: General , 1672868748246> ExceptionLogger.logException> Exception thrown se.krka.kahlua.vm.KahluaException: ISBuildUtil_NWO.lua:7: ')' expected near `=` at LexState.lexerror line:278.
ERROR: General , 1672868748246> DebugLogStream.printException> Stack trace:
se.krka.kahlua.vm.KahluaException: ISBuildUtil_NWO.lua:7: ')' expected near `=`
at org.luaj.kahluafork.compiler.LexState.lexerror(LexState.java:278)
at org.luaj.kahluafork.compiler.LexState.syntaxerror(LexState.java:289)
at org.luaj.kahluafork.compiler.LexState.error_expected(LexState.java:683)
at org.luaj.kahluafork.compiler.LexState.check_match(LexState.java:713)
at org.luaj.kahluafork.compiler.LexState.prefixexp(LexState.java:1108)
at org.luaj.kahluafork.compiler.LexState.primaryexp(LexState.java:1130)
at org.luaj.kahluafork.compiler.LexState.simpleexp(LexState.java:1211)
at org.luaj.kahluafork.compiler.LexState.subexpr(LexState.java:1303)
at org.luaj.kahluafork.compiler.LexState.expr(LexState.java:1321)
at org.luaj.kahluafork.compiler.LexState.cond(LexState.java:1424)
at org.luaj.kahluafork.compiler.LexState.test_then_block(LexState.java:1597)
at org.luaj.kahluafork.compiler.LexState.ifstat(LexState.java:1610)
at org.luaj.kahluafork.compiler.LexState.statement(LexState.java:1736)
at org.luaj.kahluafork.compiler.LexState.chunk(LexState.java:1790)
at org.luaj.kahluafork.compiler.LexState.body(LexState.java:1026)
at org.luaj.kahluafork.compiler.LexState.funcstat(LexState.java:1681)
at org.luaj.kahluafork.compiler.LexState.statement(LexState.java:1758)
at org.luaj.kahluafork.compiler.LexState.chunk(LexState.java:1790)
at org.luaj.kahluafork.compiler.LexState.compile(LexState.java:198)
at se.krka.kahlua.luaj.compiler.LuaCompiler.loadis(LuaCompiler.java:132)
at se.krka.kahlua.luaj.compiler.LuaCompiler.loadis(LuaCompiler.java:124)
at zombie.Lua.LuaManager.RunLuaInternal(LuaManager.java:546)
at zombie.Lua.LuaManager.RunLua(LuaManager.java:510)
at zombie.Lua.LuaManager.RunLua(LuaManager.java:496)
at zombie.Lua.LuaManager.LoadDirBase(LuaManager.java:342)
at zombie.Lua.LuaManager.LoadDirBase(LuaManager.java:264)
at zombie.gameStates.GameLoadingState.enter(GameLoadingState.java:97)
at zombie.gameStates.GameStateMachine.update(GameStateMachine.java:145)
at zombie.GameWindow.logic(GameWindow.java:298)
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
at zombie.GameWindow.frameStep(GameWindow.java:765)
at zombie.GameWindow.run_ez(GameWindow.java:681)
at zombie.GameWindow.mainThread(GameWindow.java:495)
at java.base/java.lang.Thread.run(Unknown Source)
I don't think this will work. The first issue is nothing after a return statement will ever get run, so the old function doesn't happen. If you put it before the return, its going to drain it the normal amount, so you'll end up draining extra. You're either going to have to not call the old function at all, or cache the fuel amount before, call the old function, then change the result after
what is the type for negative numbers
it's still integer, no?
it errors and the menu bugs out
also you have to name the new function the same as the old
oh i'm stupid
hm no new function has _NWO at the end
which means it will never get called
ah k got it
you need make the item first with inventoryitemfactory and add that
inventory:AddItem(InventoryItemFactory.CreateItem("base.item"))
thanks, but i already figured it out myself how to circumvent it
let me explain this a bit better:
we use this
local old_function = functionName
```to save the original vanilla function into a variable, we do this so that if multiple mods overwrite the same function they'll call each other's code in a chain - otherwise we'd all overwrite each other, and only one mod would have its code run
we replace the original function by using the same name, with one that calls the saved copy we made:
```lua
local old_function = functionName
function functionName(args)
old_function(args)
end
```when we do this, we can mess around with the arguments going into the original function
```lua
local old_function = functionName
function functionName(number)
number = number + 5
old_function(number)
end
```when the original function has a return value, we need to return it as well:
```lua
local old_function = functionName
function functionName(number)
number = number + 5
-- if you don't need to run any code after the original function, just return it:
return old_function(number)
-- otherwise, save it into a variable, mess with it, then return it
local returnValue = old_function(number)
returnValue = returnValue / 2
return returnValue
end
of course, you don't strictly have to mess with the arguments/return value of a function: you can run any code you want in your overwritten function
I like doing it like this lately:
ISReadABook.new = myPatch(ISReadABook.new)
blessed system
so good
this should probably be pinned lol
Also, doesn't derive do the same thing, or am I misunderstanding what that does.
CBioGasSystem = CGlobalObjectSystem:derive("CBioGasSystem")
derive is for classes, or pseudoclasses or whatever you want to call them
ah
that should seriously be pinned though
i don't think we do pins here, but i appreciate that 😇
we wouldn't have to worry so much about load order of mods if they all followed that
@molten cobalt
"- Making the time the damage is dealt between dynamic, so it is correct as of dawn and dusk in each season."
instead of dealing damage only between specific times of day, do it always but multiply damage by 1 - getClimateManager():getNightStrength()
does anyone had the issue that the texture for a model is working. but in another savegame it is not? kind of weird. the model is working fine for both tho.
table.insert(ProceduralDistributions.list["X"].items, Y)
Hi ! What is the max value of Y? 100? Is it the percentage chance of spawning?
Hell yeah! Happy to hear it :) Will be sure to check it out asap, sounds like a cool project
When I'm setting up an object, where's the most appropriate place to assign a sandbox variable to a modData variable?
Would I do it under initNew? I feel like that wouldn't update existing objects.
you want it to update existing objects? then i'd ask why it needs to be moddata
it probably doesn't need to be
does anyone know how to control the radiation in the stalker mod?
How would that work exactly, code wise and what does it do 🙂
Also, I've found an issue where even if you only take one trait, you take the damage from all three, is that because the EveryOneMinute code isn't linked to a specific trait?
local function TraitSunlightSensitive()
local player = getPlayer();
local timeOfDay = getGameTime():getTimeOfDay();
if timeOfDay > 9 and timeOfDay < 20 and player:isOutside() then
local allBodyParts = player:getBodyDamage():getBodyParts()
local bodyPart = allBodyParts:get(ZombRand(allBodyParts:size()))
bodyPart:AddDamage(5)
end
end
Events.EveryOneMinute.Add(TraitSunlightSensitive)
local function TraitMinorSunlightSensitivity()
local player = getPlayer();
local timeOfDay = getGameTime():getTimeOfDay();
if timeOfDay > 9 and timeOfDay < 20 and player:isOutside() then
local allBodyParts = player:getBodyDamage():getBodyParts()
local bodyPart = allBodyParts:get(ZombRand(allBodyParts:size()))
bodyPart:AddDamage(2.5)
end
end
Events.EveryOneMinute.Add(TraitMinorSunlightSensitivity)
yep
can the traits be earned during gameplay? if not, i would use something like
local function AddTraitEffects(_index, player)
Events.EveryOneMinute.Remove(TraitSunlightSensitive)
Events.EveryOneMinute.Remove(TraitMinorSunlightSensitivity)
-- the above cleans up the events, in case the player had the trait, died, and made a new character
if player:HasTrait('Trait1') then
Events.EveryOneMinute.Add(TraitSunlightSensitive)
end
if player:HasTrait('Trait2') then
Events.EveryOneMinute.Add(TraitMinorSunlightSensitivity)
end
end
Events.OnCreatePlayer.Add(AddTraitEffects)
```otherwise, rewriting your events like this:
```lua
local function TraitMinorSunlightSensitivity()
local player = getPlayer();
if not player:HasTrait('TraitName') then return end
-- etc
end
```would be the simplest way of doing this
No you can't earn them doing gameplay no, thank you for this, I'll see if that works now
can you call server side functions like you can with client side ones, the output just shows up on the server log?
I like musicmaniac's idea to use nightstrength though, means you'd take different amounts of damage depending how high the sun is in the sky. Could also take other weather into effect
you'd have to call them from the server
I'll add it to the suggestions 🙂
Can you access this on a local machine?
I have to use rcon don't I
not if you use the host button on the main screen, but if you set up a local server I'm sure it must have some way to enter commands for server maintenance
whether or not it lets you run lua code I don't know, I just use host for testing
Personally I have a custom Client command that I use to tell the server to run code I want to test , but its a bit of a lift to set that up
i don't think you can run lua commands from the server console
i was about to suggest what anonymous just mentioned
can servers not be run in a debug mode like that? its a shame
Do I include the " "? or just the name straight up?
as for using RCON, I thought that was impossible but I've been told otherwise, I'll have to look into that
it needs to be in quotations
checking this now
local function AddTraitEffects(_index, player)
Events.EveryOneMinute.Remove(TraitSunlightSensitive)
Events.EveryOneMinute.Remove(TraitMinorSunlightSensitivity)
Events.EveryOneMinute.Remove(TraitExtremeSunlightSensitivity)
if player:HasTrait('sunlightsensitive') then
Events.EveryOneMinute.Add(SunlightSensitive)
end
if player:HasTrait('minorsunlightsensitivity') then
Events.EveryOneMinute.Add(MinorSunlightSensitivity)
end
if player:HasTrait('sunlightsensitive') then
Events.EveryOneMinute.Add(ExtremeSunlightSensitivity)
end
end
Events.OnCreatePlayer.Add(AddTraitEffects)
Is what I have, but doesn't seem to do the damage at all now, does that look right? - I've got to head off now but I'll look at this again in the morning ty for your help
you'll have to call that AddTraitEffects function in some event
it's added to OnCreatePlayer at the end
ah
i noticed you're using different names when you're removing them than when you're adding them, i think you're likely adding the wrong names and that's why nothing is happening
does that event fire when you make a new character after death? handy
it's fired when an IsoPlayer object is created
ahh ya TraitSunlightSensitive vs SunlightSensitive
filewriter("eventdata.txt", "r")
-- read the contents of the file into a string
local fileContents = filewriter("eventdata.txt", "r", "*all")
-- check if the file is empty
if fileContents ~= "" then
-- split the string on newline characters
local lines = fileContents:split("\n")
-- create an empty dictionary
local eventData = {}
-- iterate over the lines
for _, line in pairs(lines) do
-- split the line on the ":" character
local key, value = line:split(":")
-- add the key-value pair to the dictionary
eventData[key] = value
end
-- delete the contents
-- delete the contents of the file
filewriter("eventdata.txt", "")
this is to read a json string and get the values...
anything that looks wrong?
wanted to test it but dont have pz installed on this pc
...
why do you remove them first?
even when you figure that out i dont think you'll figure that out lol... i've had trouble with those. wish there was more clarity on it. because .01 and .1 i see almost same rate
@bronze yoke , so the trait name in the "" needs to be same as the name used in the local function, that starts with Trait? Or the name used when creating the trait, like
SunlightSensitive = TraitFactory.addTrait("sunlightsensitive")
it needs to be that one - i meant the names of the functions
Events.EveryOneMinute.Remove(TraitSunlightSensitive) vs Events.EveryOneMinute.Add(SunlightSensitive)
yes, the one u use in addTrait
it cleans up the events, in case the player had the trait, died, and made a new character
sorry for imposing but im learning something i need to use for auto restart mod im working on.
Events.EveryOneMinute.Add(function)
would i keep that indefinetly?
OR
else Events.EveryOneMinute.Remove
or is there a reason you'd need to remove after?
or even have it in the first place
or only if there is a condition that would need to remove
it depends on the exact situation
for me it's checking for gettimestamp vs timestamp of server start
i want to do that regularly
if the code to add it can run more than once, you probably want to remove it first otherwise the function will run multiple times every minute
oh. so else remove would only run it once per min?
i'm trying to add a sandbox var for it so if i can figure this out then i can use that arg instead of a set number
dont need help with that part but understanding the event that makes sense for detecting gettimestamp vs server started timestamp so i can have a variable timing on server restart. and yes im an absolute noob but this mod is almost done 🙂
Sorry, so the local function name or the traitfactory one?
the traitfactory one is the one you need in the if, but that's not why your code isn't working
when you add the event, you're calling Events.EveryOneMinute.Add(SunlightSensitive), but from what i can tell your function is called TraitSunlightSensitive
Ah ok cool, so it needs to be TraitSunlightSensitive
Event.Add really should throw an error when it gets nil, lol
is this safe?
Folder placed in /shared/
Original mod used number instead of sandboxvars and he placed the .lua in client and server
shared should be fine
if they added the exact same file to client and server, that's pretty silly - the client runs files in the server folder anyway
idk but hes mod works fine in MP 😄
i'm just trying to setup a configurable version of the same mod
@bronze yoke I'll check it with the same names tomorrow and check, thanks for your help
A Necro forge user to help me? In the tab to get the list of all modded items, my items are duplicated, do you know why?
how would i go about making a command?
what kind of command?
a client to server command, one that i can use in chat
also when it comes to the actual chatbox itself, when im adding stuff to it does the image have to be from the game or can i add it with the mod.
like this: self.visibleButton:setImage(getTexture("media/ui/Panel_Icon_Gear.png"));
where the image is, can i add that to the mod folder
Thats actually a good question, I'm not sure how to add admin style commands
because im currently using ones from the game but they dont suit what i need them for
they can be from your mod
saund, thanks for the help, ill see if i can figure out that command thing.
good example of usage is in udderly up to date i believe
in the client commands file
can anyone halp me
im new too modding in PZ im not sure if i have my mods in the right load order
i can send a screenshot of my mods if that helps
idk how to tell if 1 a mod i added is working and 2 if i have them in the right load order true actions for example isnt letting me read while walking, as well as sit down n the chairs superb survivors is at the top of my mod list, i added a lot of good popular mods from the work shop QOL mods, britas guns, some vehicle mods, bunker mods for the paramilitary start mod etc
that last one is working, britas is working, npc mod check. but as far as the others idk
Cant find the ID of paw low loot in the workshop folder any idea where it is?
both of you #mod_support
are map objects just lua defined items?
I'm also noticing that if the object isn't loaded when I start the server, the server can't interact with it?
What the dog doing
Who the dog doin
Not just lua, they are coded into the Java. But you can construct new one’s through Lua afaik
But no one ever ask how the dog doin 😔
where can i find the stuff that makes obese give bonus fall damage and stuff
like the extra trait code
It'll be in the Java-side of the code, so not accessible to normal lua-based mods.
can i find examples in the files
A lot of trait related effects are on the Java side so you'd need to decompile the java files to see what they are doing.
If you just want a general usage of traits in the lua-code, searching inside files for "HasTrait" will bring up a bunch of trait-related code.
For example in media\lua\client\TimedActions\InventoryTransferAction.lua, this is where Dextrous/Allthumbs affect transfer times.
o.maxTime = o.maxTime * 0.5
end
if character:HasTrait("AllThumbs") then
o.maxTime = o.maxTime * 4.0
end```
where could i find the one for fitness/weight related ones
just wondering, where can I get the list of the Moveable. items?
I'm trying to find moveable big blue dumpster
moveables.txt and newMoveables.txt doesnt have it
i think most of them are generated at startup
oh aight, thanks
if you want the type or something it would be easier to just pick one up and grab it from the console
okies
Yeah, they are of type "Moveables.Moveable"
So a generic placeholder item that the game dynamically fills with the correct data when one is needed.
oh yeah i remember this now, i helped someone work out how to spawn them - you had to call a function on the placeholder that fills the data
I see
hmm i think scripting works too
since popsicle fridge doesnt have specific moveable
so I just do Result:Moveables.appliances_refrigeration_01_21
don't most moveables get their properties from the tile definitions?
I pull moveables from tiles all the time to give players items that may be more rare to buy on our shop. And I'm using them as my sprites for the Biofuels mod I'm making. the object sprite below is a placeholder
{
Type = Moveable,
Icon = default,
DisplayName = Moveable,
DisplayCategory = Carpentry,
WorldObjectSprite = DylansRandomFurniture01_13,
}```
you can also make a map object and set the sprite to the one in question
I'm still having trouble with my objects. When I load into the server, it doesn't initiate the server side object and I'm not sure why 😦
what do you mean
I was wrong
btw, you can send commands to server to debug it, just make a custom debug command that calls functions on server.
that would probably be far easier than what I'm doing.
Just so I can wrap my head around this. The luaobject is a temporary object that is initiated by the server on startup. And it's built off an isoObject which is the "long term" storage that is saved to the server, is that roughly correct?
So you interact with the luaobject and then push it to the isoobject for storage, right?
yeah, that how most vanilla works
seems really messy
remember the data keys I mentioned before? those are saved on the server on the global object even when the isoObject isn't loaded.
luaObjects always get their data from another object, they all have a java globalObject. To get the luaobject, you basically do globalObject:getModData(). But those objects only save things you tell them to save.
Most systems now, work around an isoObject and put / transmit the data that way.
it's just like I'm pretty sure I understand what this code is doing, but it's awful that it has to be done this way.
local isohbg = hbg:getIsoObject()
if isohbg then
hbg:fromModData(isohbg:getModData())```
but if I want to update every one of my objects on the server, I just have to iterate through them all and do this. it's just really messy
when you use getLuaObjectByIndex you get a luaObject, you don't need the getModData after that.
yea, that's old code I haven't tested yet, in my client function I'm not doing it that way.
and then after I do the work on the lua object I transmit the whole thing back to the isoObject
just seems like there an extra step in here for w/e reason
you only to call fromModData on clients btw, server shouldn't need it. Not sure how you imagine updating all objects without iterating.
and now it's not allowing me to get any luaObjectsbyindex.
if I do self.system:getObjectCount() it shows 1
self.system:getLuaObjectByIndex(1)
self.system:getLuaObjectByIndex(2)```
these all return nil
self is the instance right, you call lua functions on that directly. Not to mention Lua objects use Lua system (start from 1)
Yea, I know that. I tried 2 because the function returns (index-1)
return self.system:getObjectByIndex(index-1):getModData()
end```
that's how I'm calling it, so self should be correct
you're saying instead of self.system just use self?
no you use getLua above on the java system
either call getObjectByIndex on system, or getLuaObjectByIndex on instance, don't mix things up
there's also getLuaObjectCount or something you can use on instance
I'm sorry if this is a really stupid question, but what's the difference.
just print them to see if they are same obj and if they have same functions
self.system is a java object
this is what happens when you go to college for programming and then become a linux system admin xD
i'm honestly not that sure what it's for but that's why there's some redundancy
hmm
excuse the coder of this for any mistakes 😅
system getIbject gives you the global object
getModData then gives you the luaObject
ah, I didn't realize you wrote ISA!
just the parts after April, like this system
yeah, this system has a lot of parts like that
this is so painful, it's just interfacing on top of it
what's to stop us from just doing everything on the IsoObject?
since, the lua object modifiers just interface the IsoObject anyway
You can overwrite everything for your system, even make a different one.
this is useful
At first I thought it would give me the isoObject whenever I wanted, like you did.
You can replicate everything with a global ModData table.
I expect there to be about 60-80 of these on a server and any particular time. Likely a significant % will be doing nothing but existing.
a modData table would be thicccc
I have 2 more questions.
- Why is it when I change the contents of a container with lua and restart the server, it reverts the contents to before I did the lua work.
- Are sandboxvars available to the entire lua stack?
guys, how do I use setCanPerform(String functionName)
I'm trying to remove a recipe
what should I put in the string and function name?
getScriptManager():getRecipe('Gather Gunpowder'):setIsHidden(true)
getScriptManager():getRecipe('Gather Gunpowder'):setLuaTest('Recipe.OnTest.AlwaysFalse')```
that's how I'm doing it, I think albion helped me with that
hmmm
setIsHidden won't work if you're using ReduceLagofCraftingMenu
So I just have that line commented out.
Naturally you'd want to change Gather Gunpowder to your recipe name
@humble oriole
I've been renaming a lot of things and making them like modules instead of adding everything to global space here.
https://github.com/Poltergeistzx/ImmersiveSolarArrays
I don't suggest you do the same while debugging but it's something to consider. If you plan ahead, it will be easier to make everything local later.
is this code what's live on the mod now?
If you change them on server, they should save properly. There is one thing I've noticed with debug though, a lot of times when I quit the world doesn't save.
2. SandboxVars is a global table, the values are loaded between OnInitWorld and OnInitGlobalModData, before that you can consider to be the default values you set in the file.
it is not, I'll take a look at it. I referenced the live code on the workshop a lot for what I've written
no, I rename a lot of things so I will only upload after v42, still debugging a few things as well.
ok, I'll keep an eye on it. My mod is significantly more simple than yours, so it may not be worth it.
Do I have to do anything special to do math things in lua?
output["BioGas"] = (MethaneDailyRate / 24) * 1 * (biowaste / MaxBiowaste)
this is throwing some very odd errors
probably one of them is not a number
it was nil, not sure why
Hi guys! Can anyone explain to me, why client-side part of the mod is allowed to give a character XP?
I recently read code for the mod Skill Recovery Journal, and I was shocked when I found out that thole whole mod is client-side! And the strangest part was that I saw a call to a function player:getXp():addXp(...) in a client script.
Does this mean I can just fix any lua script on my computer to give myself max xp for all traits, and this will act like a cheat for MP? Shouldn't giving out XP be a server's prerogative?
I'm confused, please explain it to me, anyone?
Oh! @sour island You're the creator, right? Could you help with the message above? :)
I see that a lot of people are discussing issues right now, so I hope I don't interrupt anything! I've been wanting to create clothing mods for Zomboid for quite some time, and finally got around to doing it. I'm just having issues with it once I get to the whole process of having it show up in game. It does show up, but when spawned in debug mode I get 57 lua errors that I don't have the vocabulary to decipher, and when I right click on it to open the context menu my game brings up all of the debug info. Please forgive me if my descriptions of the issue are terrible, I only have experience on the visual art side of modding.
For some more context, the item is a blindfold, and should be set up right. I set the clothing location as a hat, and I haven't bothered to do any uv mapping or texturing since I'm basically just figuring out how the heck to do the whole process of modding. If anyone has any ideas or needs more info, please let me know!
does anybody has a link to a blender-addon which can export .x files?
Most things are indeed client side
Yes you can edit lua to do that but to prevent it theres a checksum of all files and if its different from the server connection is refused
Anyway if you want to cheat that much you can edit the java part
The denand for chuck is high nowadays. Wonder how much kofi donations you received thus far
That's great! Thank you for the answer
Does anyone have a code that lets me determine the angle
For a turret mod
Like where the player is
Looking for a modder that would be willing to work on an idea I had for multiplayer.
Willing to pay.
Essentially the mod idea is that instead of dying, a character goes into a DBNO (down but not out) state.
Upon hitting a certain HP threshold, your movement is heavily restricted, you’re essentially crawling, and require medical aid to get back up.
Otherwise it could be as simple as if you go down you have a countdown until another player can revive you.
I figured it out just in case somebody else has the same issue, I didn't have a line in the item's .xml file for a blood location!
how expensive are sendclientcommand/sendservercommands?
could they run ontick?
say, a sendclientcommand that tells the server to give clients near the source client the value of a variable
i dont think they are but when placed ontick im not sure
shouldnt u be using global moddata in such cases?
send command is supposed to limit traffic, not the opposite
if "source" can have modData then you can just check that modData. e.g. isoObject type
and regularly have the server send the data if the obj is loaded.
It's what the global object system like traps/farm do.
can client A check client B's getModData()?
or must server moddata be the middleman
depends where you change the values, but server is always in the middle obviously
AFAIR, when you call transmitModData() everyone else's "truth" becomes whatever the instance sent
regardless of whether the instance is a client or a server
depends what you mean, global modData specifically says it will not send to clients unless instructed to.
i’m looking to add typing indicators to roleplaychat and want to do so without bricking peoples servers
so when a player starts typing, they send logic to nearby players that they’ve done so- and as i type this i realize i can probably do this without moddata altogether
wish me luck, tysm
Olipro is there a way to set an exact float (java) from lua? It usually loses precision e.g 2 becomes 2.00000008
lol, I don't think you really mean 2 in your example, do you?
welcome to the world of IEEE-754 floating point values
what you want is unfortunately impossible
The solution is to not print unformatted floats
The innacuracy is intrinsic to floats
I don't think he's bothered about the print statement
well no I noticed that a > b is not accurate
herein lies a key issue, you almost never want to use == with a float comparison
which is why I printed it, to better show my problem
what you actually want to do is validate that x > Y > z, where Y is your float
but >= also failed
what was the exact conditional statement
the float can be higher than was I set
the other caveat you have to contend with is that when you hardcode a float in your program, that also will end up as whatever the closest representation is
I was comparing the possible maximum multiplier you can get from a book with the current multiplier of a player.
Only difference from vanilla, maximum can be multiplied by a float.
well, again, what was the comparison statement?
it was the float a which I set > the float b which the player has. Sometimes it was true, sometimes not. Which is why I added the extra y: a + y > b
I've changed this a few times but the principle is something like that.
Would math.max() work better here?
will this work if i type this on a live server
Events.OnWeaponHitCharacter.Add(function()
function isntaKill(wielder, character, handWeapon, damage)
local godWeapon = 'Base.DoubleBarrelShotgun'
if wielder == 'Glytch3r' then
if handWeapon == godWeapon then
character:getBodyDamage():setOverallBodyHealth(0)
print(character)
end
end
end
end)
no
if by "will this work" you mean "will isntaKill be in scope when I do the remove"
na forget the remove i just wanted to remove it so that when i reinitiate anychanges it removes the first version
there removed the remove
OK, so isntaKill is already defined?
in Lua, a global is really just a key in the _G table
no its not on any mod i just want to set it via debug
then just declare it
ye but it doesnt 1 shot the player i tried it
I think he just wants to run the logic inside
what are you talking about?
your snippet registers a function for an event that does nothing other than replace _G.isntaKill
im not sure if im not explaining it correctly basically once i run the command using debug im able to 1 shot a player
is there such instaKill? i just named it
if i cahange the name will it matter
🤦♂️
why couldn't you simply have said "I want to inject a function that results in a 1-hit kill if I use a particular shotgun"
sorry bout that
so will it be possible? what things do i need to modify for this to work
the enclosing function that you pass to Events.OnWeaponHitCharacter.Add takes no arguments and it simply declares a global function
what it sounds like you want to do is first declare your global function and then pass its name to Events.OnWeaponHitCharacter.Add
although you could just do it inline, but it appears you want to also be able to easily remove it from the debug prompt
whether or not it will actually work, I don't know. I haven't looked to see whether a client can arbitrarily tell other clients they've been shot and killed
yep
it wont work i think
getPlayer():getPrimaryHandItem():setMinDamage(99999999);
getPlayer():getPrimaryHandItem():setMaxDamage(99999999);
also did this
didnt work too
mmm, you would more than likely need to do it on the server
Ok il try
@sour island There was some scare earlier about whether your addXp decoration via reflection was safe / worked with anti-cheat and without debug mode.
I wasn't really paying attention at the time, but could you clarify if the solution was problematic to use, or if the anti-cheat flare-up was unrelated to the decoration? 🙂
For what it's worth, an easy way to test if a float value is close to some target value is to test if math.abs(value - target) < 0.01 (or whatever threshold you want to set for being "close enough")
Apologies if I'm teaching you to suck eggs 🙂





