#mod_development
1 messages · Page 129 of 1
Its around
-23 to + 23
so yes i will set ALL user to be east coast timezone got it.
@faint jewel try this
local current_time = os.time()
print(os.date("%c", current_time))
i test here and its works for me
let me know if it works
You could probably ask rj to add the users timezone to the pc mod and just fetch it from there.
But thats going to be an exclusive krp mod tho
if i paste it on debug lua console command line, works as same if it is on code right? @ancient grail
print(os.date("%c", os.time()))
current time from user, considering timezone, and converting to am pm, instead 24h
editted:
new version, am pm string doesnt appears on pz, so you need to add it inside the if else
the easiest way is to use the local time with 24h format (stored in current_time )
function convert_c_to_12(time_string)
local hour = tonumber(time_string:sub(12,13))
local minute = tonumber(time_string:sub(15,16))
local second = tonumber(time_string:sub(18,19))
local am_pm = time_string:sub(21,22)
if hour == 0 then
hour = 12
elseif hour > 12 then
hour = hour - 12
end
return string.format("%d:%02d:%02d %s", hour, minute, second, am_pm)
end
local current_time = os.date("%c", os.time())
local converted_time_string = convert_c_to_12(current_time)
and i need local.
So there's no API to get local?
well of course. but the hell would i want THAT for?
that's what %c spits out.
i wish PZ used %Ec
so use string manipulation to get the numbers out of that?
that makes it format it in the local time format
if %z worked i could just add or remove that as needed.
but of course not. they used the most minimal time formatting they could.
but local current_time = os.time() do works on local time,
but is not on 12 am pm format, it gives the 24h format
print(os.date("%c", os.time()))
and its true the function convert_24_to_12, doesnt work
@faint jewel finally an working version
here grab it!
function convert_c_to_12(time_string)
local hour = tonumber(time_string:sub(12,13))
local minute = tonumber(time_string:sub(15,16))
local second = tonumber(time_string:sub(18,19))
local am_pm = time_string:sub(21,22)
if hour == 0 then
hour = 12
elseif hour > 12 then
hour = hour - 12
end
return string.format("%d:%02d:%02d %s", hour, minute, second, am_pm)
end
local current_time = os.date("%c", os.time())
local converted_time_string = convert_c_to_12(current_time)
maybe the pm string are missing because i use 24h on my os
Max number of players for a multiplayer game is 100?
how to do setVariable work to free animation on half lower of player?
like doing legs do walk animation?
setVariable(IAnimationVariableSlot var)
Set the specified animation variable slot.
How can I know if there's a character near a certain tile? I'm using this so that if there's a character near a tile where a player right clicked, there would be an option added to the menu.
i know that superb survivor have closest players, here the snippet:
function getClosestPlayers(player)
local range = 15;
local Square, closestsoFarSquare;
local minx=math.floor(player:getX() - range);
local maxx=math.floor(player:getX() + range);
local miny=math.floor(player:getY() - range);
local maxy=math.floor(player:getY() + range);
local closestsoFar = range;
local closestPlayers = {}
for x=minx, maxx do
for y=miny, maxy do
Square = getCell():getGridSquare(x,y,player:getZ())
if(Square ~= nil) then
local distance = getDistanceBetween(Square,player)
local closeobjects = Square:getMovingObjects()
for i=0, closeobjects:size()-1 do
local obj = closeobjects:get(i)
if (obj ~= nil) then
--and (self.parent.player:CanSee(obj))
if (instanceof(obj,"IsoPlayer") and not obj:isLocalPlayer() and (obj:isDead() == false) and (obj:getModData().isHostile ~= true) and (distance < closestsoFar) ) then
table.insert(closestPlayers, obj)
end
end
end
end
end
end
return closestPlayers
end
@plucky dirge
just change player arg to square
Thank you!
and need this too
Firetrail.getDistanceBetween = function(x1, y1, x2, y2)
local dx = x1 - x2;
local dy = y1 - y2;
return math.sqrt( (dx*dx) + (dy*dy) ); --math.pow is slower 3.4x than x*x Вишня
end
/* commented out until we have a way to define locale and get locale formats working
https://github.com/krka/kahlua2/blob/master/core/src/se/krka/kahlua/stdlib/OsLib.java
kahlua gave up trying to fix locale
can the command
Events.OnReceiveGlobalModData.Add(function)
also be used on server side to fetch data which are send from client via the ModData.transmit command (the latter called on client side)?
Any way to add a property to specific sprites? Kinda like DoParam does for items? Currently mucking about with OnLoadedTileDefinitions and the SpriteManager
like the infamous light switches mod?
ha not familiar, I'm just trying to add some air filters lol
maybe he knows more now
I tried that earlier but wasn't seeing my properties appear in the chunk debugger
which property do you want to change?
I want to add a new one, which I'm guessing is the problem
new as not used by vanilla?
yes
I'm open to a better way of doing it, but I didn't see a way to export custom properties with the tilezed packer
I don't know if Alree's version has that option
Would you mind sharing your test code?
It shouldn't be very hard to do, you just need to add a new value to tilezed script
%user%/.TileZed/TileProperties.txt
Yes
oh i didn't realize it wasn't compiled somewhere
ok hell yeah, thanks for pointing me there!
TileZed/docs/TileProperties/index.html guide
for the record this was my test code:
function SWAB_SpriteUtility.OnLoadedTileDefinitions(_spriteManager)
_spriteManager:getSprite("swab_filters_01_0"):getProperties():Set("MyTestVal","theval",false)
end
Events.OnLoadedTileDefinitions.Add(SWAB_SpriteUtility.OnLoadedTileDefinitions)
you didn't make a new array with your value like in that snippet
oh shoot
whoops
let me try that, it would be nice to not have to compile these values into the pack
thx
Another question about the manipulation of global ModData (i.e. the data you get by ModData.get("key")): Is it safe to manipulate them on server side and then sending the manipulated data to clients? (client should only read the data, not write)
good morning from Korea to fellow developers
🙂
yea... i never really figured out how ModData works... anyone knows where I can read more about it?
seems like many mods store their data inside it so I would like to figure it out how it works..
whether it stores the data permanently or is it tempral data like local variables etc
Slowly getting my feet wet with Lua as I've worked with other languages except this one. This is a very noob question, but how can I get a key press / key hold in PZ?
I've been looking at the PZ Wiki quite a bit. So, that's been a helpful link.
Not exactly related to my previous question, but is it possible to test my mod while the game is still running? As in, I make a change, go back to the menu, and load my game again - will I see those changes?
Yeap because everytime the game loads the lua is reloaded
Thanks! In the mean time, I'll familiarize myself more with Lua and work on the key presses.
Hi there, is anyone know good mods for Foraging?
I feel like my visual standards are way too high.. I feel like PlantUML isn't good enough for generating UML.
__>
Someone needs to write a UML generator using HTML & Bootstrap.
that should be safe, since it shouldn't automatically synchronise ever - but i'd consider if you really need to use moddata on the client at all for that purpose
What exactly is a 'loadgridsquare' function?
i guess it updates a chunk just by looking at the function name
it's an event called every time a square is loaded
thank you. 🙂
For my current modding project, this is probably necessary...
Thanks for the answer. I just play-tested a bit and it really seems to work (at least via host button)
it's just that if you want it to be read from the server all the time, it makes more sense to me to just keep it as a regular table on the client - moddata is for persistence, which doesn't seem helpful here
it should still be moddata on the server but on the client it can just be a table
in my case, the server should be able to change those data over time. (server can also write). clients then can only read those data (also after the server has changed them).
For example, I start with the number 1 in the global ModData which can be read from every client. Then, after some game time, the server will replace that number by a random number. The new number should then also be read-only accessible by the clients. (This is roughly what I am doing.)
it makes more sense to send the current number to players when they join and when it changes, and have the client store it as a variable, not moddata
ah ok. This might work too (at least when in multiplayer). I currently store the current number in the client's mod data (i.e. player:getModData() ) and then update whenever the server changes something. This works in multiplayer and single player and makes the data save-game persistent in both cases.
yeah, one downside to this approach is it needs code alterations for singleplayer
What version of Lua does Project Zomboid use? I feel like knowing this will further help me accomplish what I want to do in the modding scene.
5.1
Thanks!
technically Kahlua2 :)
if you look in the top folder of your game you'll see all the libraries there
The one titled astar?
look at the jar's in the top folder
org/luaj/kahluafork sorry but yeha its lua but not in C, its lua reversed engineered written in java hard to explain 1 sec there a link that gives a good explaination
Interesting. I was a bit confused because I couldn't see any jars in common/ProjectZomboid... Closest things I could find for that were javax, jre, jre64, etc. All starting with j.
https://github.com/FWolfe/Zomboid-Modding-Guide/blob/master/api/README.md scroll down to the Zomboids Lua component
yeah threw me off at first too even more so Im like why didnt they just stick with <bla>
That is really interesting. Maybe there's good reasoning behind it. Or, maybe they just found what was best for them and stuck with it. Who knows.
sandboxing is my guess and not having to write a whole API just for the modding? kinda avoid the mess that MC went thru? I dunno
It seems to make sense in the modding regard.
Thank you for the link, by the way. There's a lot of goodies in there. Hopefully, the other sections get finished at some point.
yeah that indexing section is a very helpful part I was always wondering why my IDE was crying over something 0 index'd
Speaking of IDEs, I already have Visual Studio on my PC. Is that decent enough for the Lua or should I use something else?
well Im a netbeans user myself but for this Im using IntelliJ
So, Lua starts with index 1? Unlike C where it's index 0?
yep apparently.
I'll make a note of that. 🙂
that page explains it but yeah C/Java index 0, Lua index 1 so gotta know where its coming from
this page what got me started and going in IntelliJ pretty easy. https://github.com/Konijima/PZ-Libraries
VSCode babbyyyy
I didnt even try to look how well supported lua is for that.
Jab got any clue where sound trigger stuff is done at?
like the jumpscare when a Z catches ya offguard
yeah Im looking for the actual code that would call/trigger it not worried if its HC'd
Oh that? yeah IIRC hardcoded to call the event name.
Since I'm very new to PZ modding... Some of the things I'm currently looking into are button presses and drawing text. The reason I asked about what Lua version PZ uses is because it looks like there's a few ways to draw text in Lua. But, it'd make sense for PZ to have its own functions for drawing the text. Currently looking at media/luaexamples/ui.lua on how to do that.
yeah trying to hunt down it so maybe do some naughty since apparently surivors trigger it and the player gets slapped with teh jumpscare no reason
media/lua/client/ISUI/ISUIElement.lua
Sound files themselves are assigned to a group ID.
Is there a way to find PZ's main-loop? As in, how do I know when / if my Lua script runs in the game?
heh...
1 sec
! (exclamation), - (minus), 0 thru 9, _ (underscore), a thru z, ~ (tilde)
Just a fair warning, even though I've coded quite a bit before, I'm going to have some very stupid questions when it comes to regarding Lua for PZ.
i'd just throw in a print
everything loaded in an order basically (thats not even all of them)
my first mod was literally 'LoadingOrderAcidtest' I still have a few characters that are valid I need to check
but so far thats the sorting order I still gotta test capital A-Z also, trying to find documentation for what characters are valid for lua filenames is basically non-existent
if you running in debug your .log file will tell you when its loading them but shared folder first, client second, server last.
heh jab found out that upper or lower dont matter A.lua and a.lua seen as same file (atleast in my IDE)
okay added in the few other characters that seem to be valid (seems like it does follow DOS6 file name rules. as I said upper and lower case same letter are seen the same file (at least in creating one in the ide dunno if windows allows this...)
so updated load order ! # $ % & ' ( ) - 0 thru 9 @ ^ _ backquote A thru Z { } ~
just verified also that Z still is behind an "a" so upper or lowercase irrelative.
I bullied the Lua loading portion of PZ by doing a rebuilt reference dictionary followed by a custom init event code-block underneath every generated Lua file from Typescript.
No random reference BS when loading.
Any code generated from PipeWrench is safe from this issue.
oh I'd give my life just for a 'main' lua file where ya can then go from there but meh if there an order I dont mind now I know it.
hey guys, i would like to set a spawn point for each players manually at a diff. location that I desire. Where would be the best way to start? Any .class or mod I can take a look?
damn i want this tool
how is your progress on this mod
ill try to come up with logic
you first pick an event to be able to call when the function is triggered
ongamestart you can write where you want to set them on a file so you need getfilereader getfilewriter
then i guess on player death is the best option
ihave no idea how you are going to setup player spawn point but maybe you can modify the file the command wrote and from there you can just modify the coordinate.,. unless someone has a better idea. like menu and stuff... but basicaly you want them customizable
my brain isnt working yet i just woke up lol
then just teleport them when they spawn in game
setX
setY
setlx
setly
yo, so like I wanna gradually shift climate colors. This just abruptly makes it change every 10 minutes
function RaveClimate(_clim)
local ColorRed = ClimateColorInfo.new(1, 0, 0, 0.8, 1, 0, 0, 0.8)
local ColorOrange = ClimateColorInfo.new(1, 0.5, 0, 0.8, 1, 0.65, 0, 0.8)
local ColorYellow = ClimateColorInfo.new(1, 1, 0, 0.8, 1, 1, 0, 0.8)
local ColorGreen = ClimateColorInfo.new(0, 1, 0, 0.8, 0, 1, 0, 0.8)
local ColorCyan = ClimateColorInfo.new(0, 1, 1, 0.8, 0, 1, 1, 0.8)
local ColorBlue = ClimateColorInfo.new(0, 0, 1, 0.8, 0, 0, 1, 0.8)
local ColorIndigo = ClimateColorInfo.new(0.5, 0, 1, 0.8, 0.5, 0, 0.1, 0.8)
local ColorMagenta = ClimateColorInfo.new(1, 0, 1, 0.8, 1, 0, 1, 0.8)
local ColorTable = { ColorRed, ColorOrange, ColorYellow, ColorGreen, ColorCyan, ColorBlue, ColorIndigo, ColorMagenta }
local colorIndex = 1
function getNextColor()
colorIndex = colorIndex + 1
if colorIndex > #ColorTable then
colorIndex = 1
end
return ColorTable[colorIndex]
end
function updateColors()
local color = getNextColor()
local globalLight = _clim:getClimateColor(0);
globalLight:setEnableAdmin(true);
globalLight:setAdminValue(color);
globalLight:setModdedInterpolate(1.0);
end
Events.EveryTenMinutes.Add(updateColors)
end
Events.OnClimateManagerInit.Add(RaveClimate)
Events.EveryTenMinutes.Add(updateColors)
wow your code mp compat?
Prolly?
it doesn't gradually change tho
it just kinda short cuts to the thing
I dunno how to make lerp to the target value
because you gotta math it to transition from one color to the next.
i wonder if setModdedInterpolate is supposed to do that for you, though? that's what it sounds like it should do
dunno no clue just like not sure why there 8 values for color.
well when you say every 10 min, go from one color to another its just gonna cut... like a dubstep drop changing bpm.
He lives.

I feel like I'm writing some kind of mock-MIT paper on ZedScript lol.
felt more like I was back at oracle and they doing a presentation to the DoD
Those UMLs are literally why I'm up right now prepping UML for my work tomorrow.
xD
My boss saw em and was like "Yup. You're doing this for the meeting now."
I was lucky I was a hardware guy... but I had to still sit thru them
used to install these bad boys. https://archive.computerhistory.org/resources/still-image/Sequent Computer/102712890.03.01.lg.jpg
that and fiber optics
o-ohh...
It's going to be fun watching people react to my UML for ZedScript when I get it all done and place them in one giant image.
@red tiger to change my server nickname from Вишня to Vishnya I have to be Veteran 
I made a custom theme for PlantUML that looks like VSCode Dark Theme V1 with Ubuntu fonts.
ubuntu fonts 
I'd share you the current file I'm working on if I weren't under an NDA.
I can share you my theme because it's mine.
It's totally incomplete but it works for classes and objects rn.
never worked with plantuml before so I think it's not useful for me ha-ha
I might make a repo for it so someone will find it one day..
PlantUML is so ugly though.
I'll edit the hell out of it if I can get that professional shine.
yea, I already checked 
I'm considering writing a UML "Lego-set" in Bootstrap HTML.
Use the power of the Interwebz
Hopefully all this documentation for ZedScript will help people...
I hope won't be questions like why my 10k+ lines script file don't work

if it will help for peoples like I described ha-ha
decided to revive my pipes project before 42b 
SimCity 2000 when?
good night 
omg
uh.... sounds so complicated already XD
bleh
I posted in the wrong channel
hahaha
ColorInterpolator = {}
ColorInterpolator.instance = false
function ColorInterpolator:new(_clim)
local o = {}
setmetatable(o, self)
self.__index = self
o.clim = _clim
o.values = {}
o.colorIndex = 1
o.colorTime = 0
o.colors = {
{ r = 1.0, g = 0.0, b = 0.0, a = 1.0 }, -- red
{ r = 1.0, g = 0.5, b = 0.0, a = 1.0 }, -- orange
{ r = 1.0, g = 1.0, b = 0.0, a = 1.0 }, -- yellow
{ r = 0.0, g = 1.0, b = 0.0, a = 1.0 }, -- green
{ r = 0.0, g = 1.0, b = 1.0, a = 1.0 }, -- cyan
{ r = 0.0, g = 0.0, b = 1.0, a = 1.0 }, -- blue
{ r = 0.5, g = 0.0, b = 1.0, a = 1.0 }, -- purple
{ r = 1.0, g = 0.0, b = 1.0, a = 1.0 } -- magenta
}
o.interpolate = 0;
return o
end
function ColorInterpolator:Init()
local targetColor = ClimateColorInfo.new(
self.colors[self.colorIndex].r,
self.colors[self.colorIndex].g,
self.colors[self.colorIndex].b,
self.colors[self.colorIndex].a,
self.colors[self.colorIndex].r,
self.colors[self.colorIndex].g,
self.colors[self.colorIndex].b,
self.colors[self.colorIndex].a
)
self.color = self:registerValue(self.clim:getClimateColor(1), targetColor)
end
function ColorInterpolator:registerValue(_value, _target)
table.insert(self.values, { val = _value, target = _target })
return _value
end
function ColorInterpolator:OnEveryTenMinutes()
self.colorTime = self.colorTime + 1
if self.colorTime >= 10 then
self.colorTime = 0
self.colorIndex = self.colorIndex + 1
if self.colorIndex > #self.colors then
self.colorIndex = 1
end
local nextColor = self.colors[self.colorIndex]
local targetColor = ClimateColorInfo.new(
nextColor.r,
nextColor.g,
nextColor.b,
nextColor.a,
nextColor.r,
nextColor.g,
nextColor.b,
nextColor.a
)
for k, v in ipairs(self.values) do
v.val:setEnableModded(true)
v.val:setModdedValue(v.val:getName() == "GLOBAL_LIGHT" and targetColor or targetColor*self.interpolate)
v.val:setModdedInterpolate(self.interpolate)
end
end
end
Events.OnClimateManagerInit.Add(function(_clim)
ColorInterpolator.instance = ColorInterpolator:new(_clim);
ColorInterpolator.instance:Init();
end)
Events.EveryTenMinutes.Add(function()
if ColorInterpolator.instance then
ColorInterpolator.instance:OnEveryTenMinutes();
end
end)
I thought this would work but I keep getting an error on the line
v.val:setModdedValue(v.val:getName() == "GLOBAL_LIGHT" and targetColor or targetColor*self.interpolate)
Oh it's supposed to be "COLOR_GLOBAL_LIGHT"
btw why r u each time creating new ClimateColorInfo? u cached colors table and using it for new ClimateColorInfo, why u don't just cache ClimateColorInfo instead colors?
oh yeaaaaah!
XD
Dunno why I was doing it that way.


welp
cheers vishnya
still not working
heeey 
I just wanted the sky to shift through rainbow colors
Haha
you're trying to multiply a ClimateColorInfo?
did u ever use ColorInterpolator:registerValue? heh
But it works when you run the main code on debug? U are actually able to shift a color?
Yeah I was able to shift colors, but like, not gradually
same question but idk about this class so mb there's added mult method for it
Iduno about the class either
it's possible since it's dealing with colour but i'd still be surprised
Maybe you cant trigger changes from evvery10mins event
really surprised
I've done it before with like fog intensity
Use OnClimateTick or something
i just wanted to do it with the colros this time
just try to print everything and check mb smth even didn't called
Theres an event like that i think
Ah isee . Welp if it works on the fog . But still not sure if it works there? Idk
Doesnthat v.val:setModdedValue work
The whole line
The one inside the for loop
here's an example of when I made it work with one color
and fog
This time I just wanted a table of colors for it to run through and not do the fog
I am wondering something, a LOT can be translated, but can the description in a mod's mod.info file also be translated?
if Time > 48 then
--local intnum = math.floor(HourSurv)
--player:Say("You have Survived " .. tostring(intnum).. " HOURS")
player:Say("You have survived for ".. TimeString .. " Welcome to WURO Land")
player:getInventory():AddItems("Base.Apple", 1)
player:playEmote("salutecasual")
player:setX( math.floor(tonumber(7010)))
player:setY( math.floor(tonumber(5156)))
player:setZ( math.floor(tonumber(0)))
player:setLx(7010)
player:setLy(5156)
player:setLz(0)
else
player:Say("You have not survived for ".. setTime .. " days yet")
end
I dont know abt that i just leave mine with almost nothing written
I only modify the other one
Does anyone see why my char wouldn't teleport to indicated location??
what the hell math.floor(tonumber(7010))
it teleports but like.. 1 tile side where i was standing
ah, it's to use sandbox option .txt later
xD
what am i missing other than my brain? xD
What is player?
function TeleportSpawn_OnCreate(items, result, player)
local player = getPlayer();
--player:setHoursSurvived(1)
HourSurv = player:getHoursSurvived();
local setTime = 2
local Time = player:getHoursSurvived();
local TimeString = player:getTimeSurvived();
--local num = string.match(Time,"%d+")
--if tonumber(num) > setTime then
if Time > 48 then
--local intnum = math.floor(HourSurv)
--player:Say("You have Survived " .. tostring(intnum).. " HOURS")
player:Say("You have survived for ".. TimeString .. " Welcome to WURO Land")
player:getInventory():AddItems("Base.Apple", 1)
player:playEmote("salutecasual")
player:setX( math.floor(tonumber(7010)))
player:setY( math.floor(tonumber(5156)))
player:setZ( math.floor(tonumber(0)))
player:setLx(7010)
player:setLy(5156)
player:setLz(0)
else
player:Say("You have not survived for ".. setTime .. " days yet")
end
end
that's the whole thing
setX and setLx idnt the same
they are not the same
??
actually.. i don't get the diff. b/w setX and setLx
what is setLx do exactly?
Put that on a var first then call it
local coordX = 7010
Thats already rounded you dont need floor
player:setX(coordX)
player:setLx(coordX)
k ill ltry that
i guess it doesn't accept int. as it's parameter
It does
ah?
as Ik it using for speed calc, Lx = last(prev) x
i see
i wish debug mode has
search system after I open .lua files
so i can place breakpoints much easier
i see... so it's to calc. speed..
If I am coding a recipe and I want there to be multiple items as the result of the recipe, what would the code part look like?
Current code:
recipe Sell Pallet Of Copper Ingots
{
HCCopperingotbox,
keep HCTradingpost,
CanBeDoneFromFloor:true,
Result:HC20dollarbill
HC10dollarbill
HC5dollarbill,
Time:15,
Category:Trade,
}
You can add the OnCreate in it:
recipe Sell Pallet Of Copper Ingots
{
HCCopperingotbox,
keep HCTradingPost,
CanBeDoneFronFloor: true,
Result: HC20dollarbill
OnCreate: Recipe.OnCreate.SellCopperPallet
Time:15,
Category:Trade,
}
then in lua/client or server folder you add the function to add the items directly in the player's inventory
You need to oncreate
Then AddItems() a bunch of time depending on how many types u want to create but if its just one thing then you just add =integer
On the script
Im sure Im not clear... But if you dont understand ill explain further
I want to translate this game into Arabic with whom I speak
tnx
Where would I put the AddItems()? In between the result: and time:?
Mb, will look into the lua files of other mods to try to create my own.
Im afk
ahh
then just do Result:Base.Money=50,
dont need 0oncreate iof its jkust 1 type thats what i ment
Using HC money so I put Result:HC50dollarbill
Should I be adding the Hydrocraft. prefix to the code?
if you import module you dont need to if you didnt import then yes you should
imports
{
Base, farming
}
So should I make it into
imports
{
Base, farming, Hydrocraft
}
i gues
That would probably make sense as to why my hosting file wouldn't load when I put the mod in
Does anyone knows what the difference between the lua events "OnPlayerDeath" and "OnCharacterDeath" is?
Is there a limit to how far out in the world tiles can be placed?
Theory-crafting a way to combine multiple maps together dynamically, but it would be a lot easier if the maps could be placed anywhere in the world.
I am genuinely curious if the latter would work...
If the world bounds are infinite, you'd just assign each map to its own local "origin" and offset each of its tiles by that. And the origins can be as far away as needed go ensure that each map has enough space.
This is less a question about creating maps and more the limitations of the game's engine.
Hence why I dropped it here.
...what?
I make maps and I don't know the map limitations.
Because why would I need to for making buildings and tiles?
why do u asking us about MAPS in mods chat instead MAPS chat
Because it's more relevant here.
That's your opinion.
Lolwhat
I'm just trying to get an answer to my question in the channel I figured it would fit best in.
Is it not a question of the game engine limitation? I personally think the game map falls into that category
👆
I said the best chat for ur question
what's the problem
Look. I'm not arguing about this anymore.
No point in arguing any further lol. No harm asking there again either
Got a problem with me asking in this chat? Take it to a mod.
Anyways.
The idea would be to dynamically load individual maps into a new "combined" map with teleportation points to move between them, like how the basement mod works.
👍
So the mod would need to manage essentially taking map data, loading it into a different location within a separate map, and then linking up the transit points between it and all other areas.
I'm curious as to whether this could be done on game load, or if it would need to be a separate application.
I'm trying to see this in a different perspective. Would it even be possible for a modded map to not be connected to the "main" region?
I... think? There definitely are standalone maps.
I wonder though, do they just put their stuff super far away?
That would be unlikely lol
I'll have to check that out. Would be funny if that was the case.
Would certainly make linking them easier.
I'm all for pushing envelopes and taxing the engine, but logically it would make more sense to just manually place the maps to fit better with each-other.
Making borders or waypoints to link maps is kind of counter to how the vanilla map is setup to work - being it's handled in chunks.
Doing anything map related in real-time will be taxing to the engine/gameplay btw. Although, it might be more possible with the introduction of basements -- as they've implied they use loaded templates.
Dynamically generating roadways between maps would also be something you can generate once and be done with it. Nothing really beats generated-once-and-then-hand-curated @ornate summit
This coming from someone who doesn't know much about mapping in PZ though
Do you folks use Mod Options to allow your players to change mod settings, or are there better solutions at this point?
I believe Star plans to rework modOptions
If you prefer players to not be able to change options I made EasyConfigChucked work like that
But I also plan to rework that too, to offer both options
Soon™
Lol, well I appreciate the answer. I'd like to add options to my mod which can only be changed by the admin in multiplayer, but are configurable by players in singleplayer.
I understand that sandbox vars can achieve that, but I'm not confident on how to work with them, and I definitely want changing the values to be supported through the UI.
After a bit finally made my first mod, thanks for all the help guys!
https://steamcommunity.com/sharedfiles/filedetails/?id=2944344655
Do you happen to have an example of the valueTranslation for the enum class here?
Ugh this is really frustrating me
function TeleportSpawn_OnCreate(items, result, player)
local player = getPlayer();
--player:setHoursSurvived(1)
HourSurv = player:getHoursSurvived();
local setTime = 2
local Time = player:getHoursSurvived();
local TimeString = player:getTimeSurvived();
--local num = string.match(Time,"%d+")
--if tonumber(num) > setTime then
if Time > 48 then
--local intnum = math.floor(HourSurv)
--player:Say("You have Survived " .. tostring(intnum).. " HOURS")
player:Say("You have survived for ".. TimeString .. " Welcome to WURO Land")
player:getInventory():AddItems("Base.Apple", 1)
local X = 7010
local Y = 5157
local Z = 0
player:playEmote("salutecasual")
player:setX(X)
player:setY(Y)
player:setZ(Z)
player:setLx(X)
player:setLy(Y)
player:setLz(Z)
else
player:Say("You have not survived for ".. setTime .. " days yet")
end
end
why is this not working??? it won't teleport my char
this is what happens
is it because i ran this code in Client? should I use onclientcommand?
it worked when i was in single play or hosted a coop server but won't work on dedicated
Can share lua require share?
you mean as in like pre-load require? depenancies etc.?
Butwhat does it says cannot find oncreate? Youre doing it wrong and yes put it on server
U have to run on debug to see errors man
Yes
actually good question, I mean if its something that can run for both server and client then I would think yes? not sure if server has access to everything client does (but doesnt use it or cant...)
well makes sense. but then you got the whole SP basically being one and the same (I think) but MP/dedicated that def makes sense client/server cant see each other.
it isn't showing any errors on debug
just doesn't teleport
well it does teleport.. but just not to the given X Y Z i wrote
what do you mean paste the code on debug?
The lua console just paste the code without the conditions
Like this
getPlayer():setX(getPlayer():getX()+10)
getPlayer():setLx(getPlayer():getX()+10)
Then hit enter
oki
yeah not debug Glytch meant console.
Ye lia console
Lua
Sorry i mesed up the term
I cant figure out my shit either .. 😦
its okay I do the same thing till its like burned into memory
only way I remember things cuz I look like that face all day.
more like stare at code... time for medicine... 🚬
ah better.
Nice
Are you okay?
Dont make it complex then if that works
or have it set the coords to your log file or say it to verify ya calculations
less complex... ok
Why is my code alll messed up omg im about to pass out and failed my thing for the day
Im gona concentrate now .
heh I'll be at work all day thinking of this stuff...
yea i know what u mean
also why I typically blast hardcore or industrial while doing this... keep me in a rhythm
one death, one try, every 40 seconds a script dies from a missing end block, aye!
ouch...
still can't figure out what is wrong with my code XD i should just give up...
glad to know you found your error 🙂 congrats
Well i kinda found a hint of what the problem is..
If i plug in the coord. that is around my char, it works flawlessly. However if I plug in a long distance beyond the cell I am in.. it doesn't work
i guess ill have to load the map region first then call out this function?
see how other tp mods do it
yea, i guess that would help.. I wanted to solve it by myself.. but this is my limit
i accept my defeat Lua....
@open drum
try your command from console. There's some triggers that will stop you teleporting, I think recipe might be one of them.
oh really?
If that works, adjust your function to trigger on next tick
I think I have an example here
oh, thousand thanks
ye i already linked mine to him earlier
yea with help of you guys
i was able to make it work
thanks alot
the problem was that OnCreate function
👏
does not run teleport
congrats
thank you
coulnd't have done it without u guys
been struggling with this for whole day today
Crafting cancels movement - I think someone had a similar issue
A while back
I also had a similar issue actually - with teleporting off walking into squares
Hello. Awhile ago, I made a simple mod that removes the "rotting" parameter from food, so that it never spoils (https://steamcommunity.com/sharedfiles/filedetails/?id=2695935241). It just changes some of the .txt files, it's very straightforward. Someone asked in the comments if I could update this mod to also work on modded foods, specifically, the ones from Pomp's Items (https://steamcommunity.com/sharedfiles/filedetails/?id=2792348686). How would I go about doing that? If I grab the .txt files from Pomp's, remove the same parameters, and put it into the mod files that I upload, is it going to conflict if people don't have Pomp's installed?
You could parse through the scriptManager in Lua
Basically at the boot up you have the scriptManager look through each script and make changes you're already making. There's probably a snippet or two if you search "scriptManager" here.
whats your guys thoughts on chatgpt for helping you make mods, I tested earlier and i was so blown away it figured out how to edit UI elements and include require "ISUI/ISPanel"
require "ISUI/ISLabel"
require "ISUI/ISComboBox"
require "ISUI/ISButton"
requiring vanilla files doesn't do anything anyway
using it to assist you is fine, but don't rely on it too much - the code it generates often looks fine at a glance, but is actually complete nonsense
obviously lol but it spat out this:
require "ISUI/ISLabel"
require "ISUI/ISComboBox"
require "ISUI/ISButton"
AgingMechanicUI = ISPanel:derive("AgingMechanicUI")
function AgingMechanicUI:new(x, y, width, height)
local o = ISPanel.new(self, x, y, width, height)
o.character = getSpecificPlayer(0)
o.ageComboBox = ISComboBox:new(50, 50, 100, 25, o, AgingMechanicUI.onAgeComboBoxSelected)
for i=18,80 do
o.ageComboBox:addOption(tostring(i))
end
o:addChild(o.ageComboBox)
return o
end
function AgingMechanicUI:onAgeComboBoxSelected()
self.character:getModData().age = tonumber(self.ageComboBox:getOptionText(self.ageComboBox.selected))
end
function AgingMechanicUI:update()
ISPanel.update(self)
local age = self.character:getModData().age
if not age then return end
self:addLabel(50, 100, "Age: " .. tostring(age), 1, 1, 1, 1, UIFont.Small)
local hairColor = self.character:getHairColor()
if age >= 60 and hairColor ~= "gray" and ZombRand(100) < age-60+1 then
self.character:setHairColor("gray")
self.character:setHairDye(nil)
end
if age >= 80 then
self.character:kill(nil)
end
end
Events.OnGameStart.Add(function()
local player = getSpecificPlayer(0)
if not player then return end
local age = player:getModData().age or 18
player:getModData().age = age
local stats = player:getStats()
stats:setHunger(0)
stats:setThirst(0)
stats:setEndurance(0)
stats:setPanic(0)
stats:setBoredom(0)
player:setHairDye(nil)
end)
ive noticed it does go a bit overboard in areas or itll just produce some random shit in other areas
sometimes you gotta optimize its own code and itll maybe remove the shit at times
Have never used Lua before, but I'll see what I can figure out. The other thing people have asked for on that mod is a setting to prevent food spoilage, but only in a freezer that's currently powered on. I know you can change rate of spoilage in a freezer on sandbox settings, but I've never figured out where that setting actually lives -- if I could find it, I could just set that parameter to 0 to disable spoiling, possibly.
Any leads on that?
LOL at age 80 it just kills you??
yeah it was just a test to see if it would flag the openai warning cuz it had the word kill in the prompt
this is definitely the best i've seen from ai generated code in here, i haven't worked with ui extensively but it is definitely at least close to correct
the problem is people dont know how to speak to it and then blame the ai
its all about what you say
you gotta be clear and concise
i usually see it completely making up functions and stuff
Please just output the code and a short summary```
this was the prompt
i tried chucked random ideas and wanted to see if it would do it
it did this at first and i was like wtf
so i had to tell it to do it in a for loop
chatgpt trying to turn into a mini yandere dev
thefuq happened to the muzzle flare
Going to train chatGPT to bugfix for me
On break.
varargs may help?
Hell a range lol
I'm becoming less human. My proof? I thought of a fucking varargs solution to that picture before seeing it was a numeric literal range.
Is this a guide ill post it
Ow its not
rip
HE FLAMIN'
anyone has something on an animation state sometimes not working/ transitioning ?
or how to set an animation state ?
Question, I'd like to add a random item that you can unpack (using right click / recipe) that gives you a random item from a list. How does one go about that?
I assume wit an OnCreate but how exactly does it work
-- Define a list of items to randomly choose from
local itemNames = {
"item1",
"item2",
"item3",
-- add more items to the list as needed
}
-- Define the unpacked item
local unpackedItem = {
type = "Item",
displayname = "Random Item",
icon = "random_item_icon", -- replace with the path to your item's icon
texture = "random_item_texture", -- replace with the path to your item's texture
weight = 0.5,
-- add other properties as needed
}
-- Define the recipe for unpacking the item
local unpackRecipe = {
result = "Random Item",
ingredients = {
{"box", 1},
-- add other ingredients as needed
},
-- add other recipe properties as needed
}
-- Define the function that gets called when the item is unpacked
local function unpackItem(player, item)
-- Choose a random item from the list of item names
local randomItemName = itemNames[math.random(#itemNames)]
-- Give the player the chosen item
player:getInventory():AddItem(randomItemName)
end
-- Define the OnCreate function for the unpacked item
function unpackedItem:OnCreate()
-- Set up the unpacking recipe
self:Use("Box")
self:addRecipe("unpack", unpackRecipe)
-- Set up the unpacking function
self:setCustomContextMenu("Unpack", "unpackItem")
end
it generated this
try that or take parts if u need it
no clue if it works
Oncreate is a function that is called by item scripts
The function should be written on the server lua
To do the random thing you could
Put stuff on a table
Then use ZombRand()
Sample
SampleStuff={ "Base.Apple",
"Base.Orange",
"Base.Cherry", }
getPlayer():getInventory():AddItems(SampleStuff[ZombRand(1, #SampleStuff+1), ZombRand(8))
This will give you a random fruit and and a random amount
@wooden lodge
It wont
Pz has own randomizer function thing
ZombRand()
And
ZombRandFloat()
it did get it but on the second line lol
@ancient grail So I use this, 1:1
SampleStuff={ "Base.Apple",
"Base.Orange",
"Base.Cherry", }
getPlayer():getInventory():AddItems(SampleStuff[ZombRand(1, #SampleStuff+1), ZombRand(8))
``` in the media/lua/server directory and use OnCreate:SampleStuff_OnCreate
or am I being stupid
And which number do I need to chagne if there's more than 3 items?
most of what the ai spat out is total nonsense
After the #SampleStufd
And a local on samplestuff declaration
Should be
local SampleStuff ={
KaeldorConch = {
"Yes",
"No",
"Maybe",
"Absolutely not",
"Definitely",
}
function KaeldorConch_OnCreate(items, result, player)
local roll1 = ZombRand(1,5)
processSayMessage(KaeldorConch[(roll1 + 0)] .. "!")
local sq = player:getSquare()
end
For stuff like this
And it works
local KaeldorConch
Is anyone familiar with preventing players from putting items in a container for a short time?
I want to add some random loot box tkind of thing
Yep i got that
Just a bit confused with this now actually
How so
So let's say
SampleStuff = {
"Base.Apple",
"Base.Orange",
"Base.Cherry",
}
function SampleStuff_OnCreate(items, result, player)
local roll1 = ZombRand(1,3)
processSayMessage(KaeldorConch[(roll1 + 0)] .. "!")
local sq = player:getSquare()
end
What would I need toa djust here
I'm a bit tired too, doesn't help
local myItems={"Base.Apple", "Base.Orange", "Base.Cherry",}
MyOnCreate = function(items, result, player)
player:getInventory():AddItems(myItems[ZombRand(0, #myItems)+1], ZombRand(8))
end
And what would I need to puti in the rcipe of the box?
There
recipe Ask the Conch
{
KaeldorConch,
Result:KaeldorConch,
Time:30.0,
OnCreate:KaeldorConch_OnCreate,
AnimNode:Forage,
}
Like for example
What is the onCreat called in your case?
This one
Ye
OnCreate:MyOnCreate
so whatever you end up renaming the function to
Ye
and ZombRand0 means it picks any in the list?
Its the function itself
What does the +1 stand for?
It just generates a number
#myItems)+1]
zombrand is java so it counts from 0, lua counts from 1
(minimum, maximum)
By default if you put just one number
Ot will count from 0
yeah, though now that i'm looking at it that one should be + 1 too
otherwise sometimes it'll try to spawn 0 items...?
And if I have 3 items
and put that to 3
All 3 will always spawn?
Is that how I'm understandg it
you'd replace ZombRand(8) with just 3
(1,3+1)
And if I put it to 1
No thats the qty
Only one item from the list will spawn
Like a random one?
Shit this got me more confused than it should lmfao
oh, actually it'll spawn multiple of one item
Ow yeah if you dont add 1 it moght not spawn stuff
Thats what i intentionally did but if u want it to always generate stuff then just add 1,
What if I want to make a box that contains an entire set of gear
Like a 100% chance to spawn every item once
Like a set of gear
if you want it to pick randomly for each one it'd be better to do something like this:
local myItems={"Base.Apple", "Base.Orange", "Base.Cherry",}
MyOnCreate = function(items, result, player)
local inventory = player:getInventory()
for i = 1, 3 do
inventory:AddItem(myItems[ZombRand(0, #myItems)+1])
end
end
The. Its the same
#Gears
This returns the number of entry on the array
If you have 5 gears then thats 5
for a set of items, something like this:
local myItems={"Base.Apple", "Base.Orange", "Base.Cherry",}
MyOnCreate = function(items, result, player)
local inventory = player:getInventory()
for i = 1, #myItems do
inventory:AddItem(myItems[i])
end
end
it'll give you one of every item in myItems
Since zombrand starts from 0 we add +1 cuz we want the last item to be on the list aswell
Thank you so much for that one, yet I'm still confused about the first one that shold give you ONE random item from like a big list
If I add 20 items to thtat list
and it should only spawn one randomly
if you just want it to be one item every time
local myItems={"Base.Apple", "Base.Orange", "Base.Cherry",}
MyOnCreate = function(items, result, player)
player:getInventory():AddItem(myItems[ZombRand(0, #myItems)+1])
end
Then I geuss it would be 1 and the 3 would be 20?
I don't have toa djust any numbers there?
Albions code is for uou to spawn everything on the list
No matter if the list has 20 or 50 items?
@ancient grail did you ever figure out how to sync inventory changes from the server faster? Still hitting a wall on the DoRemove on the server side.
I think i did? If its related to container
But just inventory i have no idea if i
Theres any need for that..
Why whats happening to the items
If you did that #ArrayList+1)
inventory belongs to the client so there are no synchronisation issues there
Then ye you dont have to adjust it . O ly add or reduce stuff from list
@ancient grail So I can technically add 20, 25, 30, 39, 75 items to that list
And it would still work without changing a variable? number?
It would still pick 1 item no matter how many are to be selected?
yeah, this will work with any sized list
I just answered this
best not to confuse between tables and arraylists
I appreciate it
Did i ? Sorry
I'm doing a timed action that at the end removes the item from the container, and if a player puts anything in the container for 2-3 ticks after the timed action finishes the items evaporate and a bufferoverflow error hits the log.
arraylists are java, tables are lua
how does the inventory transfer action avoid this? (or perhaps how does it cause this)
I'm assuming that the inventories desync between the client/server when the server removes them from the container
most likely
Goodto know
If you do this on the server, you must propagate the changes IIRC.
I am, that's what's annoying
That or mixing up index 0 or 1
when they get around to making inventories fully server-side authoritative this will stop being an issue
(Haven't read up yet)
Not sure why the system in-place in b40 wasn't ok to keep.
So what happpens to your inventory
When you relogin
It's very confusing that they'd make it Client-auth.
biowastecontainer:removeItemOnServer(item)
biowastecontainer:DoRemoveItem(item)
end
end
if hbg.biowaste > maxWaste then
hbg.biowaste = maxWaste
end
isohbg:sendObjectChange("containers")```
Like the work will only be reversed.
Cuz the atm mod syncs
wait, it was server auth before? so they made it server auth, then made it client auth, and now they're making it server auth again...?
TIS is planning that ?
yes, it's been mentioned in a few blog posts
self.homebiogas:getContainer():requestSync()
ISInventoryPage.renderDirty = true
also doing this in the timed action
after sending the command
Been watching the game's Java code since Build 30.. IIRC inventories were server-auth until 41.
sh*t my autoloot mod will break for sure
if isClient() then
DoRemove(item)
end
Ithink iirc
biowastecontainer:DoRemoveItem(item)
yeah, any mod that messes with items is totally going to break
Again a mod data question: if I write smth in an item's ModData on client side via
ìtem:getModData().mydata = "something",
are those ModData then visible for other clients as well?

Should have client check still
do I need to run the doremoveitem on both the client and the server?
Whatsup
I thought that doing it on the iso object's inventory would essentially do that
even if it's on the server side
I think its already sending it to the server i mean the thing to delete
on isoobjects you need to synchronise moddata (and you should always do this, as your moddata can get overwritten by another mod that does if you don't), but on isoplayers and items this isn't needed
thx
well, these are running from the server side.
biowastecontainer:DoRemoveItem(item)```
should I move all this logic to the timed action and send the data that I want from the items to the server?
looks like removeItemOnServer doesn't do anything on the server
It might still work
Like what pao did
SendServerCommand from server lua
And then uddereverlyn noticed
We never knew you could do that
it makes the client request the server to remove it
Call server from server
What?
function HBGPlungeBiowaste:perform()
if self.homebiogas:getContainer():getAllCategory("Food"):size() > 0 then
CBioGasSystem.instance:sendCommand(self.character,"plungeBiowaste", { { x = self.homebiogas:getX(), y = self.homebiogas:getY(), z = self.homebiogas:getZ() }})
else
self.character:Say(getText("IGUI_BioGas_ContainerEmpty"))
end
self.homebiogas:getContainer():requestSync()
ISInventoryPage.renderDirty = true
ISBaseTimedAction.perform(self);
end```
Like send a command to itself
why though?
I'm literally just sending the coordinates of the isoobject to the server and making that do all the work
you can already do that... just call the function
And this is why I build tools to prevent stupid logic like that from seeping into works.
The server calling to itself to fix an issue?
local biowastecontainer = isohbg:getContainer()
local foodList = biowastecontainer:getAllCategory("Food")
if foodList:size() > 0 then
for v=1,foodList:size() do
local item = foodList:get(v-1)
if hbg.biowaste < maxWaste then
hbg.biowaste = hbg.biowaste + item:getCalories()
if item:getReplaceOnUse() then biowastecontainer:AddItem(item:getReplaceOnUse()) end
--biowastecontainer:Remove(item)
biowastecontainer:removeItemOnServer(item)
biowastecontainer:DoRemoveItem(item)
end
end
if hbg.biowaste > maxWaste then
hbg.biowaste = maxWaste
end
isohbg:sendObjectChange("containers")
hbg:saveData(true)
end```
that's the server side command
but SendServerCommand is the one clients listen for
and i had a little look and servers cannot call SendClientCommand, and clients cannot call SendServerCommand
is this aimed at me, cause I'm sending a client command from the timed action which is client side
it's aimed at glytch3r because what he's saying doesn't seem true at all
ok, I thought so, just wanted to confirm
most likely someone is running code from the server folder on the client and getting confused
Yeah. It caught me off guard enough to stop lurking.
I'm already interfacing with the container in the timed action, do I just run this in the timed action and remove the item from the client side?
Its from modding server
Feel free to join or pls join rather hehe
Links on my profile
Not really sure if thats what happened but thats what she said idk if thats the whole case incase i misunderstood i apologize
Sorry hehe
Happy BDay @tame mulch
Off-topic: I'm a little sad that no one has scrutinized my JSON schema for ZedScript.
I don't know how to interpret that. Either I'm the one setting a standard schema for ZedScript or no one has the time for it.
What is JSON schema?
It's defining what objects has what and what they are, what they store, etc.
Think of it as a skeleton for JSON.
Send me schema, I will try check
So for instance:
vehicles: [{
wheels: [{
//...
}]
}]
when
vehicle myVehicle {
wheel frontLeft {
}
wheel frontRight {
}
}
I don't have a literal JSON Shema file yet, however I have rendered everything in media/scripts with my parser and my JSON format. Here's the results:
array-like or plural object-definitions are stored as arrays with property names changed to be plural.
deconstructed / deserialized vectors, float-arrays, string-arrays and complex objects as well.
It's in order to stay within the philosophy / tools used in JSON, which means that I've modified the names of some of the properties and structs in ZedScript when parsed to the JSON API.
This sets up my JSON -> ZedScript to produce clean results.
Looks good and clean!
I don't know how to improve it)
Thanks. I'm clarifying that because there isn't a standard for the interpretation of ZedScript in JSON, I may be setting the standard if no one contests it.
The last thing I'd want to have on my hands is a fully written piece of software on-top of an interpretation of ZedScript as JSON that would be troublesome for others or something like that.
This is the actual JSON Schema format (Not PZ related): https://json-schema.org/
I'm not asking you or TIS to do anything. I'm asking that when you do something involving ZedScript and it involves or conflicts with my work that I'd be notified or the info be posted somewhere that I can see that.
That's really it.
I will update pzwiki after 42 unstable will release, so I think it will not be problem for you to update zedscript 🙂
Simply following up and keeping the door open for discussion.
Did you also see my UML?
I did some UML work for categories for ZedScript.
It may be useful for you and others to visually see how blocks of properties relate to one another.
I doubt anyone cares, but I did this and it completely resolved the issue, had to do some hacky stuff to get the modData from the server side, and I'll have to throw in a few extra checks/balances, but it seems to be working fine now.
I care. It's an incredibly useful piece of information that could save hours or even days of debugging for others going forward.
I'm in the business of caring about these solutions. I'm spending my time making solutions so people don't fall into silly gotchas & caveats.
So I've ran into the issue with an OnCreate script and a box that is supposed to give random items.
Whenever I try to start a game it gets stuck on the blackscreen.
As soon as I take the recipes to unpack the boxes and the function itself out of the files, it works again.
Anyone here experienced with that kind of stuff that I could send my script to to look over it?
Send here, I will check
Don't know where to put this so i'll use here.
I am wondering, is it possible to change the way objects look in the world, like fridges, ovens ect. ect. instead of like custom objects having it overtake a priority from the vanilla assets. I understand the regular way it works is through sheets with each individual png with 2 different directions
I want to attempt to bring 3d objects instead of having the "Deck of cards" that is zomboid.
local Lootbox1L={"Base.Apple", "Base.Orange", "Base.Cherry",}
Lootbox1 = function(items, result, player)
player:getInventory():AddItem(Lootbox1L[ZombRand(0, #Lootbox1L)+1])
end
local LootBoxImplantsL={"Base.KaeldorImplantPassive", "Base.KaeldorImplantAgility", "Base.KaeldorImplantCombat", "Base.KaeldorImplantCrafting", "Base.KaeldorImplantFirearm", "Base.KaeldorImplantSurvivalist", "Base.KaeldorImplantTraitremove", "Base.KaeldorImplantTraitadd",}
LootBoxImplants = function(items, result, player)
player:getInventory():AddItem(LootBoxImplantsL[ZombRand(0, #LootBoxImplantsL)+1])
end
recipe Unpack the Lootbox
{
Lootbox1,
Time:30.0,
OnCreate:Lootbox1,
AnimNode:Forage,
}
recipe Unpack the Lootbox Implant
{
LootboxImplants,
Time:30.0,
OnCreate:LootBoxImplants,
AnimNode:Forage,
}
Albion has looked over it too and said it's - I quote - 'very weird'
The items itself work fine and can be spawned in as well, the issue has to be somewehre in teither the script or the recipes
And when I remove the recipes and the script, the game loads fine, if I add them, it gets stuck at the loading screen after loading map etc. the "Click to Start" just never shows up
No errors and no errors visible in console either
Strange. Can you anyway send console.txt. Need check on what step game freeze
is there an IsBitten thing for playerBody?
or how would i go about it if i want to check if someone is specifically bitten?
try f11
Hi, is there an event triggered when sandbox options are modified ?
you can make one
body damage has IsBitten method
BodyDamage:getNumPartsBitten() > 0 would be the easiest way
ok thanks
so with the latter, i could use that to check if any parts are bitten at all?
yeah, the IsBitten()/bitten() methods need a specific body part
@tame mulch
also, how can i use rng to give someone a trait?
basically this comment gave me the bright idea. im sure it is possible
minus the RNG part, would this work?
I saw star made something similar for his sp mod, change sandbox options.
thx
Reopen it?
yeah the file list that lets you search through files to reload lua
i accidentally closed it
Mean the debug window itself
Find the debug settings file
the right side would usually have that list and a preview of the lua file
it's faster to reload to main menu, than find the answer?
it is faster to get an answer so i dont keep doing that
i have accidentally closed it many times and would just reload to main menu and wait for lua to reload both ways
Fire trail v1.4 is out :)) with new anims (dhert you are amazing) and added propane torch to start fire
you will notice on code, that now is more easily to add modded items, and new items
Modders:
if you want to use your modded items, use
table.insert(Firetrail.currentSupportedItemsStartFire, "Type (1st column on item list debug)")
https://steamcommunity.com/sharedfiles/filedetails/?id=2940908294
but if there's not a solution and i really do have to go back to the main menu and back into the game then i guess i will just do that
https://github.com/Project-Zomboid-Community-Modding/pz-community-modding
I think this has a file reload UI, out of paused debug state (f11)
It adds some nice tools, changes some settings and fixes some debug bugs
nice
what's the reason behind those grey outlines?
is it because they are rgb .png?
should I have them indexed with a color limit?
dumb question, but have you checked if there isn't a grey outline in the sprites?
there's none
strange
i guess look at the sprites of the clothing in the base game and see what their file structure looks like
If I want to automatically remove a part from a vehicle using code, how do I make this statement:
ISTimedActionQueue.add(ISUninstallVehiclePart:new(playerObj, part, time))
Automatically pass with .isValid()?
function ISUninstallVehiclePart:isValid()
if ISVehicleMechanics.cheat then return true; end
return self.part:getInventoryItem() and self.vehicle:canUninstallPart(self.character, self.part)
end
I guess my question is how do I set ISVehicleMechanics.cheat to be true?
hi, guys. is this the place to show people recently published (uploaded to steam) mods, for people to know them, and maybe get some feedback?
go for it. You can also post in #pz_b42_chat if you don't spam it
ISVehicleMechanics.cheat = true
I think it's a resolution issue, since the sledgehammer on your profile has the same outline on my pc, but I did my icons all the same as vanilla
but vanilla icons don't have that issue
ok. thanks. I would like to let people know about https://steamcommunity.com/sharedfiles/filedetails/?id=2943454443
its simple (my first), but I would to learn more and become able do make more.
looks good. I'd have to actually play with it to evaluate how effective it is.
A note on Brita's from the comments: Brita overrides the vanilla weapons with its own. The 9mm pistol becomes the "Taurus 9mm" and etc.
also, a question: how do I make the poster/preview image to appear in the right hand side of the mod page @ Workshop? for me the poster appear only in the same place images/videos appear.
It is showing the preview.png you uploaded with workshop.txt. If you want it to move, you need to upload another image, video, etc. on the right-hand side.
I usually have my preview images in the mod folder itself uploaded (for bigger resolution than 256x256)
I see. yes, maybe I choose the wrong words to describe what Britas do with vanilla firearms (I said it "removes" them, but maybe it just replace them).
my workshop.txt has:
version=1
id=2943454443
title=(VTF) Firearms
description=PREFACE (and all the next description lines)
should I put a line for the image there, like in the info.mod?
okay i got it to work without any RNG added yet. anything i can improve here before continuing?
no no, you need to upload to the mod page itself, on the Steam Workshop. I'll show you
Yours will be empty
looks good. Your syntax highlighting is missing "and" and "not" for some reason, I would have them highlighted for QoL
That is preview.png, in the same folder as workshop.txt
i see. i noticed that too but paid no mind
im using Visual Studio
can i change it myself to highlight that?
ye, I have VSCode for Git commits but everything I write is in Notepad++ basically (because ez and there's no Lua IDE to use unfortunately)
tbh, idk how, but it can be done
also, i kinda just copied the immune trait info but i wanna simplify it to just give the trait on the first instance so the second function can do the immunity part
yes; but for me it appears in the center (as other images/videos), not in the right-hand side:
can i just remove a bunch of stuff there or does it only work because i made it the same way i made the trait work originally?
that is because you have no images uploaded. Upload any image, or even the same one, and it will move
ok! thx! 🙂
Hello there. Modder new to the this server (wasn't aware of it's existence lol). The name in discord is the same as steam so let me know if I can help you with anything. I'm relatively new to this but hey, we're all learning 🤩🤝👍
and i want to make it only work when the player is bitten, rather than from any form of infection, since most ppl would just assume they got lucky if they werent infected from a scratch, for example
would this work in terms of simplifying, and using the bite thing albion showed earlier
for overwriting other mods: if you only want to add onto it, rename the file to a different name so it does not overwrite the original file, and only include your new code
If you want to completely replace it, you name the file the exact same so the game replaces the original with yours
this is my own mod, so i am rewriting it
ah I see
I think the way you have split discoverImmunity and removeInfection is fine
welcome 🙂
local function discoverImmunity(player)
local playerBody = player:getBodyDamage()
if playerBody:getNumPartsBitten() > 0 and not player:getModData().tested then
player:getTraits():add("Immune")
player:getModData().tested = true
else
player:getModData().tested = true
end
end
would this help to make it so they only get tested once for immunity (after i add rng)? so if they fail the immunity test it will make them not do this function anymore?
hmmm depends. when is discoverImmunity called? I would put it into the event that triggers every time the player gets hurt
you could set a global variable outside of the function to control it only happening once
OnPlayerUpdate
OnPlayerUpdate is wayyyyyyyy too often 😂, choose another one
like several times a second too often
ill look at the lua events, brb
it's just carryover from the immunity trait
Did you end up getting an answer? I can check rq if not, saw the message earlier but was too busy to respond
Update: checked. The translations are derived with "Sandbox_" + valueTranslation + "_option" + index, so if you have a value of "MyOptValues" for your valueTranslation and 3 values, you'd be expected to have translations for Sandbox_MyOptValues_option1, + two more with the same prefix but ...option2 and ...option3
i was thinking i can do every couple hours so they have to wait to find out if they are immune or not
i know about EveryTenMinutes but im not sure what the other ones were
i also managed to make the bitten trait add a bandage on their body on spawn instead of putting it in their inventory
isnt there a 1 min event?
You could do EveryTenMinutes but it doesn't have the playerObj as a parameter, you'd need to pull it from outside (if you want MP compatibility that is)
i wouldnt want it to happen every minute, they would know too quickly that they are immune
i'll probably add sandbox options further in the future
anyway, here's how I'd do it:
UniqueImmunityBooleanNameOrSomethingBecauseGlobal = false
local function myEventFunction()
-- do the check
UniqueImmunityBooleanNameOrSomethingBecauseGlobal = true
--Events.EveryHours.Remove(myEventFunction)
-- don't actually need the above, you'd need to figure it out how to make this trigger every time a player gets bitten. if you want, that is
end
Events.EveryHours.Add(myEventFunction)
for randomness, you could do local immunePercent = ZombRandFloat(1.0) and this should give a float iirc (percentage decimal form)
o also it is intended for multiplayer. do i just need to add that in the function parameters? or completely change how it works
for the percentage, that is, not the actual isImmune or not
i see. would 1.0 mean 1% chance?
you would need to isolate the server and client, so that the server knows which player is doing what. Could be easy, could be hard depending on how you do it
1.0 as in 100%, 0.01 is 1%
ah...
you need to do
for i=0,3 do
local player = getSpecificPlayer(i)
if player then
-- your code
end
end
```if you want to run code on client players without having it passed from somewhere
ooo this is good
alternatively just local player = getPlayer() but i don't really think it's that much more work to support splitscreen
i see
but that is percentages. if you want to actually determine if they are immune, a simple binary ZombRand(2) will give either 0 or 1
but that's with nothing influencing it
other than pseudo-random code >:)
ah
can i put local player = getSpecificPlayer(i) for my other stuff too like the bitten trait?
I think ZombRand(1.0) would behave equivalently to ZombRand(1), since (I believe) the implementation of Lua the game uses does not differentiate between integers and doubles
There exists a function called ZombRandFloat, though
ZombRand(1) = 0 always btw
ah shit
man...
2 it is 😂
There's also a ZombRand for floats iirc - the normal math.random stuff is locked out
that's the function I meant
i understood 1 (0) of this then 😂
Oh Omar mentioned it
i will try my best
Is float ex/inclusive? It'd be 0 to 0.9999~?
the thought that it could be exclusive disturbs me
I haven't used it either, but the function accepts a minimum and maximum
your percentages will always be a little bit off what you think it's going to be...
zombrand is - so I'd think it would follow it's own conventions
if i have (player) up here, will my local definition of player work?
it'll override whatever was passed to it
Yes, but it will shadow your parameter
and i doesn't seem to be defined so in this case it won't work
getSpecificPlayer takes a number 0-3 - the snippet i posted loops through all four and runs the code if there is a player in that slot, so that the mod behaves properly in splitscreen
if you don't care about splitscreen you can just use getPlayer() and forget about looping, but it's really not that much extra work
you need to remove player from discoverImmunity(player), with the event you're using it won't have that param
I don't suppose there's an onHit event for players?
not in the base game, probably in a mod library
I know there's a hook for it
removed
yeah, though keep in mind it's not *just* when the player gets hit, and it gets called a LOT
There's OnWeaponHitCharacter, which may or may not be exclusive to weapons (I don't think it is)
But that also fires for explosives iirc & is not exclusive to players
Yes, this reference to infection appears to be the zombie infection
so for 1% chance i would use ZombRandFloat?
yeah, normal infections don't deal damage so that's not a worry
I believe, player's infection value is zombie - indiv bodyparts' is normal infections
wish that'd be renamed lmao
(they actually do very little LOL)
ZombRand(100) -> [0, 99], so you could also use that and check for 0 (or any other integer in the range, I suppose)
okay
Looking over it - that event with the "INFECTION" ID is specific to zombie infection
what I see the sandbox option is in java SandboxOptions.instance.Lore.Mortality and there's BodyDamage getInfectionMortalityDuration to get the duration
approximate commands
local percent = (getCurrentTimeForInfection - getInfectionTime ) / getInfectionMortalityDuration
percent = math.min(1,percent)
setInfectionLevel(percent * 100)
I checked on this and OnWeaponHitCharacter corresponds to "WEAPONHIT" in that event
far as I understood it there is no body part for Z infection its the player.
Correct
bodyDamage is the object that houses alot of those values
if I recall correctly BodyDamage houses BodyParts which houses the indiv parts
isnt Z just a 0 - 100 scale?
Yes?
well I thought so as well but someone was saying apparently scalar isnt limited to that range in PZ so dunno honestly. myself right now trying to find a way to elim/limit jumpscare
btw does jumpscare happen in MP with(out) odd issues like ppl shouldnt be but get it?
public float InfectionMortalityDuration
It's a float - so I guess you could set it to 9999
but the game won't care as it's looking for >=100 = dead/dying
also for the mortality sandbox thing, if it's instant you lose 110 HP - max is usually 100
why do you need to set it? for remove it maybe set to -1
-1 is correct
var5 = (var15 - this.InfectionTime) / this.InfectionMortalityDuration;
var5 = Math.min(var5, 1.0F);
this.setInfectionLevel(var5 * 100.0F);
uhhh... trying to queue ISUninstallVehiclePart made my game freeze 
maybe % in numeric?
The game actually *100's the infection level
I assume it handles how much HP is lost per tick
is there anything problematic with this code? I am currently putting breakpoints & print statements to debug it:
if vehicleArgs["WeightReduction"] then
local vehiclePartList = {
"M998DoorFrontLeftArmor",
"M998DoorFrontRightArmor",
"M998DoorRearLeftArmor",
"M998DoorRearRightArmor",
"WindowFrontLeft",
"WindowFrontRight",
"WindowRearLeft",
"WindowRearRight",
"DoorFrontLeft",
"DoorFrontRight",
"DoorRearLeft",
"DoorRearRight",
"TrunkDoor",
"M998BackCover",
}
ISVehicleMechanics.cheat = true
for _, partName in pairs(vehiclePartList) do
local part = vehicle:getPartById(partName)
if part then
print("[LUVDEBUG] part "..partName.." was found")
ISTimedActionQueue.add(ISUninstallVehiclePart:new(player, part, 1))
end
end
if vehicleArgs["vehicleType"] == "Base.92amgeneralM998" then
local trunkBarrier = vehicle:getPartById("M998TrunkBarrier")
if trunkBarrier:getItemType():contains("Base.M998TrunkBarrier1_Item") then
print("[LUVDEBUG] this M998 has a metal trunk barrier")
-- change trunk barrier "M998TrunkBarrier"
end
end
ISVehicleMechanics.cheat = false
end
player is defined above this block
well isnt the parts list missing stuff??
I mean syntax wise looks good I think other then the spacing/tabs
this code is meant to remove certain parts, such as the doors and trunk from a Humvee
yeah i kept the # of tabs from my file
yeah it dawned on me just now. but thats all seemed off was the indenting thought ya missed an END for a sec.
ohhhhh shit I am checking vehicle, not the vehicle part I listed in the bottom lol
not that my code is getting to that statement though, because it keeps freezing
manually try the ISTimed line if possible?
ISVehicleMechanics.cheat = false try without it this as well
ah ok
good news is that my list is fine, thank God
try it now with the cheat line
yeye
i need to first check that ISUninstallVehiclePart actually works
or is at least handled correctly
thats after that one line, if that line is the cause it wont matter. (sorry just took a hit)
okay turn that back on and comment out the timed action.... 1 sec looking up the option in debug
i just want to remove parts from a vehicle ffs, why do I have to do it through a player?
setCondition() doesn't actually remove it
no that just sets if its good or wrecked... and inbetween
atleast thats what it 'says' it should be doing
this might help ya get some log info... debug.options.checks.slowLuaEvents
as for a player well thats because you are removing it. Im betting there no such thing as actual removal of parts from the car, just if they hide it or not. (and add an equal part in one's inventory when removing it...)
is this the function I want to use, or the function to look at?
ill try it anyways
...calling that didn't work, and also made some of my code not do anything :/
idk whats going on, might just leave this crap for later and push my update as it is
ISVehicleMechanics.cheat = false is not the issue though
its the action
yeah I see the same code in the UI stuff so yeah not that... I'd have to look up the code in ISUninstall....
even try using nil instead of player?
I mean the code gotta be there for flat out removing/hiding the parts so... now if its exposed... thats another story
i have no clue if that'll pass, will check code
why I said just try... cant get any worse other then throw an actual error now
no, it requires playerObj, with or without cheat enabled
so wont do nothing or blows up with a nil object
might even help if it throws an error then you can find exactly where/what it doing too possibly
I mean to me there should be a method to hide/remove the parts without the player API wise if there isnt then I'd say needs to be added
the player is needed for the 'canUninstallPart' portion
function VehicleUtils.UninstallPart(part, chr)
local item = part:getInventoryItem();
-- VehicleUtils.lowerUninstalledItemCondition(part, item, chr:getPerkLevel(Perks.Mechanics), chr);
local keyvalues = part:getTable("uninstall");
local perks = keyvalues.skills;
local success, failure = VehicleUtils.calculateInstallationSuccess(perks, chr);
local fail = false;
if ISVehicleMechanics.cheat then success = 100; failure = 0; end
if ZombRand(100) < success then
chr:addMechanicsItem(part:getInventoryItem():getID() .. part:getVehicle():getMechanicalID() .. "0", part, getGameTime():getCalender():getTimeInMillis());
local content = part:getContainerContentAmount();
part:setInventoryItem(nil);
chr:getInventory():AddItem(item);
item:setItemCapacity(content);
if keyvalues and keyvalues.complete then
VehicleUtils.callLua(keyvalues.complete, part:getVehicle(), part, item);
end
elseif ZombRand(100) < failure and part:getCondition() > 1 then
part:setCondition(part:getCondition() - ZombRand(5,10));
chr:playSound("PZ_MetalSnap", false);
fail = true;
else
fail = true;
end
local ui = getPlayerMechanicsUI(0);
if ui and ui:isReallyVisible() then
if fail then ui:startFlashRed();
else ui:startFlashGreen(); end
end
end
You should be able to pick-out what you need for a playerless uninstall
alot of lua -> java -> lua going on
shrugs no clue there should be a playerless method and I like J learned that for MC modding
ofcourse
unfortunately this probably comes down to the fact devs are developing a game and not an engine - so unless they need it or someone asks it probably doesn't exist 😅
why I said should be part of the API side if not needs to be added
although having less rigid methods would help scalability down the line for everyone
Looking at the snippet I found - I don't even think that's where part removal exsists 🤔
yeah Im betting its not exposed at all
unless it's calling 'uninstall.complete' from the script
yeah, why they didn't already make a method for this I have no idea
prob exactly as you said why.. I mean what CF said relating to developing a game not engine..
MC never had an API... lol. it took 3rd parties to make it.
the only line I need from here is the setInventoryItem() I think. Thank you
can you construct java objects in Kahlua? I want to create a new InventoryItem as InventoryItem(String module, String name, String type, Item item)
🧠


