#mod_development
1 messages ยท Page 162 of 1
I'm not too familiar with modeling, but I believe you can
hm
Can you share the item script?
sure
module Base
{
item Kurki
{
MaxRange = 1.23,
WeaponSprite = Kurki,
MinAngle = 0.7,
Type = Weapon,
SwingSound = MacheteSwing,
HitFloorSound = MacheteHit,
ImpactSound = MacheteHit,
DoorHitSound = MacheteHit,
HitSound = MacheteHit,
MinimumSwingTime = 4,
KnockBackOnNoDeath = FALSE,
SwingAmountBeforeImpact = 0.02,
Categories = LongBlade,
ConditionLowerChanceOneIn = 25,
Weight = 2,
SplatNumber = 2,
PushBackMod = 0.3,
SubCategory = Swinging,
ConditionMax = 13,
MaxHitCount = 2,
DoorDamage = 10,
SwingAnim = Bat,
DisplayName = Kurki,
MinRange = 0.61,
SwingTime = 4,
KnockdownMod = 2,
SplatBloodOnNoDeath = TRUE,
Icon = Dudclub,
TreeDamage = 10,
CriticalChance = 20,
CritDmgMultiplier = 5,
MinDamage = 2,
MaxDamage = 3,
BaseSpeed = 1,
WeaponLength = 0.3,
DamageCategory = Slash,
DamageMakeHole = TRUE,
AttachmentType = BigBlade,
Tags = CutPlant,
DoorHitSound = MacheteHit,
HitSound = MacheteHit,
HitFloorSound = MacheteHit,
BreakSound = MacheteBreak,
SwingSound = MacheteSwing,
}
model Kurki
{
mesh = weapons/1handed/Kurki,
attachment world
{
offset = 0.0000 -0.1660 0.0070,
rotate = -180.0000 0.0000 0.0000,
}
}
}
Where is this file located within your mod?
my other items work fine
so that cnat be the issue
but
/media/scripts
Is it in a file with other items, or is that the entire file?
the entire fiel
Have you checked console.txt to see whether it says anything about it?
I'm not too sure what could be the issue. Can you send console.txt so I can double check?
I'm not seeing anything too weird aside from maybe 8x_scope_ru is not a valid parameter in item: 4x_scope_ru. I doubt it'd be stopping this script from loading
Hopefully someone with more experience with items can help you out. My only recommendation is to try excluding some of the values (that is, x = y, value pairs) specified in the item to see whether one of them is preventing it from showing up somehow
ok
did you find a solution?
playSoundImpl() -- will only play locally
other playSound methods automatically transmit to other players, look for those with Impl if you want control on who hears it
What kind of coding knowledge is required to make and edit pz mods?
Lua, primarily. You also need knowledge of the game's API, the functions it provides for modders
For items, PZ has its own language, sometimes referred to as "ZedScript" (name not official yet)
Worth noting: PZ uses Kahlua, which is close to Lua 5.1 but not always exactly the same. Nonetheless, if you want to learn Lua independently of PZ before delving into modding it'd be best to consume information about Lua 5.1
WorldFlares.launchFlare will other players on MP see worldflares on their client if this is triggered by an item?
I didn't find a real solution yet.
It should be 3D sound for all players with the option enabled in mod options.
Make a networked command to send back a sound event to all players. Then when intercepted on the client you apply a check with the 'mod option'.
Client send command to server about playing a sound (at the same time it plays on it's client)
Server receive the command and send it back to all players.
All client receive the command from the server
Check if it's muted on the client option.
Play it with Impl so that it play on the client only.
I'll try. Thanks.
Hello guys I wanna ask a couple of modders smth
I wanna ask how can you add pictures in the game and you can open them as if you're reading a map for example like the mod "Undead Survivor" where you can look at a picture of a bounty hunter as if you're reading a map
like this here
Hi, I tried to use an apng for my workshop preview.png and only the first image is visible. Do you have any idea how I should achieve it ?
you add your picture in your MODNAME/whatever folder (e.g. MODNAME/media/ui/MyPic.png) and then from lua you call local mytexture = getTexture('media/ui/MyPic.png'); this will give you a java Texture object
can i message you privately tchernobill?
i don't think apng is supported on workshop
Did the devs change the BodyLocations recently? So that setHideModel doesn't work on group:getOrCreateLocation("Back")? Cause apparenty, it does not work anymore ๐ฆ
Hey y'all. I just released a set of extracted data from the official JavaDocs as YAML files.
https://github.com/asledgehammer/PZDocs-Yaml
I'll be working on applying this to other tools now.
yeah but gif is refused at upload time and this guy (see link below) has a solution. so I'd like to know how to do that if anyone knows and is here to tell :). https://steamcommunity.com/sharedfiles/filedetails/?id=2773411311
there has not been an update this year
Mhhhh odd
My old version of the tmog mod, had the ability to had backpacks, and now a year later same code, and the backpack is there
alot of mods change those
and it's probably the least mod compatible thing in the lua
messed up bodylocations is what breaks tooltips often
What do you mean by messed up body locations ?
e.g. I thought we could add any new body location. Am I wrong ?
the mod UndoMaskExclusion would be a good example
the issue is you have to overwrite the file to make it work
but if you include old locations or invalid ones
if 2 mods touch the file - you could have items pointing to locations that don't exsist
I kind of go down a rabbit hole tracking down the tooltip breaking
cause it won't say 'hey you have a scuffed up bodylocation' and instead reports anything that touches tooltips are the root of the error
which 3-4 of my mods do
So is it the BodyLocation exclusivity system modding that is fragile?
afaik you have to list them in order for layering to work properly
and you can add to the list but not remove or insert before/after
so people just replace the entire thing
did the idea of reading bodylocations to lua, resetting them and then recreating them with your stuff in the middle go anywhere?
no, I think there's other stuff going on that makes it not really possible
it would require an API that people all use
it's the setexclusives
I think I added this a while back to community projects as an issue to work on
Anybody know if it's possible to check if an object is attached to the Player's belt or other similar slots? (Like modded ones)
InventoryItem:getAttachedSlot(), getAttachedSlotType()
Thank you! I actually just found it, was about to test
Do you know what gets returned if the item is not attached to anything?
seems like slot = -1 slotType = nil
Thanks a lot!
โค๏ธ
alright time to try to figure out why my ground models arent working... again
Does anyone know of a good resource that specifically lists the Java functions that lua has access to?
I'm getting the impression that they don't all work, but that could also be my own inexperience.
private methods can't be called and some classes that are on the reference site aren't actually exposed
and in some very specific cases classes are only partially exposed
Yeah, that was my concern. Is the reference site the large white one with the search bar?
https://projectzomboid.com/modding/zombie/inventory/ <--this one?
yup!
Damn, haha. I'm afraid my code doesn't work for two reasons now ๐
More precisely, I get anxiety trying new stuff. Gonna just have to grit my teeth and reset lua ad nauseum.
it's not quite as easy to explore but candle lists only exposed + public methods https://github.com/asledgehammer/Candle
Every time, Albion. You come through
so does this look right?
oh boi
I had a suspicion they must've had some pre-production npc ai code
@autumn temple File paths look weird to me.
you can decompile most PZ java code and see by yourself. https://steamcommunity.com/sharedfiles/filedetails/?id=2748451514
npcs have been in much older versions of the game
@mellow frigate That I can already do, but the issue remains that some are declared as public but... aren't actually.
well for some reason this doesnt work
@autumn temple Nearly every mod I've seen with custom models uses WorldItems for textures and meshes in different folders. It may not matter, but that could be the issue.
the exposed classes are described in LuaManager.java
@mellow frigate ...by jove... I didn't even realize.
ya that is my trying to get the mesh, thats what isnt working.
has someone already tried to call setExposed from lua ? ๐
my mesh is in static/axe
like making the actual weapon works perfectly fine having it in weapons/axe
You may find better help in the modeling channel.
I dont feel like that is appropriate since this is the code end not modeling
even if it's accessible you'd need the class object as an argument
yes we need someone to rebuild luaManager with all PZ classes exposed ๐ like Bibi did for Zoom level https://steamcommunity.com/sharedfiles/filedetails/?id=2895974075
like the ground model doesnt work period, it just applies the weapon model without the scale.
the capitalisation in the script doesn't match the actual filepath
that didnt matter for the weapon model though 
I will change it to see just incase
like this is the weapon model, with the caps
i can't remember if they resolved it but that used to cause nonstop issues for linux users so it's probably best to try and keep things consistent anyway
i have a feeling they did something to mitigate that but i don't really remember
no closing bracket in the screenshot you sent, is it out of frame or missing?
ya cuz its in the middle of a big line of models
but in this picture I isolated it to its own text file
i mean the closing bracket for that specific model block
oh i didn't see that, looks fine
things arent fine 
Hello, Im trying to do a True Music extension and when I went to upload it to the workshop I got this error
I tried finding solutions myself but there is little to no info about this error
I tried everything I could and had no luck
list_Gasmasks = {
"HazmatSuit" ,
"Hat_GasMask",
"Hat_NBCmask",
"Hat_GasMask_Improvised",
"HCImprovisedgasmask",
"HCImprovisedhazmat",
"RogueMask",
"Mask_HECU",
"Hat_Rebreather",
"Hat_SwatGasMask",
"Hat_MCU_GasMask",
"Hat_M45_GasMask",
"Hat_FM53",
"Hat_M50",
"Hhunk",
"Mhunk2",
-- "Mhunk3",
"Hat_PoliceM17",
"Hat_M17",
"Hat_M40",
"Hat_M17Doff",
"Hat_M40Doff",
"StalkerMask",
"MysteriousHazmat",
"m45gasmask",
"PrepperMask",
"Hat_MSA_Gas_Mask",
"GP5GasMask",
"Russian_Mask_GP5",
}```
function isGasMask(player)
local inventory = player:getInventory()
local it = inventory:getItems()
if player and inventory then
for i = 0, it:size()-1 do
local item = it:get(i)
if player:isEquippedClothing(item) then
if item:hasTag("GasMask") or item:hasTag("HazmatSuit") then return true end
local iType = item:getType()
local gas = iType:contains("Gas") or iType:contains("gas") or iType:contains("GAS") or nil
local mask = iType:contains("Mask") or iType:contains("mask") or iType:contains("MASK") or nil
local gasmask = (gas and mask) or nil
if iType:contains("HazmatSuit") then gasmask = true end
if gasmask then
if debug_Fog then
-- print("Protected From Fog")
end
return true
end
for i = 1, #list_Gasmasks do
if list_Gasmasks[i] == iType then
if debug_Fog then
-- print("Protected From Fog")
end
return true
end
end
end
end
end
return false
end
if i'm reading this correctly, then all I would need to do is add the tag "gasMask to an item in order for it to protect the player from this mod's toxic fog, right?
if item:hasTag("GasMask") or item:hasTag("HazmatSuit") then return true end
due to this line
maybe scale needs a tab to the right (formatting?) idk
What's the best event for when the player loads in? Like both from a fresh spawn, a loaded save, joining multiplayer, etc?
playerObj:getModData().mGuvCustomLootTable[item:getFullType()] = mGuvLootHighlighter.Rarity.Common.Name; -- this is just a string
print("length: ".. #playerObj:getModData().mGuvCustomLootTable);
Why does this print 0 D:
I guess arrays and tables are different?
# is only for ordered tables
Kahlua has table.isempty(t) if you just want to know if it's empty or not. If you want to loop, use for k,v in pairs(t) do --[[ ... ]] end
nah cuz the weapon itself uses the same formatting and works
I made a new tile animation they are supposed to be light source how do i turn them on so that they glow
Imean as they spawn
And hopefuly mp compat
Hello everyone, i'm implementing a lot of things in the mod Advanced_trajectory. I made it much more difficult to aim Zs. It's already handling every player mood that could influence precision, recoil is also implemented. And right now, i'm trying to make the mouse cursor handling the Z axis that i could get rid of any auto aim system. However, on top of that, i would like to make it fully compatible with ARSENAL 26's mighty work. Si if any of you see him around, let him know i'm trying to contact him, to discuss about all that. Many thanks
local LightSource = IsoLightSource.new(self.x, self.y, self.z, 0.61, 0.165, 0, 3)
-- add
getCell():addLamppost(LightSource)
-- remove
getCell():removeLamppost(LightSource)
Ye thats local
Need im looking for send command thats vanilla
Like when you switch on a light bulb or something
You probably need to get the players on the client and apply the same light localy based on some conditions.
instead of networking light on/off everytime the effect apply
can i re-use this code for muzzle flash plz ?
Theres a muzzle flash
Code wait ill give you
Also you can use that konijima posted
Thats vanilla
getPlayer():startMuzzleFlash()
here you go

found that one #mod_development message maybe a resize it is? and that one #mod_development message
ok so I figured out my issue and it is really god damn stupid
I didnt delete the mod files from the workshop folder, and they were overwriting any changes I tried to do with the files in my mod folder
so nothing was wrong to begin with it just refused to apply any of my changes because of my own stupidity
Is there a way to get a value of a field inherited from a superclass for debug purposes? example: bStarted of an LuaTimedActionNew
I made a field viewer for debug tools
but I think it doesn't have that capability yet
local numClassFields = getNumClassFields(obj)
for i = 0, numClassFields - 1 do
---@type Field
local javaField = getClassField(obj, i)
if javaField then
local value = javaField:get(obj)
local valueAsText = tostring(value)
I also need to work on making that sort the values
it's a nightmare to look for something
a filter would be nice
yeah meant to say filter, just woke up lol
that and the option to modify values are planned
Does anyone know if there's a way to check if a particular child of an ui element is a specific type?
nvm my test with .Type did actually work
For anyone who uses pzstudio i released an update with a more optimized watch process.
You can update using npm i -g pzstudio
How possible do y'all think it would be to get two-way radios to pick up stuff from True Music like the boom boxes and the like.
I'm admittedly a bit worried since if memory serves correctly a lot of the radio stuff is on Java, and I wouldn't be surprised if a lot of the audio stuff was too.
True Music is a mod, right? Have you taken a look at that?
probably annoying
True Music doesn't cooperate with radios to my knowledge, I want to see if I can get the radios to "pick up" nearby boom boxes so players can set up little music stations.
the biggest limitation is that a sound can't start halfway through
so it will be desynchronised in most cases
Is it possible to adjust the volume of a sound halfway through?
If so I know a workaround, otherwise pleh
And "two ways" are only chat based right? There's no ingame voip that Im aware of.
yeah, but do you really want to play every track on every station muted at all times?
it still wouldn't work for late joiners but that's not as huge
Hm..
I mean, it's something that could be interesting to tamper with either way I think.
You have to consider the resource cost. Are you willing to sacrifice performance for a desynced audio when you can literally just carry around a CD player?
Who would use a two way radio for playing music?
Apparently a lot of people in my server LOL
i've already got something similar about ready to release, the only part that differs that i wouldn't know about is actually getting the transmitter to understand that there is music playing
Project Zomboid Studio [Dev Thread]
Hm.. would it be possible to just hook a cassette player into a HAM radio or otherwise just add-on?
That way you can turn the music on/off easily, don't have to worry about distance calc for volume or some stuff like that, and it wouldn't be as expensive.
yeah, i guess that wouldn't differ too much from what i've been working on
I see
so i imagine that's possible
Cuz if someone can just hook a cassette system into a HAM or something and just get it to play directly, that solves a lot of problems.
i wonder how the client/server relationship would look for that
Then when you change frequencies or something it can just.. cut the music.
not sure if much of that can run from the server or not
and if it runs from the clients that brings complexity too
Nevermind ๐
Thank you, it doesn't show the values from a superclass though.
It seems I have no access to java getSuperclass method from lua. where can I find the PZ kahlua limitations ?
You can find information about Kahlua here:
https://github.com/krka/kahlua2/blob/master/docs/manual.txt
Class is not exposed, getSuperClass doesn't seem to be either.
There's also this but it's also not exposed:
https://projectzomboid.com/modding/zombie/util/Type.html#tryCastTo(I,java.lang.Class)
I thought maybe being able to use the field from a different object of the expected class, but I couldn't make a new BaseAction and stopped.
well, this is fun - finding out the number of lines in a mod.
maybe i'm in over my head on this one.
how much coding experience do you have?
i went above 1k lines in code this semester, for the first time lmao
for a project
also, what mod is that?
i can definitely imagine going to the 10k-20k lines for a full on mod in PZ
Superb Survivors!
https://steamcommunity.com/sharedfiles/filedetails/?id=1905148104
oh. yeah
that looks complex asf
there are much simpler mods you can make
esp if starting out
Thats the spirit
You can do this!
how do you handle a require for a .lua inside another folder?
Folder/lua
require paths aren't relative or anything
you sure?
As long as it's in the same main directory client/server/shared it doesn't matter, the require can be pointing to a folder behind or forward
For example:
test.lua
require "OptionScreens/MainScreen.lua" --.lua is optional
```Can exist sitting in the client folder.
Or it can exist in the `OptionScreens/extrastuff/` directory.
I was referring to something like this:
client/someOtherFolder/someFile.lua
you don't include the client bit afaik
with the client/shared/server folders there's some limitations on what you can require from where, not sure if it's based on load order or something
yeah I was just explaining what I was referring to
Yeah sorry, just sat down and didn't read enough context. ๐ my bad
afaik it goes back to the connections and host thing
if you use require "myFile" from shared and myFile is in server it will fail. But if you use that command OnTick event it will work.
hosts only run server/shared lua
clients run all 3
but certain events only run on the server
and some systems are on both but only used by clients
they need to just collapse the whole thing
it's from the old MP
A good example is my shops - I have it so the type for items is saved as a string, but you can also sell by category - which is also saved as the untranslated version.
BetterSorting's ItemTweaker is client/ so it breaks my shops code lol
Cause it tries to compare client scripts that have been changed to server's which have not.
how do I make the player walk to a location before my timed action
you would add an action to walk there
if luautils.walkAdj(player, metalDrum:getSquare()) then
ISTimedActionQueue.add(ISPutOutFireDrum:new(player, metalDrum))
end
luautils.walkAdj does that for you if i recall
function luautils.walkAdj(playerObj, square, keepActions)
if not keepActions then
ISTimedActionQueue.clear(playerObj);
end
-- if not AdjacentFreeTileFinder.isTileOrAdjacent(playerObj:getCurrentSquare(), square) then
-- Avoid walking to already near spot
square = luautils.getCorrectSquareForWall(playerObj, square);
local diffX = math.abs(square:getX() + 0.5 - playerObj:getX());
local diffY = math.abs(square:getY() + 0.5 - playerObj:getY());
if diffX <= 1.6 and diffY <= 1.6 then
return true;
end
local adjacent = AdjacentFreeTileFinder.Find(square, playerObj);
if adjacent ~= nil then
ISTimedActionQueue.add(ISWalkToTimedAction:new(playerObj, adjacent));
return true;
else
return false;
end
-- else
-- return true;
-- end
end
thank you
exactly what I needed
follow up for anyone who searches this: there is a door specific function too: luautils.walkAdjWindowOrDoor
Hi, where should I look to disconnect a player or refuse a player's connection ?
getCore():quitToDesktop()
thers also one for main menu
i think you can find it on the main menu lua
@mellow frigate
Yeah sorry, I am looking for the server side handling of the connection request.
@ancient grail and thanx ๐
beginner modder here, how difficult would it be to have a roll/tuck-in feature similar to shark and peaches mod?
how do I force the player to stay in a timed action?
Prevent them from stopping it by preventing them to move maybe
This is just a guess tho
There might be some other ways
a timed action is not supposed to be enforced. you have to be able to quit at least with escape key. Maybe you are looking for something else than a timed action.
You might jave a bugged action if you prevent it from being cancelled?
I'm making an action where the player quickly grabs their foot in pain after failing to kick down a door, I don't want players to be able to cancel it
I don't think you can exit climbing through windows action
maybe there is something else other than a timed action idk
Enforced Animation are handles by java states objects.
That said, I did exactly that (enforce a timed action) in Prisonner mod, despite the fact timed actions are not made for this, because I found nothing better.
I have to warn you it was a nightmare.
Maybe an animation woudl be more suitable in your case
but I do not know much about those
ok, thank you
I might take a look at your mod then
or try out animations, only way I know how to play them right now is through timed actions
Such an impressive mod 
you can just hook isdoingactionthatcanbecancelled(? something like that)
We now have typings for EmmyLua that forwards the parameter names of the official JavaDocs.
im looking for an comission that is affordable that i can afford and is cheap for an brazillian like 30 reais i think , or 20 reais
Hey guys? What mod that make character talk like when they see zombies and characters talks?
looks really cool, how do I install it lol
@thin hornet can help. I'm just walking away from the computer.
He's also building an environment that installs it.
My apologies.
I'm sorry, this is my first time making a mod that mods another mod, if I require a mod to be installed, that goes in the mod.info right? is that all i have to do to make it a prereq?
mod.info
require=other-mod-id,other-mod-2
separate them with a , and use the mod id not the workshop id
thanks
also think of adding the required item in steam workshop
ah okay so there's a second step if i want the nice link to the required item on the mod's page?
that one is on steam
okay i think i'm good to go (ahead and fail making this mod lol)
thanks a bunch
Hmmm. So far, all my mods are on and no red errors
https://steamcommunity.com/sharedfiles/filedetails/?id=2978579731
I just released my OSRS Weapons mod for anyone interested
Congrats yoh
tyty
you're probably looking at https://steamcommunity.com/sharedfiles/filedetails/?id=2398253681
Honestly AI stuff should have a separate channel.
Spent 10 hours coding today on Candle and my PZ JavaDocs scraper projects.
Felt like bliss. Was a genuine high and the best to have.
Coding mods for PZ is getting easier for everyone each day. =]
Hello, Im trying to do a True Music extension and when I went to upload it to the workshop I got this error
I tried finding solutions myself but there is little to no info about this error
I tried it multiple times, also updating said mod is the same error: "result=2"
(The item IDs may wary because I took screenshot at different retries)
I followed this video: https://youtu.be/b7SUjPzmgfM
And the instructions on the mod page itself.
True Music: https://steamcommunity.com/sharedfiles/filedetails/?id=2613146550
We can develop mods thanks to your support at Pateron: https://www.patreon.com/_tsar
And ko-fi donations: https://ko-fi.com/tsarmods
Only Tsar's Fans are here: https://discord.gg/xkCEcwGZMW
also this is how it looks on my workshop page after like third retry (always trying to change something):
When I had this error, I just had to wait, and when trying again later it worked.
Thats weird.
Its a pity there is absolutely nothing about this error anywhere.
I found like two threads about it
Enigma suggests to google the error. https://theindiestone.com/forums/index.php?/topic/37047-unable-to-upload-new-mod-to-steam-workshop-failed-to-update-workshop-item-result2/
I'm unable to upload my new mod "Playable Arcade Machines Grapeseed" to the steam workshop. The error I get is "failed to update workshop item, result=2" The result in my workshop is an empty mod with no content. This is my 3rd mod. I've successfully uploaded my other two mods in the past. I even...
Yeah I saw this one
And did you update the mod or you re-uploaded it under a different ID?
It happened twice. Once for the initial upload and I do not remember. the other time for an existing, in that case I did not change the ID.
thats weird.
Well I have no idea how to fix it, Ill keep trying hopefully it works magically :D
wait 12 h
Please, can someone explain how to use ModData? and ?GlobalModData
Assuming ModData saves to disk, where can it be found?
Lastly, is there a limit to what data can be saved/loaded from ModData?
okay thanks :D
You can save only primary types, objects and functions are not persistent.
Player ModData would be in players.db for example.
is there a list of loot distributions somewhere?
I see... guess i'll need to experiment a few things and see what can work and not work.
thanks
You can find the defaults in game's Lua files. Distributions.lua, ProceduralDistributions.lua, Suburbs..., Vehicles...
Yo, sorry for the ping. I fixed it!
I realised that I have multiple steam accounts with family share on. So i just hopped on my alt and made the mod there
Its done!
can I cause a player to trip through lua?
fall: yes
pathfind: yes
visions: yes with drug mod
player:getStats():setTripping(true)
thanks lol
weird question: I saved a door in my timed action at the start, is there a way I can check if it still exists by the time perform is run?
if it is at a specific position, you can save the square x+y+z and recheck the square anytime
good point, I didn't think about that thank you
it is a late night, I can't sleep, yet I don't want to complete my mod ๐
take a break mate
I've taken too long of a break, stuff needs to get done
I've decided to make a few more changes and I'll chill out until next time
a number of timed actions check if an object is still in the world in isValid with this function
object:getObjectIndex() ~= -1
thank you mr
I need help with fixing a patch to the Ladders mod.
https://github.com/quarantin/zomboid-ladders/pull/24#issuecomment-1556118646
Maybe the best way to do this is by adding the object only for the time the player is climbing.
- to use object mod data, call
object:getModData(), this returns a normal lua table. to use global mod data use the ModData static,ModData.getOrCreate("key")is most commonly used - that returns a lua table too
there's a reference sheet made by mrbounty(?) to the ModData methods, i think it's linked on the wiki - object mod data saves along with the object, global mod data saves with the world, neither are human readable
- only standard types, no functions or objects
Anyone here who can modder that can handle tiles - i have a mod commission inquiry
@ancient grail
typo on the third line
mew instead of new
also local vehicle = destContainer:getVehiclePart():getVehicle() isn't going to play nice when the container isn't a vehicle because getVehiclePart will return nil
so i added a drink (pretty much a beer reskin) but im having an issue with the spawning. i tried adding it to the procedural tables of proceduraldistributions.lua but now nothing spawns ingame (i would like to send the code but dunno how u guys do it)
3 of those -> ` followed by lua then paste your code inside
ProceduralDistributions = {};
ProceduralDistributions.list = {
BakeryKitchenFridge = {
rolls = 1,
items = {
"BibliSCC.ScreamerCreamer", 10,
},
},
}
--
-- all = clothingStores;
--
-- clothesstore = clothingStores;
--table.insert(ProceduralDistributions.list, distributionTable);
--for mod compat:
--ProceduralDistributions = distributionTable;```
dang it
close it with three more after the code
yep got it now i think
you're redefining the entire ProceduralDistributions table
ahhhh
do i have to change ProceduralDistributions.list to BibliSCC.ProceduralDistributions.list ?
you can either table.insert your items into the vanilla one or do it like this but with a different name and then table.insert it into whatever the table for distribution merge is (not at my pc right now)
hm okay i will probably do it the first way thx for da help
This is looking alot more worthwhile https://github.com/Project-Zomboid-Community-Modding/pz-community-modding/issues/43
Assuming you know enough about distros to point to intended adresses:
function addItemToDistro(distroAddress, itemType, spawnChance)
table.insert(distroAddress, itemType)
table.insert(distroAddress, spawnChance)
end
In this case address is ProceduralDistributions.list.BakeryKitchenFridge.items
people usually spam table inserts for this purpose
i infact do not know enough bout distros but imma look it up now that u brought it up
table.insert(ProceduralDistributions.list, distributionTable);
ProceduralDistributions.list = {
BakeryKitchenFridge = {
rolls = 1,
items = {
"BibliSCC.ScreamerCreamer", 10,
},
},
this how i have it atm have not tried it out yet
Can we define more than one value for an item parameter? For example the ammo type a magazine can accept?
AmmoType = Base.Bullets9mm is the standard, is it possible to add another ammo type to this ?
probably not
some parameters do accept multiple (usually separated by semicolons) but the vast majority don't
as a rule i'd say if vanilla doesn't use it it doesn't exist
Roger that. Thanks a lot Albion ^^
Is there a way to tell what Occupation a character took from the IsoPlayer object?
player:getDescriptor():getProfession()
you can define multiple type of mags for a gun
Oh that's interesting.
it accepts them but you have to mess around with the inserting/ejection timed actions to make it so that it will give back the correct ammo
actually i just remembered you can define multiple types of ammo for a gun
Really? And how would you do that? I've tried defining multiples, separated with blank spaces, semicolons and colons but nothing worked. Then tried a table and the game literally freaked out
use "/"
thats it
AmmoType = Base.Baseball/Base.ElectronicsScrap/Base.UnusableMetal/Base.Basketball/Base.Bell/Base.CatToy/Base.ChessBlack/Base.ChessWhite/Base.Crayons/Base.DogChew/Base.GolfBall/Base.KnittingNeedles/Base.ScrapMetal/Base.SoccerBall/Base.ToyCar/Base.Stone/Base.SharpedStone/Base.Bricktoys/Base.Wire/```
thats for one of my shelved mods
Thanks a log Haram Gaming. Later tonight ill try and let you know. Gotta go now though IRL stuff. Thanks again!
good luck
so i am having trouble getting this recipe right, i put Destroy farming.BroccoliBagSeed/farming.CabbageBagSeed/farming.CarrotBagSeed/farming.PotatoBagSeed/farming.RedRadishBagSeed/farming.StrewberrieBagSeed/farming.TomatoBagSeed, but the broccoli seed packet doesn't work. i have like triple checked the spelling but i must be doing something wrong since no matter what i do the broccoli seed packet won't show up in the recipe
you are right, i wonder if that's the issue
might have thought Destroy was part of the item identifier
that sure did fix it, thanks!
it was looking for the Destroy farming module 
must... destroy... farming!
What's the event for a new player spawned, i.e. the first time they connect/make a new character? Is that the OnGameStart one? Or was it OnNewGame?
onnewgame
is there a way to detect if a door opens towards or away from a player?
Good question, do they all open in one direction? So you can compare player x/y vs that of the door?
honestly, no idea
do they all open in the same direction lol?
yes getVehiclePart() comparison with nil is the way
OnCreatePlayer. The others will not work when you create a new character in a server after dying
just tested this, this is not correct
I'm trying to unequip an item for my action and then re reequip it after, I found ISUnequipAction, but I'm wondering if it is safe to save the item before it is unequip, and then use that to re-equip. I know that some items (like the candle) switch themselves for a new item when unequip, how can I make sure I have the right one?
Hello,
i want use this method
projectzomboid.com/modding/zombie/network/ServerWorldDatabase.html#changeUsername(java.lang.String,java.lang.String)
method
changeUsername(java.lang.String,java.lang.String)
from
zombie.network.ServerWorldDatabase
public class ServerWorldDatabase
how i use this in console integrated ?
I tried
zombie.network.ServerWorldDatabase.changeUsername('cmt_gabriel', 'Kibal')
if its not exposed then you cant
And if it's inside a lua file?
same restrictions apply
so far only isValidUserName is exposed
so there's no way I could access it?
when a player death change the user name
i dont think username should be changed
you could change the player display name tho setDisplayName
but not sure if that do anything
hm ok thank you
If i want a recipe to output multiple things, do i make multiple Result: lines or if it all goes on the one line, what is the syntax for multiple outputs? like if i want a recipe to give an empty container back in addition to the main result
You have to make a OnCreate function that adds it
look into: ProjectZomboid\media\lua\server\recipecode.lua
desynced! anyone knows how i can fix it. my bayonet mod project replaces the shove animation with spear stab but on the other character its not showing it. but for the other its visible.. iahave no idea why
but its not 100% at the time that its desynced
so i just do the recipe as usual with one Result: line and then make a serverside lua to make a empty sack when i make that result?
yeah for example
--Open sealed bag of produce to get contents + empty sack.
function Recipe.OnCreate.OpenSackProduce(items, result, player)
result:setAge(items:get(0):getAge());
player:getInventory():AddItem("EmptySandbag");
end
recipe Open Sack of Apples
{
SackProduce_Apple,
Result:Apple=12,
OnCreate:Recipe.OnCreate.OpenSackProduce,
OnGiveXP:Recipe.OnGiveXP.None,
Sound:PutItemInBag,
Time:15.0,
AllowRottenItem:true,
}
thanks, that makes more sense now that i'm looking at it all together
I'm trying to play my animation in game but it's all fucked up, wrongs bones are moving (maybe in wrong way). I used the IK template, don't know if that made it difference. Any ideas?
might have just found my issue
fixed the first issue, but now only the upper body is animating, here is my XML
I added some lines from t he stop drop and roll mod and it works now
new XML
Is there a way to show a PNG file in-game? I tried the "Map" attribute of the item but it doesn't seem to work
Not without modding it in
If you mean opening a window to display it
anyone got experience with adding custom vehicle parts (especially template)
coming soon-ish probably maybe
It has been a long time but yeah
Im trying to add new parts to existing (if every) vehicles, so far i can create the template for the part, but not quite sure if there is a way to extend existing vehicle without "rewritting" the txt file
I tried that at some point with my vehicle tweaker api and it didn't go very well, but it could be more that I didn't understand it 100% back then
I'd say more people tried it by now but I never checked
by logic alone there must be a way to do it correctly though
the simplest way is to create your parts as a vehicle template and then use Load on the script object for the vehicle to add that template
That is exactly what Vehicle Tweaker AP does, I just probably missed something in the case of part templates. I remember the slot showed up for the vehicles in game, but it was not possible to install or uninstall parts correctly
i worked with it at length and everything seemed to work properly
Good to know it can and has been done
@bronze yoke @nimble spoke you have a public repo with example ?
Edit based on @bronze yoke response:
--- file: shared/my-mod/vehicle-part-loader.lua
local scriptManager = getScriptManager()
local vehicleScripts = scriptManager:getAllVehicleScripts()
local partTemplates = {
"SomeNewPart",
}
for i=0, vehicleScripts:size()-1 do
---@type VehicleScript
local vehicleScript = vehicleScripts:get(i)
local name = vehicleScript:getName()
for _, template in ipairs(partTemplates) do
print("Adding '" .. template .. "' to '" .. name .. "'")
vehicleScript:Load(name, "{template=" .. template .. ",}")
end
end
This works, just need to figure a bug when right clicking the item in the UI
ScriptManager.instance:getVehicle("CarNormal"):Load("CarNormal", "{template=CarNormal_Upgrades,}")
oh damn
what is the difference between the Mods and WorkshopItems field in the server.ini? Why do I need to fill out both when adding a workshop item?
workshopitems tells the server what steam workshop items to download, mods tells the game which mods that it has downloaded to activate
interesting... why would you want the server to download workshop items but not have them active as mods
multiple sub-mods can be present in the workshop content folder
one workshop item often has multiple mods in it, usually for optional content
sometimes the options are even mutually exclusive
gotcha that make sense
Cool
Spiffy. Aside from Korea I donโt recognize any of the flags lol can you educate me
Spotted
Left to right, excluding the flag of South Korea: Yugoslavia, Rhodesia, South Vietnam, East Germany. All but Rhodesia are former countries (Rhodesia was not a country)
if you ever have the time can i usggest you should also work on Greek outfits too? like hellish army if you're open to suggesting
greek lizard is in ye
aswell as turkish aegean
from left to right
yugoslavia - M-87 oakleaf
south korea - turtleshell
rhodesia - brushstroke
south vietnam - tigerstripe
east germany - blumentarn
2nd showcase image
Finally got the chance to look at this! Thank you for looking for this! Lots of this stuff I didn't see in the documentation. Last thing i'd want to ask you-- why not make it global? how would other modders be able to use this in that case?
local zedList = getCell():getZombieList()
Can I cache this and will it have all the Zombies on the server? Any cases where it would not work?
Host Client GameTime instance has default start dates 
Helpful, thanks
If you return a value from a file, then others can require your file to use it. Rather than declaring a global table, you'd just return one. It doesn't matter much & the common convention among modders is to do what you've doneโI just try not to pollute the global scope where possible (at first I declared a global and returned it, but I decided against that too)
TraitTags.lua:
local module = {}
function module.add(x, y)
-- ...
end
-- ...
return module
elsewhere: local TraitTags = require 'TraitTags'
<animNode>
<m_Name>1HDefault</m_Name>
<m_AnimName>Bob_Attack1Hand01_Hit</m_AnimName>
<m_Priority>4</m_Priority>
<m_deferredBoneAxis>Y</m_deferredBoneAxis>
<m_Looped>false</m_Looped>
<m_EarlyTransitionOut>true</m_EarlyTransitionOut>
<m_SpeedScale>CombatSpeed</m_SpeedScale>
<m_BlendTime>0.15</m_BlendTime>
<m_BlendOutTime>0.25</m_BlendOutTime>
<m_Scalar>AttackVariationX</m_Scalar>
<m_Scalar2>AttackVariationY</m_Scalar2>
...
what does speed scale do in this context ? i tried changing it to high numbers and so on but seemingly no change ingame
it is a gain on the speed of the animation. if you change the variable CombatSpeed, it should have an effect. player:setVariable("CombatSpeed",player:calculateCombatSpeed()*speedRatio)
Anyone knows how is supposed to be created CGlobalObjectSystem.instance ? Alternatively Is there any mod that implements successfuly a new GlobalObjectSystem ?
client/Farming/CFarmingSystem.lua implements it I believe
true, search for derives
CGlobalObjectSystem:derive("...")
The instance is made by the main system btw on the global object init event. Sorry typing on mobile.
thx
would i have the same effect if i just replaced combatspeed with a number or do i have to change the combatspeed variable?
I think Snow is Water does that
im not sure but is it impossible to edit xml files through modding ? (i want to edit 2HDefault.xml in media/AnimSets/player/melee/2handed)
nvm im dumb forgot to activate it
Guys i need a little favour
I need to know the letter font for this
Im making a goofy mod for some friends and i dont know what font does the bat uses
all I can tell you is it's a sans-serif font
which is basically all modern fonts outside of book print, so uh... good luck!
Has anyone made a mod, or found the data for lowering the hunger times?
I believe that peckish and the likes start appearing at 80 or so?
I'd like to be able to have 50 be your nutruel state, below that is peckish, hungry etc, and above 50 up to stuffed.
in debug mode does the generate loot UI just... not work?
wdym? it works fine for me
whenever I run it I get a break as if it errored and nothing appears in the UI
no actual error beyond that
oh, i was thinking of lootzed - never looked too much at this menu before
it must be old or something, it calls the itempicker with the wrong arguments
probably tool that TIS didn't update to B41 then
you mentioned lootzed: is this a tool that'll help testing of spawns ingame?
yeah, it's in the cheats menu
it lets you reroll spawns in a container
and it shows the spawn chances for that container too
Could someone help me figure out what is causing my mod to spam the server console with this. as far as I can tell nothing is breaking in game. ```LOG : General , 1684718687635> 321,434,541> -----------------------------------------
STACK TRACE
function: dakiBuffEffect -- file: dakiActions.lua line # 39 | MOD: Big Degen's Dakimakura Emporium
ERROR: General , 1684718687635> 321,434,542> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: attempted index: getDescriptor of non-table: null at KahluaThread.tableget line:1689.
ERROR: General , 1684718687635> 321,434,542> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: attempted index: getDescriptor 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.GameTime.update(GameTime.java:671)
at zombie.gameStates.IngameState.UpdateStuff(IngameState.java:566)
at zombie.gameStates.IngameState.updateInternal(IngameState.java:1623)
at zombie.gameStates.IngameState.update(IngameState.java:1333)
at zombie.network.GameServer.main(GameServer.java:903)
LOG : General , 1684718687636> 321,434,542> -----------------------------------------
STACK TRACE
function: dakiBuffEffect -- file: dakiActions.lua line # 39 | MOD: Big Degen's Dakimakura Emporium
line 39 is just this if not player:getDescriptor():getProfession() == "Weeb" then return end
player is null
local item = nil
local player = getPlayer()
--just type the Profession on the "" and remove the -- on the left side of the line below
if not player:getDescriptor():getProfession() == "Weeb" then return end
-- just type the trait on the "" and remove the -- on the left side of the line below
--if not player:HasTrait("") then return end
--check if servers SleepAllowed is on
--[[if getServerOptions():getBoolean("SleepAllowed") then
-- somewhat counters sleepless traits effect by adding more fatigue but only uptil 0.8
if player and (player:HasTrait("NightOwl") or player:HasTrait("NeedsLessSleep") or player:HasTrait("Insomniac")) and player:getStats():getFatigue() <= 0.8 then
player:getStats():setFatigue(player:getStats():getFatigue() + 0.01)
end
-- same as above but without the limit
if player:HasTrait("NeedsMoreSleep") then
player:getStats():setFatigue(player:getStats():getFatigue() + 0.01)
end
end]]
--player:getModData()['BuffEffect'] = "daki not found" -- for testing
if player:getInventory():getFirstEvalRecurse(function(item)
return item:hasTag("DakiWeapon") or item:hasTag("DakiArmorFront") or item:hasTag("DakiArmorBack")
end) then
--player:getModData()['BuffEffect'] = "daki found" -- for testing
local bodyDamage = player:getBodyDamage()
local stats = player:getStats()
bodyDamage:setUnhappynessLevel(bodyDamage:getUnhappynessLevel() - (bodyDamage:getUnhappynessLevel() / 4))
if bodyDamage:getUnhappynessLevel() < 0 then
bodyDamage:setUnhappynessLevel(0);
end
if player:isAsleep() then
stats:setStress(stats:getStress() - (stats:getStress() / 4))
if stats:getStress() < 0 then
stats:setStress(0);
end
end
-- else player:getModData()['BuffEffect'] = "something might be wrong" -- for testing
end
--player:Say(player:getModData()['BuffEffect']) -- for testing
end
Events.EveryTenMinutes.Add(dakiBuffEffect)```
when is this function being called? seems to be being called before the player is created
that sounds about right. I'm not the one who made the code. It's supposed to look for players with the preffesion set and give them a buff when they have an item.
is the function attached to an event or something?
yes
my b that was wrong
the last bit was som,ething else
the one above was everything
It took me 2 hours,worth it
I edited the post above to show everything related to the fuction do you know how I can fix the spam?
hmm that seems odd, i wouldn't think everytenminutes fires before character creation
i would do "if not player then return end" after getPlayer but idk
Thats an impactful one.
is that not how I already have it? I don't really understand
the if not player is already after getplayer
You are just checking if the player doesnt have a description and not if the player exists
yea, idk. like I said i don't think this is actually breaking anything but it does cause a lot of spam. I have one person saying they are getting fatigue related issues but I haven't experienced anything myself.
ok so how should it be changed exactly?
if not (player and player:getDescriptor():getProfession == "Weeb") then
return
end
and this goes where line 39 was?
Solve problems with dialogue xD
Pretty sure it does
alright. I will try that. thanks for the help. ๐
Rookie question: Is there a "spawn on the ground" equivalent of the function player:getInventory():AddItem ?
Thinking about making some tweaks to hydrocraft on our MP server and one of the things is getting items that are created from mining to spawn on the ground instead of inventory, but idk if that's even a function in PZ
Get the square and then addWorldInventoryItem there
What's the call to get the square? player:getposition() ? (I'm guessing here lol)
Depends on the square
For player it would be player:getSquare()
But itโll give you the exact square the player stands on
Well that makes the most sense to me since the player will always be standing in a square adjacent to the crafting station and it makes sense to drop at your feet there
Tyty
I finally did it lads!
https://steamcommunity.com/sharedfiles/filedetails/?id=2979375840
๐
ah this tool is exactly what I've wanted. Dunno how I've missed its existence.
well done. How do you capture PZ cursor and clicks in your videos ?
Thank you, and I use Screen2gif https://www.screentogif.com/
thx
can i edit bodydamage.java (ProjectZomboid/zombie/characters/BodyDamage/BodyDamage.java), for example add something like JustDrankBooze (JustTookBlaBla), with a mod ?
You can do that with lua
so in the mod folder instead or rather addtitionally to the media folder i would just add the zombie/.../BodyDamage.java folder and it would override the original ?
or do i need a specific file and function to change the .java file ?
I am trying to import a mod, and change the weight of an item. However, it appears to keep the weight of the import from Base.
Any idea how I am able to override this?
would call JustDrankBooze from lua be enough ?
Change java code will require a lot of stuff and manual operations that are not supposed to be part of mods.
to give context i wanna make a stimulant that increases combatspeed, and right now adding a new moodle specifically for the effect seems the best way. and to add a moodle i would have to edit zombie.characters.Moodles...
other than that im stumped on how to change combatspeed
How many hours it take from no knowledge of lua to proficient PZ modding ability?
editing java through lua i dont know how, if thats possible enlighten me pls
I am thinking of learning as a new hobby
depends if u have prior coding knowledge
you can take exemple on https://steamcommunity.com/sharedfiles/filedetails/?id=2811855174 for manipulation of Combat Speed
Assume just CS50
you can use Moodle framework for modded moodles. https://steamcommunity.com/sharedfiles/filedetails/?id=2859296947
@mellow frigate ohh good stuff
@crimson sequoia im just starting out and as you can see, lookin at other mods is a big help
We use shareX its a steam app
Just need to make the game windowed
You can output multiple file types
@mellow frigate goddamn dude im lookin at fightmechanism and jeez thats allota code and its extremely underrated imo, it makes combat much more fun incredible work ngl
thanx mate, unfortunately it is correctly rated as it is unfinished.
still awesome G
That's amazing! Absolutely fantastic I love transmog systems congrats!
Thank you โค๏ธ
https://steamcommunity.com/sharedfiles/filedetails/?id=2979437947
Hey everyone I just uploaded my first armor mod. Hope y'all like it ๐
Looking great 
Sorry if this question has been beaten to death.
I was wondering if generator range was hard-coded?
I'm attempting to develop a mod that "overclocks" generators at a cost of more fuel. However I cannot seem to find the code that deals with that part.
Please @ me if you have any information.
Thank you.
generator range is hardcoded
Thank you Albion. I appreciate the quick response.
uhhh does
Events.LoadGridsquare
only load the square once
and we have to use
Events.ReuseGridsquare
if we want it to read the square again?
im thinking of doing animated tiles
any thoughts if it would work?
animated tiles was already done.
My experience with Events.LoadGridsquare is painful
since it will attempt to load things on ALL squares within a chunked space
Ive done it too but im trying to make an api
I have no idea how big the chunk is, but in a quick test, a function was called over 6,000 times with Events.LoadGridsquare
Ye im aware of this
But idont know any other alternative function
Should i just check stuff around the player
๐ค
theoretically, you can try Events.OnRenderTick because it's calling on every frame rendered.
but i'm unsure how often you're trying to render something
for a rough idea, my own experience with onRenderTick was anywhere between 40 - 100+ calls per second.
Ontick and onplayerupdate is fine
Id rather use player update if im going to result to using that instead of gridload
Or maybe the event that gets triggered when you switch rooms?
there's such an event for rooms?
@lone nest are you still working on Superb survivors?
In case you were considering
Not sure where the latest branch is
Also, @ancient grail Load grid square happens every time the square is loaded
So walking in and out of loading range
yessir thanks
also figured the issue with EHE, one of the context menu windows was messing with it
removing that context menu stopped breaking EHE.
Does anyone know where the code for adding new recipes when you reach a certain skill threshold is located?
To find this you should search for Events.LevelPerk.Add(...), but that's not a vanilla feature in v41, is it?
It is an event- as it is included in the fancy pants event def thing made by Albion
I don't think that is what I'm looking for, since it's the more general gain or loss of a skill. I'm looking for one which only fires if a specific skill pops off-
So search in that mod. If you want to find what a mod does, look at the mod. Most people will not be familiar with mods that are not their own.
Has anyone made a helicopter mod here before?
I dont know about anyone here but I do know some exist
i know it's been made
i should have worded it better
i'm trying to speak with someone who has made a helicopter mod
https://cdn.discordapp.com/attachments/1109807319828672583/1110516288922603570/image.png
https://cdn.discordapp.com/attachments/1109807319828672583/1109862920843710505/image.png
I'm making a backpack banners mod. Any requests for certain banner textures you'd like to see in game?
currently have
EGNH
LFG
Pirate flag
reuse fires before a square is unloaded
loadgridsquare fires every time the square loads
player:setVariable("CombatSpeed",player:calculateCombatspeed()*5)
``` @mellow frigate how did you find out that you can modifie combatspeed like this, like with player:..., were you able to deduce that from the source code of the game or did you just try out and see if it worked ?+
Can anyone tell me exactly how I'm being silly here?
My best guess is that I'm not accessing the value of the table i'm making correctly?
can you show sanitizeTags?
oh sorry
i was looking at the wrong line ๐
TraitTags[traitName] will be null unless you've defined it somewhere
table.insert(TraitTags, traitName) is adding a string "traitName" to the table, whereas i think what you're trying to do with it is add a new table with the key "traitName"
TraitTags[traitName] = TraitTags[traitName] or {} will ensure the existence of a table with that key
Hi guys, new to PZ modding here. Quick question: How to use the .class files in Lua scripts . I am using the following reference site: https://projectzomboid.com/modding/zombie/ui/UITextBox2
Currently doing this, but the events are not documented for ISTextEntryBox (at least I cannot find it)
require "ISUI/ISTextEntryBox"
local SKOTextField = ISTextEntryBox:derive("SKOTextField")
Is it possible to use the UITextBox2 class?
I belive those are the java files which are protected
Im not reslly fsmilsr with all the termibilogy But this example is more like sn object i think rather than a class
Idk someone else should answer
I am trying to implement the onChange or onTextChange event, but this does not seem to work. Also, I want to limit the text field to only accept numbers (digits) and limit it to 1 char. The methods as described in the reference page for PZ modding cannot be used with ISTextEntryBox. If someone can provide me some examples or maybe a documentation link that would be great!
Textentrybox can be set to only accept numbers but you need to initialise it first
Is there a doc-reference for ISTextEntryBox?
I dont think there is any youd have to looo through vanilla code
@neon bronze Doing this after init, but does not seem to work: Don't see what the issue is. Any way to see the exception message within the game. I only see messages in the Command Console for now.
local instance = ISTextEntryBox:new("", x, y, 10, 20)
instance.font = UIFont.Large
instance:initialise()
instance:setOnlyNumbers(true)
return instance
end```
Might be the setOnlyNumbers does not exist like that.
I have that outside the function already.
Ah ok
Let me double check
You can add the entrybox as a child to the panel and then add the panel to the ui manager
Doing that already, but the issue with the function it cannot find I guess. I will try to find some docs and examples for this ๐
Ill ping you later with what i did i made a custom ui some months ago aswell
I deduced from the source code of the game.
ISTextEntryBox is not a java class, it is lua
that website only documents java classes
Found the issue. You need to use the methods after adding it to a parent UI element. It does not work before that.
you can just read the source from your media/lua/ folder
Hi everyone, is there a way to get a floor ItemContainer from a gridsquare that maybe does not already have items on it ?
Yes, thx albion, will try ๐
I wanna drop items and my blind use of the drop function seems to be buggy in AutoMechanics
Why not just add items to the square?
That's what I wanna do yes ๐
is calling square:AddWorldInventoryItem no good?
You could get the player and its square and then add the items
When I use it, It duplicates some of the items I, drop and the duplicated items are unreachable afterwards
How do you add the items?
if invItem and player and player:getInventory():contains(invItem) then
local square = player:getCurrentSquare()
local playerInv = player:getInventory();
invItem:getContainer():setDrawDirty(true);
invItem:setJobDelta(0.0);
local dropX,dropY,dropZ = ISInventoryTransferAction.GetDropItemOffset(player, square, invItem)--some random position around the player
square:AddWorldInventoryItem(invItem, dropX,dropY,dropZ);
playerInv:Remove(invItem);
ISInventoryPage.renderDirty = true
ISInventoryPage.dirtyUI();--set inventory dirty to force loot window recomputation: FAILED
end
end```
Oh yea you both add and transfer the item to the floor
Either add and remove the item or just transfer it
But i doubt transferijg it would work so just add/remove
square:AddWorldInventoryItem adds but where is the transfer ?
Ok nvm i misread i just saw the ISInventoryTransferAction and thought you would call it
i think you might need to remove the item from the inventory before adding it to the ground
Or call DoRemoveItem on the player inventory
I heard there is some discrepancies between different calls
it probably nulls the item's parent when you remove it
yeah it does
so if you move it to the ground before removing it it's going to glitch the item
hmm actually doesn't seem like addworldinventoryitem actually changes the item's container reference actually it does
so it might not be related
It works ๐ thanx
Doesnt it just spawn a new instance of the ite on the floor?
items usually stay the same object
in this case the item on the floor is actually a separate object with references to the actual InventoryItem
So its just a pointer that lies on the floor?
kinda, yeah
That is kinda smart, instead of making a whole new object just point to the existing one
But you can also add items with ItemFactory so eh
I see in the ISTextEntryBox.lua the following. It seems that self.javaObject is the class that has all the function I need. Is this something I can use in my derived instances? I am trying to get some response for onPressUp but it does not do anything in this code.
you should be able to, but in this case definitely don't
the java onPressUp method calls the lua onPressUp, so this is recursive and will crash your game
How would you define the onPressUp to print a text for example? I just want to register that even but seems not to fire at all.
it should be enough to just have the print
do you have anything that can be pressed?
This an event for KeyPressUp right?
im pretty sure its for when you leftclick on the text field and when you release it it will trigger OnPressUp
yeah it's for mouse
local panel = ISPanel:new(self:getX() + width/4, self:getY() + height/2 - height/8, width/2, height/4);
local sell = ISUIVMTextBox:new(desc, 10, 50,
panel.width - 20, 20, item, false, self.data.player:getInventory(), self.data.vmInventory, panel)
sell:initialise()
sell:instantiate()
sell.data.listbox = listbox2
sell.data.listbox2 = listbox
sell.data.player = self.data.player
sell:setOnlyNumbers(true)
panel:addChild(sell)
panel:addToUIManager()
panel:bringToTop()
thats for my custom textentrybox which is just the vanilla one but i renamed it internally
ignore the selfs
i think when i was documenting the events i came across a bunch for keyboard input but i would hope that ui already has some handling for it
i dont know if the OnPressUp in the textEntryBox is the same as the lua event
it's not strictly an event but i don't want to complicate things for someone who's new
yea i know that i just dont know if they both have the same trigger
they do and don't, the ui stuff takes priority over the events, so if you click on a ui element the events for clicking won't be fired and it calls the lua functions for that ui element instead
ah that explains the typing without walking
enter is special and calls the onCommandEntered function of the text box.
Everytime i learn more and more about pz it feels like its more and more ducttaped together
i think the keyboard events always fire, you don't walk because walking isn't using lua events anyway
unless the game is told to eat specific key presses but it almost never does that
Struggling with lua tables again
I'm trying to get the count of a tag used, and giving it back in a sorted way is giving me an aneurysm.
function TraitTags:getTagsStatistics()
local tempTable = {};
local sortTable = {};
local returnTable = {};
--get
for trait, tagTable in pairs(TraitTags)
do
if type(tagTable) == "table"
then
for _, tag in ipairs(tagTable)
do
if tempTable[tag] ~= nil
then
tempTable[tag] = tempTable[tag] + 1;
else
tempTable[tag] = 1
end
end
end
end
--sort
for key, value in pairs(tempTable) do
table.insert(sortTable, {tag = key, count = value})
end
table.sort(sortTable, function(a, b) return a.count > b.count end);
table.sort(sortTable);
--condense
for _, entry in ipairs(sortTable) do
returnTable[entry.tag] = entry.count;
end
return returnTable;
end
The sortTable looks... sort of correct:
but when condensed into simple key-value pairs in returnTable, I get this
(struggling to get a picture right now but it looks exactly the same as tempTable)
So how can I get returnTable to look like
"Anthro", 104
"Human", 84
"Carnivore", 2
"KeenVision",2
etc?
you can't because string keys are not ordered in any consistent way
the {count = , value = } thing you're doing is the best way to emulate that behaviour
wait, really? Not even by order of insertion?
the way tables are implemented probably ends up effectively sorting them in some manner but they aren't guaranteed or intended to stay in a certain order
๐
Fair enough I guess. It makes more sense why I was struggling now
for i = 1, getn(sortTable)
do
returnString = returnString..sortTable[i].tag..": "..sortTable[i].count.."; "
end
return returnString;
I'll just return a string instead I guess. It's just for looking at and debugging, not for any real code use
do sandbox options for a mod need to be "refreshed" if it the mod in question is updated?
For reference, this is what it looks like in-game
I've added "NPCGroupsSpawnsSize" but it does not appear in-game
The associated EN text file
when you start the server with the new sandbox variables, it takes the default values. In your case you probably are still using the old version.
also remember what you see in your "client" game includes the default mods sandbox options, not the server mods sandbox options
Ughh... then I need to know how to clear the server mods... Hmm..
it really depends on your setup
I've been running the mod locally and exclusively
which is why i'm a bit confused on how the sandbox options is stuck on the older version
then go to Host and change the settings > mods of your server
remember your server must be stopped during that operation
when you start the server with no settings, it creates a setting (all default)
funny when i tried to create new settings, it is still missing the group size spawn option
show your settings mod list
you may expect that your settings sandbox options are related to the server settings mod list. but it is related to your default mod list instead.
Yeahi 'm gonna try a hard reset
i'm a tad confused since this is my first time working with sandbox options;
do you mean the sandbox options file and the associated translation?
-OR-
the in-game menu for sandbox?
show your settings mod list => show you in-game menu for server settings mods selection
how did you show a list of mods sandbox options from the game if you've never selected the mods ?
as i said, i was running locally exclusively, straight from the solo sandbox
i didn't use the host server settigns
sorry, I went very far in a wrong direction.
so you want to control sandbox options for a solo game
yes
how do you select the mods in the solo game ?
From the main menu, mods
Scrolled down to my mod
Solo --> Custom Sandbox
https://steamcommunity.com/workshop/filedetails/discussion/2577903374/2958293022033269881/ point 3 and 4 distinguish default mod selection and game mod selection. does it help you ?
i'll give a try, thanks
That's strange, it looks like what Dislaik did.
#modeling is your next home then ๐
Another question from my side ๐ Starting to get there, thx to your help so far!
I have 2 mods on my local device. Not yet on Steam. One is a library I would like to use in other mods. See it as a shared library of common stuff I would like to use. When I want them locally to be both loaded, I've selected them in the Mods menu and both are loading. How do I reference the library mod and use the stuff from there?
My Core-Library mod has the following in the file SKOCoreLib.lua
require "ISUI/ISTextEntryBox"
local SKOCoreLib = {}
SKOCoreLib.TextField = ISTextEntryBox:derive("SKOCoreLibTextField")
function SKOCoreLib.TextField:new(x, y)
local instance = ISTextEntryBox:new("", x, y, 23, 23)
instance.font = UIFont.Massive
instance:initialise()
return instance
end
return SKOCoreLib
The other mod tries to load it in like this:
local SKOCoreLib = require("SKOCoreLib")
if (SKOCoreLib == nil) then
error("SKOCoreLib is nil")
end
Do I need to provide another path for the require call? The mod id is SKOCoreLib which I have on my local device only.
in your mod.info of the client mod, add the line require=SKOCoreLib
once you have uploaded both on steam, add the lib as required item to the client mod (there is a button for that)
local SKOCoreLib = require("SKOCoreLib") is correct in this case?
require statement means that the symbols of the current file require some symbol from the required FILE
SKOCoreLib.lua must be a valid file for the statement to be valid
Works! Thx. I had this (based on another documentation):
require = {
mods = {
"SKOCoreLib"
}
}
require=SKOCoreLib works!
to clarify, require statement in mod.info declares a mod dependency while require statement in a lua file declares a lua file dependency
I know, but the last require in the mod.info was not correct. requie in lua is sort of import like in typescript etc.
Thx for your help!
I asked for help yesterday with an error I have been getting reports on with one of my mods and the help I recieved seems to have worked but now people are reporting a new one. anybody know 2what this means or how I might be able to fix it? ````SEVERE: Error found in LUA file: D:/Steam/steamapps/workshop/content/108600/2756636139/mods/Big Degen's Dakimakura Emporium/media/lua/server/dakiActions.lua
ERROR: General , 1684826052384> ExceptionLogger.logException> Exception thrown se.krka.kahlua.vm.KahluaException: dakiActions.lua:39: function arguments expected near == at LexState.lexerror line:278.
ERROR: General , 1684826052384> DebugLogStream.printException> Stack trace:
se.krka.kahlua.vm.KahluaException: dakiActions.lua:39: function arguments 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.funcargs(LexState.java:1075)
at org.luaj.kahluafork.compiler.LexState.primaryexp(LexState.java:1149)
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.subexpr(LexState.java:1312)
at org.luaj.kahluafork.compiler.LexState.expr(LexState.java:1321)
at org.luaj.kahluafork.compiler.LexState.prefixexp(LexState.java:1107)
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.subexpr(LexState.java:1300)
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.localfunc(LexState.java:1635)
at org.luaj.kahluafork.compiler.LexState.statement(LexState.java:1764)
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:667)
at zombie.GameWindow.mainThread(GameWindow.java:495)
at java.base/java.lang.Thread.run(Unknown Source)
sigh, it is in the first 5 lines
ERROR: General , 1684826052384> ExceptionLogger.logException> Exception thrown se.krka.kahlua.vm.KahluaException: dakiActions.lua:39:
Did you check for a boolean comparison?
function arguments expected near `==` at LexState.lexerror line:278.
se.krka.kahlua.vm.KahluaException: dakiActions.lua:39: function arguments expected near `==`
the mod Big Degen's Dakimakura Emporium has a semantic error in dakiActions.lua file line 39 report this log to the mod owner.
I am the mod owner. The last issue lied with line 39 as well. I had chaned it to what was sugggested and it seemed to fix the spamming error I was getting but it only replaced it with this new one. I'm not really great with this :p Here is what line 39 used to be and what it is now. if not player:getDescriptor():getProfession() == "Weeb" then return end if not (player and player:getDescriptor():getProfession == "Weeb") then return end
return
end```
you have to test your mods after each change before uploading them or you will have infinite complaints.
Thanks I will try that. And yea, I know. I need to get better at that.
initial problem was probably that player is not always valid so you have to check for nil before using it. second problem was syntax error.
most of us want to rush production;)
Is it possible to have clothing make you run faster? I tried messing with the running/combat speed stat but im not really sure
https://steamcommunity.com/sharedfiles/filedetails/?id=2899775865 I'm glad you ask
Hey,can i ask something that can seem basic af?
ah hmm if it requires a framework ill make that side of the mod sperate. Thank you, I'm glad to know a way exists! Hopefully the next build implements it
Yeah thats what this Channel is here for!
Hello,
I'm working on a mod and I would like get the SandboxOptions ZombieLore mortality value.
However, as I can see in the Javadoc, the Lore field has no getter, so how can I get it ?
javadoc link : https://zomboid-javadoc.com/41.78/zombie/SandboxOptions.html#Lore
I'm sorry if this is a dumb question, I'm completely new to Lua and Zomboid modding...
Javadoc Project Zomboid Modding API declaration: package: zombie, class: SandboxOptions
ok so i tested this one and still seem to be getting an error. ````se.krka.kahlua.vm.KahluaException: dakiActions.lua:39: function arguments 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.funcargs(LexState.java:1075)
at org.luaj.kahluafork.compiler.LexState.primaryexp(LexState.java:1149)
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.subexpr(LexState.java:1312)
at org.luaj.kahluafork.compiler.LexState.expr(LexState.java:1321)
at org.luaj.kahluafork.compiler.LexState.prefixexp(LexState.java:1107)
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.subexpr(LexState.java:1300)
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.localfunc(LexState.java:1635)
at org.luaj.kahluafork.compiler.LexState.statement(LexState.java:1764)
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)
๐
Why the poster isnt working? i've been looking if the file names are well writen and the file is a png too,i genuinely dont know what does not work
are you sure the extension (.png) of the file is correct? What is the size of the picture ? Is the path valid ?
The size is 720x527
@drifting ore if you want to, you can display file extensions in your file explorer by clicking "view" then checking "file name extensions", that might help you later
should give you something like this
ohhhh,thanks
SandboxVars.ZombieLore.Speed
oh
Sorry we must be missing something obvious here. split your code in multiple lines and see where it is going west. once you have found, print all potentialy wrong parameters e.g. print (tostring(player))
I thought I needed to use getSandboxOptions().
is there a place that lists other global variables like SandboxVars ?
I do not know, when I am looking for something like this, I use AgentRansack / FileLocator to parse Project zomboid media/lua + decompiled java code
ok thanks a lot, i'll take a lot at this
Hey, anyone know how to tell if the zombie can see the player? Tried this somewhat hacky solution for lack of finding something better, but it didn't end up working.
function Legend.zombie_canSeeTarget(zombie, target)
local prev_target = zombie:getTarget();
zombie:setTarget(target);
if zombie:isTargetVisible() then
zombie:setTarget(prev_target);
return true;
end
zombie:setTarget(prev_target);
return false;
end
(Forgive me for my naming convention sins)
local booleanCanSee = zombie:CanSee(target)
Beautiful! Thank you!
Hi!
I'm trying to make a small mod that allows the player to make Logs and Twigs into wood chips to put in the compost. Something strange is happening though. If I spawn in the Wood Chips using the debug log they work as intended. They start out as Stale and go Rotten soon after. When I create them through the recipe, they never go stale or rot and they don't stack with the debug items. Has anyone experienced this or know what I might be doing wrong?
i just uploaded the backpack flags mod for those who were following. Hope y'all enjoy! โค๏ธ
Like so?
you have to split the logic like print ('Player = '..tostring(player or 'nil')) if player then local descriptor = player:getDescriptor() print ('Player getDescriptor = '..tostring(descriptor or 'nil')) if descriptor then local profession = descriptor:getProfession() print ('Player getProfession = '..tostring(profession or 'nil')) if profession then local professionIsWeeb = profession == "Weeb" print ('Player isWeeb = '..tostring(professionIsWeeb and 'true' or 'false')) if not professionIsWeeb then return end else return end else return end else return end
ah, so I was way off, lol
Ok so I did that and loaded up the game and seem to have gotten the same error. where do retrieve the printed part?
in %username%/Zomboid/console.txt just above the error
I don't think it worked. this is all that I can find pertaining to the error Dakimakura Emporium/media/lua/server/dakiActions.lua May 23, 2023 6:54:53 PM zombie.Lua.LuaManager RunLuaInternal SEVERE: Error found in LUA file: H:/SteamLibrary/steamapps/workshop/content/108600/2756636139/mods/Big Degen's Dakimakura Emporium/media/lua/server/dakiActions.lua ERROR: General , 1684882493357> ExceptionLogger.logException> Exception thrown se.krka.kahlua.vm.KahluaException: dakiActions.lua:39: function arguments expected near `==` at LexState.lexerror line:278. ERROR: General , 1684882493357> DebugLogStream.printException> Stack trace: se.krka.kahlua.vm.KahluaException: dakiActions.lua:39: function arguments 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.funcargs(LexState.java:1075) at org.luaj.kahluafork.compiler.LexState.primaryexp(LexState.java:1149) 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.subexpr(LexState.java:1312) at org.luaj.kahluafork.compiler.LexState.expr(LexState.java:1321) at org.luaj.kahluafork.compiler.LexState.prefixexp(LexState.java:1107) 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.subexpr(LexState.java:1300) 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.localfunc(LexState.java:1635) at org.luaj.kahluafork.compiler.LexState.statement(LexState.java:1764) 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)
wait I think I know why
Is this how it should look? When I copy and pasted it from you message it didn't line up correctly.
I do not understand what is the difference ?
Well I fixed it there that's why i am asking if it looks right. Before when I had pasted it it was all wrong looking.
this is how it looks when I just copy and paste it
that's because you paste with some blank chars before. anyway lua is not blank sensitive
and there is no '==' on line 39. you are running a different file than the one you modify
try adding () around the last condition?
My EmmyLua typings are now fully pulling info from PZ's official JavaDocs.
--- @public
--- @static
---
--- Almost Unit Identity This is a near-identiy function that maps the unit
--- into itself. It is the cousin of smoothstep(), in that it maps 0 to 0, 1 to 1,
--- has a 0 derivative at the origin, just like smoothstep. However, instead of
--- a 0 derivative at 1, it has a derivative of 1 at that point. It's equivalent to
--- Almost Identiy above with n=0 and m=1. Since it's a cubic just like
--- it is very fast to evaluate.
---
--- @param x float value in [0..1]
--- @return float value in [0..1]
function PZMath.almostUnitIdentity(x) end
An example snippet from the codebase.
@tame mulch
Letting ya know there's a replacement for Capsid now.
Where?
Going to write installation and usage guide but the project is here: https://github.com/asledgehammer/Umbrella
idk how that would be possible. In the mods folder it is saying I am using the rigth stuff.
around (player:getDescriptor():getProfession() == "Weeb")
yea but where do I place the () there? at the end?
Looks like you already did it - my discord didnt update
ah. 
my guess was that the code was being read as (not player:getDescriptor():getProfession()) == "weeb"
which doesn't really make sense
you can use () to make your code more legible too
idk I didn't write it I'm just trying to get it to work.
in your file editor, verify the path to the file you are modifying, if it is the same, refresh the file.
I have. I even relaunched the game just now and same error
let me unsub from the mod
that might be it
the game says it isn't using that version but idk
the error tells you exactly where the file is and that there is "==" line 39. you should check that file.
ok so it was because I was still subbed on the workshop it seems. I'm not getting any error when I use this. print ('Player = '..tostring(player or 'nil')) if player then local descriptor = player:getDescriptor() print ('Player getDescriptor = '..tostring(descriptor or 'nil')) if descriptor then local profession = descriptor:getProfession() print ('Player getProfession = '..tostring(profession or 'nil')) if profession then local professionIsWeeb = profession == "Weeb" print ('Player isWeeb = '..tostring(professionIsWeeb and 'true' or 'false')) if not professionIsWeeb then return end else return end else return end else return end
so I guess i should just upload it as is then?
you should test the mod, not just verify there is no error.
and remove the print they kill performances
oh I am also the error never seemed to actually break anything anyways.
Just a quick question; is there a way to render a straight line?
as far as I can tell it all works. but that's odd considering isn't this just what I was already using just broken up?
Does anyone know if it's possible to create recipes through LUA code instead of using a txt file?
Items too
yes, self:drawLine2( xScreen1, yScreen1, xScreen2, yScreen2, a, r, g, b) for lua objects that derive ISfrom ISUIElement note that this is screen relative
When you say screen relative, I assume you mean that setting the values only renders it on the screen itself, and not in the game world?
Maybe a better question to ask is if I can raycast in the game world, dunno if that's possible
there are functions to convert from screen-relative to world relative.
but you need to have your UI refreshed at the rate of the world (it's an option that reduces performances) or it will be ugly
and the UI is always superimposed on the world (no masking)
anyone have any idea why this loop doesn't even run?
function TraitTags:getPlayerTraitTags(player)
local playerTraits = player:getTraits();
local concatenatedTags = "";
local returnString = "";
if playerTraits ~= nil
then
for _, trait in ipairs(playerTraits)
do
print(_..", "..trait);
if TraitTags[trait] ~= nil
then
concatenatedTags = table.concat(TraitTags[trait], ',');
returnString = returnString..concatenatedTags..concatenatedTags;
end
end
end
return returnString;
end
ScriptManager seems to be both too central and too private for this without Java change. But I would not bet against you achieving it anyway ๐
that's pretty much why I made Battle Royale https://steamcommunity.com/sharedfiles/filedetails/?id=2970134188
Oo!
any ideas how to get the frame number?
Seems like getTraits() doesn't return a table? I'm confused--how are you supposed to figure out what traits a player has?
BTW anyone know how to get an update event for all floor items
or can I get a list of the floor items nearby somehow
Here's said error if anyone has any insight
AutoLoot mod checks all items on floor
getTraits returns a TraitCollection, you need to read decompiled PZ. Current version is available somewhere on the wiki. I prefer to get a local version. latter here https://steamcommunity.com/sharedfiles/filedetails/?id=2748451514
former here https://zomboid-javadoc.com/41.78/
Javadoc Project Zomboid Modding API package index
you can find events in LuaEventManager.java
do I have to decompile for that?
yes, or check the online version
e.g. OnFillContainer is called when items are spawned in a container. I do not know if that includes all items spawns or not.
thank you, I think it is only for when items are created from a loot distribution or something, I'm trying to get all items when you load the world. I'm trying OnMngInvItems
So I see on TraitFactory.Trait there is an isFree check. Any idea how I can make a trait free?
I am using ProfessionFramework and added a trait with zero cost... but I do not see it in the list.
Ohhh I think thats only for traits applied from professions.. looks like there is no way to allow the player to choose a trait for free
anyone knows what the palettes parameter does for items?
quick question does resetting lua suffice or do i have to restart zomboid completely to update mod changes ?
So far with everything I've done, resetting has been enough.
If you're just changing LUA, you can open the debugger (F12?), search for your file and hit "reload lua" without even leaving your game
though note depending on what you were doing and if/when any errors happen - that method isn't always the best as some stuff gets left in a partial state
okay good to know thx
Put the trait cost at 0
Where I can find the Bump Types that I can set to a damage, and the effects it cause ?
so I am trying to add this vhs tape to the loot table for the livingroomshelf. the game tells me that it is in the loot table at like 98% spawn chance. but after 5 minutes of rerolling the shelfs loot it hasnt spawned. so I dont think its working 
Are you definitely on the right sub type of container? LootZed can be confusing for that.
and I assume you've spawned the item manually to make sure it's in the game at all?
ya i can spawn it manually
the item works fine, I can attach the recorded_media to it and play it on a TV
Hmm, your Type is different to the rest and includes the Base prefix
but I don't think that's causing problems as it got the Name right
you can attach multiple loot tables to the same tile. but most tiles only have 1 loot table
Yeah, my bad - I thought that shelf had multiple for some reason
the base prefix shouldnt really effect anything
because the other items I have spawn just fine even with the prefix
How is your tape defined?
this is the rest of the item
Whats the module the item is defined in?
Base
How many rolls does the container has?
the container im using to test just has the 1 loot table, the LivingRoomShelf
Well yes but it also has defined how often the game will roll for items to spawn in ProceduralDistrobutions
oh I set it to 100 so it has a high chance to appear
So it rolls 100 times for items?
maybe im thinking of the wrong thing
I think you are how does proceduraldistrobutions look?
Can you find the entries for LivingRoomShelf in ProceduralDistributions.lua?
Maybe instead of Base.Vhs_Avp just VHS_Avp
If you have events like ongamestart
That wont get triggered when you reload
Item scripts too afaik
Doesnt get reloaded
ya the item still appears in the lootzed but its still not spawning in the shelf
Did you reload and everything?
Yes I did
Even when you force roll the thing?
Spam it till it does
If its on the list it should spawn
Mhm I've been spam force rolling an item with 97% on the lootzed like 50 times and not a single spawn
You could atleast for now make a new table with just your item in it and insert it there
See if its just awful rng or something else is wrong
when is the item being added to the tables? is it attached to an event?
iirc if you change the loot tables after item picker has parsed them lootzed will show the values from the lua tables even though they aren't actually being used by the item picker
Hello, does anyone know of an Event that fires whenever a zombie hits the player, and if possible has parameters for the type of damage (scratch, laceration, bite) the zombie just did ?
I looked at PZEventsStubs but couldn't seem to find one.
In my experience you dont need to put it in event in my mod the items would just spawn
Ya, this VHS tape isn't the only item in this mod. And the other items spawn perfectly fine using the same ProceduralDistributions
Look maybe in the list structure? Thats the only thing that comes to my mind why it wouldnโt work
is there an event that takes place when consuming food ?
context: i want to check if a food item has a certain tag
Remember to hook both stop and perform as stopped eat action may (and may not) consume food.
Good morning.
oh damn hooking is a complete new concept have to look it up thx
So do EmmyLua users typically write their mods in Intellij IDEA?
i think vscode and its respective lua plugin is more commonly used
Okay cool.
I'll need to write down simple instructions on setting up a environment for Candle & Umbrella.
Going to do it on my lunch.
where is repair chance stuff stored?
questions in comments ```lua
local orgISEatFoodAction = ISEatFoodAction:stop();
function ISEatFoodAction:stop() --does this check after consuming food ?
if not item.hasTag("Stimulant")do
ISEatFoodAction:stop() = orgISEatFoodAction --compatibility with other mods/game update
elseif item.hasTag("Stimulant") do --Initiates "stimulant" effect
JustConsumedStimulant = 100 --or ISEatFoodAction:item.getTag(Stimulant) ???
end
end
--ISEatFoodAction:perform() gonna do the same as in function ISEatFoodAction:stop()
Event:EveryOneMinute --Is the syntax right? does this mean the function runs every ingame minute?
function StimulantReaction()
if JustConsumedStimulant > 0 do
moodleValue(Stimulated) = moodleValue(Stimulated) + 0.1;--moodleValue inc aslong as stimulant is active
if moodleValue(Stimulated) > ... do --if the value goes ((above))/below a certain value
player:setVariable("CombatSpeed",player:calculateCombatSpeed()(moodleValue(Stimulated)+1)); --Increase of CombatS according to stimulant amount
elseif moodleValue(Stimulated) < ... do --if the value goes above/((below)) a certain value
player:setVariable("CombatSpeed",player:calculateCombatSpeed()(moodleValue(Stimulated))); --Decrease of CS according to stimulant OD,...
end --unremarkable amount of stimulant
JustConsumedStimulant = JustConsumedStimulant-1; --stimulant wears off, should depend on consumed stimulant
end
end
stop is when the timed action is cancelled by the player, perform is when the action completes successfully
ah so change it out instead of ISEatFoodAction:stop() ISEatFoodAction:perform()
in this case you want both because food action still eats a portion of the food when you cancel it



