#mod_development
1 messages ยท Page 521 of 1
well the world is running and I'm logging these in Events.EveryTenMinutes on the server, it stays 0
mhm
I messed up, sorry. My test player died and I didn't notice. ๐คฆโโ๏ธ
so it works you get the safehouses?
hey man, could you give me a hand with this lua? i model for a long time but just started messing with lua... i want to make this Glove here (Hand body location) to give +4 Strenght when equiped, the code dont give errors but im missing something here because it dont give the bonus:
local function PowerGlovesEffect()
local player = getPlayer()
local perkLevel = player:getPerkLevel(Perks.Strength)
if player:getClothingItem_Hands() == "Wiz_BatgirlGloves" then
local modifier = 4;
for i = 1, modifier do
player:LevelPerk(Perks.Strength)
end
end
end```
might want to try :setPerkLevelDebug(Perks.Strength, perkLevel + 4);
replacing player:LevelPerk(Perks.Strength) ?
yeah thats the only method i found
thanks i will try
hum but them i need to remove the local modifier no?
also i think i would also need a else (not equiped), set -4, or each time i equip will stack +4 no?
yeah
you have to revert might also have to save the XP values somewhere to adjust it and not reset the player xp also considering the xp gained while equipped
hum but why he would gain XP when it add strenght?
in the code they seem to use this way
getPlayer():getXp():setXPToLevel(Perks.Strength, val);
getPlayer():setPerkLevelDebug(Perks.Strength, val)
Not that it add xp, just that if its a temporary modifier based on equipped item. While its equipped the character will gain strength xp when training etc. But once he unequip it might reset the gained xp, idk
hum so i have to set for both? lol sorry im very noob on lua started couple days ago
Lets say
- im str level 5
- i need 30,000 xp point to level up
- i have 1000/30000 already.
- i equip the item, your script add 4 levels.
- now it show that i need 150,000 xp to level up.
Just make sure the 1000 xp point he had already and any xp gained while equipped, is not lost
huuum
im loading here with that first simple one you pass me to see if works
local function PowerGlovesEffect()
local player = getPlayer()
local perkLevel = player:getPerkLevel(Perks.Strength)
if player:getClothingItem_Hands() == "Wiz_BatgirlGloves" then
setPerkLevelDebug(Perks.Strength, perkLevel + 4);
end
end```
yeah both factions and safehouses seem to work
great
You have to use both method here:
local newLevel = 5;
getPlayer():getXp():setXPToLevel(Perks.Strength, newLevel); -- this update the total xp required to level up from that level
getPlayer():setPerkLevelDebug(Perks.Strength, newLevel); -- this set the actual level
also where do you call PowerGlovesEffect()
how do i call ? at the end, like Events.XXXXXXX.Add(PowerGlovesEffect)
what event you call this from? -> XXXXXXX
lol no that is the part i dont know
you probably want to call this when equipping and unequipping the item
yeah, but i dont know how to write that line lol
and this part i need lua local newLevel = 5; ?
Add this into a client script, and replace Base.PowerGloves for your item Module.ItemName
-- Hook into the equip weapon action
-- Check if the item that was equipped is your powerglove
-- Add the strength perk level
local ISEquipWeaponAction_perform = ISEquipWeaponAction.perform;
function ISEquipWeaponAction:perform(...)
ISEquipWeaponAction_perform(self, ...);
if self.item:getFullType() == "Base.Wiz_BatgirlGloves" then
print("Equipping Wiz_BatgirlGloves")
-- add strenght perk levels
local currentLevel = self.character:getPerkLevel(Perks.Strength);
local currentStrengthXP = self.character:getXp():getXP(Perks.Strength);
self.character:getXp():setXPToLevel(Perks.Strength, currentLevel + 4);
self.character:setPerkLevelDebug(Perks.Strength, currentLevel + 4);
-- save current xp for when unequipping later
self.item:getModData().strengthXPbeforeEquipping = currentStrengthXP;
end
end
-- Hook into unequip action
-- Check if the item that was unequipped is your powerglove
-- Remove the strength perk level
local ISUnequipAction_perform = ISUnequipAction.perform;
function ISUnequipAction:perform(...)
ISUnequipAction_perform(self, ...);
if self.item:getFullType() == "Base.Wiz_BatgirlGloves" then
print("Unequipping Wiz_BatgirlGloves")
-- remove strenght perk levels
local currentLevel = self.character:getPerkLevel(Perks.Strength);
local currentStrengthXP = self.character:getXp():getXP(Perks.Strength);
self.character:getXp():setXPToLevel(Perks.Strength, currentLevel - 4);
self.character:setPerkLevelDebug(Perks.Strength, currentLevel - 4);
-- restore last xp + gained xp after
local xpGainedWhileEquipped = Perks.Strength:getTotalXpForLevel(currentLevel) - currentStrengthXP;
local strengthXPbeforeEquipping = self.item:getModData().strengthXPbeforeEquipping;
self.item:getModData().strengthXPbeforeEquipping = nil; -- reset the modData
-- set the current xp
self.character:getXp():AddXPNoMultiplier(strengthXPbeforeEquipping + xpGainedWhileEquipped);
end
end
This is gonna need a little bit more code cause this will reset any xp gained before and after which is a problem.
oh because it brings back to a certain level i see
yeah
you could save the info into the item modData to restore it and calculate the new xp gained into it
also idk if there is a better way of doing this without all this code thats just something i came up with real quick
I'm currently working on a mod that will replace an existing clothing item with an extra feature.
My current assumption is that:
clothing_jackets will get pulled in at some point in time when the client/server launches
I want to find the item I intend on replacing, remove it from the collection and add mine back in instead (effectively overriding the base version)
Is this assumption correct/best practice? Ideally I'd like to modify as little as possible for compatibility purposes
ah shame it dont work; dont give the bonus when equiped, and when i tried to unequip, it wont unequip and give this error:
function: perform -- file: ISUnequipAction.lua line # 63
function: perform -- file: Wiz_BatgirlGloves.lua line # 24
LOG : General , 1644312565448> bugged action, cleared queue zombie.characters.CharacterTimedActions.LuaTimedActionNew@26dbc6df
LOG : General , 1644312571431> -------------------------------------------------------------
attempted index: sound of non-table: null
LOG : General , 1644312571431> -----------------------------------------
STACK TRACE
function: perform -- file: ISUnequipAction.lua line # 63
function: perform -- file: Wiz_BatgirlGloves.lua line # 24
ERROR: General , 1644312571432> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: attempted index: sound of non-table: null at KahluaThread.tableget line:1689.
ERROR: General , 1644312571432> DebugLogStream.printException> Stack trace:
Hi! I am trying to add text descriptions to a mod so that they can easily be translated to other languages. I tried using constructuions like local text = "UI_myCustomText" or local text = getText("UI_myCustomText") and then defining the actual text in a txt file in /lua/shared/Translate/EN/UI_EN.txt via UI_myCustomText = "here is my text". i had no success so far. does anyone knows how to introduce custom UI_something strings properly into game? thanks!
check the post i updated it forgot some stuff
ah cool i will give it another shot
its not completed too
ty
no errors now, but no bonus
did you replace the item type in the code example to fit your item?
if self.item:getFullType() == "Base.PowerGloves" then
ye
try add a print and see if it run at all
if self.item:getFullType() == "Wiz_BatgirlGloves" then
you need to add the module
my mod ID?
i never use them i think
show me the script txt file that add your gloves
then Base.Wiz_BatgirlGloves
kk
Got a question on how TV scheduling works. I wanna mod a TV guide into the game. You know, the ones from back then when you had to get a Magazine to know whats on TV.
Are the schedules there actual schedules randomly generated. Or does the game randomly decide what show to broadcast when a set broadcasting time is met?
replacing base items can only be done OnGameBoot using the item:DoParam method.
check ItemTweaker mod to learn more about it
replacing a base item from script.txt will cause error in multiplayer when loggin with debug mode.
Thank you!
i dont need the Base. on my batgirl glove item too do i?
item Wiz_BatgirlGloves
{
DisplayCategory = Accessory,
Type = Clothing,
DisplayName = Batgirl Gloves,
ClothingItem = Wiz_BatgirlGloves,
BodyLocation = Hands,
BloodLocation = Hands,
Icon = Wiz_BatgirlGloves,
ScratchDefense = 15,
BiteDefense = 10,
Weight = 0.1,
Insulation = 0.5,
WindResistance = 0.5,
WorldStaticModel = GlovesLong_Ground,
}
just in the code i sent you
your item in the txt file is already inside the module Base {}
@opal wind you could use a different module name
}```
This way it would prevent some mod conflict
Ohh nvm. Just found out that all tv shows start on a set time. Flipping nice ๐
Where are mods I downloaded from the workshop saved, so I can look at examples?
@signal frost here
C:\Program Files (x86)\Steam\steamapps\workshop\content\108600
Life saver, thank you
@opal wind
actually i had errors lol I used this instead of self
-- Hook into the equip weapon action
-- Check if the item that was equipped is your powerglove
-- Add the strength perk level
local ISEquipWeaponAction_perform = ISEquipWeaponAction.perform;
function ISEquipWeaponAction:perform(...)
ISEquipWeaponAction_perform(self, ...);
if self.item:getFullType() == "Base.Wiz_BatgirlGloves" then
print("Equipping Wiz_BatgirlGloves")
-- add strenght perk levels
local currentLevel = self.character:getPerkLevel(Perks.Strength);
local currentStrengthXP = self.character:getXp():getXP(Perks.Strength);
self.character:getXp():setXPToLevel(Perks.Strength, currentLevel + 4);
self.character:setPerkLevelDebug(Perks.Strength, currentLevel + 4);
-- save current xp for when unequipping later
self.item:getModData().strengthXPbeforeEquipping = currentStrengthXP;
end
end
-- Hook into unequip action
-- Check if the item that was unequipped is your powerglove
-- Remove the strength perk level
local ISUnequipAction_perform = ISUnequipAction.perform;
function ISUnequipAction:perform(...)
ISUnequipAction_perform(self, ...);
if self.item:getFullType() == "Base.Wiz_BatgirlGloves" then
print("Unequipping Wiz_BatgirlGloves")
-- remove strenght perk levels
local currentLevel = self.character:getPerkLevel(Perks.Strength);
local currentStrengthXP = self.character:getXp():getXP(Perks.Strength);
self.character:getXp():setXPToLevel(Perks.Strength, currentLevel - 4);
self.character:setPerkLevelDebug(Perks.Strength, currentLevel - 4);
-- restore last xp + gained xp after
local xpGainedWhileEquipped = currentStrengthXP - Perks.Strength:getTotalXpForLevel(currentLevel);
local strengthXPbeforeEquipping = self.item:getModData().strengthXPbeforeEquipping;
self.item:getModData().strengthXPbeforeEquipping = nil; -- reset the modData
-- set the current xp
self.character:getXp():AddXPNoMultiplier(Perks.Strength, strengthXPbeforeEquipping + xpGainedWhileEquipped);
end
end
im testing, i will correct it
Do lua files automatically run if in the correct folders?
Or do they need to be added to some list somewhere
thank you!
The java script engine process them all.
Global objects
scriptA:
myGlobalObject = {}
scriptB:
require 'scriptA'
print( type(myGlobalObject) )
Not Global object
scriptA:
local myObject = {}:
return myObject; -- file can return an object
scriptB:
local myObject = require("scriptA")
require is some kind of import I take it
require will simply ensure that the required file is proccessed before the caller
Ah nice
a good practice is to use directory name into your mod.
client: media/lua/client/MyModClient/myFile.lua
server: media/lua/server/MyModServer/myFile.lua
shared: media/lua/shared/MyModShared/myFile.lua
then you can require them like this
require 'MyModClient/myFile'
require 'MyModServer/myFile'
require 'MyModShared/myFile'
this will prevent lua file with same name and path to be overwritten or conflict
So media/lua/xxx/ is considered the root as far as require is concerned?
xxx being server or client, whichever is relevant
yeah require ignore the media/lua/client|server|shared
so having a file with same name in client and server would be confusing i believe
Konijima
Can i take your time too, while you are here? :)
Is it possible to add additional context menu button for weapon?
And...how?
Yeah that makes sense
I'm semi-looking into this atm, I would believe it's similar to the way hoodies have extra options
Sadly hoodies extra is pretty simple to add, dm me and i show you.
@cold burrow
this would look like this
local function functionToCallOnItem(item)
end
local function OnFillInventoryObjectContextMenu(player, context, items)
for _, _items in ipairs(items) do
if instanceof(_items, "HandWeapon") then
local option = context:addOption("Context option title", _items, functionToCallOnItem);
break;
else
for j, item in ipairs(items) do
if instanceof(item, "HandWeapon") then
local option = context:addOption("Context option title", item, functionToCallOnItem);
break;
end
end
end
end
end
Events.OnFillInventoryObjectContextMenu.Add(OnFillInventoryObjectContextMenu);
I looking for a way to add context button to weapon and then while this button clicked -> pass function.
Much appreciated! <3
I'm gonna keep going to try and figure it out myself, but thanks for the offer. I'll hit you up when I hit a wall
np
If I'm nesting my stuff inside a folder, does it then need to be required? or will java still pick it up
The way i like to make my mods, it to separate and return my object and require them when needed.
I find nested structure to be messy on massive scale
I also like to use the fewest global possible
classes and object that can used both by client and server are in my shared such as utilities class, or table of data, data map etc.
Curious, why PZ not provides ISEquipAction, only weapon and heavy item. ๐ค
with type 2 diabetes that's absolutely correct!! there is an important difference between type 1 and type 2 diabetes, beside the first being principally found in adolescents - type 1 diabetes is also called insulin dependant diabetes. in it, your pancreus stops making insulin altogether. you cannot survive without insulin. your cells cannot get energy from the food you eat without insulin, and you eventually starve to death, even though you eat. the hp loss at high and low blood sugars is meant to represent the acute danger present in extreme cases of hyper and hypoglycemia, where coma and seizure become increasing potentialities. while i believe it's possible to simulate a coma in zomboid, the effect would be the same as character death, and so i think the hp damage function works acceptably in this instance.
traditionally the wasting would happen over a prolonged period of time, while the pancreus still sporadically made insulin. this mod essentially "takes place" years AFTER diagnosis, when the wasting would be circumvented by a more immediate coma.
that SAID ive considered making a type 2 diabetes mod as well, specifically to capture the fact that while potentially debilitating, one could live for years with persistantly high glucose, but thats putting the cart before the horse a bit, since type 1 and type 2 are very different diseases
While i trying to equip for example sneakers or pants, it's not working.
simple example just to test:
local ISEquipWeaponAction_perform = ISEquipWeaponAction.perform;
function ISEquipWeaponAction:perform(...)
ISEquipWeaponAction_perform(self, ...);
print("eq")
end
local ISUnequipAction_perform = ISUnequipAction.perform;
function ISUnequipAction:perform(...)
ISUnequipAction_perform(self, ...);
print("uneq")
end
But works while i trying to equip something in hands.
Still really good to know how to hook timed actions. It's a gem for me. :D
oh that would probably be the action ISWearClothing
๐ฅณ
Guys what are the best mods for beginners?
If you are 100% beginner try playing the vanilla game and learn the basic of the game.
If you have done that already, browse the mod workshop and add some mods based on what you want to add to your experience.
Really sorry to bore you, i have no idea why, but i can't make it works.
local function functionToCallOnItem(item)
print("This is a print from function")
end
local function OnFillInventoryObjectContextMenu(player, context, items)
for _, _items in ipairs(items) do
print(items) -- <-- Returns table
print(_items) -- <-- Returns table
if instanceof(_items, "HandWeapon") then
print("table _items") -- <-- Returns nothing
local option = context:addOption("Context option title", _items, functionToCallOnItem);
break;
else
for j, item in ipairs(items) do
print(items) -- <-- Returns table
if instanceof(item, "HandWeapon") then
local option = context:addOption("Context option title", item, functionToCallOnItem);
break;
end
end
end
end
end
Events.OnFillInventoryObjectContextMenu.Add(OnFillInventoryObjectContextMenu);
@cold burrow its because OnFillInventoryObjectContextMenu param items can be an item or a table of selected items from the inventory pane.
How's game defines that is "HandWeapon"? Maybe i could use something like SubCategory = Firearm?
you can check the item how you want, you could actually replace "HandWeapon" to "InventoryItem" and then check for other values on the item if you need more specific
I did both, thnx!
when you select an item in the inventory, sometime you might select a single item or a group of items, so that why we have to check for both case
Hm, but new one context button don't adds to item. Idk why ๐ค
when selecting the first red square it return all items in that stack.
when selecting the second red square it return that item itself.
well actually it's a little more complex than how i describe it
ooooh
You can add error(items); at the top, whent he debuger open with the error you can browse the data
local function OnFillInventoryObjectContextMenu(player, context, items)
error(items)
this willl help visualize how its structured
like just double click it and it will go inside the table
Oh god. This is amazing!
Does anyone have a way for resetting zombie modData whenever the game object is reused? There's no OnZombieReset callback I can use.
i have no experience with that, but does the ID changes?
super neat idea, I'll check it out! I only see OnlineID, would you happen to know if that works for both SP/MP?
in SP it might be -1 i think
otherwise you could save a modData value when it dies, and check when ever its alive if that data was set to know it "came back to life"
ye that's the only other way I'm thinking. It doesn't work when the zombies despawn without dying (ie I despawn zombies using debug mode) but hopefully good enough for an actual game
Hey anyone know anything about the autotsar trailer mod? I finally found a camper van, is there supposed a texture on the "switch seat" menu?
I think the OnlineID suggestion would work though ๐
with like a diagram of the trailer, like how a car is
Unless your question is about mod development i suggest you ask in #mod_support
I'm looking into making BritaWeaponPack an optional requirement for my mod. How can I detect if the game has Brita loaded?
I was thinking about check if one of the custom globals of GunFighters exists
Here is some code I found that checks for ItemTweaker as a dependency
require("ItemTweaker_Core");
else return end```
Perhaps you can repurpose for your ends?
Hahaha I'm just recycling code that Konijima sent me an hour ago
good luck
Konijima 
Thanks man
I have like 30 min of lunch break to try and make it work

