#mod_development
1 messages ยท Page 53 of 1
Is there a "OnEquipPrimary" But for clothes?
Havent found anything yet in the wiki and vanilla lua files.
There's two equip actions, from context and from double click
Okay, just looked into the mod i subbed today "ExQueaseMe" and it seems like he is using a event i might can use. Which is called "OnClothingUpdated"
keep in mind onclothingupdated isn't only called by equipping, it's also called when dirt/blood levels change
depending on what your code does this isn't a big deal
Good to know, thanks
But i have to check if the player wears a specific item anyway, so it shouldnt conflict.
You could tie into the timed action for equipping
That would probably be the more efficient way to do
Which event i would use for that tho
It's not an event persay
media/lua/client/TimedActions/ISWearClothing.lua
You can overload the timed action
ISWearClothing:perform() is likely what you're looking for
function ISWearClothing:perform()
self.item:setJobDelta(0.0);
if self:isAlreadyEquipped(self.item) then
ISBaseTimedAction.perform(self);
return
end
self.item:getContainer():setDrawDirty(true);
if instanceof(self.item, "InventoryContainer") and self.item:canBeEquipped() ~= "" then
self.character:removeFromHands(self.item);
self.character:setWornItem(self.item:canBeEquipped(), self.item);
getPlayerInventory(self.character:getPlayerNum()):refreshBackpacks();
elseif self.item:getCategory() == "Clothing" then
if self.item:getBodyLocation() ~= "" then
self.character:setWornItem(self.item:getBodyLocation(), self.item);
-- here we handle flating the mohawk!
if self.character:getHumanVisual():getHairModel():contains("Mohawk") and (self.item:getBodyLocation() == "Hat" or self.item:getBodyLocation() == "FullHat") then
self.character:getHumanVisual():setHairModel("MohawkFlat");
self.character:resetModel();
end
end
end
triggerEvent("OnClothingUpdated", self.character)
--~ self.character:SetClothing(self.item:getBodyLocation(), self.item:getSpriteName(), self.item:getPalette());
-- needed to remove from queue / start next.
ISBaseTimedAction.perform(self);
end
local original_ISWearClothing_perform = ISWearClothing.perform
function ISWearClothing:perform()
--do stuff before
original_ISWearClothing_perform(self)
--do stuff after
end
The problem with some stuff is that it may not return an object or results that you can safely change and pass on
Thanks man!
I try that out
function ISWearClothing:new(character, item, time)
local o = ISBaseTimedAction.new(self, character);
o.item = item;
o.stopOnWalk = true;
o.stopOnRun = true;
o.maxTime = time;
o.fromHotbar = true; -- just to disable hotbar:update() during the wearing
if o.character:isTimedActionInstant() then o.maxTime = 1; end
return o;
end
You could try to apply a variable here to check in perform
Depends what exactly you're trying to do
Basically i just want to check if the equipped item is the dress i made, if the character is a male and strength is above 2 the dress will be removed and instead you will get some ripped sheets ๐
So far my plan, but one step at a time.
Alright, thanks!
Nice, you got it working
Hello everyone ๐ Quick question, does the following code look correct for getting the items in a players inventory? I am getting an error when I try to run it
local playerInv = getPlayer():getInventory():getAllItems()
change getAllItems() for getItems()
Oh, silly mistake
I am trying to use this resource
declaration: package: zombie.inventory, class: ItemContainer
Just learning my way around.
Thank you so much
Hey does this Error matter or no? ERROR: "media/maps/Basements/spawnpoints.lua" doesn't exist, spawn points may be broken.
[3:29 PM]
I have Basements mod but wasnt sure if this was a big deal
this resource is more up to date https://zomboid-javadoc.com/41.65/zombie/inventory/ItemContainer.html
Javadoc Project Zomboid Modding API declaration: package: zombie.inventory, class: ItemContainer
Cheers Albion, I will save that
wiki says it's v41.77 or is some error?
i didn't hear if it was updated
well the person who changed that on the wiki is a tis employee, so i'd say it's probably accurate ๐
disregard then
anyway, I don't think it matters, I mean, not much has changed
actually i noticed the other day that the official one has variable names
i accidentally ended up on there and assumed it was always like that, but i guess it's new actually
that makes it a lot easier to discern what a lot of functions are supposed to do/what the arguments are actually supposed to be, so it's quite a bit better
not sure if you're still reading this but disregard that actually ๐
so the other docs are updated finally?
looks like it
did anybody even know this? i never heard about it and evelyn seems surprised too
having a decompile is much better in any case, there are several functions that are hidden in the documentation
if the wiki was updated at the same time then this update was already a month ago
i'd say having both is best, the javadoc is much easier to search
I check the wiki from time to time to get something quick, it's at least 2 weeks old I think
definitely yes
When I look into the templates for vehicle parts that vehicles use they always refer to another template inside them. What and where is this file?
For example The Template_engine is refering to template vehicle Engine.
it's defining the template
OOH
that makes so much more sense lmao
I cant believe how braindead I feel sometimes from this
looks awesome
fingerprint is fitting like a glove
what does a template with a "!" mean?
template copies parts, template! loads the entire script
specifically it copies areas, parts, passengers and wheels
so you can use another vehicle using template! ?
from what i'm reading yeah
i look forward to finding out what spams my logs with stupid shit without having to search
i presume that's what it does by the name

when adding events, what options are there?
Events.EveryHours.Add(functionHere);
is there one for every day?
Thanks
https://pzwiki.net/wiki/Modding:Lua_Events is mostly up to date

