#mod_development
1 messages · Page 111 of 1
Got for-loops implemented today.
Translating loop logic between Lua and TypeScript is kind of meh. =(
Nice man
After loops I'm going to work on instancing "self"
Then class generation using a class adapter API I'll build for detecting pseudo-classes in the code and possibly how to implement them too.
Yay for progress.
does something like that exist: OnCharacterMovement
OnPlayerMove
I tried Player but it doesn't exist
you won't catch non-player characters with that but it might be what you need
he returns me (nil)
function: OnPlayerMove -- file: PlayerMove.lua line # 17
ERROR: General , 1676093054327> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: Object tried to call nil in OnPlayerMove at KahluaUtil.fail line:82.
ERROR: General , 1676093054327> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: Object tried to call nil in OnPlayerMove
can i see your code?
sec
local grassSoundFiles = {
"media/sound/grass_footstep1.ogg",
"media/sound/grass_footstep2.ogg",
"media/sound/grass_footstep3.ogg",
"media/sound/grass_footstep4.ogg"
}
local grassSoundIndex = 1
local function xyz(player)
return player:getX(), player:getY(), player:getZ()
end
local function OnPlayerMove(player)
local x, y, z = xyz(player)
local surfaceType = player:getSurfaceType()
if surfaceType == "grass" then
player:BaseCharacterSoundEmitter(grassSoundFiles[grassSoundIndex], x, y, z, false, 20)
grassSoundIndex = grassSoundIndex + 1
if grassSoundIndex > #grassSoundFiles then
grassSoundIndex = 1
end
end
end
Events.OnPlayerMove.Add(OnPlayerMove)```
getSurfaceType() does not exist
player:BaseCharacterSoundEmitter also doesn't exist. try: player:getEmitter() to get the current emitter on the player, and use it to play sound.
So the error didn't exactly refer to OnPlayerMove, but to this one in line? o.o
it was saying OnPlayerMove because you named your function that, and the error was in that function
thank you, i think i found the right one
Is there really no player:getOccupation()???
player:getDesc():getOccupation()
wow, they buried that
I'm still fighting an issue with moving things to a container after removing items from the container inventory
guess I'm not sure how to access this one
what do you mean?
well, there is no getDesc() and I'm looking at getDescription() and there isn't one for IsoPlayer
I can see getName() under the profession factory, but I think that just for interacting with professions via lua and not how they're tied to the player
my bad, getDescriptor()
( ͡° ͜ʖ ͡°)
Occuption - getPlayerByOnlineID(0):getDescriptor():getProfession()
Thanks as always
ok, so players don't get hasSafehouse(), but Safehouse.hasSafehouse(player) returns the whole safehouse instead of a boolean... because they're doing hasSafehouse(player) do a get. Then did getSafehouse(coord/square) and not getSafehouseByPlayer(player) and getSafehouseBySquare(coord/square).
Any reason why Safehouse.hasSafehouse(getPlayerByOnlineID(0)) wouldn't work from debug?
declaration: package: zombie.iso.areas, class: SafeHouse
SafeHouse
Why not use reference to existing type as boolean?
even better, I wasn't sure it did so was just being explicit
Pretty much works for any type checks
Same for variable default value failover
someVar = someVar or 0 means if someVar is nil then its assigned to 0
The only thing I dream if in some languages is something like object.field?.anotherfield?.value like TS has.
It's nice at a glance though if you see ~= nil you know that the function doesn't return true/false imo. Probably preference?
Yeah maybe, I'm just more into compact code as much as possible without damaging human reading.
yea, I get that
I try to do things with the most efficiency and readability. Compactness isn't as important.
Yeah as I said not gonna judge any codestyles.
aww we can't set a building def 😦
lol what are you trying to do
i messed around with a lot of that stuff trying to figure out switches
it does not have:
local floorType = floor:getType()``` ???
well, any building that has residential rooms is claimable even if it's not orange on the map. So, I've been pondering how we can stop that as server owners. With the knowledge that we can't set a building def, I'll have to look for another way for an admin to swing through and prevent that building from being claimed again.
Afaik as long as theres a bed
Which is why the hone for the aged and those hardwarestores with rooms above are claimable
Also condo units and hotel
if not safehouse and clickedSquare:getBuilding() and clickedSquare:getBuilding():getDef() then
local reason = SafeHouse.canBeSafehouse(clickedSquare, playerObj);
if reason then
if test == true then return true; end
local option = context:addOption(getText("ContextMenu_SafehouseClaim"), worldobjects, ISWorldObjectContextMenu.onTakeSafeHouse, clickedSquare, player);
if reason ~= "" then
local toolTip = ISWorldObjectContextMenu.addToolTip();
toolTip:setVisible(false);
toolTip.description = reason;
option.notAvailable = true;
option.toolTip = toolTip;
end
end
end```
Ahhh ok
Dubunked!
Lol
Anyways what i said was comming from a players perspective / non modder
yea, I didn't know till about 30 minutes ago
and having a bed might be enough to change the building def
so, you could still be right
I think it has more to do with the room definition
can you access fields with a .[field]
getBuilding():getDef().items
https://projectzomboid.com/modding/zombie/iso/BuildingDef.html
declaration: package: zombie.iso, class: BuildingDef
like that?
do you guys know of any resource than can help me learn how to animate the project zomboid user character?
how to control fog on lua
getClimateManager():getFogIntensity(float)
https://projectzomboid.com/modding/zombie/iso/weather/ClimateManager.html#getFogIntensity()
declaration: package: zombie.iso.weather, class: ClimateManager
🙏
oh that's getting it, idk if you can control it with that
there's a setFogIntensity under WeatherFX
but, that may not work as intended and only draw fog on the client instead of making it foggy via the climate
so whats for global
oof, I'm not sure I understand how they're doing it on the admin panel
lua/client/AdminPanel/ISAdmPanelClimate.lua
var = clim:getClimateFloat(FLOAT_FOG_INTENSITY);
self.tickBoxFog.selected[1] = var:isEnableAdmin();
self.sliderFogSlider:setCurrentValue(var:getAdminValue());```
elseif _slider.customData=="FogSlider" and clim:getClimateFloat(FLOAT_FOG_INTENSITY) then
clim:getClimateFloat(FLOAT_FOG_INTENSITY):setAdminValue(_slider:getCurrentValue());```
elseif _tickbox.customData == "Fog" then
if clim:getClimateFloat(FLOAT_FOG_INTENSITY):isEnableAdmin() then
clim:getClimateFloat(FLOAT_FOG_INTENSITY):setEnableAdmin(false);
else
local val = self.sliderFogSlider:getCurrentValue();
clim:getClimateFloat(FLOAT_FOG_INTENSITY):setEnableAdmin(true);
clim:getClimateFloat(FLOAT_FOG_INTENSITY):setAdminValue(val);
end```
you have idea how to produce sound but only heard localy?
local clim = getClimateManager();
Alright. A
for anyone who can tell me what is causing the error here. I am not understanding the debug log... The items get removed correctly but an error still occurs ??
local playerInv = getPlayer():getInventory():getItems()
local playerInv2 = getPlayer():getInventory()
local ItemsToRemove = 1
local table = {'Necklace_SilverSapphire', 'Necklace_SilverDiamond', 'NecklaceLong_SilverEmerald', 'NecklaceLong_SilverSapphire', 'NecklaceLong_SilverDiamond','Ring_Right_MiddleFinger_SilverDiamond','Ring_Left_MiddleFinger_SilverDiamond','Ring_Right_RingFinger_SilverDiamond','Ring_Left_RingFinger_SilverDiamond','BellyButton_DangleSilverDiamond','BellyButton_RingSilverAmethyst','BellyButton_RingSilverDiamond','BellyButton_RingSilverRuby','BellyButton_StudSilverDiamond'}
for i=0,playerInv:size() - 1 do
local ItemType = playerInv:get(i):getType()
for i=0,#table do
if table[i] == ItemType and ItemsToRemove > 0 then
playerInv2:Remove(ItemType)
ItemsToRemove = ItemsToRemove - 1
end
end
end
self.sound = self.character:playSound("GetWaterFromTap");
Guys if there's already an animation in the game, I need to trigger it, right?
yes
self:setActionAnim("Loot")
just find in files for setActionAnim and you'll see what is used in the vanilla code, not sure if there are others
well, your inner for loop is setting i back to 0 so that's not great. and I'm betting playerInv:get(i):getType() isn't doing what you want
I'm reading this player:animEvent("sitGround")
thnx
Yeah, it counts back down to 0. playerInv:get(i):getType() IS pulling the correct item as it does remove it from the players inventory?
Changing ItemsToRemove to ItemsToRemove=8 would remove 8 of those items for example
getSpecificPlayer(player):reportEvent("EventSitOnGround");
end```
does it give an in game error?
It does...but I unfortunately do not understand it.
attempted index: storePos of non-table: null
I get what those words means, but not put together for this loop 😐
I will keep messin' with it
It's my 3:00am brain causing problems I think
the problem is with storePos not the code you showed
Okay, maybe that's not the error...
I'm new to PZ scripting - typically when I get an error message it pops up on the screen with an error log. This error doesn't it just...shows a blank screen.
It shows this:
usually that happens to me when I call something that doesn't exist
or misspell something
I'm just running this code in the console, ``` local playerInv = getPlayer():getInventory():getItems()
local playerInv2 = getPlayer():getInventory()
local ItemsToRemove = 2
local table = {'Necklace_SilverSapphire', 'Necklace_SilverDiamond', 'NecklaceLong_SilverEmerald', 'NecklaceLong_SilverSapphire', 'NecklaceLong_SilverDiamond','Ring_Right_MiddleFinger_SilverDiamond','Ring_Left_MiddleFinger_SilverDiamond','Ring_Right_RingFinger_SilverDiamond','Ring_Left_RingFinger_SilverDiamond','BellyButton_DangleSilverDiamond','BellyButton_RingSilverAmethyst','BellyButton_RingSilverDiamond','BellyButton_RingSilverRuby','BellyButton_StudSilverDiamond'}
for i=0,playerInv:size() - 1 do
local ItemType = playerInv:get(i):getType()
for i=0,#table do
if table[i] == ItemType and ItemsToRemove > 0 then
getPlayer():getInventory():Remove(ItemType)
ItemsToRemove = ItemsToRemove - 1
end
end
end```
It's probably something silly
I appreciate t he help. Maybe after a nights rest I will catch it
idk if it'll fix your issue
It does exactly what I want it to
you may be looping too many times
Oh probably that
You're right. If I put **return **after ItemsToRemove = ItemsToRemove - 1 it does not throw an error. It also doesn't remove more than 1 item. But that does tell me it's an issue with the table loop
Okay. I think it has something to do with removing items while looping...probably not a good idea.
I replaced the table with a simple if, then statement and still got the error lol
@pulsar heath I remember you been working with zombie AI. Is there any simple method to make them start roaming in random directions?
Here's an example of something I use, if it's helpful
local hour = getGameTime():getTimeOfDay();
if( hour < 8.0 ) or ( hour >= 22.0) then
local players = getOnlinePlayers()
for i=0, players:size()-1, 1 do
local player = players:get(i)
local zlist = player:getCell():getZombieList();
if(zlist ~= nil) then
for i=0, zlist:size()-1 do
local zed = zlist:get(i)
local tempx = zed:getX() + ZombRand(-25,25)
local tempy = zed:getY() + ZombRand(-25,25)
local tempz = zed:getZ()
zed:pathToLocation(tempx,tempy,tempz);
end
end
end
end
end
For dedi/MP only, but you could easily modify it
ah zed:pathToLocation to random X,Y.. makes sense.
There is a nil in there!
How the
showcase: #mod_development message
userful for debug if you dont have controller, you can test axis using mouse, and to change axis change in code
to
isLeftAnalogStick=True
for modders that dont have controller to test with, this works for simulate controller
i bsc computer science pair programming with chatgpt to produce a python joystick keyboard opensource, to work with vjoy, enjoy
to debug using a virtual controller, to got 99.9% precision use your window screen monitor borders, someone can try optimize the precision using math and screen knowledge (hint you can reduce the screen to fit better the circle of radial menu)
https://github.com/rslgp/virtual-controller-opensource
requirements: vjoy https://sourceforge.net/projects/vjoystick/files/latest/download config 18 buttons there
to run, install python
pip install -r requirements.txt
python chatgpt-keyboard-axis-reifel.py
press F1 to exit
a virtual controller opensource coded by bsc Computer Science with pair programming with chatgpt - GitHub - rslgp/virtual-controller-opensource: a virtual controller opensource coded by bsc Compute...
This project was originally designed to provide an open-source replacement for PPJoy. The product, at this point, consists of virtual joystick…
Lua starts with 1 not 0
When you index over a lua table not a java table
👍
Also, editing a table while you are iterating over it is not a good idea lol
Copy the table and edit the copy while iterating over the og table
local ItemsToRemove = 2
local table = {'Necklace_SilverSapphire', 'Necklace_SilverDiamond', 'NecklaceLong_SilverEmerald', 'NecklaceLong_SilverSapphire', 'NecklaceLong_SilverDiamond','Ring_Right_MiddleFinger_SilverDiamond','Ring_Left_MiddleFinger_SilverDiamond','Ring_Right_RingFinger_SilverDiamond','Ring_Left_RingFinger_SilverDiamond','BellyButton_DangleSilverDiamond','BellyButton_RingSilverAmethyst','BellyButton_RingSilverDiamond','BellyButton_RingSilverRuby','BellyButton_StudSilverDiamond'}
local removetable = {};
for i=1,playerInv:size() - 1 do
local ItemType = playerInv:get(i):getType()
for i=1,#table do
if table[i] == ItemType and ItemsToRemove > 0 then
print (ItemType)
removetable[#removetable+1]=ItemType
ItemsToRemove = ItemsToRemove - 1
end
end
end
for i=1,#removetable do
getPlayer():getInventory():Remove(removetable[i])
end
```
Final solutio
n
I put the items I want removed into a separate array 😐
What exactly are you trying to remove?
This is for a more complex recipe system. So instead of duplicating recipes, the player just needs any combination of those 10 items in the table
I've been struggling to make this work for a week now.
So I have this array for random name generating, but it wouldn't work for some reason, like the event is not triggered properly.
local firstNameArray = {"Ivan", "Michael"}
local lastNameArray = {"Jackson", "Buba"}
local function generateName(player)
local firstName = firstNameArray[ZombRand(1, #firstNameArray+1)]
local lastName = lastNameArray[ZombRand(1, #lastNameArray+1)]
getPlayer():getDescriptor():setForename(firstName)
getPlayer():getDescriptor():setSurname(lastName)
end
Events.OnNewGame.Add(generateName)
However, when I type this code (without event block) in the lua interpreter ingame, it works...
So I tried to check whether the function is even running OnNewGame:"
local function generateName(player)
local firstName = firstNameArray[ZombRand(1, #firstNameArray+1)]
local lastName = lastNameArray[ZombRand(1, #lastNameArray+1)]
getPlayer():getDescriptor():setForename(firstName)
getPlayer():getDescriptor():setSurname(lastName)
print("DONE")
end
And... "DONE" string is displayed! So the event is triggered, although the name is not changed. What am I doing wrong? Any suggestions would be greatly appreciated!
try maybe initializing a new world? the description for the event is
**Triggered after a new world has been initialized. **
or try using ZombRandBetween
showcase virtual controller for debugging, analog stick changeable and controlled with mouse
Can someone help me? I'm trying something simple:
local keyBind = "b" -- Defines the key that will trigger the sit action
local function OnKeyPressed(key)
if key == keyBind then
local player = getPlayer()
if player then
print("Player found, triggering animation...")
getSpecificPlayer(player):reportEvent("EventSitOnGround")
print("Animation triggered successfully.")
else
print("Player not found.")
end
end
end
Events.OnKeyPressed.Add(OnKeyPressed)
The player still does not sit
did you try just using getPlayer instead of getSpecificPlayer(player)
?
i dont know much about modding, but it seems redundant. in my mod i just used getPlayer or getSpecificPlayer(0)
would just getplayer be myself, right?
Dam that's a trouble. Apparently IsoPlayer is getting instantly culled in MP
All right, I managed to get it working.
So the trigger fires only after reconnecting to a host, so it didn't fire right after the character dies and pushing the character creation button.
In my scenario it works, because the player drop off a whitelist after death, therefore he reconnects and initialises the world again, and therefore the event triggers!
This is why in case one launches a lan session, it wouldn't work, until he shuts down the session!
getPlayer would be the player that initiated the action if i understand correctly
mine is a trait tho, and i used getPlayer() to give them a wound when they spawn
Just be warned, getPlayer() only returns the first player. If doing co-op, using getPlayer() will not return the correct player if you are trying to do something on another co-op player. You must use getSpecificPlayer(playerNumber) in those instances.
also i was told to test the specific command line in console to make sure that command works
if getSpecificPlayer(playerNumber):reportEvent("EventSitOnGround") works using command console, then that part is fine
right?
im learning too
Correct.
i want to make another mod some time in the future
it'll involve the health panel, so i wanna start out small by making cold packs work to relieve pain that appears on the health panel
as in neck pain when u sleep wrong, or muscle soreness etc
oh neat. more first aid items always help, there's not enough of them in the game imo.
i want to make the first aid skill actually useful, but none of the mods currently out there suit my tastes
as well as making first aid from other players helpful
like if u have a first aid person in ur party, it would be better for them to patch you up than just carrying sterilized rags in your pocket
i like
I'm trying to make the game a bit to my liking, something more realistic pulled towards horror🤣
im just trying to make my ideal server basically
The sounds mainly, for me it's what makes all the difference
Well, since I know some people are curious about the mod I'm working on (and because I want to show off a bit) I have made some pretty big steps forward in how I'm calculating damage now for the offhand attack. Turns out, the whole "SwipeStatePlayer" thing I found really wasn't going to work out, as it still didn't take into account the offhand weapons skills. So, this lead me back to square 1, and I have now re-implemented the weapon damage/hit reaction code for zombies in Lua. There are still some bugs, like I need to figure out the window and fence climbing state stuff, but overall this is working for everything and getting pretty much the same values as vanilla. This has also let me add my own "hit reactions", so zombies will react to the right when you hit them from the left and whatnot too. 😄 I also found there is a Hook that is unused where you can actually handle all of the damage calcs and stuff in Lua. So, I have added an option to hook into that so that my functions handle vanilla attacks too. Still very much WIP on that front, but this ensures consistency between hand damages, AND will also let me expose a whole bunch of stuff in the Sandbox options for combat. Will likely make that the default once I have everything working. Sorry for the book, just a lot to talk about here.
Here's a thing of my character hitting a crit because of a zed's back, but 100% calc'd from me.
just post it on the mod resource thread
where can i find this thread? here or steam? can you link it please?
this one? https://discord.com/channels/136501320340209664/1070852229654917180
thank you, didnt notice that thread exists, very helpful!
is there a way to disable debug mode while still in game?
or like disable most of its effects?
yo imma too looking to made mode for first aid(like more medicines)
panic animation but with checks
function MT.isFearless(pl)
if pl:isAccessLevel('admin') then return true end
if pl:HasTrait("Desensitized") or pl:HasTrait("Brave") then
return true
end
end
we really should add another channel just for animations lol
cant
Pretty sure this mod wil 5star quick
Its highly anticipated.
I have been periodically checking to see if it's or @thick karma 's had been released. Very excited to give it a try
This looks really good! Are you the using spacebar for the attack? Or did you choose a different keybind so you still have the option to push?
guys, anyone knows how to make tooltips(like painkillers have)? Cuz i was looking on youtube but for no avail
I'm doing something similar with climateFloats, it can change the climate settings globally but I'm having a couple issues with it
using setAdminValue doesn't really work in most cases, pretty sure it only works if there's an admin character on at all times
and the non-admin alternatives have weird quirks
what're ya trying to do with fog?
Good morning.
haven't done it myself but this is a likely candidate: https://pzwiki.net/wiki/Scripts_guide/Item_Script_Parameters/Tooltip
ty going to check it out
yea seems like you would just use the tooltip tag and define the string in Lua/Translate/EN
good. ty so much. one problem less now
my pleasure pal
can u help with another thing? ive found myself stuck on context menus. is there a way to make more than 1 action for consume . like in Open jackets mod i think. imma working on medical items and big contex menus would be terrific i think
ive found CustomContextMenu line but does this work with arrays? and if yes what is syntax for that
I'm confused with the rolls system in the distributions... Would it be a probability of the item being in that container?
arent roll is like random item from loot table?
ye
so prop of item be in container is proporshional to all items in table / to your item
no idea pal, someone here could probably help you but in the meantime it might be worth taking a look at how another mod does it and learning from there
yup found Spongie's mod he done that using item tweaker
gonna use that then
if i remove the rolls option, would the item be 100% in a container?
u mean u hand-placed item in specific container?
if so i guess - it will be there
but no rolls = no items there from loot table
im not sure that u will achieve what u want by that
I want the item always in that container with high probability, for test custom items...
For me to know that they are being generated
in that specific container
So u def need to use loot tables
Mb try to create special container that bound to ur specific loot table
yes, but i'm confused about this rolls option 
And in table let be like 4 your items and 1 control item then do several rolls and u will get ur item with high prop
In theory that must work nice but i didnt work with tables here yet. So mb there will be some technicalities
Is there a limit on the weight chance number? Because 0.5 is very rare...
example: items = { --"Base.p88p", 0.5, This number is very small and I believe that it is very rare for this item to be there
Which loot table u looking into now? So i can check out this myself
Anyway, I'm going to test with a value of 50 just to make sure the item is there🤣
to answer your question, I'm looking at this gunstorestorage ={ all={ rolls = 2, items = { "Base.132Box", 2, "Base.500Box", 2, "40Clip", 1, "Base.PPSHClip", 0.7, "Base.LewisDrum", 0.5, "Base.WitchySMGClip", 0.6, "Vest_WitchyCarrier", 0.6, "RogueGreaves", 0.5, "RogueArms", 0.5, "Shoes_Rogue", 0.2, "Gloves_Rogue", 0.3, "Base.medbag2", 0.2, "RogueWaist", 0.5, "Vest_RogueVest", 0.5, "RogueHoodie", 0.5, "RogueMask", 0.3 "Base.strapchest", 0.5, "Base.MVest", 0.5, "Base.m79", 0.2, "Base.WitchySMG", 0.3, "Base.TKShotgun", 0.2, "Base.Lewis", 0.2, "Base.PPSH", 0.4, "Base.ClericRevolver", 0.3, "Base.RogueSniperRifle", 0.2, "Base.MAS38", 0.3, "Base.MASClip", 0.6, },
Ok i guess up to 10 weight u must be safe for sure
Squawk
oh well Bag_JanitorToolbox = {
items = {
"PipeWrench", 50,
"Wrench", 50,
"HandTorch", 50,
"Hammer", 50,
"Saw", 50,
i guess u can max weight up to 100
so its like % as i understand
Interesting i can make it harder or easier
an item with 0.001 would be perfect and pretty rare
i guess so but u still need a loot table or to modify existing
btw vid of using loot tables https://youtu.be/N6tZujOPnDw?t=1152
This tutorial video will show you how to make a simple drink in Project Zomboid. I will go into the steps involved from start to finish. Read more below.
0:00 intro
1:08 Start
1:44 Searching for images to use in game
2:30 Searching for the Sound Effect
3:06 Creating mod file directory
3:54 Creating mod.info
4:34 Creating a poster
7:14 Adding ne...
I will use local distributionTable = {}
there is still a distribution in the folder called ProceduralDistributions I will get even more lost
u dont need that. use regular
Could someone explain the difference between standard recipes and evolved recipes? I don't think I quite get when to use one over the other.
In my case I'm trying to "transform" one item into a related clothing item (think newspaper into newspaper hat), which seems like it would be a candidate for an evolved recipe...but why not just use a standard recipe with the item as an ingredient and the hat as an output?
Is there some advantage to one over the other that I'm missing?
I don't know why there are 10 objects being distributed in different lines, but in the same container😓
I would only use evolved recipes for food in v41.
This makes it possible for multiple items to spawn per roll. (I think.)
So, if each of those lines gives a 10% chance of a saucepan to spawn, even if there's only one spawn roll, it's possible for there to be anywhere between 0 and 10 saucepans in the container.
I think the difference in chances between lines is meant to create a "median" likelihood, as in, it's most likely for there to be 1-6 saucepans, less likely for there to be 7-8, and very unlikely for there to be 9-10.
I guess so
Disclaimer being that I have no idea if I'm actually right, I haven't looked at the backend code, this is just the conclusion I came to based on my understanding of the roll/spawn system.
finally got it, but i still hate the roll🤡
Anyone worked with ItemTweaker API? I guess imma need some advice
It would be easier to identify all the containers in the world and there would be a chance for the item to appear in that container in the specific house, if not maybe in others.
Hello. Is it possible to change engineForce on BaseVehicle?
I don't know if it makes sense, but i have crazy ideas and sometimes it doesn't make sense.
I guess so, check out popular mods with big vehicles
They all have atleast 400-600 horses usually
And its must be edited cuz i ain't saw any vehicle with that numbers
Btw guys any suggestions for firstaid mod? Got +- easy autopsy system and going for medicines
more medicines is cool for me
it adds many more pills and tourniquet, hemostatic powder and syringes
Thinking about rework (atleast cosmetic) of vanilla drugs
I have not seen anywhere that the engine power was changed in lua. What mods are you talking about?
how this should help me?
generally modded cars are stronger
i think he means that
so this means higher power for modded cars
HEMT series mb? Im not sure about specific way of editing engine
If you give me a link, I'll tell you for sure.
Gimme a sec
maybe... ```Distributions = Distributions or {}
local distributionTable = {
kitchen_cabinet = {
isContainer = true,
item = {
itemName = "Beercan",
chance = 0.7
}
}
}
table.insert(Distributions, distributionTable)
function checkContainer(container)
if container.id == "kitchen_cabinet" then
if math.random() < container.item.chance then
container:AddItem(container.item.itemName)
end
end
end
Events.OnFillContainer.Add(checkContainer)```
it was just an idea... ignore it
Imma going to call it a day, gn guys
In this mod, lua does not interact with the engine power in any way.
Good to know, sry for misleading
And I want to edit the engine power through lua, but I didn't find any functions.
when you say engine power dya mean max speed? or something more specific
engineForce
So i will have to do the 10 lines to roll the items
Press F - engineForce=1000
Only if you want there to be a chance for multiple items to spawn per roll.
from what I can see there's no obvious way to change that variable directly, no
what're you trying to do?
I am trying to make a part that will change the enginePower of the BaseVehicle during installation.
okay, but for what reason? enginePower might not be the only way to achieve what you want, is why i'm asking
Logically, the part should make the engine more powerful. If you installed TwinTurbo, then the engine has become more powerful, right? You can reduce the weight, but this is not an option.
ah yea, that's why I was asking if increasing/decreasing max speed would do
you could probably make a part that you could install, which would increase the max speed
i'm fairly certain that maxspeed will also translate into like, better pulling power in relation to mass
not 1:1 but
ok. Is there a way to increase acceleration force?
not just max speed
And how does it work? Does the maxspeed affect the vehicle's force?
It's just max speed
yep
nevermind, you can set quality, loudness and enginePower with setEngineFeature(x1, x2, x3) respectively
where x3 is power
i don't know exactly what the difference between engineForce and enginePower is so if you find out then let us know
Yes, I can. But it just doesn't work. The forward force does not change, but the backward one does.
I don't understand why it works this way.
I don't even know what enginePower is
there's only engineForce in model's description
EngineForce is script (vehicleName.txt), enginePower in code (class BaseVehicle)
yea it looks like the only time enginePower is set directly by the code is in the exit() method
idk when that runs, I'd assume it's when a character exits the vehicle but that's a guess
Yes, I see, but why is it necessary? What for?
And that still doesn't answer the question. How to change EnginePower? The exit method is not clear at all....
im not making a mod but i think if someone turned the zombies into vampires or just based the zombies on the vampires in the book "i am legend" i think that would be really cool
you can't, there's no setter
Then what is the setEngineFeature method for, if that's what it does?
oh, that'll work
not sure why that didn't come up in my search 😅
if you only want to change the engine power, do vehicle:setEngineFeature(vehicle:getEngineQuality(), vehicle:getEngineLoudness(), newPower)
it still doesn't because it seems to be overwritten later in the code
yeah, it's going to get reset every time you get out
maybe set it back OnExitVehicle? not sure if that's fired before or after
I'd do almost anything to have some comments in the java
my guess why is maybe sunday driver/speed demon originally changed enginepower
it definitely seems like a leftover from something like that
I tried to do it. Yes, the method works, but the forward force does not change, and the reverse just changes. If I make EnginePower = 100, then the car will not go back at all. I don't understand why it works this way.
Thanks for the guess. I'll just check it out.
https://steamcommunity.com/sharedfiles/filedetails/?id=2931916573
done with commission mod for the day
Pray for me gamers, first attempt to see if the 4 new mods I added for the farming patch work well

I think your answer might lie in core.physics.vehicleController
I think so too, but I've already stopped understanding what's going on here. Names of variables and methods....
I looked. Yes, trait affects the car, but not in the way I would like to see it.
It kinda worked first try kinda didn't
Ты про что? setEngineFeature?
I'm sorry
No worries!! We just vibin
has anyone had issues with OnFillWorldObjectContextMenu not finding the same objects outside of debug mode?
when i right click on a tap in debug mode or with admin, it finds the tap on the square and does the context menu stuff as expected, when i do the same without it only finds the tap if i click on the part of the tap that bleeds into another square (and if i do this with admin, it picks it up twice)
if i print the size of the worldObjects table, without admin it is 2, and with admin it is 8
im going to try out since im using it almost the same way
Someone please kill me
Guys I'm trying to make the character sit on the floor with a specific keyboard key, but he doesn't sit and doesn't show errors on the console. Doesn't it work like that?
i havent really checked the table in debug/admin vs not so now i wonder
I was trying to get the Le Gourmet Revolution compatibility for seed packets working without having Le Gourmet Revolution enabled
One of the problems of having such a large patcher means I have to make 100% sure that I have every mod enabled

lololl
Head please.
If it's any consolation I think "wasting an entire day because of an incredibly obvious and easily fixable error" is a rite of passage for coders everywhere, so welcome to the club.
At least this isn't as bad as having to reprogram basically the entire farming system from the ground up
Apparently I was programming it extremely similarly to Filcher despite the fact I didn't even look at how it worked until I patched it in
i was testing it and it's still finding them. not sure what you mean tap, but it's a specific worldobject you are clicking? or is there a few in teh area you are using it for?
like a water tap?
not sure, i've gotten the report a lot and now i'm finally getting it myself
i'd be surprised if it happens to everyone since that's a pretty major feature that doesn't work
You can remove functions from events right?
yep
Looking to commission a armor mod for PZ/my server.
context:insertOptionAfter("Remove Light Bulb", "Change Light Switch Bulb", sprSwitch, ISWorldObjectContextMenu.onLightBulb, true, light, true, player_num, true, remove, bulbitem)
``` i'm struggling with using the onStart feature. anyone have any idea about utilizing `onLightBulb` here?
i can add the booleans for some of these and it will show i used them, but when i just use the arg themselves it just finds nil for bulbitem, remove, and light. i know it's my order or usage of the args here but i cannot figure it out
this was all i coudl find on it
insertOptionAfter(prevOptionName, name, target, onSelect, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10)
also no matter what i do player is always nil
is remove intended to be a variable?
it's looking for it so i'm guessing yea
As in like, local remove = whatever
i mean i assumed it would be used in the standard usage of the function?
ISWorldObjectContextMenu.onLightBulb = function(worldobjects, light, player, remove, bulbitem)
ohh I see
yea i'm using that vanill function to remove lightbulb
yea there is SO many also here
i got all to be recognized except player lol....
even though im using it fine earlier
has to be order im guessing
i literally got it all done except actually removing the damn bulb
How many PZ modders does it take to change a lightbulb
worst case i remove it completely and use vanilla method no custom

LOL
How do i make item compostable. Does it just have to be in "food" category or are there other steps?
Can't I use it to make the player perform a sit down action? I used it and I'm still standing...
EventSitOnGround local player = getPlayer() if player then player:reportEvent("EventSitOnGround") end
It might have a designated tag, I don't recall.
you're passing 8 parameters to a function that takes 5?
ahahah okay i did only pass 5 oroginally
it just all cam e up nil
i tried like every order
mfw how did i not
notice that
im
dying
Im so sorry nippy LOL
Thank you albion for existing in times of need
I am looking at items in items_food.txt, i see no additional tags aside of ones associated with food.
this is how i used it
contextRead5 = context:insertOptionAfter("Remove Light Bulb", "Change Light Switch Bulb", sprSwitch, ISWorldObjectContextMenu.onLightBulb, light, player_num, remove, bulbitem)
it seemed like this would be correct
Yeah now that albion mentions it, it just wouldn't pass the extra args.
So they would be nil.
when i dont use them at all though it throws an error saying player is nil
which hurts my brain
Huh..
Man it's been a month since i've touched any of this, no worries at all lol
I'm rusty
and you're sure they're not nil before the function call?
yes because i use player_num earlier to get perk level
id assume i can use it same right?
since it's being used in the same context as before?
i don't see why you can't
local function bulbContext(player_num, context, worldobjects, light, remove, bulbitem)
local sq = nil
for i,v in ipairs(worldobjects) do
local square = v:getSquare();
if square and sq == nil then
sq = square
end
local sprLight = v:getSprite()
local sprSwitch = sprLight:getProperties():Val("CustomName") == "Switch"
if not sprLight then return end -- if not sprite, exit function
local player = getSpecificPlayer(player_num) -- get player
local bulbLevel = SandboxVars.Nipswitch.Bulblevel -- Required Electrical level from SandboxVars
local zapLevel = player:getPerkLevel(Perks.Electricity) -- get player's Electrical level
local lowLevel = zapLevel <= (bulbLevel - 1) -- set lowLevel to true if player's Electrical level is equal or below SandboxVars
local contextBulb = context:getOptionFromName(getText("ContextMenu_RemoveLightbulb")) -- get "Read" context menu option
local dumbText = getText("ContextMenu_One") -- get text for dumb context menu option
local smartText = getText("ContextMenu_Two") -- get text for smart context menu option
local toolTip = ISWorldObjectContextMenu.addToolTip() -- get tooltip for context menu option
local previousPhrase = "" -- set previous phrase to blank
if sprSwitch and contextBulb and lowLevel then -- if book is in inventory, Read is in the Context Menu, and player's Electrical level is too low
toolTip.description = dumbText -- set tooltip to dumb text
local rand = ZombRand(1, 4) -- generate a random number between 1 and 3
local newPhrase = "" -- set new phrase to blank
while newPhrase == previousPhrase do -- continue generating new phrase until it's different from previous
if rand == 1 then
newPhrase = "You see a lightbulb socket and become intimidated..."
elseif rand == 2 then
newPhrase = "You wish you knew more about lightbulbs..."
elseif rand == 3 then
newPhrase = "Does my finger go in the light socket..?"
end
rand = ZombRand(1, 4) -- generate a new random number between 1 and 3
end
previousPhrase = newPhrase -- set previous phrase to new phrase
local contextRead6 = context:insertOptionAfter("Remove Light Bulb", newPhrase) -- insert new phrase into context menu where "Read" was
contextRead6.toolTip = toolTip -- set tooltip for new phrase
contextRead6.notAvailable = true -- set new phrase to not available
context:removeOptionByName(getText("ContextMenu_RemoveLightbulb")) -- remove "Read" from context menu
else
if sprSwitch and contextBulb and not lowLevel then -- if sprite found, Remove bulb is in the Context Menu, and player's Electrical level is high enough
toolTip.description = smartText -- set tooltip to smart text
local contextRead5 = context:insertOptionAfter("Remove Light Bulb", "Change Light Switch Bulb", sprSwitch, ISWorldObjectContextMenu.onLightBulb, light, player_num, remove, bulbitem)
contextRead5.toolTip = toolTip -- set tooltip for "Read"
contextRead5.notAvailable = false -- set "Read" to available
context:removeOptionByName(getText("ContextMenu_RemoveLightbulb")) -- remove "Remove Light Bulb" from context menu
end
end
end
end
Events.OnFillWorldObjectContextMenu.Add(bulbContext)
blam
Unrelated but related- I'd avoid using "remove" as a variable name if you can help it.
I believe it's reserved by lua.
i didn't think i've need it TBh because how it's used in vanilla
but i cant figure out.
I doubt it's the only thing causing problems, if it's causing problems at all, but just wanted to point it out.
context:addOption(getText("ContextMenu_RemoveLightbulb"), worldobjects, ISWorldObjectContextMenu.onLightBulb, lightSwitch, player, true);
this is for addoption tho
i'd assume it's not much diff than this
when i used this tho also error haha
ill try it and see what i get from it. i literally just want my custom option to initiate removing bulb haha D:
I remember addOption having a wonk order of handling functions but I dont recall the specifics, apologies
the first parameter is before the function, it looks correct to me
not woorldobject
Maybe try using OnPreFillWorldObjectContextMenu?
i do use that for event
That's what it was, I never understood why it was set up that way but eh
I think the vanilla uses OnPreFill
would that make the diff you think... it doesn't make sense but i can try
vanilla doesn't 'use' either, it triggers them
yea
Thats what i mean
insertOptionAfter isn't going to work with prefill
at the end
yea dont want that
Not necessarily
it wouldn't matter tbh
it's working
the ONLY part that isn't is onlightbulb
i'm using bad args or bad order
i got all context working perfect
just need to actually change bulb when click 😄
ill try it again with fresh mind here and report back
maybe i did something stupid lol
i know i dont need bulbitem or remove
i think thats only for submenu

both vanilla options use the same function
if remove is false then it installs bulbitem, if remove is true then it uninstalls the existing lightbulb
Is there a reason why people don't use sandbox variables at this point?
rarely
they're useless for per-client options and there are some limited things that load before sandbox options so they can't be used to affect them
ah, per client options, yea, that makes sense
big help actually ty
If I want to remove an event, would the syntax be Events.EventType.Remove() ?
yes
okay 👍
haha nice
Time to see if it works alongside LGR, if it does then
very nice
Been coding since 9:30 AM. It's 2:30 PM. :D
i use it so im extra happy lol
mood
Made a lot of progress.
Is this the correct way to remove items from the distro for a zed's inv?
RemoveItemFromDistribution(SuburbsDistributions["all"]["inventoryfemale"], Bullets22Box, nil, true)
RemoveItemFromDistribution(SuburbsDistributions["all"]["inventorymale"], Bullets22Box, nil, true)```
I do not control the sheep
Progress is not slowing down.
Le Gourmet Revolution bell peppers growing alongside Rugged Recipes cucumbers
is there a method to get the item that the player currently has equipped, primary or secondary? I can't seem to find it
I only see which item when it's the events onEquipPrimary and onEquipSecondary
declaration: package: zombie.characters, class: IsoGameCharacter
context:insertOptionAfter("Remove Light Bulb", "Change Light Switch Bulb", sprSwitch, ISWorldObjectContextMenu.onLightBulb, lightSwitch, player_num, true)
works TY for that insight also with that boolean
I might be moving onto class discovery & class adapter API for my transpiler by the end of this weekend. 🤤
deciding if make a mod that lets players use tiles to build houses from scratch....
sweet, thank you.
like More Builds and More Builds+?
Been considering making a schematics mod for PZ.
AKA schematics of houses that you can apply.
havent really looked at them but it would use existing tiles. so lets say you have the addams family map on your server and it comes with perts tiles for that
zombies destroy the house windows... doors
you can replace them and they will also have player built properties as well
since those tiles are on the server you would be able to replace them after you destroy previous wall/tile
ill look into those other ones but i dont think they work exactly the same
would be nice if your windows are broken though and you can replace with exactly same tile that matches your house you take over. if there is a mod that does that, please feel free to let me know
I have code that repairs windows.
for all maps* not just specific
can't you replace windows in vanilla
Yeah.
i meant for non vanilla maps and tiles
yea, sounds like More Builds, the problem with those mods is they just blanket the item cost for the building of the item so it's not really balanced.
like, military crates with 120 cap cost 2 planks and 2 nails
yea i see what you mean. i'll check into how they work, i'm already working on util for handling scaling of craft amounts by level
It seems I am not getting the type of item correctly. TVs and Radios are set under "Radio", and that's what I what to check for. What would be the correct method? Or have I misunderstood something
the type as shown here
handItem is nil
i see that. Does the event not give the item being equipped properly?
also getType() returns internal item name
shoot.
I am following this doc, but maybe its outdated
https://pzwiki.net/wiki/Modding:Lua_Events/OnEquipPrimary
never worked with that event before - the wiki can be unreliable but i'd be shocked if that event really didn't pass the item
probably an unequip
may as well bypass the parameter and just call the item from the player object 🤦♂️
it looks like it does pass the item, so it must be an unequip
if you start your function with something like if not handItem then return end it should be okay
i will try that, thank you kindly
What does this method do
https://projectzomboid.com/modding/zombie/inventory/InventoryItem.html#getCat()
declaration: package: zombie.inventory, class: InventoryItem
itemtype enum
seems to be categories but not the ones defined by the items themselves
Is there a way to find all the distributions? I'm still fighting this and it doesn't seem to be doing what I want and I'm pretty sure it's because the distribution I'm trying to use isn't correct.
for key, value in pairs(SuburbsDistributions["all"]) if key:contains("Outfit_") then removeFunc(...) end
wonder if that would work @humble oriole
Bullets22Box should be string "Bullets22Box" or "Base.Bullets22Box" ?
...how do you actually log to the console
is it this method: writeLog(logger, myLog) and if so, what's the string for the command terminal or the in-game command console
print("Hello World")
yes
the game threw me an error, so I'm assuming it's not simply print() and within a class
it is just print
hmm okay, then ill get the error that I'm referring to in a bit
strange. now it worked without an issue
why did the game then throw an error for the same exact line? this is so frustrating
apparently string concatenation is not a thing in lua
that was my stupid issue
anyone familiar with if getProperties():Val("PickUpLevel") can be set? i thought i seen it was possible but now im not finding anything
strings are concatenated with .. not +
What's your mod about? 😮 Is always good to see compatibility with Snake's modpack!
It's just a massive patcher mod that makes farming mods play nice, since I noticed very few of them decided to "be friends".
11 mods are officially supported in the patcher now.
Snake's included.
😮 nice!
It hasn't really blown up or anything, but here's a link if you'd like it. https://steamcommunity.com/sharedfiles/filedetails/?id=2895419952
Unsure of the stability at this exact moment since I just released an update for it adding 5 mods to the mix, but it should run alright from brief testing.
i can say it makes a huge diff prior to update so looking forward to it
i dont even use lgr either
also has that quick fix for not needing to sow seed packet thing
That's the especially nice thing about this patcher, I made every mod an optional thing.

ty for your efforts!
sarghshtrh thank you for appreciating it hehe
This has cost me
countless hours ill never get back
lolol
You just described modding
fr
i realized restarting my game 60 times is roughly an hour of my time D:
All December and January without modding. Yesterday I came back and I already spent about 10 hours only modding, if not more...
didn't think about it before
like bare bones no mods lol just hosting a game quick
realoading lua for me so hit and miss sometimes also depending on what i change
If I want to call a field, is the syntax scriptItem.isTelevision ?
Because calling this public field from the Item class (https://projectzomboid.com/modding/zombie/scripting/objects/Item.html#isTelevision)
is giving me nil, as though it doesn't exist
declaration: package: zombie.scripting.objects, class: Item
you can't call fields directly most of the time
You are not able to access variables directly, and have to use a getter function to get the value. if there's no get function then you can't check that variable, unfortunately.
thats very unfortunate. I just need to check if an item is a TV or not
am I able to call that from InventoryItem?
sort of - it's on Radio, an InventoryItem subclass
looks like I can, if the parameter passed by the event includes it
I will try it out
does it need to be explicit when it's base?
Also, I have a pretty big question about IsoObject containers. I'm running into an issue when I remove items from the isoobject on the server side, I have to wait a short period of time before I'm able to put items into that container again or else I get an error. I was able to lower that time with a request sync, but I'd love to get rid of it completely. The error has to do with addtoItemSendBuffer, it's like after I remove items from the inventory it isn't ready yet to receive items.
omg it actually works now 😭 I spent 4 hours suffering on this stupid condition check
albion you will be my top credit if I get this mod working and published
Could someone help me figure out why my gun isn't appearing when the character equips it in game? Symptoms:
No gun model appears in hands or on the back
Character acts like the hands are empty (shoves instead of pulling a trigger while aiming)
While the invisible weapon is equipped, aiming does play the "M16BringToBear" sound I defined in the weapon's script file.
Magazine context menu does not have an option for "Load/Insert into gun"
do you have the model instantiated in a txt file? stupid question, but just to make sure
Define instantiated
the model is defined in its txt file
since models have a .x or .fbx and a .txt file that points Java to it
it sounds like an item script issue to me
So... trying to imitate vanilla, I have 2 files in /media/scripts:
One script for weapon stat definitions
One script for item models
I tried putting both the model definition and the item definition in 1 file like Blackbeard's tutorial said to do but it didn't work.
can i see the item script? i think if the model was the issue it'd still behave normally otherwise
there just wouldn't be a model
are you using blackbeard's tutorial for the nuka cola mod? because it is outdated to some degree
i recommend downloading a mod that adds in one firearm (like the fallout ones) and look at its file structure
& files
Uh... the other one is too big, how do I blockquote text in discord?
Oh man..
Translating Lua string library to JS string lib.
let reversed = 'Hello, World!'.split('').reverse().join('');
lol
Jab, i saw you working with TypeScript and lua files. What are you trying to do?
does anyone know if comments with # are allowed in scripts? i've never seen that before and the parts below the first one seem to be the parts that are broken
Just a note, that was a very recent change. The # commented sections were notes from what the file was like before. I'll try removing them again...
yeah that's what i thought
I'm writing a 1:1 Lua to TypeScript transpiler.
I made it possible to mod PZ using TypeScript. I'm rewriting one of the three transpilers it runs on.
Guys this item is from a base game right?table.insert(ProceduralDistributions.list["MeleeWeapons"].items, "Base.medbag2"); table.insert(ProceduralDistributions.list["MeleeWeapons"].items, 1.0);
also, is this in scripts/ or a subfolder? this won't be causing your issue but if it's scripts/models_items.txt, that is a very generic name and mods with the same file names will cause conflicts
you should always be careful about this, because of steam workshop weirdness you can't safely change your file structure after release
scripts/mymod/models_items.txt is fine of course
ive never seen MeleeWeapons as a list, double check ProceduralDistributions.txt in the base game
Very neat, but what would it accomplish
if my item is from a mod, how do i import it instead of the base? Instead of using Base.medbag i wanted it to be from my PWp.medbag mod, example
I explain this on the repo and the original paper I wrote explaining why I did it. It's for type-safety and compilation checks.
I want those in my coding environment and Lua lacks this as a language because it isn't designed for this sort of thing.
You know what you're working with. Literally.
you need an import statement that looks like import { NameofPWPmodule } at the beginning of the txt file
It'll tell you if you apply something wrong.
When PipeWrench updates to an updated release of PZ and your code doesn't call a revised API call correctly, the compiler will immediately tell you this.
You won't need to thumb around to find out why, if you know the offending code to start with.
You will save countless hours of time debugging.
If it is lua, then i think its require "nameofthefileitcomesfrom"
Yes, it's on the moon
i find it funny that PZ is using lua in ways it is not intended, its very specific 🤣
otherwise you can also use the prefix, without importing, i think
you make a prefix by using module mymodulename
it would otherwise throw an error if the mod module doesn't exist
Changing the # to // where I had them has not changed any symptoms, but I'll keep the proper comment format in mind.
/Zomboid/mods/Arsenal/media/scripts is where I have the .txt files. Should I just change the models_items.txt filename?
Here's the mods I'm currently working with, "Arsenal" is the mod I'm making:
anyway going to try both ._.
either way works
it is possible to constructors for objects from the java classes? If I want to create an object in the world
or do I need to use a method that constructs it for me
example: PocketTVIso = IsoTelevision(cell, square, nil);
sorry, i'm very confused. If the script is in lua i will use require, if not i will use module?
finally 
you only need the import statement if you have module moduleName {} in a .txt file. It's for the java scripts
oh wait, you just added support for Grow Medicinal Herbs? Awesome, thank you. I was wondering if this patch and that mod were compatible
local PocketTVIso = IsoTelevision.new(cell, square, nil);
For Java constructors, use .new()
For Lua constructors, use :new()
It's a technical gotcha.
ah good to know
if I keep that variable local, will running that same function over and over overwrite the variable? I want the event to only have one instance of that object at all times
Fresh off the presses hehe

Working on a Better Batteries update too because apparently the way I was going about it in the past made duct tape in a friend's server godly
Near infinite duct tape!!!
not a bug its a feature
yess
require "Items/ProceduralDistributions"
require "Items/VehicleDistributions"
require "Items/ItemPicker"
module PWp
table.insert(ProceduralDistributions.list["MeleeWeapons"].items, "PWp.Supersword");
table.insert(ProceduralDistributions.list["MeleeWeapons"].items, 5);
table.insert(ProceduralDistributions.list["Foods"].items, "PWp.Heineken");
table.insert(ProceduralDistributions.list["Foods"].items, 5);
-- table.insert(Distributions, 1, distributionTable);
local function isMod(mod_Name)
local mods = getActivatedMods();
for i=0, mods:size()-1, 1 do
if mods:get(i) == mod_Name then
return true;
end
end
return false;
end
you don't need module in .lua, I believe
I don't have a lot of experience with the imports, I'm sorry if I am confusing you with my amateurity 😭
I'm new to this game system the same on lua and im not experienced either 
Did a ton of cleaning on my string stuff.
:D
Looks way better for string literals.
0-index translation also.
ahhh, i think I have hit a wall with what I am trying to accomplish
It is possible to link an IsoObject (an object placed in the world) with an InventoryItem (the item that lets you place that object)?
I don't know how the game handles it, and I essentially just want to make an InventoryItem have some properties of an IsoObject (using the player as a reference point in its "position")
scripting blocks seem to strip out only /* */
ScriptParser stripComments
depends how it's added, the check is a == b
Not sure about the buffer thing, what kind of errors happen when you try to add items?
Got 8 hours in for my code jam weekend so far. :D
Kahlua Transpiler
split though?
Split?
LOG : General , 1676159167875> 17,467,539> ERROR: addToItemSendBuffer parent=zombie.iso.objects.IsoThumpable@38ed5454 item=zombie.inventory.types.Food@ef2783a
DEBUG: Multiplayer , 1676159175909> 17,475,573> ItemTransactionManager.receiveOnClient> 2 [ 698125665 : -1 => -1 ]
DEBUG: Multiplayer , 1676159248839> 17,548,504> ItemTransactionManager.receiveOnClient> 2 [ 445151282 : -1 => -1 ]
LOG : General , 1676159248939> 17,548,603> ERROR: addToItemSendBuffer parent=zombie.iso.objects.IsoThumpable@38ed5454 item=zombie.inventory.types.Food@7fa4ca8d
LOG : General , 1676159248939> 17,548,604> ERROR: addToItemSendBuffer parent=zombie.iso.objects.IsoThumpable@38ed5454 item=zombie.inventory.types.Food@275bfa06
LOG : General , 1676159248939> 17,548,604> ERROR: addToItemSendBuffer parent=zombie.iso.objects.IsoThumpable@38ed5454 item=zombie.inventory.types.Food@12942158
LOG : General , 1676159248940> 17,548,604> ERROR: addToItemSendBuffer parent=zombie.iso.objects.IsoThumpable@38ed5454 item=zombie.inventory.types.Food@5693fb50
LOG : General , 1676159248940> 17,548,604> ERROR: addToItemSendBuffer parent=zombie.iso.objects.IsoThumpable@38ed5454 item=zombie.inventory.types.Food@2e60b04e```
lua has no string split
it just hit me
If it's because of my use of split, that's generated code to handle a missing string utility in JavaScript.
that's like greek to me
Grabbing food and eating. Might write a format utility that's also not there.
All good.
Lua has some tools that JavaScript doesn't. Vice versa.
I have to solve that for situations.
have you tried getting / renewing the container from the IsoObject before you add items. I suspect you have a cached invalid container.
How would I do that from the client side
function HBGPlungeBiowaste:perform()
if self.homebiogas:getContainer():getAllCategory("Food"):size() > 0 then
CBioGasSystem.instance:sendCommand(self.character,"plungeBiowaste", { { x = self.homebiogas:getX(), y = self.homebiogas:getY(), z = self.homebiogas:getZ() }})
else
self.character:Say(getText("IGUI_BioGas_ContainerEmpty"))
end
self.homebiogas:getContainer():requestSync()
ISInventoryPage.renderDirty = true
ISBaseTimedAction.perform(self);
end```
are there any mods that create an object that follows the player? as in its separate from the player, and not a vehicle
there's a dog one, not sure how great it works
That dog is scarier than the dogs from silent hill 1.
I have found a way to have a "following" object, but its issues are that when the player moves onto a new square, it doesn't remove its instance from the previous square (a logical memory issue), and when my item unequips, it doesn't remove the last instance (fixing it rn)
Yo! I'm someone with absolutely no modding experience whatsoever with any game. I'm trying to change a texture or two and essentially make my own personal addon for friends to use. Could I get some help and talk to someone about what I'm trying to do?
BUT it doesn't help my issue, as I want to have the object have functions, and not actually appear
you can just publicly ask questions here. Overwriting textures should be pretty easy, you just make a dupe file that replaces the vanilla one
I'm unsure how to actually access any of those files, how to structure them into a folder, etc.
i recommend looking at https://discord.com/channels/136501320340209664/1070852229654917180 to start getting an idea of what you want
damn, embed isn't working
I basically want to change the name of rosewood, and then change the texture of the map you can get to accompany the name I changed it to
How to force wake up while sleeping?
changing name is going to be media/lua/shared/Translate/EN/ and the preview image, i don't know
look at Project Zomboid's media folder
It's not so simple. There are objects like Rosewood Road Sign, Rosewood Map etc, also TV phrases.
you're right
ahhhhh
Hm, I think it's just forceAwake()
dementia
like, I don't understand this at all
the maps folder is the physical positions of everything
it doesnt have textures or text
textures are in their own folder, and the text is in that folder above that i told you
Wish I could code on this phone
ahh okay
Too lazy
It is. You're right
Google Play: Terminal Emulator NO ROOT NO VIRUS 100% FREE NO ADS
when I change the textures I want to change, and rename things, how do I organize it properly to upload to steam workshop?
you organize it the same way it appears in the media folder
for the mod info itself, it has a specific folder & file structure that you need to make
theres an old tutorial that shows uploading it properly, one sec
You should check the tutorial link I sent you
there is a github link showing you the workshop directory structure.
and there's this video
https://www.youtube.com/watch?v=N6tZujOPnDw
This tutorial video will show you how to make a simple drink in Project Zomboid. I will go into the steps involved from start to finish. Read more below.
0:00 intro
1:08 Start
1:44 Searching for images to use in game
2:30 Searching for the Sound Effect
3:06 Creating mod file directory
3:54 Creating mod.info
4:34 Creating a poster
7:14 Adding ne...
I used this to figure out how to upload to the steam workshop
ahh okay
I also used that link when I worked on the textures in Meditation (the other link I sent you), though it was missing some stuff about getting the world models to look right in your hands. @rigid hull
Just updated Better Batteries, fingers crossed that everything doesn't immediately combust and I don't get a bunch of angry comments!

That's something that I don't deal with because modders are my users.
whats a good way to store a variable in memory
ERROR: General , 1676162706280> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: attempted index: items of non-table: null at KahluaThread.tableget line:1689.
ERROR: General , 1676162706280> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: attempted index: items of non-table: null```
two variables, one constanting overwriting the other?
what you're referring to can't be found
yes , i believe that the error is .list["MeleeWeapons"].items,
Store a variable in the table of your Lua module?
But I don't know how to access the items
nvm
table.insert(ProceduralDistributions.list["MeleeWeapons"].items, 5);
table.insert(ProceduralDistributions.list["Food"].items, "PWp.Heineken");
table.insert(ProceduralDistributions.list["Food"].items, 5);```
I'm drinking and lurking
if your module is your mods module then you dont need prefix
is line 8 that first line?
unles PWp is another mod
yes
try removing the prefix, as Nippy said
I dream of the day when all the API are intuitive and documented
if your items.txt script starts with module PWp then you dont use prefix
if you import Base you also dont use prefix Base.
only use prefix if the module is not imported or created
the API is documented. But not in an understandable, guided format 🤣
You're giving the code too much credit.
i got it
i wish it said somewhere that LuaManager.GlobalObjects is where all of the global functions are, rather than passing it through word-of-mouth
because I had no idea until someone told me
I don't think that you should need to go and look for that if the API were documented and dry code.
i read this on PZ WIKI and still got it wrong
PZ wiki is outdated rn, don't use it as a reliable source
PipeWrench is a prioritization of documentation and type forwarding to combat that very issue.
is PipeWrench the TS transpiler?
More. Three transpilers, two that I wrote.
It's a node environment for modding PZ with typings of the entire codebase that is exposed for modding.
hmmm, it's not possible to write in lua within that transpiler, is it
it has to be node and TS
It tells your IDE what you're working with.
You absolutely can.
Lua can be written and interfaces to communicate with Typescript
so, could I set my root directory to be the Workshop content folder of a mod, write .lua and .txt files, and PipeWrench interprets all of it with a node server?
something like that? 😅
More like you can write Lua and Typescript that compiles to Lua.
i am using this code for testing in lua/client, it saves me a lot to test sounds of some items ```-- General mod info
local MOD_ID = "YOUR MOD ID";
local MOD_DESCRIPTION = "adds new items to the game.";
local debugItems = true;
-- Functions
-- Prints out the mod info on startup.
-- Add some items to the player's inventory for testing purposes.
local function giveItems()
if debugItems then
local player = getSpecificPlayer(0);
player:getInventory():AddItem("modID.ItemNAME");
player:getInventory():AddItem("modID.ItemNAME");
player:getInventory():AddItem("modID.ItemNAME");
end
end
-- local function getRandomCondition(_item)
-- _item:setCondition(ZombRand(_item:getConditionMax())+1);
-- end
-- Game hooks
Events.OnGameBoot.Add(info);
Events.OnGameStart.Add(giveItems);
Is there a way to add recipes via Lua, when my own one loads, if it detects other specific mods are "installed"?
I don't like writing Lua but I know it better than most since I am writing a second transpiler for it.
yeah its possible, you should take a look at some mods that patch within their code to get a sense of it
i don't remember how it works, but you somehow refer to the mods installed and check if its enabled
Fair enough. You wouldn't happen to know an example of a mod that does that, off the top of your head, would ya?
Most of the ones I know simply make the patched mod a requirement and assume it's there lolz
my brain is blanking rn
umm ill take a look
ah, speak of the devil, this mod just got updated. It patches for several mods internally
https://steamcommunity.com/sharedfiles/filedetails/?id=2895419952
No worries, I can do a search for them; just didn't know if ya knew one already.
C style syntax is king.
Oh, alright lolz.. I'll take a look at it, thanks skulker
i wish this server let me change my server name to my steam one 😮💨
Literally any syntax other than what Lua uses is an improvement haha
lua does all of its dumb syntax for "speed", yet PZ uses it for different reasons
This fact is why I spent 8 months crafting PipeWrench
That said though, Lua is an excellent choice for what they're doing here. The only HLL faster than Lua, for specific tasks, is C, which is NOT very friendly, especially for new modders to the game to learn...
Lua isn't for scalability
could you imagine ...python instead of lua?
-pukes-
i'd die tbh
PZ Lua is well beyond the threshold of concern for the scalability argument to be a valid discussion.
Py wouldn't really be an improvement either... same syntax style that's opposite from the mire common languages, and, slower than Lua by a massive degree..
Jython. Look it up.
hey babe, have you jompiled your Jython jile for your Jroject Jomboid Jod?
TBH though, scalability isn't exactly a requirement as far as the game design/concept goes, so although you're completely correct there, it doesn't matter as far as the choice of language to use goes.
Kahlua isn't real Lua.
Take a look at ISUI
As someone that uses Lua regularly because yes, Kahlua just exists.
No, but it's still faster tha most other languages, simply due to it's extreme simplicity (which is the main point of Lua in the first place).
Gal does have a point though, Lua is the fastest scripting language so
It has design flaws because Lua doesn't have a built-in checking solution for OOP -like designs.

When I started adopting OOP for the first time I learned that Lua wasn't all it was cut out to be
It made me sad
Lua, and every other language meant for scripting
but then TS exists and stuff so...
Right and that's what I mean.. For general purpose, Lua is a terrible choice, but if you're making a game that has needs that fit within those limitations, it becomes an excellent choice. As far as PZ goes, it likely fit the bill perfectly at the time.
Lua isn't designed with OOP in mind. You can implement it but lua won't support it out of the box. Lua is designed for small scripts
Yeye
local option = context:addOption(
Is there a way to get the link to the option AFTER call?
context:addOption(......)
local option = ???
It's possible via funny tables but it's just
pleh
I'd rather use C# or something for that type of thing
I MADE A SPRITE THAT FOLLOWS THE PLAYER
...kinda
Don't think so(?)
Can you make it a pepsi instead? lolz...
/s
I use Typescript because it is made for transpilation and provides error detection to keep my code consistent at scale.
It returns the option instance from the function call, either save it in a variable for later or do the top thing.
Unless there's some wonk workaround, but knowing zomboid there probably is

Also afaik my Java to Typescript transpiler is the most advanced Java to Typescript transpiler that exists. XD
Huh, you learn something new everyday.
Probably because noone in their right minds wants to convert to Java....

I translate deep generics from the Java language so all PZ typings from it reflects accurately.
1000% accurate
pepsi cola?
hahah, yes yes yes
I feel bad cuz I'm trying to help then I end up being wrong and it's aaaaa
I converted to TS but ya know....
I wish I had brAin
It haunts you
Java generics when transpiring is a bitch.
This isn't even what I'm trying to accomplish argrghhhhhh 🤦♂️
Honestly, I wouldn't take it like that. There's often many ways to do something in this game, as far as data goes ^-^
I suppose you're right there-
TBH only reason I don't care for TS is because it is quite literally just a wrapper around JS.
Plus in order to run anything written in TS, you end up having to compile to JS anyways, 95% of them time.
I wish I could save, but I need it in an injection 🙂
ISWorldObjectContextMenu.doSleepOption = function(context, ...)
old_fn(context, ...)
local option = ???;
...........
end```
If you don't like js syntax then yeah I understand
ohhhh I see what you're doin now
Yeah that makes sense
Sorry for leading ya the wrong way on accident hehe
TS is used primarily as a superset of js. It's a transpiler language though so it can convert to anything
I primarily write in C#, JavaScript, and PHP, so I'm used to those styles.
I only really know Lua and Java tbh
I'm learning a bit of C# and Python tho
Python feels really weird compared to Lua-
I both love and hate indents being my syntax
I use TS for what it can do as a mediator not for js syntax sugar.
I would recommemd learing JavaScript TBH; its the easiest language for learners, despite people saying Py is easier. Py is in fact easy, but unless you plan to never touch any other language, it's terrible to learn because every other language commonly used, is completely different in syntax, compared.
Py is by all rights a good, powerful, and flexible language. Just.. not really great to learn if you intend to learn other languages lolz
What an insanely useful language TS has been for me over the years
is there a method for moving IsoObjects? (as in keeping an object, and not creating it and destroying it)
If haxe was good I would be using it now.
I've taken a lot of my knowledge from Lua and successfully applied to to Java when I was in school, so that was a pleasant surprise.
It's saying in console function: PWp_ProcDistributions.lua -- file: PWp_ProcDistributions.lua line # 13
(PWp is my mod test)
ERROR: General , 1676165699578> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: attempted index: items of non-table: null at KahluaThread.tableget line:1689.
ERROR: General , 1676165699579> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: attempted index: items of non-table: null
table.insert(ProceduralDistributions.list["MeleeWeapons"].items, 50);
table.insert(ProceduralDistributions.list["Food"].items, "Heineken");
table.insert(ProceduralDistributions.list["Food"].items, 50);```
I have to use something like require local/do/item ??
Only reason Python is tempting is because of the number of jobs that'll go "ooga" if you have a cert in it or something.
you only require the distrib files you need to merge into
UI snd transpilers has become a part of my trade thanks to pz xD
you should only have one
Which honestly makes no sense really... Py isn't really any better than other languages, for most things. My legacy C# from 8 years ago still runs faster and has less errors than the equivelant Py version for example.

require "Items/ProceduralDistributions"
thats it
I enjoy C# endlessly more but that's just how it be
then the rest should be fine
Even then I'm still learning it
Python was a protest to Pearl.. like who cares lol
In a nutshell C# just seems like Java but done right.
I was trying to access the items script folder

People still use Perl? Geebus.. I learned that like... 20 years ago almost
Seems it works. Thanks!
local TEXT1, TEXT2 = getText("ContextMenu_Sleep"), getText("ContextMenu_SleepOnGround")
local old_fn = ISWorldObjectContextMenu.doSleepOption
ISWorldObjectContextMenu.doSleepOption = function(context, ...)
old_fn(context, ...)
-- get last option
local option = context.numOptions and context.options[context.numOptions - 1];
if option and (option.name == TEXT1 or option.name == TEXT2) then
print('Success!')
end
end
I'm laughing way too hard IRL with python rn
you can access it without a require I think. I'm going to post what I use for distribution injections
We both know that python doesn't even know what it wants to be
Oh, don't even get me started on how I was gonna have to learn Ruby just to modify my other favorite game

Watching blender is proof
`local function AddLootToType(itemName, containerName, itemChance)
local containerData = ProceduralDistributions.list[containerName]
if not containerData then
print("Container does not exist. Are you sure you typed it in correctly?")
return
end
table.insert(containerData.items, itemName);
table.insert(containerData.items, itemChance);
end
-- Example Add
AddLootToType("Item ID", "ArmyStorageElectronics", 1)`
No require required
you dont need to require any of your other files unless you are calling anything specifically from them. scripts do not count
Like, I'll admit Py is good with ML amd some other concepts, but beyond that, I don't understand this mad rush to convert perfectly working apps to some new language, just because it's new.. Like, Py is slower than the C's, and provides less system access, resource access, etc... like whyyyyy??? lmao
Ruby to Lua transpiler when?
I had to learn Ruby for making games in RPGEngine.. ;-;
Hahaha
I write transpilers. I'm by definitely insane.
....and they have since switched to JS for the engine scripts, so that's a couple years of my life wasted lolz
RPGMaker was the one I think for me
OneShot runs on it.
Yeah, their engine. That exact one lolz
I was considering sub-contracting to type RPGMaker. True story
o?
Yup
Well that's a feat in itself... You understand Japanese?
Welp, you can tell I'm old because it took me a second to realize you meant 2018, not 1918... 
We may not be talking about the same thing then Jab; Degica is a Japanese company, not Russian..
True. I had an opportunity to suv-contract for a Russian friend to type the RPGMaker JavaScript codebase.
Would be kinda surprising either way that they would even consider talking to an outside party too; back in 2008/09 they wouldn't even talk to American companies for the US port of their engine.
I mean.. I don't blame them.

(they even tried shutting down our forums from what I remember, until they realized that forum happened to be where a massive number of scripts used in games on their engine came from lolz)
Does anyone know if there is a problem with non-workshop mods? In testing my problem, I subscribed to a single gun mod, copied the files into my mod and unsubscribed. Then I put my mod in "C:\Users\myusername\Zomboid\mods" and the exact same problem happened... everything works except for an invisible gun model. WHYYYYYYYY
Can you confirm that model is working with the Steam version?
Reminds me of the days when Nexon DMCAd the MapleStory private servers when I was into modding that game
It is. Example is the MCX RATTLER mod.
I was never into that game, so I am unaware of that lolz.. Sounds bad though.
Nexon= Korean EA
Huh, okay well that kills my train of thought then. Have you downloaded some mods from Nexus to see if their file structure is different? That's probably what what I would check next. I know that mods on Nexus doesn't require the Workshop folder structure, so it may be that..
There's a thought, I'll try that.
Aye, and def lemme know if that works; I've been thinking of uploading to there myself maybe too lolz
Make some of my stuff available to non-Steam users too. Plus free download points I can convert to IRL moneh each month haha
Alright, welp, time to go re-read that answer I was given forever ago and check into adding recipes dynamically.
Should I upload my sprite drawing code somewhere as a resource? It has good potential but I have no clue what for
will this load a mod item? And not base item?
I'm trying to understand how to generate the item i created from the mod inside the containers
still don't understand how the distribution of modified items from mods to containers works in lua
The function I posted above injects items into the procedural distribution. I don't know if that's what you're trying to accomplish
you simply copy the function and call it
and it goes into lua/server/items/Yourfile.lua
No difference in the file structure of a Nexus mod that I can tell, but I did notice this in a /scripts file (models_lightsaber.txt):
`model weapons_lightsaber_staff-light
{
mesh = weapons/2handed/weapons_lightsaber_staff-light,
scale = 0.95,
attachment world
{
offset = 0.0000 0.2900 0.0000,
rotate = 0.0000 0.0000 0.0000,
}
}
'
"attachment world {...}"
What does this function do?
Ok, good to know.
This is infuriating. I've literally copied someone else's files that work and put them in my own mod and suddenly it doesn't show the model anymore.
did you compare the naming convention used in the scripts themselves?
even one cap letter or underscore would do it
Yes, I've been over that part with at least 4 different mods as examples.
What is "WeaponSprite" referencing? Both in game and in files.
media/textures
The entire folder or something more specific?
if weapon> media/textures/2handed or 1handed
is the location of the weapon texture
I changed the images by photoshop
So you are saying that "WeaponSprite = blah" defines the texture to apply as found in /media/textures/blah.png?
yes
I changed the texture of a weapon through photoshop, but I don't know if it's the right thing, because i noticed a problem in the drawing
example
So what does this refer to?
model mygun
{
mesh = weapons/firearm/mygun_model,
texture = weapons/firearm/mygun_texture,
}
The texture for the model itself
That part I don't remember. I think model x?
Then what is the difference between texture and WeaponSprite?
A texture is what is applied to the model itself; basically the image that gives it colour, lines, etc.
No clue where a weaponsprite is used
Ok... this might be it. In the following function of /media/scripts/mygun.txt, what does the bolded portion need to match? A function? A filename? A variable?
model mygun
{
mesh = weapons/firearm/mygun_model,
texture = weapons/firearm/mygun_texture,
}
That's just the name you want for the model; you reference that in the item definition.
So for example... (one sec, grabbing an example from my current mod)
So it needs to match:
item mygun
{...}
item PlantFiberCord
{
DisplayName = Plant Fiber Cord,
DisplayCategory = Material,
Weight = 0.15,
Type = Drainable,
UseDelta = 0.1,
Icon = PlantFiberCord,
WorldStaticModel = PlantFiberCord,
cantBeConsolidated = false,
}
model PlantFiberCord
{
mesh = WorldItems/Twine,
texture = WorldItems/PlantFiberCord,
scale = 0.55,
}
Notice the WorldStaticModel in the item definition, referring to the model by the same name?