I assume I need to check for Brita since it's the mod ID
Yeah, looks that way
It seemed odd that it would just be Brita, but I think you're right

name=Brita's Weapon Pack
id=Brita
poster=preview.png
description=New weapons added
require=Arsenal(26)GunFighter
Work like a charm, thx again
anyone know how to get a player's favorite weapon in Lua?
This is the function use in the vanilla game
ISCharacterScreen.loadFavouriteWeapon = function(self)
self.favouriteWeapon = nil;
local swing = 0;
for iPData,vPData in pairs(self.char:getModData()) do
for index in string.gmatch(iPData, "^Fav:(.+)") do
if vPData > swing then
self.favouriteWeapon = index;
swing = vPData;
end
end
end
end
should be able to be easily modify it
I thought getModData would relate to... mods
The game uses it for something because it's mostly data sticking to the player
But I thought that too at first
How can I make a "normal" item have a lower "equipped" weight? It seems they aren't impacted by this, and to get that effect I have to make it a "drainable" or some other type of item.
There's the player's hotbar, some variables on fitness, favorite weapons and 2-3 other things but it's pure random
ok I'll have a look
is my game bugged or am i going mad
if i get the players inventory on the server its empty
How do you get the player on the server side ?
im sending a client command
and on receive i use the player arg
ive also tried getting by num or id
Are you sending the player object?
it sends by default but yes ive tried manually sending
For my mod I send player:getOnlineID() on the client side to the server side and then use local otherPlayer = getPlayerByOnlineID(onlineID) on the server side
thing is the object is there no matter how i get it
i can do getUsername() and it shows the right one
why do you send the id?
getInventory() gives an empty array
Cause it's work, not going to try something else
i mean you dont have to send anything
sendClientCommand will send the player no matter what
mmk in that case that make sens
And how do you get the inventory?
getInventory()
Ok well except with the online ID as I showed you, I don't know. If you have the player object on the server, getInventory() should work. Maybe the inventories are not accessible from the server, no idea
as i said i tried it
Maybe try getPlayerInventory(playerNum).inventoryPane.inventoryPage.backpacks
It's how I gett all backpacks that the player wear. I know that in inventoryPage there is an other tables that backpacks with items from inventory
why would there be a self
It's just a copy past
you can easily get all players with local players = getOnlinePlayers(); on the server
it return an ArrayList of IsoPlayers
now for the inventory, i suspect the player inventory is transmitted only when the player is being saved.
been looking though the source but can't find anything special to get a player inventory from the server.
i even saw vanilla code getting the inventory on the server
alot of code in the server directory are actually running on the client
like recipe code etc
idk why tho
Try adding item to the player inventory from the server and see if it "transmit" it to your client player
getOnlinePlayers():get(0):getInventory():AddItem("Base.Axe")
check if that at least reflect to the client for the inventory being empty i feel there is something that need to be requested
didnt receive the item
i dont think the game send all item to the server instantaneously. It must have a buffer cause sometime we transfer hundred of items
but it did add the item to the inventory
i think the game will transmit the actual player only when "saving" before closing or when client quitting
not sure just theories
reconnecting to try
nope still dont have the axe
it was successfully added to an inventory
but not the characters
what do you want to do with the inventory from the server?
edit item properties on the server side
can i have a use case, like an example
in this specific case i need to set mediadata
not like i can get to that since the inventory is empty
when does that happen, user action? timer?
atm on click i send a client command
Why not change it on the client side ?
i have it on the client side but in multiplayer games the item has no playback when played so i suspect the server needs to associate the mediadata to the item too
You can use obj:sendObjectChange("state")
Like if you change the sprite of an item
obj:sendObjectChange("sprite")
ill test that but id still like to know whats happening with the inventory
sendObjectChange seem to be for isoObject
the server has to be storing the inventory else on connect you wouldnt have anything
Is that an issue ?
Mmmmm yeah make sens
indeed there is sendObjectChange checked the docs
on click send client command
on received client command get players items
everything else can be ignored ive commented any other code out to test
well getting the items on server seem to not work so you gonna have to figure an other way probably
- what do you click?
- send commend to set item data?
- Item is in player inventory or container?
- Changing media data is it a vhs or something like that?
- What is the player and other player suposed to see
click a key literally just OnKeyPressed
yes the item is in the players inventory
- and 4) irrelevant to this since i cant even get the items
might be an issue with my server globalmoddata isnt even persisting
Would anyone know why I can't access certain properties through lua? Whenever I do
local function handleZombieUpdate(zombie)
if zombie:isAlive() then
print(zombie.speedType)
end
end
It says speedType is nil, but the debugger says the correct value (i.e. 2). Is that intentional?
Can I add custom fonts ?
does anyone know how to get the slot index of a worn holster via lua code? (is an integer.)
should be able to
In the player hotbar, if I remember correctly, there is a table with the items which adds slots (with their indexes).
To get it getPlayerHotbar(playerNum)
yeah only methods seem to be exposed
thx! i'll try that!
cheers tnx for confirming!
Is there any way to get item custom properties?
Like foo = bar?
what property you need
Any custom one.
Like, idk: color, size, faces, foo.
If i add something to item in scripts or lua, like:
local item = ScriptManager.instance:getItem("Base.ExampleItem")
if item then
item:DoParam("foo = bar")
end
How could i get value for foo property?
foo is bar man... FOO IS BAR!
It's not required atm actually, but it would be nice to know.
To add/read custom properties.
for the script item? or for a spawned instance of the item (InventoryItem)? its different
spawned instance is easy (its in the item's ModData)
print(item:getModData().foo)
for a script item its a bit more of a pain
id be interested to know how that work for custom properties into the scripts.txt files if you got any info
well short version, when you add custom properties into the the scripts .txt, it gets added to a 'defaultModData' table (a field in Item.class)..when a item spawns as a InventoryItem instance, all those custom key/values get transferred to the item's modData table
since the unspawned script item has no get/set method for the defaultModData table, have to take a more hackish route to get it
but as mentioned before (few lines down from that pasted message) that was more proof of concept code then anything. it could do with some cleaning and optimization
nice to know ty
at the lua event OnNewGame the command getPlayerHotbar(playerNum) seems to call a nil value although the slot index for the holster is already defined (I added the holster as a custom clothing to the character before the game starts)
Does UTF-8 is ok for chinese ?
OnNewGame the player is not create yet
just check here: media/lua/shared/Translate/CN/language.txt
It's in UTF-8 in the vanilla game and my mod but someone told me that it's not working. Wait maybe not in my mod
the slot index is already there and is 2 in my case OnNewGame. i can work with it and attach a weapon at this event which works fine. could go on and simply hardcode "2" but I am afraid this might not so good for stability....
local function OnCreatePlayer(playerNum, playerObj)
if not playerObj:getModData().newGameInited then
playerObj:getModData().newGameInited = true;
-- do something the first time this character is initialized
end
end
Events.OnCreatePlayer.Add(OnCreatePlayer);
i suposed that would work better
might not be a good solution for respawning new character in mp, my bad..
player is technically created already in OnNewGame. the IsoPlayer instance is one of the arguments to the event callbacks (IsoPlayer and IsoGridSquare)..though i'm not sure if its fully spawned in until after the event is called
Ok mb
np ๐ any idea might be helpful!
point is: since the holster already has a slot index at this event, i would be surprised if there isn't any "smooth" way to call it somehow
I still need help with this. Day 3 of staring at it trying to figure out what is wrong.
so basically at this line: local weaponPerkLvl = ACAC.getPerkLevel(_player, ACAC.currentWeapon)
** I think ACAC.currentWeapon errors out due to calling nil**
Object tried to call nil in OnWeaponSwing
I've also had it say this about the same line:
Object tried to call nil in Unknown
It's something to do with the categories being wrong, maybe? Because it throws this error with every weapon type.
**I've tried changing ACAC.currentWeapon to **
ACAC.OnEquipPrimary(_player, "HandWeapon")
end
And
ACAC.OnEquipPrimary(_player, _item)
end
Both of these changes break the code entirely.
any luck man? thanks again!
https://www.reddit.com/r/projectzomboid/comments/snqgq8/could_we_add_small_mods_for_more_disabled/?utm_source=share&utm_medium=web2x&context=3 how hard do you think it would be to code in something like hearing aids that negate the deaf trait, requiring them to run on batteries? What about something like a wheelchair, or realistically using crutches?
0 votes and 1 comment so far on Reddit
@warm sequoia I think there are already mods that do that for deaf (requires hearing aids) and nearsighted/farsightedness (requires glasses and autozooms you in/out)
I think hydrocraft adds them but there are other lighter options as well
oooh, if you ever find some links to those let me know
This is hydrocraft: https://steamcommunity.com/sharedfiles/filedetails/?id=2081538550&searchtext=hydrocraft
Note that it adds quite a LOT of things though. You maybe able to find more specific mods that only handle disabilities/traits
How do I go about removing the clipping issue, and the random added gray tile underneath anything placed down in Tile mode?
Oh, maybe that glitch is fixed or only happens in specific situations.
Oh a coma being a result years after diagnosis, I did not know that.
i manage to make it work as attach and the model shows, but since both my gun and attachements are .fbx, im having trouble to set the offset and rotation on the attachment
It's based on the tile layer the hedge is on
u know any mod with attachments for Firearms with .fbx i could look?
the attachment is flooting about 5m above the char lol
How did you fix it?
You can save having to restart the zomboid software just to reload a model because the game will still load new models from \scripts and also unload models no longer in \scripts
I do not knonw any. You could adjust the attachment point on the weapon's model but that could be problematic if the attachment is the problem.
hi there. Relatively new modder here (about half a year's experience with clothing mods/vehicle skins, no models).
So anyways, when I try to run "sendObjectChange()" in my code, it works in SP, but MP (Specifically the local server, from the host menu), returns with " sendObjectChange() can only be called on the server" How would I fix this?
You could use this #mod_development message
The person who posted this got client and server the wrong way around somewhere though, which took me more than a few tests to find out. :c
ah, thankies
Please advise:
I've got a stupid question. I can't get custom wheels to spawn. What am i doing wrong?
Wheel model is in place, but it doesnt spawn for some reason. The error is definitely in the script, using other version it works...
I've lifted the template from vanilla station wagon, sadly seems like all vanilla cars have the same wheels so i cant steal that code too... I have the custom wheel template, and i have my custom models declared. What am i missing?
its because all the mods i saw and the vanilla models for guns and guns attachments are .x, im trying to make a .fbx, the only way i see how to make this atm would be manually adjusting the offset?
ยญ ยฏ_(ใ)_/ยฏ
Ey if I wanted to make a really small weapon mod that adds two items how would I go about that. I'm bad at art assets but then again the game isn't about art.
Is there an event for when the player quit ?
I mean I could make it into a larger mod but i want to start with this.
Also is most of the modding just text files or no
fragMOTION can open and save .x but I find it bad and slow for model editing so I use some other software. Some people use blender or milkshape (milkshape costs money).
look on debug mode the attachment looks perfect, but on the game its x100 bigger and floating about 20m up from the char
both are .fbx
I have not had that problem and I have not had to fix it. :\
you made your guns .x?
also you see that attachment name on the side there? that name must be the same as the 3rd/4th or the 1st/2nd on the weapon file?
ModelWeaponPart = Base.WizGunLightsmall Base.WizGunLightsmall wizgunlight wizgunlight,
I have tried .x and .fbx but I have not tried .fbx attachments.
Something the same name as something on the weapon file?
needs more big red arrows i think
LOL
hey mr_anon i think i found the thing, since its .fbx i think its a scale thing, messes around with all the attachment positions
i will make a test here
(deleted)
Dese ppl de doxing they/themselves tfw
Just wait for me to reupload your mod so that you give me your full address muahahahahaha
im getting closer
so it was the scale; .fbx are x100 smaller, now the scale is right
i think nobody did .fbx weapons with attachments yet
im a pionner here lol
i dont care in giving my first name ๐ its Gustavo like that dude from breaking bad
mother of GOd...
i did not needed debug mod tool at all
was just the scale thing and the position is this
attachment wizgunlight
{
offset = 0.0000 0.0000 0.0000,
rotate = 90.0000 0.0000 0.0000,
}
just 1 rotation
.fbx need to scale the weapon part to scale = 0.0.1 (this info will be usefull for all who make .fbx gun/attachments)
now all i need to do is making the light turn On lmao
guys is this here right? i need to put the key name in () ?
if (keyNum == getCore():getKey(KEY_COMMA)) then```
In lua, you can use a boolean thing without brackets around it.
Is it possible to spawn a weapon preloaded with ammo?
I'm having trouble figuring out how to implement/use this.
I might be just dumb though
Client Script
local function OnServerCommand(module, command, args)
if module == "myModule" then
if command == "myCommand" then
print("Recieve command " .. command .. " from server!")
end
end
end
Events.OnServerCommand.Add(OnServerCommand);
sendClientCommand("myModule", "myCommand", { test = 1 });
Server Script
local function onClientCommand(module, command, playerObj, args)
if module == "myModule" then
if command == "myCommand" then
print("Recieve command " .. command .. " from " .. playerObj:getUsername() .. " client!")
sendServerCommand("myModule", "myCommand", args); -- send command to all clients
sendServerCommand(playerObj, "myModule", "myCommand", args); -- send command to this client only
end
end
end
Events.OnClientCommand.Add(onClientCommand);
Note: sendServerCommand doesnt work in single player.
Solution:
local function sendServerCommandToAll(module, command, args)
if not isClient() and not isServer() then -- is single player
triggerEvent("OnServerCommand", module, command, args);
else
sendServerCommand(module, command, args);
end
end
local function sendServerCommandTo(playerObj, module, command, args)
if not isClient() and not isServer() then -- is single player
triggerEvent("OnServerCommand", module, command, args);
else
sendServerCommand(playerObj, module, command, args);
end
end
ah, ok. I think I figured out how to get sendObjectChange() working on the hosted server, but if this fails, thanks in advance for that
Does anyone have interest in breathing life into this project? The codebase looks clean its just out of date. I'm New to LUA and zomboid modding, so I could use an experienced modder helping me out...
https://steamcommunity.com/sharedfiles/filedetails/?id=922781416
Is it possible to increase the character limit when adding notes on maps, by modding the game?
Does getPlayerIndex() work in solo? I tried it and the game returns an error code.
Hey modders... Is there any existing server options, debug settings or something to log or retrieve player stats, zombie bites in multiplayer? I'd like to be able to retrieve more information about players on the server for a discord bot to react to, but I don't see any logging of bites or stats in any db or bin file
guess I'll explain what I'm trying to do. In essence, I've been writing code to replace zombies with outfitA with zombies wearing outfitB. I've got it working in SP, but server-side, it's blasting about "sendObjectChange() can only be called on the server". I'm at a loss here.
I assume you'll want the code snippets?
getPlayerIndex() is probably called on a player object I think, like some_player:getPlayerIndex()
playerObj:getPlayerNum()
IsoObject.getPlayerIndex() -- actually is static and return the assumed player object index if found.. not sure what that mean exactly
both return the same playerIndex
zombie\iso\IsoObject.java
public void sendObjectChange(String var1) {
if (GameServer.bServer) {
GameServer.sendObjectChange(this, var1, (KahluaTable)null);
} else if (GameClient.bClient) {
DebugLog.log("sendObjectChange() can only be called on the server");
} else {
SinglePlayerServer.sendObjectChange(this, var1, (KahluaTable)null);
}
}
// got a couple overload
public void sendObjectChange(String var1, KahluaTable var2)
public void sendObjectChange(String var1, Object... var2)
that's very informative. Thanks
here's hoping I can learn the answer to my dilemma from that...
Is there an easy way to have it so that when you spawn a car it either has the key in it or gives you a key via Lua?
Don't know how to use it tho
sendClientCommand(playerObj, "vehicle", "getKey", { vehicle = vehicle:getId() })
same command used for the cheat that give you the car key
also check client\DebugUIs\ISSpawnVehicleUI.lua for spawning
I wrote 4500 lines of code today in just under 30 minutes!
I was just adding items to a store mod that I have, I guess I didnt hand write them but instead used Notepad++ functions to turn 604 lines of code into 4554! Should be more as I need to add a couple more lines
to each item
Okay then i think you also deserve a burger 
in case anyone is interested: my current workaround is to attach weapons by modifying the vanilla function ISHotbar:refresh() and append some code to it. In this function, the slot index is easily available. btw, a question to everyone: is appending code to a vanilla function considered a somewhat "safe" way when it comes to overwriting issues and compatibility with other mods? to append code, I always use constructions like this:
Yeah, looks like you have a handle on the standard good method for modifying vanilla functions.
thx for feedback! very helpful to learn from experienced modders how to do things in a proper way to minimize risk of bugs/instability/incompatibility
hnnnnng finally finished
@small topaz if you want to improve it a little bit
local ISHotbar_refresh = ISHotbar.refresh;
function ISHotbar:refresh(...)
ISHotbar_refresh(self, ...);
end
I use the real name with _ . (this is personal preference)
I use ... in case TIS decide to add parameter in the future that would ensure that any new parameters would still be passed.
Other than that you got it

thx for the hint! i'll use it!
Anyone know whats the correct path/naming to place new trait texture icon?
media/ui/Traits/trait_mytrait.png think i got it
I'm using the true music mod but recently i'm getting ATA_Bampers template error when trying to host but it was working fine a few days ago, anyone know what's up? Tried unsubbing and redownloading mods, reinstalling zomboid, everything works fine if i disable true music so it's deffo just that mod or the mods it requires to work (TCC and Tsarlibrary)
I suggest you ask in #mod_support as this channel is about mod development.
my bad lol
Having an issue at the moment with removal of a sprite from an IsoObject... Can't figure it out for the life of me:
require('luautils');
local function onGroundCleanupCommand(module, command, player, args)
if module == 'GroundCleanup' then
if command == 'GroundCleanupCommand' then
local sq = getCell():getGridSquare(args.x, args.y, args.z)
if not sq then return end
for i = 0, sq:getObjects():size() - 1 do
local object = sq:getObjects():get(i);
if object:getName() == "Generic" then
local attached = object:getSprite()
if object:getName() ~= nil then
local sprite = attached:getName()
if (luautils.stringStarts(sprite, "d_generic_1")) then
** object:RemoveAttachedAnim()**
object:transmitUpdatedSpriteToClients()
end
end
end
end
end
end
end
I'm getting an exception on line
object:RemoveAttachedAnim()
that states:
Callframe at: RemoveAttachedAnim()
(This specific tile) Trying to target the d_generic_1_23 sprite
does anyone knows what maximal value for dirtyness of clothing is?
I was wondering, is there a mod that makes the loot of the ||secret military base west of the Knox Prison|| good?
If not, how can I make it myself? with loot that can respawn
Does anyone know if addZombiesInOutfit in MP works, or simply spawning zombies in MP? They seem to despawn right away.
Another question - is there any way to clear zombies from specified area?
Someone know how he manage to use a gif as preview image ?
https://steamcommunity.com/sharedfiles/filedetails/?id=2730052793&searchtext=
Just uploading the gif to imgur or something and adding the link does not work?
I mean, he use a gif as preview image, not in the description
Workshop\ModTemplate\preview.png is a gif for him
You mean you tried to use a gif and it's not working?
I can't, when I click on "create or update items", then choose the mod, then click next I get an error "There is no preview.png file in the folder you chose. A 256x256 PNG preview image is required for all workshop items"
But I want preview.png to be a gif
Try changing the image file suffix to png instead of gif?
I tried, it's doesn't move. It's just a png now
Maybe not, a guide on google seem to say the same thing as you
Hmm, I got it to work for me? It appears to work in some contexts, an actual .gif with suffix changed to .png, but not others?
"The preview.png file could not be read. The format appears to be invalid."
New error
Maybe a hacked client is the trick? ๐
Mmmm, no idea but what annoying, I wanted a gif for my mod
Step 1: Make a .gif preview file using a software like photoshop.
It has to be under 1 MB file size for this to work.
Step 2: Put the preview.gif you exported in the About folder of your mod
Step 3: Change/Rename the file extension of your preview.gif to preview.png
That's exactly what I did. I imagine that the format of my gif is not the right one
Utilities class to help make mods work in SP and MP together more easily:
With this you can simulate your networked mod into a SP environment.
This help for developing networked mod in SP for faster testing, until ready to test on a server.
Add the Utilities.lua into your lua/shared directory to access it from both client and server scripts.
To import it in file that you need:
local Utilities = require("Utilities")
If you see improvement or have a bug let me know, hopefully that help you guys.
Part 1
---@class Utilities
local Utilities = {};
--- [SHARED]
--- Return true if game is single player
---@return boolean
function Utilities.IsSinglePlayer()
return not isClient() and not isServer();
end
--- [CLIENT]
--- Return true if client is admin or single player + debug mode
---@return boolean
function Utilities.IsClientAdmin()
return (isClient() and isAdmin()) or (Utilities.IsSinglePlayer() and isDebugEnabled());
end
--- [CLIENT]
--- Return true if the client is admin or moderator
---@return boolean
function Utilities.IsClientStaff()
local playerObj = getPlayer();
return Utilities.IsClientAdmin() or (playerObj and playerObj:getAccessLevel() == "Moderator");
end
--- [SERVER]
--- Return true if the IsoPlayer is admin or single player + debug mode
---@param playerObj IsoPlayer
---@return boolean
function Utilities.IsPlayerAdmin(playerObj)
return (Utilities.IsSinglePlayer() and isDebugEnabled()) or (playerObj and playerObj:getAccessLevel() == "Admin");
end
--- [SERVER]
--- Return true if the IsoPlayer is admin or moderator
---@param playerObj IsoPlayer
---@return boolean
function Utilities.IsPlayerStaff(playerObj)
return (Utilities.IsSinglePlayer() and isDebugEnabled()) or playerObj and (playerObj:getAccessLevel() == "Admin" or playerObj:getAccessLevel() == "Moderator");
end
Part 2
--- [CLIENT]
--- Send a command from the client to the server
---@param _module string
---@param _command string
---@param _data table
function Utilities.SendClientCommand(_module, _command, _data)
if isClient() or Utilities.IsSinglePlayer() then
sendClientCommand(_module, _command, _data);
end
end
--- [SERVER]
--- Send a command from the server to a specific client
---@param _targetPlayerObj IsoPlayer
---@param _module string
---@param _command string
---@param _data table
function Utilities.SendServerCommandTo(_targetPlayerObj, _module, _command, _data)
if isServer() or Utilities.IsSinglePlayer() then
if Utilities.IsSinglePlayer() then
triggerEvent("OnServerCommand", _module, _command, _data);
else
sendServerCommand(_targetPlayerObj, _module, _command, _data);
end
end
end
--- [SERVER]
--- Send a command from the server to all clients
---@param _module string
---@param _command string
---@param _data table
function Utilities.SendServerCommandToAll(_module, _command, _data)
if isServer() or Utilities.IsSinglePlayer() then
if Utilities.IsSinglePlayer() then
triggerEvent("OnServerCommand", _module, _command, _data);
else
sendServerCommand(_module, _command, _data);
end
end
end
--- [SERVER]
--- Send a command from the server to all clients in range
---@param _x number
---@param _y number
---@param _z number
---@param _distanceMin number
---@param _distanceMax number
---@param _module string
---@param _command string
---@param _data table
function Utilities.SendServerCommandToAllInRange(_x, _y, _z, _distanceMin, _distanceMax, _module, _command, _data)
if isServer() or Utilities.IsSinglePlayer() then
if Utilities.IsSinglePlayer() then
triggerEvent("OnServerCommand", _module, _command, _data);
else
local players = getOnlinePlayers();
if players then
for i = 0, players:size() - 1 do
local targetPlayer = players:get(i);
if Utilities.IsPlayerInRange(targetPlayer, _x, _y, _z, _distanceMin, _distanceMax) then
sendServerCommand(targetPlayer, _module, _command, _data);
end
end
end
end
end
end
--- [SHARED]
--- Return true if the IsoPlayer is in range
---@param _x number
---@param _y number
---@param _z number
---@param _distanceMin number
---@param _distanceMax number
---@return boolean
function Utilities.IsPlayerInRange(_playerObj, _x, _y, _z, _distanceMin, _distanceMax)
if not _playerObj then return false; end
local x2, y2, z2 = _playerObj:getX(), _playerObj:getY(), _playerObj:getZ();
local currentDistance = IsoUtils.DistanceTo(_x, _y, _z, x2, y2, z2);
return (currentDistance >= _distanceMin and currentDistance <= _distanceMax);
end
return Utilities;
take a look at client\DebugUIs\ISSpawnHordeUI.lua for everything your just asked.
Thank you very much.
Hi everyone, is there a clothing mod that lets u wear any clothes at start but excluding the armor and backpacks
Doesn't that work only if the player is in the car when run?
no you dont have to be in the car to get the key with the debug option this command is exactly the same
but you need the reference to the vehicle yes
@thin hornet if I have just spawned the car is there an easy way to check for it near me and get its reference, or alternatively force the player into the car?
@round zenith is the car spawned nearby the player?
local vehicle = playerObj:getVehicle() if not vehicle then vehicle = playerObj:getUseableVehicle() end if not vehicle then vehicle = playerObj:getNearVehicle()
found that in ISVehicleMenu.lua
@modest yarrow @thin hornet TY TY TY it worked!
function CarCrafting_OnCreate(items, result, player)
addVehicle("CarNormal")
local vehicle = player:getVehicle()
if not vehicle then
vehicle = player:getUseableVehicle()
end
if not vehicle then
vehicle = player:getNearVehicle()
end
sendClientCommand(player, "vehicle", "getKey", { vehicle = vehicle:getId() })
end
now time to rewrite the method to handle way more values instead of just a single one.
anybody know why my shading is showing up over the damage overlays?
Guys, hello there!
How I can patch the workshop mod by other workshop mod?
The require= field in mod.info has to contain the modID of the mod you want to patch.
Well then I do everything right, but it wonโt reload (rewrite after) ItemName_LANG.txt fileโฆ
Yeah, that specifically isn't working properly right now, but should be fixed in a future update?
Item tweaker wonโt work tooโฆ Tried to rewrite displayName class of the target mod items (like Organized books mod rewrites icons) but still no result.
Yeah like I said, it isn't working properly right now, but should be fixed in an update?
The translation files overwrite display names so until the fix is in an update there's no simple solution for the issue.
Why then organized books working with modded stuff too?)
Anyway, thanks for response! Last question is: where I can find syntax and list of variables issued by mod.info and workshop.info?
Trying to Google it a week already
- It's the translation files when patching other mods that have translation files that is the specific issue.
- I've never seen one? I've just fumbled through learning what they do from looking at how other mods use that file.
Maybe this: #mod_development message
- understood
- Doing the sameโฆ Well thatโsโฆ Should we check workshop API then?)
โSeparated by a commaโโฆ Then I do it right.
Really appreciate! Thank you!
๐
so i wanted to do a smallish mod, idk how hard or easy it would be, i wanted to add a profession and a two items, It would be fencing instructor (to keep it simple for now) and two swords in the game, the catch is that the two swords aren't sharp they are practice swords, one is a poly longsword made of plastic, and the other would be a steel feder long sword, they would do blunt damage as they arent sharp. i used to do longsword fencing till i couldnt do it anymore for personal reasons so this would be a fun mod to add
also adding the practice helment i used and the padded jackets that i wore would be awesome
it was basically a cloth gambeson but for the sport
the real question is why hasnt anyone added baseball knee pads
easy and makes sense.
bump
hella stuck on this
How would i make 556 mags and ammo spawn at gun stores for my mod
I also want to make a larger 9mm magazine, but i feel like it would be out of place to have a โ9mm Magazineโ and a โ30 Round 9mm Magazineโ and might confuse people
Main problem for me here is that vanilla don't allow you to use different magazines for same weapon.
Oh, i was presuming i could make multiple guns use one magazine
You can, but one gun can't use different mags. In vanilla at least.
I also want to make it so the 223 rifle has an internal magazine so i can use the 223 magazine for a different gun
It's should be possible and not so hard.
I however have no coding experience so iโm going to figure it out as i go
You don't need any coding experience at all if you only want all what you says (except possibility to swap magazine type for same weapon).
But some modeling skills would be good, if you need new one models for weapons.
Oh i have modelling skills
Thatโs why i want to make the mod
Hereโs something i made a while ago, but i could do the pz style pretty well
Wish i have that much modeling/painting skill. :D
You just have to keep doing it and over time you get better and learn tricks, thatโs how i did it
Practice doesnโt make perfect it just makes better
Also, is it hand painted model?
Itโs not textured at all, just solid colors with lighting
Every detail is modeled
It's amazing.
while nice... it is way to high poly. you COULD make an extremely low poly one and bake that onto it.
oh i know. just looking ahead lol
I'm pretty sure you will get it pretty fast. :D
Here are some lower poly guns
I got a feeling i will
I'll update you guys on my progress
I don't know much about guns but those look v nice
Thanks
https://streamable.com/ori823 and then... i started blasting
e11 blaster with max aiming
Day 4, not much closer to figuring this out.
Wish i could help you mate. :(
Trying to call nil may also mean you're calling a function that doesn't exist, can you post the exat line where that error happens?
local weaponPerkLvl = ACAC.getPerkLevel(_player, ACAC.currentWeapon)
At this point I think I'd be better off just making my own mod that determines the max amount of zeds hit based on strength level. Maybe this is just too advanced for me.
aye
I guess ACAC.currentWeapon is a global variable. I suppose ACAC.getPerkLevel exists nad is not calling nil
so, make sure the variable is set, add a line before that one _player:Say(tostring(ACAC.currentWeapon)) just to check whay is going on. If the player ever says nil, you know that is probably the issue
_player:Say(tostring(ACAC.currentWeapon)) What does this do?
the player should "speak" in a text above his head whatever is stored as the weapon
if you have a proper weapon stored in that variable I'd say check the whole ACAC.getPerkLevel again
local categories = _weapon:getCategories()
for i = 0, categories:size()-1 do
local s = categories:get(i)
if s =="Axe" then return _player:getPerkLevel(Perks.Axe)
elseif s =="SmallBlunt" then return _player:getPerkLevel(Perks.SmallBlunt)
elseif s =="Blunt" then return _player:getPerkLevel(Perks.Blunt)
elseif s =="SmallBlade" then return _player:getPerkLevel(Perks.SmallBlade)
elseif s =="LongBlade" then return _player:getPerkLevel(Perks.LongBlade)
elseif s =="Spear" then return _player:getPerkLevel(Perks.Spear)
elseif s =="Improvised" then return -1
elseif s =="Unarmed" then return -1
end
end
if s ~= nil then
print("S+ MOD ERROR: Weapon type not found:", s)
end
return -1
end```
This is the function for getPerkLevel
If it equals nil then it should print that there's a mod error in the console.
But it doesn't.
At least, not that message.
double check the perk names, they could return nil if there's a typo or anything wrong with them
Yeah it's across the board though for every category
I will double check in the API though.
How's hard to add new one attachment point PartType to engine? Like currently we have Canon, Scope, RecoilPad, e.t.c.
You can't without modifying the java.
Oh. :(
That's really, really sad.
Also check if you have any weapon missing the categories value, I don't know if that's possible, but the function doesn't cover the case of categories being empty
with enough lua trickery id say it is
Lua is both really great
@nimble spoke the mod throws the error in the loading screen when I'm continuing a game.
And the biggest headache
Any thoughts on that?
Full stack log:
function: ongamestart -- file: DebugScenarios.lua line # 147
LOG : General , 1644437664184> Object tried to call nil in unknown
ERROR: General , 1644437664190> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: Object tried to call nil in unknown at KahluaUtil.fail line:82.
ERROR: General , 1644437664190> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: Object tried to call nil in unknown
at se.krka.kahlua.vm.KahluaUtil.fail(KahluaUtil.java:82)
at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:975)
at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:163)
at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1980)
at se.krka.kahlua.vm.KahluaThread.pcallvoid(KahluaThread.java:1812)
at se.krka.kahlua.integration.LuaCaller.pcallvoid(LuaCaller.java:66)
at se.krka.kahlua.integration.LuaCaller.protectedCallVoid(LuaCaller.java:139)
at zombie.Lua.Event.trigger(Event.java:64)
at zombie.Lua.LuaEventManager.triggerEvent(LuaEventManager.java:130)
at zombie.iso.IsoWorld.init(IsoWorld.java:2688)
at zombie.gameStates.GameLoadingState$1.runInner(GameLoadingState.java:260)
at zombie.gameStates.GameLoadingState$1.run(GameLoadingState.java:217)
at java.base/java.lang.Thread.run(Unknown Source)
LOG : General , 1644437664191> -----------------------------------------
STACK TRACE
-----------------------------------------
function: null -- file: LotsaZombies.lua line # 40
function: ongamestart -- file: DebugScenarios.lua line # 147```
In that same line?
that's a different error
might want to check and fix that one first
Yeah this one I've been getting more of than the other. It's weird.
I got the other one once and was working on fixing it, and now every time since then I get this one instead.
Wait would this just be from scenarios?
I am loading into a new scenario.
looks like it is related to debug scenarios
Maybe I should try in a new game?
yeah
can anyone recommend any mods that add moodles? i'm trying to reverse engineer the process to create my own
maybe check the alcoholism mod?
I'm trying to revive this project, the author was attempting to manually set values for each item in the game.... Is there a procedural way to do this?
ItemValueTable["Base.TrapBox"] = 0.00; ItemValueTable["Base.TrapCrate"] = 0.00; ItemValueTable["Base.BookTrapping1"] = 1.00; ItemValueTable["Base.BookTrapping2"] = 1.00; ItemValueTable["Base.TreeBranch"] = 0.00; ItemValueTable["Base.Trout"] = 0.00; ItemValueTable["Base.HandShovel"] = 2.00; ItemValueTable["Base.TunaTin"] = 1.00; ItemValueTable["Base.PaintTurquoise"] = 0.00; ItemValueTable["Base.TVDinner"] = 0.00; ItemValueTable["Base.Remote"] = 0.00; ItemValueTable["Base.Tweezers"] = 1.50; ItemValueTable["Base.Twigs"] = 0.00; ItemValueTable["Base.Twine"] = 1.50;
instead of doing this for every item
Basically wondering if there's a table or enumeration I can access with all the items in the game.
anyone know how to fix world dictionary error
I have been trying to mod food categories; I have "Better Sorting", but it creates only "Food - (non)perishable" and drinks and I would like too more like something that's on PZwiki - "Proteins, Games, Fish, Vegetable, Fruit, Grains, ..." possibly with better sorting on cooking utensils and acutally useful items (pots, bowls); so I started to experimentally to understand the load process from the snippets and similar mods and don't quite understand how this loads. What's difference between onGameStart vs onGameBoot events and what (more like when/where) happens when I do some commands in the lua script? Also my impression is that all the categories mods are quite incompatible? At leasst I
at least I didn't managed to load my categories alogside better sorting; like I would like to override this my mod being the last, but just can't get it to work. I wonder - have anyone experimented in this areas, are there some good tutorials I'm missing?
Add the removed item back
@chrome agate decompile the java classes, that should tell you a lot in terms of what the functions do
maybe better sorting is overriding your mod somehow still?
oh cool? I would thought it's all minified and obfuscated; cool devs then
ye it's pretty cool. tho tbh most games these days tend to be non-minified.
yeah, there's something weird going on I can't understand; I mean I know lua only from like week experimenting with PZ so it's kind of rough start, but it would seem that while there's a mod that handles this transparently (TweakItems API) very few of the mods actually use this and they instead copy-pasted the code snippets with their own onGameBoots and whatnots and it seem to be all around the place
@chrome agate Why would you expect 2 categorization mods to be compatible when they're trying to take control over the same thing?
that's the thing - I could not get it working even with load order (which I'd expect to work out of the box) - the last mod changing items' category wins
have you managed to change the category of normal items? have you managed to change the category without better sorting?
yes; when I take vanilla with just my mod it works like a charm; but whenever better sorting is loaded too, no matter what order I load the mods the better sorting wins; and I'm chaning just few specific items
I understand the conflict (like messing with one thing) but I'm using TweakItemAPI so it's rather simple like
...ItemTweakerAPI require boilerplate "if tweakerApi; require; else return; end"
TweakItem("Base.Apple", "CategoryName", "Fruits")
It really depends on what each mod is doing
This is all that is required to add/change display categories. Just this.
- a lua file in server or shared directories with this lua code
local item = ScriptManager.instance:getItem("Base.Money")
if item then
item:DoParam("DisplayCategory = Money")
end
- A
IG_UI_EN.txtfile in\media\lua\shared\translate\ENwith this in it
IGUI_EN = {
IGUI_ItemCat_Money = "Money",
}
That's all it takes. Just that. Nothing else. No Item Tweaker required.
Just make sure all of your new categories are in the IG_UI_EN.txt file. Add as desired for other languages in other directories, but if they don't have a file it'll default to the English version.
that's it; TweakItem mod has it's own instance that keeps map of "ItemToChange"->"newName", it collects this from all mods and applies it with its own onGameBoot handler (the idea I guess is that this happens only once collectively for all mods); but probably for some B40(??) compatibility, every mod has own onGameBoot and it seems to mess things up?
yeah those files for UI ItemCat I have, this part works
neat!! so I can just access and change this directly?
Just do it the way I did, and as long as you do it properly it should work.
can this be done in-game? like are display categories dynamic like this? for example if I'd had a "change it all now" button in-game
You.... ....could do that, but that's significantly more complicated than "just use this code and it will work"?
I have it in client, so this MP-wise this will show up only for individual players with the mod installed?
how is it done? I saw DoParam around, I think this pushes something into Java part of the game?
In MP all clients and the server need to have identical versions of the same mods (unless checksum is disabled, which is a terrible idea)
There's no such things as client-side-only mods in PZ.
ok, shared/ it is then
not really sure but i think the mod folders "client", "server" and "shared" (or better: their names) are not related to multiplayer-singleplayer stuff.... but other people here know more about this...
They are, and it's best to put everything in the shared folder unless you know a good reason otherwise or such.
If you follow how vanilla lua does it, it should work, but when in doubt use shared.
ok... didn't know this.... thanks for the info. my current strategy was to put luas in the folder where the functions they modify are located. for example, when a mod modified a vanilla function located in client, i simply put my modded file into the mod's client folder
thats generally good policy, if your modifying something in client, go in client as well...just as a general rule most things should go in shard if its something both client and server will need
theres a load order that happens with the files...shared are loaded first, then client, then finally server...if its in MP the server doesnt actually load anything in client
which is why clientside stuff like UI, context menus and timed actions belong there
ok. good to know!
could this lead to problems if i define a global variable in shared which should also be used in client? should be safe if shared stuff is loaded first...
accessing a global in client that was defined in shared is fine, accessing one defined in server could lead to problems (depending on when you try to access)
accessing one in server that was defined in client will fail in MP situations (for the actual server anyways)
i generally have my mods define a global table with in shared all the functions/data thats accessed from both client and server
how 2 make spawn mod in secret compound
here is one way you could try: in your mod folder create a new folder CustomSpawnpoints (for example) and put it to the directory media/maps. in this folder, add a lua which defines your new spawnpoints. also add a txt file called map.info and this should contain the line "title= my spawnpoints" and i think a second line "lots=Muldraugh, KY" could do it...
without quotation marks
you could also check the mod folder for "Occupied Louisville" for example or other spawn point mods and see how they define the new spawnpoints. there quite a lot of them
would the secret lab be a safehouse? aka no zombies would spawn there?
i want to do a rp where you're one of the dick scientists that started it all
probably yes. no zombies in your spawn house by default afaik
bazz89? more like based89
ty
oh... just updated a mod today and might be possible that i made this mistake: a function in shared called something from client. XD XD no problems for single player but not sure about mp (not really possible for me to play test mp). maybe i should re-update soon...
ya that could lead to issues as the mp server tries to access it, since it doesnt actually parse the client files
best thing is probably if i do it right now asap...
Has anyone done any communication out from lua to another process (websocket/tcp/etc?)
Nice! You got the shapes of it pretty well.
Also the vertice count is solid, not too high poly and details where they are needed.
Is that a Dragunov tho? I really want to play with such a gun
ipc is pretty limited in pz, since theres no io.* module in pz's kahlua..at best your pretty much just limited to rcon or using files as a buffer for reading/writing data
Its just an AK
Its less polys than the M16
OH
I thought you were talking about the AK i made
Those werent made for zomboid, i made them maybe 4 months ago
I think files would be ok (looking to export data from pz, don't really need full RPC), rcon is limited to dedicated servers right?
They could fit into PZ with some texturing tho, the scopes are so sexy ๐
pretty sure, but never really checked to confirm it
Thanks, i'll think about doing that
Anyone know the name of the mod that allows you to claim vehicles?
In ScriptManager.class there is a public method called getAllItems, can I call this from a lua script?
Anyone have a clue as to why the server is never receiving this command? Other commands in my mod are being received just fine.
local function OnGameTimeLoaded()
print("sending command from gametime event")
sendClientCommand(getPlayer(), 'myModule', 'myCommand', {})
end
Events.OnGameTimeLoaded.Add(OnGameTimeLoaded)
the message shows up in the log, and no errors appear
not sure when that event fires (never used it) but probably happens before character is fully in game? sendClientCommand doesnt seem to work until then.. couldnt even get it to fire OnGameStart previously
Can anyone point me to an example of how to create a simple mod that adds traits? I simply want to add traits that give skill levels, that's all.
Found this one because it's when LuaNet is initialized, so my log looks like
[09-02-22 16:51:07.375] LOG : General , 1644450667375> 40,562,037> LuaNet: Loading....
[09-02-22 16:51:07.375] LOG : General , 1644450667375> 40,562,037> sending command from gametime event
I'll see if maybe I can get the character creation ones to work
i'm looking at the lua files in the base game and there is only one file with *trait* in it, and it's for the GUI
Use the TraitFactory (https://zomboid-javadoc.com/41.65/zombie/characters/traits/TraitFactory.html)
Javadoc Project Zomboid Modding API declaration: package: zombie.characters.traits, class: TraitFactory
i'll have a look, thanks
From my Better Lockpicking Fixes:
local nimblefingers2 = TraitFactory.addTrait("nimblefingers2", getText("UI_trait_nimblefingers"), 3, getText("UI_trait_nimblefingersDesc"), false)
nimblefingers2:addXPBoost(Perks.Lockpicking, 2)
BaseGameCharacterDetails.SetTraitDescription(nimblefingers2)
3 is the cost, false means it's not an occupation-only trait
ah, excellent... i can work with this. Thanks again
There's a bit of nuances with MP though.
- That code needs to go in the shared folder.
- You will need to overwrite the base game's recalculation of traits in order for them to apply correctly when making a new character after dying. (code below) This one also affects singleplayer.
local OldDoTraits = BaseGameCharacterDetails.DoTraits
local function CreateTraits()
--create trait(s) here from code above
end
local function DoTraits()
OldDoTraits()
CreateTraits()
end
BaseGameCharacterDetails.DoTraits = DoTraits
oh ok...
public static void sendClientCommand(String var0, String var1, KahluaTable var2) {
if (GameClient.bClient && GameClient.bIngame) {
GameClient.instance.sendClientCommand((IsoPlayer)null, var0, var1, var2);
} else {
if (GameServer.bServer) {
throw new IllegalStateException("can't call this function on the server");
}
SinglePlayerClient.sendClientCommand((IsoPlayer)null, var0, var1, var2);
}
}
it wont work until GameClient.bIngame is true. that doesnt get set true til a few lines before OnTick event fires for the first time
Thanks! I'll see about using OnTick then deregistering it on the first tick then.
thats what i do when i need to fire on connection
Nice it works!
Can anyone run this for me and send me the output? I can't get it to work.
https://github.com/cocolabs/pz-zdoc
I need access to the API, I'm struggling looking through decompiled classes
Anyone know a mod to spawn any item???
Debug mode works fine?
CheatMenu is what i use
Where can you find the item icon textures
I got it what do I press to use it
if you have it active just right click anywhere and you should see the cheat menu
Ok got it thanks sm
Anyone have experience using global mod data or GameTime.instance:getModData?
I've tried using both to simply store 4 string values, but the values either aren't being saved or loaded (can't tell which)
Anyone know the lua code to remove an item from someones inventory someone previously indicated it was palyer:getInventory():Remove("ITEM NAME") but that doesnt seem to work
@round zenith i dont think server and other clients have access to someone inventory. But the server could send a command to the targeted player and ask to remove the item if its found.
Am I able to write my own radio stations and add them in
@tranquil jackal https://steamcommunity.com/workshop/filedetails/?id=2224576262 is what you are looking for I believe
@thin hornet is that not what the code would be achieving? --> player:getInventory():Remove("ITEM NAME")
I mean the code playerObj:getInventory():Remove("ITEM NAME") would only work if called in that player's client.
other clients cannot remove someone else inventory items (i believe)
i dont even think the server can either
the server would have to transmit a command to the specific player and tell him to remove it, and then that client receive the command and execute it
I have the code being called in this lua file when the user craft something, according to what you are saying it sounds like it should work then?
crafting recipe are placed into server/ dir, but are not executed from the server (mp)
I want to be able to do it myself though
Like
Make my own
@tranquil jackal ya so just modify what they did in there code and you can
np
some stuff into lua/server/ are still clientside (it seem)
you crafting recipe should work, can you post the code maybe something is wrong into it
no crafting recipe works fine
recipe Sell 25 Pearls for Masterson Horizon
{
Pearls=25,
keep WalkieTalkie4/WalkieTalkie5/HamRadio1/HamRadio2/HamRadioMakeShift,
Result:MastersonHorizon,
Time:10.0,
Category:Trading,
OnCreate:CarCraftingMH_OnCreate,
}
Lua code
function CarCraftingMH_OnCreate(items, result, player)
addVehicle("SmallCar02")
local vehicle = player:getVehicle()
if not vehicle then
vehicle = player:getUseableVehicle()
end
if not vehicle then
vehicle = player:getNearVehicle()
end
sendClientCommand(player, "vehicle", "getKey", { vehicle = vehicle:getId() })
**player:getInventory():Remove("MastersonHorizon")**
end
item definition
item MastersonHorizon
{
Weight = .01,
DisplayName = Masterson Horizon + Keys,
icon = MastersonHorizon,
Type = Normal,
}
everything works as intended but removing the item after the car spawns as I want the car to show in the image for the recipe
isnt that item the result item of the recipe?
if so it is added officially to the inventory only after OnCreate is called
oh damn, is there a way around that so that its called afterCreate?
yeah
add RemoveResultItem = true
try that in the recipe script.txt
this will prevent the result item to be added after the recipe is completed
recipe Sell 25 Pearls for Masterson Horizon
{
Pearls=25,
keep WalkieTalkie4/WalkieTalkie5/HamRadio1/HamRadio2/HamRadioMakeShift,
Result:MastersonHorizon,
Time:10.0,
Category:Trading,
OnCreate:CarCraftingMH_OnCreate,
RemoveResultItem = true,
}
that didnt appear to work when i just tested it
according to zombie\inventory\RecipeManager.java
public static InventoryItem PerformMakeItem(Recipe var0, InventoryItem var1, IsoGameCharacter var2, ArrayList var3) {
line 151
if (var6.equals("RemoveResultItem")) {
this.removeResultItem = var7.trim().equalsIgnoreCase("true");
}
line 681
if (!var0.isRemoveResultItem()) {
return var9;
} else {
return null;
}
@thin hornet to confirm this goes in the recipe code not the lua?
isRemoveResultItem = true and RemoveResultItem = True didn't work
also tried IsItemDestroyed
RemoveResultItem = true
idk from the source code thats what i would expect it to do. It should return null and then in ISCraftingAction it shouldnt add the item.
If that doesn't work in the source code is there a method for AfterCreate?
nope
List of recipe possible field:
Override
AnimNode
Prop1
Prop2
Time
Sound
Result
OnCanPerform
OnTest
OnCreate
AllowDestroyedItem <-- not used anywhere *useless* became -> NoBrokenItems
OnGrab <-- looks like this one useless too
needtobelearn
category
RemoveResultItem
CanBeDoneFromFloor
NearItem
SkillRequired
OnGiveXP
Tooltip
Obsolete
Heat
NoBrokenItems
StopOnWalk
StopOnRun
@thin hornet lolol
I figured it out
ready for this
its going to make you rage at human error
its not RemoveResultItem = True,
its RemoveResultItem:True,
D:
ah right
if (var2[var4].contains(":")) {
String[] var5 = var2[var4].split(":");
my bad missed that one lol
ya I missed it because you showed me Java and I got happy because I love Java
cool now I can push a few 1000s more lines of code to update the currency mod I have. TY!
np
Weapons and WeaponTools have a "ConditionLowerChanceOneIn" attribute... anyone know how I access this in a lua script?
anyone can help me
I'm trying to make a mod that increases washing time
and optimizes water u sage
it keeps throwing out the error
ERROR: General , 1644477266685> ExceptionLogger.logException> Exception thrown se.krka.kahlua.vm.KahluaException: ISWashClothing.lua:6: unexpected symbol near `10` at LexState.lexerror line:278.
ERROR: General , 1644477266685> DebugLogStream.printException> Stack trace:
se.krka.kahlua.vm.KahluaException: ISWashClothing.lua:6: unexpected symbol near `10`
Hello guys ! I'm looking for a 3D modder/designer who would have the time to help me develop a mod around trailers or trucks plus trailers. I am available in PM
first of all i suggest you add a sub directory for your script:
from /lua/client/ISWashClothing.lua to /lua/client/BetterWashing/ISWashClothing.lua
To prevent name clash
secondo, your error is about a syntax error, somehow unexpected symbol in your code on line 6
like 6? what does that mean
ISWashClothing.lua:6 tell you that the error is on line 6 of that file i believe
im tired i type bad right now lol
should i send whole code here
or would that be bad idea
or a screenshot
function ISWashClothing.GetRequiredWater(item)
local filth = (bloodAmount+dirtamount)/2
if (filth > 10) then
return 10
else
return filth / 20
end
end
function ISWashClothing:new(character, sink, soapList, item, bloodAmount, dirtAmount, noSoap)
local o = {}
setmetatable(o, self)
self.__index = self
o.character = character;
o.sink = sink;
o.stopOnWalk = true;
o.stopOnRun = true;
o.item = item;
o.maxTime = ((bloodAmount + dirtAmount) * 1);
if o.maxTime > 100 then
o.maxTime = 100;
end
o.soaps = soapList;
o.noSoap = noSoap;
o.forceProgressBar = true;
if character:isTimedActionInstant() then
o.maxTime = 1;
end
return o
end```
ive changed the filename now
but the output error still says ISWashClothing
require ("ISWashClothing");
function ISWashClothing.GetRequiredWater(item)
local filth = (bloodAmount+dirtamount)/2
bloodAmount and dirtamount are not known here
ah
you should add em in the :new()
o.bloodAmount = bloodAmount;
o.dirtAmount = dirtAmount;
oh never mind
might want to add Filth as a parameter
since that method is not an instance method but is a static one
sorry, quite new to lua
so we set o.filth here instead of bloodAmount and dirtAmount and add filth to new()
wait are you overwritting ISWashClothing?
yeah wait ill show you
Example for a static method:
local ISWashClothing_GetRequiredSoap = ISWashClothing.GetRequiredSoap; -- store the original function
function ISWashClothing.GetRequiredSoap(item)
local vanillaRequiredSoapValue = ISWashClothing_GetRequiredSoap(item); -- call the original to know the original value
local resultValue = 10;
-- do your stuff
return resultValue; -- return your overwritten value
end
Example for an instance method:
local ISWashClothing_perform = ISWashClothing.perform; -- store the original method
function ISWashClothing:perform(...)
-- do your stuff before
ISWashClothing_perform(self, ...); -- call the vanilla method
-- do your stuff after
end
Example for a constructor method:
local ISWashClothing_new = ISWashClothing.new; -- store the original constructor
function ISWashClothing:new(character, sink, soapList, item, bloodAmount, dirtAmount, noSoap, ...)
local newObj = ISWashClothing_new(self, character, sink, soapList, item, bloodAmount, dirtAmount, noSoap, ...);
-- do your stuff to the constructed obj
return newObj;
end
so could the reason why it outputs that error
is I havent actually been replacing the code
and its sitting on top of the vanilla values
yeah
The method i show we call it "Hooking"
The way you did first was litteraly overwritting (which is bad for mod and game update compatibility)
we all did that mistake when we started
it doesnt have to, its just how i choose to do it for making it readable, to know what it is.
for example
local washcloth_new = ISWashClothing.new;
you can do that its just less clean in my opinion
for me i want to know what object and what method it hook. its more specific/clean if i use the same names
yeah, good reason
so by calling original value, do we still have to do o.bloodamount (or o.filth)
also if you dont need the param for the constructor
Example for a constructor method:
local ISWashClothing_new = ISWashClothing.new; -- store the original constructor
function ISWashClothing:new(...)
local this = ISWashClothing_new(self, ...);
-- do your stuff to the constructed obj
this.inventory = this.character:getInventory();
return this;
end
you dont need to pass the bloodamount and dirtamount to the constructor of that action
What do you want to do exactly
Since I made a variable "filth", i want to use filth instead of bloodAmount+dirtAmount
sorry gotta be like this local ISWashClothing_new = ISWashClothing.new; no ()
woops
you want to change the time it take and the amount of water it use right? thats all?
yea
so all you need to do is simple
not longer than 100 time but linearly based on the amount of dirt and blood
with water
not more than 10 water, but proportionally based on dirt and blood
Is there a good way to play sound from a player that will stick to the player?
--- To overwritte the time needed to wash this item
local ISWashClothing_new = ISWashClothing.new;
function ISWashClothing:new(character, ...)
local this = ISWashClothing_new(self, ...);
this.maxTime = 100; -- the time you want
if this.character:isTimedActionInstant() then
this.maxTime = 1; -- for when instand action cheat is enabled
end
return this;
end
a new function to calculate the filth:
local function CalculateItemFilth(item)
local bloodAmount = 0
local dirtAmount = 0
if instanceof(item, "Clothing") then
if BloodClothingType.getCoveredParts(item:getBloodClothingType()) then
local coveredParts = BloodClothingType.getCoveredParts(item:getBloodClothingType())
for j=0, coveredParts:size()-1 do
local thisPart = coveredParts:get(j)
bloodAmount = bloodAmount + item:getBlood(thisPart)
end
end
if item:getDirtyness() > 0 then
dirtAmount = dirtAmount + item:getDirtyness()
end
else
bloodAmount = bloodAmount + item:getBloodLevel()
end
return bloodAmount + dirtAmount;
end
and a hook for the amount of water:
local ISWashClothing_GetRequiredWater = ISWashClothing.GetRequiredWater;
function ISWashClothing.GetRequiredWater(item)
local filth = CalculateItemFilth(item);
return 10 / filth --- or what ever calculation you want
end
so that allow you to add the two value that you wanted and change the maxtime as you need
i dont think you need the blood amount here
I dont need to re-calculate blood and dirt
sorry im lagging quite a bit
internet
I thought it was a bit simpler
you need to recalculate it cause its not available inside the GetRequiredWater function
its pretty simple
cant I getInstance or equivalent?
the whole script look like this
-- function to calculate an item filth, same script used in vanilla
local function CalculateItemFilth(item)
local bloodAmount = 0
local dirtAmount = 0
if instanceof(item, "Clothing") then
if BloodClothingType.getCoveredParts(item:getBloodClothingType()) then
local coveredParts = BloodClothingType.getCoveredParts(item:getBloodClothingType())
for j=0, coveredParts:size()-1 do
local thisPart = coveredParts:get(j)
bloodAmount = bloodAmount + item:getBlood(thisPart)
end
end
if item:getDirtyness() > 0 then
dirtAmount = dirtAmount + item:getDirtyness()
end
else
bloodAmount = bloodAmount + item:getBloodLevel()
end
return bloodAmount + dirtAmount;
end
-- this one we overwrite cause anyway it just return a constant
function ISWashClothing.GetRequiredWater(item)
local filth = CalculateItemFilth(item);
if filth > 10 then
return 10
else
return filth / 20
end
end
--- To overwritte the time needed to wash this item
local ISWashClothing_new = ISWashClothing.new;
function ISWashClothing:new(character, sink, soapList, item, bloodAmount, dirtAmount, noSoap)
local this = ISWashClothing_new(self, character, sink, soapList, item, bloodAmount, dirtAmount, noSoap);
local filth = bloodAmount + dirtAmount;
this.maxTime = 100 / filth; -- the time you want
if this.character:isTimedActionInstant() then
this.maxTime = 1; -- for when instand action cheat is enabled
end
return this;
end
btw i am unsure
is 100 max blood and 100 max dirt?
dirt+blood = 200?
hence my 20 divisor
i have no idea, try printing it out
this still overwrites without using the throwaway_new?
local audio = playerObj:playSound("WashClothing");
-- to stop the sound
if audio and playerObj:getEmitter():isPlaying(audio) then
playerObj:stopOrTriggerSound(audio);
end
is that good ?
yeah it overwritte cause the vanilla just return a constant number. so we are not breaking anything here
and as you can see its used multiple time
so the way we did it will work consistently everywhere that function is used
Do you think I should be using ogg vorbis or ogg opus codec?
i use ogg vorbis
what program is that btw, looks neat
so overall this is everything
i use Visual Code
Was hoping I could dive into mod options today
curve steeper than i thought
esp not much examples of modoptions
is there a modding tutorial for intermediate programmers?
im comparing my code to the code of another mod using modoptions
thank you
oh so local doesnt apply to those on the bottom
without local it will be global
which will clutter the global environment (would overwrite it if it existed and would set it and make it accessible in any other code)
I saw this
"Flickering mod sounds"
When I play a sound on my player, it will wobbles from one ear to the other.
This will be fixed in the next patch?;
i do hope that fixes it too
its the 3D sound that make it like that
so once i delete that and add local to filth
its all good right
function ISWashClothing:new(character,...)
local this = ISWashClothing_new(self,...)
local filth = CalculateItemfilth(item);
this.maxTime = filth / 2;
if this.maxTime > 100 then
this.maxTime = 100;
end
if character:isTimedActionInstant() then
o.maxTime = 1;
end
return this;
end```
its should be good, you might have to adjust the maxTime depending of your testing if its too quick
Thanks okay
try checking with console.txt in your documents/Zomboid directory
error will be explained better
Exception thrown se.krka.kahlua.vm.KahluaException: ISWashClothing.lua:6: unexpected symbol near 10 at LexState.lexerror line:278.
but a line 278 does not exist
wot
DebugLogStream.printException> Stack trace:
se.krka.kahlua.vm.KahluaException: ISWashClothing.lua:6: unexpected symbol near 10
LOG : Lua , 1644497120746> Loading: E:/SteamLibrary/steamapps/workshop/content/108600/2748768980/mods/BetterWashing/media/lua/client/ISWashYourself.lua
WARN : Lua , 1644497120746> LuaManager.RunLua> recursive require():
hold on brb toile
place your script into a sub directory
media/lua/client/BetterWashing/here
try to reload the game too
also your require is wrong and useless in this case
should be this if you really want it
require "TimedActions/ISWashClothing"
mods will always load after the vanilla scripts so thats why i say its useless in this specific case as most vanilla script are global
oh so you dont really need require? i thought it called for values in a different file but guess not.
require would ensure its loaded first
but your mod will 100% load after vanilla scripts
mods that require other mod need to check if the other mod is active and then require what it needs.
cause mods will have different load order
mods l.oading mods to load mods while modding modded mods that can be modded by mods?!
I see. I used some other mod as a base because I didnt understand lua
they just copy pasted the code inside ISReadingBook
so I copied the method
modulation
i gotta go to store will be back shortly
modception!
getEmitter():playSound plays different soudns on all clients if there are more than 1 sound files defined for 1 sound eevent
Interesting to know
Using clip to define multiple files
Also it gets muffled by walls ๐ฎ
ModOptions.lua:48: 'end' expected (to close 'function' at line 34) near <eof>
Check everything above that function
hey lovely mod people! I started to look into modding, and I was wondering, does anyone know if the limits on how far away a player can look (move the camera away) in Aim Mode can be set/get with Lua functions?
I would like to play with reducing / increasing it (I know if I increase I might run into a scenario in which you are looking further away but the chunks aren't loaded, but step by step)
If not, does anybody know which class is related to this behaviour? I'm looking at the IsoCamera class but I don't understand if the vector used for this is FakePos or offVec or I'm looking in the wrong place
Last time I played with camera I had a lot of "unexpected" behaviors.
I wanted to make a CCTV test to see far away
hahaha that's very encouraging
the vanilla camera by default quite looks unfriendly
I have a great mod suggestion in mind but too advanced for me
not sure if possible
better blocks occlusion
this exists
but its more important on this side, but doesnt happen
yeah I see
i do hope the object and walls occlusion is fixed eventually, its really weird to see through wall with home-made building.
yea and well its making it transparent on the wrong side
so with CCTV test, you mean you wanted to be able to temporarily move the player Camera to the position of the surveillance Camera?
@radiant hound yeah
that sounds neat, but yeah, can see how it'd be hard
I dont recall exactly what was the issues i had its been a while
something like the player become invisible and the fog of war not loading
ok but do you know which variables / functions were related to moving the Camera away?
also i prefer the occlusion method to be left
center = unoccluded
right = current occlusion
left = preferred method
ideally I "just" want to increase the amount of distance the player can look away while in Aim Mode, rather than have the Camera fixed somewhere else in potential conflict with player actions, as in your CCTV case
wouldn't you have then the same problem you have now but on the other side?
fixing other side to not occlude at all
but it is occluding correctly with right-method
because you are behind
sorry I'm a bit dense with visuals, I think i'd need to see all the cases with player positions (but don't bother on making it to show me, I'm not skilled enough atm to do anything in that area anyway xD)
tough getting behind all these crates
looking for sledgehammers
and takes you a long time to find what is blocking your way
hi! does it matter whether I create new folders in the lua/shared (or in lua/client or lua/server) directory and put my .lua files in there? is this safe? or is there a possibility that this might cause problems?
i suggest you do, thats gonna be cleaner, might prevent naming conflict too
ok... so answer is, creating new folders within shared, client or server is safe...? (presupposed that the new folders in client for example only contain functions which belong to the client side ofc)
Might this be an error with ISWashClothing.lua in itself?
if modified in any way
might give up for tonight
@small topaz
lua/client/MyMod/ClientScript.lua ---> require("MyMod/SharedScript")
lua/server/MyMod/ServerScript.lua ---> require("MyMod/SharedScript")
lua/shared/MyMod/SharedScript.lua
example with both client and server requiring stuff from the shared
thanks for the help @thin hornet cool guy
Does anybody know why the 223 magazine exists? No gun uses it
The gun that would use it has an internal magazine
ill check it out next time you get back on it
Line is just commented. So, could be they just made mag and forget to remove it.
also, is there a .x exporter for blender
You could use .fbx for weapon and attachment instead of .x.
Probably for everything, but i didn't test it.
I was watching a tutorial on how to make a firearm mod and it said to use .x
so im not sure on whether or not FBX is the way to go
If you really want .x, you could export .fbx and then convert .fbx to .x online, like here.
https://3d-convert.com/en/
It works, i already tried.
Oh ok
Someone needs to make a special infected mod. Would love to see screamers, spitters tanks, ect as a possibility
How possible would that be?
i'd like to commission a mod, pls dm me for more details
Do these zdoc jar files still exist in Zomboid? I can't locate this folder in either my steamapps dir or the home directory. I get the feeling IntelliJ would be able to pick up the entire Zombies directory but I'd imagine just having IntelliJ decompile everything every time it opens would be horribly slow.
https://github.com/Konijima/PZ-Libraries/blob/Tutorial/README.md
edit: nevermind https://steamcommunity.com/sharedfiles/filedetails/?id=2748451514
We can commission here?
$50 a pop and i got chu LOL
bro make a tank zombie, a witch and a spitter that would be worth 50$ for me depending how well you execute it
the hell. you want custom special zombies?
there's already a special zombie mod.
do they actually have separate models and function alot like l4d?
no, they are weorse. so much worse.
in a good way?
So, I was thinking about a Negative Trait..
Zombie Fetish.
You have a % to randomly take off your pants around zombies.
hello there. I have yet another coding question:
With sendServerCommand, how would I use it? would this work?
GetZedOutfit = GetZedList:get(i):getOutfitName();
GetZed = GetZedList:get(i);
sendServerCommand("STR", "GetZed:sendObjectChange(GetZedOutfit, {})", {});```
I'm mainly confused as to what "commandName" pertains to. Do I point it to a function?
I'm new to the whole Multiplayer/server data stuff
I posted a workshop link. It has a tank and a witch-like zombie.
Wait a min i just read ur name, thats sick good work dude
Question how exactly can the tank be killed? Hitting it enough or only bullets? All i got from a youtube vid was โmust me killed in unconventional waysโ
yep, that's right, unconventional ways work. Direct weapon damage only works if it is a critical, sneaky stab with knives or I think runnning attack with spears? Never tested that one
But in sandbox mode you can set it to take normal damage if you want
Anyone know how to save mod data to the server? From what I can tell, the server just doesn't save any mod data whatsoever.
How do you make custom ammo types
I need to make a new ammo type for my gun mod but idk how
search ProjectZomboid/media/scripts/item_weapons.txt for 556Bullets
Should be a good example
You have to sync it manually
Use ModData.Transmit(key)
or ModData.Request(key)
Even if I never want such data to be sent to a client?
If you don't want it to be sent to the client create it in the server and never transmit
That's what I'm doing
It just doesn't load in the server, because the server apparently doesn't save mod data.
Will this ammo goes directly to gun, or to magazine?
You prob talking about 7.62?
Yeah
It does. Check my Toxic Zones mod
It is a complex thing to work with though. I had to summon higher powers for a detailed explanation
Looks like all your moddata loading is in the shared folder there? Which means it's getting it from the client
All the data originates from a client because that's the idea of the mod, but it works the same way if you want to create it in the server
this conversation's getting me thinking... How would I make a server run something like... dressInPersistentOutfit("EMSLouisville"); sendObjectChange('GetZedOutfit', {}); reloadOutfit();?
instead of the client
module Base
{
/* First step - create bullets */
item Bullets762mm
{
DisplayCategory = Ammo,
Count = 5,
Weight = 0.01,
Type = Normal,
DisplayName = 9mm Rounds,
Icon = 40calAmmoBox,
MetalValue = 1,
WorldStaticModel = 9mmRounds,
}
/* Second step - create ammo box
item Bullets762mmBox
{
Weight = 0.2,
Type = Normal,
DisplayName = Box of 9mm Bullets,
DisplayCategory = Ammo,
Icon = HandgunAmmoBox,
MetalValue = 30,
WorldStaticModel = HandGunAmmoBox,
}
/* Third step - create magazine that uses your bullets */
item 762mmClip
{
DisplayCategory = Ammo,
CanStack = FALSE,
Weight = 0.2,
Type = Normal,
DisplayName = 9mm Magazine,
Icon = BerettaClip,
MaxAmmo = 15,
AmmoType = Base.Bullets762mm,
StaticModel = GunMagazine,
GunType = Base.Pistol, <-- here should be your gun
WorldStaticModel = Gun_Magazine_Ground,
}
/* One of the last steps - add new magazine to your weapon */
item AK47
{
AmmoType = Base.Bullets762mm,
MagazineType = Base.762mmClip,
AmmoBox = 762mmBox <-- actually idk what is that
}
}
You also need to add a recipe to open your bullet box.
Where would i make a recipe?
it's just a script, something like that.
recipe Open Box of .223 Ammo
{
223Box,
Result:223Bullets=8,
Sound:PutItemInBag,
Time:5.0,
}
recipe Place .223 Ammo in Box
{
223Bullets=40,
Result:223Box,
Sound:PutItemInBag,
Time:5.0,
}
But swap 223 to yours ammo
This recipe from
...\Steam\steamapps\common\ProjectZomboid\media\scripts\recipes.txt
{
item 762bullets
{
DisplayCategory = Ammo,
Count = 60,
Weight = 0.025,
AlwaysWelcomeGift = TRUE,
Type = Normal,
DisplayName = .762 Ammo,
Icon = 762bullets,
MetalValue = 1,
WorldStaticModel = RifleAmmo,
}
item 762box
{
DisplayCategory = Ammo,
Weight = 1.2,
AlwaysWelcomeGift = TRUE,
Type = Normal,
DisplayName = Box of .762 Bullets,
Icon = 762ammo,
MetalValue = 40,
WorldStaticModel = RifleAmmoBox,
}
item 762clip
{
DisplayCategory = Ammo,
CanStack = FALSE,
Weight = 0.2,
Type = Normal,
DisplayName = .762 Magazine,
Icon = BerettaClip,
MaxAmmo = 30,
AmmoType = Base.762bullets,
StaticModel = GunMagazine,
GunType = Base.ak47,
WorldStaticModel = Gun_Magazine_Ground,
}
recipe Open Box of .762 Ammo
{
762box,
Result:762bullets=60,
Sound:PutItemInBag,
Time:5.0,
}
recipe Place .762 Ammo in Box
{
762bullets=60,
Result:762box,
Sound:PutItemInBag,
Time:5.0,
}
}```
Is this a good script?
Im so happy this actually works
How could i make a gun that has an internal magazine but is not bolt action
Vanilla Firearms Expanded has an SKS that is semi-auto with an internal mag, might offer some insight
I already figured it out
I feel like I'm doing something wrong, I'm trying to increase the mag size of a weapon in a mod by 1 shell but changing the ClipSize or MaxAmmo value doesn't actually change anything in game. Is there something obvious I'm not seeing?
Should works actually. Do you have require=ModIDYouWantToOverwrite in your mod.info file?
I didn't make a separate mod, I just overwrote the value in the actual file. Is that where I went wrong?
Oh, that's how. Try to spawn item again maybe.
After you change something.
Or looks like it's not working too. :)
I tried, tried an entirely new game as well and it didn't work.
I double checked that the values were still what I changed them to and they were but it kept generating or being spawned as the original value.
There something weird going on. It should works.
I'm not sure, but could be that this value maybe was overwritten in lua somewhere in mod? Which i found pretty strange.
What mod you also talking about @weary crypt, i could check.
Vanilla Firearms Expansion, specifically I'm trying to revert a change it makes to the vanilla shotgun of reducing it's internal shell capacity from 5 to 4.
๐ค
Any chance that this value was overwritten by another mod? idk
I have idea, can i dm you VFE_weapons.txt and you just replace it?
Sure
It's weird af.
Just to make sure.
- Do you place it in
...\Steam\steamapps\workshop\content\108600\2667899942\mods\VFE\media\scripts? - Maybe any other mods on that affects this value?
Yes, and I'm checking right now. I can't think of any because that's the only mod I have that touches firearms but I'm loading a fresh world right now with nothing else
The only two mods active here are VFE and Cheat Menu
Actually wait a sec
I think I figured it out.
What was that?
Need to confirm first
Yep figured it out. I only glanced at the filepath at first but I realized I was in the local copy of the mod instead of the one you posted
while I don't know of the exact year of origin of this vehicle, an idea of PZ happeing in "ye olde times" would be very neat ngl
also lovely model
Knew it. :D
I was in \SteamLibrary\steamapps\common\ProjectZomboid\steamapps\workshop\content\108600\2667899942\mods\VFE\media\scripts
Thank you for the help, I appreciate it.
Well, glad that you figure it out.
I had a feeling it was something simple I was missing.
Me too, lol.
How would i make my custom guns use the vanilla attachments

