#mod_development
1 messages ยท Page 241 of 1
also true XD but they are still there shown in the interface at least
All the infection stuff would be easy enough because it's already there. As a total newb i would guess you just need to script checks for wet condition, then add that status to a be tracked for duration and after x time apply condition. But then you need to tell the game to do something about it? So maybe you need to make a wet-infection condition of your own that you can then link to walking speed and pain levels? Sounds like work
It'd be cool if they added blisters to the game as an injury type ๐ค
I did not know that ๐ so no need to disinfect?
iirc they make the wound heal a lot slower
but without a wound i don't think they do anything at all, they don't make you sick or anything like some people might assume
there's similarly little reason to clean bandages
all dirty bandages do is increase the chance of infection, but because of a bug(?) a wound can't be infected more than once, and in my experience wounds usually get infected the first time pretty fast even if you try to avoid it
a lot of the medical system is just designed to look more significant than it is ๐
That's a shame. Hopefully they flesh it out a bit in a future update. The need to have good hygiene and clean clothes would be cool. Dental care and such. Imagine having to extract a tooth ๐ง
a wire and a door ๐
๐ฌ tooth infections would be a bitch to deal with.
@thick karma sorry for another ping. Would you happen to know how importing or creation of character works for project zomboid? I am looking to import or create an animal into the game.
Wound infections should 100% give you sickness
I know its a mod already
But the medical system should be much more fleshed out
I need to find a server with high realism
Also How about a mod that makes you have to search through containers to find stuff? Say you have a crate and it's full. You'd only really be able to see what is on top, and would have to dig through to find anything else.
check this out then https://discord.com/channels/136501320340209664/1235971208265203794
looks cool, too bad i couldnt join them cause of my ping
inventory tetris has this as an optional thing and i think its a mod for vanilla looting too
is Lua the standard for PZ modding? I'm a scripting modder for BG3 and we basically only use Lua there, however when researching PZ I hear about using Java (like here https://github.com/cocolabs/pz-modding-guide), I wonder if that's even considered nowadays
nobody makes java mods
If people desire a mod that's done using Java, then they'll download it.
I do and have for over 10 years here. =)
Most mods don't require modding Java.
If you're doing core-related changes, you'll need to.
Just note that you'll be in a heavy minority and some discussions surrounding Java modding can be touchy depending on who you talk to.
could you give an example or broad categories?
- Modifying the Lua API to add functions not exposed by the Lua engine.
- Modifying or improving the render engine to provide more features or optimizations.
I touch and do both these things.
ok, *one guy makes java mods
no mo culling is in common usage, there's a couple more niche ones that have some popularity, but apart from that it's not really done, mostly because it's a hassle to install
and by hassle i mean 'takes a minimal amount of effort' but we are in the era of the steam workshop ๐
thanks, and the Lua API is official and exposed by the game itself?
Yup.
The only unofficial alternative to Lua is TypeScript and it is compiled to Lua in order to run.
@cobalt star Since you're familiar with Lua I'd imagine you knowing about the vscode extension lua the language-server for Lua.
If you use this, use Umbrella. https://github.com/asledgehammer/Umbrella
That should help you get familiar with the API when writing the code itself. For examples, I wouldn't know where to look.
that seems great, thanks! we have our helpers in BG3 too
@bronze yoke Manages the Event API while I manage the other API.
I'm assuming the https://pzwiki.net is the most comprehensive source of modding info
If you get bored and want to play with the experimental TypeScript environment: https://github.com/asledgehammer/PipeWrench-Template
One of them. It's the most official source. It's somewhat dated in areas so keep this in mind when searching.
The documentation in this game is verrrry lacking, if not missing altogether. Keep this in mind too.
(My current project is third-party documentation)
definitely would prefer TypeScript for more complex mods, can PW still be used?
This is the 41.77 official JavaDocs. https://projectzomboid.com/modding/index.html
package index
It's a little dated but runs afaik.
I use it for a React HTML project and it's been compiling and running in PZ.
If you need to reference that project's package.json, it's PipeWrench-UI on my organization.
I'll get back to it eventually.
Working on this for now:
:3
Maybe you can help me, then! The mod I want to make is so simple if I can edit the java, but I'm not sure how to make my edits override the vanilla code, and I'm not sure if it can be done via Lua (I think probably it can't).
I've been looking at APIs to see if anyone's already exposed what I need, but... I kinda doubt it.
The only way I can think to do it with Lua would be to intervene when the entire class is loaded, probably on loading into a game, and replace the entire class with a slightly tweaked one... but that'd definitely be pushing the limits of what I know how to do, and then some.
Depends. If it's a Lua class then yes? If not then no.
Is IsoClass
Java, and no.
I keep pushing this commons-like Java patch project but I haven't released anything publicly yet although it already has enough to release something for people to mess with.
Is Zomboid Storm?
?
But yes! A way to patch the java code is precisely what would let me do this.
Well, the mod I intend to make would tweak the formulas for how often you cut your feet walking barefoot outside.
There's a mod that attempted to just wholly disable that feature, but I don't really like that idea. I just want to tweak the devs' really bizarre underestimation of human feet, so you don't need four bandages to walk across a single manicured suburban lawn or down a pristine sidewalk.
All I'd need to do is change like... 9 lines in updateFootInjuries in IsoPlayer.
As a stretch goal, I'd expose some of the variables I'd be changing in a sandbox settings tab, like how harsh the two types of outdoor terrain are, how likely it is to get a scratch based on movement speed, and the base for the foot injury timer, so players can decide for themselves.
The existing mod that tries to just disable the entire system looks like it monitors constantly the call to check to see if the character is wearing shoes or not, and temporarily adds 100% scratch protection for that event, which is just... so blunt and inelegant. And also it's broken and doesn't work anymore anyway, and... I'm not sure it ever did, given the comments in its workshop page.
Would a mod made with your project need any special installation by users? Or could it just be a simple "click Subscribe" mod like most, @red tiger?
(Presumably with a dependency)
I have considered other ways of doing it, like periodically resetting footInjuryTimer, but that's much clunkier and less flexible.
Is it solely for personal use? (No pun intended)
Meaning for me myself? Or just not-multiplayer?
just for you.
I'd like to publish it... but am willing to consider not. I do already have a supporting mod published, though, and there is interest in the community.
Why, just thinking of having me recompile the game with the edits? xD
That's why I asked. You could do that yourself it seems.
Like you understand what to do.
To some extent...
What's holding you back?
Is decompiling, editing, and recompiling consistent enough to just work?
You'll need to recompile against the game's compiled class files.
If IsoPlayer has errors on decompilation then you'll need to fix those.
I'm not a professional... I've been a coding hobbyist all my life, starting with AppleBASIC on my parents Apple II-C, and I took some programming classes in college, so I'm not a novice, but this is still beyond anything I've done before, or at least in over two decades.
See I... know the general gist of what it means to recompile against the game's compiled class files, but I don't know how to actually do that.
Hmm ok
I take it what I want to do is pretty rough, in a publishable form?
Rough in that it requires clients to be modified to work. Not rough in procedure.
What about the idea of resetting the timer periodically? The period would give me at least a little control, especially if I can detect walking vs. running vs. sprinting purely in Lua.
If damage can be interpreted per instance in Lua then you could fling off a few of them based off of a percentage calculation to offset it.
I mean yeah, if I could just patch the class, it'd be super simple. But I'm aware that "just patch the class" is a big hurdle.
I'd argue that these sorts of events should be done in Lua to begin with.
I mean, most of them are. It's frustrating... almost any other injury in the game seems to be triggered in Lua. Just this one thing is hard-coded for some reason. It feels like maybe a very early decision made in an early version, that just never got updated to a new system as they progressed.
I wish that a lot of things were Lua-side. =/
I mean literally it would take me about two minutes to edit what I need to edit in the java.
Just edit these, and a few lines down, change 8500 in if (Rand.Next(Rand.AdjustForFramerate(8500 - this.footInjuryTimer)) <= 0) { to something higher (which is what I'd expose in mod options), and maybe reduce the scratch time it adds if that doesn't feel like enough.
Speaking of which... a lot of numbers have an F after them, like these... what does that do, just let it know it's a floating point?
Anyway... it sounds like it's kind of a no-go for publishing it without a patch system or some complicated shenanigans... is there an easy guide to follow for how to recompile just this class? Obviously I'd have to redo the changes after every game update, but those seem... <_< Less than frequent, here. *cough*
Looking to get a clothing/costume mod made. Would be a big onesie essentially but the hard part would be the art portion and creating the actual character we would like as a costume. I guess the closest thing it would be to is making a zombie skin replacer such as OccultZed
What is it you want the outfit to be?
Oh wait... I just realized, the game isn't mostly one giant archive file like I'm used to, it's in tons of small files... so can I just compile IsoPlayer.class?
I'm not sure I fully understand how this is working, though, as there's IsoPlayer but also IsoPlayer$1, $2, $InputState, $MoveVars, etc. InputState, MoveVars and such are categories in the decompiled code, but 1 and 2 are not, so does it just split it into two chunks for more granular editability? How do I know which one to replace? Or do I do the whole IsoPlayer.class? @red tiger
Is there a way to check if the player is crouched?
or to detect when the player crouches?
player:isSneaking() will return true then. However, there are a few things to note: it will always return true when the player presses the sneak button, also when the player is sitting or aiming. In those cases, the player is actually not in the sneaking animation but will automatically go to sneaking animation when sitting/aiming ends (in case player does not stop sneaking by pressing the sneak button again). Possible that there are other situations like that but I know for sure that this applies in the case of sitting and aiming.
In case you mean with crouching that the player is sneaking near a wall, you could try this instead:
player:isSneaking() and player:checkIsNearWall() >= 1
This is true when player sneaks near a wall and therefore goes into a take-cover position. My remarks from above concerning sitting/aiming also apply here.
Haven't you found a way to realize this by using lua only? Irrc, whenever player gets an injury, the game triggers the event OnClothingUpdate. Not 100% though but maybe worth a try. In case this applies, you could try to use this event. Only problem I see here is that whenever you get a foot injury and the event triggers, it is not obvious how to detect that the injury is due to walking without shoes and not due to a zombie or broken glass lying on ground assuming that in the latter cases, you probably won't change anything about the injury. I still speculate that it will be possible somehow...
Yeah, but I don't want the character's feet to be immune to zombie attacks, or scratches from walking through trees or stepping on glass. I want realism. And unfortunately, while most injuries happen in Lua, that one specific case happens purely in java.
The mod "Callused Feet" tries to do exactly that, with some pretty involved stuff, but the last patch broke it to the point that the game just disables it. I'm not convinced it worked before that patch, either, as there were varying reports of its reliability.
I see where the problem is...
But when using the lua event, couldn't you just check whether there are zombies near the player, glass or rough terrain is on the tile the player walks on and stuff? In case not, chances are good that the injury comes from walking without shoes alone and then you could try to remove the injury manually (or remove it with a certain chance). In case zombies are present for example, you could simply not change anything about injuries. Still possible that the injury is then in fact due to having no shoes and not from a zombie but it could still be an ok-ish approximation to what you'd like to achieve.
Just an idea though and not sure whether this is acceptable for your project...
EDIT: Ok... there are still complications. For example when there is more than one injury on the player's feet, things can still get messy I guess...
I've done simple java mods by just manually recompiling with the target version set to the one the game expects. Didn't need any dependency other than javac
javac --class-path "<PATH-TO-GAME-FOLDER>" -d .\out --release 17 -Xlint:none .\*.java. Something like this (I say "something" because it's adapted from a build script that puts the output where the build file is)
Note that this may not work for every file in the game since it assumes every dependency the file needs is in the class path specified. This should be true for most, though
You can't do it within the IDE? I'm using IntelliJ IDEA 2024.1.2
It's also saying the file is read-only... but within its own menu structure, it thinks it isn't (I can "make read-only" rather than "make editable")
Are you looking directly at a .class file, according to the IDE?
That is, I know it's decompiledโbut does it say .class?
Then my guess would be you're looking at something that's being decompiled on-the-fly. Just a guess though (I know IDEA can do it, no idea whether it's the case right now)
i.e., if you drag the file into notepad it wouldn't be what you're looking at there
Unfortunately I don't actually remember how I decompiled itโI think I used fernflower directlyโbut people here have recommended beautiful-java, which you can find with a search here. That likely decompiles it to a permanent file, as opposed to IDEA's temporary decompilation
In that case I'm back to ๐คท๐พ Dunno enough about that IDE to know what's going on there
Mine decompiled to .java. I don't think javac would care, at any rate
Yeah, they're .java in the decompiled directory
I wonder if it's because it's within Program Files...
I want to make an item turn into something else/replace if its been in a x container for x amount of time. Which lua files handle these things?
Ah, thanks, yeah, turns out when I was editing the project as a whole, it was still treating it as .class and read-only. When I opened just IsoPlayer.java it's editable.
this answered my question, thank you. ๐
there has not been a patch since that mod was released, i think the author just didn't want to admit it was badly made
the game has not had an update of any form released since 2022 ๐
looking at its code, i think it was probably ai generated and never tested
most of the structure makes sense but the actual protection part entirely relies on functions that just don't exist at all
I can get the character's walk or cancel keypress using if player:pressedMovement(false) or player:pressedCancelAction() then -- some code end
but how do I get the "WalkTo" action in "WalkTo" action? After the player pressed "WalkTo" when walking by "WalkTo" action
The OnPlayerMove event?
I have an action in which the player approaches an object, I need to cancel the action if the player uses "WalkTo" while walking
if the player does not use "WalkTo" while moving to the object, then the action does not need to be canceled
Ah no
there's an event when the keybind is used, i don't think the context menu fires it but that probably triggers a global lua function you can hook anyway
I think I see what they're saying now... I think what they really want is an onComplete function for their action that only occurs if the approach to the object is successful
I have an example one sec.
They have an action they're firing right after a walkto times event
Is that right?
Above
for better understanding, I need check in InTick that player will not use right click "WalkTo" timed action again, cuz it breaks the walking for two players
local function onTick(player, clickedPlayer, args)
function InTick()
if player:pressedMovement(false) or player:pressedCancelAction() then
sendClientCommand("123", "noBusys", args)
return
end
local distance = player:DistTo(clickedPlayer)
if distance <= 1 then
ISTimedActionQueue.clear(player)
Events.OnTick.Remove(InTick)
ISTimedActionQueue.add(SomeTimedAction:new(player, clickedPlayer, args))
end
end
Events.OnTick.Add(InTick)
end
Events.OnServerCommand.Add(function(module, command, args)
if command == "noBusys" then
ISTimedActionQueue.clear(getPlayerByOnlineID(args.clickedPlayerID))
ISTimedActionQueue.clear(getPlayerByOnlineID(args.playerID))
Events.OnTick.Remove(InTick)
end
if not (module == "123" and (command == "onAcceptWindowRequest" or command == "onAcceptWindowRequestclickedplayer")) then return end
local player
local clickedPlayer
if command == "onAcceptWindowRequest" then
player = getPlayerByOnlineID(args.playerID)
clickedPlayer = getPlayerByOnlineID(args.clickedPlayerID)
else
player = getPlayerByOnlineID(args.clickedPlayerID)
clickedPlayer = getPlayerByOnlineID(args.playerID)
end
ISTimedActionQueue.add(ISWalkToTimedAction:new(player,clickedPlayer:getSquare()))
onTick(player, clickedPlayer, args)
end)
So you just want to call sendClientCommand("123", "noBusys", args) if the player activates walkTo while InTick is running OnTick (which is imo not a good way to make yourself talk about this)?
Yep
I already have a check for canceling the action and walking with the keys
if player:pressedMovement(false) or player:pressedCancelAction() then
sendClientCommand("123", "noBusys", args)
return
end
but if player clicks "WalkTo" this check not working
I mean I have an idea but intuition is telling me this has to be overkill lol
overkill?
I am skeptical that all this is necessary to make two players walk to each other properly
what do you mean?
If that is your fundamental goal
That two players walk to each other
I just don't see all of this OnTick business as likely necessary...
That is the goal, yes? It's not a follow mod or something is it? It's just that you want two players to close the gap between each other automatically?
If you do not set these checks, then if the players interrupt the action of walking towards each other, they will not be able to start the action again until the server is restarted
No
That seems like shortcoming of the timed action design
I need the players to approach each other before the action begins
Hmmm
I mean intuitively it seems to me that you should be able to accomplish that with a modified WalkTo action without the weird onTick/InTick function. I'm torn about what to tell you because you're closer to weird solution than one that would feel intuitively logical to me.
We may be able to make the weird solution work with a final hack but if it's so sensitive to interruptions I'm not sure if it's the ideal strategy in the first place.
what solution do you mean, please tell me more details?
One way would be to decorate the base ISWalkToTimedAction:new function.
Run the function as normal and set some accessible variable to true, and if thatVariable then you send noBusys.
When you first trigger the event you set thatVariable = nil to ensure that the variable does not exist unless someone runs a new walkTo action after initiating the movement you triggered.
You might call thatVariable something like yourModule.justFiredWalkTo... it might be best to make that a table so you can track each local player separately, as in yourModule.justFiredWalkTo[playerIndex], if you want to be robust.
you mean like this?:
someVariable = nil
local function onTick(player, clickedPlayer, args)
-- some code
someVariable = true
end
function ISWalkToTimedAction:start()
if someVariable then return end
self.character:getPathFindBehavior2():pathToLocation(self.location:getX(), self.location:getY(), self.location:getZ());
end
No you would decorate the signature function ISWalkToTimedAction:new (character, location, additionalTest, additionalContext)
Do you know how to decorate functions yet?
a little
Well you decorate that one such that it runs normally and then you set the variable and then you return the new object.
Now personally my instinct is to handle this differently. I would be inclined to make a custom WalkTo action with a modified definition of success
A successful event would complete when I reached the other player and OnSuccess I would then trigger the server's "we're dealin" behavior
And if I reached the halfway point and the other player weren't there, I'd wait X seconds (or ticks) and bail under assumption of failure if user never showed up.
And eventually that action would terminate reliably without bugging out a player.
In other works, I would make a new WalkToTimedAction and then customize that action's update function
So I would just go
local action = ISWalkToTimedAction:new(character, location, additionalTest, additionalContext)
function action:update()
-- Check conditions of failure or success that make sense for my
-- custom event.
end
That way I don't need a decoration of the vanilla module
Nor do I need to write my own custom module that is essentially a duplicate of ISWalkToTimedAction
And while you're at it you would call action:setOnComplete(onCompleteFunc, arg1, arg2, arg3, arg4)
And make sure the way you defined update() ran through action:perform() on success so that your custom onComplete function would fire.
but the player will still be able to call the vanilla Walk To, right?
Yeah but that should not matter if you fully followed what I'm suggesting above.
Because the process would go:
- Players approach each other.
- If and only if 1 goes well, fire the client command that connects the two clients in a state of interaction.
- While clients are interacting, routinely check their distance. If their distance becomes > maximum allowed, cancel action.
- Players who remain near each other proceed through interaction by other normal means.
I don't see an obvious point of failure if you make the process follow these fundamental rules.
Why would activating WalkTo on either client mess up this process in a way that would bug a client? I would think it shouldn't and if it does you have some other problem.
2,3,4 points are already implemented, the only problem is that the player can use Walk To, when one client uses Walk To, the second client will continue to walk to the point until the first client stops walking, also, if the first client is nearby, then the second client will start an action, this problem is not very critical, but quite funny
and I believe that if it can be solved in a simple way, then why not
Either path above could fix that issue. Neither one would result in a player continuing to walk until the other stops. They would simply walk to the target location and wait. And if they wanted to hit escape and bail from the action they could.
I would pick a fixed location approximately halfway between the players; I would not update their goal based on the movement of the other player.
Got it, thanks, by the way, can you please tell me if you know how to make the players move away from each other at a certain distance before starting the action?
I mean that if the distance between the players before the start of the action is 1, then they first moved to a distance of 5 and only then started the action
Gonna' start a map mod for PZ in preperation for build 42 changes/additions. Though with PZ modding I'm 99% noob(I've made professions before
) and modded other games.
But what's the best tutorial now days for PZ map modding to go to? And the best way to get the tiling going? I saw a map tutorial by Daddy Dirk from 2021 just not sure if that's still the most relevant.
There's a mapping Discord
Daddy Dirk is good I believe
Hi! What is the command to check whether a particular modded sandbox option has been set to true in lua? Thanks!
What encoding should i use to encode polish letters properly?
SandboxVars.OptionModule.OptionID
Has a list of the encodings
https://pzwiki.net/wiki/Translations
Thank you! :)
Many thanks! ๐
Is there a way to set a custom weight on an InventoryContainer in code? setActualWeight seems not to exist on the InventoryContainer I'm working with, in the ISInventoryTransferAction
Did you look at the PZ java doc ?
@sour island Hiya Chuck! I used some slap-chop magic with Expanded heli events models/skins + TTAJ1bl4's UH 60 scripts to make a civilian heli. Asking for permission to use those parts if I also get TTA's perms for his code base. Always happy to credit and link, thanks for all the work!
I was under the impression we couldn't call Java setters from Lua?
The java doc is every methods you can access from the lua
Javadoc Project Zomboid Modding API package index
Javadoc Project Zomboid Modding API declaration: package: zombie.inventory.types, class: InventoryContainer
That doesn't seem to be universally true, to clarify. In-game, inspecting the Lua instance of the InventoryContainer, there is no "setActualWeight" function, and trying to call it anyway just throws a nil exception.

Exactly ๐
https://zomboid-javadoc.com/41.78/zombie/inventory/InventoryItem.html#setActualWeight(float)
InventoryContainer:setActualWeight(float)
Javadoc Project Zomboid Modding API declaration: package: zombie.inventory, class: InventoryItem
How do you call it in your code?
InventoryContainer inherits a bunch of InventoryItem class methods
And it inherits setActualWeight
So you can apply setActualWeight on InventoryContainer
It could also be a problem of the method being available but not actual doing the correct thing on the java side
local destination = self.destContainer;
destination:setActualWeight(0.1)
destination:setCustomWeight(true);
Crashes with Object tried to call nil in transferItem on the second line.
There's a lot of methods that are exposed and that you can use, yet in the java they don't do shit or what they do is unused by the game
And from in-game debug GUI to show that is an I- Ah.
Verify destination is not nil
It is not
transferItem ?
Your function ?
The name of the function I'm inside of.
Yeah right
require "ISInventoryTransferAction";
local originalTransferItem = ISInventoryTransferAction.transferItem;
---@param action ISInventoryTransferAction
function ISInventoryTransferAction:transferItem(item)
originalTransferItem(self, item);
if self:isAlreadyTransferred(item) and self.weightAlreadyAdjusted then
return;
end
if not self:isAlreadyTransferred(item) then
return;
end
---@type InventoryContainer
local source = self.srcContainer;
---@type InventoryContainer
local destination = self.destContainer;
if (source:getType() == "FirstAidKitSwiftlyPacked") then
source:setActualWeight(10.0);
source:setCustomWeight(true);
end
if (destination:getType() == "FirstAidKitSwiftlyPacked") then
destination:setActualWeight(0.1)
destination:setCustomWeight(true);
end
self.weightAlreadyAdjusted = true;
end
Full code here, but simplified to the stuff that matters in the above example, because it was a little obtuse otherwise.
But yeah, I see the error.
It is not an InventoryContainer, it is an ItemContainer.
Indeed
Javadoc Project Zomboid Modding API declaration: package: zombie.inventory, class: ItemContainer
And you can't modify its weight
Rip
It has a containingItem and inventoryContainer field, so I can access those, probably.
I'm not familiar with these class and item/container handling so eh
You can access them yes, doesn't mean you can do shit with them lol
welp gl gtg, you got the doc so maybe you can figure something out
I already had the decompiled code and kahlua definitions, so it was more just noticing that my thing wasn't what I thought.
The container here is not the inventory item/container
Aye, we got there.
Chat just updated for me
I remember we looked at getting values from Java fields at one point. Do you remember if it was safe for non-debug and multiplayer?
The way containers are handled is probably the better way to handle behaviors in items - but the class names are very hard to follow lol
Getting is safe regardless of mode, setting only works in debug
Perfect. Then I have my path to success.
I was planning to make items capable of holding "bulk stuff", similar to Pantry Packing, but without hardcoding lots of crafting recipes.
To start with, I stored things in modData for my faux-container, but it was quickly a little dirty and hard to see things.
With this approach, what I'll do is modify the weight of the bulk storage item dynamically when the player puts something in or takes it out. I'll probably use modData on the container item, just to sanity check and be a bit defensive, in case an exploit is found that lets you remove items or add items without the weight update applying.
require "ISInventoryTransferAction";
---@param instance Object
---@param fieldName String
local function getField(instance, fieldName)
local i = 0
while true do
local field = getClassField(instance, i)
if field:getName() == fieldName then
return getClassFieldVal(instance, field)
end
i = i + 1
end
end
local originalTransferItem = ISInventoryTransferAction.transferItem;
---@param action ISInventoryTransferAction
function ISInventoryTransferAction:transferItem(item)
originalTransferItem(self, item);
if self:isAlreadyTransferred(item) and self.weightAlreadyAdjusted then
return;
end
if not self:isAlreadyTransferred(item) then
return;
end
---@type ItemContainer
local source = getField(self.srcContainer, "inventoryContainer");
---@type ItemContainer
local destination = getField(self.destContainer, "inventoryContainer");
if (source and source:getType() == "FirstAidKitSwiftlyPacked") then
source:setActualWeight(10.0);
source:setCustomWeight(true);
end
if (destination and destination:getType() == "FirstAidKitSwiftlyPacked") then
destination:setActualWeight(-10.0);
destination:setCustomWeight(true);
end
self.weightAlreadyAdjusted = true;
end
And thanks! Saves me restarting a bunch and testing out multiplayer. This is so much better than my original plan of moddata fiddling.
There's an example of how to get java fields in Lua in the community repo
I've been meaning to make it a usable API for the frameworks portion
I just used this old goldie
---@param instance Object
---@param fieldName String
local function getField(instance, fieldName)
local i = 0
while true do
local field = getClassField(instance, i)
if field:getName() == fieldName then
return getClassFieldVal(instance, field)
end
i = i + 1
end
end
Did the strategy improve at some point?
Sorry to ping you at random Chuckleberry!
Strategy?
Like, is there a better way than numerically going through the class fields and selecting once you find a name match?
I think I changed it up to bypass a few iterations, you'd need to play around with it.
I could just add a memoization here, since I'm always getting the same field.
I'd need to ask the modellers about it, do you have a screenshot of what you have done so far?
https://streamable.com/ikjlls TTAJ1bl4 gave me the ok on the code
That might work to make it faster. For weapon lengths, since they're static, I made a table of types and values.
So it's TT's helicopters and EHE's old skins?
Where were you able to find the old models?
They're still in the mod pack lol
Ah
My server thought I was trolling them when Udderly kept spawning the parts and random Civ heli that didnt work
So I figured I would make it work ๐
The newer models look a lot nicer. ๐ข
But, I'll forward the request and video over to the modellers.
I actually had plans to make such a mod where you can add items in it but without storing the entire item in it
Like adding antibiotic pills inside a small fake container
I already have functionality for this for a first-aid kit if you'd like it. It has support for bandages, disinfectant, and painkillers, but adding new ones is fairly simple.
You could make a framework for it
That was the original plan, but I can't really be bothered with it now that I can just use real containers and adjust their weights ๐
local function addFirstAidKitPackedStorage()
local proxies = MutiesBulkStorage.Proxies;
MutiesBulkStorage.AddStorage(fak.itemType);
-- Add disinfectants to the storage
local disinfectantType = "Base.Disinfectant";
MutiesBulkStorage.AddStorableToStorage(fak.itemType, disinfectantType);
MutiesBulkStorage.AddFieldToStorable(fak.itemType, disinfectantType,
"alcoholPower", proxies.getAlcoholPower);
MutiesBulkStorage.AddFieldToStorable(fak.itemType, disinfectantType,
"deltaUses", proxies.getUses, proxies.setUses);
MutiesBulkStorage.AddLimitToStorable(fak.itemType, disinfectantType, fak.LimitNames.Disinfectant);
-- Add painkillers to the storage
local painkillersType = "Base.Pills";
MutiesBulkStorage.AddStorableToStorage(fak.itemType, painkillersType);
MutiesBulkStorage.AddFieldToStorable(fak.itemType, painkillersType,
"deltaUses", proxies.getUses, proxies.setUses);
MutiesBulkStorage.AddLimitToStorable(fak.itemType, painkillersType, fak.LimitNames.Painkillers);
-- Dynamically add bandages as storables
local allItems = getScriptManager():getAllItems();
for i = 0, allItems:size() - 1 do
---@type Item
local item = allItems:get(i);
if item:isCanBandage() then
local type = item:getFullName();
MutiesBulkStorage.AddStorableToStorage(fak.itemType, type);
MutiesBulkStorage.AddFieldToStorable(fak.itemType, type,
"bandagePower", proxies.getBandagePower);
MutiesBulkStorage.AddLimitToStorable(fak.itemType, type, fak.LimitNames.Bandage);
end
end
end
Events.OnInitGlobalModData.Add(addFirstAidKitPackedStorage);
I wrote it forever ago, but it was always intended as a kind of framework with storages (the first aid kit) and storables (the stuff that goes inside).
The main limitation I kept running into was having to create these proxy functions so I could get and set uses for items, or adjust alcohol power, or God forbid I stored food with their million getter/setter combos.
It honestly made the code so hard to decipher and require so many pieces of indirection that whenever I've taken a break and come back, I've just kinda stared at it for 20 minutes, then closed IntelliJ and walked away.
Can't read that I'm on phone but I have other stuff to do before looking into it ngl
just want to make sure the player is not holding a firearm (so a melee weapon or a tool etc.) I tried everything I could find yet none of them worked till now anyone has any ideas?
if getPlayer():getPrimaryHandItem():getSubCategory() != "Firearm" then if not getPlayer():getPrimaryHandItem():getSubCategory() == "Firearm" then
if weapon:isHandWeapon() then (weapon is a parameter)
if not weapon:isRanged() then
etc.
I started to feel like blind, if anyone has an idea I appreciate it
Morning people. Anyone know wher i can find the character parameters like hunger, stamina, calories, health, etc. I search everywhere in the LUA files but i can't find them. i want to add a "mana" parameter that refills over time without any requirement
How do i translate item names in a mod i'm making?
Like i have the translation files, but it doesn't display properly.
ItemName_EN=
{
ItemName_GlassOfBleach = "Glass of Bleach",
}
What am i missing here?
I think i might have figured out what i did wrong.
Is there a file where I can dress zombies the way I want? Like for example if I wanted all girl zombies to where dresses, is this possible?
Is there any way to get if player drank a spefific item?
Yeah, decorate the drink function
The drink action to be more specific
--Override vanilla function
local base_perform = ISEatFoodAction.perform
function ISEatFoodAction:perform()
base_perform(self)
doSomething(self.item, self.character)
end uses
getPlayer():getPrimaryHandItem():isRanged() will return boolean for ranged weapons
Is it possible to enable chat in SP so I can type admin commands ?!
they changed it ? Was possible in 2015 ๐ฆ
Am I missing something or is there not a way to check a players inventory from server side? eg:?
- playerObj:getInventory():getItemCountRecurse(name)
- playerObj:getInventory():getItemCount(name)
- playerObj:getInventory():getItems():size()
All return expected on client, but 0 or nil on server
I believe it's not possible
Could verify it
or let me asks the question another way, how would I start to add a right menu to a container so I can change it's max content amount ? I dont know the difference between amincontextmenu and debugcontextmenu
Hmm it's probably stored clientside then
I checked let me speak code and they make their own window and their own interpreter
Context menu
that is the issue basically it would need to use ServerCommand to trigger other mods as normal
since it uses its own window that mod back from 2015 didnt use the built-in sendservercommand
Looking at 2015 mods is definitely not a good idea
local player = getPlayer();
local base_function = ISEatFoodAction.perform;
function ISEatFoodAction:perform()
base_function(self);
PotentComboDeath(self.item,self.player);
end
function PotentComboDeath(item,player)
print(item:getType())
if item:getType() == "PotentCombo" then
player:Kill(player)
end
end```
I'm getting a error when i drink the modded item.
the problem in the game ischat.lua is basically ISChat.createChat = function( if not isClient() then return; end. Is it possible to change that by lua code ??
What did i do wrong?
Yeah you can change it
But there's most likely a reason it's like that so you'll have to verify it actually works properly
and how do I change it from another code ? Obviously for a mod I cant just tell the player to change their game file and to not verify game integrity
seems like the only way so far would be to copy-paste it without the isclient()
That function should be global
So just replace the function
In another file, redefine the function
-- your file
ISChat.createChat = function()
...
end
thanks this is the one ๐ ofc it was that one combination I didnt try lmao ๐
Finally getting my head around controller support
Food for thought: we need a mod to use player-to-player trade; that mod depends on sending focus back to the inventory panel after temporarily focusing on the player trade panel. I know you have plans for heavy editing. Food for thought before you get deep into it, you would simplify compatibility with this existing need greatly if all edits came down to modifications of type ISInventoryPage (iirc; in other words, the type of the table that comes back when you call getPlayerInventory(0)), so that the mod is still fundamentally sending focus back to that object. Other minor adjustments might be needed from there, but I could work them out more easily if this the starting point.
(Though I guess we can always branch to a custom UI if necessary.)
So how I've got this going for Equipment UI, and it will be the same for Tetris, is the only thing I modify on the vanilla panel's is navigation to allow selecting the equipment ui panel if its open
The rest is all handled automagically by my class ControllerNode, which gets injected into every ui element I need to have controller support
Sounds awesome
I am stoked to see you workin on that
I almost tackled it myself a few months ago but just did not have the energy lol
I did take a look at your stuff
People want that support bad.
Basically, the nodes intercept the controller events, see if they can do something with them, if not, they defer to the vanilla handler
Nice. Sounds like the right way to do things.
I will definitely make sure to do any minor changes needed on my end to ensure compatibility with your stuff if you get yours working independently.
Feel free to ping me with updates so I can try to be on top of that when you drop it.
๐
Hoping to update Equipment UI asap and Tetris a week after
(Equipment UI has some changes that Tetris requires and I don't want to be in another situation where the workshop lets people run outdated copies of Equipment with latest Tetris)
for sure.
I had a dream about a zombie apocalypse
I'm making a texture for it but to make it accurate
I need to know how to just
Make crawling zombies really fast
As some of the zombies in the dream crawled on all fours
I think it would also be extremely horrifying to see a zombie crawl at you at the speed of a sprinter
Now i wanna find a server with that ๐ญ
My path to success did not work. Upon reloading, the container resets to its normal weight, so back to my framework-style approach ๐
A common problem with MP zomboid is the servers continue while you are offline. Loot gets taken or expires, the players progress and things move on. Like say you want to travel a long distance but only get an hour to play a day.. .
So I'm wondering if it'd be possible to have a mod that lets you set offline goals for your player? Say you want to practice carpentry or read a book. You set the activity in some UI, go offline and then when you log back in it does some logic based on how long you were away and gives a little experience or progress on the book. Maybe even a little loot?
Would that be a difficult thing to implement?
Difficult ? Probably not
You want all the zombies to be like that ?
Only the crawling ones
It would be accurate to the dream and scare the hell out of people
Look into modifying the base game AnimSets
And increase the speed scale factor
This will make animations run faster and thus the movements of the zombies too
It works like that?
I figured I'd need to speed the zombies up and the animation separately
Yup
No need for anything fancy
Would require you to modify a few AnimSets
Difficult as a first mod?
Yeah
Involves a lot of stuff but you shouldn't let that slow you down. The problem is that you might need to get some experience in lua to do it properly
I see, well I'm a dev but I have never used Lua. It's similar to python right?
How do I do that
I have seen the animation sets
But like everything in the zomboid files
They are a weird filetype that I don't know how to edit
Sort of yeah
AnimSets are .xml files. There should be files about crawler zombies. You take those, copy the ones that you want to speed up and increase the speed scale factor
Is this done in blender
Or are .xml files done though code
XML is a markup language like html so I assume it's done through code.
Code
It's really easy to do
I'd assume it is but I really don't know what I'm doing
I'm not exactly sure what speed scale is
Though I'd think it's just a number in the code that I can increase
I hope
Can you point me in the right direction to get started? Maybe I need to look at a spawn script or something? Find out the time they logged off and the current time?
Scrolled too fast, found it~
GameTime to count how much time elapsed btw last disconnect and now
ModData to store player informations whenever they disconnect
Use Events that trigger OnGameStart and on quit to apply the data save
Apply XP idk the thing exactly but could find it easily
Yeah it's really extremely easy
Just go check the AnimSets folder then crawler zombie
You'll see it's very easy to navigate
If you want an example mod that speeds down or slows down zombies, check the mods for slower sprinters
Anyone know how to build the integer required to make an ImmutableColor, if I already have the rgba values?
Build the integer ?
Not sure what you mean by that but I know how to create an ImmutableColor with rgba values
Please enlighten me, then. All I could find was the decode function, which takes an integer in string form.
declaration: package: zombie.core, class: ImmutableColor
Yes
ImmutableColor.new(Color.new(0.70, 0.70, 0.70, 1)),
Hello! Is anyone sitting on any decent resources regarding getting started with Lua programming for PZ? ๐ค
I'm starting out small and am currently trying to figure out how to write "hello world" in the console when booting the game up lol
Probably find a similar mod and look inside the files to see how it works
Best place to start
Got it working, forgot to say. But thank you!
@solar rover hey did you ever end up figuring out how to delete books once they're read?
How would I go about setting the overal body health of a player if certain conditions are met?
Nothing I was able to write did it yet, no. Best bet is what Burryaga told me but I don't know how to make it happen. "You can decorate the update function of book-reading such that when you complete the book, you also call a function that replaces the book in player inventory with a different item."
Let me know if you figure it out? ๐
gotcha, just wanted to check before i start trying to figure it out myself
will let ya know if i get anywhere with it
Try
local function yourCondition()
if .... then return true end
end
if yourCondition() then
local damage = 50
local body = getPlayer():getBodyDamage()
body:setOverallBodyHealth(damage)
print(body:getOverallBodyHealth())
end
setting overall body health doesn't do anything, the game recalculates that value every tick
How do I make those fancy codeblocks?
The way I've been doing it so far has been like this:
` if intensity > 0
then
local playerHealth = getPlayer():getHealth()
getPlayer():setHealth(playerHealth - intensityToDamage)
print(playerHealth)
end`
```lua
paste code here
```
Eventually the player dies, but the health in the health panel doesn't update to show it
the player's 'health' is a weighted average of the health of each of their body parts
the game calculates that average every tick when it's processing health stuff, so if you change it, it just gets discarded and replaced by whatever it normally would be anyway for the purpose of actual calculations
Hi! Is it possible to organize your xml files from the media/clothing/clothingItems folder into different subfolders (assuming you correctly specify this in fileGuidTable ofc)? Just asking because in the vanilla game, there are no subfolders but using them would make the organization so much easier...
Ah, that's fair then I suppose. So to cause "global" damage you could go about just damaging each individual limb?
just incase you need this
BodyPartType.Foot_L
BodyPartType.Foot_R
BodyPartType.ForeArm_L
BodyPartType.ForeArm_R
BodyPartType.Groin
BodyPartType.Hand_L
BodyPartType.Hand_R
BodyPartType.Head
BodyPartType.LowerLeg_L
BodyPartType.LowerLeg_R
BodyPartType.Neck
BodyPartType.Torso_Lower
BodyPartType.Torso_Upper
BodyPartType.UpperArm_L
BodyPartType.UpperArm_R
BodyPartType.UpperLeg_L
BodyPartType.UpperLeg_R
Love you xoxo
Is there anywhere I can get the java references without having to decompile the game?
getPlayer():getBodyDamage():getBodyPart(BodyPartType.Hand_R)
oh you can find it on github
i think
declaration: package: zombie.characters.BodyDamage, enum: BodyPartType
in the clothing xml files, what is the parameter
<m_Static>false</m_Static>
doing?
what property do I need to reset to keep perishable fresh indefinitely in a container shop ? Id run it like once per day and make sure item sold have 0 days freshness ?
I just made my first ever mod, and I'm trying to test it but my items don't appear in the item list when I'm testing my mod in debug mode. What are some things I might be doing wrong, or what are some reliable resources I can use to troubleshoot?
set your model animation, like backpacks moving arround when you walk/run, or stay static, glued to your back
many thanks for the info!
idk how the animations are made tho
I've tried the Wiki, I've tried tutorials and comparing my mod to other existing mods, but nothing seems to work. I checked the console, both the mod and the distributions lua load, but that's all I see in the console. Is my mod loading impartially for some reason?
EDIT: My mod also contains items, recipes and models lua, along with custom models and textures (fbx and png respectively)
mostly asking this for others in the channel cuz I just started but how are you trying to load the item ? lua console ? debug mod with an item list ? loot list ?
I use the item list in the debug mode, and I also check the crafting menu for my recipes
It's an items mod
oh, i'm not familiar with those, try copying a workshop mod that already exists
and does the same
Yeah that's one thing I've tried with multiple mods, but I'm still stuck somehow. I'm digging deep for solutions right now haha
Thanks! Taking a close look EDIT: Verified all code multiple times now lol
depending on what your mod add if you post it somewhere and its for b41 someone might be willing to try to load it and figure whats wrong ๐
Is there anyway I can go through the radio messages and TV messages and change them
I wish to change every message from the Project Zomboid lore to my own
So the people can learn the general state of things while they play
I think there should be a file somewhere in the /media folder containing all of the messages. I might be mistaken though, let me check
\media\radio\RadioData.xml i think?
can you confirm @agile lily?
Yup! Seems to contain a lot of those things, I ain't going through it to see if it's all of the lore though. It's a lot to read x)
Thank you I'll check it out
The radio data should be what I need
Now I get to ask the questions. How do I start/define a period of rain through code?
There's a boolean called "isRaining" but I'm not too sure how to use it, if it actually starts the rain or if it just checks if it already is raining
@gleaming sorrel do you know about this?
https://theindiestone.com/forums/index.php?/topic/21318-wordzed/
Yes
okie :3 just making sure
isRaining() returns true if it's raining and false if it's not, to start raining there's a function called startRaining(), you should check this: https://zomboid-javadoc.com/41.78/zombie/iso/objects/RainManager.html
Javadoc Project Zomboid Modding API declaration: package: zombie.iso.objects, class: RainManager
if it has the prefix "is" it will always mean that returns a bool
Thank you. I've been staring myself blind at this exact page without figuring it out so far haha. So to make it start raining i'd call "RainManager():startRaining()"?
I only started dabbling with this today so forgive me if I'm being a bit slow <:)
for stuff like this I recommend decompiling in intellij etc as per the guide
Maybe you also need the StartRaindrop() and StartRainSplash() for visuals idk, never used it
Yeah, I was trying to do so earlier but I was getting some errors. Is there a newer guide on how to decompile the game, or should the one that's up on github still work? Will probably need to give it another try, working like this is far from optimal :x
honestly id recommend setting up procyon, cfr or fernflower manually even though it is more advanced
and tell it to process all classes file in the game folder and subfolders
cuz it seems limited to do it file and file and I personally prefer being able to grep or GetChildItem | For-Each in powershell
like with the code: so startraining dont seem to do anything
so youd probably have to use climatemanager
so for this Id start from this: and uses the climate debugger in debug mode to find good values for rain, dont forgot to set setprecipationissnow to false
ie: in lua for example fx = getCell():getWeatherFX(); .fx:setPrecipitationIsSnow(_value);
Here are some snippets from my mod's lua files. Can someone identify what I'm doing wrong please? My items don't appear in the debug item list, but the mod appears to load.
From Recipes lua:
{
imports
{
Base
}
recipe Unfold Picnic Blanket
{
FoldedPicnicBlanketPink,
Result:PicnicBlanketPink,
Sound:PutItemInBag,
AnimNode:RipSheets,
Time:20.0,
}
recipe Fold Picnic Blanket
{
PicnicBlanketPink,
Result:FoldedPicnicBlanketPink,
Sound:PutItemInBag,
AnimNode:RipSheets,
Time:60.0,
}
recipe Make Pink Picnic Blanket
{
keep Needle,
Thread =5,
Sheet=3,
[Recipe.GetItemTypes.HairDyePink]=2,
Result:PicnicBlanketPink,
Sound:PutItemInBag,
AnimNode:Disassemble,
SkillRequired:Tailoring=2,
Category:Tailoring,
Time:120.0,
}```
From Items Lua:
```module Base
{
item PicnicBlanketPink
{
DisplayCategory = Camping,
Weight = 2.4,
Type = Normal,
DisplayName = Pink Picnic Blanket,
Icon = PicnicBlanketPink,
WorldStaticModel = PicnicBlanket,
}
item FoldedPicnicBlanketPink
{
DisplayCategory = Camping,
Weight = 1.2,
Type = Normal,
DisplayName = Pink Folded Picnic Blanket,
Icon = FoldedPicnicBlanketPink,
WorldStaticModel = FoldedPicnicBlanket,
}```
From Models Lua:
```module Base
{
model PicnicBlanketPink
{
mesh = PicnicBlanket,
texture = WorldItems/PicnicBlanketPink,
scale = 0.15,
}
model FoldedPicnicBlanketPink
{
mesh = FoldedPicnicBlanket,
texture = WorldItems/PicnicBlanketPink,
scale = 0.15,
}```
Attached folders screenshot for reference.
Here's my models folder too, since I forgot to include it in the screenshot above. They are FBX files, the icons and textures are PNGs with indexed colors for compression
EDIT:
All feedback is welcome! This is my first mod, and I have no idea what I'm doing so far.
Also, I don't think the distributions lua file is an issue because I've noticed in the console that it loads without issue along with the mod, but there's no indication of any other part of the mod loading.
module Base
imports { Base }
without imports base
in script folder it's should be TXT file, not lua
module Base
{
recipe Unfold Picnic Blanket
{
FoldedPicnicBlanketPink,
Result:PicnicBlanketPink,
Sound:PutItemInBag,
AnimNode:RipSheets,
Time:20.0,
}
recipe Fold Picnic Blanket
{
PicnicBlanketPink,
Result:FoldedPicnicBlanketPink,
Sound:PutItemInBag,
AnimNode:RipSheets,
Time:60.0,
}
recipe Make Pink Picnic Blanket
{
keep Needle,
Thread =5,
Sheet=3,
[Recipe.GetItemTypes.HairDyePink]=2,
Result:PicnicBlanketPink,
Sound:PutItemInBag,
AnimNode:Disassemble,
SkillRequired:Tailoring=2,
Category:Tailoring,
Time:120.0,
}
} -- close Base {
another look fine
All of this is great, thank you so much for your help!
That was it
Now the time has come to rewrite the entire Project Zomboid story
I wonder if there is a mod in which there was ever self-driving
especially with the cell, lot etc thing I dunno if you could even know that something distant is a road and astar it
There is. Don't remember the name of the top of my head but you open the map and place waypoints and the car auto drives
Turns and all that shit
its from the "NAVIGATION" mod
Hello, does anyone know the script to identify when a player is in idle?
Hi so I'm completely new to modding this game but real quick question how hard is it to mod like a custom radio station into the game
Or add a CD that has multiple tracks on it that works like a music CD
getPlayer(playerNumber):isPlayerMoving()
playerNumber is 0 unless playing splitscreen co-op where its 0 to 3
This mod provides the ability to add custom music rather easily:
https://steamcommunity.com/sharedfiles/filedetails/?id=2613146550&searchtext=music
Would you mind explaining how?
There's an entire write up and a video tutorial on the linked mod page
Thank you
Inventory Tetris controller support
About 80% done.
@thick karma Unlisted test copy of Tetris with controller support (and incomplete clothing pockets)
https://steamcommunity.com/sharedfiles/filedetails/?id=3260666789
Hey guys, just a general question.
Is there a way to pull out info about all players on a server?
For example, what's the distribution of occupations and traits among players etc.
Is there a mod for such things or third-party software?
Log extender mod
Currently it's a bit unclear to me in which cases I should write code for the client, server or for it to be shared. Is there any reading regarding this?
Server and client cant access their files
So you can have 2 goobal function named the same kn each folder and it wont overwrite themselves
Client and server can access files from shared
Client does more control on player stuff thats local
Server is where you would want definitions to go to and global events etc.
If you place something like a spawn function and you want it to Only happen once for example then out it on the server
Otherwise it will spawn many times cuz each player can trigger it
Im not explaining this clearly...lol
I suggest you look at how vanilla does it
But just to ask
What are you trying to build?
server folder globals will overwrite client folder globals
Ahhh, I think I get it... -sorta-. Right now I'm trying to make an acid rain mod which damages the player and applies burns & other nasty effects if they're caught outside. I've got the very basics working thus far (detecting if you're inside/outside, getting damage from the intensity of rainfall and so on...) but this has all been stuff I've written on the client-side of things, which seems to work fine in singleplayer. I'm not asking for any particular reason other than me suspecting I'll need to know how this works at one point or another 
You can trigger the rain event via server and handle the damage client side
But thats just me .
Someone else would give better advice
I think that's a good idea, as soon as I figure out how to create my own "weather events". I was asking about this yesterday but couldn't figure it out haha. Currently ALL rain damages the player, which makes it a bit too predictable. Eventually I'd like to be able to define different storm presets that get picked from a list. Probably should get to decompiling the game so I can get a closer look at things, haven't found any examples so far that are accessible in the media/ folder.
I really appreciate the advice though, you've all been very helpful so far :D
On a second unrelated note, how would you go about implementing chance based randomness to the game? Using math.random from lua seems to make PZ a bit angry
lua random isn't available in the pz environment, use ZombRand and ZombRandFloat
Hi, I'm a beginner working on creating a new trait: 'Undead Stalker' for a game character. I'm struggling to implement these features efficiently and seek guidance to finalize the code. I put this code into a new Lua file in the media\lua\client directory.
My goals:
Create the 'Undead Stalker' trait with the following enhancements:
Increase character size by 25%.
Double strength and fitness.
Boost XP gain for strength and fitness by 60%.
Double defense and endurance.
Lower bite chance to 15%.
Double attack range.
Reduce panic and fatigue by 4 and 2 times, respectively, against zombies.
Expand inventory capacity by 1.5 times.
Enable reversion to human form within 5 seconds after zombification, removing zombification effects.
Organize functions and variables into a separate table to prevent conflicts with global elements.
Here is my code:
is there any mod so I can debug my mod with an existing save IN PEACE WITHOUT BEING INVISIBLE like debug ghost mode does ?!
like what is usually called no target in other games
did you see what I said about it ?
Oh, right! I'd forgotten about that. It was about four in the morning(night?) for me when you sent that. I'll give it a looksie. Thank you!
yeah and here are some values for you to try it: with these there is light rain
so along with #mod_development message you could probably set off rain in the current cell
and stop it with stopraining or forecasts system
Character size ? 
There also command for admins they can type on chat
/startrain
/stoprain
Iirc
Theres a send command for you to use that via lua. Just dont know the syntax , im using mobile rn
it isn't a thing
Bcs I've never seen it used
You know stuff in the doc doesn't always do smthg ?
Tho why not right imean isnt that something that we should have available would be nice to have that really
Ik
Yea
Esp for custom zeds lol
They grow
Omg thats gona so cool
Like every player kills they gain size
I'd love for some special infected to keep you on your toes
Check out @bright fog he did special zeds
Climbing buildings can actually be done now i think
Yup
Also a guy made his zombies bigger yesterday
Oh yeah, I saw that too. Looks really nice :D
So yeah you have to to set the outfit right? But its not gona be incremental unless you make lots of outfit models(same model but diff sizes)
Is there any code that can help players revert to being human after turning into a zombie?
I meant, with this trait, is there a possibility of immunity after being infected, or a chance to return to being human after turning into a zombie? Is there any code that accomplishes this?
Yeah
Basically
Still some limitations but I didn't knew that was doable
No
I don't think so
But you can become immune that's for sure
There's a lot of mods with such a feature
try this
local bodyDamage = getPlayer():getBodyDamage();
bodyDamage:setInfected(false);
bodyDamage:setInfectionMortalityDuration(-1);
bodyDamage:setInfectionTime(-1);
bodyDamage:setInfectionLevel(0);
bodyDamage:setInfectionGrowthRate(0);
bodyDamage:setFakeInfectionLevel(0);
untested
but thats what i could find in a short time so i guess one of em might work
but threre are 2 types of infection im always confused as to which one is the zed infection
Lol understandable
the one on bodydamage will always be zombie infection, you can't get a full body wound infection
Hmmm, this seems very promising but for now the getCell() command returns "nil"
Hmm true
I suspect there needs to be something more there to help define which cell it's supposed to affect
there is only one cell, if it's returning nil the game has not loaded yet
No it should give the cell
The cell around the player I believe ?
There's always a confusion on player cell and map cell tho
the IsoCell object is not related to map cells
Huh, weird. I've set the function to trigger every ingame hour so I'm pretty sure the game is loaded
Hmm
I use it I believe and it does work
So hard to say what breaks for you ?
Overwriting getCell globaly maybe ?
can you show the code that shows it returning nil?
Sure
Nevermind, I tested it and it does return the cell, the weather change doesn't seem to cooperate though
local getTheDarnCell = getCell()
local var1 = getCell():getWeatherFX()
var1:setFogIntensity(1);
--prints affected cell
print(getTheDarnCell)
end
Events.EveryHours.Add(ChangeWeather)```
I give up
The weather change applies to the getCell() ?
No, nothing happens when it calls "setFogIntensity(1)"
so without changing the vanilla game .luas what is the fastest way I can test the above code in-game ? ๐
I wanna be a weather wizard too
but it seems like even for one line of code you need the whole modding template
I suspect youd probably need all values, I used this help you but it would probably need a full climate def before it display something and in the code they just call setfogintensity too but that is along the rest of cell having values. Maybe weatherfx is off for that cell in that particular moment etc. At this point Id suggest looking at the weather wizard mod and see how they did it
seems more complicated than IRL to make it rain ๐
This does not create an error, it just doesn't do anything "getClimateManager():transmitServerStartRain(100)"
AAAAAAARGH FINALLY
i'm looking to replace the warehouse in muldraugh with a better, more expanded version. anyone got any pointers on how I'd be able to clone the nearby roads and buildings into the mapping tools?
for context, it's the mass-genfac warehouse packed full of metal on the mainroad of muldraugh
there's a decompile of the vanilla map floating around somewhere on github
you can build off of that
someone in #mapping can probably give you a link
damn thanks man
found it myself ๐๐ป
This worked for me:
getClimateManager():triggerCustomWeatherStage(WeatherPeriod.STAGE_TROPICAL_STORM, 10);
end
Events.OnGameStart.Add(WeatherServer)```
that is a big of a nuclear option ๐คฃ
"light rain doesn't work" - k let's do a hurricane then
Hahahahha
genuinely thank you so much
just what i needed
glad i could help!
again #mapping let's keep things of relevancy in the relevant channels please
unless you are copying it by code which is probably not possible very hard this is a pure mapping thing
Is it possible to change player's accesslevel to admin using OnConnected function?
I dont understand how to....
You just call setAdmin()
You might need to disable certain anti-cheats to allow that to work
can setadmin sets intermediate level like moderator ?
No clue
where can I find it? I've looked everywhere for it
like
I didnt found it
I just know setAdmin() will toggle admin mode when you're in -debug
on wiki
I changed most debugs lua to work without -debug in SP lol by direct editing. Know that this cant be a mod but nice practice regardless
https://zomboid-javadoc.com/41.78/
https://zomboid-javadoc.com/41.78/zombie/Lua/LuaManager.GlobalObject.html#setAdmin()
Javadoc Project Zomboid Modding API package index
Javadoc Project Zomboid Modding API declaration: package: zombie.Lua, class: LuaManager, class: GlobalObject
ty
couldnt stand having the lua debugger in the way
so setAdmin() will not work without -debug enabled?
I didn't say that. I don't know when it will work. I just don't use it when I'm not debugging.
no that is another subject unrelated to yours. Like you work on your own things and I work on mine and I comment on my things in a public chat ๐
so... huh...
lua methods are globals right ? So I could call another mod methods right ?
if they are global
They're global by default not always. If we preface them with local or they're in a local module, they're not global.
but even if they are in a table I can go throught the table to call it ? Like for instance ISUICheatMenu:ObjectCheatMenu if im not too rusty in lua ?
(I last did lua in opencomputers in minecraft in 2020 so Im a bit rusty ๐ฆ )
if that table is global
it is defined as ISUICheatMenu = ISUICheatMenu or {}; cant find any other definition for it...
Idk if that's global but that's not how you call a function. You need () to invoke a function.
That's global.
Unless I suppose local ISUICheatMenu = nil appears somewhere above that in the file, which is highly unlikely.
No just a bunch of required. For my target mod if all else fail the target has sendClientCommand(playerObj,"shop", "ImportStores", {}) and it's loading exportedshops.txt in its folder. I dont know if sendclientcommand actually works in SP though
So I start a game with a sandbox variable set to -150. and it works all nice. But when I load the save next time it resets to its default value being 30.
What could be the issue? How do you save and retrieve a sandbox variable?
So my method so far would be : 1) gather items in a container in-game, spawning it with item menu (so it only work with an uncraftable one like locker) 2) click a button in my mod to export the container in exportedshops.txt using zomboid legal IO to put it in the other mod folder 3) call the other mod with sendclientcommand 4) profit or critical failure
isn't it SandboxVars.Temperature = -- to set it and getSandboxOptions():getTemperatureModifier(); -- to get it ??? That is the kind of stuff I see all over the game lua
you'd use the former to get it
This works the first time on starting a new save, but when loading it afterwards it fails and uses default values from the sandbox vars
you're caching it too early
when the file runs the game hasn't loaded the sandbox options for the save yet
if you want to cache them do it during OnInitGlobalModData (the earliest event after sandbox options load)
did you use initSandboxVars() as well at some point to add your ownj sandbox vars or the game lua is lying ?
this works when creating a new save because the sandbox options are still set from the menu screen
No what you see is the entire mod, except for the sandbox-options.txt
in your case i don't think you need to cache them at all, you can just call on the sandbox option directly during your OnInitSeasons
like this?
yeah, looks good
@bronze yoke is initSandboxVars() actually required ? The code seems to says it is
I've tried this earlier, but I had both Server and Client versions running at the same time. Now I'm server only.
no, i've never seen that before
And I need this only in the Server lua folder right? No shared or client necessary for something this small?
meh I have so many self-blockages about learnoing lua ๐ฆ
but in hospital I was stuck with my laptop and no internet and learned most python basic in 6 hours (the programming language not the snake) ๐ฆ so when I really want to I can
i would guess that this will automatically synchronise to clients when done from the server, but you'll have to test that yourself
however be mindful that the server folder runs on the client as well
Yeah that's the reason removing the caching didn't work the first time.
hello. never really worked with mods before and am new to coding so please bear with me as i proceed to butcher this question.
is there a way to use FindAndReturn() to do partial matches? or perhaps some other way to read the inventory that returns an array?
like if i had Base.xxxyyyzzz, where yyy was always static, xxx and zzz has multiple variations (to include blank), how would i go about building a list of everything that has a matching yyy?
if needed, zzz only has 4 variations so i'd be willing to run multiple times for yyyzzz too, but would prefer running only once
spent some time trying to resolve it myself, but i don't know my way around documentation well enough to figure anything out ๐ฌ
Are you messing around with weather stuff in what you're currently making? You wouldn't happen to have stumbled across how to define your own custom weather patterns? It seems like it would be possible but so far I've had no luck at figuring out how to create your own custom weather
.
What do you mean by variation?
There cant be more than 1 item with the same fulltype
Oh i was just fixing KYR's Realistic Weather mod, it had some bugs with saving and loading in Singleplayer.
But check out MonthlyClimate.lua from Monthly Climate Settings, that should get you started in the right direction if you want to change weather and season params at certain times.
i assume when you say fulltype you mean like Base.Axe right?
okay. let's use vanilla items for an example.
let's say i want Base.Hat_CrashHelmet, Base.Hat_CrashHelmetFULL, Base.Hat_CrashHelmet_Police, Base.Hat_CrashHelmet_Stars
"", "FULL", "_Police", "_Stars" would be variations
now if we pretend those are the only things in the item list that have "Helmet", for my example...
xxx = "Base.Hat_Crash"
yyy = "Helmet"
zzz = "FULL"
i basically want to find and return for anything that contains "Helmet" in my inventory
In your case youre just manually defining the key for your table
Especially since you would have to manually do this for each items as they are not named using a certain pattern where you can just replace/remove certain parts of it
Even on your example
If you omit the first characters then you should have
{"FULL", "_Police", "_Stars" }
Oh wait i think i misunderstood
You probably ment look for an item which is partially similar to your input
I think its
:contains("Helmet")
sorry for replying but I just want to say that is a really nice font choice, I need a 4k monitor so bad
It's a nice to have for sure haha. I'm unsure what font exactly this is, but I'm prety sure its one of Rider's IDE default dark themes.
Is it possible to call a function in the client from a server script?
maan im so hyped about the pockets
You can require a /client file and it will load the /client file on the server
Allowing you to run functions that you can access from that /client file in a server side
I published my first mod today which adds picnic blankets to the game. But I just noticed that my items don't appear in Item List when testing on a Mac. No issues on PC. Any ideas what the problem might be? Here's my mod: https://steamcommunity.com/sharedfiles/filedetails/?id=3262481378
Case sensitive file system immediately comes to mind
On Windows
myFile.lua and MYFILE.LUA are the same file.
On Mac and Linux they are not
It worked
And now the workshop will live in fear
It definitely will
Thanks! I will check for discrepancies
hi! i'm trying to add new sounds to an already existing mod, does anyone know if a table like this:
{
sound MBatHit
{
category = SnakeMods,
clip
{
file = media/sound/MetalBat_Impact3.wav,
volume = 1.0,
}
}
}```
could hold multiple sounds for variation?
i was also wondering if i could add some sort of pitch variation to said sounds, i'm pretty much new to LUA, but i know that a module called pitchVariation exists but don't know how to apply it here
Yes it can:
module Jumper {
imports {
Base
}
sound Rifting
{
category = Player,
clip
{
file = media/sound/jump1.ogg,
}
clip
{
file = media/sound/jump2.ogg,
}
clip
{
file = media/sound/jump3.ogg,
}
clip
{
file = media/sound/jump4.ogg,
}
clip
{
file = media/sound/jump5.ogg,
}
clip
{
file = media/sound/jump6.ogg,
}
clip
{
file = media/sound/jump7.ogg,
}
clip
{
file = media/sound/jump8.ogg,
}
clip
{
file = media/sound/jump9.ogg,
}
clip
{
file = media/sound/jump10.ogg,
}
clip
{
file = media/sound/jump11.ogg,
}
clip
{
file = media/sound/jump12.ogg,
}
clip
{
file = media/sound/jump13.ogg,
}
clip
{
file = media/sound/jump14.ogg,
}
}
}
No idea on part 2.
No worries, much obliged for the fast response!
I don't know why the file size is so big
I just deleted all of the images and the file size did not change at all
Uhhhh are you sure you're zipping the same folder you're emptying?
Yep I'm 100% sure
Okay well 185 MB was the size of the original file
So it sounds like whatever you're doing is not deleting the data that needs deleted for some reason
Almost half-way, the ETA is a total lie because speed isn't stable
Actually wait couldn't I just make an .rar file to compress it even more?
At this point probably not worth it
Already halfway through'
Unless compressing from .zip to .rar will reduce size by > 50%
Doubt it
I don't want to jinx it but Google givin me all the bandwidth now
From hours to seconds lol jeez
Rip
I am clarifying really quickly I am getting legal rights to use the music that I put in the mod
No
Then I'm going to take a shot in the dark and guess that you have this directory in Zomboid/mods
Needs to be in Zomboid/Workshop
You likely misunderstood; it's in Zomboid/mods when testing
Oh wait
When you move it for upload it goes to Workshop
No I'm sitting here I'm looking at it I'm wrong it's in the workshop file
So does your directory go Zomboid/Workshop/True Music Addon/Contents/mods/truemusic_addon?
etc?
E:\SteamLibrary\steamapps\common\ProjectZomboid\Workshop\True Music Addon
Wrong Workshop folder
That's **ProjectZomboid/**Worskhop
Which despite the one-word difference is enormously different from Zomboid/Workshop
And is a common mistake
Zomboid/Workshop is in your user directory
You can open it on Windows by typing Windows Key + R and dropping this in it: %UserProfile%/Zomboid/Workshop
So I'm looking for zomboid not project zomboid
Correct. It's not in the game installation folder. It's in your user directory.
I feel so dumb I'm not even going to lie to you
It's an easy mistake to make
I've been sitting here going off of this stupid guide on YouTube for the past like 30 minutes wondering what I've been doing wrong this entire time
There are many very similarly named things throughout Zomboidland
Takes great care not to mistake one thing for another.
All right thank you I'm going to go back to working on my mod and get rid of all of the stupid placeholder text I put
This was my first ever time modding this game
While I'm looking at this, I'm gonna throw some other tips out there that the guide may or may not cover or communicate effectively to you.
In workshop.txt file, make sure you set title and description, but do not set id. In fact, you can delete id= line entirely and Steam will create it for you when you first upload your mod.
I wouldn't name my parent folder True Music Addon. You are free to be descriptive; the mod will still work. I would go with True Music Addon - Amazing Music if that's your working title. (: not allowed in folder name).
Alternatively you can drop the True Music Addon entirely -- that is not necessary at all for the mod to work. Some people put True Music at the end of the mod name and that's fine too -- e.g., "Music for the End of the World [True Music]"
Well the entire mod is just going to be adding all of trocadero's music into the game
i don't think contains will do what i want at all...
Truecadero Music
How does the mod not name itself
๐
I want to sucker Punch you so badly sir
lmfao what it's a perfect name
I've never felt my body physically heat up like that before
Don't hate the player
No I'm going to use that I just I'm mad about the pun
I've never heard the term parent folder before I assume you mean the main file?
Anyhoo so yeah you can change True Music Addon folder name to Truecadero Music, and I would personally change the truemusic_addon subfolder of Contents/mods to TruecaderoMusic (I generally avoid spaces in folders and filenames at that level of the mod).
I mean the folder containing the entire mod.
Okay yeah that's what I thought you meant
You have the mod in Zomboid/Workshop/True Music Addon... I'm calling the last of those three folders the "parent folder" of your mod.
You could have many workshop items adjacent to it in the Zomboid/Workshop folder.
So does this look better?
Standard practice for many of us would be to use that same smashed foldername (TruecaderoMusic) as the mod id (on the id= line of mod.info, which, again, you must not confuse with the id= line of workshop.txt [again, the latter of these does not even need to exist until you upload]).
C:\Users\gayman1\Zomboid\Workshop\Truecadero Music\Contents\mods\TruecaderoMusic
So I don't need to worry about the workshop. Text
It is very important that you do not forget to append a unique id to those files
How would I go about doing that
No wait
hold on
Let me double-check
It may be the Lua ones not the scripts
Yes, the scripts, too.
Okay so you pick a random long number, perhaps 10 digits.
Well I know what I'm going to do
I'm going to do the lyrics from one of their songs
Okay yeah that would work
So where would I exactly edit it at
Just nothing too insanely long idk what the limits are here.
Would it be like this?
But basically you need to edit these four filenames:
Exactly
I doubt it matters but I have not experimented.
What you did is standard.
All 4 files get the same number
Just do the same thing that I did last time?
Yep
Exactly
Yeah afaik the scripts and all the mods Lua files are what you have to rename
Somewhat yes
Okay so I know it adds vinyl into the game and this is going to kind of sound dumb but would you know how to add like a custom image on the vinyl in the game
Textures what I'm looking for
Work well I think you know what I mean
Music for the End of the World does that. I would recommend referring to that mod for guidance.
Basically, in your current item scripts (the MusicScript txt files), you have a line that says this:
WorldStaticModel = Tsarcraft.TCVinylrecord3,
This points to a generic record model provided by True Music
I think I understand?
You would change that to say
WorldStaticModel = Tsarcraft.VinylRECORDNAME(YEAR)Model,
Then you would make a model somewhere else in that file by adding a new block just like the item blocks that looks like this:
model VinylRECORDNAME(YEAR)Model
{
mesh = WorldItems/TCCover,
texture = WorldItems/VinylRECORDNAME(YEAR),
scale = 0.0012,
}
Or .0012 is used by MFTEOTW. You might want your vinyls to be slightly bigger or smaller, that's on you.
I think I'll just let it stay generic
Fair
You're doing a very good job at explaining it but I don't understand a word you're saying
It's always an upgrade you can consider if your mod is popular.
Is there a video/image guide for this?
No I am translating things for you by reading the mod files for other mods that do this.
local stuffList = {
'BlueJacket', 'BlueShoes',
'RedShoes', 'RedJacket',
'RedHat', 'BlueHat',
}
for _, v in ipairs(stuffList) do
if v:contains('Blue') then
print(v)
end
end
--prints: BlueJacket BlueShoes BlueHat
My head is starting to hurt
If you do decide to do vinyl covers, the last step is including the vinyl as a .png file in media/textures/WorldItems/ called VinylRECORDNAME(YEAR).png
for _, v in ipairs(stuffList) do
if v:contains('Hat') then
print(v)
end
end
--prints: RedHat BlueHat
@warm plover
There are no further steps
That would be the last detail you needed to learn
But honestly I recommend a break @grizzled burrow ๐คช
Breaks are good
These things take time and energy
cool. maybe it will do what i want then. how do i make it work on the inventory?
i tried getPlayer():getInventory():contains("text") but just got "false"
oh. wait. let me try it with the for loop
sorry. new to this
unfiltered
local inv = getPlayer():getInventory()
for i = inv:getItems():size() - 1, 0, -1 do
local item = inv:getItems():get(i)
print(item:getFullType())
end
filtered
local inv = getPlayer():getInventory()
for i = inv:getItems():size() - 1, 0, -1 do
local item = inv:getItems():get(i)
if item:getFullType():contains('Worm') then
print(item:getFullType())
end
end
thank you

I want to turn this game into the Sims
I tried to do this through imagur and it didn't work
I'll just leave this here.
https://steamcommunity.com/sharedfiles/filedetails/?id=3262742704
Use Github and you don't need to copy the video link in a special way
I don't know how to embed from Github
I see no option
You open the image, then open the source image in another tab and you'll have the link for it
I did a guide for that I believe on the modding Discord
No I didn't
I will do it later today
But yeah you need the raw link of your image and video
Video is a bit annoying to do
Also I believe imgur does work
I did use it
What did you put for the bbcode of your video
I'm not sure
But I copied it straight from imgur
This is the video I'm trying to do it with
But I just can't for the life of me get it to work
some more bags ive been working on
An example with imgur
[video mp4=https://i.imgur.com/dAvvzEL.mp4][/video]
[Img was there instead of video
The reason it didn't work ?
Possible
An example with github
[video mp4=https://github.com/SirDoggyJvla/Susceptible-Overhaul/raw/main/images/natural_drain.mp4][/video]
That link requires a bit of a trick to get
Bcs for images, if you open the source image it gives you raw link
But for videos if you open the video in another tab, it downloads it
So what you have to do is copy the link to the video, and in that link there's a part you need to modify
Bcs the link won't give the raw,.it will give smthg else
So where the raw is supposed to be, you have to modify the link to replace the part that took its place
Hi, I am in the process of creating the Undead Stalker trait. In this function, I want panic, fatigue, and stress to be reduced to 0 when I have this trait, but it is not working. Here is my code:
Anyone able to hook me up with an example of how to call a function on the client from the server?
I read earlier that it's possible, just not too sure how to actually do it ๐ซ .
-------------------
-- server file
-------------------
-- table of arguments to send to the client
local args = {}
sendServerCommand("MyMod", "MyCommand", args)
-- if you have a specific player to send it to, use this instead
sendServerCommand(targetPlayer, "MyMod", "MyCommand", args)
-------------------
-- client file
-------------------
local function handleServerCommand(module, command, args)
if module ~= "MyMod" then return end
if command == "MyCommand" then
myFunction(args)
end
end
Events.OnServerCommand.Add(handleServerCommand)
Woah, now that's an example! Thank you a lot :)
Please optimize this game
How does the case-senstive file system affect mods on Mac? My mod doesn't appear to work on Mac (items don't show up in item list), and I'm not sure where to start to fix it
All the files being refrenced and such in your code needs to have matching capital and lowercase letters, they need to be referenced exactly as the file is named
Oh ok, that's what I figured too. I've made sure that everything is referenced correctly, but found no discrepancies. Is it possible for the problem be the names of my scripts, lua files or folders? Here is a preview of my file/folder structure. I can also share my code if it helps
Sounds good, thank you so much! Here are my files shared to pastebin:
Distributions lua
https://pastebin.com/pkqrQskZ
Items script
https://pastebin.com/JBHNdjCn
Models script
https://pastebin.com/bEjma69b
Recipes script
https://pastebin.com/FMa4Bh7Z
anyone know where to find the scripts for the military duffel bag and medical bag? they are not in with the rest of the backpack scripts
perhaps in containers or containersnew
The Media folder should be lowercase
Ahhh thank you!! I will try that!
Wait wait..?
They're case-sensitive about it?
Unix is
didn't they patch that out ages ago?
I've only ever modded under build 41 and it's been a thing I've had to deal with
you should be consistent anyway but it should ignore case
because it was causing so many problems
it would've been one of the last patches of b41
so around a year and a half ago
yeah, it was the very last major patch actually
- When sorting the relative paths of scripts and Lua files to determine load order, the relative paths are first converted to lowercase. This is to fix platform differences breaking checksums in multiplayer. It also fixes the issue where the same file might be loaded more than once if mods use different capitalization for the same file or folder.
Sorry, I guess that was outdated advice. Case sensititivity was patched.
Your mod also tested fine on Linux on my end.
@wet sandal
ayo
Finally got around to tryin this
DMs or here for code chat?
Errors and such
Either is fine iwth me
Oh ok, thank you! Glad to know itโs fine on Linux too
Okay in NotlocControllerNode you have problematic decorations of onJoypadDirRight etc.
Here you forward a UIElement as input to that function:
But that function expects joypadData
(et cetera)
the ui element is taking the place of self
Doesn't work
But yea, I need to get the joypad data
When it gets forwarded to functions expecting valid joypad data, it is possible they'll get nil instead.
Did someone say UIElement? :D
And when they do you trigger errors that are not possible following vanilla convention
You must pass the exact form of variable these vanilla gamepad functions expect or they will get pissy fast
@wet sandal I'm currently documenting the ISUI library and just did most of ISUIElement.
In the case of the error I saw, self.og_onJoypadDirRight(self.uiElement) led to an error because self.uiElement was nil instead of joypadData
Need to figure out how to reliably pass the expected data here. Odd to be called from a function receiving dx, dy... Hmmm.
Does a NotlocControllerNode reliably have a player controller index?
You can use the controller index to grab the correct joypad data object
But I do not know exactly what's available in this module at a glance. Seems its fed joypad data from an external file..
Yea I think I've got it fixed uploading now
Sorry, didn't realize that those functions had a param
The vanilla ISInventoryPage was my base
No worries, this controller code can be a bit hard to follow.
This might help. I researched as much as I could into the joyData stuff.
It looks like there's legacy fields for ISUIElement.
Check out zombie.input.JoypadManager
Also ISPanelJoypad explains some things, and JoyPadSetup explains others, and ISButtonPrompts explains yet others.
Oh and the sub-class Joypad in there.
I don't think we can do anything with JoypadManager... I've tried using it iirc.
Thanks. I'll take a look at that for myself.
No I mean the object Joypad is passed IIRC.
I see I don't remember finding or trying Joypad specifically. I think I saw functions in the Manager I wanted but couldn't access them but I'm about to test it
Might be worth documenting this @red tiger
--- Triggered when the down-direction of the arrow-pad of the joypad is pressed.
---
--- @return void
function ISUIElement:onJoypadDirDown() end
--- Triggered when the left-direction of the arrow-pad of the joypad is pressed.
---
--- @return void
function ISUIElement:onJoypadDirLeft() end
--- Triggered when the right-direction of the arrow-pad of the joypad is pressed.
---
--- @return void
function ISUIElement:onJoypadDirRight() end
--- Triggered when the up-direction of the arrow-pad of the joypad is pressed.
---
--- @return void
function ISUIElement:onJoypadDirUp() end
These functions are actually being called by the game with a param often referred to as joypadData
joypadData's contents:
Thanks. Looking into it.
@thick karma Fix uploaded, should properly ferry the joypad data through now
Good catch there!
BTW I started a long-term project working on third-party documentation for the API of the game.
Oh, joypadData is also present after button in ISUIElement:onJoypadDown
I wrote a webpage that makes it easy for me to document the game's API. Will be crawling over things over time.
can i disable some of these somehow?
You know what would be a cool thing to add? Ziplines and those rope hooks that can be thrown to a roof and used to climb up
Go from roof to roof like this ๐
is there a trigger for when a repair finishes?
Would anyone like to take a look together with me and try to figure out why I can't call a function from the server to the client?
Here's the code for the Client: https://pastebin.com/D1s3NH0T
And here's the Server: https://pastebin.com/sH54LxaU
I think I must've done something stupid, just not sure what ๐ .
Honestly? I have no idea
That's just me saying "random BS, GO!!" and trying out things I think might work
i'm pretty new to this myself
I think my reasoning was that the array will contain the arguments you pass onto the command you want to send
so i dunno if it even changes anything
But that's probably wrong
When does the Event OnGameStart fire on the server?
I suspect that might be the issue.
- Does it actually fire on servers?
- If it does, is the client connected to receive the command at this point?
First off
ZombRand(min,max) --exists
Secondly OnGameStart doesn't fire server side:
https://github.com/demiurgeQuantified/PZEventDoc/blob/develop/docs/Events.md#ongamestart
Mint, I needed this myself
maybe i'm misunderstanding, but having an array even with false in it will return true
I really wish that PZ didn't force everyone to use a high-quality PRNG.
Here you check that args exists, so since the table exists it will return it
Yeah well, deal with it lmao
true. my next point was gonna be this, because i type slower than molasses
{true} == true means false
I believe that will break because you compare a table to a boolean
that's what trog is doing
Nope. I mod the game's core.
Hmmm, so what do I do regarding the array? How do I pass arguments to the client from the server?
Let me check that again
Also that's a complete missuse of args
server line 1
client line 49/53
client line 3
You can send args = nil and it will work if you just want a check for your command
You don't need to send table data to send a command.
yea that's my point
i'm trying to say that client line 3 will always return false, no matter what server line 1 reads. acidrain will never run
or am i misunderstanding how lua works
because i might, since i'm brand new to coding in general
First off: please change MyMod and MyCommand
-- client side file
function HandleServerCommand(module, command, args)
if module ~= "AcidRain" then return end
if command == "AcidRain_start" then
AcidRainDamage(true)
end
end
Events.OnServerCommand.Add(HandleServerCommand)
-- server side file
function AcidRainEvent()
getClimateManager():triggerCustomWeatherStage(WeatherPeriod.STAGE_TROPICAL_STORM, 12)
sendServerCommand("AcidRain", "AcidRain_start", nil)
print("Acid Storm active.")
end
Events.OnGameStart.Add(AcidRainEvent)
Secondly: don't make your function global so:
First off: please change MyMod and MyCommand
-- client side file
local function HandleServerCommand(module, command, args)
if module ~= "AcidRain" then return end
if command == "AcidRain_start" then
AcidRainDamage(true)
end
end
Events.OnServerCommand.Add(HandleServerCommand)
-- server side file
local function AcidRainEvent()
getClimateManager():triggerCustomWeatherStage(WeatherPeriod.STAGE_TROPICAL_STORM, 12)
sendServerCommand("AcidRain", "AcidRain_start", nil)
print("Acid Storm active.")
end
Events.OnGameStart.Add(AcidRainEvent)
So I could do sendServerCommand("MyMod", "MyCommand") in the server and then:
if module ~= "MyMod" then return end
if command == "MyCommand" then
AcidRainDamage(true)
end
end```
?
Yes, check the code snipet I just sent above
Ah, I think I get it now. Thank you :)
Remember to replace RandomInt(maxValue, minValue) with ZombRand(min,max)
I had no idea that function even existed. Where do you people learn all of this?
declaration: package: zombie.Lua, class: LuaManager, class: GlobalObject
This devilish place which you need to learn how to use
#mod_development message
i'm still curious as to if it'll run at all