#mod_development
1 messages Β· Page 222 of 1
Even between client and shared
(but base stuff must be in shared if imported within shared at runtime)
so when I call it would be as simple as using something like "Getkills()"?
Sure, you could create and call a function called NomOptions.getKills by calling NomOptions.getKills(from, necessary, params). I do recommend what has become known to some people as "lowerCamelCase" (which I was taught to call camelCase) for function, field, and variable names and "UpperCamelCase" (which is sometimes called TitleCase) for classes / modules to give some immediate clarity of purpose when people read your variable names.
Just to be clear you cannot just call getKills() without the module prefix unless you create a truly global function with no parent module called getKills, and most of us would not recommend that.
When you make global functions with highly appealing and simple names, you increase likelihood of eventual conflict with other modders who want to do that or the vanilla game's future available global functions
Even when I'm 99% sure a global might eventually exist in vanilla and be named and used exactly as I would name and use it, I personally resist the urge. @vital karma
Oh, how do i use java in lua?
There are a wide variety of classes, objects, and functions exposed to Lua through a Java class called Exposer in a Jaca class file called GlobalObject iirc.
That is where you find stuff like "getSpecificPlayer"
And other functions we call
I.e., you can just write it.
print(Keyboard) in your debug console should verify an object with that name exists
When i use key==Keyboard.KEY_G it doesn't work even though it's in the library mentioned, so would I have to reference Exposer to get that?
Hmmm
I could also try printing the key var and see what i get in case its that
Then the mod itself doesn't recognize it for some reason
Should I just change it to key == 34?
WizBanger = {}
WizBanger.thisIsG = function(key)
if getPlayer() and key == Keyboard.KEY_G then
print("This is G")
end
end
Events.OnKeyStartPressed.Add(WizBanger.thisIsG)
This works for me when I put it in console
if it doesn't for you, I think you need to move to client or perhaps you have a weird keyboard with abnormal keycodes.
@fathom sapphire
I was using
Events.OnKeyStartPressed.Add(WizBanger.OnKeyStartPressed)
Mb lol
Well actually
OnKeyPress = {}
OnKeyPress.log = function()
print("UP IS PRESSED")
end
OnKeyPress.OnKeyStartPressed = function(key)
local player = getPlayer()
if player ~= nil then
if key == Keyboard.KEY_G then
OnKeyPress.log()
end
end
Events.OnKeyStartPressed.Add(OnKeyPress.OnKeyStartPressed)
Would it not work cause it is named like that or
Cause its OnKeyPress.OnKeyStartPressed
Which is the event and the function name at the same time
it doesn't matter what it's called
Well then idk why that one doesn't work, Ill try your code burry
oh you're missing an end
I just saw that
Lmao
I just dropped it in console and was literally copying his code to say that
Beaten to it again by the champion
β€οΈ
Oh i added the second if without adding the end, mb lol
Thank u
Btw is there anywhere I can see all the functions I can reference, cause I assume there is seperate ones for lua and java
If not thats alr and thanks for the help so far lol
They're kind of endless
Many are referenced here but trial and error may be necessary to figure out what's really accessible:
https://zomboid-javadoc.com/41.78/
Javadoc Project Zomboid Modding API package index
Most of the rest are found searching ProjectZomboid/media/lua
You can access most of the functions in lua above
which is a directory, not a file
a directory of many, many files and directories
You can index the media directory and search its files for text in Window File Explorer
if you're using vscode you can install umbrella and get autocomplete + warnings when you're using functions that don't exist/aren't exposed
tysm
Jesus lol
I'll try to use it but im brand new to vsc
my hope is that it should only make things easier, even for a brand new user
quick question that i want to try asking before actually pursuing
i know that pz can have random attachments spawn on firearms
is there a way to make that be able to force spawn one attachment onto every firearm?
primarily, i'm looking to spawn the Iron Sight attachment onto every firearm, for access to modularity aspects
hi how do i commision a mod
does anyone know if voice chat range is configurable?
nvm i found it its in the server .ini files lol
Is there any way to modify all of a specific weapon type? For example, I want to increase the damage of all Short Blade weapons. I want this to include weapons added from mods as well.
Hey guys, I've been troubleshooting this for a while now, and I have no clue whats wrong, So im making a trait for every 100 Zombie Kills you get, you recieve a Food item, however whenever you Kill a Zombie it Spits out an error about "Then was Expected near '=' "
Here's the code:
if ZombRand(0, 3) = 1 then
inv:addItemOnServer(inv:AddItem("Base.CannedCorn"));
HaloTextHelper.addTextWithArrow(player, getText("UI_trait_dokitraitrecievedfood"), true, HaloTextHelper.getColorGreen());
end
I'm not sure if this is the right chat to direct the question I have, but nonetheless. I am currently trying to implement automatic Discord role removal on player death on my whitelisted server. What I've done so far:
- NodeJS scans for the latest
*_user.txtand gets it's output. - The needed entry with
died atis regexed and I have the line with the timestamp and username of a person who died. Then I regex again, compare the username and Discord user name, run the Discord bot thing and voila, role removed.
However I'm wondering if that's really an efficient solution to get dead players, as there is probably a better way to do this?
rm -rf / for happy life
Is there a way to lock certain item with type Literature from being edited?
what kind of editing do you want to avoid?
If a player has a pencil etc. he can edit/add stuff to the paper. There's a certain item I spawn in inventory for this player with information, which I want to stay intact
Can't papers be locked?
If someone else locks it, yes, but this paper is spawned through a script in player's inventory
If I'm not mistaken, this leads to player's being able to edit it if he has a utensil
Is there a way to lock it initially?
You could add a Lua function to the onCreate of the recipe. Which you can lock as if by someone else.
is writing to a sheet of paper realized by a recipe?
Probably not, but he's saying it's spawned through a script
I'll try setLockedBy() with some random characters to be applied to this item
Yep, this fixes my issue
Thank you
Is there a way to trigger a timed action when another timed action is aborted by the player? I tried to add the new action to the queque in the aborted action's stop() function, so smth like
ISBaseTimedAction.stop(self)
ISTimedActionQueue.add(NewAction:new(...))
end```
But this doesn't work for me. Also tried adding to the queque before the stop(self) command without success.
Would anyone be interested in making kenshi-inspired weapon pack? Ill do the 3d but know nothing about coding
For some reason items from this mod fail to translate. I suspect it to be failing to find the translation files, as it uses the default DisplayName and "IGUI_ItemCat_Documentation" string as a category from the script. Any ideas what could cause this?
The symbols are broken because they're not UTF8
I kinda use the correct path: media/lua/shared/Translate/RU/filename.txt, so what could be the deal?
Also the server log shows the files are found:
got it
Never mind. This bug happens only on Linux.
Testing on my Windows machine revealed everything works properly... Weird.
little question about the "Recipe" translation files (Recipes_EN.txt for example). I saw some mods were starting the file with (lets take EN language as exemple) Recipes_EN = { and i saw another one starting with Recipe_EN (without the s). Do that change anything? Both mods are working, same with their translations. The game just don't care if their is a s or not ?
the first line is a lie, the game just ignores it
Quick question, does anyone know where I can find a list of the names of the skills as they appear in the code? I.E. Woodworking for Carpentry
lovely
most people don't know this and those who do just write the Recipes_EN = { for consistency, and if they make a mistake doing that it's not like it throws an error or anything
declaration: package: zombie.characters.skills, class: PerkFactory, class: Perks
Does anyone knows the difference between getAllTypeRecurse(something) and getAllType(something)?
recurse searches containers inside the container, getalltype doesn't
a recently released mod got my first big hit on reddit, useful for beginners, quest-driven people, and people dealing with missing loot frustation
after 1 year hiatus from modding scene,
my popular mods are Fire trail (35k subs) (with only 43 upvotes on reddit announcement post) and Wheelbarrow (26k subs)(without reddit post),
Dragon Radar have the concept that i first want in a mod, when i first play the game, as a newbie that didnt know where to find specific loot, so it was from that that i begin my modding scene, resulting in serve 75k people in total now a days
https://thejaviertc.github.io/steam-workshop-stats/user/id/reifel1
a reddit version will be out soon (and i will be in hiatus again after that)
i know its not for everybody, and its for some people, reddit post splits into two strong groups
if you want to try:
Dragon Radar - item finder searcher
https://steamcommunity.com/sharedfiles/filedetails/?id=3172486046
for the old ones
RIP 01-2022 to 06-2022 pz-map.com
with hot zones map used with that purpose
will Dragon Radar be the closest spiritual sucessor from it?
useful to find how to use generator magazine, sledgehammer...
I know this isn't related to mod support... but...
I'm looking for someone to collaborate with on a project, I have been inspired by project zombiod. I was thinking of making something similar to it... I know C/C++ very well with vulkan & opengl π
dm me
NOTE: this is pure hobby so don't expect anything professional xD
You can look for someone to work with here:
https://discord.com/channels/136501320340209664/1125248330595848192
ohh right
my bad π
np
also ur pfp looks like a cringe character from a lil indie game
if you play against this 'character' you will get annoyed... her name is briar
Nah it's not a cringe character :(
I know the character lmao
I love her
I'm a main Briar :>
:>
we should play sometime, we could play like 1 match of lol... get tilted and go to project zombiod, die on day 2 and get even more tilted.
#imagine_being_left_on_read_could_not_be_me
Haha I was in a match sry
Hey y'all! First time modding. I'm getting back this error when I'm trying to load into the game "unexpected symbol near ) at LexState.lexerror line:278."
I'm not sure what LexState.lexerror is
Somewhere the file that's missing the ) should be mentioned
Is there any way to modify all of a specific weapon type? For example, I want to increase the damage of all Short Blade weapons. I want this to include weapons added from mods as well.
Animating tiles is hard. But y'know what's harder? Being a normal ass citizen in Half-Life 2 https://i.gyazo.com/901c99e87861294827d8679e202d4199.mp4
God bless. More half-life 2 pls...
So I have a small doubt, I made a recipe through Lua.
But how do I make it necessary to have a specific level to be able to craft this?
Example Carpentry 5
Would it not be the 2nd line that says Skill Required? The green one?
So, it was supposed to be. I put this line
However, as soon as I place it, the "object in question" stops appearing in the game, and it gives some errors
Did you look in the vanilla files how they do it ?
I didn't find it in the lua part, only in the standard script. But I tried this same method and it didn't work ;/
recipes aren't created through lua, they are created through scripts
Did you check your recipe works without the skill requirement ?
I want this crafting to be necessary to have
electrical 4 for example
that's why I'm asking about "skill required" in lua
That's in the lua ?
Why do you make a recipe in the lua ?
yes
Because i'm using the "crafting enchanced core"
I see
and the way he makes the tiles, it's different
Ah thatβs. An important detail
i'm trying to put a skill required for making this computer
Check in mods that use it how they added a skill requirement ?
Or check the documentation of the mod ?
That's the problem, in the original mod or in this case the basic framework, there is none with this parameter
π
Did you check their code how they handle it ?
No I meant a mod that use this framework
The base mod doesn't add any recipes I believe (which they fucking should if they remake the whole recipe system with their thing)
Yes they dont add,I created my own tiles, and recipes. However, for the recipes to be possible, this "workstation" system is necessary.
And only this mod added this "provisionally" until build 42 arrives
Once it arrives, this system will be native to the game itself and will no longer be necessary.
you should ask the mod author for help, nobody here will have experience using their original recipe system
Did you look at mods that use this framework ?
if none of their recipes use it it is very likely that it is simply not supported
Like I can't say it enough but go check mods that use this framework
Thanks for the help :)
Another bad thing is that mods that use this framework are rare lol
i had a quick look at their github and i couldn't see anything that checked skill levels
I went there too, there is nothing
I know but there are examples of mods that use it anyway
SkillRequired:Tailoring=2;Aiming=1,
SkillRequired:MetalWelding=2,
SkillRequired:Woodwork=1,
SkillRequired:Electricity=2,
SkillRequired:Trapping=1,
this are some examples for adding skill requirements in lua
Check this sheet for more coding info
Where should i put it?
Dont know much about LUA, but just adding it as a line should/could work
Let's hope everything goes well, this is the before
God damn it wtf is that
it is beautiful, isnt it?
Even more documentation that's in a random format for sharing
after, where is my pc? π’
When I place this line, the object simply disappears
not from the world, but from the crafting tab
better than nothing π I found it quite useful, dont know its origin
Wait show the line of code
the framework you're using just doesn't support what you're trying to do
yes but that would just make it not disappear, it still doesn't support skill checks
like this?
this is the correct way?
Unfortunately, it didn't work both ways, but thanks for the help anyway.
I'm finishing my machine mod, they are all solid tiles with unique craftings for each one
Press,Glass furnace,Paint mixer etc
I guess @bronze yoke is right then. It seems like the specific system you are using to implement your recipe not supporting any kind of level requirements, or if, has them written in another way
Unfortanely, probably it's the first option
Taking advantage of another quick (and easier) question
The time there put into crafting
is it in minutes?, seconds?, ticks?
Looking awesome! Your computers keyboard is floating though
He is a time traveler π³
48 crafting ticks = 1 second
Thanks :) this saved me
Are you trying to add buildable objects via the context menu? You can use the Building Menu, it acts as a framework.
I tried, but it's just as complex. other than that it uses its own framework
Now I'm trying to make a recipe that gives xp when making it
I don t think it s that complex, I even made a guide for it https://github.com/eI1on/pz-building-menu/blob/main/DEVELOPMENT.md
Hi! What elements of the lua code determine whether a timed action makes sound which attracts zombies? (if there are any...)
Does Build Menu have controller support?
(If not that would be one point for a context menu solution. @mystic vessel)
Yes, it was much harder than I expected to add compatibility, I had to redo almost the entire UI.
Wait it actually is controller supported?
Yup
Dang I hadn't tried it yet and one look at the page made me skeptical... Idr seeing anything mentioned about that on it. Good shit.
Yeah adding controller support to custom UIs is usually more work than modders want to do, so I tend to fear any custom UI that doesn't explicitly claim to be supported on its page. Sometimes stuff is so unsupportive that it breaks the few things that used to work for us.
cough Mod Manager cough most character creation panel mods
Kudos for doing a truly complete custom UI that can support the whole playerbase
I always try to warn people working on new UIs to base their stuff on the updated gamepad-friendly UI modules because if they don't they end up needing to redo most of their UI to add it at the end.
(I've redone several vanilla ones myself and oof.)
hi, is there any tutorial on modding UI elements using lua? looking at mods I have it seems there are "ISUI" files for each element (button, slider etc..) but I'm not getting the whole picture on how to use these elements. also are there any UI "containers"? like UI elements that sort child elements in certain patterns like a grid or a vertical alignment for example? sorry if this is a nooby question I'm really struggling to find any guides on modding ui
I recommend trying to learn by reading through custom UI code in mods that have similar layouts to what you need.
If any of mine have elements you need to learn to implement, you're welcome to refactor my code
oof I wish there was some guide to get me started but yeah. so far that's what I've been doing. man the learning curve for PZ modding is quite challenging huh?
local unwantedPerks = { "Agility", "Aiming", "Axe", "Blunt", "Combat", "Doctor", "Firearm", "Fitness", "Lightfoot", "LongBlade", "Melee", "Reloading", "SmallBlade", "SmallBlunt", "Spear", "Sprinting", "Trapping" };
for i=0, PerkFactory.PerkList:size() -1 do
local perk = PerkFactory.PerkList:get(i);
if table.contains(unwantedPerks, perk:getType()) then
print("Don't level up")
return
end
print("Level up")
end
Why am I getting this?
Object tried to call nil
If I run
for i=0, PerkFactory.PerkList:size() -1 do
local perk = PerkFactory.PerkList:get(i);
print(perk:getType())
end
This outputs the values the same way as in the array in unwantedPerks
I suspect I compare incorrectly?
afaik there's no table.contains function?
You could do something like
local perkType = perk:getType()
for _,v in pairs(unwantedPerks) do
if v == perkType then
print("Don't level up")
return
end
end
I've got a lot wrong in my function. Firtstly getType() returns an object, not a string, so I must resort to getId() for Perk object. Also there is a contains method, however using it correctly on an existing array is essential
declaration: package: zombie.util.list, class: PZArrayUtil
but a table isn't an array*
There's a VERY basic Hello World UI in my Workshop that was published by a friend I helped. You could start there to keep things simpler and expand from that if looking at finished UIs is overwhelming.
say, a while back I know that I had some kind of mod that allowed for a visible belt: nothing fancy, just a "random tint = true" belt that appeared OVER a standard pants texture.
I thought it was from either AuthenticZ or ClothesBox; haven't used either of those for a while, but I just tried them again and neither one appears to have a visible belt option -- I mean just a simple texture-painted-on-the-player-model belt, not a holster or rigging or an added model.
I was hoping to play around with it and see how whatever mod I had been using had accomplished having your belt be visible, but I can't find it! Anyone know what I'm talking about / what mod I'm thinking of so I can look at its code, or alternately, know how I would accomplish making a visible belt that appears over your pants on my own?
(I know the vanilla xml defines an emptytexture and I can have it call for a visible one, but I can only ever get it to appear UNDER all the clothing, directly on the character's skin)
oh i suppose i could define the bodylocation as torsoextra...? but then i'm stinking up that slot.
You could use a slot noone pretty much uses, for example one of ring slots. I wanted to make a watch not be hidden when wearing longer shirts and jackets (it was pocketwatch that was hanging on side of pants). When i used vanila locations for watches, the model was hidden once you wore something "longer", but the moment i put BodyLocation = Right_RingFinger, it was working perfectly fine and was above every other layer of clothing.
that makes sense and is probably what I'll end up doing, thanks-- I certainly remember it being in the "belt" slot in whatever mod was making it happen, though. Strange!
Is there a reference file that shows what body slots take preference over the others for visibility, like how pants will always appear over shirts?
That sure would come in handy, I went with trial and errors on this one.
I think you can create your own body location, but i'm not familiar with it
ah well, thanks!
ooh handy! thanks
your example derives from an existing class, but what if I just want to use the built in panel instead of deriving my own?
require "SUI/ISPanel"
local function onGameStart()
if getGameFrame():getActiveScreen() == MainScreenState.getInstance() then
local screenWidth = getCore():getScreenWidth();
local screenHeight = getCore():getScreenHeight();
local blankPanel = ISPanel:new(0, 0, screenWidth, screenHeight);
blankPanel:initialise();
blankPanel:instantiate();
blankPanel:addToUIManager();
local button = ISButton:new(0, 0, 40, 40, "hello world", blankPanel, nil);
blankPanel:addChild(button);
end
end
Events.OnGameStart.Add(onGameStart);
this doesn't seem to work for some reason.. also why blankPanel:initialise() and blankPanel:instantiate() instead of only calling one? and why pass panel to button ISButton:new() as an argument while also doing blankPanel:addChild(button) shouldn't one of the 2 be enough?
FYI, requiring SUI/ISPanel is not needed and in fact would not work at all because it's ISUI/ISPanel (and ISPanel is available without importing it). Friend might have a typo if that's what their code says. I haven't looked at it in awhile.
I do not recall testing whether both initialise and instantiate are required. I think that was likely copied from some other vanilla panel that did both and assumed to be necessary.
Good question about addChild; I'm not home so I cannot confirm whether that is actually unnecessary right now.
@dawn portal
If creating a new ISButton with those commands will call panel:addChild(self) on provided panel where self is the button, then that is probably not necessary to call again
I'd check ISButton:new to confirm
Im doing the items_distributuion lua code... do I need the isShop = true for all the shops? Or is it ok how I've done it? I dont want to use the procedural distributions tho.
that's crazy
Yeah, it's a big project I've got in progress right now. That vid is only the tip of the iceberg
You should see this framework I'm putting together, it's turning into something else lol
can I set the sound radius of a vehicle idle sound? like I want the sound to carry a little farther that normal
not the engine loudness that affect zombies but the distance from the vehicle the actual noise is generated
@dawn portal Okay initalise calls this:
function ISUIElement:initialise()
-- FIXME: need to avoid calling this method more than once, ID changes
self.children = {}
-- Give each UI element a unique ID.
self.ID = ISUIElement.IDMax;
ISUIElement.IDMax = ISUIElement.IDMax + 1;
end
instantiate does this:
function ISUIElement:instantiate()
self.javaObject = UIElement.new(self);
self.javaObject:setX(self.x);
self.javaObject:setY(self.y);
self.javaObject:setHeight(self.height);
self.javaObject:setWidth(self.width);
self.javaObject:setAnchorLeft(self.anchorLeft);
self.javaObject:setAnchorRight(self.anchorRight);
self.javaObject:setAnchorTop(self.anchorTop);
self.javaObject:setAnchorBottom(self.anchorBottom);
self.javaObject:setWantKeyEvents(self.wantKeyEvents or false);
self.javaObject:setForceCursorVisible(self.forceCursorVisible or false);
self:createChildren();
end
So I would definitely recommend both as they seem to have very distinct purposes.
Also, ISButton:new never uses blankPanel to call blankPanel:addChild so I would have both of those lines as well.
ah yes, the tunnel bore tank
nah but for real I got fence destruction to work. just need to add signs in
I did this ``` elseif instanceof(obj, "IsoObject") then
-- Check if the object has the specified tile properties
local tileProperties = obj:getProperties()
if (tileProperties:Is(IsoFlagType.HoppableN) or
tileProperties:Is(IsoFlagType.HoppableW) or
tileProperties:Is(IsoFlagType.TallHoppableN) or
tileProperties:Is(IsoFlagType.TallHoppableW)) then
vehicle:playSound("VehicleHitTree")
-- Check if the object is a building component
local stairObjects = buildUtil.getStairObjects(obj)
if #stairObjects > 0 then
-- If it's a stair object, destroy it
for k = 1, #stairObjects do
if isClient() then
sledgeDestroy(stairObjects[k])
else
stairObjects[k]:getSquare():RemoveTileObject(stairObjects[k])
end
end
elseif not tileProperties:Is(IsoFlagType.solidfloor) then
-- If it's not a solid floor tile, remove it
if isClient() then
sledgeDestroy(obj)
else
k:RemoveTileObject(obj)
k:getSpecialObjects():remove(obj)
k:getObjects():remove(obj)
end
end
end
end```
I'll try that when I can, thank you for your help!
Nothing to try above, just answering your question from earlier about why you see initialise and instantiate, which sound like they might serve the same purpose but afaik do not.
trying to figure out what tile property for road signs
oh I see, sorry I just glossed over the code. don't have access to my computer. I guess calling one should be enough. as far as I'm familiar with other software usually something like "initialize" or "init" is enough, it feels weird having 2 functions do the same thing pretty much
If you read my messages you'll see that calling one is probably not enough.
They do entirely different things despite similar names.
Making some textures but the ear seems to be staying the same color
Any idea why?
k:RemoveTileObject(obj)
--k:getSpecialObjects():remove(obj)--not needed, included in k:RemoveTileObject(obj)
--k:getObjects():remove(obj)--not needed, included in k:RemoveTileObject(obj)
yeah I'll take those out, but I'm more interested in figuring out how to get signs and roadblocks to be affected
are you using the ingame chunk debugger ?
nah I actually forgot to try that lol
it is fire π
I'll check it out
it's not elegant, but it does the job!
I think the distributions is working... they're still craftable tho
Why do you not replace the fences with the broken down versions ?
The UV is probably elsewhere
Check where the base model UV sets the ears
I dunno just the way I did it. I took the code to break everything and then used the is hoppable property to filter out everything else so it just breaks the fences
so it breaks every kind of fence even like chain link and stuff. Also like the military fences and sandbags because I used the nothoppable tile property too
thats how I had it as a tunnel bore too because that was just the function without the filters
I guess I could probably use destroyFence()
Ok I checked using the damage decals
The back part of the ear is a ways above the front of the ear texture
Probably gonna have to go through a few of my textures to fix the mistakes from that
Really need to figure out how people do this in blender
is the ear a separate object from the head? I'd think you'd be able to import the mesh and check the UV map
do what?
No that's probably not it, just it probably links somewhere else in the UV texture
you think maybe both ears share the same UV?
No that's not what I meant
Just the place where you think it is, isn't actually the place where the texture is
does anyone know why my mod no longer be picked up off the wall?
I'm getting "testnill" in the debug window, and lots of them.
It worked when I tested right before i uploaded to the workshop
Did you put a print in lua ?
Textures
I would prefer work on a 3d model instead of a 2d image
Everything stretchs out so sometimes like with the ears it takes a bit to find where a texture molds over the model
The issue is that I'm not sure if you can access the current UV map of the model of the game
You'd have to find the folder where the model of the zombies are kept
I'm near certain its kept in the models_X folder
I can find a kate in the models folder
No bob
Only place both are is in the animation folder
What do you mean by a print in lua?
DerGeisler did some great detective work and suggested putting HGW.[itemname] in the tile definitions and it fixed everything.
π
I'm not familiar with script files and how they work exactly
But that looked like something printing in the console and all I know is that comes from a function printing it in the log
oh ok... no I didn't put any print lines in anywhere... i'm not good enough for that stuff yet π
np
is weird why it's doing that tho. not seen it before. so long as it's not killing anything, i guess it's not a biggie
Hello, if anyone could help me I'd greatly appreciate it.
I am trying to add a multi-barrel shotgun, but the double barrel reload animation is fixed to show the character loading two shells. I have found the vanilla reload animations (LoadDblBarrel.xml and LoadDblBarrelSawnoff.xml) and attempted tweaking them to no avail. When looping the animation, the character simply loads 2/x rounds every time you reload until full.
I have also found the Bob_Reload_DBShotgun_Load.X file though it is very large and I have no idea where to look/what to tweak. (I opened it in Notepad++, though I am sure that is not the correct way to open that file).
Please @ me/reply etc if you are able and willing to help! Thanks in advance!
I might release my traits and professions mod without multiplayer support and then support it on the next update, you guys think that's fine?
Could be fine yeah but eh
You could just wait and finish it fully ?
But I get the impatience, I'm currently holding myself from sharing my zombie framework lol
Fine is relative, but I would also wait until I finished MP support if it were me. Besides, I can't imagine it even needs much if it's a traits mod... Most stuff would presumably be done clientside with player mod data...
Unless your traits add lightning bolt attacks
That's heat, I'm a big Hl2 fan so can't wait to see more, I'm a concerned citizen 
I can't read lol - reposting here, triyng to replace the baseball bat model with a custom made .fbx model and im getting this as a result. Anyone know what could be the cause?
that looks like a scaling issue. You will mostlikely have to scale your model down quite a lot
see I thought i did, I matched it to the original model
I am no blender pro, so take everything with a grain of salt of course π But you have a texture and the game is loading something that it thinks is your model. So I would bet on scaling
from my experience, not making sure that multiplayer was properly supported from release really impacted its success. i got a lot of questions about multiplayer early on and by the time i added support i haven't gotten a lot of feedback on whether it is working or not or if people are enjoying it now
at the same time tho, more people tend to comment if they have a request or a complaint. so the fact that no one is commenting anymore is also a sign that the mod is good enough for most people
If I were to add MP support right now before its first release then how would I test it by myself?
No easy answer... I test as much solo, then rent a server to test it there. To verify moddata transfer I just load in another character and sometimes I just need another player. If you have a server and need a body for testing, let me know when I am online. Sometimes a proper failure only comes out when 3 people are online, etc...
Sometimes I just need to wait a couple of days to get a friend that knows the exact test I need to run to hop on and try it. Some people have had luck with a local server and multiple copies of PZS running at once in different windows. Never could get that to work.
Is there a way to re-add an IsoLightObject with addLamppost() that doesn't involve hooking into the LoadGridsquare event? I'm trying to persist one between server restarts
if you play with the game in non-steam mode you can just run two instances and connect to yourself
Nvm, I just went with LoadGridsquare after all
.exe and steam shortcut?
Ah, wasn't there x64 and x32 versions?
a steam copy always launches using steam by default, use the -nosteam launch parameter
I never ended up releasing this. With the popularity of the source material now, would there be any interest in me finishing it and releasing it?
YOU'RE DOING YOUR PART
Hey guys: Very basic question - how do you search through lua files? When I use windows searchbar, it cant find lua files, neither search through their contents, as it would do for txt files
In the windows search you can do *.lua and it will find any lua files.
The asterisk is a wildcard. I think you can even use it for partial words, but I don't remember rn
That is working! Awesome, thank you!
ask someone to run a test with you.
Use vs code
Index the folders with the Lua files and add Lua to indexed filetypes.
Hey guys, I'm creating a custom weapon which should have infinite ammo by default. I created the weapon, defined a magazine, but how can I actually make it spawn directly with the magazine inside of it and without the bullets depleting on everyshot? The only thing I could, at the moment, was to spawn a clip with max ammo=999 and add 999 bullets into it, but that is kind of tedious to do.
@austere sequoia https://www.geeksinphoenix.com/blog/post/2022/05/15/optimize-searching-for-files-in-windows-10-and-windows-11-using-indexing-options
Can this be done through scripts or should I make a .lua for it?
thanks, I will have a look at this!
Hey, quick question
I want to try making a simple mod that allows you to unbutton the formal shirt
Like, wear it open collar
But the thing is, I donβt know how to go about that. I know you can just make another texture, but switching to that alternative texture in game in the same way you can with Spongieβs is what Iβm trying to figure out
Well first off, in terms of coding, just check how Spongie does ir
Secondly for the models, you will have to learn how to use Blender and texturing in it, as well as modifying models
Oh wait I thought it was just a texture
If it was a jacket Iβm sure Iβd have to use blender
But IIRC if itβs just a regular shirt it should just be as simple as changing the texture
Or, to be more specific, changing the item ingame as youβre wearing it
Idk how shirts are handled by the game but you can change the textures of the shirt yes that's possible
Tho is just changing the texture enough ?
So you could change it from Formal Shirt to an item called Formal Shirt (Open Collar), which would change the texture of the shirt youβre wearing by making it an alternate item
I presume the way you do it is crafting it in Spongieβs
so when you right click on the shirt, you craft it into the alternative variant of it, being a different item.
That different item only being the shirt with just a texture change.
π for heavens sake i wish i knew how these new doors worked, i dont want to make door tiles just to have them not be usable in build 42
Spongies Mod (https://steamcommunity.com/sharedfiles/filedetails/?id=2812326159) already contains various open shirts.
However, if you like to make your own version, here is one possible approach where I assume you'd like to arrange things so that you can unbutton your formal shirt via right clicking on it and then selecting a new option:
-
Edit your clothing item and bring it into game. (Either using blender and making a 3D model or just edit a texture depending on your likening. Vanilla formal shirts are just textures). The unbuttoned version of the formal shirt will then in fact be a new clothing item.
-
The vanilla game contains a .lua file lua/client/ISUI/ISInventoryPaneContextMenu.lua. There the function createMenu() generates the menu which appears in game when you right click and item in your inventory. Add an option for opening your formal shirt (and maybe for closing it again in case it is open...).
-
When the option has been clicked, simply exchange the default formal shirt with your edited one. A typical way to achieve is is using a TimedAction (TimedActions are also used by the vanilla when you exchange clothes for example).
-
In step 3, you might like to transfer all properties form one shirt to the other For example, when the worn shirt has condition 50%, the opened version should probably also have condition 50%. Similar things might apply to dirtiness, bloodiness and other attributes a clothing item can have.
Oh yeah, makes sense
Iβm not familiar with LUA however so Iβll have to figure that out as well
When I speak about unbuttoned though I only mean so the collar is open
Ah ok. Then it is different from what Spongie did. My bad. π
Anyway, the overall strategy I outlined would still apply to your case (may still be there are better way to do this... it's just one suggestion).
Some lua coding for the approached I outlined is necessary and I doubt that your mod project could be realized without any coding...
Agreed
Though, it shouldnβt be very difficult to do in the first place
Since, it is indeed the same as the way that it was done in Spongieβs mod
Might not be an entirely good practice, but I could just take what was done in Spongieβs and just copy it over
Iβd want this to be an add-on that just adds yet another way to mess with the shirt
You don't even have to do maje a whole new item I think
You wouldnβt?
You can in fact just use textures
Items have texture variants and there's an easy way to swap between those I believe
Hmmm
That is a good point actually
Having the collar open wouldnβt change any of the protection values or how insulating the shirt is
Didn't knew that changing textures of clothing in game is possible. Then this could simplify things...
Yeah
Only thing though it has to be changeable ingame, not in character select
Like, by right clicking on it and stuff
this coud still be realized by some lua coding. even if you just exchange textures somehow
Hmm, hopefully
it would just be a mostly cosmetic exchange as well, unlike opening the shirt or rolling up the sleeves
Iβll see what I can do but I donβt know how I could do that with LUA coding because I donβt know how to code with Lua
Most modding Iβve done was map modding but thatβs it
Yes that's still doable
If you want more in-depth help:
https://discord.com/channels/136501320340209664/1125248330595848192
I will just point you towards your solution:
-look for itemVisuals
-look for commands you can apply on clothing items
-check out how to make custom menus for items
(context menu)
Though, one extra thing
I do want it to be compatible with Spongieβs
So youβre able to have the unbuttoned collar with rolled up sleeves and such
You're changing the same items than Spongie does ?
You can definitely make it compatible, in fact the texture change could make it even more compatible since Spongie might not use that but I have no idea how he handles his stuff
But IIRC, I donβt think Spongieβs replaces the collar shirt, only lets you change it into different variants
Itβs handled via crafting I think
You'll have to look at how Spongie does it bcs then you could just make your mod an addon to his own
Yes but if he adds new items, models, textures or else
I think so
From what I know, you right click on the shirt (either while youβre wearing it or not), and choose what option (rolled up sleeves, open, etc) and then you change the shirt to that variant
Usually via a timed action
And the shirtβs name usually something like βFormal Shirt (Rolled Up)β
Itβs either that or what was outlined here
It could possibly be what Razab said as opposed to just crafting since when you change shirts, the animation looks as if youβre putting something on
Hmmm.... in case you'd like to have a shirt which can be unbuttoned (from your mod) and rolled up (from Spongie's Mod) at the same time, I guess you have to make a texture for each possible case, so one texture for "only unbottned" and one texture for "unbottened and rolled" and so on... Can't imagine how this will work automatically...
Way I was thinking was adding 2 more options for when you change the shirt
When you right click for the shirt on Spongieβs, the options are:
Rolled up
Open rolled up
Open
Closed
Yes wow incredible but I just described to you at least 10 different ways to do it lmao. You'll have to go look at his code in depth
I understand
You could possibly to it in an even more fancy way but it all depends what he does in his mod
You'll just have to look at how he does it and be smart on your way of doing it
Thatβs fair
Either way, it shouldnβt be too hard itβs just adding 2 more variants
Or 4 if you count the colored shirts but I donβt think I want to mess with those
Be it the way you described it. The issue is if he uses models, you'll have to make models unless you create textures for all his model variants or if he uses textures then do the same
whoops... I meant "unbottened and rolled up" in my previous comment. "unbottened and opened" make no sense XD Edited
Don't shirts use models ?
Shirts are just textures from what I know
yeah. just textures here
So in theory it should be very easy then
From what I see, Spongie seems to use some APIs for adding new options like "rolled up" in the UI. Maybe you could also try to use them. This could make it easier to make the mods work together as you like it
Thatβs what Iβm going to try doing
Me waiting for the moment he realises it is, in fact, hard asf to do

Thatβs why I said βin theoryβ
In reality it is just adding two extra options for when you change the textures in Spongieβs so
Oh yeah spongie has an api in a separate mod no ?
yeah. spongie requires in fact two API mods and the functions of those seems to be to simplify adding custom options for clothing items (among other things)
they are set as requirement in spongies mod's steam page
But they do seem to add the option
using those API mods usually comes with advantages and disadvantages...
Like?
If my mod is an addon for another mod then it being dependent on other mods isnβt much of an issue
Advantages: 1. You may not need to write too much code since you can simply use some predefined functions from the API.
2. Since Spongie seems to use them, just using the same APIs may make it easier to make both your mods work together nicely.
Disadvantage: 1. If the APIs contain bugs, your mod might also be malfunctioning and your are completely dependent upon the API's creators and wait until they fix them (which might happen quickley, slowly or never). Even worse, the authors could also remove them from the workshop.
2. An update of the API could require you to update your mod too.
3. Modlists of users get longer (= more annoying mod management)
ya... it's just a matter of personal preference. Totally fine to use them but also legitimate to try to avoid them.
heya, i want to make my first ever project zomboid mod, where should i start?
Alright
Iβm gonna see how I can utilize the API
Not that I know how but having access to it for what Iβm trying to do really does simplify things
Some nice basic infos can be found here: https://github.com/FWolfe/Zomboid-Modding-Guide/blob/master/api/README.md
but really depends on what you'd like to do...
if you want to make your mod dependent on spongie's, then it will automatically be dependent on the APIs which spongie has as requirement. so you might not loose anything by using the APIs too
Thatβs the plan
thank you so much, im also reading the modding part in the wiki, i just want to add ambience music for now, maybe later i'll do something harder!
Well Iβm gonna figure this out later when Iβm back on my desktop
Came a long way from making map mods π₯Ά
Any ideas on how to play sounds/music to the client so that other people won't hear it?
Run it client side only for the player ?
assuming you're already using a sound emitter and you're just trying to stop it from networking, the -Impl methods don't get networked automatically, whereas the ones missing that suffix do
Or send command to a specific player
That's what I'm trying with the getSoundManager() but maybe I'm using the wrong function
Oh ok, I'll look into using those. Thank you albion!
hey folks - back at it again, figured out my first problem and it definitely was scaling, I wasn't applying the scale or exporting right lol. New problem, it looks like the textures are using the default baseball bat despite me changing it in the games folders, is there anything I'm missing?
nvm figured it out - I thought textures would update automatically but that's just models lol
What is the most up to date/commonly used .pack unpacker? I'm trying to unpack a mod for troubleshooting a minor compatibility issue. (Trying to see what Plain Moodles looks like.)
The one I found and used (Zomboid Pack Manager 1.0) did not seem to work.
@jagged fulcrum knows
And neither has PZ UnPacker
hey I found the answer to this: the Shared NPCs Bodylocations lua IS an order-of-operations list. I moved, for instance, "shirt" ongenerate to come after "pants" and now my shirts are "untucked" and visible over any pants textures (models excepted)
so the order each category appears in that file's generation list is the order it "paints" the model, and you can directly change it by cut and paste
It's a rather minor issue. Basically it looks like they scale poorly due to how they were made, but I just want to check if what I think is the issue is correct.
Thank you very much!
π
Oh interesting, thank you very much! It looks like my assumptions were wrong, and they should scale fine, but the API I'm using might not be properly expecting the change in size.
Is it possible that the mod is improperly scaling the images down in game, due to how they're packed? They seem smaller than vanilla, and have some blurring that reminds me of bilinear scaling.
Next to the yellow line, do you see the slight bleed?
You gotta squint since it's quite small. π But it becomes obvious with my mod that makes moodles resizable. I can see it though. And it looks different than it does in the files.

It seems to be an issue with how the game is scaling them, possibly due to them being 32x35, instead of 32x32. Though that resolution seems mostly necessary to properly position the heads.
The background looks a lot sharper in the base image... π©
Wdym the tiles are the same size?
How do you check this information? I'm using TileZed as well, which I think is the same thing.
Since it says Tiled at the top.
Ah yeah I'm in the pack viewer.
Just didn't see that additional information.
π

i remember chuck having some issue with non-vanilla textures scaling differently? but maybe i'm conflating something
God damn it. π€£
Thank you so very much. I didn't realize how much it compressed them. I'll be sure to tell people on the mod page to turn that off. π
The texture compression was it, also the max texture size impacts textures abnormally.
Or I could be misremembering it, I think I wrote a bug report a while back.
Hello, I'm curious about updating my mod that added food variants and distributions to the world, and there is current subscriber an ongoing multiplayer server. Is it safe to do?
Just cut and paste will overwrite the vanilla body locations and all manipulations done to body locations by mods which are loaded before yours making them incompatible. To solve the issue, you can backup all body locations in a lua table, reset the vanilla locations and restore them step by step. You can then apply your changes during the restore process. You also have to back up all infos related to body location like "setHideModel" and stuff to make it work properly.
In every case, server owners have to restart their server to make the update effective. Before the server restart, players are not able to login to the server.
In most cases, updating a mod should be completely safe for singleplayer as long as your updates are save game compatible.
In case your update is not save game compatible, single player as well as servers must start a completely new game.
For the thing about the food distribution, you should note that your update may not affect parts of the game where the items have already spawned. But this depends on what exactly your mod and the updates do.
Do you by any chance happen to know how to fix when only a part of the files are indexed? I made windows index lua, and made it index my PZ folder. When I search I rarely get luas searched including their content, what leads me to believe that in principal everything is working. But then it seem like it only indexed a fraction of the lua files, since some others cant even be searched for by their names
Next best option that is coming up to my mind would be wiping all of the indexes, so windows has to start from scratch. But I would prefer not to delete system files, lol
I also got the most windows notification ever trying to fix it: "Problem manager can not be started due to a problem" lol
Uhhh I just followed the instructions and added Lua to the filetypes indexed, and made sure it selected all folders and subfolders I wanted it to search. Didn't delete any index rules, just added my own for the folders where I want to search for Lua in addition to everything else.
dang it... I will keep trying around until it works then π
It does take time...
You're sure it finished indexing right?
Took a fair chunk of time to index ProjectZomboid e.g.
it says "0 files left to index", so I'd guess. I just found the button to restart all the indexing on my PC. Will take some time (900k files), but should work hopefully
you can just open the lua folder with your ide and search it there
ide?
the program you use to edit code
the editor can search my files for the contents of lua code? oO
That's was Jvla originally suggested, too. I was just directly answering the question about why Windows search wasn't searching what you wanted it to search. When Jvla said use VS Code they meant open folder in VS Code and do folder search.
Ctrl Shift F unless I changed the default and forgot.
I can do Ctrl F when I have files opened in Windoes Editor. I somehow get the feeling that we are talking about different Editors.
What do you use?
I also use VS Code. But I frequently do Windows searches because it's more convenient than opening a folder in VS Code every time I want to search it.
If by "Windows Editor" you mean Notepad, only masochists and people who lack experience code in Notepad.
Booooo Notepad
(I'm joking, you're allowed to like Notepad, but I would need to be masochistic to want to use it over a proper editor.)
I might possibly fall into the first category, most definitely into the second. Notepad worked fine so far though xD
With VS-Code you mean Visual Studio, what is preinstalled in windows?
VS Code is Visual Studio Code, an app in the VS family of programs.
it's pretty lightweight and user friendly, even if you don't know how to use many of its features it should be a far better experience than notepad
got it! Thats awesome, thank you to both of you! I am still new to programming, so I dont know shit
Good luck!
That is sooo much better than opening each file by hand in Notepad and searching it for specific terms xD
I love it already
Lmao yeah
There is an open folder shortcut too and by default the shortcut is absolutely awful if I remember right
Idk I make it Ctrl Shift O and take other shortcuts off of that
Is it Ctrl K O by default? Idr but it feels bad to me
ctrl k o, yes π too complicated
Yeah oof I changed it
keyboard stuff can be rebound in menu
I prefer ctrl O for file ctrl shift O for folder personally.
I think VS Code defaults use ctrl shift O for switching focus to open files and also jumping to things in open files
Which can be useful sometimes but doesn't feel like it belongs on ctrl shift o to me
Yeah, I guess I will find my optimal shortcuts by playing around π
Hi! I have a situation where I have to use identical auxiliary functions in different .lua files in my mod's cient folder. Performance wise, it is a good idea to copy-paste the auxiliary functions and put them as local functions in the respective .lua file? Or is it better to make only one version for each auxiliary function, set them global and just call them in the different .luas whenever I need them?
You can easily code without using the mouse at all in VS Code
Plus, assuming you're not running Win 11, VS Code has a dark theme so you don't go blind
the dark theme definitely has its benefits over notepad!
I had entirely forgotten W10 Notepad still doesn't have a standard dark mode... What garbage lol
I have W11 so even Notepad isn't that kind of terrible. White backgrounds. Oof.
So lets say I want to write a mod that changes one tiny thing in lua (somthing stupid like make the counterclock rotate key alt instead of shift), how would I replace a vanilla function (function ISPlace3DItemCursor:checkRotateKey in my example) with my own function? Just add it and it automatically overwrites vanilla function? Sorry for the super basic question, trying to fill my toolbox with some nescessities, lol
Yes but we usually try to avoid doing that at all costs. What people recommend instead is decoration, which involves override but doesn't completely throwaway original functionality and is therefore more compatible with other mods.
At least that works if the module is a Lua module and it's either global or you've required it successfully somehow.
You just want to rebind the checkRotateKey function? Is that your literal goal r.n.?
lua module - a lua file?
global - in the shared folder?
required - what exactly does this mean in this context? The "require "ISLUAStuff" "
Lua module = classlike Lua table.
Can be used either statically or dynamically in the instantiation of objects or the derivation of functionality.
Lua require = import
It means, "Establish this file as a dependency, make sure it has already run, and grab the return values it provides after it runs."
At least for testing and learning. If I can succesfully change a couple of characters, I will eventually change whole lines and then eventually add functions. at least thats the plan, lol. Thank you a lot for your assistance
You can catch them by going local ReturnedModule = require("ReturnedModuleFilenameWithNoExtension")
local is optional but considered good practice to keep the table of global variables (including modules) limited
@austere sequoia https://github.com/Zendachi/Wookiee-Tutorial-Party-Animal/tree/main
your answer is part of this.
Many other questions you'll have will also be answered there
oooh, thats awesome. I love the explanations!
u should consider instead of replacing the keybinds to just make those options bindable through modoptions or whatever is the most up-to-date alternative. that way you can update it for other keybinds you wanna change and still have it available if u host a server with friends who dont wanna change those binds
local is just the prefix "local"? How exactly does it effect how it works/is loaded? I would assume that global stuff is constantly loaded, local stuff only when certain parameters are hit?
idk what is currently bindable or not bindable, but i think anything that changes a keybind might as well just be an option (from client-side) instead of a full replacement
It really is not meant for any mod π I just want to start as tiny as I can think of: By changing a single key
The link I provided shows how to use Mod Options for a custom keybind
It also demonstrates function decoration
i see
It also explains modules
whatever burryaga sent is probably already more than enough info for a launching point
I mean simple LUA, I already did a couple of mods, also with tiles and stuff. Now I am trying to get into LUA, since without much of the stuff I want to achieve would lack elegance or even the potential to work in the first place
good luck!
Thanks π
It also may explain scope which is the answer to this question.
I am trying to find you a good link for the basics of scope but everything is overcomplicating it so I'll just try to tell you.
my first mod was just some traits that changed stats, and i kept branching out to more things i wanted/thought were doable
so i only slightly increased in ambition each time and made better and better mods
burryaga helped me make blackouts work in multiplayer and greatly optimized it, so you're in good hands
gn!
@austere sequoia Scope is the field of existence (or at least referenceability) for any variable define in any computer program. Often scope is indicated by keywords like then and end or special characters like { }.
good night!
The broadest of all scopes is the "global" scope. In Lua, variables are global by default. This means that if you declare a variable in file A.lua, and then that file loads, and then you try to access the variable in file B.lua, it will work.
And locals only work in file A?
and in the "require" files?
The next broadest scope would be files; if you declare a local variable at the root level of a file, it continues to be referenceable from any code that executes in that file after that declaration.
what is the "root level"?
Not in any function or module.
module or table
Modules are are just a kind of Lua table
Almost everything "fancy" in Lua is done using Lua tables, which are very flexible.
so those lone standing lines beginning with "local"?
aLuaTable = {
looks = "like",
this = "."
}
Right exactly. E.g. a lot of files have require lines at the top of their files which I would describe as running at the root level of the file, by which I just mean the outermost scope in that file.
as in where all the functions are I reference in the file?
Now as soon as you enter a table or a function or a loop or various other defined constructs in Lua, you enter new scopes, and locals defined there are only referenceable from within those scopes after they are declared.
Usually, yes.
Sometimes people define new functions within other functions.
I have seen that, yes
@austere sequoia Therefore:
function ayoooooo()
local x = 5
return "psych"
end
print(x) --> prints nil
I dont fully get this point. Could you give me an example? As I understood it: If I want to reference a local within a table, it has to be a local that is defined in another table?
See above.
What I'm saying is that a local in a function, e.g., does not "exist" for practical purposes (or more specifically can no longer be referenced) once you are no longer running commands in that function.
Ah, awesome! So I thought correctly. Sorry, I dont know a lot of the proper terms yet, so I have to translate your smart people language into my stupid people language π
Even if that function is global, its locals are limited to its own scope. ayoooooo above is in fact global because I did not tell it to be local.
No it's cool I wrote it the second before you asked.
I knew you would need an example
I am operating under the assumption that you, too, are human.
And this is alien speech.
it is not that easy to wrap ones head around, but I slowly am getting a picture. I am fine with "alien" speech though! π Got to learn it somehow
so what exactly would this example do?
So then, as I mentioned, loops and modules and some other things are also scopes, and you can have scopes within scopes within scopes where things come to exist and get recreated over and over. Each iteration of a loop, e.g., is its own scope.
Print nil in console.
because the label x would be interpreted as having the value nil (no value ever assigned)
Because the line local x = 5 was done in deeper scope than the file-level print statement
So the file-level print statement has no reference to it
!!!! But if you move the local line out of the function, it would work?
Correct.
the "--> prints nil" are your notes, not part of the code?
Keys declared in Lua tables are also being declared in their own scope. So if you do this:
local y = 5
local DerGeisslinAround = {
x = 3,
y = 4,
z = 7
}
print(x) --> prints nil
print(y) --> prints 5 (not 4).
print(DerGeisslinAround.z) --> prints 7
How would you make it reference the table?
print({y}) probably not like this?
Added that example
aaaaaah!!!!
tablename.value
because the whole table is a local. and we reference the locals
And you can also have functions that use this to make your code a bit simpler:
function getPlayerXYZ()
local player = getPlayer() --> Keyboard player, no good for splitscreen.
local x = getPlayer():getX()
local y = getPlayer():getY()
local z = getPlayer():getZ()
local xyz = {
x = x, --> The LEFT variable is a new variable, a key defined in the xyz table's scope.
y = y, --> The RIGHT variable is the variable from the scope of getPlayerXYZ.
z = z
}
return xyz
end
(This would almost certainly be a pointless function to have, it's jut an example for understanding.)
You could also reference them if they were globals. We just don't declare them as globals because there is a table of global variables that has a rather large number of globals already, and the modding community is making an effort to minimize that practice.
There is measurable performance cost in using global table references instead of local variables.
Especially for looping references.
one would think so!
So people try to encourage newbies to make their modules local whenever possible.
like redstone clocks on crack?
it basically is a never ending, continous circle that keeps ticking forever. That is what I believe a loop to be from what it sounds like. Stuff like checking for certain conditions to be met, probably
correct me if I am wrong, lol
Oh no
Loops are not neverending
Sorry I could not understand what you were asking for a minute
btw, off topic: is there a way to save/favorite this conversation?
A loop is a structure in programming that tells a certain process to happen repeatedly under certain conditions, but not necessarily forever.
Usually a loop that never ends is a mistake; in Zomboid, it would definitely be a mistake.
Only the main game is allowed to loop forever.
so it is never ending with an on/off switch
If you tried writing a loop that lasted forever, your game would freeze and crash.
Most loops are defined to happen a specific number of times.
A loop that is neverending until a switch is flipped is called a while loop.
for loops are more common.
Get the Cheat Sheet Here : http://goo.gl/0j15W0
Subscribe to Me: http://bit.ly/2FWQZTx
Best Lua Book : http://amzn.to/2yYX5im
βοΈ LIVESTREAMS : https://www.twitch.tv/derekbanas
βοΈ DISCORD : https://discord.gg/2dkDmpVvgD ( Contact Me Anytime )
MY UDEMY COURSES ARE 87.5% OFF TIL December 19th ($9.99) ONE IS FREE
β‘οΈ Python Data Science Series fo...
I always like this guy's language overviews.
Then here would be another good place to start learning fundamentals of programming (such as what people mean by loop): https://www.lua.org/pil/1.html
Keep in mind that his printing commands will differ from yours because it's a different environment
But a lot of structural patterns will apply
dude, I cant thank you enough π That is awesome help, opening some knots in my brain
One very helpful tool for learning Lua in Zomboid is debug mode. Are you using it yet?
For testing, yes. Do you mean that small window on the bottom left that always tells what is currently going on (looks like codestuff to me)?
Yes. You can also drop entire functions into it for testing, and just keep overwriting them and trying them differently, depending on the nature of the function
as in copy pasting them and the game runs them?
ahhhh, I get it
So, to give you a specific example, you wanted to decorate this:
function ISPlace3DItemCursor:checkRotateKey()
if self.chr:getPlayerNum() ~= 0 then return end
if self.chr:getJoypadBind() ~= -1 then return end
local pressed = isKeyDown(getCore():getKey("Rotate building"))
local reverse = isShiftKeyDown()
self:handleRotate(pressed, reverse)
end
yes, exactly. that is what I was looking at when I came up with the example, lol. I guess I would have to turn "isShiftKeyDown" to "isXKeyDown"?
to make it use the X-Key instead?
@austere sequoia In order to do what you want, you would really need to intervene in the middle of this function's process, but that would require decorating isKeyDown (which most would not recommend because that's a major global function that everyone needs to work correctly and quickly), or overriding (which again I would discourage). My favorite solution would therefore be to replicate a few conditional checks to figure out what the outcome will be, and branch as needed:
local DerGeisslinAround = {}
-- Container for any decorations of Indie Stone's Place3DItemCursor functions:
DerGeisslinAround.Place3DItemCursor = {}
-- Store reference to original function:
DerGeisslinAround.Place3DItemCursor.checkRotateKey = ISPlace3DItemCursor.checkRotateKey
function ISPlace3DItemCursor:checkRotateKey()
if self.chr:getPlayerNum() ~= 0 then return end
if self.chr:getJoypadBind() ~= -1 then return end
local pressed = isKeyDown(getCore():getKey("Rotate building"))
if not pressed then
pressed = isKeyDown(getCore():getKey("Your custom keybind name"))
local reverse = isShiftKeyDown()
self:handleRotate(pressed, reverse)
else
DerGeisslinAround.Place3DItemCursor.checkRotateKey(self) -- Call original function.
end
end
Lua note: : in the function signature is a way of passing "instances" around. Without going into endless detail, the instance gets passed as self. When you call your backup reference to original function, you don't use : notation on the object itself, so you need to manually pass self forward.
To understand more about what an instance actually is, you need to look into basics of object oriented programming.
what does "container for decoration" mean. I assume you dont mean pixelart.
Store reference to original function is the part that makes my function override the original function?
No you're saving a way to call the original function using a new label
I still dont fully get it
A function is called using a variable name that points to it.
In Lua, people (including me) often use the following notation for statically called functions:
MyModule.staticFunctionName = function(parameters, you, will, need)
-- stuff happens
end
Which emphasizes that MyModule.staticFunctionName is just like any other variable... like x in x = 5
and in fact if you then said x = MyModule.staticFunctionName, you could do this:
MyModule.staticFunctionName = function(parameters, you, will, need)
-- stuff happens
end
x = MyModule.staticFunctionName
x(parameters, you, will, need) -- stuff happens
That's what you're doing... you're saving the original function inside of a new variable.
Then you can redefine the MyModule.staticFunctionName to refer to a new function that does new stuff, but x will still do the original stuff.
MyModule.staticFunctionName = function(parameters, you, will, need)
-- original stuff happens
end
x = MyModule.staticFunctionName
-- parameters, you, will, need assumed to exist
x(parameters, you, will, need) -- original stuff happens
MyModule.staticFunctionName = function(parameters, you, will, need)
-- new stuff happens (original stuff overridden)
end
MyModule.staticFunctionName(parameters, you, will, need) -- new stuff happens
x(parameters, you, will, need) -- original stuff happens (still)
Might take awhile to sink in fully. You have to mentally separate the function itself from the label used to call it. Colloquially we often refer to ISPlace3DItemCursor.checkRotateKey as a function, but technically speaking it's a label that points to a function. The function itself is just data at a memory location, like the number 5, or "bob".
That I understand π
Okay good good.
Well then yeah you just gotta see how the function data continues to exist as it is in its original location even if the variable that originally pointed to it is told to point to a new function.
That's the whole trick of this decoration.
so that way I can specifically overwrite certain parts of functions?
leaving the rest of the function untouched
Sort of. Technically you're adding behavior external to the original function
I didn't actually change anything about original function; I just don't call it if the key was wrong.
if this behaviour collides with behaviour already present in the function, as what rotation key is used in the example, would this override the original function? Or would I get an error? or would both keys work?
Both keys would work
In my example
Because it doesn't call the original function if it's not the original key
ah, I get it. Now it makes sense
And it doesn't call crucial lines of the new one if it is
If I run into problems in the future, may I ask you for assistance?
Looking for testers for Expanded Heli Events: #1215626507846688808
Trying to figure out how to do this whole testing thing. I personally should be home around 5-6 EST. But the test requires no group participation, mostly seeing if events are wonky, if the sounds are good, etc.
can i use getModData
to save persistent table?
to keep data stored, when loading a save again
will the debug menu throw you an error on functions too? So you know which portion of the code is not working.
It'll give you line numbers but they're a bit tough to interpret because they'll be relative to the first line in the chunk you enter. And if you enter a function with a runtime error it'll give you the usual error message for that exception.
For a ton of things, yes, it can save a lot of time
Sometimes it's just not worth the effort to avoid a restart, but if you just need to test a utility function with data that you can either fabricate or scrape using another function, it's much quicker.
You can also test functions added to events if you globalize them or their modules first and then remove them from the event before you overwrite them
(and then add them again after overwriting)
I've done this often when doing context menu stuff.
the point is that I'm trying to spawn a custom gun with infinite ammo, I don't want to have infinite ammo on everything, just on this one but to do it I need to find this weapon in the inventory and then permanently keep the clip size to the max.
The problem is that the documentation seems to be obsolete, so maybe I can find some information directly through debugging.
@steady lagoon I would add a function to OnEquipPrimary and grab item for a global variable as you equip it
(then explore global for opportunities)
Do I need to import those external libraries into my custom lua script or can I just call those events directly?
Events.OnEquipPrimary.Add is global
Reason: Bad word usage
how can i store table, or table values in moddata?
and load it when game starts again (load, continue)
I'm looking for the section where the maximum weight the character can carry is recalculated when he gains a level in STR, but I'm a little lost in the files, can anyone guide me?
hello guys is there an event to check if you shot with a weapon?
you can use:
Events.OnPlayerAttackFinished.Add
just found it
it's better and is more graceful than onEquipPrimary
onEquipprimary is triggered on unequips as well
and you need to deal with Exceptions there
True
Check the weapon in your hands is the correct one
local function OnPlayerAttackFinished(character, handWeapon)
-- Your code here
end
Events.OnPlayerAttackFinished.Add(OnPlayerAttackFinished)
I'm looking to ask a few questions to a modder regarding player currency, specifically with Shops - Noir. If anyone is familiar with it, that has a few moments to break it down for me, please let me know.
Good morning, friends.
I am creating a new map for Project Zomboid, and I've successfully completed almost everything. It's working perfectly in my game, but there's one issue: I don't know how to enable the map when I press the "m" key (the minimap). Can anyone provide assistance with this?
Thanks in advance.
if i start working on a custom map for the current build, will it carry across and work on build 42? or would i be better off waiting?
assuming most mods are gonna break too
I understand, it's indeed a good idea for those starting a new mod. However, it's a pity because I've already done everything on the map; only this minimap is missing. I just wanted to finish it since no other errors are occurring, only this one.
making it local is slightly faster but doing it that way is a nightmare for maintenance, you don't want to have to remember to fix a bug in 5 different places - you can make these functions global and then pull them into the local namespace just using local myFunc = myFunc, or preferably use a module
Example of what Albion is talking about with vanilla functions
--- Import functions localy for performances reasons
local table = table -- Lua's table module
local ipairs = ipairs -- ipairs function
local pairs = pairs -- pairs function
local ZombRand = ZombRand -- java function
local print = print -- print function
local tostring = tostring --tostring function
pulling in members of the tables is also slightly faster```lua
string.gmatch(...) -- slowest
local string = string
string.gmatch(...) -- faster
local gmatch = string.gmatch
gmatch(...) -- fastest, but not by much
i found tks π
https://www.youtube.com/watch?v=wITXnrBuoA0&ab_channel=CatRaven
This is a tutorial on how to update your in-game map system in project zomboid. I hope that this video offers you some guidance and clear directions on how to. The original written instructions can be found here:
https://theindiestone.com/forums/index.php?/topic/43627-how-to-update-your-map-mod-to-work-with-the-new-in-game-map-system/
For the k...
Reason: Bad word usage
item Hat_BaseballCap
{
DisplayCategory = Accessory,
Type = Clothing,
DisplayName = Baseball Cap,
ClothingItem = Hat_BaseballCap,
ClothingItemExtra = Hat_BaseballCap_Reverse,
ClothingItemExtraOption = ReverseCap,
clothingExtraSubmenu = ForwardCap,
BodyLocation = Hat,
IconsForTexture = BaseballCapRed;BaseballCapGreen;BaseballCapBlue,
CanHaveHoles = false,
ChanceToFall = 60,
Insulation = 0.10,
Weight = 0.5,
}
isnt it "clothingExtraSubmenu"?
could also be "ClothingItemExtraOption", I dont have the game in english, so I cant check right now. But in your files it should be called "context menu_downhoodetc....", so you should be able to recognize it
try it π If it works for baseballcap, it should work for your hoodie
It it working?
Thats great!
@mellow frigate Hope it's alright for me to ping you! I'm working on a mod to work with MoodleFramework, and I'm running into a weird issue with MoodleFramework. If a user loads in with the scale set to 1, and then sizes up a moodle, everything works as expected. However if a user changes the moodle size before loading into the game, moodles using moodleframework are offset on the x-axis.
Example:
The code:
local LuaMoodles = require("StatsAPI/moodles/LuaMoodles")
local old_adjustPositions = LuaMoodles.adjustPositions
-- Set the default moodle size.
local RvMoodleScale = 1
-- Check for MoodleFramework
local modInfoMF = getModInfoByID("MoodleFramework")
local MFenabled = 0
if modInfoMF and isModActive(modInfoMF) then
MFenabled = 1
require 'MF_ISMoodle'
end
-- Get the moodle scale from MCM
if Mod.IsMCMInstalled_v1 then
-- initialize the main mod option table
local MyModOptions = ModOptionTable:New("ResizableMoodles", "Resizable Moodles", false)
-- Add options
MyModOptions:AddModOption("RvMoodleScale", "number", RvMoodleScale, { min = .1, max = 10, step = 0.001}, "Moodle scale", "The multiplier for moodle size. Default is 1.", function(value)
RvMoodleScale = value
LuaMoodles.adjustPositions()
end)
end
-- Adjust size
LuaMoodles.adjustPositions = function()
LuaMoodles.scale = RvMoodleScale
if MFenabled == 1 then
MF.scale = RvMoodleScale
end
old_adjustPositions()
end
Even if I delete everything and just use MF.scale with no other settings, setting it above 1 and then loading in causes issues. It's really weird... Since your Bigger Moodles compatibility script doesn't seem to have the same issue.
I do not understand. Are you creating another scale factor than the one froml StatsAPI ?
No no, that was just a troubleshooting step I tried to see if I could find the issue with my code.
What do you want your mod to do ?
Allow a user to resize their moodles.
But to a scale of their choice
Vanilla moodles work perfectly. MF moodles work if they load in with a scale of one, and then upscale, But if they start at a higher scale, the issue arises.
and did I understand correctly that the problem does not occure with Bigger Moodle ?
Yes that is correct
I've tried looking through the code to see what's different but it seems like it's functioning the exact same.
except that it is not changing over time.
I think the point is to choose the size once and for all.
Still... I would think if that was the issue, then it would load in correctly, and break on an update. But instead, it breaks immediately upon load in.
what breaks ? wasn't it only shifted on Y axis ? ?
what is load in ?
If you load into the game with a scale of 1, then change the scale to anything else, nothing is broken. Both vanilla and MF moodles work flawlessly.
If you load into the game with a scale other than 1, Vanilla and MF moodles are scaled properly. Vanilla has no issues, and MF moodles have a strange x offset.
As demonstrated here:
how do you change the scale after loading ?
Once the scale is changed, it fires LuaMoodles.adjustPositions()
so you are changing the scale after loading with an interface of your own right ? (I guess the function from modoptions)
Basically yes.
it looks like Moodle Framework would need to adjust the reference position of all moodles created before your changes.
π€ Is there a specific function in MF I could call to adjust it? It seems to be capable of doing it, and just isn't properly being called by my code?
Perhaps mine doesn't work because the value is set too early? So perhaps I could have it somehow wait till a save is loaded to make the change?
the only real difference between this and big moodles is that mod options is calling adjustPositions, so the blame is probably that being called too early
although i don't really know how mf's compat works
LuaMoodles.adjustPositions = function()
local scale = core:getScreenHeight() / 720 + 0.5
scale = scale - scale % 1
if scale < 1 then scale = 1 end
MF.scale = scale
adjustModdedMoodlesPosition()
old_adjustPositions()
end
local function adjustModdedMoodlesPosition()
--we need a double loop that parses the following table containing the modded moodles instances
--for each valid playerNum / moodleName, do
local myMoodle = MF.MoodlesStorage[playerNum][moodleName]
local x, y = myMoodle:getXYPosition();--uses MF.scale
myMoodle:setX(x)
myMoodle:setY(y)
local width = 32 * MF.scale;
local height = 32 * MF.scale;
myMoodle:setWidth(width)
myMoodle:setHeight(height)
--end do
end
My brain hurts but I will give that a shot, thank you.
-- can you try this the following ?
require 'MF_ISMoodle'
function MF.adjustScale()
for playerNum, playerMoodles in pairs(MF.MoodlesStorage) do--for each local players (splitscreen)
for moodleName, myMoodle in pairs(playerMoodles) do--for each moodle already created
local x, y = myMoodle:getXYPosition();--uses MF.scale
myMoodle:setX(x)
myMoodle:setY(y)
local width = 32 * MF.scale;
local height = 32 * MF.scale;
myMoodle:setWidth(width)
myMoodle:setHeight(height)
end
end
end
--the following requires MF_MoodleScale to be loaded
require 'MF_MoodleScale'
local modInfoBM = getModInfoByID("BigMoodles")
if not modInfoBM or not isModActive(modInfoBM) then
return--handle : compat not required
end
require 'BigMoodles'--I guess your code replaces BigMoodles, so it should require your own file instead here
local LuaMoodles = require("StatsAPI/moodles/LuaMoodles")
local core = getCore()
local old_adjustPositions = LuaMoodles.adjustPositions
LuaMoodles.adjustPositions = function()
old_adjustPositions()--let BigMoodle/StatsAPI do the job and then MF_MoodleScale set MF.scale
MF.adjustScale()--use MF.scale to reposition/rescale each already created moodle.
end
That did not work for me, but I probably did something wrong. Is there a list of events or triggers available somewhere? Like OnGameStart, OnGameBoot, OnGameLoad, etc? As well as an explanation of when each triggers?
Ah actually found that on the wiki, if anyone's looking: https://pzwiki.net/wiki/Lua_Events
Is there a way to check if currently in game, or just at the start screen? I feel like I definitely saw that somewhere...
the wiki list is pretty outdated, i like to point people to my one instead https://github.com/demiurgeQuantified/PZEventDoc/blob/develop/docs/Events.md
Oh awesome, tyvm
Do you know if there's a way to tell the script if it's currently in the start menu or if it's currently in a game?
I feel like the isClient() function is really close...
No that's not how
isClient() returns true if ran in a client lua and when ran in multiplayer
Also why would you want to know if it's in the start menu or in-game ?
What kind of mod would you need to run in both ?
My mod is trying to make moodles resizable... It works perfectly in most situations, except explained
here
Pic here for reference
The issue seems to be caused partially by the game applying the values too early... So I was hoping to delay them till after the game is loaded. But it would need to know if the client is currently in a game or not too to apply them.
Guys, hi, it's possible to remove events from one mod X with mod N
For example:
Mod X have folder lua/myExample/luaTemplate.lua with func:
local function somecodeshitstuff()
--*bla bla bla*
end
if getActivatedMods():contains("another mod neebubratan") then
Events.EveryOneMinute.Add(somecodeshitstuff);
else
Events.EveryTenMinutes.Add(somecodeshitstuff);
end
not if it is local
you need a reference to the function to remove it
okay, if func global?
yeah
anyone knows how to get zombie's Z position??
local Z = zombie:getSquare():getZ()
thank you!!!
Where can I promote my mod?
Reason: Bad word usage
You can post your mods here or #pz_b42_chat but don't spam.
oh word? imma just...slide my lil update in here then...
https://steamcommunity.com/sharedfiles/filedetails/?id=3172171349
is there any way to let recipes not appear in the "big" crafting menu, but only get the option to apply the recipe when rightclicked on an item in inventory? I have to add a lot of recipes, but would prefer not to flood the craftingmenu
Anyone else run into issues where random wooden tiles appear around the map? I'm noticing a connection with EHE - but I think the issue is getCell():getOrCreateSquare() being used on cells outside the current cell.
My interpretation of the method was that it would be loading a single square's data when called. Haven't tested my new draft that avoids using that method, but just curious if anyone ran into a similar issues.
Previously using fastmove and having events call getOrCreate made swathes of wooden floors - in my current testing the problem seems fixed.
Is it save to declare your mod's TimedAction functions as local and then import them via the require() command whenever you need them?
sorry folks, how can I find the ItemID using the debug mode?
It's an item ID of a custom item created within a mod
with or without lua coding? (not sure if there is even a way without coding...)
I'd take both, as long as my recipes dont spam the crafting menu
Do you happen to know how this works? π
I am just looking because I could use this in my modding work too.
So the recipes have a java command called
recipe:setIsHidden(boolean)
This could be useful. But I don't know how to get the actual recipe object which should be in the variable "recipe" in my code example
I unfortunately do not know enough about lua to be of any help here. And I cant think of a mod that does this as well
saw it happen on PEI map but not sure why
Here is something that seems to work:
function ISCraftingUI.populateRecipesList(self, ...)
local recipe = getScriptManager():getRecipe("Make Jar of Broccoli")
recipe:setIsHidden(true)
vanilla_populateRecipesList(self, ...) -- execute vanilla code
recipe:setIsHidden(false)
end```
This must be the content of a .lua file which has to be in your mod's client folder. But use with care and playtest this a lot!!!! I just had a quick look at and it looked good. But could still be that smth is wrong with.
... the example will hide the recipe for crafting a jar of broccoli from the Craft Menu but not from the right click menu according to my testing
are ArrayLists treated differently in Project Zomboid?
I should be able to call the content using array[index], but it just throws an error?
In the debug menu, there is an option called Items List. You can try to search within the first field called "Type" (bottom left of the search menu after you clicked on Items List). But not sure whether it will also show you mod item. The second field "Name" can be used for searching an item by its display name.
Jave ArrayLists in Zomboid can typically accessed by
list:get(i)
afaik. Not sure if it applies in your case but might be worth a try.
Awesome! I will give it a shot π How would I write it, if I had multiple recipes? seperated by comma in the "make jar of broccoli" bracket?
Yeah it's like this
Hii, I'm trying apply a different texture to an existing guitar item, but the new guitar doesnt visibly show in the character's hands.
Is it best to copy the .x file and change the texture filename, or use a .fbx of the guitar item?
use :get(index)
I'm not sure if the Weapon item searches in the models_X/Weapons/2handed folder location
No. Then you need smth like this:
local recipe2 = getScriptManager():getRecipe("My second Recipe")
recipe1:setIsHidden(true)
recipe2:setIsHidden(true)
vanilla_populateRecipesList(self, ...) -- execute vanilla code
recipe1:setIsHidden(false)
recipe2:setIsHidden(false)```
and don't forget the :setIsHidden(false) commands at the end for each of your recipes. Otherwise, they will be completely removed from game (i.e. also in the right-click menu)
okay! I dont need any "require ISRandomLuaStuff" thingies? Just copy paste and I am good to go? π
don't think so
so yeah, just try copy paste
Your code is working - partially π I have multiple recipes with the exact same recipe name, your code is only disabling the first recipes of each name
Ok. Same name for different recipes is a special thing my code does not solve. The question is then how to grab your individual recipes with a command similar to getScriptManager():getRecipe("something"). Don't know how this works but there is probably a solution...
In worst case I have to give everything its own name
I guess there is also a better solution. maybe there is a way to get all recipes with the name at once so that they are in list...
does each of your recipes has a unique result which can not be crafted by any other recipe?
almost all of them have
there should just be one item in the current list that can be crafted in vanilla
A bit difficult to explain if do not a lot of coding. But there is a command
local list = getScriptManager():getAllRecipesFor("Base.MyItem")
I've never tried it but I guess the "list" will then contain all recipes for the item. You could then iterate through the list, check each item if it is one you would like to hide and then hide it as done above. At the end of the code, you have to unhide each of them again ofc
what I do in such a situation is trial and error and check whether this or something similar will work...
oooof, that will be quite a lot of work. But as long as everything is fine in the end, I am happy π "MyItem" I guess it the precise itemname of the item I want to hide?
Hello everyone! I want to make a mod that change an item's Category based on its Display Name (not base Item Name). For example, if I rename an item to "My xxxx", its category will change to "AAA", (so it will be at the top when sorted by catogory). Is it possible? If so, please give me a some pointers on how to do it?
Thank you in advance!
Yes. There should be your items script ID. The code itself would probably not be so long. Just a few lines. But testing stuff and working everything out might take some effort.
I would start with smth like this
local backUpTable = {}
for i=1, myList:size() do
local recipe = list:get(i-1)
if recipe:getName() == "Your recipes name" then
recipe:setIsHidden(true)
table.insert(backUpTable, recipe)
end
end
vanilla_populateRecipesList(self, ...) -- execute vanilla code
for _,v in pairs(backUpTable) do
v:setIsHidden(false)
end```
But not sure if this works. Just made it up in my head
the upper part would be one per item?
this would do this for all recipes which have the result "MyItem". In case you have more than 1 result items, you have to do this for each of your items BEFORE the command "vanilla_populateRecipesList(self, ...)". And write everything you changed with "setIsHidden(true)" into the backUpTable
local myList = getScriptManager():getAllRecipesFor("Base.MyFirstItem")
for i=1, myList:size() do
local recipe = list:get(i-1)
if recipe:getName() == "Your recipes name" then
recipe:setIsHidden(true)
table.insert(backUpTable, recipe)
end
end
local myList = getScriptManager():getAllRecipesFor("Base.MySecondItem")
for i=1, myList:size() do
local recipe = list:get(i-1)
if recipe:getName() == "Your recipes name" then
recipe:setIsHidden(true)
table.insert(backUpTable, recipe)
end
end
vanilla_populateRecipesList(self, ...) -- execute vanilla code
for _,v in pairs(backUpTable) do
v:setIsHidden(false)
end```
something like this maybe
yes, that is what I thought it would look π Thank you man, I am currently trying to get a grisp of lua, so I hope to repay your help in the future!
np. but not sure if my code will really work. maybe some syntax errors. also not sure if you have to use "Base.MyItem" or just "MyItem" instead. These are things to find out via trial and error
btw, how many recipes and items are we talking about?
when everything is done and finished? around 100 items and 2 recipes each
I am not sure this is even possible. I spent like two days reading code to find something similar (replacing a script value of an item), but there was nothing.
ufff... then you shouldn't do it by manually making a for-loop for every item but make an outer for-loop running through all your items somehow. moreover, this might slow down the game each time you open the craft menu. this menu has tendency to become lagging very quickly. it is something you simply have to try then
dang, I wanted them out of the inventory, to keep it from lagging
hmmm... not sure. taking recipes out of the craft menu could increase performance since the game does not have to calculate and render the options for the recipes. however, if you take out 100 items, it may happen that just the process of taking all the recipes out may slow down it again so that there is either no effect at all or the game gets even slower...
as I said, it is something to find out via trial and error
I guess I will just take the middleway - add an own crafting category, so noone, who does not click on it, has to suffer through it
It might also be worth thinking about whether there is another place in the vanilla code where you could add your new code. I have taken the function "ISCraftingUI.populateRecipesList". It is always called when someone opens the craft menu. Maybe there is an alternative which is only called once the game starts or smth
that would be sick! Great hint, when I have time I will go on the search
Reason: Bad word usage
yes, that works perfectly
the timed action queue just needs to be passed a reference to a timed action instance, nothing about it actually needs to be global
then I think I can rework all my mods so that they have no global data at all (except for modData in case they count as global)
through all of my experience i have never found a situation where you have to use global variables except for functions referenced in scripts
Hi everyone! I am trying to make a simple mode that create a few new items, base on vanilla ones, new item category, and add some recipes involving the new ones. I created translation files. I put the mod in (Windows 11) User/xxxx/Zomboid/mods. The game recognizes the mod. I add the mod to an on-going game. But I couldn't find the new recipes. Here is the code on github: https://github.com/WarBuggy/PZMods/tree/master/PersonalizeItems
Could someone please point me in the right direction? Thanks in advance!
scipts
Does maybe one of you know, how I can write translation files without them losing german special characters (Γ€ ΓΆ ΓΌ)?
save them in ANSI instead of UTF 8
i do french translations so have to do the same ^^
awesome, thank you π
np!
Thank you!
im cooking
Hi! I am currently re-working some of my mods by replacing global variables with locals using the "require" command to call the locals in other luas. Works fine so far.
However, what I found out is that if I put a
local myData = require("myLuaFile")
command in the client folder for example, it only searches for the file "myLuaFile" in the client folder. If I want to require the file from a client's subfolder, I can use
local myData = require("mySubFolder/myLuaFile")
and it works fine. But how do I require a file in the client folder when the file is located in shared?
requiring shared from client should work fine with the same syntax
i don't know what happens if there's a file with the same name in both directories so don't do that
oh, do you mean requiring client from shared? that's not possible because shared loads before client
it doesn't really make sense to, you're trying to pull client-only code into a file that will also be executed by the server
I mean the following situation:
file "mySharedCode.lua" is located in shared/sharedSubFolder
I want to use it's data via the require command in client's file. For example in
file "myClientCode.lua" located in client/myClientSubfolder
So, just writing the command
require("sharedSubFolder/mySharedCode")
into "myClientCode.lua" will do it?
yeah
A totally different question which some people here might know smth about:
What does the command "setMetabolicTarget()" exactly do? I see it sometimes in the vanilla TimedActions. For example
self.character:setMetabolicTarget(Metabolics.LightDomestic)
Is this somehow related to how much endurance a TimedAction costs the player?
That means that it costs you the calories (effects your metabolism) for the value of "light domestic" tasks, iirc. From what I have seen metabolic seems to be used for the players metabolism, and metabolics always have name like "HardWork" or something like that
I could be totally wrong though, since I am still learning the lua stuff. But from what I have read, it seems logical
makes sense!
and "LightDomestic" probably means that not much calories are used?
I would assume so at least
but dont ask me how much, cant find a lot on that. But since alternatives are called "HeavyDomestic" and "MediumWork", I would assume that it even is the lightest of works, seeing that it is used for stuff like removing bait or trimming the beard
btw, I figured out a way to hide recipes globally (or the creators of "Simple Overhaul: Melee Weapons figured it out and I managed to adapt the code to my needs, lol):
in case you need it π "Erect", "Knock Over", etc, are the recipe names. Works flawless even if multiple recipes share the same name
To be fair, I dont fully understand what the first function (hasValue) is doing, looks cryptic to me. But it is working
goes in "server"
but won't this code hide the recipes completely from game? i.e. even in the right click menu?
btw the hasValue just checks whether the acutal recipe belongs to listhiddenReicpes as far as I understand
aah, great! No, it works perfectly with the rightclick
only if you add one of those lines it makes problems (I guess why is self explanatory, lol):
recipe:setNeedToBeLearn(true) recipe:setCanPerform("nope")
Ok. Then the setIsHidden() command is only for hiding recipes from craft menu but not from the right-click menu. I just expected it will hide it from the full game without testing properly.
In this case, setIsHidden() is exactly tailored to your needs! π
exactly π fixed all my issues
Hello! I do not know in which chat to address this question: How to make normal display of non-English text in the server console? (in the CMD itself the text is displayed normally, but in the server console it is not).
Does anyone knows what determines whether an obejct of the map (tables, chairs,...) hides the player model? There are different things which could happen:
Chair does not hide the player model. Toilet does.
Iβd assume it has to do with what layer itβs on. Iβm not The Best at mapping, but tldr, different things go on different layers, and though youβd Think all furniture goes on the same layer, afaik it doesnβt. So Iβd maybe ask in #mapping fwiw
Someone pls correct me if Iβm wrong ππ½
ok. will repost this in the mapping channel then...
I think it may also have to do with the fact that the window is there, since the game lets you access windows on the inside even if thereβs furniture in the way, even though from the outside youβd climb over it.
So Iβm curious if the chair still does that when you place it away from the window.
I tested the thing with the chair at other locations too and it seems that it never hides the player, indepent of windows.
Interestingβ¦Iβm nearly certain it has to do with layers, but I have no idea what layer chairs go on.
Would be great if you could somehow change this hiding behavior via modding. Maybe the people from the mapping channel know more.
Yea! I wonder how possible it is, because I think the chairs from build menu work differently from chairs in the brush tile. So I wonder what the dev of that mod does for their chairs, cuz they have collision and hide the player
What are you wanting to do with this again..?
The chair and toilet are not modded. They are just from vanilla game.
yea i know! i'm more saying that it's possible to move tiles from one layer to another, given that build menu's chairs are solid
ok. misunderstood. my bad
I think it is because the toilet is a wall object
wall objects appear in front of player
chair is a normal moveable
Depending on how the "hiding the player model with furniture" exactly works, it might be possible to let the player sit on chairs facing in all directions without looking too glitchy. But just some rough ideas. Not sure whether this could work
hello here ! I created a mod that added a recipe to find via a magazine. This recipe allows you to make an axe. Users have informed me that with this mod, it becomes impossible to tear clothes! And honestly I don't see the connection. It's the magazine part that seems to be the problem because without the axe part, the problem is still there. An idea ? π
do you know whether the property of being a wall object can be changed somehow?
in tiled
but you would have to creat a new tile I guess, unless you really want to go mad and start changing one of the games most important vanilla files XD
at least I think so. Maybe there are better ways to change to property of vanilla tiles
so no way to change this via java commands in lua code?
tbh, I would not be surprised if lua would work. Have seen mods that add functionality to vanilla tiles, or even check for certain vanilla tiles to replace them with modded tiles. But I have no clue how exactly to program this
But best give it a shot beforehand if this is actually the setting causing the issue. Sound logical to me, though. Toilet is mounted to wall, wall is displayed before player, so toilet is displayed before player. I unfortunately have no real option right now to test this theory
I've released my chat mod (https://steamcommunity.com/sharedfiles/filedetails/?id=3178882070) just a day before I'll have to go on a business trip for 3 days, so crossing my fingers that there's not some glaringly obvious bug that'll need fixing π
Oh and we can no longer open cans that open by hand!
have you reproduced the bug by yourself?
do you know any web resources which explain a bit about tiles modding and bringing them into game?
Nice job!
Daddie Dirkie Dirk has some nice youtube tutorials that helped me a lot:
https://www.youtube.com/watch?v=Fbvb6LeX0Sw
Quick video on getting custom tiles in the project zomboid editors (buildinged, tiled and worlded)
If you like what im doing please consider donating to my Patreon.
https://www.patreon.com/DaddyDirkieDirk
the wiki also has some nice sources (also linking the videos above)
I am far from being experienced at making tiles, but I already got some selfmade tiles with selfmade textures into the game, with the properties I wanted. So if you have specific questions on how to do this, feel free to ask π
Yes I tried and the bug exists
is your mod on the workshop?
ripping the clothes is not the problem
you have overwritten ALL recipes. Rename your recipe.txt to something specific to your mod, and everything works
like "recipes_canaxe.txt".
no problem π You have unintentionally overwritten the games vanilla recipe.txt file by naming your file the exact same way. That is why nothing is working anymore π
because the game only knows the CanaxeStone now
yeahhhh π π€
humm nope I can't rip the clothes ^^ I rename the file and start a new game
I renamed the file and everything worked for me π
damned
gonna try something
nope doesn't work for me, can you send me zip file of my mod ? lol
this is what I changed in your scripts folder - only the recipes.txt name
that is everything I changed π
and that is the result: I have your axe, but still can rip clothes ("kleidung zerreiΓen" in this case because german)
I think I found, I'm stupid, It was on the wrong folder
π shit happens. Can also be tricky if you have in the workshop or mods folder and are subscribed to it on steam as well. Then you are running up to three copies of your mod at the same time, what definitely will mess up any changes
and it's ok !!! thanks !!!!!
OMG so much to learn ^^
gonna update my mod ! thanks thanks thanks !!!
de rien! π
π
are you on windows or linux when using TIleZed?
on windows
are there any modders hoping to have voice lines in their mod packs? Iβd be happy to help as a voice actor c:
Good day sirs! I have recently dwell into modding and I must say that it is even more addicting after playing 600 hours.
I have a question regarding InventoryItems and similar (items on the ground). Lets say I'm saving some item ID into a file on OnSave event. Is it possible to somehow get that object instance by ID the next time I load the game up? Currently I have only found tile scanning techniques and looping over them to find item instances but maybe I have missed something?
any idea where this problem comes from:
Invalid tileset size '0,0' for tileset 'fixtures_bathroom_01_2'
(while reading Tilesets.txt)
??
I am confused, maybe this is a part I dont know yet - I know the tiledefinition.tiles file and the .pack files, but I dont know any .txt files involved in creating tiles
ah! I see it, it is the file in the TileZed folder? I never touched this, what do you need it for?
btw, there is no entry in the txt file (at least the vanilla file I got here) that is called "fixtures_bathroom_01_2".
Hello everyone, thanks to some friends of mine we have been working on a mod that turns Water into Seawater.
I am excited to finally share this mod with you all.
What does this mean for gameplay? You cannot drink or fill containers at water tiles anymore. Admins can create custom 'Fresh Water' zones using the Zone Editor.
Prince Edward Island and ROK's Bria Island are supported out of the box without any additional setup required.
https://steamcommunity.com/sharedfiles/filedetails/?id=3178562599
question. I finished my mod which ads a new type of beverage, everything worked perfectly, i even have footage of it working perfectly. Then i upload it and leave for about 5h. I come back and the model is 2x the size and in the drinking animation it is held backwards.
nothing changed in the code
theres like 30 lines total so id know if it was changed
bewildered at this
If youβre subbed to the mod unsubscribe and test the local workshop directory version
I wasnt subscribed, didnt work.
Subscribed to see if it would work, didnt work.
like how does this even happen
RotationData Bug in Blender. Oddly Common.
Try Re Applying Transforms. After Sizing it again?
i use the vanilla fbx model and just change the mesh texture
hmm. Size Annotation issues. perhaps Doubling the model to the mod, and Forcing Scale will help
tried messing with scale, 0.5 and 1 are identical
dont know if its limited to integers or anything
but didnt get lua errors so π€·
odd.