#mod_development
1 messages · Page 166 of 1
I have, OnCharacterDeath is one exemple
what are you trying to get this facing direction for anyway?
honestly im just testing how everything works
oh fair, i guess you'd have to use OnPlayerUpdate if you wanted it to track rotation without moving then
i have a few ideas but nothing really concreat till i learn more about the games limit
hey, don't you make barotrauma mods? i think i've seen you around that discord before
i do
that's sick
hmm time to keep learning
so i saw in the docs theres IsoDummyCameraCharacter and IsoCamera and a few other dummy things, but whats the point of the dummies and what are they used for? i was searching for IsoDirections and saw it
im assuming dummy isnt really used for anything as it is just a dummy
intresting
im surprised you can even mess with the camera as the game heavily relies on your camera being in an exact angle
you're not able to mess with it in a 3d sense
oh?
it's just for moving it about and zoom and stuff, it can't be rotated or anything
huh
would of loved to see if i could break the camera and show how the buildings worked in 3d space
unfortunately the game doesn't have a 3d world at all
i thought it was 3d? as the guns in game appear so
it does render some things in 3d but there isn't a 3d world, those are 3d models rendered on top of the 2d world
ah i see how its done a bit more
im assuming anything that rotates is 3d but everything like the ground and buildings are 2d textures?
yeah, pretty much
figuring out how the game works makes it easier for me to mod stuff in the long run
Are you 100% this works? it does not look like it's being triggered in my code
hmmm i wonder if theres a way to get and set camera zoom amounts...
if you mean changing the specific zoom levels, no
damn
Like, I have followed your example but notthing happens
CasualoidUtils = {}
function CasualoidPrint(...)
if not isDebugEnabled() then
return
end
local arguments = { ... }
local printResult = ''
for _, v in ipairs(arguments) do
printResult = printResult .. tostring(v or 'nil') .. " "
end
print('Casualoid:' .. printResult)
end
CasualoidUtils.patchClassMethod = function(class, methodName, createPatch)
CasualoidPrint('CasualoidUtils.patchClassMethod', methodName)
local metatable = __classmetatables[class]
if not metatable then
error("CasualoidUtils.patchClassMethod: Unable to find metatable for class " .. tostring(class))
end
local metatable__index = metatable.__index
if not metatable__index then
error("CasualoidUtils.patchClassMethod: Unable to find __index in metatable for class " .. tostring(class))
end
local originalMethod = metatable__index[methodName]
metatable__index[methodName] = createPatch(originalMethod)
end
CasualoidUtils.patchClassMethod(TraitFactory.class, "addTrait", function(addTrait)
return function(...)
local args = { ... }
local traitId = args[1]
print('traitId' .. traitId)
if args[1] == "Asthmatic" then
return Trait.new("", "", 0, "", false, false)
end
return addTrait(unpack(args))
end
end)
it's quite a popular mod idea and unfortunately it's only been found to be possible with java modding
i was trying to make it so i forced zoomed when wearing an item..
java modding? the hell?
if you want to force the player to be at a specific vanilla zoom level it should be fine
i think there's a longsighted mod that forces you to be zoomed all the way out while not wearing your glasses
but anything path vanilla is a no go
yeah, you can't change the actual zoom levels
pain
how much more in depth is java modding? like is there a limit to what you can do there too?
not really, but there's very little support for it
i have no idea how java works so
your mods have to be manually installed and you'll just be rebuilding the game source with your changes
there might even be legal issues with redistributing them because of that... not sure
yeah im not sure thats a thing id even try
wish there was more players could do with cameras and such, could be very cool
time to go back to experimenting
@sour island Chuck, I tried to use your metamethod overwrite but I'm having no success
-- Based from: https://github.com/Project-Zomboid-Community-Modding/pz-community-modding/issues/38
local _metaMethodOverwrite = {}
_metaMethodOverwrite.addTrait = function(original_fn)
return function(self, ...)
local args = { ... }
print('args[1]'..args[1])
local originalReturn = original_fn(self, unpack(args))
return originalReturn
end
end
function _metaMethodOverwrite.apply(class, methodName)
local metatable = __classmetatables[class]
local metatable__index = metatable.__index
local originalMethod = metatable__index[methodName]
metatable__index[methodName] = _metaMethodOverwrite[methodName](originalMethod)
end
_metaMethodOverwrite.apply(zombie.characters.traits.TraitFactory.class, "addTrait")
It never prints the 'args[1]'..args[1] do you have any idea why?
Hello there, anyone has insights on when to use getSquare and when to use getCurrentSquare for a player ?
you're patching TraitFactory.class, instead of Trait.class here.
So i've been able to access IsoPlayer object through LuaManager GlobalObject. How would I go about getting IsoGameCharacter object? I'm interested in inventory items which is accessible via IsoGameCharacter but how to get IsoGameCharaceter from IsoPlayer? Or am I going about the wrong way 
I'm trying to intercept the TraitFactory.addTrait Don't I have to intercept TraitFactory?
oh, sorry I just got back, you're probably right
No worries, anyway. As I said earlier, the interceptor is not being triggered at all
IsoPlayer inherits from IsoGameCharacter
Is the patch printing? CasualoidUtils.patchClassMethod
so all interface from IsoGameCharacter can be called from IsoPlayer
I can't imagine why they wouldn't be the same reference so I'd be very surprised if this worked, but have you tried just TraitFactory.class
Part of my logs here; https://pastebin.com/8dqkBf00 @fast galleon
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
What do you mean sorry?
As opposed to zombie.characters.traits.TraitFactory.class, just TraitFactory.class
Sure I can try that
Nope, notthing happens. No logs, no anything.
I think this happens because media\lua\shared\NPCs\MainCreationMethods.lua is loaded before my lua file. And I can't intercept the traits yet
The traits are added in an event handler for OnGameBoot, so I wouldn't think that'd be an issue
They have to be exposed to be intercepted - is it?
this.setExposed(TraitFactory.class); java\Lua\LuaManager.java
Looks like it is
Wait, is the fact that addTrait is static a problem?
public static Trait addTrait(String var0, String var1, int var2, String var3, boolean var4) {
Trait var5 = new Trait(var0, var1, var2, var3, var4, false);
TraitMap.put(var0, var5);
return var5;
}
public static Trait addTrait(String var0, String var1, int var2, String var3, boolean var4, boolean var5) {
Trait var6 = new Trait(var0, var1, var2, var3, var4, var5);
TraitMap.put(var0, var6);
return var6;
}
Is it characters in the classes?
Yes? java\characters\traits\TraitFactory.java
Not on a computer so just eyeballing it
@heady crystal
I can see why Kahlua wouldn't add static methods to the class metatable, so you may be onto something there
add hairspray flamethrowers to common sense
Feature requests is not what this channel is for lol
Ah yes, average entitled user moment
👏
Right, so you would just patch the normal function
Someone's parent forgot to teach how to say "please" and "thank you"
@ Chuck add railgun to EHE
Even decorating the java calls works on calls from Lua
Doesn't get applied to calls made in java
If there's something in the global table that can be overwritten it should be done there
If it's static they may not be present in the class metatable since instances wouldn't necessarily need it—if that is the case, what poltergeist said should work unless it prevents overwrites (idr whether it does)
Tbf, I could do what I did for my tmog mod and directly override the function
local backupGetAllItems = getAllItems;
getAllItems = function()
-- Funny code here
end
ISItemsListViewer.initList(self);
-- put the original function back in it's place
getAllItems = backupGetAllItems;
I intend to use InventoryItem:getId() to identify uniquely an item instance on a server. Is that the way to go or should I use something else instead ? are those IDs recycled or really unique ?
@frank elbow @sour island @fast galleon
This WORKS 🎉
local oldAddTrait = TraitFactory.addTrait
print('YOLO')
TraitFactory.addTrait = function(...)
local args = { ... }
print('args[1]'..args[1])
return oldAddTrait(...)
end
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
So, this is bad but it works, sooo, it's not bad?
Oh cool, didn't know you could capture ... args like that into a table
It's quite cool! I learned about this recently! It's like the desctructuring in javascript, but a bit worse
Beware cases where any of those can be nil, since it'll discard it & any after that; select is useful for those cases
select?
I'm a bit confused what are you referring to?
https://www.lua.org/manual/5.1/manual.html#pdf-select (5.1, which is not Kahlua, but select works the same)
local function f(...)
return {...}
end
local function g(...)
local t = {}
for i = 1, select('#', ...) do
t[i] = select(i, ...)
end
return t
end
f(1, nil, 3) → {1}
g(1, nil, 3) → {1, nil, 3}
oooooooooh
I just tested that in 5.4 and both resulted in the second table, so maybe I'm completely wrong ? I'll have to try it with 5.1 and see
Okay I understand now. But I can still do oldAddTrait(...) and have the ... still spread the nils, and values correctly right?
Yes, if used directly it'll be fine
Ah okay 🤔
Alright 🫡
Thank you and I'll look into it 😄
Okay, different question.
How does Events.OnGameBoot work when you connect to a MP server?
Like, if Events.OnGameBoot is only fired in the main menu, why then you can still use custom trait mods when you connect to an MP game, even if you don't have the mod enabled before connecting to it?
A quick search of the source suggests that, on the client, it's fired when resetting Lua, when exiting the ingame state (likely return to main menu or desktop), or as one of the first steps when initializing the game thread. These occur in both SP and MP, particularly that last one
seems to be true if you use unpack
you only get the 1
Maybe that's what I was thinking of; my memory is clearly going 😄 thanks
makes sense. was able to make it work. thank you!
So, doing this is unsafe?
TraitFactory.addTrait = function(...)
local args = { ... }
local traitId = args[1]
if noobTraps[traitId] then
-- oh no! I need to remove this trait!
args[5] = true -- Mark it as a profession only trait
end
return oldAddTrait(table.unpack(args))
end
unpack also accepts arguments that specify the start and end indices
It's not necessarily unsafe if nil is not an acceptable argument (rather, if it's contiguous), but you can use those to be safer
main issue is with function that have 0 to 5 arguments and adding nils or removing args causes issues
TraitFactory.addTrait = function(...)
local args = { ... }
local traitId = args[1]
if noobTraps[traitId] then
CasualoidPrint('Noob trap detected, remove it', traitId)
-- oh no! I need to swap this with a dummy trait!
return oldAddTrait("", "", 0, "", false, false)
end
return oldAddTrait(unpack(args))
end
LOG : General , 1685728735620> Casualoid:Noob trap detected, remove it Asthmatic
I think this works well enough 😄
Can't trust my newbie friends to not cripple themselves with bad traits 😅 🤣 (again)
Yes, it's good enough
Check one of the devs replies, luckly I asked this yesterday lol
so does player:getPosition give me the positions x and y?
I need help...
Would it be possible to have a vehicle with a container that has only one item inside, which can be equipped by the player, but, has the restriction of Not allowing the player to leave the vehicle with the item in their inventory?
If the item was some kind of weapon, would it be possible to equip it without it going into the player's inventory?
Hi, I am creating new "Carpentry" items... I took reference from ISWoodenContainer and made my own canBuild function for solar panels and made context menu for it. For sprites I used crate sprites since I dont have my own rn but main problem is when I place it on ground it creates object named Crate and not Solar Panel(I also named it in code) + when I dismantle it it gives me plank... is there something I need to change because I dont see any settings for it... Firstly I thought it is selecting by sprite name (but its kinda weird for me)...
here is my code
https://pastebin.com/7guz4yh3
https://pastebin.com/xgCauytb
does this really not have any use? it is using x,y, and surprisingly Z
how i gotta figure out how to print their values to see if they ever update
the class is literally never instantiated
the unused turn based code instantiates it but the turn based stuff is barely more than stub - it was probably intended for whatever that was going to be
looking around it it seemed like it was intended as a way to control the position of the camera from lua, but it's such a skeleton that i don't really expect it to work
well i doubt it would work, but by the dummy type, it could be what the camera is attached to so having more control over the camera is the dream
print("Current Camera Position: X: "..IsoDummyCameraCharacter.getOffX().." Y:"..IsoDummyCameraCharacter.getOffY().." Z:"..IsoDummyCameraCharacter.getOffZ());
```kinda hoping it was this easy, its not lol
i might be misunderstanding, but what im wishing/hoping for is that its used in some magical way, idk man im just wanting more camera control as having a Z axis could be very interesting for multiple reasons such as ADS
@TIS could you make IsoMarkers rendered even for players on different levels? (depending on some Line Of Sight check)
There's a lot of dead code in the docs.
seems so, but its always cool to try to find what still has a unintended use
wonder if i can lock the camera to the player to prevent anyone from looking around...

Vehicle container with 1 item -
Possible
Restrict from leaving the vehicle - possible
Equip without going to inventory - not possible
If youre making some sort of mounted gun thing . This is certainly not the way to do this.
Well atleast not the way others did it .. but you can try and if you happen to make it work
Pls do dm me as im interested
Could anyone give me a lead as to why TraitFactory is throwing an error here? on TraitFactory.getTrait(traitname)
--Uses alphanumberic symbols and commas only.
TraitTags.add = function(traitName, tags)
local globalTagTable = ModData.get("TraitTags");
local sanitizedTags = TraitTags.sanitizeTags(tags);
local tagTable = {};
if TraitFactory.getTrait(traitName) ~= nil
then
if globalTagTable[traitName] == nil
then
print("Trait Tag Framework: Initializing entry for "..traitName.." in TraitTags")
globalTagTable[traitName] = {};
end
if string.len(sanitizedTags) > 0
then
tagTable = string.split(sanitizedTags, ',');
print("Trait Tag Framework: adding tags "..sanitizedTags.." to "..traitName.." entry.");
globalTagTable[traitName] = tagTable;
else
print("Trait Tag Framework: No tags detected for "..traitName..", skipping...");
end
else
print("Trait Tag Framework: Cannot find trait "..traitName..", skipping...");
end
end
log:
traitName is most likely not a string
You mean getTrait isn't looking for a string? or what I'm feeding it isn't a string?
what you're feeding it isn't a string
require("NPCs/MainCreationMethods");
local TTF = require("TraitTagFramework");
...
local function initAnthroTraits()
...
TTF:add("KeenHearing", "Anthro,KeenHearing");
...
That first TTF:add is what it's erroring out on
the use of a colon is passing TTF as traitName
OH MY--
hold on. let me try changing that
yep. That was it. Thank albion 🤦♂️
Anyone have examples of the use of ModData (the global one)? Try as I might to access ModData it seems to be giving me nils
or @bronze yoke you mentioned that using global ModData to keep track of this table was unnecessary to keep it persistent. Do you have another suggestion if I can't figure this out?
i just don't think it needs to be persistent in the first place
it should regenerate itself the same every time
a typical usage of global moddata is just like:```lua
local myModData = ModData.getOrCreate("MyKey")
myModData.foo = "bar"
item MetalsmithTable
{
DisplayCategory = Item,
Weight = 30,
Type = Normal,
DisplayName = Metalsmith Table,
Icon = MetalWorkbench,
MetalValue = 1,
WorldStaticModel = MetalsmithTable_Ground,
}
recipe Make Metalsmith Table
{
keep [Recipe.GetItemTypes.WeldingMask],
keep [Recipe.GetItemTypes.Hammer],
keep [Recipe.GetItemTypes.Saw],
SheetMetal=5,
BlowTorch=2,
Result : MetalsmithTable,
Sound : Welding2,
Time : 1000,
SkillRequired : MetalWelding=2,
OnGiveXP : Give25MWXP,
AnimNode : BlowTorchMid,
Prop1 : BlowTorch,
}
this my mod but not crafting
Looks like you have a table index error. Could you show the line it's erroring out on?
and the full line of the log, it's cut off in the picture
here
ha okey wait
ERROR: General , 1685731017219> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: attempted index: texture of non-table: null at KahluaThread.tableget line:1689.
one of the items in your recipe can't be found
Why does this code work if I haven't defined what "player" is?
you or another mod probably accidentally made a player global somewhere
or it's local to your file scope or something
damn, need to fix that shit, thanks!
Wait wait spoon
How did you figure this out
Like you tested and it work
I mean
I dunno how to phrase my question ...
I had some people complaining on a mod so I finally disabled all mods and tested the mod in question alone and I kind of figured it was some global variable somewhere. I wanted confirmation from this channel as well 😄 As you know : I think everything related to coding is magic 🧙
Someone had a big brain moment and made a global player = getPlayer()? 🤔
Can anyone tell me why this function thinks the passed variable is itself, and not what I provided?
sounds like unwanted colon usage
line 233, when I pass player:
that's what I thought
but then I get here and it says that player is actually the TraitTags object
I made sure I wasn't using a colon so I'm kind of confuzzled
The only thing I could think of is the "self" I put on line 233, but how else do I reference that function I need?
if you're not using a colon, self shouldn't have any meaning, so i'm not sure why self.getPlayerTagStatistics() is even valid
you'd just use TraitTags.funcname instead of self:funcname
but that's originally what I had and it did the same thing
let me reload the whole game and see if this is just something that can be resolved by that
by the way, it lit up in pretty colors so I was pretty sure it was valid before you said that lmao
the function is getting called, so it is valid, but i don't understand why it is
Thank albion, I know what happened now. I was getting an error that I misread, or wasn't the true error. Then I kept getting errors and looked more closely and saw that the player was returning the TraitTags obj
when the original error was that my return value couldn't be automatically concatenated into a string 💀
I swear though, it said it was returning nil but I can't get that to reproduce.
debugging 
It's 100% my least favorite part of coding
Debugging is a whole different skill to master.
Debugging is hardest when either you assume something is correct or a library you call assumes that something is correct.
98% your assumption
Debug test code in smaller bites. Evaluate parameters and calculations. It'll save you time.
well not to mention once you triggered an error you have a high change your code won't be working properly unless you quit and reload the game
lua reloads are usually enough
depends how you reload lua
i never reload single files
so I played zomboid, it's been a while. I can see the game is getting more and more bugs along new versions 😂
I can't prevent myself to imagine an inversed changelog like:
So for this version we decided to break this and that subsystem because it's more fun!
😂
how do you reload all of lua?
when you're in game
you cant
not midgame
dang okay
You back out to menu then load again
what i do is turn off my mods on the main menu so that lua reloads whenever i reload the save
To load faster in, you can start a game with no zombie, it load much faster. But of course if you dont need zombies in your mod.
Just released a new mod that I think is pretty useful / cool. Hope y'all enjoy!! ❤️
https://steamcommunity.com/sharedfiles/filedetails/?id=2984175956
Is it possible to mod the camera pan?
Like infinite panning
Make the character invisible and have them teleport along the panning path
When they stop panning, teleport back to original spot
That's how I would try to do it
Hey, I don't know if I'm just missing it on the java docs or I'm doing something wrong, but is it possible to write modData on the player server side, then allow the client only read it?
Could someone tell me if while making new firearm item is there diffrence between X files and FBX files in terms of visibility of attachments? I added my model in FBX as new item but no matter what i did i couldnt get attachments to appear on model with player (it was visible in attachment editor in debug mode), so i tried overriting m16 that had x8 scope on it. Vanila m16 has 8xscope model where it should be, but once i changed only model to my FBX one it was nowhere to be seen, no floating, nothing. Making new model of attachment with new item attachment aswell appear in attachment editor, but not on playermodel while playing? Neither the attachment or muzzle flash are visible.
What are you trying to achieve exactly?
Assigning a integer value to player modData when using a custom item via the context menu server-side, then checking it client side
For more context, I’m making a mod with various medkits, if the player is healing at a rate equal to greater than the rate of the medkit they are trying to use, it won’t let them
you're talking about what you think is the right solution to your problem, but what exactly are you really trying to achieve?
Sorry if I’m not understanding what you’re trying to ask me, I’ll do my best to explain
What I’m trying to achieve is syncing mod data on the player, both client side and server side.
use transmitModData?
I'd like to try my hand at creating new TV channels / Radio channels for players who'd like some extra lore, or general entertainment to listen to. Would anybody know how to go about doing this? Never modded a game before and I'm really throwing myself into the deep-end with no experience here.
@fair crater I don't know but all the text for TV/radio channels are in shared/Translate. Search for one, get the textID and then search the textID in the code to see how it's used
Wasn't there a tool for tv/radio?
why even involve the server? everything you've mentioned happens on the client
Using the item on the ground would cause modData desync - so probably make sure it occurs in hand
also, transmitmoddata is not relevant to players, their moddata is automatically synchronised and transmit doesn't even work on them
would it? it's the player's moddata, not the item's
Oh I thought he was giving a value to the bag - nvm morning brain
I know azakaela has a couple of radio mods and there’s also AnimeTV that you can look into
Nice! I have a working poc of ModGuardian where both ModGuardian and the mod using it are encrypted 😄
of course the loader is only obfuscated, but I don't see any way around that
@sour island 😄
Pirate
i made a leg amputation item using m_mask in the .xml
however
shoes don't care about clothing masks
so you still get a shoe on the amputated side
anyone have any ideas on what i could do to fix this
I don't but you could check this mod:
https://steamcommunity.com/sharedfiles/filedetails/?id=2703664356
i'm working on that mod right now
haha
that's what this is for
its because it was a modded shoe lol
works with vanilla shoes
I'm curious what happen if you remove the shoes from your character, does it work then?
works if its not a modded shoe
so any vanilla shoe works
amputation + wheelchair
Wheelchair trait moment becoming reality
i need some help
so im trying to make a moodle and the coding doesnt work it says error 1,2,3,4,5
and it make me frustrated
can someone please help me
and yes its two mod combind its the insanity one and the cannot attack'
I appreciate the reply, but, I'm entirely dropping myself in here without any clue on what to actually do. So, this is practically gibberish to me, unfortunately.
hard to say if you don't share the exact error
full stack trace if possible
whats that?
While in game, listen to some radio or TV channel, take note of some part of the text, then search that text in all files under the media/ folder of your zomboid install directory (steam). It should give you some lines like:
Some_Identifier = "The text you search for"```
Then search for `Some_Identifier` (replace with the actual identifier) in all .lua files. It should show you where it's used and how to use it.
Thank you very much for this, but.. well, how would I go about actually making a mod to add new channels to the tv and radio so I could write my own stations n' all that? I apologise for being dense, because I am, but I've never modded anything before and do not know a single thing as to what to do.
I MEAN WHEN I OPEN THE GAME WITH THE MODS IT COMES UP WITH A ERROR 1 2 3 4 AND IT OPENS A MENU WITH ALL THE FILES
of the game
https://steamcommunity.com/sharedfiles/filedetails/?id=2896041179 Enable this and recreate the errors.
yes, in that case it means you have the details of the error in console.txt (And no need for screaming 😂 )
Also at the top there is a checkbox and play button. Uncheck the checkbox and hit the play button.
If someone who has experience with modding in custom foods and drinks, please let me know. I'd want a mod created, and I am willing to pay you
@ancient grail Mod group does that
Hello there, any Global Object specialist around ? When I remove a global object on solo it's all good. when I remove a global object in MP, the luaObject is removed (both Server and Client sides), but the isoObject remains on the world (at least client side). last info known on the server is that transmitRemoveItemFromSquare(isoObject) returned 1 (which is the position of the said isoObject in the square array, see pic from the client side). Last info known on the client is the call to my CGlobalObjectSystem removeLuaObject that seemed successful (size of lua GO array confirmed to be 0). Any cue is welcome, and I mainly wonder who is responsible for removing the isoObject on MP client side ? (both when the isoObject is loaded client side at removal time and when it is not)
howw do i use place walls in tilezed?
Like making a building? If you are making structures you would want to use BuildingEd.
well yeah in buildinged
If you need extra walls to divide a room you can use the 'place walls' and select trim,int walls, ext walls to customize them from the panel on the right.
However if you click on the red/blue/green cube you can set up default walls by room and establish the internal name there as well.
- You can also use the 'Place Walls' and select 'None' in that right panel if you want to 'erase' walls for an open floor plan.
ok
most cases in vanilla: something happens on client and isoObject is removed, global object is removed on server and then removed on clients.
You may have issues if you try removing a 2nd tile object because it's hard to sync the indexes
In my case the Client sends a remove command to server. Then the server removes the GO and then that server removal propagates to client. The client removes the GO, but the isoObject remains.
More info: after quit and join again the isoObject has disappeared
In that test case, my actions are very slow and there is only the ground and my isoObject. index seems fine.
I may simply add client isoObj removal, but it seems redundant and it requires the grid to be loaded.
and also CFarming /CPlant does not do that.
My isoObj specificity is that there is no sprite but as removal works in solo I guess it should be also ok in MP
What are you sending from client? I think it should be remove isoObject and transmitRemoveItemFromSquare. Then server does everything automatically.
I am sending a client command sendClientCommand, both for adding and removing, like it is done for CFarming. All isoObj life control is done server side.
In fact I create 2 objects initialy instead of 1. so deletion seems to work, deleting only one. it is the creation that I must analyse. my bad
I may be back crying in a few hours. 
How do annotated maps work? Is the reference generated upon looting the map? So if I get a map that says a house has guns. Does the game then decide to spawn them there?
anyone know where the big lights are in BuildingEd?
Asking because I’m looking to create a pseudo quest system. Whether it be following clues, or going after certain spawns. But if the system already has a mechanic in place, development will be easier.
good luck
Not sure what you're doing but you'd probably have better chance to get a useful answer in #mapping
Thank you for the help, sorry for bothering.
not something i've looked into myself, but i've heard that this is indeed how it works
@drifting ore
Hello, welcome to PZ mod development!
Here are some links with resources to get familiar with making mods for Project Zomboid.
https://pzwiki.net/wiki/Modding
https://github.com/FWolfe/Zomboid-Modding-Guide
Yeah link on my profile
Im pretty sure sapph would love to do this project
Please create a ticket.
Thank you
Thnx boss @eternal garnet
No worries g 
Buildings are added in WorldEd, Go to #mapping for stuff related to WorldEd and TileEd Many of these questions already have comprehensive guides and/or answers posted so you won't have to wait for someone to come back with answers.
i want to make a custom spawn location for a local game i'm playing with few friends, i found this guide https://shockbyte.com/billing/knowledgebase/482/How-to-Set-the-Spawn-Point-of-Your-Project-Zomboid-Server.html but idk where to find the "Custom Spawn Choices" field, can someone help?
The Shockbyte Knowledgebase contains hundreds of tutorials for managing your game servers for Minecraft, Hytale, ARK, Rust and more.
At login, my client does not receive a GlobalModData update, what is the right way to get it ? (I would like not to force Global Data synchro to all clients, just the the new one).
DM me if you're still looking for someone
When you have to fix yourself the issues in libraries you need for your project 😂
https://github.com/boolangery/py-lua-parser/pull/45
I've got (what is hopefully) a quick question about table.insert(). I'm trying to burn a body part which I can do in the lua console with getPlayer():getBodyDamage():getBodyPart(Hand_L):setBurned() but when I unpause the game the damage disappears. I'm guessing I need to write this data to either a player table or a moddata table. Without telling me what table it goes on, how can I determine WHERE this data needs to be written? Or is this just a matter of "You kinda just need to know where it goes."? I'm assuming it needs to be inserted because I'm digging through the More Traits mod and that's how it's being done there.
Update: I had GodMode on and everytime I unpaused GodMode would kick in...
are you testing in single or multi player?
single player
Ok so it's probably not related to transmitting moddata
generally, you need to call updateFromIsoObject, there's also a server transmit on init or something similar
I'm not on the Global Object anymore. (I was calling twice the isoObject transmit from the server)
-- TimedAction and UI code should call this repeatedly to keep this luaObject
-- in sync with the isoObject, which may be updated at any time.
function CGlobalObject:updateFromIsoObject()
I'm on another part involving GlobalModData aka ModData
oh
wait
ModData.request("...") and Events.OnReceiveGlobalModData.Add(OnReceiveGlobalModData)
how can I fix this? Im loading in my own map and I got this error in the console.txt ERROR: General , 1685817644774> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: can't create player at x,y,z=456,506,0 because the square is null at IsoWorld.init line:2799.
choose a valid square. this one is not.
how do I know if it is valid?
for vanilla map, you can have a look at https://map.projectzomboid.com/ (activate MapCoordinates)
not sure but maybe try: getSquare(x, y, z), if it returns nil then it's not a valid square
sorry, Im new. where can I try it?
I guess your spawnpoint is wrong
got the same message this time even after changing the spawn WARN : General , 1685818432139> SpawnPoints.initSpawnBuildings> initSpawnBuildings: no room or building at 456,546,0 ERROR: General , 1685818432144> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: can't create player at x,y,z=456,546,0 because the square is null at IsoWorld.init line:2799. ERROR: General , 1685818432145> DebugLogStream.printException> Stack trace: java.lang.RuntimeException: can't create player at x,y,z=456,546,0 because the square is null at zombie.iso.IsoWorld.init(IsoWorld.java:2799) at zombie.gameStates.GameLoadingState$1.runInner(GameLoadingState.java:268) at zombie.gameStates.GameLoadingState$1.run(GameLoadingState.java:225) at java.base/java.lang.Thread.run(Unknown Source)
is this a custom map? these co-ordinates are very far from the vanilla map
Thx I discover that request 🙂 Events.OnInitGlobalModData.Add(function() ModData.request(keyword) end)
yes.
[SOLVED] I had unchecked everything in the debuglog menu of the f11 view.
different question. I can read a table in the lua console with something like this
mod_data = getPlayer():getModData() for k,v in pairs(mod_data) do print(k) end
but it's annoying seeing the output just 11 lines at a time. I've been trying to find my print output in any log files but can't. ***Is there a way to force console.txt or debuglog.txt to capture lua commands that are run in real time? ***
I've even tried just "print(hello world)" and a ctrl-f for hello world and can't find it. I've confirmed the logs have updated since I ran the last print.
did you confirm by checking the time stamp /size of the file ? Or did you ensure it was reloaded in your viewer ?
completely closed and reopened the file in my editor too. closed the file, printed statement, waited for file to update, reopened it.
Then I guess your code does not run
if you see it in debug console it must run, maybe i'm mistaken about that going to console.txt
I'm running print(hello world) in the lua console. 😦 I know the code is running.
i don't know the exact syntax for it but you can write to clipboard, then paste and read that, or write to your own file
hmmm writing to my own file is a good idea. I'll just look into that.
anyone knows what OnGrab does for recipes?
I added alot more weapons recently, love it so far lol
https://steamcommunity.com/sharedfiles/filedetails/?id=2982935909
it fires when grabbing the items
it seems kind of redundant with ontest, i don't think vanilla even uses it
@bronze yoke and @mellow frigate thanks for the help. I figured out the problem... I had unchecked just about everything in the debuglog menu. I rechecked everything and data is flowing in again. I must have unchecked everything last week when I was trying to figure out how to get the command console to reopen.
Yea it doesnt do it + most of the recipe just give you the item direct/ have OnCreate for that
Still very interesting legacy thing
i mean when grabbing the ingredients
Oh is it when you pick stuff from your inventory and backpacks and such?
yeah
i can't really imagine anything you would want to do then that you wouldn't want to do ontest
True
Is it possible to require an item in a recipe to be cooked to perform the recipe, I have yet to find an example of this or find a way to do so.
Rewrote my dataset for PZ's official JavaDocs to support both JSON and YAML, along with a proper JSON Schema.
https://github.com/asledgehammer/PZ-Rosetta
https://github.com/asledgehammer/PZ-Rosetta-Schema
Yes through an OnTest function
Is there a way to get a grid square clientside when the cell isn't loaded for the client?
not really, as far as i remember
depending what you are trying to do there are work arround
I'm trying to get mod data off of a door at a square, would it be possible to get it serverside?
Hmm I had tried that and it didn't work I must have done something wrong, thank you I'll try it again.
https://github.com/badonnthedeer/TraitTagFramework
This is done I guess! I'm assuming I'll be fixing some bugs as they come up, but for now, thank you all for your help! Especially you @bronze yoke. Hopefully one of you gets some use out of this
What is the Data you are trying to get from that door?
Mod Data that was set on it by my code, specifically a username that's stored on said door. My mod is for renting/buying buildings/sections of buildings
If I can get the door on the square serverside then I should be able to do what I need to do serverside
(which is validating leases by removing someone's auto billing if they're no longer a leaseholder or removing duplicate leases)
you could just save them in global mod data by co-ordinate
Ye, I already have it setup that way which is why I'm able to do it serverside (if I can actually get a square serverside that is)
I'm assuming that's possible
not object moddata, global moddata
that way it wouldn't really be tied to whether the square is loaded or not
I'm using both right now. My global mod data has everyone's leases with coordinates of the door their lease was activated on, and the object mod data stores required info (e.g. key ID, who's renting what, whether it's for lease or not, lease price, etc.)
Hmm... I could reimplement everything to use global mod data I suppose
There'd just be a lot of networking between the client/server
how do you make a player more tired,sad,start dying slowly
Someone willing to enlighten me on how much of an idiot I am? I apparently can not figure out how to create the OnTest function to force an item to need to be cooked in order for the recipe to be valid. Yes, I looked at the Github and PZWiki guides and have got nowhere.
Is it possible to combine different lootables so a server has the same likelihood of spawning weapons in a crate with a ton of mods that it does in vanilla?
Or, the likelihood when there's only a couple of weapon mods as opposed to having 8?
Hi, do you have any idea what I should do to ensure a teleport called during OnUpdatePlayer is not reversed by vanilla ? (destination out of the current cell, my player is teleported back to the center of its previous square) I currently do the teleport on next OnTick and it works but I wonder if there is a better way.
create one item and replace it with your own randomisation OnFillContainer
How would that work?
I wish we had a mod for that
So we can add as many Melee Weapon Packs as we want
And there are a lot
i've been thinking about making an api for it since i've spent so much time making stuff like that already but i haven't had the time yet
I wonder if that's part of Eggon's Utils mod
Depends on the context . How did the player teleport
Is it cuz his fast moving or cuz he did an animation or cuz he used a portal
Honestly at this point I think I am just making it worse and worse. 😕
function Recipe.OnTest.KetchupIsCooked(item)
local itemType = item:getType()
if itemType == "Food" then
if item:isCooked() then return false; end
end
return true;
end
getType() returns the internal name of the item
If you want you can ad delays between checks or turn of the on playerupdate as soon it teleports
most likely the name of a food in this case
ingame OnPlayerUpdate forcing of its position ```playerObj:setX (destPos.x+offsetX)
playerObj:setY (destPos.y+offsetY)
playerObj:setZ (destPos.z+offsetZ)
playerObj:setLx(destPos.x+offsetX)
playerObj:setLy(destPos.y+offsetY)
playerObj:setLz(destPos.z+offsetZ)
I need it to be controlled by the model
like fast move?
you can look at fast move i guess
I replaced "Food" with the item name already if that is what you are referring to and it still throws a thousands errors complaining about the function not existing
either your file is not loading or your script references your function wrong
yes, like fast move, like all teleports (map, minimap). it seems not to work reliably from OnPlayerUpdate when the target square in not loaded
I am going to be honest I have no idea what I am doing at this point and the function script in the lua may be completely wrong. The goal was to force the item "NWCookingPotOfKetchup" to be cooked before the recipe to put it into bottles was executed. At this point it stopped throwing errors for the function itself and has just broken the craffting UI until it wont even open.
function Recipe.OnTest.KetchupIsCooked(item)
local itemType = item:getType()
if itemType == "NWCookingPotOfKetchup" then
if item:isCooked() then return false; end
end
return true;
end
if the crafting ui won't open the recipe is broken elsewhere
i've seen that happen when an item in the recipe doesn't exist
Result : Base.Ketchup=4, is not valid
a recipe can have exactly one result, you must use an OnCreate function if you want more
the ui is breaking because it's looking for an item called 'Base.Ketchup=4' for the preview
oh-
no, apparently i'm wrong, you can do that
weird, i could swear i've seen people using oncreates to get around that - you do need them for recipes that make more than one kind of item
Multiple Items, Like the empty pot + the ketchup would be an issue for sure. I will change it just to see what happens
you can have multiple sources fine
If I tried to have it give me a Pot+the Ketchup from the ResultItem it wouldnt work
I also had an issue with putting destroy in front of the destroyed items making it not register the first item in the list and keep wouldnt work at all
multiple sources is fine, multiple results of differing types isn't
and the ui is still broken? no function issue should be able to cause that
yeah, that's a classic 'item not found'
it's trying to call getFullType on an item, but the item is null because it was failed to be found
So then in theory the item is borked?
either the item is borked or there's a mistake in the recipe
in my experience it's always been the latter: does the item show up in the debug spawner?
All 3 the empty Bottle, The Pot of it, and the completed product. Oh for whatever it is worth I overwrote the vanilla ketchup bottle to have it give you an empty on use
then the mistake must be in the recipe, no matter what's up with the item that should work so long as the game has loaded it, which it clearly has
Both recipes in relation to the pot It helps when I find the right thing.
recipe Prepare A Cooking Pot Of Ketchup
{
Base.WaterPot, Base.Salt;2, Base.Sugar;2, farming.Tomato=6,
Result : NWCookingPotOfKetchup,
Time : 100,
OnGiveXP: Recipe.OnGiveXP.Cooking3,
Category: Cooking,
AllowRottenItem:false,
}
recipe Pour Cooked Ketchup Into Bottles
{
NWCookingPotOfKetchup, KetchupEmpty=4, Base.Spoon,
Result : Base.Ketchup=4,
Time : 100,
OnCreate : Recipe.OnCreate.BottleKetchup,
OnGiveXP : Recipe.OnGiveXP.Cooking3,
OnTest : Recipe.OnTest.KetchupIsCooked,
Category : Cooking,
AllowRottenItem :false,
}
Idk I do not see a problem, not that that is saying much. I have half a mind to just write it off as a skill limitation and axe the cooking aspect. Thanks for the help Albion.
Anybody know how i could give my servers players unlimited carry capacity for a limited time without having to give them full admin privilages? is there a mod for that anyone knows of?
Anybody know why this doesn't have a size property? I thought all tables did
Here's what it looks like
java arrays have size
lua tables have the # operator (#AnthroTraitsGlobals.UnwieldyHandsAffectedTimedActions)
also if you're looping through a lua table you probably want to do for i = 1, length instead of for i = 0, length-1 since they're 1 indexed
Oops. I've been using that and it's been working. Let me try the #
That doesn't work either... 😰
It says it's calling nil
If niether are working, I suspect that I defined the table wrong so it isn't recognized as a table or something
It's got all the commas though. and the strings seem appropriately wrapped in quotes?
the definition looks correct to me
Could someone please make a Diagonal Log Walls Mod?
I don't care if they have a full 1 Tile Hitbox
I don't care if there's no placement of any other object next to them
I just want diagonal Log Walls to accomodate for irregular terrain
local OriginalTimedActionCreate = ISBaseTimedAction.create;
ISBaseTimedAction.create = function(self)
OriginalTimedActionCreate(self);
local atg = AnthroTraitsGlobals;
local timedActions = atg.UnwieldyHandsAffectedTimedActions;
local uwu = timedActions:size();
local n = table.getn(timedActions);
print(#timedActions);
print(uwu)
could it be that this isn't working because i'm hooking into the original function, and it doesn't have that?
even the table library doesn't work
it's "oops! All nil"
lol
I guess I can try pairs?
i don't think getn exists in kahlua
i could be wrong but i went through the kahlua library stuff a while ago and i don't think i've even heard of getn before
(though google does confirm that it does exist in normal lua)
i wonder if omar's stubs include it
nope, only the kahlua original stuff (as it probably should)
I couldn't find getn either
hum, so I have a Lua popup that derives from ISPanelJoypad. In the render() method i do this:
self:drawTextCentre(getText("UI_ModGuardian_Title"), self.width / 2, 10, 1, 1, 1, 1, UIFont.Title);```
In `media/lua/shared/Translate/EN/UI_EN.txt` I have this:
UI_ModGuardian_Title = "ModGuardian"```
Yet when my popup is shown the title is UI_ModGuardian_Title instead of ModGuardian.
Any clue what I could be doing wrong?
I'm doing the exact same thing for other strings which are correctly replaced, so I'm a bit at a loss here
is the file formatted correctly with the UI_EN = {? (or whatever the correct one happens to be, since they don't always match the filename)
oh my, actually no, thanks
but how come it's working for the other strings in the same file though?
iirc the whole thing is pretty much fake
it's not really parsing the header?
i caught some of them just ignoring the first line, but i also remember some not working because of the wrong header
so it just skip the first line or something?
so it's inconsistent between them
i see
maybe they were actually lua files in the past or something
otherwise the dedication to pretending to be a lua table seems really odd
looks like Lua and JSON had a malformed kid to be honest 😂
hum and what about this:
local message = getText(self.text, self.config.modID) .. "\n\n" .. getText("UI_ModGuardian_Warning")
self.richText:setText(message)
``` It is rendered correctly, except for the "\n\n" which are displayed as is
hmm i remember it working differently in different places (again), try <BR>
sweet, everything's in order, thank you ❤️
nice!!
still one mystery remains though, I replaced \n\n with <BR>\n\n<BR>, but the \n are not visible anymore 😂
it's not really a problem but it still feels weird
Nice! My stuff is very close to be fully working and usable by others 😄
Question for you all. I found the timed actions "ISClimbOverFence", "ISClimbSheetRopeAction", "ISClimbThroughWindow", etc.
Is there a way to make these go faster?
maxtime doesnt seem to affect them, or at least these actions don't get created
I know some actions have a time related parameter that let's you choose how much time the action will take, but for the ones you describe there's a character animation, so I doubt you can easily speed them up
maybe I'm wrong though
these things are usually heavily tied to the speed of the animation itself, yeah
it's not something i've looked into myself but somebody here mentioned that these timed actions only get used in specific circumstances
Welp I did find one issue in a different recipe unrelated to the ketchup, so yea... I feel my IQ dropping. The UI works again. However the recipe for the bottling now just sits greyed out and unusable. I am assuming that I built the function incorrectly. The goal of the function is to force the pot of ketchup to be in a cooked state in order for the recipe to be executed. Have I got anywhere close with this function?
function Recipe.OnTest.KetchupIsCooked(item)
local itemType = item:getType()
if itemType == "NWCookingPotOfKetchup" then
if item:isCooked() then return true; end
end
return true;
end
are you sure you want to return true in all cases?
Nope. I have tried swapping both the the trues back and forth just to figure out what I have messed up and that is just an artifact of that
do you know if your code is called at least?
I know the function listed before it (On.Create) in the same lua was working before I added this one. outside of that 🤷
have you tried to print the value of item:getType() to see if it matches what you expect?
I'm not sure but I kind of remember print() statement not going to console for recipes though
Nope I have not as I know nothing about coding. I have only got as far as I have with my modding thanks looking up functioning examples, going "ok this is how this works", and starting a monkey see monkey do routine. So far I have only used script and not used the lua outside of translation files, the only reason I am touching it now is because I kinda have too.
so try to add print("DEBUG", itemType) just after local itemType = item:getType() and search your console.txt for "DEBUG" until you find the itemType. If it's not printed I would try to remove the check on itemType and just keep the if item:isCooked() part, see if that changes anything
(also fix your return values)
first is true second is false
sounds good
print should be fine
I remember some place where you can put lua code in script files and the print() statements were ignore, probably because it's called as a closure or something. Am I hallucinating?
i've never heard of it anyway, if that is a thing it's not recipes
ok good to know
Adding that has resulted in a stream of
[03-06-23 23:38:44.097] ERROR: General , 1685849924097> LuaManager.getFunctionObject> no such function "Recipie.OnTest.KetchupIsCooked".
Recipie
you got an extra i in there
it was a typo all along...
Oh ffs
Not even mad I just want to cry, lets try this again
Ok now the pot of ketchup in the recipe is lit up but it is graying out the bottles and spoon despite them being in my inv. Tested and confirmed it is only lighting up when the pot is cooked. Would that be due to my function check? Do I need a bypass for the other items. Also THANK YOU so much for finding that. I have been fighting this since yesterday.
Are you testing with DEBUG mode ON? I know some recipes are fucked up when in DEBUG mode, such as the rain collector, some items where grayed out even if I had them on me, but the recipe was working anyway (probably due to DEBUG mode)
I have not engaged Debug, however based on my track record so far I will double check that.
can you show the latest version of your function? i'm guessing it's been edited since you last posted it or else i'm really stumped
function Recipe.OnTest.KetchupIsCooked(item)
local itemType = item:getType()
if itemType == "NWCookingPotOfKetchup" then
if item:isCooked() then return true; end
end
return false;
end
i would do it the other way around
function Recipe.OnTest.KetchupIsCooked(item)
local itemType = item:getType()
if itemType == "NWCookingPotOfKetchup" then
if not item:isCooked() then return false; end
end
return true;
end
that should sort it out i think
That fixes the other two but allows the uncooked kecthup
Hello there, I wanna add a radio communication, any idea where I should start with ?
it shouldn't allow the uncooked ketchup as far as i can see
I can only tell you it does, and that would be due to a typo again. I hate this keyboard.
Working as intended. thank you so very very much.
nice!
FYI with my obfucations stuff I realized ; are never required, even if you put all your code on a single line. (Maybe I simply haven't found yet the issues it can create though) 😅
yeah i don't typically use them
i didn't realise they were literally never required though
I was suprised because in Lua 5.1 they are supposed to be mandatory for some cases, but my lua 5.1 is not choking on my obfuscated code
the only time i can think i actually use them is when i want to debug an early return (e.g. if foo then print("foo"); return end), if that's not necessary i suppose i'll omit them from now on
please do and let me know if you find cases where it's breaking semantic 😅
will do! i'm sure your obfuscator would've run into it by now though
I'm sure too but I guess it could not trigger an error, and still change the logic of the code somehow
hmm yeah that's possible
the nice thing about having one lines with no semicolons is that no Lua editor / code beautifier I tried so far where able to process the input 😄
isn't there already radio communications?
I want to add someone (not a player nor a npc, just some lore) talking through radio that can be heard on any radio. I just do not know how to do it but vanilla already does it a lot 🙂
ah so you just want to add a radio channel basically?
yes, what should I take exemple on ?
I'm using continued survivors but I found that it kinda buggy
What's the best survivors mod at the moment, raider npc didnt die when I shot him 5 times bruh
@mellow frigate I have implemented this sort of feature in my "Rick's MLC AdHocCmds" mod where the PZ streamer chat can broadcast their chat through the player radio. The code for it adds a new radio station and adds broadcast strings
thx
I have not posted here before, but do you want the code or will you be OK downloading the mod? The particular file in the mod is 106 lines long (RicksMLC_Radio.lua)
When a player is attacked by a player's previous character (now a zombie) I would like to know which player's zombie attacked the player. At the moment when I call the ISOZombie zombie:isReanimatedPlayer() it returns true, but the zombie:getReanimatedPlayer() returns nil. Is there a problem with the zombie:getReanimatedPlayer()? Or is the information only known for a short time (eg between player death and creating a new character for the same player)?
Hello i have a question about making this mod I'm trying to develop appear in the mod loader in game I followed the example mod template however neither my example mod nor my mod show up in the mod loader I event tried loading it into the workshop folder and following that structure that did not work either here's an image of how the folders look any help is much appreciated.
You can mod to transfer the information from the player to the IsoZombie mod data at player's death/IsoZombie creation time.
Leave the id blank
it didn't work it still doesn't appear in the mod loader
how do i do it with hoast?
You just add the name on the mods section
is this what you mean cause it still empty sorry for bothering you with so many questions
You might have placed it in the wrong folder
You can see that modtemplate's directory
Just go there and paste your mod there
Hi guys
I was wondering if its possible to mod the behavior of the zombies
like make it so that some of them can run from you in certain conditions?
I found that I have to put my mods into the C:\Users\YourUserName\Zomboid\mods\ directory, and the mod.info must have an id=YourModUniqueIdName. (edited: Had mentioned the Zomboid\Workshop directory, but that is if you want to publish to the steam workshop)
Chase your dreams, nothing is impossible.
Well to be fair many things are 😅
i found a mod that lets you spawn inside a prison, but when i do that the whole building is empty, is there a way to fix that?
I don't know man, I think most people come here expecting others to produce the code for them.
Vanilla forces spawned building to be empty of zombies. You can force it otherwise but you may die with no chance to escape
Hi folks, is it any lua documentation where I can check available functions, their signatures, etc?
you can decompile all PZ. Here is how I prefer to do it, others have other preferences. https://steamcommunity.com/sharedfiles/filedetails/?id=2748451514
Still looking for help about your radio channel?
AFAIK this one should be more up-to-date:
https://zomboid-javadoc.com/41.78/
Also the javadoc of the other libs etc, like Kahlua, fmod etc is available
Javadoc Project Zomboid Modding API package index
Have you tried this? 😄
https://github.com/quarantin/beautiful-java
It's using IntelliJ too for the decompiler, but you don't need to run IntelliJ by yourself. Also I rename variables that have meaningless names to something based on their type, which is way easier when you read the code
it's technically more up to date but only a little bit and lack of parameter names makes it much less useful imo
true, guess I could parse the official one to inject parameter names
Thank you
I've not tried it yet, but having meaningful variable names would help a bunch ! you should add the link here: https://pzwiki.net/wiki/Decompiling_game_code
I will as as soon as I receive the mail from the wiki to reset my password
@mellow frigate are you done with your radio channel stuff?
I've not started the work on radio channels, I just wrote the text yet
Another quick question, is it possible to add some custom attribute to the Vehicle object?
Basically, I'm trying to create a new object and attach it to the vehicle on context menu click
Rope.attach= function(o, vehicle)
o.vehicle = vehicle; # sets attribute to my custom object, works fine
vehicle.rope= o; # doesn't work
end
You can not set any type of variable to userdata (java objects) from Lua without a set function
but you could serialize those objects into a table, and instanciate them back when you need to
this copied everything, it's not only decompiled code.
yes, cause I need it to generate the javadoc
also it's easier to have all your code in one place, allows me to edit part of the game for testing without fucking up my game installation
is it a problem?
not really, how do I make it into a library so it's not editable
I'm not sure I follow what you mean
I think capsid packs them into a jar for example?
well that's not really my use case, also half the code is bash scripts, not sure how I would make them run from inside a jar
guess I could package only the variable renaming part into a jar though, cause it's pure java
No, I mean the original Lua files and the decompiled Java files. So that I can read them without accidentally editing them.
I'll test some things, see if Intellij can still read them.
just flag them read only
yeah just set read only permission on the parent directory and sub files/folders
done, good idea
going to try how ?
Nevermind, I was trying to set Intellij to not edit the files. Then I just changed the folder permissions.
how would i do that?
getCell():roomSpotted(room)
real @mellow frigate
Yo, anyone knows how to check if specific vanilla sandbox settings are enabled
Namely I need those 2
From MP server settings
Set function is something that already declared in userdata?
usually every variably has it's own set, e.g. setInventoryItem.
If you are in debug mode, you can also use reflection to set variables.
These are server settings, you should be able to get the setting by name and get the value.
example?
getServerOptions():getBoolean("SleepAllowed") getServerOptions():getBoolean("SleepNeeded")
yep parse your code source with SleepAllowed and you got them
item Thrumbo
{
DisplayCategory = Plush,
Weight = 0.2,
Type = Normal,
DisplayName = Thrumbo plush,
Icon = Thrumbo,
WorldStaticModel = SpiffoPlushie,
}
my item doesnt apear in the item spawner but im sure my code is right cause i used teh spiffo plush code
have you checked in your console.txt? Also can you show the full item file?
also did you restart the game to be sure?
yup
thats the full item file
i have the model in a seperate file
hum from memory there's a kind of header to add in the item file
yes
you're welcome
Learning to make a mod. Just adding in a simple item for my first one. How does one understand distribution tables?
I get the gist of things like rolls and whatnot. I just can't quite understand how to find the exact containers I want to.
Like, how do I find kitchen cupboards in large houses?
Regarding the error.
what capsid does is include an older version of the decompiler
I'm not sure if you can do / add this, but Jab suggested a backup plan
Fernflower doesn't decompile every scenario. If you see a method with a comment that says FF didn't decompile it, go to the same method using JAD and then you should be able to work that decompile into the method with fernflower.
can you please elaborate a little
i make these sprites if anyone needs any for a mod if i have time ill do it free
enable lootzed, find that container ingame, see what definitions that container uses
lootzed?
I am thinking about getting an artist here to do some trait symbols for me 👀
right now most of my trait ui symbols are just crowbars lol
you can find it in the debug cheats menu
we can chat more if youd like
when it's enabled right click the icon of a container in the inventory ui to open lootzed for that container
i just like making mods and doing art for them its fun
Absolutely. Feel free to shoot me a DM if you'd like
ive added u
just keep in mind that I'm working on a trait mod for furries, so the symbols would have those for a theme
also there's like ~18 traits right now. I want to add a few more
Is there a simple way to keep a zombie in a ZombieOnGroundState?
Vaguely I remember there's like an IsCrawler() function for zombies
there might be a way to set that, if that's what you're looking for
I am afraid if I do that, Zombie might be reset and or player logs out and then it will be permanently a crawler.
It seems that the game adds ReanimateTimer when a player is standing on a zombie but it didn't work for me.
Is OnTick the only option 🤔
Opened up lootzed and selected the first kitchen cupboard I saw.
- What information shows what exact loot pool this is pulling from
- How do I get rid of the menu, I can't find an x ._.
They like to hide the close buttons in the most unusual places
there's one probably on the bottom lol
that dropdown with KitchenBottles i think
https://github.com/Project-Zomboid-Community-Modding/pz-community-modding/blob/main/Contents/mods/!pz_debugTools/media/lua/client/vanillaDebugTweaks.lua
You can install the debug mod. Otherwise I think the script to fix the close button is here.
So I need to place my item in:
Kitchen{
KitchenBottles{
}
}
Or something that looks similar to that?
yes, KitchenBottles which is in procedural distributions
Anyone has experience adding a simple object to the game?
To practice and for fun, I would like to make a mod that adds some collectible toys, probably using Creative Commons 3D models I can find
I don't know where to start
Alright, so I could edit the procedural distributions. But what if I want to edit the... not procedural distributions (Not quite sure what to call them.) Like say I wanted my item to show up here. How would I be able to tell exactly what small boxes this is referring to?
smallboxes is a container type defined in the tile definition. Other types are crate, metal shelves, etc.
Game picks a distribution table based on room type and container type. That can be either procedural (a selection between a number of tables) or direct distribution table.
If there's no match for the special combination it then goes to All and container type.
thank you turns out i was trying to put the mods in the wrong zomboid directory it had to be the one on my c drive the one on my p drive thank you for the help
So that smallbox item pool was found in grocery. So does that mean in grocery stores all small boxes will pull from that item pool? And if there was no item pool defined specifically for small boxes, it would refer to all and use that item pool?
But since the small box pool is defined here, it won't pull anything from all?
Alright. So how do I figure out what specific item pool a container is pulling from?
smallbox
So here, I would find:
Kitchen{
cupboard{
}
}
?
You can press Kitchen Bottles and see all available tables.
Since it gives you a table in procedural distributions, you should choose one that suits you more from those.
This table is in in Distributions.lua, you can check it out if you want.
Ah, alrighty then
Thanks mate
hi guys i'm new to modding, is there any resources for creating a custom profession mod? i'd also prefer not to use the professions framework
#mod_development message
this is base hook to the function
then you need something like
local burglar = ProfessionFactory.getProfession("burglar")
You can see examples in MainCreationMethods.lua
@drifting ore
ty, i'll check it out 👍
Anyone know how to sync an IsoObject's mod data to the client from the server when the client isn't in that particular cell? I've tried transmitModData() and sendObjectModData() but neither seemed to have worked
it should be transmit, but, how do you even have an object if it's not in the cell?
the client will discard it because transmit moddata finds the object through the square and obviously there is none if it's not in the cell
No, the object is in the cell. The client isn't though
oh, when i say cell i mean IsoCell
i don't think mapping cells have any runtime relevance
The client will not have information about map parts that are not loaded for him.
Well I'm assuming the server keeps everything in memory, because if I reconnect after the mod data has been updated then the changes are reflected. It's just that right after it's updated, if I enter the cell where the object is then the mod data is desynced
are you editing objects that aren't near any players, or ones that are near a player but not this player?
https://projectzomboid.com/modding/zombie/iso/IsoObject.html#transmitModData()
After you change data you should use this command.
declaration: package: zombie.iso, class: IsoObject
I edit an IsoDoor's mod data on the server, no client is near it (since it's just me on my locally hosted test server), then if I teleport back to the door and check (for example) who the lease holder is on the door it'll still show it as me, if I reconnect then it will show that I've been removed
I tried this like I mentioned before, didn't seem to work
hmm, you're not really supposed to be able to access objects in unloaded areas at all, so i imagine the issue is to do with that
i wonder if doors are a special case or something because i don't understand how you're even getting that far
Well the data does reflect the changes, it's just that I have to reconnect
Hmmm
the server usually only keeps the chunks near players loaded, it reads/writes chunks to/from file when needed
probably cached object or getOrCreateSquare
I haven't even done anything like that. I fully restart the server and reconnect at which point the mod data is supposed to be updated (while I'm in a different cell), then I TP'd back to see that the changes aren't reflected clientside, and finally I reconnect/restart again and then I find that it's showing the changes
i feel i should correct you about how cells work
Sure thing
IsoCell is a singleton that contains the area loaded around the player, the idea of 300x300 area cells is mostly only relevant to mapping and doesn't seem to matter for anything at runtime
i'm not sure it matters too much for what you're talking about right now but it is something a lot of people end up tripping up on
Reason: Bad word usage
So is an IsoCell larger/smaller in size than the game's cell regarding the in-game map?
the size varies by resolution (or so i've heard)
i think it's usually smaller
i remember being able to access a ~200x200 area with getsquare
It depends on a number of factors, debug has option for even smaller size
For context this is how far I TP'd away before reconnecting: https://i.gyazo.com/0ee5fa76477878b94ec6aa58787c590a.png
So I'm almost certain it wouldn't have been loaded yet, and yet the changes get reflected after another restart
i don't understand how the object is even loaded on the server, how are you grabbing the object?
By coordinates with this serverside function:
function RoleplayProperties.getDoorAtCoordinates(x, y, z)
return getSquare(x, y, z) and getSquare(x, y, z).getIsoDoor and getSquare(x, y, z):getIsoDoor() or nil
end```
You should think well about when you actually set the data and read it. There is something weird here.
i wonder if doors are a special case then
Well apparently I can get the square, and then the door on the square. So something is definitely up in both regards 🤔
This isn't singleplayer btw, I'm using the Host button on the main menu
my guess is that the server (and likely client) still keep track of it to some extent while it's unloaded, but the transmitmoddata receiver isn't able to understand that
When you're telepoting there's a few ticks before the player is moved to an unloaded square. I was trying to do things at the new square and had to wait for a few ticks is what I mean.
I wonder if I could just hook into LoadGridsquare's event and request the moddata on the square's door (if it has a door) and call it a day 🤣
Bad for performance I'd imagine...
yeah generally i would tell someone not to try to edit unloaded objects and just cache the changes until the object loads
i don't really know why that isn't as necessary here as it usually is but it still seems like the solution
Any pointers on how I could go about updating the mod data once an object loads? The caching part I could probably figure out on my own
Actually, I've already answered that. I just gotta use the LoadGridsquare event
module base
item Thrumbo
{
DisplayCategory = Plush,
Weight = 0.2,
Type = Normal,
DisplayName = Thrumbo plush,
Icon = Thrumbo,
WorldStaticModel = SpiffoPlushie,
}
this item should work correct?
the wsm is wrong
i just noticed
but it should apear in the item spawner right?
loadgridsquare has a stupid performance impact, so make sure your code is fast
when it fires it fires hundreds of times at once (because it loads in chunks) so any imperfections will be amplified
Ye, I'm just going to do some nil checks for a door and then if that exists then request the mod data on said door. Hopefully no major performance impacts in my testing
well
this doesnt work
and i cant figure why
needs an extra } at the end if that's the full file
ah
item Thrumbo
{
DisplayCategory = Plush,
Weight = 0.2,
Type = Normal,
DisplayName = Thrumbo plush,
Icon = Thrumbo,
WorldStaticModel = Thrumbo,
}
}
like this
that didnt work
ima go for a bit
You're not following the format.
module Base {
item Thrumbo {
DisplayCategory = Plush,
Weight = 0.2,
Type = Normal,
DisplayName = Thrumbo plush,
Icon = Thrumbo,
WorldStaticModel = SpiffoPlushie,
}
}
how do you check if game is in single player or in multiplayer?
found it 
thought i had it bookmarked
Hello everyone, who can help in writing a mod? Based on the Stalker setting
have got the base now and i'm wondering how could i lock the clothing choices to only include inmate outfits?
Hello there, I added an IsoObject on a specific square and I am surprised to see no spriteName through F2 tool. The sprite is the one expected though. Can you explain to me why the sprite is not cemetery_01_30 ? ``` local isoObject = IsoObject.new(square,sprite)
square:AddTileObject(isoObject)
isoObject:getModData()[mdKey] = {myObjModData}
isoObject:transmitCompleteItemToClients()
after quit and reload, the isoObject is still there but it cannot be seen anymore.
nvm i figured it out, wondering if there is a way to disable the "None" option for clothing though.
https://steamcommunity.com/sharedfiles/filedetails/?id=2983937638
Hey guys, I made this loot box mod the other day. I'm looking for a way to include modded items, but only if they are enabled. What sort of "if/then" statement would I need to use to make this possible?
local activatedMods = getActivatedMods()
if activatedMods:contains("ModId") then
since activated mods will never change it's optimal if you can structure things around only checking them once
I'm totally taking that and telling people to stop pestering me about writing mod patchers.
i'm not gonna write 200+ mod patch checks for you random people.

Also, thank you for sharing
Thank you very much! So if, for instance, I wanted to include content from Authentic Z, would I include the Workshop ID number, or the actual mod ID name? And I assume if I wanted to include content from various mods, I would just repeat that if/then statement multiple times?
should be the mod id
Okay sweet, thanks for your help 🙂
if i just omit the category from a crafting recipe it will be in the general category right?
You could also use getAllItems and check if they are obsolete
Would it be possible for the end user to add the ID's into a Text file?
I assume you mean writing to a txt file... yes it is
Something like this should be OK and it should create a log file on game start.
local activatedMods = getActivatedMods();
local file = getFileWriter(
"logs/" .. "activatedMods_logs.txt",
true, -- true to create file if null
true -- true to "append" to existing file, false to replace.
);
local content = tostring(activatedMods);
file:write(content .. "\r\n");
file:close();
end
Events.OnGameStart.Add(logActiveMods)```
the file will be located in %USERNAME/Zomboid/Lua/logs
Cause I'm big dum, I'm looking at my code and drawing up a blank, wondering where I'm supposed to put this if/then statement, and what to put after it
i have a problem, i'm trying to add knox prison as a starting point but the problem is nearly all of the doors there are locked. is there anyway i can have the doors be unlocked by default or give a special key to the player?
Replying to you cause you seem to be pretty knowledgeable when it comes to code, unlike myself 😛
function Recipe.OnCreate.OpenCommonLootBox(items, result, player)
comweap = {"Base.MugSpiffo", "Base.Plunger", "Base.TableLeg", "Base.ChairLeg", "Base.Fork", "Base.Spoon", "Base.ButterKnife"};
comsup = {"Base.Pills", "Base.Tissue", "Base.Dogfood", "Base.TinnedBeans", "Base.RippedSheets", "Base.Pinecone", "Base.Sponge"}
comcash = {"ASS.asscoin"}
combox1 = comweap[ZombRand(7) +1];
combox2 = comsup[ZombRand(7) +1];
combox3 = comsup[ZombRand(7) +1];
combox4 = comcash[ZombRand(1) +1];
player: getInventory():AddItem(combox1);
player: getInventory():AddItem(combox2);
player: getInventory():AddItem(combox3);
player: getInventory():AddItem(combox4);
end
So here's a snippet of the code I'm working with. If I had to take a wild guess, I would assume that I pop this getActivatedMods if/then statement at the very top, before the function starts? and tell it to require, say, BCGTools as an example. Then would I have to specify it to add the items from BGCTools? then just add those items to the comweap category as necessary?
local keyid = player:getBuilding():getDef():getKeyId();
if (keyid) then
local key = player:getInventory():AddItem("Base.Key1");
key:setKeyId(keyid);
player:getCurrentSquare():getE():AddWorldInventoryItem(key, 0.5, 0.5, 0);
player:getInventory():Remove(key);
end```
theoretically should give you the key of the building you're in.
ty, i'll try it out
although getSpecificPlayer(0) points to local player only...
also the game seems to have a system in place where it clears out your spawn location of zombies or something, is there anyway to work around that?
your guess is as good as mine, I'm still fairly new myself. ¯_(ツ)_/¯
well let me think...
if activatedMods:contains("ModId") then
-- Your function below
end
i dunno when you plan to call your function, nor what mod you're referring to
so replace ModId as needed for whatever you're trying to use.
So in my code, the function is called as the very top line. It's the first thing in the lua file
... That would imply it runs unconditionally when the game app launches.
not when the game starts.
and ideally, I'm trying to add compatibility for multiple mods, Bushcraft Gear, Bushcraft Rare Weapons, Shark's Weapon Pack
...maybe it does? Honestly I'm super new to this whole coding thing
🤔
I suggest taking a look at Lua Events and determine when you need to run the mod check https://pzwiki.net/wiki/Modding:Lua_Events
order of execution matters, if your code runs at the start, it could be running before the specified mods are loaded.
Riiiiight. See I haven't encountered this issue before, as everything that my function is calling for is a vanilla "Base.XXXXX" item
Oh, then it's probably not an issue
Adding compatibility for modded content is a whole new thing for me 🥲
since base game assets are loaded before everything
In my experience, Events.OnGameStart.Add(<function>) is generally a safe starting point...
If you're looking at sandbox options, Events.OnInitGlobalModData.Add(<function>)
but if it's related to action and/or equipment slot, you may need to add a check on those events.
https://pzwiki.net/wiki/Modding:Lua_Events/OnEquipPrimary
https://pzwiki.net/wiki/Modding:Lua_Events/OnEquipSecondary
https://pzwiki.net/wiki/Modding:Lua_Events/OnClothingUpdated
more experienced modders may have better insight, this is just based on my 1 month messing around.
Oh it's not related to equipping or clothing or anything - basically I've made a loot box that you open from the crafting menu
Oh then Events.OnGameStart.Add(<function>) should be fine, as long as your mod is loaded after the pre-req mods.
dunno if require applies since not all users, I assume, will have every listed mods installed.
I'm hoping to set it up in such a way that, if you DO have these mods installed, it'll put these items in, but if you don't, it'll just omit them
Well, I'm guessing it would look like this?
local activatedMods = getActivatedMods();
if activatedMods:contains("ModOne") then
-- Your function below
end
if activatedMods:contains("ModTwo") then
-- Your function below
end
end
Events.OnGameStart.Add(AddStuffToMyBox);```
I don't know what you're trying to add to your loot box nor how many
but I'm assuming that's logically what it should look like.
and since you're checking for multiple mods, I think there is no need for else and elseif to consider.
I probably need to sleep cause i'm over-correcting myself here.
so have a good night and hopefully you'll have your answers tomorrow.
Hah that's quite alright. I appreciate the help regardless!
is it possible to trigger a radio broadcast from the xml? for e.g., an item in inventory, right click -> use, timed action into a onCreate function, then trigger specific broadcast from the radio xml?
my main thing im stuck on is triggering the broadcast itself
Guys don't fall asleep in west point wtf
that list contains all mod ids even if their files haven't run yet, and all scripts are parsed before any lua runs
so trying to spawn modded items like this should never be an issue
i asked for the same thing yesterday, and got this answer, but idk what to do with that, maybe you can figure it out, and please @ me if you do
getCell():roomSpotted(room)
bit of an odd question, anybody know of any mods that take advantage of the spears spawning in zombies after a certain amount of months modifier to make modifiers for seeing other things?
like more weapons, like nail spiked planks and bats stuck inside zombies, or even different zombie types, like more of a chance to see nomad zombies as time goes on, essentially zombies definitely not from within the exclusion zone, but happened to wander in, or nomadic survivors that got infected with preserved food and wilderness survival gear
I'm having a bit of a problem I think using Profession Framework for my mod. I'm trying to add an xp boost for stats to a perk with a line like SpecialInterest:addXPBoost(Perks.Fishing, 1) because the modding wiki said you need to use a trait to add an xp boost, but I keep getting an error of attempted index: addXPBoost of non-table. I'm suspecting it's because it's not recognizing the trait because of Profession Framework or something. I'm not super experienced and don't know what to make of it.
Does getPlayer:getCell() return what's loaded for the player in-game, or does that return the map's cell?
The reason I ask is because I'm working with the LoadGridsquare event but it doesn't appear to get called after a player hits "Click to continue..." after loading into their game
I just discovered the getChunk() function available on an IsoPlayer, maybe I could use that for what I need to do
So, sorry if I'm misinterpreting this, but are you saying that I don't need to any if/then statements to include modded items in my code?
as i mentioned before, map cells don't seem to exist at runtime at all
you still do but using them immediately should be fine, you don't need to wait for them to load
So wait, even if I get a player's cell and/or chunk then the squares on them can't be accessed at all? Because I noticed this field on the IsoChunk but I don't know how to access fields from an IsoChunk https://zomboid-javadoc.com/41.78/zombie/iso/IsoChunk.html#squares
Javadoc Project Zomboid Modding API declaration: package: zombie.iso, class: IsoChunk
Unless I'm confused about what you mean by runtime
isochunk is the loaded area
oh sorry
you can access the squares, but the cell object isn't related to map cells, it's just the loaded area
That should be exactly what I need, I had to use the LoadGridsquare event to handle rental bill payments/evictions, but for some reason it's not called after a player loads in for the first time. Do you know how I would go about accessing the squares from a chunk? I've tried getPlayer():getChunk().squares but that didn't work
you tried this?
local sq = getCell():getGridSquare(x, y, z)
No, but how could I get the squares if the code doesn't already know the x y and z?
As idea, try get coords of player and check squares in player radius
Ah yes, that could work. I'll try that out
Is there any method to make a refrigerator when I build it to be both a Fridge and a Freezer? I'm using
local _simpleFridge = ISWoodenContainer:new(sprite.sprite, sprite.northSprite);
_simpleFridge.containerType = "fridge"; -- to set it as a fridge
hello! I want to make a mod for project zomboid, so that objects in the world will spawn regardless of the place in which they are located. That is, so that I could find a shotgun, a needle, an anesthetic, anything in the kitchen.
Who can help me? I do not know codding PZ, but i get ready learn it/
Let him cook…
ressources for modding: https://pzwiki.net/wiki/Modding I recommend starting with F wolf's guide. for your topic, look for "distribution"
the visual 'fridge' is an isoObject hosting 2 containers. you will need to create the frozen ItemContainer myFreezer and call _simpleFridge:addSecondaryContainer(myFreezer)
Hello there, Battle Royale mod teleports players. this provokes client being kicked from the server with type2. Is there a way to keep anticheat type 2 on and not kicking the client by initiating the teleport server side ?
Not that I know of, sorry :X
I was hoping anyone knew if when a trait was added or lost in game triggered an event. All I can find is "onlevelperk" which I don't think is the same thing
you're right, it is not the same thing
there is no event for this https://github.com/demiurgeQuantified/PZEventDoc/blob/develop/docs/Events.md your best bet is to check trait list changes OnPlayerUpdate
Fair enough. I was hoping I wouldn't have to do that
Thank you for looking into that for me, I was hoping this (https://pzwiki.net/wiki/Modding:Lua_Events) didn't have all the answers
I did a little research, according to Poltergeist here (#mod_development message) You can find what each anticheat protection does if you look for it in the java. Here's what I found for type 2:
public static boolean checkSpeed(UdpConnection var0, IMovable var1, String var2) {
float var3 = var1.getSpeed();
double var4 = var1.isVehicle() ? ServerOptions.instance.SpeedLimit.getValue() : 10.0D;
boolean var6 = (double)var3 <= var4 * ServerOptions.instance.AntiCheatProtectionType2ThresholdMultiplier.getValue();
if (!var6 && ServerOptions.instance.AntiCheatProtectionType2.getValue() && checkUser(var0)) {
doKickUser(var0, var2, "Type2", String.valueOf(var3));
}
return var6;
}
If there's a way for you to set the speed of the player below the threshold while teleporting you may be able to circumvent that
(is pasting vanilla java here okay?)
decompiling seems ok to TIS so I'd say yes until further notice from them
I hope that helps
thanx
There are errors in the pzwiki events catalog.
what kind of errors?
parameter types.
Quick Question:
If I want to add multiple modules to my file how do I do that?
module Base
Would it be as easy as:
module Base,UndeadSuvivor
```or
```lua
module Base;UndeadSuvivor
Or do I just list it twice?
module Base
module UndeadSuvivor
```?
is it possible to have lua code that would be available for require() from any of those locations: client/server/shared?
or do I have to duplicate my code
guess I should try to put it in shared 😂
oh damn
seems to be working when I move my code to shared, but since I use stuff from client it's not able to load it :(((
WARN : Lua , 1685990507570> LuaManager$GlobalObject.require> require("ISUI/ISPanel") failed
WARN : Lua , 1685990507571> LuaManager$GlobalObject.require> require("ISUI/ISButton") failed
WARN : Lua , 1685990507571> LuaManager$GlobalObject.require> require("ISUI/ISModalRichText") failed```
unless someone knows how I could create a panel with a title + text content + a button without using those from vanilla?
shared means shared between client and server
yeah, I realized that after I asked the question 😂
but it's only solving half the problem
yo, where can i find api docs for methods, events etc.
yes, but for example distribution is in shared, and I need this code to have access to a popup
you don't.
well I really do
otherwise code from shared can't use my stuff
and I need it to be able to use it
explicit your need precisely 🙂 I can promess you do not need UI stuff server side 😄
I don't need it server side, that we can agree on
but I need code from shared to be able to use the popup
What needs a pop up does not need to be shared.
I guess you'll have to split between shared and client
indeed, in my case it's the opposite, what's in shared needs a popup 😂
I'm making a library mod that let's you obfuscate/encrypt your lua code. It's decrypted on the fly. So if someone obfuscate/encrypt his code that is in shared, then shared needs access to my decryption routine. In case something goes wrong I want to show a popup with an explicit description of the problem
encryption description looks like shared stuff, output (concept) of that is shared, but effective output can only be logs server side and can be that or pop up client side.
problem is, the popup is targeting regular players, not people who go check their logs when they see a red square
I need some sort of notification in-game
there is no player to click the pop up server side. you can either handle the error automatically or crash. I'd recommend the crash for a start or you'll obfuscate your obfustacing error report :D.
you keep talking about server and I keep telling you I don't care about server
hum, unless what you're saying is that distribution only occurs in server?
let me see where your wrote that
ok, so why is any of the code in shared ?
because code in shared can only require code from shared
and code in shared should be able to use my mod
if I put my mod in client, when code from shared is calling require(), it just returns nil because it doesn't have access to code in client
this either mean that the code in shared should be in client or that you do care about server
if i wanted to use getCell():roomSpotted(room) how would i go about that since it can only be called from the server, what event can i use to determine when a player has spawned in?
if someone wants to use my mod on a map mod, he will want to obfuscate the distribution code which is usually in shared AFAIK
hum, maybe I could write code in server and in shared that would send a message to client so that it would trigger the popup?
At your place I would write the code in shared and call a new dedicated event with the result info. catch the event server side to log it and catch the event client side to log it and pop it up (if really you want to pop it up)
lol
in wake them up mod, I use OnTick. but you may prefer something else if you find one here https://github.com/demiurgeQuantified/PZEventDoc/blob/develop/docs/Events.md
WIsh that Umbrella were linked here instead. =(
maybe with this? https://pzwiki.net/wiki/Modding:Lua_Events/OnCreatePlayer
Umbrella has those events.
feel free to correct my answer when you have better. I just cannot recommend what I do not use (yet)
Umbrella has that exact typings in it.
ty, i was looking for documentation earlier lol
this is exactly what i needed, ty
@mellow frigate @red tiger maybe I could use sendMessage or something like that?
I don't know what you're doing.
I saw albion's events repo being linked and mentioned that her typings are included in a full typings project.
I'd like to trigger a popup on client side from code in shared (or eventually in server)
Oh ok.
sendServerCommand
pz naming can be so confusing sometimes 😂
thx I'll try that
so sendServerCommand is called from server and sends a command to client right? 😂
Ok, help me out here, who has gigabrain in optimizing code.
Local functions run faster than global. But I got following situation. I have a function that I want to use in 2 different lua files. I can either
- Make function global
- put my functions into some CommonFunctions.lua and require that lua in my 2 files (but that would make them global, unless I'm confusing something?)
- Just copy my function to 2 files.
So like on 1 hand I don't want to have 2 instances of same code, but on other hand I want shit to be optimized. Opinions?
You could probably do something like this:
local MyMod = {}
function MyMod.doSomething()
-- do something
end
return MyMod```
Then when you need to call someFunc from somewhere, you just do:
```lua
local myMod = require("MyMod/MyMod")
myMod.doSomething()```
ye that's option number 2
except it doesn't make doSomething global
ah that's the point i was missing
or well somehow it does, cause it's accessible globally but it's still a local symbol AFAIK
but to be honest, considering the awful performance of pz this kind of optimization probably won't do much
it's still nice to organize your code
haha ❤️
I can respect that 😅
😂
@red tiger how do I catch the sendServerCommand from client? I can't find any example in vanilla or in all the shitloads of mods I subscribed to
oh maybe Events.OnServerCommand.Add?
How does one create a new animationset? I'm trying to give a player a different AnimationSet based on a trait they pick but, when I try setting it I get an error
damn I think I found a bug in grep linux command 😮
looks like aa is not a table
Don't think so, otherwise it would tell you about it
@trim mist try to add this: lua print("DEBUG", aa, type(aa)) just after assigning aa
this seems like a very useful tool
thing is, AdvancedAnimator is a java object, not a table
and AdvancedAnimator is not exposed to Lua
yeah :/
I think this is quashing my dreams of selective sped up animations
@trim mist but you could check True Actions etc to see how they do it? I think what you need is similar right?
thx
My mod loader does this.
Thank you for the resource. I'll look into it
problem with this, p sure its only gets fired client sided
that's probably the case, although I would still give it a try. Worst case you can probably do it using sendServerCommand
ah wait
not sure you can catch sendServerCommand from server 😅
@weary matrix you can I think.
_G.__sendServerCommand = _G.sendServerCommand;
_G.sendServerCommand = function(..)
-- Do your stuff here.
_G.__sendServerCommand(..);
end
@drifting ore check Jab's example, but to be honest I don't understand why/how it would work 😂
The .. should be replaced by the proper params.
if i use OnTick then im gonna have to somehow check a few things like if the building is actually a spawn location as i don't want the same effect to be applied to every building in the game
its p weird how the game doesn't have an event fired on the server for when a player first spawns in tbh
if i can have the client give the server a message tho i can prob work around it ig by using OnGameStart client-sided and having the client tell the server they just loaded in
seems kinda scuffed tho
using onTick is heresy
mhm, would be really bad to use it for this too since im gonna be going thru like every tile to find a tile a player is in and then somehow determine if they have just spawned there which sounds absolutely horrible
excuse me what do you mean going through every tile
there's absolutely no way you can do that, zomboid map is 16k by 16k or some shit
cell*
ok that's bearable
ye i think im just gonna have the client tell the server when they have loaded in ig lol
tho it sounds sorta insecure since the server is trusting the client for that
not sure how multiplayer is in this game since i haven't really tried it at all but i'm assuming its bad practice for the server to just blatantly trust whatever the client tells it