Question, does onSeeNewRoom triggered only once for each room? Aka if it's multiplayer server, and different characters explore same room, will it fire up once for each character exploring it or only once per server for each room?
https://pzwiki.net/wiki/Modding:Lua_Events/OnSeeNewRoom
from description if I undrestand correctly it's once per server/save, right?
it sounds like once per save
thanks
hell yeah
:)
Whats the lua event for thing im writing
A tile will have a certain moddata
And it increases overtime
If a player isnt present im sure it will stop
So i have to be able to capture the time and compare it to the time someone sees it again
Should it be ontick playermove or something else
Probably not onloadgrid?
Load grid is fine but a better event would be when they actually interact with it
Then you don't even need the loop
Ow i guess im forced to learn context menu then
What are you trying to do again?
Oil Derick that produces unrefined oil
Then convert it from the refinery into petrol which will then refil gas stations
Theres an event i recall
Something like
Oncontainerload
Or
Inventoryload
Idk
Something like that
Maybe that will work
So once the player access it it then calculates time
And then adds stuff on the container
Making it easier
I have a mod commission for any dev in here, zombie camouflage. There's already a mod for it but it's outdated and doesn't work in MP, went to see the mod's dev and they told me that they couldn't update it because of college and stuff but I'd like to add it to play with friends
Is it possible to use DoParam to edit a specific item in the players inventory?
OnRefreshInventoryWindowContainers
doparam is used to edit an item script, not an instance of an item, but most of those properties have their own setters on the instance
i.e. instead of Item:DoParam('DisplayName = foo') you can do InventoryItem:setName('foo')
Ah this is the permanent edit to the item right?
Can you modify the fulltype with doparam?
Cuz if you could then you can write entire items using lua as you have dummy items to edit
Gotcha thank you.
Makes sense
I thought that even if a java object wasn't exposed, as long as you could get one from the code somehow you could still manipulate it, but that doesn't seem to be the case. Trying to call isSet(IsoObjectType.lightswitch) on a ZomboidBitFlag is giving me Exception thrown java.lang.RuntimeException: attempted index: isSet of non-table: zombie.ZomboidBitFlag@4b85edeb at KahluaThread.tableget line:1689
if I'm reading this code right, calling this should tell me if there is a streetlamp on a tile, I'm not sure if there is any other reliable way to do it
are there any good up to date tutorials on making mods?
not sure what you want to mod
https://pzwiki.net/wiki/Modding
the guide by Fenris is good
I'll check it out, thank you.
I started getting into modding around December 2021 or so, but never got it quite right. I added a new recipe book. Functionally the item worked as intended when I spawned it into my inventory, but I couldn't get the darn thing to actually spawn in naturally in the world. I had a mod that tweaked stats of some items, but it broke sometime after 41.53. I'm interested in doing a variety of stuff, but nothing too crazy. Mostly vanilla-friendly tweaks.
Hi there, just to let you know https://zomboid-javadoc.com/ is going to expire on the 23rd of december. If you're using the website please consider making a donation on my ko-fi (see my discord profile) so that I can pay for the renewal. If no one cares, I'll let the domain expire and the website won't be available anymore.
You can still use those reflection APIs on java objects whose classes are not exposed (but can't invoke methods outside of debug mode, as usual)
You can only really read fields in non-debug mode
Could you use free domain, e.g. zomboid-javadoc.tk?
cant help notice the irony of a site offering free domains that doesn't support https on their site (which they can get for free from letsencrypt)
Well technically it can be done by anyone, it's just a CNAME entry. Problem is referencing wouldn't be as good, also it would break people bookmarks, pinned messages, and wiki entries. But to be honest I don't really care, I'm not modding pz anymore.
Hi @quasi geode, good to see you ๐
hey m8 glad to see your still around(ish) lol
What's up? Still waiting for a stable pz release to update ORGM? ๐
nope, retired. handed the mod back to the original author so he could find a new maintainer
so you're done with pz modding too? ๐
ah extended break. still here apparently but not actively modding atm
I see ๐
so what are you up to these days?
i can take over the hosting and the domain if that is a thing you would support and/or facilitate
of course, but just the domain is needed, hosting is done on github
I can transfer the domain to you
i'd prefer the full package so it does not rely on github. i'll throw it on a webserver i already have so it's no issue at all to host it too.
are you in a position to dump the full site into a package?
but then how will I update the javadoc for new release? With github I just have to do git push and it gets published
you did not (visibly) update the site since the 65 javadoc and you also said above you were done with the whole modding topic. i did not expect you to want to continue updating the doc. if you do, that's fine, and i'll just take over the domain.
well I'm done with modding as in I don't write mods anymore, but I'm still willing to update the javadoc (and yes I've been lazy and couldn't find the proper motivation to update the javadoc since 41.65 ๐ )
alright, then let's transfer the domain over to me and i'll pick up the tab this year. with 78 getting its "final" hotfix very soon, could you update the doc for that version, too?
sure
@sharp fulcrum please let me know what credits I should add to the index so people know it's you who's paying for the domain
let's get the domain transfer taken care of first, so it does not expire. dm me about the rest of the process!
As far as updating the javadoc, could send PRs to the github repo or could also give him push access if he would update the java docs. Could delegate the work that way
what would be the point of sending PRs to a repo where I can already push on the main branch?
I mean, if you wanted to do that, go ahead. Guess you can give yourself feedback ๐
I was suggesting bknht could send you a PR
Or could give him push access
both as options to offload the work of updating the javadoc (with different amounts of involvement on your part)
I wouldn't mind giving push access to bknht but I'm not sure he'd be willing to do it, otherwise he would have already setup his own javadoc website I guess ๐
i am more interested in preserving an essential community resource than i am interested in maintaining it
what's up @sour island ?
Just saluting an old friend
You have some great mods - also I assumed the javadoc was integrated into the mainsite
Or was that doc just updated for that time?
come on, I'm not that old ๐
could you show me where? I can't seem to find it
More so it will be a loss of a creative modder.
well that's the website I made ๐
for which I just transferred the domain name to @sharp fulcrum
Oh so it is, wow - I mistook it for the official lmao
hehe ๐
Could maintaining it just be a matter of dumping in the games files and running a GitHub Action?
I wouldn't mind doing that once and a while
it's a bit more involved that than, first you have to decompile the game files, then remove decompiler remnants from the decompiled code, then running the javadoc command
also with latest pz releases the trick I was using to generate the javadoc is not working anymore
like:
error: package exists in another module: jdk.unsupported
package sun.misc;
Could that be causing it?
yes
I'm doing my part
hum except they switch to 17 not 18 if I'm correct
I think you are, but I use 18 for my stuff and it doesn't seem to be an issue
yeah probably not an issue
I use the decompiler from intelliJ, they have a jar file that you can call from the command line
IntelliJ or PZ?
intelliJ
It translates what's exposed from decompiled Java into a Lua file that allows you to auto-complete while writing Lua
oh I see
It's the thing Yooks wrote - idk if you remember/were in that group?
Possibly, Konijima wrote an updated/clearer guide on how to use it
@sour island so you're writing your mods using IntelliJ?
Yessir ๐
Couldn't do it otherwise
My old method pre-EHE was rooting around the files one by one guessing based on file name
of course you could ๐
I know people use vscode and stuff but I meant keeping all the functions and things sorted out in my mind
Having to at least remember a couple classes or part of the functions name makes modding much less of a headache
Hopefully pzDoc doesn't break anytime soon as I think Yooks dipped at the same time as you came in or during 2020
I've never been able to use an IDE, always been using vim ๐
I've been told intelliJ and such have too many bells and whistles
I haven't used anything else tho
I gotta get ready for work, I'll catch up in abit
@sour island regarding the problem to generate the javadoc, it's because TIS is using the class sun.misc.Unsafe, but the package sun.misc should not be used, and javadoc is choking on it. Wondering how they even compile their game ๐
Hmm
aaaah sweet! Finally found the culprit to generate the javadoc
๐
Out of curiosity, have you just become too busy or just not interested in modding PZ?
been tired of TIS attitude towards modders
You know VSCode autocompletes for us when we open the vanilla files in the background right?
(Not intelligently, but still, does help and save time)
(at least tells you what to search for)
Oh I wasn't aware - like entire functions?
It stores strings from other loaded files automatically somehow
So if I have e.g. the PlayerData file that has getSpecificPlayer in it and I type "ge", getSpecificPlayer shows up fast as one of the likely targets of typing "ge"
But it only does this for files that are currently open
Still that's v useful because I generally know where the files are that have the vanilla functions I'm working on
And often have them open
Yeah, if you can follow the PZ libraries tutorial you'd get the auto-complete for everything anytime
I.e., I don't just remember it all either using VS Code
Good to know tho ๐
That is p. cool though
Might explore that myself, seems convenient
But yeah the VSCode thing is especially helpful if you're unaware of any libraries for autocompleting your code.
Sort of a generic approach that always works to some useful degree
โค๏ธ I don't know you but I have relied often on your JavaDoc. Sorry so many companies lack the wisdom to show proper appreciation for the modders who make their half-finished games playable, but people like me appreciate you. ๐
I get what you mean, as it sometimes feels like we're deep in the back alleys trading secrets- but at the same time it is their project so I can see why they'd be more inclined to actually work on it and not spend time making sure modders have a better time.
Which I think is a shame, because modders are also end-users at the end of the day. And their role also has a net positive on the game retaining players (I'd assume).
But this is all me filling in the gaps, as truth be told - it's not a negative attitude being felt -- just non-interaction tbh.
Although Nasko is often open to ideas, as he's the community guy (idk if that's in his job desc)
And there's red names in here /mapping
thank you for telling me, it feels good to know ๐
I could deal with no support for modders, the problem is more about pooping on the face of people who makes your game more enjoyable (cause you know, who plays pz with no mods? ๐ )
i tried it once and ended up falling asleep - you guys have inspired me to dip my feed in head first this weekend and its quite intimidating with how different things are from whats referenced - the vs code autocompletion helps but understanding is very hard. just wanted to say thankyou for the work you guys do - you guys literally complete the game for me
aww that's so sweet โค๏ธ ๐
you can just add the lua folder as a library in your lua plugin's settings
the pzdoc stuff also sort of works with vsc, but not amazingly - i still end up relying on the javadoc most of the time, it's basically just a spellcheck at this point
Legendary...
any clue how to remove the sick moodle with debug mode (sick aka queasy)?
I tried this but it's not changing the sickness level:
getPlayer():getStats():setSickness(0)```
like the sickness you get from being infected? that's set every frame so you can't really do anything about it
food sickness is separate and can be messed with iirc
yeah the sickness from being infected
it has to be doable cause you can also get sick from spending too much time around corpses, but if you go far from the corpses the sickness goes away
that actually gives you food sickness
as far as i know everything except zombie infection goes through 'food sickness'
well if you do lua getPlayer():setGodMod(true) the sickness will be removed, whatever the reason, so it has to be doable somehow
doesn't that remove the infection too?
it's recalculated completely every frame, so if the infection is removed so is the sickness
ah, I guess I wrongly assumed that if I removed the bite it would remove the infection
hum so I tried this:
getPlayer():getBodyDamage():setInfected(false)``` but character is still sick
you need to make the bodypart uninfected too
Is it possible to convert string to number
tonumber(foo)
๐
okay I am seriously at a loss here. I cant figure out why this isnt working. I created a template for a new vehicle part. If I include this template in a custom vehicle it shows up in the vehicle mechanics. But if I try to use the template in a vanilla vehicle it refuses to show up in vehicle mechanics. Furthermore the custom part has an item and a model associated with it but neither show up when the part is installed on a vehicle
vanilla car with template
custom vehicle. As you can see the part shows up in bodyworks. but even than it still doesnt show its item or doesnt display the model on the vehicle
is the custom part in a different module?
ya, unfortunately the fields aren't very useful in that class. Not the end of the world, I think I found another way to do it
Does anyone know if it is possible to make new attack animations for the player character and add/replace them in the game?
yep
What languages does pz use for modding?
I want to try learning how to make said animations in blender, but I have 0 Lua knowledge. Good to know it's possible at least.
Lua mostly.
any other possible ideas?
I'm going insane. Does anybody have any ideas?
Currently trying to make Lantern compatible with the new Better Batteries system, but for some unknown reason it just refuses the OnTest??
What's strange is that the console is printing that the battery can be removed, yet the context menu for the recipe just... doesn't show up.
I know for a fact it's not referring to the vanilla method because it's printing this in the first place.
Not to mention that the Better Flashlights patch works fine??
Literally the only problem is the fact that you can't take dead batteries out of the lantern despite passing the OnTest method.
Lantern uses the vanilla TorchBatteryRemoval OnTest method, but this is overwritten and fixed for Better Batteries.
My code is simply
function Recipe.OnTest.TorchBatteryRemoval(sourceItem, result)
print("Battery can be removed:")
print(not sourceItem:getModData().batteryRemoved)
return not sourceItem:getModData().batteryRemoved
end
Unless I need to wrap it in parenthesis, which I highly doubt seeing as it works with Better Flashlights.
The recipe for the battery removal is just..
recipe Remove Battery
{
keep LTN_SL.Lantern,
Result:Battery,
Time:30,
OnTest:Recipe.OnTest.TorchBatteryRemoval,
OnCreate:Recipe.OnCreate.LanternBatteryRemoval,
}
wh, it doesnt work with vanilla flashlights either
Is it a load order thing?
Better Flashlights still works fine though..
Okay so for some reason it works with one vanilla flashlight but not the other??
im going nuts
welcome to project zomboid modding ๐
Sorry, that sentence was a low hanging fruit!
Naw it's quite alright hehe
I know this is usually pain but c'mon
Its like the game is literally picking and choosing what works and what doesn't.
I am in the exact same boat. I cant figure out what I am doing wrong at all.
I found out that only some of the Better Flashlights flashlights work, the rest just, don't??
Seemingly at random.
They all index the same exact test methods.
could be related to a recent patch? I remember reading something about batteries?
Remember that pz is in active development, things always could change
A g o n y
I'll look through the patches but I don't recall seeing anything recently at least.
A few weeks ago something similar also happened to me, but here told me that some things changed in TimedAction
Hm.
I'm not entirely sure what a TimedAction change would cause in terms of recipes though..
Like I know it's used but, what would that change in terms of OnTest and OnCreate methods?
Oh no, that was a particular thing to happen to me, not related with your current issue
Ah.
Even then, I know my recipe code for the Lua side is up-to-date because my Zomboid is also up-to-date so it's like
???
I swear I'm not crazy yet
yet
I don't even know where to start looking to fix this, inserting batteries works fine.
It's removing them.
If anyone has any ideas please let me know, I have no clue.
Can you remove batteries normally?
I thought you had to let them drain
Also haven't read any context
This is for a mod
Batteries can ordinarily be removed as long as charge is present
This mod adds modData to electrical devices like Flashlights to detect if a battery is in them independant of current charge, allowing one to remove dead batteries and potentially recharge them.
Problem is it just doesn't work for battery removal if the charge is 0???????
And since a battery is already in it, it won't let you insert a new battery either.
I've already checked if it's using the legacy method by throwing a print statement in zomboid's lua files, but nothing came of it.
@bronze yoke I finally released it.
https://steamcommunity.com/sharedfiles/filedetails/?id=2891623922
nice!
lol now I just hope it works for everyone like it has been locally so I can stop thinkin about it for awhile
Now I'm humoring combat animations.
That seems like it'll take more work but damn it I need more than swing left swing right
Still this mod was a big hurdle for me
Making this animation and triggering it properly is a step toward weapon animations for me.
Anyone experienced in vehicles with custom armor parts willing to help me out a little bit?
what do you need help with?
still the same issue from earlier today
^^
custom templates dont appear on vanilla vehicles for some reason
And my custom vehicle parts arent being linked with the item I assigned them
I tried reaching out to ki5 and some of the autotsar devs with no luck. I know no one else that does custom parts for vehicles
i've done what you're trying to do before, i just don't know why it isn't working, it looks fine to me
could it be the file structure?
all my script files are in the scripts/vehicles folder
including the items and the model definition the template is pointing to
i don't think subdirectories have any special meaning
file names dont matter either right? every script file gets loaded no matter its name
Well I dont feel like its justifiable to bang my head against the wall because of this anymore
guess I am giving up unless someone has any other ideas
Is it possible to create a recipe purely from lua
getScriptManager():getModule('Name'):ParseScript('script string') probably does that
dunno if it's right for my server (we actually kick people who are AFK too long) but i 100% can see this taking off and getting ur name out there more like u deserve
grats
great idea
you might consider putting a submod that just adds the animation as an emote to catch an even wider net (we'd use that)
i look forward to seeing what you might do with animations going forward 
I could 100% do a custom-animation-only version if you would want to use it. Wouldn't take too much time to just remove the code that does quirky mechanical stuff.
I could in theory even just extend the mod with a sandbox setting to prevent the other mechanics.
There is already 1 sandbox setting for allowing everyone to meditate, vs only allowing yogis to do it
I might make it so the red little error box is a button that you click and it shows you each unique error neatly with the mod ID and call stack
Would this be something useful / already done?
Half the battle of bug reports is educating people how to access the console log - and then they clip the error is half anyway
Kind of a pain in the ass
yes please
I would definitely use this in debugging if it were faster and cleaner than the built-in debug screen.
I instinctively click the thing even though it does nothing
because it really should
Resizing the debug windows every time is so tedious
that would be intensely helpful
as a server operator and modder
both
would let me check errors on-the-fly and help users send me errors better..
that sounds great
not having to open the log during gameplay would be great even as a dev/server op
Alrighty, just wanted to check in - I assume it's not been down before?
not that i've seen but i haven't gone looking
what is ur thought, make it pull up the f11 error list thing?
if so that's sometimes incomplete errors too
(for some reason, i have no idea why)
still useful tho
Well with the print() thing I messed with the call stack info
I think I can just hijack what it sends to the console and have it in an array instead
List unique errors + the copy count
nice
Ideally make a copy to clipboard button
users can screenshot if that's not doable
u can 100% make it selectable tho if u can't do the clipboard from the game
From UI?
(there's a chance they sandboxed that or there's just no function)
I could make a text input window
To have it selectable
yup
that way if u cant write to clipboard
good workaround
can even put instructions for totally noob users
how to copy
<_<
Id probably make a chart if the call stack runs through different mods
I've gotten reports cause of another mod handling the same function as me
And they named their file something generic
Where as mine had the mod name on it
Punished for being a good boy ๐ญ
Is there a way to reverse / cancel climb sheet rope, do you edit animation or timed action?
yeeah
You could probably mess with timed action - canceling fence climbing would be a good addition too
that reminds me, has anyone made a mod that changes the default order of actions when you spam "use"? For example, when I'm trying to quickly escape out a window I'm not a fan of my character closing the window instead and getting eaten
on the flip side, maybe jumping out the window shouldn't be a hotkey at all if your on the third floor
Anyone know why there arent any new meshes for zombies? Is it hard coded/difficult to include?
I think people have made zombies with different bodies by making special clothes for them, but the base model seems to be untouchable
Good work around. So I guess copy the coverall item and replace the mesh and textures with something else?
I imagined thatd be a clipping nightmare
Idk I havent touched pz modding yet but Ive been eyeing it for a while
I haven't done any of this, just read about it in patch notes and stuff, so take it with a grain of salt, but I believe the base mesh is divided into portions that can be hidden to prevent clipping issues
yeah you can just mask the whole model
how does PZ create fog effects? I know there is climatemain.lua, but ... how does it produce fog visually? it is a texture?
or is it a particle
Modding for pz weirdly looks pretty difficult
I read skimmed through the tutorials
Tbf I dont even know where to begin, I only know how to create meshes
Is the ability to change the main menu music a thing? Also for the death music?
I remember there were mods back then allowing both menu background changes and music too, but i heard its like not possible (?) now
Asking because I kinda wanted to make a few mods replacing those things
there are mods that replace the menu music, but they require users to manually replace files
i think death music can be done normally though?
thats what i was afraid of, at that point id rather just make some replacing the death one
if you can replace it and it works for everyone obv
i also remember there were a few mods on steam that actually full on replaced the music ingame and didnt require someone to do it manually etc..
again tho i think that ability is all gone now
So- With the tag system that was added back in like april, does anyone know if there is a way to add custom tags in the game right now?
yeah, you can just put whatever you want
Hell yeah.
That is super helpful lol, thank you kindly! When using the check for the items, if I am using them in a recipe and they have a depletion value, how would that be taken into consideration?
Like, if I added a tag for cooking oils, and spliced that into different mods. Because they have their delta values, would I still be able to check for an item with the oil type, and use 1 delta's worth? Independent of the type of Oil used
i'm unsure, but probably yes
sweet. I appreciate the help <3 thank you!
have they broken the tile picker in recent versions? Trying to put some tests together but even with the brush tool enabled selecting stuff from the tile picker doesn't give me the option to place it
Did you set up your mod info correctly? making sure to reference your .pack and tiles files?
just placing vanilla tiles
Oh-
Lmfao...
Sorry haha, just ran into an issue with that recently and brain defaulted
there may be something wrong with my tilepicker, I have a bunch of categories for stuff like "TileThuztorRugs" that are completely empty
Anyone know what that tiny red error box is referred to as?
hey @bronze yoke ! do you think you could show me a version of that item dummy replacement code that works on normal containers?
it turns out that if you develop a mod exclusively using extremely low sandbox loot settings you don't notice that having too many items makes a bajillion things drop on higher loot settings even when you try to mitigate that
oh of course!
i was actually going to post some snippets like that to github but i totally forgot about it... luckily i already finished that one in particular
-- list of items to replace the dummy with
local itemList = {'Base.Orange', 'Base.Pear'}
local function replaceDummies(container)
local dummies = container:getAllType('Base.Apple') -- dummy item type
for i = 0, dummies:size()-1 do
container:Remove(dummies:get(i))
local itemChoice = ZombRand(#itemList)+1
local item = container:AddItem(itemList[itemChoice])
container:addItemOnServer(item)
end
end
-- for items in containers
local function onFillContainer(_roomName, _containerType, container)
replaceDummies(container)
end
Events.OnFillContainer.Add(onFillContainer)
thank you very much! :) time to entirely replace the loot distributions with this instead because there simply is no way to balance adding 1000 items to the same container
question: does anyone know if there's a way to disallow decimals in sandbox values?
like for a number entry? use type = int
yup! awesome, thank you
oops sorry that's type = integer
Isn't there a way to organize data in the loot tables so only one item drops? I vaguely recall it working that way when I skimmed through the java code that rolls for item drops (Maybe I'm thinking about a different random loot mechanism, like attached weapons drops)
it's possible, i never actually looked into anything like that since i adapted this system from a vhs spawn thing i have for my literacy mod, which absolutely necessitates this since vhses aren't separate items
Hmmm can't seem to hijack exception throwing
if such a thing exists, i'd love to know!
hmmm DebugLogStream hmmm
--formatStringVarArgs(DebugType0, LogSeverity1, Str2, Obj3, Str4, Obj5, Obj6, Obj7, Obj8, Obj9, Obj10, Obj11, Obj12, Obj13)
local DebugLog_formatStringVarArgs = DebugLog.formatStringVarArgs
function DebugLog.formatStringVarArgs(var0, var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13)
print("TESTING: ",tostring(var0), tostring(var1), tostring(var2), tostring(var3), tostring(var4), tostring(var5), tostring(var6),
tostring(var7), tostring(var8), tostring(var9), tostring(var10), tostring(var11), tostring(var12), tostring(var13))
DebugLog_formatStringVarArgs(var0, var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13)
end
wish me luck
its obvious what they all do ๐
LogSeverity logSeverity,
String prefix,
Object affix,
String format,
Object... params)```
the updated javadoc is pretty handy
tried:
local DebugLogStream_printException = DebugLogStream.printException--(Throwable1, String2, String3, LogSeverity4)
function DebugLogStream.printException(Throwable1, String2, String3, LogSeverity4)
DebugLogStream_printException(Throwable1, String2, String3, LogSeverity4)
end
both aren't actually exposed it seems
LOG : General , 1669085886252> -------------------------------------------------------------
attempted index: printException of non-table: null
DebugLog_formatStringVarArgs doesnt seem to print anything tho
Can you make a new saw, but also have it be a weapon?
yeah, an item's use in crafting is mostly independent of its type
Would it be too OP to have a weapon also function as a saw and axe?
Can't seem to find a way into error tracking
Has anybody managed to get leads of OnTests failing or nada
It feels like I've been banging my head against drywall for hours
OnTest like recipes?
Yesyes
Sorry Im late Ive been working on other things
for some unknown reasons my OnTest for the BatteryRemoval just.. fails to register to the system or something..?
I had a print statement set up in the function, as it was supposed to overwrite vanilla, and the print statement does its thing just fine.
So I know for a fact it's firing.
It just doesn't.. do anything?
For some reason?
And it just likes to pick and choose what items work and which ones dont, seemingly at random.
One vanilla flashlight works, other one doesn't. Some Better Flashlights lights work, some don't. Lantern doesn't work period.
And yet they all use the vanilla method that I'm currently trying to replace.
So it makes 0 sense that some work and some dont.
SNIPPET: create java Array(?
local arr = array.new();
print(arr) -- []
array.push(arr, "Test")
print(arr) --[TEST]
////////////////// array functions //////////////////
metatable.rawset("__metatable", "restricted");
metatable.rawset("__len", new UserdataArray(LENGTH));
metatable.rawset("__index", new UserdataArray(INDEX));
metatable.rawset("__newindex", new UserdataArray(NEWINDEX));
metatable.rawset("new", new UserdataArray(NEW));
metatable.rawset("push", new UserdataArray(PUSH));
I don't even know if it's an OnTest problem anymore.
I just decided to try an experiment that, guess what, failed.
Forcefully set all recipe onTests to a separate, custom onTest, and nada.
I'm going insane.
It's printing and returning the correct data, so why isn't it working
Drain* ๐คญ - im rooting for you
I RAN INTO THIS EXACT SAME PROBLEM LAST TIME
- small question do folder names matter when structing the mod or is all based on convention ? as im looking around it seems everyone has a semi diffent way of doing it
I HAVENT LEARNED DIDDLY SQUAT
I think for some it matters
Stuff like media, lua, server, shared, client, etc
Generally speaking it's the folders that matter mostest
^ yeah i think i understand that much but inside that do the folders have to specifically reference the function its accessing or is that just for legibility?
that much im unsure about
alright thanks for the guidance lol ill keep smashing my face into the keyboard until something pops up in game lol woo!
Felt that
yeah, vanilla structure up to client/server/shared need to be same, though they did patch capitalisation.
After that you can just have everything in those folders or add more folders.
Anyone know which events triggers on weapon swing, but right before swing and after hit?
We already talked about this, didn't we?
Not really compare to multi tool ๐ like an item that can do all that anyother tools do
But if u want ideas that are op
Try a pencil that can destroy wall like any sledgehammer.
i think the eraser would be more fitting lol wax on wax off
Hi, is there any events for "Player A kill another player"?
can someone please explain to me these?
I am guessing complete is defining what lua function the game should execute when the uninstallation of a part is complete right?
For all the other things I have no idea what they do and when they are triggered
okay so from my understanding from looking at the lua functions.
Hmm probably OnWeaponHitCharacter event can help you, You would only have to validate the health of the victim player
create is triggered when a vehicle is spawned.
init I am still not sure
update is just done regularly on a cycle every however many ticks.
Use is for whenever I interact with that part. So lets say when I use a trunk it makes the trunk container accessible
do I understand this correctly?
new mod released: https://steamcommunity.com/sharedfiles/filedetails/?id=2891944169
IIRC there is OnWeaponSwing when you first hit the button, then OnWeaponSwingHitPoint, I'm not sure if the damage has taken place at that moment or not, then finally OnPlayerAttackFinished
yea, first one is OnWeaponSwing. Thanks for info. ๐
Anyone know if the debugLog that's exposed is related to the actual red box errors?
I would have assumed so, but nothing seems to happen when I overload it
As far as I remember from looking at that java code, it is for setting up log levels, which can be toggled on/off e.g. general, error, combat, etc etc
Yeah after looking over it again and comparing it to debugLogStream - it seems there are actually exceptions than something called "Lua exceptions"
And annoyingly, part of the java classes to write to different log levels isn't exposed :/
There's a Lua manager function actually counting and listing errors but it doesn't seem related to the red box
So it might be the "Lua exceptions" which I think come from the parser validating the Lua
I might have to grab the console.txt and reverse engineer this to work
Not ideal ๐ฆ
I would imagine the main game loop has a try-catch block to catch any exceptions and does something to make the red box show up when it catches an exception
There is a Java side UI element that retracts - I haven't tried grabbing the UI element cause I really want the text being outputed
Ideally, exception info is sent to lua to render the red box, but it could be done java-side too. I haven't looked at how the red box is implemented
But the stuff that looks like it would be it isn't exposed
I could put in a request, but it's such a niche ask, I don't think it would be worth changing the feature locked version
I'll have to try again when able - might be something I missed
I saw that catch has ExceptionLogger.logException(ex); apparently, this is in charge of render the red box
I'll take another gander
init is the first time that part is installed
ah I see, thank you
well I still cant figure out any of this
so I am giving up. Its hopeless lols. no one has any info on it and I cant figure it out by myself
Is it somehow possible to block player damage?
Like using the OnWeaponHitCharacter event and returning false?
they recently added a OnPlayerGetDamage event that handles most if not all sources of damage
But are you able to return / alter the damage there?
Cause I wasn't able to find a resource that modifies a event or rather the output of it
you may have to just revert the damage. I haven't used the event myself, just saw some talk about it when it got added
Hmm I see... thx
SWAT mod has a shield that blocks damage from zombies, You should take a look
there should be a WeaponHitCharacter hook for that
LuaEventManager.triggerEvent("OnWeaponHitCharacter", var2, this, var1, var3);
if (LuaHookManager.TriggerHook("WeaponHitCharacter", var2, this, var1, var3)) {
return 0.0F;
from IsoGameCharacter.Hit()
should also beable to call player:setAvoidDamage(true)
theres a few ways to do it really
oh that's handy. Been looking for a way to isolate the damage a player takes from the the damage the vehicle takes during a crash, that'll be easier to use than what I was planning
not sure if it takes effect with crashes, but havent really looked at the crash mechanics at all
I imagine it would, I'll check it out after work
But doesn't that just trigger the event / hook and not override it?
I'm used to return false in events to block it
ya thats the code that triggers the event. i displayed it to show the hook trigger below
you can add a function to the hook (similar to adding events) that blocks when returning true
or call :setAvoidDamage during the event
i had no idea we had hooks like that ๐
I am also unclear on how that's supposed to work
True. I just wanted to make items to make nomad a better experience. Was making a scrap axe weapon with lots of scrap metal "teeth". It looks a lot like a saw and thats an item you cant build with wood and stone
Events.OnWeaponHitCharacter.Add(function(attacker, target, weapon, damage)
if some_condition then
target:setAvoidDamage(true)
end
end)
--- or
Hook.WeaponHitCharacter.Add(function(attacker, target, weapon, damage)
if some_condition then
return true
end
end)
-- alternately
Hook.WeaponHitCharacter.Add(function(attacker, target, weapon, damage)
return some_condition
end)
do all events have a corresponding hook?
sadly no
a quick search of the java shows me there's only 5 usages of hooks in the entire source lol
but ya.. hooks are the little known underappreciated event system. i wish there was more
with my events I've been experimenting with returning the results of all the handlers and its been working so far
because I believe all the event handlers attached to an event that is triggered in the lua run before the trigger function returns
essentially like this
local args = {totalDamage = 100, isCanceled = false}
TriggerEvent("ExampleEvent",args)
if not args.isCanceled then
object.applyDamage(args.totalDamage)
end
like I said it seems to work great as long as the event is only triggered and handled in lua
ya works good in that instance, not so good when the event is coming from the java side and the args is a numeric or something passed by value and not by reference
ya, I only use this specifically for events I made myself
as a afterthought, should probably actually manually check though that the hooks still work as intended. NGL my info maybe out of date since i'm not entirely active anymore ๐
You should be able to list them all like you do with events
Using the Hook table instead of Events
There were only 5ish iirc
Like this, but using Hook
AddEvent("AutoDrink");
AddEvent("UseItem");
AddEvent("Attack");
AddEvent("CalculateStats");
AddEvent("WeaponHitCharacter");
AddEvent("WeaponSwing");
AddEvent("WeaponSwingHitPoint");
the hooks listed, there maybe more but i havent dug around through everything (cant really fire up pz atm to check)
also, taking a quick look i might be remembering how they function wrong
looks like when they're triggered the return value will always be true if a hook exists, regardless of what the callback returns
hey @bronze yoke ! could i convince you to look over my implementation of your d- wait i just realized something
do you think the code that you made for the zombie inventory replacement and the one you sent me last night would like... conflict
if they're both implemented within the same file
oh they might
here's the full snippet that definitely works together
-- list of items to replace the dummy with
local itemList = {'Base.Orange', 'Base.Pear'}
local function replaceDummies(container)
local dummies = container:getAllType('Base.Apple') -- dummy item type
for i = 0, dummies:size()-1 do
container:Remove(dummies:get(i))
local itemChoice = ZombRand(#itemList)+1
local item = container:AddItem(itemList[itemChoice])
container:addItemOnServer(item)
end
end
-- for items in containers
local function onFillContainer(_roomName, _containerType, container)
replaceDummies(container)
end
Events.OnFillContainer.Add(onFillContainer)
-- for items found on zombies
local function onRefreshInventoryWindowContainers(inventoryPage)
if not inventoryPage.inventory or not instanceof(inventoryPage.inventory:getParent(), "IsoDeadBody") then return end
replaceDummies(inventoryPage.inventory)
end
table.insert(SuburbsDistributions["all"]["inventorymale"].items, "Base.Apple");
table.insert(SuburbsDistributions["all"]["inventorymale"].items, 100);
table.insert(SuburbsDistributions["all"]["inventoryfemale"].items, "Base.Apple");
table.insert(SuburbsDistributions["all"]["inventoryfemale"].items, 100);
Events.OnRefreshInventoryWindowContainers.Add(onRefreshInventoryWindowContainers)```
i'm thinking of writing a tool that'll either convert tapes to this system or a replacement for the generator that'll do it in this system, but i'll have to check if their license allows that (and i should check if what tyrir said about there being another way to do this was right too)
thank you!! i'll give this one a shot later today
Hooks are amazing in that they can completely replace the vanilla content
If there were more you'd see a lot more overhaul mods I imagine
If having a hook at all causes the original code to not run puts a lot of pressure on the hooker modder to implement the damage event properly. Imagine breaking the targeting code just cuz you wanted to tweak damage values in WeaponHitCharacter
There's a hook for stat calculation on players too
the hook for Attack seems ominous
That's kind of the nature of it
ya idk it doesnt seem right from memory, i may have just read it wrong but i just took a quick glance
Hooks bypass entirely
Which hook takes priority if multiple try? haha
The first I think?
or does it fire every hook like the events
It checks if a hook is present
So probably they all pile on
It does Add to the hook
all of them, it used the Event.class, essentially the functionality is the same
There's some cases where you don't want vanilla to play out - the alternative is what I had to do with calorie balancing -- I had to rewrite the entire method anyway just to figure out the difference between vanilla and my own rates - and apply just the difference
So if you'll be rewriting stuff anyway, might as well make it straight forward
I wonder how busted it would be if Events were given a boolean to make them behave like hooks
the Attack hook was used in the old ReloadManager for firearms (might still be used in the new timed actions for firearms too).. so i should remember this all clearly from ORGM days. but meh i'm getting old my memory isnt what used to be lol
I like the idea of intercepting things and changing them entirely instead of trying to figure out what happened and reverting it, especially for damage calculations where the reversion may come too late. But it is intimidating
It's more or less the same logic tbh
I can help, I rewrote the item picker
I couldn't figure out how to spawn filled first aid kits ...
So I just rewrote the loot spawn for containers
Any modders accepting commissions for a weapon?
Kind of hope there isn't some method I missed
I've written stuff that already existed in utility files too
Feels bad
hay Chuck - im sure youve been all over the code by now but did you you notice the refereces to stack traces in events-schemes.jason and in deboglogstream.java?
in reference to trying to find what it is that calls for the red box thing -
I looked at debugLogStream but it doesn't seem to be exposed
I followed the flow from catch to print, hoping to gobble up that info
No luck so far
Might also be getting names mixed up
I have a few attempts commented out
debugLog class seems to be the only one not throwing exceptions suggesting exposure issues - but I can't seem to figure out where it's doing it's thing
- there's two Lua manager methods referring to errors and error count - but it isn't the same as the red box errors it seems
Is there a known way to like
check if a flashlight was on a belt
and then put it back-
getAttachedSlot() setAttachedSlot()
I thank thee
Is there a tutorial for making melee?
function Recipe.OnCreate.TorchBatteryInsert(items, result, player)
local oldItem = nil
local battery = nil
for i=0,items:size()-1 do
local item = items:get(i)
if item:hasTag("Battery") then
battery = item
elseif item:hasTag("BatteryItem") then
oldItem = item
end
end
if oldItem and battery then
local currSlot = oldItem:getAttachedSlot()
result:setUsedDelta(battery:getUsedDelta())
result:setFavorite(oldItem:isFavorite())
result:getModData().batteryRemoved = nil
--[[if result:getAttachedSlot() ~= currSlot then
result:setAttachedSlot(currSlot)
end]]
end
end
Anyone know what's wrong with this?
Problem is in the commented out code.
It seems to trigger an error but otherwise function, though I'd like if it just like, didn't
which line errors?
if result:getAttachedSlot() ~= currSlot then
result:setAttachedSlot(currSlot)
end
setting the attachment slot of the result seems to cause problems.
the if statement is a little redundant but I wanted to check anyways
correct slot
what's weird is the error triggers but the item is in the slot like you would expect
might just wrap it in a pcall
ehh i dunno
that feels weird
player:removeAttachedItem(oldItem) might be needed
How would i be able to trigger a sprite change for a custom tile that ive added? something similiar to how the rain barrel sprite changes after water has gone into it.
im trying to work on a upgradeable workbench so it can have different recipes for every tile
hey @bronze yoke ! https://pastebin.com/Df19P50c does this look like it should work to you?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
i thiiink something's busted with the loot distributons but i can't figure out what
i don't think your code is busted, cuz i can't even get to the part where i'd test that because the blank cassettes aren't showing up in the loot tables ๐
those if-then statements could have been done MUCH more gracefully but i ended up having to do it that way for time's sake
i could have just packed them all into 4 if-then statements but it would have taken me a lot more time
i'm not sure if it's the cause of the issue, but your if statements should be using == not =
welp. Here I am. The modder who hardly talks....
There's been an issue with Linux users running my mod for ages, and I seriously don't know how to fix it. When a linux user hovers over a clothing item in their inventory (from my mod), they get spammed with this error: Callframe at: se.krka.kahlua.integration.expose.MultiLuaJavaInvoker@67767343 function: render -- file: ISToolTipInv.lua line # 108 | Vanilla. [22-11-22 19:23:55.554] ERROR: General , 1669166635554> ExceptionLogger.logException> Exception thrown java.lang.reflect.InvocationTargetException at GeneratedMethodAccessor465.invoke.. [22-11-22 19:23:55.555] ERROR: General , 1669166635555> DebugLogStream.printException> Stack trace:. [22-11-22 19:23:55.822] LOG : General , 1669166635822> Helpful logging, right?
Anyways, if anyone has any ideas... I'm all ears. Thanks for your time. ๐
maybe try moving some of the table.inserts outside of the if statements to see if it's a problem with them
some of them are totally outside of the if statements
and even those ones don't show up
other than the cassettespawn one but
that one was working before i changed anything
oh, have you checked your log for errors then?
i didn't see any pop up while i was in debug but i'll give it a look!
doesn't seem like it.. hmm
this is just obnoxious, it really seems like everything ought to be working fine and it's just.. not
i'll try removing all the if-thens and see if it just works as raw loot distribution tables, and if it doesn't then obviously i've messed something up there
yeah that's what i'd try
tyrir asks this! i may have messed up integrating your code maybe? (though i think that's a later issue rather than what's causing this problem)
he's missed that it's added to the event at the very end
oh! wait no
this is a different issue but this Events.OnRefreshInventoryWindowContainers.Add(replaceDummies) should be Events.OnRefreshInventoryWindowContainers.Add(onRefreshInventoryWindowContainers) now
as i theorised, i get this error too if i set an invalid ClothingItem in the script, so the issue is definitely to do with loading ClothingItems
hmm actually i have a question that might obviate all this if-then silliness-- albion, is there a way to have this dummy replacement code replace the blank with more than 1 item at a time, and have it randomly decide how many to add?
yeah, hold on
local function replaceDummies(container)
local dummies = container:getAllType('Base.Apple') -- dummy item type
for i = 0, dummies:size()-1 do
container:Remove(dummies:get(i))
for i = 0, ZombRand(5)+1 do
local itemChoice = ZombRand(#itemList)+1
local item = container:AddItem(itemList[itemChoice])
container:addItemOnServer(item)
end
end
end
the number in that ZombRand is the maximum amount that can spawn
it might just be easier to add the dummy item to the spawn table multiple times though
hmm. ok, i'll keep trying to make it work this way and if i can't figure something out i'll give this method a shot instead
good to have a back up
hm.. vexing
it does appear to be something related to my attempt at integrating sandbox settings
that's annoying, i wonder why it's breaking..
they do just work as raw loot tables
it's really weird that it breaks without an error
yeah i was checking the debug console and the console/co-op console files and none of em had anything that seemed related
i think i'm gonna have to try implementing the random version up above--a quick related Q, is there a way for me to separate it from the zombie one so that it only applies to containers? because i think in the merged snippet that controls dummy replacement for both zombies and containers, right?
-- for containers
local function onFillContainer(_roomName, _containerType, container)
local dummies = container:getAllType('Base.Apple') -- dummy item type
for i = 0, dummies:size()-1 do
container:Remove(dummies:get(i))
for i = 0, ZombRand(5)+1 do
local itemChoice = ZombRand(#itemList)+1
local item = container:AddItem(itemList[itemChoice])
container:addItemOnServer(item)
end
end
end
Events.OnFillContainer.Add(onFillContainer)
-- for zombies
local function onRefreshInventoryWindowContainers(inventoryPage)
if not inventoryPage.inventory or not instanceof(inventoryPage.inventory:getParent(), "IsoDeadBody") then return end
local container = inventoryPage.inventory
local dummies = container:getAllType('Base.Apple') -- dummy item type
for i = 0, dummies:size()-1 do
container:Remove(dummies:get(i))
local itemChoice = ZombRand(#itemList)+1
local item = container:AddItem(itemList[itemChoice])
container:addItemOnServer(item)
end
end
Events.OnRefreshInventoryWindowContainers.Add(onRefreshInventoryWindowContainers)
eeeexcellent
for i = 0, dummies:size()-1 do
container:Remove(dummies:get(i))
for i = 0, ZombRand(1 * SandboxVars.MFTEOTW.lootrarityfactorA)+1 do
local itemChoice = ZombRand(#itemList)+1
local item = container:AddItem(itemList[itemChoice])
container:addItemOnServer(item)
end
end
end```
does this look like it would work or is integrating sandbox settings not something i'd be allowed to do in this segment
that would work
this will have issues if SandboxVars.MFTEOTW.lootrarityfactorA isn't an integer
it is!
specifically set it as an integer to avoid that, it's why i was asking about how to do that last night :p
@_@ it does not appear to have... restrained itself sufficiently
hmm
or wait.. this might be my drop settings maybe
gotta futz with some things, i kinda forgot to consider 'hey it might just spit out multiple of the blank cassettes which would then multiply into way more cassettes' so i've probably gotta turn that initial blank cassette drop chance down
actually wait--i'm getting turned around because i've been working on this a bit and staring at white screens for a couple of hours has a way of turning your brain into mush. if a container only has one entry in its drop table for an item, can it still spawn multiple of that item if the chance is high enough?
i don't think so
then i'm not sure what happened here.. hm
i only have one entry for each container type
and the sandbox setting was set to 2
this is causing me Acute Brain Madness i have no idea what's breaking it now
did you change this at all since you sent it?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
here's the full thing
i don't think this is the issue, but you should remove the Events.OnRefreshInventoryWindowContainers.Add(onRefreshInventoryWindowContainers) line near the end of the file and this function
-- for items found on zombies
local function onRefreshInventoryWindowContainers(inventoryPage)
if not inventoryPage.inventory or not instanceof(inventoryPage.inventory:getParent(), "IsoDeadBody") then return end
replaceDummies(inventoryPage.inventory)
end```as they're made redundant by some of the code you just added and i'm not sure what will happen if you have both
done!
so since it's
(1 * SandboxVars.MFTEOTW.cassetteDropNumberA)+1
does that actually mean that, by default, the max would be 2?
oh yeah it's still totally broken.. hmf, it's wild, i wasn't expecting this to be this tough! seems like there's always somethin

found the issue. Apparently fileGuidTable is case sensitive on Linux :/
ZombRand actually returns a value between 0 and one less than the number you put in
oooh i see
but yeah, just seems like one of those days where the code refuses to cooperate--absolutely nothing i've tried has worked as it should lol
yeah i really don't get this one
are... some containers considered to be multiple kinds of container? i suppose i should ask
yeah i think so
i'm not sure if it takes from multiple loot tables or chooses one though
either way, lootzed should show which tables that container can have
ah yeah, that's not the problem then
this one is just BedroomSideTable and it has 9 cassettes in it when it should have 2 :p
vexing.. urgh
the worst part is both methods of implementing this system have run into inexplicable dead ends where no one can figure out what's causing it @_@ what a frustrating outcome
i guess i'll just come back to this one another day and try it again from the top
yeah that seems best
this is weird, if I do speed = Vector2.new(x,y):normalize() I get a float, but if I do speed = Vector2.new(x,y); speed:normalize() I get a Vector2
the javadoc says it returns a float, but does that even make sense?
what does the float represent?
looks like a length, tbh
ya its length
I got so used to the vector methods returning this that I didn't notice the normalize doesn't
that doesn't make sense
normalising a vector makes its magnitude 1... that's the whole point
yes, the method normalizes the vector, and returns its original length in case you wanted to do something with it
i see
the vector I'm getting is wrong anyway, the velocity at the point the crash happens has already been altered. Gonna see if BaseVehicle.lastLinearVelocity is still accurate
also gotta figure out how to use IsoSprite.RenderGhostTileRed so I can try and display what I'm doing for debugging, but thats tomorrow me's problem
did you try using Vector2f or Vector2i?
just used the basic Vector2, although I'll likely just move the math to the lua side instead, since I'm converting the Vector3f to 2D anyway
or I may just scrap the vector stuff altogether since the vanilla code doesn't use it. In the vanilla code, if you collide with something while driving, everything around the vehicle takes damage, even if they're not really touching. You can see it the most clearly if you run into some trees, you'll see trees off to the side and behind you shake too
testing something i didn't think to test: whether or not it's the sandbox setting in the field fucking up the ZombRand field
that'll at least narrow things down a little bit if it is
yeah this is driving me crazy i have NO idea why it's broken
i set it to only 1 like the normal default, i removed all the loot entries on the table except for one just to test it on a single container, and just for no reason it seems to vomit cassettes into every loot source it applies to
i cannot for the life of me figure out wtf it is doing or why
i'll have a closer look at it tomorrow, maybe i'll be able to work it out
when you do
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
here's the latest minimalist version i used for testing
hopefully u spot somethin!! thank u for all the help albion
of course ^_^
Trying to make a melee mod and whenever i try using the weapon, weapon appears but the model doesnt.. Works still as a weapon though (Also comes up with this failing to load the model)
Also everything is name correctly by EthanCleaver.
Texture and .X file
directory is off
double check, change, restart game to test
By directory do you mean file directory?
I'll post what i have in the script, pretty sure I have everything right.. Model is in models_X\weapons\2handed
And texture is in textures\weapons\2handed
Script is in scripts\weapons
module Base
{
item EthanCleaver
{
MaxRange = 2,
WeaponSprite = EthanCleaver,
MinAngle = 0.8,
Type = Weapon,
MinimumSwingTime = 3.5,
KnockBackOnNoDeath = TRUE,
SwingAmountBeforeImpact = 0.03,
Categories = Axe,
ConditionLowerChanceOneIn = 15,
Weight = 1.5,
SplatNumber = 4,
PushBackMod = 1,
SubCategory = Swinging,
ConditionMax = 25,
MaxHitCount = 4,
DoorDamage = 55,
IdleAnim = Idle_Weapon2,
SwingAnim = Heavy,
DisplayName = Ethan's Cleaver,
MinRange = 0.8,
SwingTime = 2.6,
KnockdownMod = 2,
SplatBloodOnNoDeath = TRUE,
Icon = BaseballBat,
RunAnim = Run_Weapon2,
TwoHandWeapon = TRUE,
BreakSound = BreakWoodItem,
CriticalChance = 40,
critDmgMultiplier = 2,
MinDamage = 1,
MaxDamage = 2,
BaseSpeed = 0.96,
WeaponLength = 0.75,
AttachmentType = BigBlade,
}
}
did you register the model?
Define register 
I did make the model, just sorta slapped it as a .X file matching it with a other model (baseball bat)
Thank you for the help btw ๐
I mean, create a model on scripts something like this
module Base
{
model EthanCleaver
{
mesh = weapons/2handed/YOURMODELFILE, /* Model patch ~models_X/.. */
texture = weapons/2handed/YOURTEXTUREFILE, /* Texture path ~textures/... */
scale = 1.0, /* Directly related with size model on blender */
/* Where will the weapon be at rest */
attachment world
{
offset = 0.0000 0.1630 0.0000,
rotate = 180.0000 0.0000 180.0000,
}
}
}
Ohhhh i swear i saw that on a wiki somewhere just thought that was for worlditems for something
No i did not do that but tyvm!
yeah, just find the script model of the weapon you are basing it on and copy it
Alright thank you, time to go through the process of trial n error ๐ ๐คฃ
Which is what i heard from rumors; offset and rotate
Is there a modder who accepts commissions here?
what do you have in mind?
A single firearm
With vanilla stats in mind, stat wise it would be the same as an m16
Hello
I want to make a mod that will make the cooler bag run on battery. Is there anyone who can help with this
Convert it something that accepts batteries like radio or flash lights
Try to copy how they consume the battery
Or you can use moddata
I know this, but when I change the type of the bag, the items are not put in it
Us Delta can only be used in Drainable
Is there a complete guide on pz modding
How would i be able to trigger a sprite change for a custom tile that ive added? something similiar to how the rain barrel sprite changes after water has gone into it.
im trying to work on a upgradeable workbench so it can have different recipes for every tile
Well if you have a trigger you use setSprite("...") yourself.
If you want it to change by adding water, you can edit the script.
Depending how different it is, you might use an overlay sprite. That's how containers like shelves change for example based on items inside.
hi, is there a way from lua to retrieve all the players? There's GameClient::getPlayers() but it looks like GameClient is not exposed ๐ฆ
(I need to check if players have radios)
Is it easy to lock a bag to only holding one type of item? Like a quiver for crossbow bolts/arrows
Or a bag to hold a bunch of crafted spears?
Doable but not easy
Look at the miniscoreboard
The code you are looking for should be somewhere there
It lists all the players connected
If youre looking to players even if they are not connected check the database panel
bags are relatively easy, movables not because they don't save the AcceptItemFunction.
is there a way to check if a specific coordinate is valid
like if its part of the map
i mean world
like maybe isValidSquare()
imade that up tho
When you fix a mod and people complain about the name somebody else gave it 
that one only has the usernames. I need the actual IsoPlayer instance to check if they have a radio
those are for local players
@high citrus
actually, use this newer version
for _, player in ipairs(SoulUtils.getPlayers(true)) do
print(player:getDisplayName())
end
He has to require soul's mod to his mod?
tanukiUtils = tanukiUtils or {}
--[[
Gets all players matching a predicate. The default predicate is all players that aren't dead.
Usage example:
local all_living_players = tanukiUtils.getPlayers()
local all_players_named_bob = tanukiUtils.getPlayers(function(p) return p:getDisplayName() == "bob" end)
Notes:
getNumActivePlayers:
- Singleplayer: number of local players in client (including all split screen players)
- Client: number of local players in client (including all split screen players)
- Server: 1, but getSpecificPlayer() calls always return nil on server
getOnlinePlayers:
- Singleplayer: nil
- Client: lists all players (including split screen players)
- Server: lists all players (including split screen players)
getConnectedPlayers: trash. only seems useful for working with scoreboard?
- Singleplayer: 0
- Client: only updates when a player manually open scoreboard, but lists all players then
- Server: 0
]]
tanukiUtils.getPlayers = function(predicate)
local result = {}
predicate = predicate or function(player)
return not player:isDead()
-- and player:getCurrentSquare() -- Will filter out players sufficiently far from client that their square isn't loaded
end
if not isClient() and not isServer() then
-- singleplayer
for i = 0, getNumActivePlayers() - 1 do
local player = getSpecificPlayer(i)
if player and (predicate == true or predicate(player)) then
table.insert(result, player)
end
end
else -- multiplayer
local onlinePlayers = getOnlinePlayers()
for i = 0, onlinePlayers:size() - 1 do
local player = onlinePlayers:get(i)
if player and (predicate == true or predicate(player)) then
table.insert(result, player)
end
end
end
return result
end
No, tanuki just needs his mod now :p
for _, player in ipairs(tanukiUtils.getPlayers(true)) do
print(player:getDisplayName())
end
@hearty dew thanks ๐
What is the simplest way to store Lua data on the server side and access it from the client side? Do I need to set player variables and store raw strings or is there a better way for transferring a Lua table from server to client?
Mod data is probably the simplest. Could also simply send the table as an argument in a client command if it isn't necessary to persist the table
Oh I can actually send parameters through client commands? It is fine if they receive a copy of the table, rather than the actual table.
Yea arguments can be sent via server/client commands with the caveat that only basic lua types will be sent (tables, strings, numbers, booleans, etc). userdata (java objects) poof when sent
keep in mind the table has to be fairly simple. No java objects, or multiple copies of the same reference
err, missed that Tyrir mentioned the java objects already
if you have the same reference to something multiple times in the table they will become independent copies once passed
so zombie textures can have alpha and it will apply ingame already?
like uh missing arm etc
i THINK i read something about this here before
oh nvm nvm i found the comment
also im in the wrong channel coz it was in #modeling lol
Thanks a bunch as always.
@astral dune Understood, thanks for the input.
Can I send a server command directly to a player? Or do I just need to let clients catch the command? I want to tell players to store some data as soon as they join a server...
Would be preferable not to update all of them
SendServerCommand has two versions, I believe, one with a player argument and one without
@astral dune Sure enough, thanks hero
So on serverside can I just catch OnConnected on any player who connects and send them a command?
Or does OnConnected only fire clientside?
you can request moddata from the client
if you're not using mod data then you can basically do the same thing by sending a client command that gets the server to send a server command
does anyone know why an item's type might be different from the script? i was helping someone with strange behaviour on their mod and the issue ultimately turned out to be that an item, base.testitem, was coming out as base.test despite it being defined correctly as far as i can see
could be for compatibility with legacy mods, a lot of Java code that interacts with mods/script has some specific cases where it converts things to more recent type
Probably this, zombie.scripting.objects.scriptmodule
else if ("item".equals(getTokenType)) {
final String[] split2 = trim.split("[{}]");
final String trim3 = split2[0].replace("item", "").trim();
final String[] split3 = split2[1].split(",");
final Item item = this.ItemMap.get(trim3);
item.module = this;
try {
item.Load(trim3, split3);
}
catch (final Exception ex) {
DebugLog.log(ex);
}
}
ah, that'll be it
thanks I hate it
How do I put more RAM into Project Zomboid?
Is there a reliable way to type check?
I've tried
local isDrainable = instanceof(trueItem, "Drainable") or instanceof(trueItem, "DrainableComboItem")
to no success
InventoryItem:IsDrainable()
keeps returning false despite the fact that :getTypeString() is returning "Drainable"
Ah that works
Thank
wait I dunno if that'll work here
I'll try it but I'm unsure if this is an InventoryItem
It's not, it's an Item.
My fault there for not providing more context though
lemme post more code
I would've formatted it in discord but it would've looked off
well that's your problem, Items are always just Items, drainables and other types like that extend InventoryItem so checking their class won't help
if getTypeString() returns 'Drainable', can't you just use trueItem:getTypeString() == 'Drainable'
I suppose so, I just was wondering if there was a better way to handle it.
you could use getType() and compare that to the static if that's exposed, but that seems like it would complicate things
Probably, guess I'll just use getTypeString and do a comparison there.
Thank you, sorry for any trouble hehe
something like trueItem:getType() == Item.Type.Drainable
I'll try that, it just feels more properly integrated that way.
yep, that's exposed
i know what you mean, it just feels more professional when you're not using a string lol
Yeye!
I know it makes virtually no difference because of how the code is set up but it matters to me!1
Strangely didn't seem to work, Item.Type returned nil.
I imagine the :DoParam() route would be the best way to do it, least incompats
spent the last couple hours writing a tool to output a simplified scan of an area to the debug, using unicode box drawing characters. Turns out lua hates unicode and I had to scrap it, lol
Did some research in the backlog of this channel, seems another person was doing something similar and couldn't compare to Enum.
isn't the firing speed tied to the animation? might be complicated
well the upside is string comparisons are O(1), so comparing typestrings will be quick
Well that's nice
that's kind of strange... it *is* exposed, but you can't just reference it
is item.type static?
i doubt there's any getter for it, so the only purpose it can really serve being exposed is that you'll be able to call its functions if you get an instance of one
yeup, static
its functions that... don't really do anything
hmm, usually static fields are easily accessible, but maybe not the instance fieldof a static field. I imagine you can use reflection to get it if you REALLY want to
i tried a few sneaky ways to get it but i couldn't find anything
i'm not too into reflection though so i'm sure i could have missed it
I just want to change the sprite itself like if I were to use it as a crafting station and use certain objects to upgrade the station how would I trigger a command to just change the sprite in its place.
IsoObject:setSprite(spriteName)
IsoObject:transmitUpdatedSpriteToClients() -- if this code runs on the client, use IsoObject:transmitUpdatedSpriteToServer() instead
NOO ITEM CAN'T HAVE MODDATA
sobbing
I guess I could do a cheaty method but it's like bleh
why do you need item to have moddata?
So I can store it's "getReplaceOnDeplete" data while still having "setReplaceOnDeplete" be nil.
I'm wanting to override replacement behaviour to only occur when the battery is removed, rather than when the item runs out.
I still need to store the item it turns into, though.
Only idea I have is a dictionary.
trueItem:DoParam('oldGetReplaceOnDelete = ' .. oldGetReplaceOnDelete)
will make every InventoryItem of that item start with getModData().oldGetReplaceOnDelete = whatever

any unrecognised parameters become default mod data
Yo hey is there a mod that adds a negative trait where it gives your player dementia? like for instance once in a while your character forgets where he is and all tiles that have been viewed turn unviewed (turned black) and you'd have to view the area again, kinda like reloading a save?
if not, theres an idea for anyone. i think it would make the use of maps even more useful?
its a cool idea but like you said, this happens anytime you load up a save anyways so technically everyone already has dementia. I think it would be an annoyance more than anything
I do like the idea of dementia,
maybe having dementia means you sometimes forget about some items in your inventory and you need to "search" trough your bags to make items appear again. Or some skills might decay and go down in XP/level if not used for a while.
having to re-read magazines because you forget how to operate a generator and stuff like that
Is using the OnCreate function of a recipe a pretty standard way for adding functions to items, or is there a more direct way to add a selection to the item's context menu that triggers a function?
When doing IStimedbasedAction
How do i force the player to equip a tool
Is there an event that triggers every second or every game tick or generally an event that triggers all the time consistently ?
note: this doesn't pass an IsoPlayer like the wiki says, it passes a player num - my pull request to correct this hasn't been noticed yet
OnTick
thank you
The parameter on tick. Does that return the total number of ticks? Or what exactly does that return?
Thanks
I've seen them make that mistake in a couple places so I always check. Thanks for the warning.
all four context menu events are incorrect in this way
it's the total number of ticks
I see, thank you
Is there a way to clone a shirt and make it a new item with my own texture? So far I didn't understand how the item from scripts/clothing/ are connected with the model and the texture.
item Shirt_FormalWhite
{
DisplayCategory = Clothing,
Type = Clothing,
DisplayName = Formal Shirt,
ClothingItem = Shirt_FormalWhite,
BodyLocation = Shirt,
Icon = ShirtGeneric,
BloodLocation = ShirtLongSleeves,
Insulation = 0.25,
WindResistance = 0.15,
FabricType = Cotton,
WorldStaticModel = Shirt_Ground,
}
I assume I have to use the ClothingItem "Shirt_FormalWhite" and lookup the Shirt_FormalWhite.xml under clothing/clothingItems/
<?xml version="1.0" encoding="utf-8"?>
<clothingItem>
<m_MaleModel></m_MaleModel>
<m_FemaleModel></m_FemaleModel>
<m_GUID>ac7976de-2c73-44ea-9392-5d24ac1fb649</m_GUID>
<m_Static>false</m_Static>
<m_AllowRandomHue>false</m_AllowRandomHue>
<m_AllowRandomTint>false</m_AllowRandomTint>
<m_AttachBone></m_AttachBone>
<m_BaseTextures>clothes\shirt_tshirt_textures\shirt_formal</m_BaseTextures>
</clothingItem>
If this is correct... What can I do then?
You usually equip it before the action. You can add check to isValid if you want it to stop if it's unequipped.
Obviously you can use commands to skip the equip action if you want.
I use this in a script I have
ISWorldObjectContextMenu.equip = function(playerObj, handItem, item, primary, twoHands)
how does one use the OnUseVehicle event? When I enter a vehicle my function doesnt trigger.
and does it trigger continuously every tick or does it just trigger once like OnEnterVehicle?
Is there a reason to set it as a function? I used it like this:
ISWorldObjectContextMenu.equip(player, player:getPrimaryHandItem(), knife, true)
Is this wrong?
I got a question: Is there a (relatively simple) way to include water from a sink/water source into a recipe? For example:
{
Toothbrush,
Toothpaste;1,
Water=1,
Result:Toothbrush,
Time:500.0,
}```
Is there a way to replace the Water=1, with something that will refer to a water source as well, and not just any bottles/etc in your inventory?
@fast galleon @balmy prism where do i put this? on the isValid?
or start?
cuz i see other actions make the player take the inventory and equip it
So when I hook into OnFillInventoryObjectContextMenu, I can see the list of options in table.options, but how do I actually add an option to that table? I'm not seeing it ๐ฆ
I tried just setting the next options value to an object and giving it a name, but it gets overwritten next time I right-click...
So clearly that's wrong
Did he just ping two random people?
Hold on I think I see... context:addOption(getText("ContextMenu_CheckMap"), map, ISInventoryPaneContextMenu.onCheckMap, player);
Stuff like that
Maybe making sense now
ow im so sorry
iment this soul
pinged the wrong soul I think
i used it like this:
local knife = player:getInventory():getFirstEvalRecurse(predicateKnife)
ISWorldObjectContextMenu.equip(player, player:getPrimaryHandItem(), knife, true)
local function predicateKnife(item)
if item:isBroken() then return false end
return item:hasTag("SharpKnife") or item:getType() == "SharpKnife"
end
I am really confused. Are the "OnUseVehicle" and "OnExitVehicle" events just broken? they cause my game to black screen every time I boot it up if my script incudes those events
you should check for and equip the item before the action starts, that's how vanilla usually does it
don't add the context option if the player doesn't have the item, and have the context option queue the equip action before the main action
if it's already equipped it'll just skip the action
Does DoParam always pass as a string or is there a way to make it pass booleans?
My code is also from the "click" Action on the menu. In the valid function I just check if it's still there.
trueItem:DoParam("batteryRemoved = true")
Doing this for an item sets "true" to a string which is.. undesired.
is batteryRemoved a customAttribute? If yes, you could parse the string by yourself.
I never used booleans so far. Maybe someone else knows more.
batteryRemoved is intended to be mod data yes
it'll check if it can be converted to a double, otherwise it'll be a string
I also can also confirm this. Checked it in the java:
try {
Double var27 = Double.parseDouble(var4.trim());
this.DefaultModData.rawset(var3.trim(), var27);
} catch (Exception var15) {
this.DefaultModData.rawset(var3.trim(), var4);
}
Im not sure if my mod has bugs for now i got it work whew.. it doesnt auto equip yet but aslong as it works. Lol
Did you moved it outside of the ISTimedAction?
function PlayerSay()
local player = getSpecificPlayer(0);
player:Say("Exit");
end
Events.OnExitVehicle.Add(PlayerSay)
This script causes my game to hang on a black screen when booting up. Why is that? Is the event that I am using just broken?
@bronze yoke Thanks again for the crumb, I got it figured out now.
what does the console.txt say?
glad it's working!
Where can I find that?
Im not sure what i did lol. Im really not used to doing timed action
I made bunch of tweaks so i cant remember. Plus is almost 6am here .. another long day finished...
Albion might be right about the check before the action thing. I didnt test it without the equipped jtem
Or item in the inventory or floor
But all i know is that if i right click the context menu is always there
I couldnt remove it as easy as OnTest
Its very diffrent coding for me.. need to study this somemore
Thnx alot guys ๐ซก๐
In .."userprofile"\Zomboid\ folder.
are you using windows?
Nvm you already found it... Wanted to post "%userprofile%\Zomboid"
Which is line 7 of your script?
