#mod_development
1 messages Β· Page 524 of 1
not sure if it is
but there is one example
not isClient()
Is this a normal way for sending update to clients and server?
object:transmitUpdatedSpriteToClients()
if isClient() then object:transmitUpdatedSpriteToServer() end
Yeah I can't decide if the syntax would register correct or not Lol
This might be helpful, idk.
#mod_development message
isServer(). You should check out the GlobalObject documentation someone sent a bit ago, it's listed there
not isClient() might work, dunno, but it raises the question of "what does isClient/isServer return when the game is played on singleplayer/splitscreen?"
Which could be determined with a bit of testing, or answered by someone who knows (I don't)
Unsure what you mean
I was referring to this link
oh sorry
im thinking of a different thing
I'm not sure how to do what I want to do
is making my mod work on both multiplayer and singleplayer
as simple as moving it to lua/shared
instead of lua/client?
afaik, from my testing, server/client is only for the scope of what you're trying to do. lua/client would work in both sp/mp if the mod is limited to the client and does not need global/persistent information from what the server does.
lets say your mod allows your player to kill zombies in your immediate area by pressing the 7 button. that would work fine under lua/client
because the kill zombie button would work on server/client
if i remove if isClient() It would work globally?
but what config would it follow
the config of the person who joins
or the config of the host
You can test it out for confirmation, but I think it should take server's options/settings (not the client/joinee's)
Would it be possible to create 2 factions on game start and then also make the player have to choose the faction before spawning?
I have no idea but that'd be so cool wtf
I'm tryna work out a feasible way to do team death match for my server
But obviously we don't want the players to accidentally kill eachother on the same team
I already worked out good server settings to make it less "one hit kill- ey" and worked out server options so that you spawn with decent weaponry
with the better hair ui mod, i won't be surprised if this is possible, as it should just be a dropdown. hope you get it working, sounds like a fun server π
Yeah just been doin setup for it
might launch Free For All tomorrow
maybe using SteamID to keep score of Kills and Deaths would also be cool
is the isAdmin() for host?
I assume it's for anyone that's an admin
it's an access type
if you try to host, you can check and grantadmin on yourself/other players
admin has special powers, kinda like debug mode
oh so thats not gonna work
ah
i finally understand what question to ask
what line of code allows me to change a line in sandbox_vars
or wait. does my mod already apply in multi?
i dont play multi
There is a way to do Lua MySql :)
Unaware if its feasible with PZs LUA
But def would be cool
what
so blood level 0 = max blood
and blood level 1 = no blood?
but dirt amount is 0 = there is no dirt
perhaps that is whats missing
No like
100 = Blood Level Maximum
0 = Blood Level Minimum
Since its a range value
and bloodLevel is 77
Whereas bloodAmount
Is a ratio
1 being maximum blood and 0 being minimum
Iirc
I forgot the term for it in mathematics
so what say you suggest for the math
but do you know how to convert
Inclusive Interval
Thats what it is
Also idk
Its basically just 100-0
But in this case a decimal
So I think .77 is just equivalent to 77
You just tack on a leading zero
But its def weird
To have one measurement be a value of 100 to 0
And the other to be a decimal of 1 to 0
I dont know why there is 2 values man
bloodAmount is my local
Thats kinda confusing lol
i set it so that it gets bloodLevel
yes
Thats even more confusing
item getbloodlevel
if it says 100/100 bloody
i want 100 bloodLevel
and 100 bloodAmount
Its a float value
BloodLevel is
And floating point arithmetic is
Confusing as fuck to me
Idk man
maybw item:getBloodLevel isnt returning the correct values
hallo all guys!
MySQL would be quite overkill for something like that though. Just save the data in memory and save to a file or use sqllite which pz would already have it anyway
I'm now experiencing that moment when you lose 2 hours to understand why your script doesn't work and then you notice that the script was not working due to one single typo... π
Life of a modder is really hard LOOL π
Nice work mate, they're amazing!
thanks
I was looking the last screen...the upper car...we need a Ghostbusters skin for it too π
I presume a toy ( Image found on Google images ) π
is it possible to have an item (e.g. food) that only gives +unhappiness to certain players, rather than modifying the item properties themselves (so you can't trade the -unhappiness item, they would see it as normal)
btw whats the difference between
item:getBloodyness()
and
getBloodyness(item)
are they the same?
are these examples of those
sugars
A person is making this car right now commissioned by SheriffEli
hey
who wants to make a house heater mod
i have a model i made for it and its just sitting here doing nothing
i can make it into a tile as well
This is relevant to something I'm trying to understand. Once you create a new type of panel window, how do you construct or invoke it?
Trying to create an item searching mod - input a search item and induce the character to walk around searching nearby containers for it. The two points of understanding I'm missing are constructing/binding data into the new panel and figuring out how to scan for nearby containers.
I made a guide to understand the base:
https://github.com/MrBounty/PZ-Mod---Doc/blob/main/Make an custom UI.md
Thank you very much! I will give this a look.
And I use that to find nearby container:
local containerList = {};
for i,v in ipairs(getPlayerInventory(self.playerNum).inventoryPane.inventoryPage.backpacks) do
table.insert(containerList, v.inventory);
end
for i,v in ipairs(getPlayerLoot(self.playerNum).inventoryPane.inventoryPage.backpacks) do
table.insert(containerList, v.inventory);
end
return containerList;
it returns all containers except the player's inventory
So things like nearby storage racks, etc., are contained within the backpacks object?
yep
Weird!
backpack of the loot inventory is like the backpack of your player inventory
ahhh
You see ? There is the base inventory (player inventory and ground) and after that you add backpack. Like real bag or container
Yes now I'm noting the variation to call getPlayerLoot
item is a table right
and it has "Dirtyness" and "BloodLevel"
how do I get these values from the item table
in code
If I wanted to expand the searchable area to the entirety of a room (even the large warehouse), would I have to use a different method to grab nearby cells and search for containers?
ive already attempted
Yes, impossible with that. It's give item at hand
local function CalculateItemFilth(item)
local bloodAmount = 0
local dirtAmount = 0
local blood = item:BloodLevel
local dirt = item:Dirtyness
if instanceof(item, "Clothing") then
if (item:BloodLevel > 0) then
bloodAmount = bloodAmount + blood
end
if (item:Dirtyness > 0) then
dirtAmount = dirtAmount + dirt
end
else
if (item:BloodLevel > 0) then
bloodAmount = bloodAmount + blood
end
if (item:Dirtyness > 0) then
dirtAmount = dirtAmount + dirt
end
end
return bloodAmount + dirtAmount
end
local ISWashClothing_GetRequiredWater = ISWashClothing.GetRequiredWater;
function ISWashClothing.GetRequiredWater(item)
local vanillaWaterAmount = ISWashClothing_GetRequiredWater(item);
local filth = CalculateItemFilth(item)
if filth > vanillaWaterAmount then
return vanillaWaterAmount
elseif filth < 1 then
return 1
else
return filth
end
end```
i dont think this is the right way
the functions getDirtyness() and getBloodLevel() return a different value from what it actually is
item:getBloodlevel(), item:getDirtyness()
It's what I use
it's a %
so [0-100]
if its a percent
if i dig into the debugger info
the item table shows it as 77.**
but bloodamount, the local i set, shows 38.**?
so..
item:getBloodlevel()*100
should i say
ill just try to make a new .lua file
just to get the values
I don't get why item:getDirtyness() is not working
Do you get an error ?
Because dirtyness and blood level is for clothing, so you need to be sure that item is a cloth before call item:getDirtyness(). Like that item:IsClothing() (Or item:IsWeapon() because weapon got blood level too)
How, can you specify?
I was thinking, how can I add weapon/gear stashes spread out in the map?
Hello guys. I am trying to learn some Java and PZ Modding structure/basics, and to begin with learning I began to dig through some code while trying to suit a specific mod into my own needs. So digging through the mod code i wanted to add a property for an custom medical item, which apart from reducing pain, would also fully reduce cold/flu symptoms. Sadly it didnt quite work. I have tracked the same method which the author used to add the getReducePain function in the item, but i wasnt successfull. Could someone maybe take a look onto what I was doing wrong? Appreciate any help.
You might need to provide a little more information to get some assistance. Do you perhaps have a link to your source code, or at least a relevant snippet?
Of course!
So this is the code of the function in the item that reduces pain:
local normalEffect = function()
if not Survivor:isInitialized() or Survivor:getBlood():getDrugs()[Alkagin.alias] == nil then
return false
end
if not Survivor:getBlood():getDrugs()[Alkagin.alias].isActive then
return false
end
if Survivor:getPainReduction() < 35 then
Survivor:setPainReduction(35)
end
end
I tracked the getPainReduction function back to the Survivor class:
---@return number
function Survivor:getPainReduction()
return getSpecificPlayer(0):getBodyDamage():getPainReduction()
end
---@param value number
---@return void
function Survivor:setPainReduction(value)
getSpecificPlayer(0):getBodyDamage():setPainReduction(value)
end
And I basically did the same by adding the get and setColdStrenght function to the Survivor class
getSpecificPlayer(0):getBodyDamage():getColdStrength()
end
function Survivor:setColdStrength(value)
getSpecificPlayer(0):getBodyDamage():setColdStrength(value)
end
and then adding a second local function to the medical item:
Javadoc Project Zomboid Modding API declaration: package: zombie.characters.BodyDamage, class: BodyDamage
if not Survivor:isInitialized() or Survivor:getBlood():getDrugs()[Alkagin.alias] == nil then
return false
end
if not Survivor:getBlood():getDrugs()[Alkagin.alias].isActive then
return false
end
if Survivor:getColdStrength() > 1 then
Survivor:setColdStrength(0)
end```
This was my reference while adding this function
There are all the functions. Search "cold" on the page and you will find everything
getColdStrenght is specified there
So I miss understand the issue mb
But it doesnt sadly work in this code, at least at this moment when i am debugging it
It reduces the pain though, but not the cold. Thats why i am wondering myself what could ive missed.
Are you sure it's not reducing ? Maybe the max value of the strenght is higher that you think
I tried that also with other functions like get/setColdProgressionRate
Yeah i am sure. The cold is set in debug mode at 100.
Otherwise search in .lua vanilla game, to find exemple
I can't do more here, no idea
I tried using common mallow as my reference as it reduces in vanilla game the flu sympotoms as the only item.
But i didnt find anything in lua which could be related.
The only thing i found with common mallow was a parameter FluReduction =5
So I think it's not made for. Maybe make an food and make the player eat it
But it was stated in scripts/items
Sure thanks so much for the help anyways @drifting ore . If someone would have a clue or a little tip though It would be greatly appreciated.
The function is use one time in media\lua\client\LastStand\AReallyCDDAy.lua, line 112
That it
hey guys. How do I set perk level? I'm trying to use the function "setPerkLevelDebug" but nothing changes
Small question: whas is actually the difference between SpecificPlayer and playerObj? Does SpecificPlayer refering to a specific player in MP and playerObj to the single player character?
yes
getPlayer() always returns the first local player
with getSpecificPlayer() you can get other local players for example split screen players
I want to make a neckwear item, and have code running to modify their temperature if the item is wet
how do I modify only the player(s) wearing the item(s)?
Thanks!
Managed to get it working, thanks once again for your help mate.
Guys a quick question so I can save a bit of time...When you start a new character in Apocalypse in one of the previous screens/menus before starting you can chose if your character will be naked/dressed and what kind (if any ) of clothes your character will wear. In that screen you can also save any preset you want ( ...and they are saved in the "Users " folder ).
Somehow by default the game assign a basic combo of random characther name, body style ( hairs,bear, etc ) and clothes.
Anyone knows where the vanilla file/s that control this is/are located?
( I guess somewhere in media-->lua )
Is guns accuracy only calculated via Java? Cause I can't find any reference in .lua files
I found the Reloading in ISReloadWeaponAction ISInsertMagazine.lua and ISLoadBulletsInMagazine.lua
π
@gilded hawk For the nimble stats you can alter them via the MainCreationMethods file IIRC π
lua test()
ignore it. Just messing around trying to quote code
@drifting ore
and preceding image
i think i should keep backups before editing
|gnore it. Just messing around trying to quote code
@daring palm Click on the + symbol you can link files/scripts or you can send the message as code ( Simply write the part of code of interest/the script part in the writing box then press enter the option will pop up )
what's the difference between ContextMenu_lang.txt vs IG_UI_lang.txt ?
try write this:
```lua
local test = test();
```
i guess you mean the "Character Customisation Screen". It is controlled by the files "lua/client/OptionScreens/CharacterCreationMain.lua and CharacterCreationHeader.lua in the same directory. The randomization is mainly done in the Header file. The save and load functions are in the Main file.
@small topaz Thanks mate !!!! π
I'm reading ISInventoryPaneContextMenu.lua and I see local playerObj = getSpecificPlayer(player). Where is player being passed in or coming from?
Yes, is it really necessary to test that here?
To reply to your question...ContextMenu_lang.txt will affect only the writings when you mouse over an item in the inventory for example
Yes, I sort of figure this out. The other one is for things placed in the world
Yep correct + any other UI elements π
how do you guys reload your mods when developing ingame? just use the f11 menu? seems a bit buggy for me
I personally restart the game but I set it in windowed mode ( Not the borderless one ) so I can close it in a click
ah k
it only reload lua I think
reloading save works well but it was a bit annoying, so I tried f11 reloading and it gave me stack errors after a few reloads on a simple print script
not .txt if you reload via F11
so I don't trust it
In addition if you want you should find around a scripts that let the game restart automaticallly every time you'll close it
So in brief I do so: One click in windowed mode to close it quickly then the script restart the game automatically
its ok
it takes 10 seconds to quit save and load save
and it reloads my lua mod
slightly annoying but I can deal with it :D
yep a bit more cumbersome but at least safer
good idea on the game relaunch script tho, but my first mod isn't so big that I have to restart the game (yet) π
it reminds me I saw in passing a modification to zomboid startup script that enables debug launching by launching the game holding shift
In the case you'll need it here is the link to the auto launcher script: https://github.com/ssjshields/pz-crash-auto-launcher
Is there an event for equipping items? Or is that the only way to run user-code ? From Wiki I see only two events, OnEquipPrimary and OnEquipSecondary
Is there a list of all events / callbacks on https://zomboid-javadoc.com/41.65/ ?
Javadoc Project Zomboid Modding API package index
At least for clothes I define them in the script located in the Client folder, for the weapons instead I define them directly in a lua file in the shared folder
Sample:
for i , item in pairs(clothes) do
clothes = inv:AddItem(item);
pl:setWornItem(clothes:getBodyLocation(), clothes);```
You should use ``` code ``` for that
For the weapons instead as said I place them in a lua file in the " Shared " folder ( or rather as per normal )
Sample:
["Base.M723"] = 1, -- RIFLE
["Base.556Clip"] = 7, -- RIFLE CLIPS
["Base.556Box"] = 16, -- RIFLE AMMO BOXES
["Base.Sight_Aimpoint"] = 1, -- RIFLE PARTS```
It's backtick, not single quote, ` not '
Yep but it's pita to use because on the ITA keyboard there isn't it ( I hope you'll get it somehow )
It should exist on any keyboard
Unfortunately on ours there isn't... ( Like some others symbols like for example ~ )
That's the pain of the ITA keyboard layout. If I want them I have to switch to ENG language but then the keys don't match the keyboard ones, unfortunately
If you are on Windows, you should be able to type in the hex code for it
Either that or just copy and paste it from the character map application
Yep but I have to remember them every time that's not exactly handy to be used...
The code is U+0060
Thanks, I've made already a notepad file with all the special symbols written so I have only to copy/paste them when needed π ( At least when I'm not too lazy to do it LOOL π )
if you find that more useful https://www.reddit.com/r/LearnUselessTalents/comments/4eyvqi/making_Κ_without_copypasting_alt_codes/
26 votes and 12 comments so far on Reddit
Life saving registry key LOOL π
So I need some advice. I am making an anime body pillow mod and each pillow has a different image on both sides. Now you can use it as a weapon but the main detail is it is meant to be a bit of a decorative item. I want to make it so that when you place it in the world you can choose which side is being showed. As of right now I can only think of one way to do so and that is by adding a recipe to transform it into and entirely different item that is just the same thing but flipped. Do you think this is worth it or should I just make it 1 sides?
On Linux, I just do Ctrl+Shift+u, then 0060
I really wish there was a way a way to rotate it when placing
that the only way I think
@sharp wind I'm on the Windows shit here LOOL π
You can add context menu item for the pillow item to allow flipping the side
How would I do this?
Ah, you'll have to blunder through code
@hot patrol Do you think this is worth it or should I just make it 1 sides?
IMHO That's the best option
Keep it simple π
yea I'm thinking so as well but man am I a sucker for detail
lol
you'll have to look at example code in the game
for things like watches
to see how to add a context menu
@hot patrol If it's not complicated there's no fun in scripting LOOL π
you mean for swapping wrists?
so I would image you can do the same for the pillow
maybe
right click on the pillow, which is placed in the world, to transform
either while in world or in the inventory
the thing I was thinking of would require me to add the same item as an entirely new one and make a craft recipe to flip it
too much coding for that tho imo
both of that have examples, you have a wrist watch, and a clock (the one with the two big bells)
If you want to auto randomise it you can even use a Events.OnTick ( So to have it flipping after a certain amount of time )
I will see if I can find an example
nah I don't need any ghost pillows rotating on their own

man everytime I say I am done working on this think I think of more work
There's already simple examples
@hot patrol On the 20th of January I've started writing a script with the same thing in mind...Still working on it right now LOOL π
you'll need ISInventoryPaneContextMenu.createMenu
you know which file has that so I can see it an try to copy it to work for me? That little bit doesn't help someone like me with no real coding knowledge
I was saying in here a while back we need an advanced world placement mod for stuff like this.
being able to hang stuff on walls and such
You can already hang stuffs on walls...
there's another mod that added a context menu that I know of is "They Knew"
ISInventoryPaneContextMenu.lua
If it's in the game, you need simply to find the script/lua that generates it and then modifying it accordingly...
As reference take a look at the code of this mod ( give me a sec for the link )
Just found that and am skiming it now. Will check out that mod as well. thanks!
true but I meant for most every item. Right now if you want to place something you can only rotate it. I would love if you could do a little more like maybe rotate the other axis so that you can place certain items like cans so they look like they were knocked on their side
or stand guns against the wall
feasible probably but that means that you have to play with the script/code/game coordinates
yea, figures. I wouldn't even know where to begin but if that was available in the game by default it would certainly fix my pillow problem 
In game we can rotate any item on the X coord, that probably means that also the Y ones are available somewhere. If I would be you I would start looking into Media--> lua files...
( Just guessing)
I'll look at that two because that would be a lot more elegant than a context menu option anyways
It doesn't help to rotate in this case
unless the item you placed down is a 3D object
I guess you 3D model the pillow?
If not you can grab the 3D model of the pillow directly from the game
In game the command to rotate a 3d object on the X coords is:
rolls =
I'm pretty sure that around there's also the command to rotate them on the Y coord...then finding it, it's another story LOOL π
maybe
flips=
?
Now that I think about it I would also need to assign a key bind to the action, no?
normally i see that when you place down a weapon, it prefers one side
so rotating it won't do you any good
unless you can place it down on the "edge"
then rotating it would work
exactly my issue. I can rotate it left and right but I want to be able to rotate the bottom to the top
but then it would need to be a furniture type
not sure furnitures are 3D objects
they look like sprite to me
if the can is a 3D object ( it's placed vertically in game ) you can use it as reference...Somehow also vertical ones show only the same side but better than nothing no?
This is my item there is an image on the opposite side as well and I want to flip it the same way you can rotate 3d objects like guns
that is what I am talking about
you can rotate left and rigth on on the x axis but not on the y.
so either I add a context menu optiuon as Mice suggested to just flip the item or I find out if it is possible to make the Y axis also adjustable
can you write you actual X coords command used in your script? Wanna try a thing....
attachment world
{
offset = 0.0000 -0.3620 0.0000,
rotate = 0.0000 90.0000 0.0000,
}
do you have some local params in your script ( Send me via PM the script so I can see it if you don't want to post it publicly )
Hey idk if anyone is free to maybe just dm me some advice but the last week or so I've been wanting to learn the basics of modding and no one has really given me any advice. I want to make a profession mod and maybe two or so items
Didn't try but also found this function:
getCore():ResetLua("default", "modsChanged")
in the lua actions there is no event triggering when an item is equipped or unequipped, so yeah hooking into it is a way of triggering your own event
Ok guys i try the whole day to make a function in a mod item work, which should reduce Cold/Flu if the character has a ColdProgressionRate higher than 0, but i keep constatly getting an error.
return false
end
if Survivor:getColdProgressionRate() > 0 then
Survivor:setColdStrength(0)
end
if Survivor:getPainReduction() < 35 then
Survivor:setPainReduction(35)
end
end```
The getPainReduction is the code from the author of the mod which i try to suit for my needs - and it does work without problems.
@sharp wind
All timed action derive from ISBaseTimedAction class
Could hook the base action method to trigger an event.
local ISBaseTimedAction_start = ISBaseTimedAction.start;
function ISBaseTimedAction:start(...)
ISBaseTimedAction_start(self, ...);
triggerEvent("OnAction_" .. self.Type .. "_Start", self);
end
And then hook into any action this way:
local function OnAction_ISAddFuel_Start(action)
-- do something after ISAddFuel:Start() executed
end
Events["OnAction_ISAddFuel_Start"].Add(OnAction_ISAddFuel_Start);
When im adding my lines (the getColdProgressionRate and setColdStrength are defined in the same way as the author defined getPainReduction) the code doesnt work and it spits the error:
With line #9 being :
if Survivor:getColdProgressionRate() > 0 then
If i add the same function like this though it does work, but it works constantly adding the value -20 per tick to the cold/flu level, which results then in something like -233.23992 cold/flu value. if Survivor:getPainReduction() < 35 then Survivor:setPainReduction(35) Survivor:setColdStrength(-20.0) end end
I see, so making your own event callback
@sharp wind Yeah i could see this kind of basic event added into the source code but for now that could be done. Might want to use a prefix in that event name in case other people use the same concept
Honestly I've been considering making a library mod for more events and data-driven menus and systems, a ton of stuff is hardcoded and requires invasive rewrites meaning people will be super incompatible doing the same things
Like the good approach to that would be to add an event to the action for equipping/unequipping items
But having a lot of mods overriding files leads to problems with compatibility down the line, so a library would be better
@thin hornet do you know if it is possible to make a script that allows you to rotate placed items on the y axis along with the x? Me and @lusty nebula are trying to figure it out for my anime mod
My pillows are 2 sided and I want to be able to dispay either side
it seem that we can only rotate on the z axis
inventory\InventoryItem.java
public void setWorldZRotation(int var1) {
this.worldZRotation = var1;
}
An approach could be to give items a fake list of world items which could have different models (and thus different model offsets/rotations, such as a can on its side or the flipped pillow), and which you cycle through using a hotkey?
Which is basically just a shiny version of adding a "flip pillow" context menu action to the item, really
that is somewhat what I was initially thinking but adding an entirely new item to the code seems like a lot of nonesense just to flip it over. I was thinking it was just better to make then just 1 sided
It's definitely a lot of messing around, yeah
I mean my mod is already going to have a lot of the same item just for different image prints
but it is a good idea
I wonder if you could automatically generate the flipped variants using ItemTweaker or something similar?
now that would be perfect. Realistically it shouldn't need to be a new item.
just swap the rotation values
Actually I doubt you can define new items like the scripts from lua, but I'd have to research it
DoParam would only edit existing item, it cannot edit models or other stuff like recipe tho
not sure what that means but I would have made it a recipe. so you right click the pillow and "craft" it into the flipped varient
that is what I was gona do originally
mind you I can't code so it's the best I could think of
there is ScriptManager.ParseScript(string) but no idea if that's exposed to lua or what would happen if we were to generate new items via it after scripts are actually loaded
or if it even works like that, I guess
ParseScript only do the parsing job
the actual part that add parsed item is
public ArrayList getAllItems() {
we do not have access to add to this variable this.itemTempList.add(var4);
Ah, neat
Little disappointing that DoParam is defined on Item instead of BaseScriptObject, looking at the javadoc
It works for script items
local item = ScriptManager.instance:getItem("Base.Hat_Army")
if item then
item:DoParam("BulletDefense = 100")
end
all this is going right over my head
Also i think DoParam must be done in OnGameBoot to properly work
Can't wait to have flipping objects on the Y axis so we can finally cook homelettes too LOOL π
It can be done at any time and work, although it won't change every parameter of items that are already instanced.
It should be run in shared or server directories however.
public Item getScriptItem() {
return this.ScriptItem;
}
public void setScriptItem(Item var1) {
this.ScriptItem = var1;
}
we do have the method to change the script item tho
Maybe we can have different angled items and just change the current item ScriptItem
soo.. that can help me?
-- just a pseudo code to show the idea
local horizontalItemScript = getScriptManager():getItem("Base.HorizontalItem");
local verticalItemScript = getScriptManager():getItem("Base.VerticalItem");
local myItem = theItem; -- InventoryItem
if key == "UP" then
myItem:setScriptItem( verticalItemScript );
else
myItem:setScriptItem( horizontalItemScript );
end
Alternatively, could I use context menu to equip the item? Reason is I want to track the item so that when they equip it, I can record the player and the item to run code
What is your item?
A neckwear
mhm
once worn, I track the item and the wetness
You can wear it normally and you add an new option wear with soaking?
Normal wear would be normal, no change, but if you soak it first, it will run code
so can you explain how this would work to me? Would this require me to make 2 versions of the item or does this take the base item and change the values?
Then yeah just make a OnFillInventoryObjectContextMenu and add your option if the selected item is that one.
I didnt test changing the script item, so i have no idea what it would do
ah.
if you do test it can you check back? I'm don't know how to do it myself so i'm lost on that one.
What you want is to place the item on the ground right
but want to have different angle other than the only one
yea. I want this but the pillow flipped on the other side to show the other image.
that happen to be set into server\BuildingObjects\ISPlace3DItemCursor.lua
I want to be able to hot swap it. I know I could just make all the pillows 1 sided and save trouble but this would cut down on items I need to add if I can make it 2 images a model plus it is more realistic since dakimakuras are like that
Now from there gotta look what we can do
we still cannot change its rotation but maybe we can detect your item and add a key to switch it for a different one that would be the "other side"
that would work
Hello there. Just a question: HOW to extract the bank-files of ZomboidSound.bank and ZomboidSound.strings.bank?
I like that and I guess if you hit a key like alt+r it would flip it?
the Fmod Bank Tools can't extract it. (throws errors)
not as elegant as proper rotation but it serves the purpse perfectly
You could just use a recipe as well
recipe Flip Pillow
{
Pillow1,
Result:Pillow2,
Time:1,
}
would be less of a headache
This what I was going to do originally but I would need to make pillow 2 an entirely new item. Easier but a lot more work considering I am going to already have like 50 different pillows in game
Has nobody any idea how to extract ZomboidSound.bank ? :/
all pillow use same model right?
yeah i recall
for the rotation or for different textures. I know for textures I do
would your script for flipping it also require another item made for it?
it's what brita does for their guns
well the rotation would be a recipe that switch between the regular and the reversed item
... i'm very annoyed ... the ZomboidSound.bank file can't be extracted. HOW i can replace the zombie sounds through mod? ... -.-
yea but I would still need to make a different item for it. That is 2 items per pillow for however many pillows I add. A lot of bloat there
it should be Fmod Bank Tools maybe check for a latest version on TIS forum
where i can find "TIS"-Forum?
already worked on them ... but he throws errors by this bank files.
thats why i'm here
did you say this would also require having 2 versions of the same item? I got a bit confused. If you then yea I will either do as @willow estuary said or just make the pillows 1 sided.
0.0.1.4 = Newest version i can found anywhere ... and thats not working ...
Editing ISPlace3DItemCursor would still require duplicating your items
there is no way around this
ok so yea the crafting method is easier to go with
the game engine is not offering the possibility
sucks but gotta work with what you got I guess.
yep
thanks anyways.
ok. fixed ... the ZomboidSound.bank-File takes VERY MUCH TIME to start extracting ... regardless of errors ... what?
stupid question but I hate how rotation items in zomboid works so someone help a brother out here. If the roation for this item here is rotate = 0.0000 90.0000 0.0000, what do I change it to for it to be completely flipped on it's other side.
the z one ofc
assuming that's in degrees
and you are looking at rotating around x,y,z
but try 90 for each
and see how they rotate
I pressume it's 0,0,90
but could be 0,0,180
I think what you are saying would put the backside upside down. I think I want to change the middle value.
like I said, try 90 for each
ok will do.
If 0,90,0 is what's in the image, changing the middle value might just make it spin
ok I'll try that
So made this little piece of code not sure if that is useful to anyone or if it can be improved.
But that should allow to bind to any action start,stop,perform beforepre or afterpost its execution.
File: media/lua/client/ActionEvents/ActionEvents.lua
require 'TimedActions/ISBaseTimedAction';
local definedEvents = {};
LuaEventManager.AddEvent("OnActionStarted");
LuaEventManager.AddEvent("OnActionStopped");
LuaEventManager.AddEvent("OnActionPerformed");
local function triggerActionCustomEvent(action, method)
local eventName = "On_" .. action.Type .. "_" .. method;
if not definedEvents[eventName] then
LuaEventManager.AddEvent(eventName);
definedEvents[eventName] = true;
end
triggerEvent(eventName, action);
end
local ISBaseTimedAction_start = ISBaseTimedAction.start;
function ISBaseTimedAction:start(...)
triggerActionCustomEvent(self, "PreStart");
ISBaseTimedAction_start(self, ...);
triggerActionCustomEvent(self, "PostStart");
triggerEvent("OnActionStarted", self.Type, self);
end
local ISBaseTimedAction_stop = ISBaseTimedAction.stop;
function ISBaseTimedAction:stop(...)
triggerActionCustomEvent(self, "PreStop");
ISBaseTimedAction_stop(self, ...);
triggerActionCustomEvent(self, "PostStop");
triggerEvent("OnActionStopped", self.Type, self);
end
local ISBaseTimedAction_perform = ISBaseTimedAction.perform;
function ISBaseTimedAction:perform(...)
triggerActionCustomEvent(self, "PrePerform");
ISBaseTimedAction_perform(self, ...);
triggerActionCustomEvent(self, "PostPerform");
triggerEvent("OnActionPerformed", self.Type, self);
end
Usage Example:
require("ActionEvents/ActionEvents"); -- Require first
local function OnActionStarted(actionName, actionInstance) -- action param is equal to the actual action self
print("Action " .. actionName .. " has started");
end
Events.OnActionStarted.Add(OnActionStarted);
local function On_ISTakeFuel_PreStart(actionInstance) -- action param is equal to the actual action self
actionInstance.character:AddItem("Base.PetrolCan");
end
Events.On_ISTakeFuel_PreStart.Add(On_ISTakeFuel_PreStart);
looks useful
Of course its not the same as hooking directly as you cannot overwrite the process and change it directly. But it serve as an event emitter for action start,stop or performed and still give a direct reference to the action self.
Which is useful
as I imagine you can get the player doing the action
which is half the battle
to stick code onto the event
yep i just updated to have a more global trigger too
well yeah you have access to anything the action instance has.
without having to run things OnTick, OnHour, or OnTenMinutes, or whatever
Ok ... and now? ...
hello guys i have a question. how can I play the original knox county map in nomral singleplayer
without the zombie waves of the you have 1 day challenge.Is it a mod?
actually this is flawed
cannot add event if its not declared first
i dont see how that could be done without making a list of all the possible actions
Truly hellish solution: override shared/ISBaseTimedAction.lua to hook into ISBaseTimedAction:derive and register events
anyone here could help me out with a mod called SimpleShop (Project Capitalism) ?
right now the mod allows you to buy stuff while a radio is inside your inventory but I would simply like
this to be able to check if the player is standing next to a HAM radio instead, not inside the inventory.
Creating a reason for players to come to the trading hub where there is a HAM radio present.
That feeling when you were making a mod and wokeup to realize someone made it as well
I was making a turret mod!
could actually work yeah mhm will try
How would I go about removing an element from a combo box? I see AddOptionWithData, is there something that can remove a given option?
editing the Fashion Montage lua btw.
sounds tough because fashion montage not work
I think (but not sure), but you gonna have to add this line inside the recipies:
CanBeDoneFromFloor:true
and replace all the instances of "keep" by:
keep HamRadio1/HamRadio2
if you only want the HamRadio
whats the mod that adds the gas tank truck
Hey, could someone take maybe a quick look and tell me if this has a bad syntax or something which is the reason the debugger shoots out the error "__le not defined for operand"? Appreciate any help. ``` end
if (Survivor:getColdStrength() >= 20.0) then
setColdStrength(getColdStrength() - 20.0)
end```
You're certain that's the line that's triggering the error? I'm asking because __le refers to the "less than or equal to" operator, <=, but that's >=
It's likely using le as in 20.0 <= x rather than explicitly defining greater than
Try printing the value of Survivor:getColdStrength() and making sure it's what you expect
You're totally right, Lua doesn't even have metamethods for greater than & greater than/equal to π forgot about that
getColdStrength supposedly returns a float, though, which should be fine. If it were nil the error would've said that instead
shouldn't it be
if (Survivor:getColdStrength() >= 20.0) then
setColdStrength(**Survivor:**getColdStrength() - 20.0)
end
Actually missing it before setColdStrength too
Thanks for the response guys. I've tried both fixes and they throw the same error.
I've did print out the function and here is the result:
While those are the cold/flu settings for debbuging:
That's a type compatibility error because it's comparing to nil, no?
You're building on Immersive Medicine and implementing Survivor:getColdStrength() in their file, right? What does your function look like?
does the game actually run on java?
because i have a few ideas
or its just the server
The game's core is built in Java, but the modding system is in Lua
I believe you can pass them to the executable, but I'm not sure what actual Java version it is or how to run the jars directly, so something like changing garbage collectors may or may not work
I haven't experienced anything that looks like GC hitching in PZ, though
That is totally right. I try to suit it a little to my needs and i had some success (at least with the blood loss function), but while im trying to add this cold/flu reducing function to one of the iMed drugs, defining the function the same like the author did the getPainReduction in the same drug, but without success. The whole function looks at this moment like this: ```local normalEffect = function()
if not Survivor:isInitialized() or Survivor:getBlood():getDrugs()[Alkagin.alias] == nil then
return false
end
if not Survivor:getBlood():getDrugs()[Alkagin.alias].isActive then
return false
end
if (Survivor:getColdStrength() >= 20.0) then
Survivor:setColdStrength(Survivor:getColdStrength() - 20.0)
end
end
local overdoseEffect = function()
if not Survivor:isInitialized() or Survivor:getBlood():getDrugs()[Alkagin.alias] == nil then
return false
end
if not Survivor:getBlood():getDrugs()[Alkagin.alias].isOverdose then
return false
end
if not Survivor:getBlood():getDrugs()[Alkagin.alias].isOverdoseEffectApplied then
if Survivor:getFoodSicknessLevel() < 80 then
Survivor:setFoodSicknessLevel(80)
end
Survivor:getBlood():getDrugs()[Alkagin.alias].isOverdoseEffectApplied = true
end
end
Events.OnTick.Add(normalEffect)
Events.OnTick.Add(overdoseEffect)```
while the original normalEffect function does look like this:
if not Survivor:isInitialized() or Survivor:getBlood():getDrugs()[Alkagin.alias] == nil then
return false
end
if not Survivor:getBlood():getDrugs()[Alkagin.alias].isActive then
return false
end
if Survivor:getPainReduction() < 35 then
Survivor:setPainReduction(35)
end
end```
me either, apparently big deal in minecraft
Ah, so if you haven't modified uhhhHHH media/lua/client/Component/Survivor/Entity/Survivor.lua to add the getColdStrength() function, while it is part of the base game's systems that the Survivor object is built on, it doesn't have that method. So you'll have to add it yourself, along with the other cold-related functionality:
function Survivor:getColdStrength()
return getSpecificPlayer(0):getBodyDamage():getColdStrength()
end
function Survivor:setColdStrength(strength)
getSpecificPlayer(0):getBodyDamage():setColdStrength(strength)
end
function Survivor:getColdProgressionRate()
return getSpecificPlayer(0):getBodyDamage():getColdProgressionRate()
end
function Survivor:setColdProgressionRate(rate)
getSpecificPlayer(0):getBodyDamage():setColdProgressionRate(rate)
end
anyone know how to set server options
with lua
if isServer() then
MinutesPerPage = 0.1
end
is this enough?
Well, the issue is I did modify the Survivor class and did add the getColdStrength function - that's the weird thing: ```function Survivor:setColdProgressionRate(value)
getSpecificPlayer(0):getBodyDamage():setColdProgressionRate(value)
end
function Survivor:getColdStrength()
getSpecificPlayer(0):getBodyDamage():getColdStrength()
end
function Survivor:setColdStrength(value)
getSpecificPlayer(0):getBodyDamage():setColdStrength(value)
end```
ah it was what I thought! You just forgot the return for the getColdStrength
I have done this many times in the last few days
I am very sorry if this is a trivial question @rare sleet , but I am rather a noob in programming and Java - could u tell me how i should implement the return for the function correctly?
function Survivor:getColdStrength()
return getSpecificPlayer(0):getBodyDamage():getColdStrength()
end
Basically to make a function output some value, you've gotta return the value you want, so you use a return statement for that. Without that, the function always returns nothing
Ah, no implicit returns in Lua
Unfortunately I've gotta head off so I hope this has fixed the issue and it works π good luck!
you can do calculations in between
but what actually gives the function its value is
return value
if you do alot of code in between
but in the end its return 0
then Surviver:getColdStrength() will only give 0
i see you are trying to set cold strength
Thank You very much @rare sleet - everything is working fine with your fix!!! I really appreciate the time and help π
Howdy @drifting ore, your guide on UI handling is pretty helpful. However, in your full example you seem to have duplicate definitions for MyUI:new-- one of new(x, y, width, height) signature, and one of simply new() signature. Is that intended for some non-obvious reason?
Yeah i just figured it out thanks to clocklers advice
functions must return yeah
Anyone have any info on how getSpecificPlayer interacts with network reproduction? I'm going to assume if you're passing (0) that it's just the player in clientside code, but I'm not sure on that (or how it relates to code that runs on the server, or if you'd have to fetch the player object through other means for shared/serverside code).
yeah now i see that function Survivor:getPainReduction() return getSpecificPlayer(0):getBodyDamage():getPainReduction() does return a value too. One small detail did cost me nearly a day of digging through this - thats fascinating and frustrating at one time...
because this
getSpecificPlayer(0):getBodyDamage():getPainReduction()
is also a function
that's not always true, is it? for instance if I have
x = 0
function doThing()
x = 1
end
doThing()
print(x)
then you'd get a result of 1, right?
You're correct, but that's a different case of assigning to a variable outside the function scope
To get a return value from a function, you must call return within it
just making sure I was getting that right, my lua is pretty rusty and I forget exactly how variable scope works
something something local and everything else is global iirc but it's been a while
Hey guys still new to modding, just would like to ask how do I code an item for me to be able to place it? I did a mod wherein the radio is used to craft but now I can't place the radio because it's considered as an "item"
does it really give me 1?
i thought that'd get a result of nil
as far as I understand you only need to return a value if you're actually setting something to the function itself
ah.
i.e. x = yourFunction() would need a return value
pretty sure x in that context is a global variable, so doThing can just modify it without needing to return a calculated value
You could, you'd just need to rewrite your function to handle that usage. At least for this example of printing a variable value
even if it was local, it should still work - the function is contained within the same scope
but yes, if it was local inside the function that's different
(at least, I believe that's how that'd work out)
am getting an error on line 7
expected function near 'local'
i mean do I really have to do numPages = 0?
originally it didnt need to be like that?
or a typo elsewhere
im confused
Doesn't that stack trace say the error is in clothes.lua rather than the file you're showing?
ain't no thang
am concerned tho
people commenting on my mod
that it doesnt work in mp
and that it used to before
I can see how that would be concerning.
old code i posted which is just a copy-paste of original game code with minor edits here
konijima said i had to use a throwaway to replace game code
i think that worked i guess?
Do you know if there is a way to know the starting configuration of a save ?:
- which playstyle is currently played ? (apocalypse, builder, a challenge (which one)
- the traits and occupation set at the beginning
- the character config
I would like to add a button when the player die to quickly do a restart (new save) with exactly the same config.
And also eventually delete the old save
sort of like minecraft hardcore
You can prolly save it on char creation. If not then load traits and sandbox settings and save that
But I think the problem there is if it's a new save then the mod won't know the data? Unless it's somehow saved to filesystem independent of the save
from my notes the file map_sand.bin in the save folder contains the world settings. (could be out of date) so you would want it to copy that
so
does somebody know if i can edit Serveroptions.ini
with a mod?
specifically
settings MinutesPerPage value
if mod is installed, server automatically sets
I can only find getServerOptions()
I dont see a setServerOptions in the documentation
I was just reading about the global ModData functions. Would those be suitable for your purpose?
I think you can set the properties once you have the serveroptions
MinutesPerPage is a setting in vanilla server
getServerOptions():set('sometjing')
Something like that
You have to check the code
ah
i think i got it
but what is the syntax
if isServer() then
getServerOptions():setFloat("MinutesPerPage")
end
getServerOptions():setFloat("MinutesPerPage") = 0.1
or is it
getServerOptions():setFloat("MinutesPerPage", 0.1)
It's a method so the latter most likely
or
getServerOptions():getFloat("MinutesPerPage"):setFloat(0.1)
looks like the most sense
getServerOptions():MinutesPerPage:setValue(0.1)
may work?
This doesn't really make sense sense cause getFloat would return a float and therefore not have a method to set
oh wait
But yes just look at the source to see how it is :)
the ServerOptions object that gets returned by getServerOptions() has a MinutesPerPage child, which has setValue()
so ye that should work
getServerOptions():MinutesPerPage:setFloat(ReadingIsAJokeOptions.dropdown1)
vanilla code is o.minutesPerPage = getServerOptions():getFloat("MinutesPerPage") or 1.0
so i just assume its a float
the object MinutesPerPage is an object of type DoubleConfigOption
at least, according to the documentation
who knows
that's for 40.43 i just realized, so maybe it's a float now
in 41.xx
getServerOptions().MinutesPerPage is the option object, you can use getServerOptions():getFloat("MinutesPerPage") to get the value according to the current javadoc, but to change the value you use getServerOptions().MinutesPerPage:setValue(float) I think. would have to test it
yeah i think that's correct
not sure whether to use . or : here
do I have to reference self?
. is to access a value, : is explicitly for calling functions as methods
ah
yeah i missed that when i posted it first as well, but period first then colon second for setValue()
in functions it calls self as parameter, i thought that was it
if you use someObject:someMethod() then self in that function will be the object before the :
also i doubt it'll matter, but setValue takes a double as an argument rather than a float, but i think it'll handle the type conflict for you automatically?
Yeah, Lua only has a "number" type I think? All the java number types like int, float, double should be translated to it automatically
ye
the only other issue i can think of is how early you'd need to set this value, because if the server reads the .ini file only once and then just rolls with it you're kinda fucked
but i'm going to assume it works similarly to SandboxOptions which can be set in-game by admins
I would assume that if you change it at runtime then most things will be getting it from the config as it needs it, rather than caching
but again, testing
yeah for sure
idk how to use the zomboid doc at all
to find what i want
like an event after server finishes load
i know Events.OnGameStart exists
but when i search it on site doesnt show up
@gilded hawk @hidden estuary It looks like this gets the profession in character creation MainScreen.instance.desc:getProfession()
For how I found it, I tell you to help you find things in future: There are the files CharacterCreationHeader.lua, CharacterCreationMain.lua, and CharacterCreationProfession.lua. One of them has somewhere where it stores the chosen profession. I looked in CharacterCreationProfession.lua, with a search for mentions of profession.
-- the profession list choice
self.listboxProf = CharacterCreationProfessionListBox:new(16, self.topOfLists, self.tableWidth, self.bottomOfLists - self.topOfLists);
```This looks like it is it. `self.listboxProf:setOnMouseDownFunction(self, CharacterCreationProfession.onSelectProf);` looks like a function that happens when you click on it. The function says `self.profession` in it. So a search for mentions of `.profession` gets `desc:setProfession(self.profession:getType());`. There is a `setProfession`, maybe there could also be a `getProfession`. A search for `getProfession` got the answer.
if isServer() then
Events.OnServerStarted.Add(function()
local serverjoke
if
ReadingIsAJokeOptions.dropdown1 == 1 then
serverjoke = 2.0
elseif
ReadingIsAJokeOptions.dropdown1 == 2 then
serverjoke = 1.0
elseif
ReadingIsAJokeOptions.dropdown1 == 3 then
serverjoke = 0.1
elseif
ReadingIsAJokeOptions.dropdown1 == 4 then
serverjoke = 0.01
else
serverjoke = 0.1
end
getServerOptions().MinutesPerPage:setFloat(getfloat("serverjoke"))
end)
end```
now would this work perhaps
testing
you're still using setFloat instead of setValue, I don't think the type that MinutesPerPage is using has a setFloat method
and I'd just set it to serverjoke instead of getfloat("serverjoke") since setValue actually needs a double, not a float
if getdouble() is a thing then maybe that, but idk
I don't think you need to explicitly define type in this situation, but if you get type errors then obviously you'll need to figure something out
woops
getServerOptions().MinutesPerPage:setValue(serverjoke)
should work imo
console works with code right
so it should work if i paste it
getServerOptions().MinutesPerPage:setValue(0.1)
to test
without the serverjoke first
in theory, yeah. the only limitation i can think of is if getServerOptions isn't global and requries some sort of scope
but i don't think that's a thing
since it's a lua function
i'd try to get the value first though, and print it - then do setValue
just so you can actually see the changes in the console
getServerOptions():getFloat("MinutesPerPage") or 1.0 works fine
because its vanilla code
and its just getting the value
setting tho? i dont think its possible now
or maybe with this method
yeah you'd need to actually access the ServerOptions object, which is what getServerOptions() actually returns
so once you have the object itself, that's how you can use the properties (like <object>.MinutesPerPage)
ServerOptions by itself is a class
does zomboid have getClass()?
Javadoc Project Zomboid Modding API declaration: package: zombie.network, class: ServerOptions
you're getting an object of that class
This may work
getSandboxOptions():set("MinutesPerPage",serverjoke)
-- or
getServerOptions():set("MinutesPerPage",serverjoke)
oh is it actually a sandbox option?
i think you're overcomplicating it when you could just do .MinutesPerPage:getValue() and .MinutesPerPage:setValue(x)
nah, what blair posted is incorrect
it's in ServerOptions
print(getServerOptions().MinutesPerPage:getValue()
getServerOptions().MinutesPerPage:setValue(0.1)
print(getServerOptions().MinutesPerPage:getValue()
it takes 2x as much time to debug server
@next glacier if you run these lines one by one in the console, you should see it print the existing value, then you set the value, then you can print the value again to see if it changed
brb
so its 1
2nd line errors
java.lang.RuntimeException: attempted index: setValue of non-table: null
at se.krka.kahlua.vm.KahluaThread.tableget(KahluaThread.java:1689)
at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:641)
at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:163)
at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1980)
at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1782)
at se.krka.kahlua.integration.LuaCaller.pcall(LuaCaller.java:76)
at se.krka.kahlua.integration.LuaCaller.protectedCall(LuaCaller.java:117)
at zombie.ui.UIDebugConsole.ProcessCommand(UIDebugConsole.java:278)
at zombie.core.Core.updateKeyboardAux(Core.java:1953)
at zombie.core.Core.updateKeyboard(Core.java:2284)
at zombie.core.Core.DoFrameReady(Core.java:3046)
at zombie.GameWindow.frameStep(GameWindow.java:761)
at zombie.GameWindow.run_ez(GameWindow.java:661)
at zombie.GameWindow.mainThread(GameWindow.java:475)
at java.base/java.lang.Thread.run(Unknown Source)```
You don't have your statements formatted properly
print(getServerOptions().MinutesPerPage:getValue()) not print(getServerOptions().MinutesPerPage:getValue()
and
print(getServerOptions().MinutesPerPage:getValue()) not print(getServerOptions().MinutesPerPage:getValue()
yeah whoops, forgot to close those parentheses
hmm
(for my other mod)
so instead of item:getBloodLevel()
i can use item.BloodLevel instead?
It depends on the object, it might be able to be done that way, but you should favor using the functions where they exist
you might actually need : over . when dealing with lua functions that provide a java object rather than returning a table
so in this case, you might actually need getServerOptions():MinutesPerPage
but i'm not 100% sure on that
the first question is if its possible or not (if hard-coded or modifiable)
yeah all the functions/objects i listed are public, so it's 100% possible
although I can completely override the function to not use minutesperpage at all
the question of whether or not it's possible in the way you want is whether it can be set during runtime, which i'm still not sure about
just need to test in that regard using print
no idea, that's the part you need to use the console to test
getServerOptions():getFloat("MinutesPerPage") is the syntax for fetching the value
i mean in vanilla you cant right
getServerOptions():getOptionByName("MinutesPerPage"):setValue(value) would be the syntax for setting a value, but dont expect it to properly work during runtime (never tested, so cant comment)
An alternate approach with "easier" coding, do this for every book in items_literature.txt
local item = ScriptManager.instance:getItem("Base.BookTrapping1")
if item then
item:DoParam("NumberOfPages = 1")
end
btw whats the difference between
for j=0,coveredParts:size()-1 do
if self.noSoap == false then
self:useSoap(item, coveredParts:get(j));
for i=1,coveredParts:size() do
if self.noSoap == false then
self:useSoap(item, coveredParts:get(i-1));
Lua - for Loop, A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times.
cant find for j here
j is just a variable name; i is used normally for "iteration" but if you have multiple loops people just move forward to i, j, k and so on so they have different variables
Nop it was a error, fixed, thx.
Btw I'm making an API to make simple UI, it may interest you instead of doing everything
Btw
how do I get the number of items in an index
local coveredParts = BloodClothingType.getCoveredParts(item:getBloodClothingType())
for j=0, coveredParts:size()-1 do
local thisPart = coveredParts:get(j)
is it j
i=0 repeats until ends right
yeah cant seem to get only the BloodLevel in its table
its not the way
So anyone knows the difference between getActivatedMods and isMod? I mean in terms of what they do.
@weary matrix Hi, sorry to bother you, but can you look into the code of "sendObjectChange" method for isoObject class? It seems to be a way to transmit object data from server to client, but I can't figure out the input for this method. It could solve so many MP modding issues if we can figure this method out, thanks
You can see a bunch of usage of it in media/lua/server/ClientCommands.lua - looks like it's used with the first argument being an explicit string from a list of defined commands (such as adding experience to a player, setting a sink to use an external water source, or "state" for things like adding fuel to or lighting a barbecue)
Also media/lua/server/Vehicles/VehicleCommands.lua for ones relating to vehicles and mechanics
Does anyone know which parameter in the Arsenal (26) files is responsible for the rate of fire?
And what is the OAL?
Is there a function to check if an item can be equip ?
Hi guys is there a way to open a console to see if there are any errors
When I display my own prepared PNG images, they always look messy. Is there a solution to this problem?
errors are usually shown in the console.txt file. moreover, if you play in debug mode, you will see a small console-like box on your screen showing some technical information while in-game.
How do I open that file? What's debug mode? π
how do I make close-up high res screenshots of my characters?
wdym messy?\
ohh i see
make sure those pixels are 100% opaque
the console.txt can be found in your Zomboid folder. that is the same folder which contains the folder "mods" for example. don't know the exact location for you since it depends on the operating system (for ubuntu 20.04 it is /Home/Zomboid). to play in debug mode, go to your steam library, right click on Project Zomboid -> Properties -> General. in the Launch Options, simply add "-debug". the game will then always start in debug mode until you remove the -debug option.
Thank you very much. There may be a problem with the way I create my image files. I tried with another tool, and it was not perfect, but it was better.
np
Folks. I need some help with cloth rendering.
I'm making an exoskeleton mod.
The rendering works fine until I take off the clothes
wearing it
taking off the long sleeve shirt
the masks!
wait what? I'm new to this
there are masks applied to certain clothings.
they hide pats of the body for rendering purposes.
how do I set them?
taht i do not know... but the fact that her hands and chest are still there... tells me it's the masks
in your .xml your clothing is using masks .eg for example here is my astrosuit:
<m_MaleModel>skinned\clothes\AstroSuit</m_MaleModel> <m_FemaleModel>skinned\clothes\AstroSuit</m_FemaleModel> <m_GUID>ab725954-15f2-4767-96bd-aad4a37b228a</m_GUID> <m_Static>false</m_Static> <m_AllowRandomHue>false</m_AllowRandomHue> <m_AllowRandomTint>false</m_AllowRandomTint> <m_AttachBone></m_AttachBone> <m_Masks>14</m_Masks> <m_Masks>15</m_Masks> <m_Masks>3</m_Masks> <m_Masks>5</m_Masks> <m_Masks>7</m_Masks> <m_Masks>9</m_Masks> <textureChoices>clothes\AstroSuit</textureChoices> </clothingItem>
I would simply remove these and it would stop masking over those and stop them from vanishing
Your .xml that will need to be changed is located in clothing\clothingitems\clothingname.xml
It worked! thank you @drifting ore
I copied that file from the modding tutorial and you were right. There were a couple of masks enabled
masks basically make certain parts of the body disappear, e.g if i make a fat suit I would take most of the body part masks so I can make sure the body underneath vanishes
yep
@drifting ore is it necessary to assign the button (or other) child elements to a property on self for the panel, or is that just a convention? I am thinking of using a makeButton convenience function to simply wrap the generation and return the element for the self.addChild(element) call
Like so:
function ItemSearchPanel:create()
local function makeButton(x, y, width, height, title)
local id = string.upper(title);
local button = ISButton:new(x, y, width, height, title, self, ItemSearchPanel.onOptionMouseDown);
button.id = id;
button.initialise();
button.instantiate();
button.borderColor = self.buttonBorderColor;
self.addChild(button);
end
-- Add entry box for item input
local buttonHeight = SMALL_FONT + 2 * 4;
local buttonWidth = 75;
local padBottom = 10;
local itemEntry = ISTextEntryBox:new("Search for what item?", 25, 40, 150, buttonHeight);
itemEntry:initialise();
itemEntry:instantiate();
self.addChild(self.itemEntry);
local close = makeButton(self:getWidth() - buttonWidth - 5, self:getHeight() - padBottom - buttonHeight, buttonWidth, buttonHeight, "Close");
self:addChild(self.close);
local search = makeButton(5, self:getHeight() - padBottom - buttonHeight, buttonWidth, buttonHeight, "Search");
self:addChild(self.search);
end
tho I assume those locals probably can also be removed and the result fed straight into addChild
and if you need anymore help you just let me know alright
I will. Thank you again
This is really useful! What is mask 11 though? Can't seem to pick out what's hidden in that shot.
i have no idea ngl
haha at least I'm not the only one!
back?
oh good thought
I got one question about modding for MP. The basic idea is to send a msg to the server to sync state and validate some actions, right?
It depends on what you're doing. Some MP-capable mods only do client work, so they don't have to sync anything.
For example, If I want to set skill points, I must send a msg to the server so that it validates it, right?
Suppose I wanna mod "Sprinter's sneakers" that sets the player 10 on sprinting skill upon wearing it
does the setting information must pass to the server to validate it or I'm free to set it locally in the client?
right now I'm doing locally, but I'm not sure if that would work in MP
I don't know off-hand, but I'm sure someone here knows
No element don't need to be a variable of the UI, just call addChild is enough but I think that it's important to align stuff, change all the elements at once or something like that
There's a good chance that you want to get the element from the window itself for anything (like changing the text of a button after clicking an other one). For simple menu it is useless but for more complex it is important.
But you can just put every element in a table or different table by type of element, as you want
Ah I see, I'm liable to want the reference for other things. Got it, thank you!
I'm thinking of reviving the scp mod idea
However
Instead of scps already in the world
The player picks a trait and one scp will be chasing them
096, 106, and 1120
Each trait gives 12 points
I know 100% 096 and 1120 are possible
However
Idk about 106
How would I add custom zombies to pz? Something like soul's turning time
Your change notes entries are empty, it would be nice to see something in those
Can I add an event to an object ?
Something like that:
function ISSimpleUI:onCustomUIKeyPressed(key)
if self.key and key == self.key then
self:toggle();
end
end
Events.OnCustomUIKeyPressed.Add(ISSimpleUI.onCustomUIKeyPressed)
There really shouldn't be anything different between doing it that way and wiring up a non-class function
In either case (ref - https://github.com/TheCrimsonKing92/pz-item-searcher/blob/master/media/lua/client/ItemSearchPanel.lua#L79) you should have access to the function reference you need passed to the .Add call
Note, that's untested unrun code, but it's based on the example from Mr Bounty I've been following
I'm reading this guide here for setting up intelij for zomboid modding with the zomboid libraries, I'm wondering if theres one that shows how to decompile the game/ if there is one for use with vscode? https://github.com/Konijima/PZ-Libraries/blob/Tutorial/README.md
Thank you!
this example wont work. defining your function as
function ISSimpleUI:onCustomUIKeyPressed(key)
is the same as doing:
function ISSimpleUI.onCustomUIKeyPressed(self, key)
since the event is calling it in the second style (with . not :) and only passing one argument
the key getting pressed gets shoved into the self variable, the key variable remains nil
So that work ?
function ISSimpleUI.onCustomUIKeyPressed(self, key)
if self.key and key == self.key then
self:toggle();
end
end
Events.OnCustomUIKeyPressed.Add(ISSimpleUI.onCustomUIKeyPressed)
uh no
I found a better way, just curious here
thats the same thing
So there is no way to make something like that work ?
not like that. the event will always be blind to the specific instance of ISSimpleUI, it will never pass a proper self variable
ok thats what I thought, just wanted to be sure thanks
You can probably add an event via LuaEventManager.AddEvent & then trigger it via triggerEvent in the same class (or via the global triggerEvent which presumably just calls the one in the class)
That's how the vanilla code does it (in Lua)
Just realized I misunderstood what you were trying to do, disregard that. Came to ask a question though:
Are sounds replicated to the server & other clients automatically? If so, how do I make them not be?
And if they aren't, is the standard way to trigger via client/server commands, or is there a more ideal way? (I know I could just check existing mods to determine this, but I figure if anyone knows the answer off the top of their head they could let me know)
Anyone knows where the file that controls/lists the available face makeups is located?
you can try media/lua/client/ISUI/ISMakeUpUI.lua. This file seems to control the in game ui and usage of make up. otherwise, i am not sure if there are any special luas related to make up since make up is technically realized as clothing items afaik.
thanks mate π
Items are marked as makeup using a MakeUpType field on their item, & most (if not all; I only did a quick check) of them seem to be defined in scripts/clothing_others.txt*
I've mixed up the makeup items with the makeup "clothing"; the MakeUpType field isn't used, the DisplayCategory is
What I'm basically trying is to find that file to change some makeups names
In that case, all you need to do is change the translation
Also...good point...
I'm unsure about the exact process of overwriting translations, but I assume if you have the same translation string (that is, the same left side of the =) in your mod it'll overwrite it
You can call the needed file anytime ( via script/lua)
in that case, the lua i mentioned is probably not needed
Thanks all guys very much appreciated your help here! π
As reference in case it could be of help for others makeup names are located in C:\Program Files (x86)\Steam\steamapps\common\ProjectZomboid\media\lua\shared\Translate\EN
Always as reference: The file is very short so simply put it in your relavant mod folder ( Shared --> EN ) and make the necessary modifications, the mod then, when activated will overwrite them
FYI you only need to have, and should only have, your new/modified entries in a mod's translation files.
Anyone know how to have the giant wall of text that some servers like Project Apocalypse does when you login that you can write info and rules on?
does anyone have any idea how the attachment editor works. I'm trying to fix the way my model looks in the world and it is doing my head in
How can I address correct lua file (from other mod) via
require "PATH_TO_MOD/LUAFILE.lua"```
Which path should I use?
don't need the path to the mod, just the path to file (inside client/shared/server) and drop the .lua suffix. for example if the files path is media/lua/shared/SomeFolder/Somefile.lua then your require is just
require "SomeFolder/Somefile"
or
local somefile = require("SomeFolder/Somefile")
depending on the syntax required
Well, if I run the game with two mods (1st is core, and 2nd depends from 1st), everything that should I do is to mark dependency via mod.info and then use path as you described above?
yep
Is it somewhat easy to make modded chat bots for servers?
We would like to have a chat bot which uses the /quit command on your server two times a day for restarts
Can I use VS code to mod the game
Yes, this is what I use
if hypthetically i coded something how would i apply it to test it
there is a ton of lua code on VS code which one do i get
nvm
how do i add skills to a profession
acording to one tutorial this is all I have so far
HEMAProfession.luarequire'NPCs/MainCreationMethods';
require'NPCs/ProfessionClothing';
-- HEMAProfession.lua
require'NPCs/MainCreationMethods';
require'NPCs/ProfessionClothing';
local function initProfessions()
-- Java: Create a new profession.
local hema = ProfessionFactory.addProfession("hema", "HEMA", "Prof_rm_Cheater");
-- Java: Add a custom trait called Undesireable (no one likes cheaters ).
hema:addFreeTrait("Brave");
-- Java: Add the vanilla trait Nightowl.
hema:addFreeTrait("ThickSkinned");
end```
i might have copied and pasted rn ill fix it soonm
sorry nvm i found a better reasource
My clothing items seem to magivcally be borken for no reason that I can see. would anyone mind taking a look at if for me? I get 1 error at start and all the clothing items don't show their icon nor do they apear when worn. When I drop them on the ground all the models including myslef also vanish.
how do i find the names of icons in the game
how do you reference the names of the skills in the game anyway
idk
Hey, is there any way I could commission a mod?
what type of mod?
for carpentry for example, you can use this: hema:addXPBoost(Perks.Woodwork, 1) and similar for other skills.
also, speaking of mods...
how on earth does one force a zombie to update its rendering?
like.. I got code that dynamically replaces zombies wearing outfitA, with outfitB, yet...
they don't update their worn clothes until a world reboot
not sure but it might happen that the way you add the "free traits" could be a bit buggy. the vanilla game distinguishes in the trait definitions between free traits and selectable traits. in case you simply assign selectable traits as you do, it might happen that the player can remove them during the profession and trait customisation. but not sure about it. just mentioned it so you could have a look at the issue when play-testing.
the names for the skills can be found in lua/shared/NPCs/MainCreationMethods.lua for example.
java is generating numerous repetitive exceptions: "Caused by: java.lang.NullPointerException: Cannot invoke "zombie.core.skinnedmodel.visual.ItemVisual.getTint(zombie.core.skinnedmodel.population.ClothingItem)" because the return value of "zombie.inventory.InventoryItem.getVisual()" is null"
@hot patrol
Callframe at: Render3DItem
function: render -- file: ISPlace3DItemCursor.lua line # 146
function: DoTileBuilding -- file: ISBuildingObject.lua line # 172
@hot patrol It's hard to figure out exactly what's going on.
if you took a look at my mod do you think you could figure it out?
I can try
I would say it could be because I redid the UV map but I had updated the models afterwards and I was having the issue with one of them before that anyways
what issue?
the one I stated above about the models not showing up, no icon and having all models in the area vanish when I would drop the clothing
Evening all! I am having trouble with teleportation code, it is very wierd, I follow the same pattern as the teleportation from map but the character is not teleported like if something is preventing it. Maybe someone here could help me with that please? π
Here is the code ran at the end of a timed action :
if self.doTp == true then
print("Teleporting to " .. self.xValue .. "x - " .. self.yValue .. "y")
self.character:setX(self.xValue)
self.character:setY(self.yValue)
self.character:setZ(0.0)
self.character:setLx(self.xValue)
self.character:setLy(self.yValue)
end
And here are the print from console, 1. is the print from the teleportation and 2. is the print from the current coordinates of the player after teleport (or actuelly, after not being teleported). Am I missing something obvious here?
(teleportation is trigerred at the end of each timed action)
Weirdly, it centers the character to the nearest square instead of teleporting it away π€
Are you accounting for the difference between world coordinates and local coordinates?
I am not sure what it means? But in any case it should move my character away even if not to the coordinates I would like isn't it?
The character is in Muldraugh and I am giving it Louisville coordinates.
There it just refuse to teleport and get centered on the nearest square. But I am willing to try this world coordinates thing to see if it changes anything!
A radio mod, I donβt think itd be super complex I just want a custom extension to the existing radio channels to match some βloreβ I had for a server of mine
that's an incredibly vague question
Ok should have specified, sorry.
How would I make custom zombie types like those of turning time or EHE: super weird edition?
Have you tried looking at the code for those mods?
^
Yes but I don't wanna directly copy their code
Just look at the methods they use and then reproduce them.
Don't wanna make shark feel hatred towards me, not that he already doesn't...
From my experience, you won't be liable to find enough information without looking at working examples. There simply isn't enough existing, complete, documentation.
yup
true
speaking of documentation. are you guys using cocolabs/pz-zmod project at this date and age?
trying to get at least some code completion running in lua, but so far only endless gradle tasks
Have you tried making it work with just EmmyLua first? https://github.com/Konijima/PZ-Libraries/blob/Tutorial/README.md
hmm, i'm using emmylua, though maybe not in the right way. that seems to be another guide i've missed. thanks.
hi, how can i make a mod modifying the human characters in pz? i already have the models and they work in game but idk how to make a mod with them.
just to be clear. if i see this, that means autocomplete works as intended?
So I tested that flip pillow method we talked about yesterday and it doesn't seem to work. Changing the rotation seemingly does nothing even when I do it in the attachment editor in game
soooo... A new radio station?
any coders in here know How I could go about adding a feature to flip the texture on my pillow wepon to show the texture on the back?
I mean sure but like more along the lines of expanding the existing stations
oh, well. i seem to get the gist of it.
god damn you, prototype chain...
i suppose one could say life didn't prepare lua for inheritance
hmmm... Well uhhh... My DMs are open if you'd like to explain it further?
but yeahhhh... I've been metaphorically bashing my head against the rock that is forcing zombie visuals updates for a while...
Hi. I want to create a new item using ItemZed, but i can't seem to figure out how, exactly?
alright, i seem to have underestimated lua type system
almost feels like home now
This is what I've got so far and now I'm stuck. How do I give this thing the same stats as a scissor and modify them?
Hi all, does anyone know how the timestamps correspond to the day value? Timestamps for a channel seemingly continue to increase even as days tick up and I'm wondering if it's possibly a universal value. Or how it matches up to specific hours. Googling hasn't produced many good results, but it's possible I'm not googling the right terms
What is IS short for?
infinite suffering
"Indie Stone"
I'm rethinking binding my custom UI to a certain key, since it looks like many are already bound, and I think I might want to use a solution like ModOptions to go down that route.
My new thought is to add a new entry to the right-click menu on the survivor which opens the menu. Am I correct that I would need to call Events.OnFillWorldObjectContextMenu to add this new entry (via a new function), or is that not the right place?
Nice model!
