#mod_development
1 messages ยท Page 168 of 1
can you show line 58 of ISCraftAction.lua ?
uhhhh yeah one sec...
What is happening in ScavHunt.lua? This likely means you're using the wrong type so it can't find a proper invocation target (actually, looking further down, maybe just a nil param)
local resultItemCreated = RecipeManager.PerformMakeItem(self.recipe, self.item, self.character, self.containers);
That's line 58
Thnx bud @weary matrix
ScavHunt.lua is as follows...
-- function Recipe.OnCreate.CreatePuzzleStaff(items, result, player)
weap = {"ASS.puzzlestaff"};
box1 = weap[ZombRand(1)];
player: getInventory():AddItem(box1);
end
Can you show more of the context? I assume you're creating an ISCraftAction somewhere and doing stuff with it?
That's literally the whole file ๐ฅฒ
I suppose it's occurring as a result of the recipe then
Like, when I go into the game, I'm able to craft the item just fine, but it keeps chucking that error at me
recipe Combine Puzzle Pieces
{
puzzle1,
puzzle2,
puzzle3,
puzzle4,
puzzle5,
puzzle6,
puzzle7,
puzzle8,
puzzle9,
puzzle10,
Result: puzzlestaff,
Time:100.0,
OnCreate: Recipe.OnCreate.CreatePuzzleStaff,
Sound:PutItemInBag,
}
There's the create recipe
I may be misremembering, but I believe ZombRand with integers works with an exclusive range
Meaning ZombRand(N) โ integer in [0, N), thus ZombRand(1) โ 0. If this is the case, your box1 will always be nil, since indexing starts from 1
It's possible that the error occurs there, and the Java code responsible for executing the OnCreate callback throws it as the exception you're seeing
Looking at the Caused by exception, it seems likely that that's the culprit
Right, sooo how would you recommend I fix this issue? I'm quite new to coding in general, so advice is greatly appreciated ๐
Would adding a +1 integer to the zombrand do anything? or would that break it even further?
Excellent intuition, that's what I would suggest. I think you'd be better off basing your ZombRand number directly off of the length of the table as well, so you can change it without worrying about breaking it
Also: using local variables is recommended
Alrighty, I'll try adding a +1 to the zombrand and see if that changes anything
Okay, so it didn't pop up with an error this time, but it gave me two staves instead of one
Well, that seems to be what you're telling it to do
Your recipe has Result: puzzlestaff, and the OnCreate callback adds another
If you only want to create one item and do not need any side effects, you don't need it
I assumed from your use of the random function that you want to randomize something in the future
Oh that was mostly just me being lazy and copying over the code from my last mod to see if I could do it that way ๐
Just removed the call for the oncreate function from the recipe, let's see how this pans out...
Heeeell yeah, that did it. Thanks for the help Omar! ๐
Are you talking to me ?
Whats the way to play a sounds through a player? Is it through the players sound emitter?
Would there be any errors from having nights survived < 0 so that world age is also < 0?
I tested it briefly before, but maybe I missed something.
yes
Are they 3d? Or only heard by the client?
@neon bronze PlaySound will transmit automatically and yes it will play 3D, PlaySoundImpl will play 3D but not transmit so would be heard locally only
Thank you
that was intended for you yes, haha
Does anyone know how to fix this scroll bug?
we don't see ur code so nothing to fix
https://pastebin.com/Gju8jfgk This is the code, but I think I figured out the issue anyway,
Apparently if you add a ISButton as child, it will always render on top of everything before 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.
I'm trying to use getUrlInputStream, this is my code so far:
local function readByte(dataInputStream)
local status, byte = pcall(function()
return dataInputStream:readByte()
end)
return status and byte or nil
end
local function downloadConfig(config)
if not config or not config.url then
print("Config URL missing!")
return
end
local output = ""
local dataInputStream = getUrlInputStream(config.url)
local byte = dataInputStream:readByte()
while byte do
output = output .. string.char(byte)
byte = readByte(dataInputStream)
end
dataInputStream:close()
print(output)
end
``` It is working as expected, but my concern is the call to pcall doesn't seem to prevent a stack trace on the java side:
```Caused by: java.io.EOFException
at java.base/java.io.DataInputStream.readByte(Unknown Source)
and also I'm getting a red square error
anyone know where icons are stored?
@tame mulch any way to catch java exceptions from Lua? Otherwise I'm not sure how to read from dataInputStream without triggering an exception, because you'll always get EOFExcpeption at the end of input. I also tried to use the method dataInputStream:available() but it's always returning 0. Other methods that don't trigger EOFException require a java byte array, but from what I remember we can't instantiate java arrays from Lua
icons?
For items
in the texture packs
@bronze yoke hey, any clue about my problem?
sorry, not a clue - never worked with the url stream or even the file streams, and i'm usually in a position to avoid exceptions, not handle them
You have balls just straight-up @ing staff lol
somone pinged nasko yesterday asking for mod
he was one of the translators
lol, I've known Aiteron for a while, before he joined TIS ๐
Also getUrlInputStream() is fairly new AFAIK, so I guess not much people tried to use it
ummm
oh fair enough. I figured there might have been more context
Is there ever a time where staff does like an AMA?
i think it's in the UI packs
oh
my take is that no one tried to use it, or didn't report the issue if they did try. Or maybe someone did but it's not fixed yet.
what's an AMA?
ask me anything
ah hum
basically just a period of time that's set aside to answer questions
usally for upcoming updates
like an hour or so
I think they did it sometimes, not sure how regular it is though
also normally live
I'd love to leverage that to ask some modding questions
100% worst part of mod dev is icon creation
which questions you need answered that can't be answered here? ๐
if you just need to create one you can just dump a png into textures
ik
but ive finished my mod
this is just the last thing
for me it's when you try to achieve something that should be simple with Lua code, but you realize how much of a nightmare it will be to get it done within pz ๐
oh shit
i gotta do distributions
ty for reminding me
i also got a question
for dists
is the base.item or whatever
just the item name
like this
yeah, prefixed with the module
i dont have a mod
if the module is base you can usually just omit it
- is there a way to add animations with a higher speed scale, and allow only some players to use those? I've tried adding animation xmls with different filenames and m_names, but all my attempts to allow only some players access to those have ended with overriding the other animations, so all players get the higher speed scale.
- Is it possible to add outlines to zombies without aiming at them? My attempts to do it each frame result in no visible change.
- Are there plans to allow modders to affect vision? What about the hearing radius, thermoregulators (changing base core temp, stopping sweat, etc), shaders, or interactions with NPCs?
among others haha
have you checked how it's done when aiming at them?
also if you really can't figure it out or get a proper answer here, I guess you could ping nasKo about it so that he would take the questions to the dev team. He's the community manager after all ๐
thats what nasko does?
i thought he coded or sm
nope, not that I know of at least
but ik aiteron does that
yes he does
yeah, there's an exposed setOutlineHighlight function that doesn't seem to do anything
i'll look over it again quickly, but i'm 100% sure i checked before and it was just impossible
have you figured out how it's done when aiming? It has to work ๐
let me also look into it haha
the problem is that because it works when aiming it doesn't work from anything else
it's always overwritten by what aiming is doing
if it's only on the java side and stuff are not exposed then you're fucked
with all my respect ๐
i see
my distributions dont work smh
also do you get an error in console.txt or something?
where did you put that file?
IIRC it has to be in server but I'm not 100% sure, or maybe shared
try to add print("Something") to your distribution file, and then look for Something in console.txt. If not found it probably means your file is not loaded
items>server>lua>media
are you sure about that path? ๐ค
Yup
shouldn't it be something like: media/lua/server/Items/?
Maybe
Is there a discrete zombie/player base class you can work from to make new enemies from?
setOutlineHighlight is for the outline effect on the container you're accessing
i'd be surprised if that would even work on non-sprite objects
check IsoPlayer, IsoLivingCharacter, IsoGameCharacter, IsoMovingObject, not sure if any of those would be usable for your case though
the actual aiming highlight is called outlineColor and is not exposed at all
if it's still not working just check any mod that do distribution to see where they put their distribution file
hmm maybe actually... if you could use the weird field stuff to get it you might be able to mess with it, the class is exposed and the field is public
i gave up on that idea immediately because you can't set fields, but you wouldn't actually need to set it in this case, since it's an object
albion, if I go further with this idea I'd likely need to lean on you pretty heavily in that case.
but-- if you have any other ideas about what I could do-- my use case is trying to show zombies outside of vision within a limited range. To represent "smell"
arent zombies outlined when aiming at them?
that's what we're discussing
read up a bit ๐
My thoughts have been outlining zombies, using a moodle to represent how close they are (a la the sixth sense mod), but I'm not really sure if there's any other options
and I hate the idea that they could be, you know. Actually seen moving rather than hinted at in the outline approach
i think with field shenanigans you can change the colour, but it doesn't matter because it won't render unless bOutline is true, which doesn't have a setter - and i'm also not really sure how arrays (as opposed to arraylists) behave in kahlua so maybe the first part isn't possible anyway
just some thoughts really, but isn't there a way to draw an overlay to the scene? So that you could draw whatever you like on that overlay. Might be a bit messy to get it right though
Could add a circle on the ground that represent a range?
i remember seeing some getters that convert arrays to arraylists, so i'm guessing arrays might be problematic...?
I haven't heard of overlays, is there a basegame or mod example of that?
I just played through the tutorial. That could work, maybe.
I honestly don't know, it's really just a thought ๐
The debug UI usually have circles when selecting squares (spawn zombie for example)
I know some maps add an overlay, but not sure if it can be used from a mod
got fed up with my decompile misbehaving while looking into this, quickly ran beautiful java, it's a lifesaver
why r u trying to write exactly byte?
-5 % 24 = ?
lua 5.4: 19
kahlua: -5
trying to handle end of networking process by pcall is some of crazy thing tbh
I was just doing some testing, but i can't find a way to read the data without triggering a java exception basically. That's why i'm asking for a better way. If you have some insight about how to use getUrlInputStream properly i'd gladly take it
can you help?
write data as string? jsonify it since it's just a config with string and numbers
but as I think there's network limitation for 65536 bytes for each stream so if config is big u will need to split it and send separated, after u got all chucks of original config concat and json unjsonify it
I can show to u how it can looks like but example not from pz but gmod
Yea, if you have a working example please show me
Don't care about the JSON part though, all i need is Lua
Not sure if an example from gmod is going to be relevant though

oh wait, I misstook in that r u trying
mybad
I see u tried :readFully()
but u missed with one thing
first argument is TO WHERE data will be written
u don't need any bytes info
Problem with readFully is you need a java byte array, but you can't instanciate a byte array from lua
AFAIK
A java byte array is no simple string
I'm not sure that it will handles like that
but never tested so yea can't guarantee
I can guaranty you it wont'work because a lua string and a java byte array dont use the same representation in memory, also lua strings are immutable
i am trying to play some sounds but they are not heard
function voice_commands(key)
print(key)
if key == 20 then
getPlayer():getEmitter():playSound("ScoutLaugh2")
end
end
Events.OnKeyPressed.Add(voice_commands)```
Even though i added the sound file correctly
module Base{
sound ScoutLaugh2{
category = Player,
clip
{
file = sound/Scout_laughhappy02.ogg,
}
}
}
```` the sound script file in question
ok nvm figured it out, its just strange that you have to parse through the name of the file and not the sound name as you defined it
is there a way to remove the fuel from the gas tank of a vehicle with dev tools for testing?
Really struggling to find a way to add custom zombie animations, all mods I found only used stock. Can anyone bumb me in the right direction, please?
Spawn a gas can and siphon the gas? ๐
that means your sound script isn't working
iirc it just creates one if it doesn't find a script by that name but can find a matching sound file, so if you don't need to do anything fancy it's probably not a big deal to not have one
it probably has some performance impact to create it live but it only has to do that the first time you try to play it
with cheat just set the content of the container
How is that done? I have the debug stuff enabled but didnโt see anything for emptying containers
How would a working script sound then look like?
I guess i forgot the media
Are there any snake-related items in the vanilla game?
i have a feeling you're not asking about the bandana
Didn't know PZ had those.
it's been a long time...
Anyone know the hydrocraft devs discord?
i'd like to ask him about snagging an asset
Anybody know if it's possible to spawn a particle in a certain square?
Like a muzzle flash or something

embed fail
how longs it supposed to take for a mod to get accepted by steam? been like this for the past hour and a half
1gb true music mod
i've never even heard of a waiting time
yeah i've uploaded other mods before and it was short if not instant
think i should just duplicate it and try again
?
maybe yeah, it sounds like something might have gone wrong
aight
Steam is checking if you are sharing better content than Emule
might be a far stretch but do you think you think opening a lua file as a txt document mightve fucked it up?
because thats the only real thing i did out of the usual
is there a safe way to make sure a breakpoint set in the lua debugger works even if this breakpoint is in a function used in the Events.OnGameStart?
why would that stop it from working?
Well, it's not working
I put the breakpoint, and it's not being it. But the logs are still appearing
Does anyone know why group:setHideModel does not work with the Back body location?
I'm trying to hide the backpack
This is a question for everyone here who codes: Would you code python 3 if you could code python for modding PZ?
Hey @gilded hawk . Have you tried using the new EmmyLua typings for PZ?
My answer is no, but figured I'd add both reactions so it's easier to keep track (feel free to react to them yourself & I'll make it accurate)
The reason I ask is because I looked into the possibility of supporting python for modding PZ and it is possible.
Certainly sounds interesting, but I'd just stick to Lua as usual ๐
I personally have no preference.
Umbrella?
i have been working in python a lot recently, but i like to stay native... as native as scripting languages get anyway
If it's umbrella then yes, I am, and it's lot's of fun. I'm using it for my casualoid project
niiiiiice.
I need to advertise Umbrella.
You've used PipeWrench so you know It's trying to do the same but in Lua.
Yeah, I found that even if I'm a seasoned js/ts dev, I still prefer to stay native and Umbrella + PzStudio is a great combo
Holy shit I found a almost native way to hide backpack! ๐
nope
new to pz modding, what are umbrella and pzstudio?
@red tiger this is best for you to answer
Also, this is pz studio: https://github.com/Konijima/project-zomboid-studio and umbrella: https://github.com/asledgehammer/Umbrella
Lua typings that exposes and defines the PZ API used for modding.
so pzstudio looks like a mod organization tool. i'm not clear on what this means in the descrption, what is it responding to? dynamically monitor and respond to changes
Hello there, what should I look for to control the camera position in other ways than Vanilla ? No Java modification. Has someone already done such thing ?
Someone already played with IsoCamera.SetCharacterToFollow ?
How
it's already accepted by steam lol
there's no any text part about validation, it's just hidden so change visible state of it
it wasnt, how true music works is that they give you some preset then you add in .mp3 files and you use an exe file to conver them to .ogg file, my antivirus blocked that exe
so i just turned it off and it worked
it was* just read the text on top of screen
there's absolutely no sense between steam workshop item and ur antivirus
yeah ik bout that, but when i uploaded the mod through the game it had a name and a preview pic
i couldnt change the visibility either
it also mentionned the mod was 0.000 megabytes, even tho the file contained something like 1gbs worth of music
it also didnt even have a name at first, i juse renamed it to "j" just to see
but anyways it works now so it doesent matter much
good then 
There is a watch command that will check for changes in your project (saved anywhere you want) directory and mimic the change in the Workshop directory where the (generated/disposable) mod is at. All you need when a change has been done is to reload the script in game
I made pzstudio to suite my needs but im all open for PR on github for any improvements and ideas.
I have plan in the future to implement a translation manager too for making translating mods easier
this is not gona work but its cool to look at lol
venom!
https://imgur.com/6cIa579
Heya! New modder here. I'm getting these error messages in my logs. for GazTigr it's trying to load a file that isn't installed because I accidentally left the modID in there when I wanted to remove it, but the rest I'm certain are installed
@plain crane I'm also pretty new here so I don't know if I'm barking up the wrong tree, but by any chance are you testing with the -nosteam flag? If you are then your client won't pick up anything from the workshop.
Negative, this is on a dedicated server and I have a lot of other mods that work just fine. But thanks for trying to help!
is there a way to spawn items inside an equipped bag?
I just woke up, I'll tell you after breakfast
Here are some snippets
spawn bags with items inside
heres a code we used for Signs of Sickness Server - ToxSick Event
local shotgun = InventoryItemFactory.CreateItem("Base.DoubleBarrelShotgun");
local bag = InventoryItemFactory.CreateItem("Base.ShotgunCase1");
shotgun:setTooltip("initially has 6 chambered shells");
shotgun:setClipSize(6);
shotgun:setCurrentAmmoCount(60);
shotgun:setRoundChambered(true);
shotgun:setAimingTime(90);
shotgun:setMinDamage(shotgun:getMinDamage()*2)
shotgun:setMaxDamage(shotgun:getMaxDamage()*2);
shotgun:setName("SOS ToxSicK Event Shotgun");
getPlayer():getInventory():AddItem(bag);
getPlayer():setWornItem("Back", bag);
bag:setName("SOS ToxSicK Event Gun Case");
bag:getItemContainer():AddItem("BladeSOS.Bloodbath");
bag:getItemContainer():AddItem(shotgun);
another one used as template for Kentucky RP server
local spwnbag = InventoryItemFactory.CreateItem("Base.Bag_Schoolbag")
spwnbag:getItemContainer():AddItem("Base.Apple");
spwnbag:getItemContainer():AddItem("Base.Apple");
spwnbag:setCapacity(70)
spwnbag:setWeightReduction(70)
spwnbag:setName("Kentucky RP - Store Items");
getPlayer():getInventory():AddItem(spwnbag);
getPlayer():setWornItem("Back",spwnbag);
getPlayer():resetModel();
been thinking about adding something similar to pzst
do you have to create a bag and get the player to wear it or is there a way to refrence already equipped items and spawn it inside them?
You might want to test it to figure out what it does
Just paste that on the lua console
Then modify as u see fit
You wont have to look for the syntax as everything id there already
Goodluck
@hardy flint Hey, do you mind sharing a code snippet to see how to use getUrlInputStream() properly?
right now I'm able to retrieve content, but not without triggering a java exception at end of file
hum guess I could use a BufferedReader to avoid the exception, but that feels a bit overkill
damn, I would need InputStreamReader but it's not exposed :/
Also tried readUTF but getting EOFException as well
only thing working is readLine() but it's deprecated...
am i correct in interpretting that there is only a single shared random number generator in Lua?
should i not seed it if i need to use it? will that potentially mess up other things using it that may want the seed persisted?
anyone know if there's some reason goto would not work in PZ's lua? I can't find anything wrong with my syntax
if not ShouldDoThing(thing) then goto continue end
...
::continue::
pz lua is not lua, it's Kahlua. Also goto was only introduced in lua 5.2
ah, thanks
but the Kahlua version in pz is based on lua 5.1 IIRc
if you need continue you have to wrap your code inside if blocks
yeah np just wanted to make sure i understood why it wasn't working
ah, so math.random is not available either. is there an RNG solution?
PZ: ZombRand, ZombRandFloat, other variants.
Kahlua also has some other random option, you can see them in Umbrella, __kahlua.lua
In fwolf's guide, he uses repeat and break to imitate continue.
ZombRand works great thanks for the tip!
OK so using getUrlInputStream() like this is working:
local output = ''
local dataInputStream = getUrlInputStream(config.url)
local line = dataInputStream:readLine()
while line do
output = output .. line
line = dataInputStream:readLine()
end
dataInputStream:close()
``` but the `readLine()` method is deprecated so I'm wondering if someone knows of a better way?
In every sandbox I have like 300-400 mods so its easier to parse mods for added items
Instead of debugging who replaces who ingame
is it for servers or just for singleplayer?
Both, script just parse mod files and upload to db
Or just in one csv/xml/json
Primary goal was to recategorize all that tons of new items
nice, is it published somewhere?
Not yet, still writing some stuff
How does PZ handle online players that are out of cell bounds? Is there a player object, no square?
is there a guide on setting up custom setting options?
Try this
#mod_development message
hum, but you're reading from a file in that example, not from an URL? ๐ค
I just tossed something that might replace readline which you mentioned
Idont have any odea about the read steam thing. But i know how to open browser to a specific url
Tho someone mentioned it doesnt work anymore
You can't read from a URL in vanilla PZ.
Also openUrl() is a defunct API call. Not sure why it isn't rid of at this point since it was confirmed to be replaced or removed from TIS a ways ago.
Unfortunately people won't be able to click buttons in-game that opens a discord invite link.
(So freaking useful back in 2017)
well you actually can
I just did it
It'd be very dirty / tricky.
no
except for the part where you can't catch the eventual exceptions related to IO/network errors
The only method I figured out was to run a separate process to catch file requests / changes using an IO reader.
@red tiger
@LuaMethod(name = "getUrlInputStream", global = true)
public static DataInputStream getUrlInputStream(String string) {
if (string != null && (string.startsWith("https://") || string.startsWith("http://"))) {
try {
return new DataInputStream((new URL(string)).openStream());
} catch (IOException ioException) {
ioException.printStackTrace();
return null;
}
} else {
return null;
}
}
Yes. You modified the Java.
If this is a server solution then yes this will work.
The fuck? Where did this come from?
probably a recent release
I searched for this sort of thing occassionally.
yeah me too, been looking for it since day 1 of modding pz ๐
I was the biggest bitch about not having any access to URL stuff.
but now you can! ๐
I was told the original one was disabled due to issues with security concerns.
This isn't any safer.
Oh wait it sort of is.
so for example with ModGuardian I'll be able to report the IP of servers that run modpacks with your mods ๐
I'd think that'll get some people angry. =/
I don't mind pissing off thiefs ๐
Hopefully that's all you piss off.
who else could I piss off? ๐ค
It might bother the devs. I'm not one so I can't say they would.
Mod packs has always been such an annoying fight in the mud.
It's also data-gathering.
It might be an issue?? I wouldn't be the guy to be mad about what you're trying to do here specifically.
It's a different attempt to control the issue you have where people steal your stuff.
There's no official means to combat this problem so I don't think anyone should get mad at you for doing this.
Same with my mod loader.
It makes mods "exclusive content".
Even with good-faith, someone will eventually spoil it for all of us.
but it's a lesser offense than stealing intelectual property? So that makes it ipso-facto legal because there's no other way to report the later crime?
One could argue that your firewall logs IPs.
not sure about that, I'm no lawer but that would seem fair to me
I don't think it'd fully translate to your case.
for example in france, it's illegal to record someone unless he agrees to
but if you record someone to report a crime he's commiting, and there's no other way to prove the crime, then you're allowed
kind of
Anyways thought I'd bring this point up to maybe help you think about the implementation. I'd like to see the results.
It's somewhat frowned on however some MC premium plugins do licensing and key tracking.
It's the same problem, really.
the thing is I won't be logging all server IPs that use my stuff, only the ones caught in the act of stealing
When people package mods, they sometimes alter them so if your goal is to ping an endpoint, they could remove that code.
like:
if modpackDetected then
logServerIP()
end```
As a mod packer, I'd remove it.
the code is not in clear text
I mean.. I'd be fine finding it but would all mod packers?
it is very easy to reverse it, but then you get heavily obfuscated code with no symbols and no newlines and you can't indent the code using beautifier tools
so yeah of course it's possible
my bet is that most mod packers are not smart enough
I don't know if you can load your own mod files
but yeah I'll probably add some sort of anti-tampering at some point
IIRC you should be able to access your mod's filetree.
getMod('mod_id').getFolder()
or something.
I did this in the past.
local modInfo = getModInfoByID("my_mod");
local modDir = modInfo.getDir();
@weary matrix
getting the dir is easy, but can you list the content to get the file names? Assuming yes, can you open those files for reading?
If you know what to check then you can complete those paths.
most filesystem related global functions are checking if you have ".." etc in your path
That's the root so you don't need it.
let's see
modInfo.getDir() returns a string
so you can't use the File methods on it
meaning you'll have to open the files by path, and I'm not sure it's possible
If you can digest a file's contents then it's possible.
can you?
yesss
how?
You use the reader.
Take that string, complete the path and then open a reader instance.
but most reader function open files in the cache folder
then you'd have to go up to the parent using ".." etc but those functions check for ".." and forbid it
for example:
@LuaMethod(name = "getFileReader", global = true)
public static BufferedReader getFileReader(String string, boolean boolean1) throws IOException {
if (StringUtils.containsDoubleDot(string)) {
DebugLog.Lua.warn("relative paths not allowed");
return null;
} else {
String string2 = LuaManager.getLuaCacheDir();
String string3 = string2 + File.separator + string;
string3 = string3.replace("/", File.separator);
string3 = string3.replace("\\", File.separator);
File file = new File(string3);
if (!file.exists() && boolean1) {
file.createNewFile();
}
if (file.exists()) {
BufferedReader bufferedReader = null;
also openurl is still functioning and vanilla uses it
Did they fix it?
It was due to a JVM arg in the JSON file for the exe.
maybe? i do remember having no luck with it before
@LuaMethod(
name = "getModFileReader",
global = true
)
public static BufferedReader getModFileReader(String var0, String var1, boolean var2) throws IOException
java.awt.headless=true is what breaks openUrl()
but now it's used to open the tos in browser
@weary matrix mod_id, path, some boolean I forget
Wait wtf
createifnull
this one does cache too.
yep
Okay now I'm fucking angry.
it gives you a folder specific to your mod to write files to, but it's not your mod folder
Maybe my memory of this API is too outdated.
it is the mod folder, isn't it?
I don't think so:
@LuaMethod(name = "getModFileReader", global = true)
public static BufferedReader getModFileReader(String string, String string2, boolean boolean1) throws IOException {
if (!string2.isEmpty() && !StringUtils.containsDoubleDot(string2) && !(new File(string2)).isAbsolute()) {
String string3 = ZomboidFileSystem.instance.getCacheDir();
String string4 = string3 + File.separator + "mods" + File.separator + string2;
if (string != null) {
ChooseGameInfo.Mod mod = ChooseGameInfo.getModDetails(string);
if (mod == null) {
return null;
}
string3 = mod.getDir();
string4 = string3 + File.separator + string2;
}
string4 = string4.replace("/", File.separator);
string4 = string4.replace("\\", File.separator);
File file = new File(string4);
i actually have a mod about done that heavily relies on that fact so i'm quite sure of it
Forcing the cache dir is cancer.
@bronze yoke I'd be curious to see it
do you read your own lua files or you just write files to it?
i use it to read txt files, writing is a bad idea
if you write it'll mess up the checksum forever
true
local reader = getModFileReader(mod, "media/musicradio/scripts.txt", false)
Fun fact: the game internally refers to http://pz-mods.net, which is blocked by uOrigin for "Badware risks". TIS might want to rid of that URL.
ZomboidFileSystem.instance.getCacheDir(); actually returns the path to your Zomboid folder in your home
I always thought it was returning Zomboid/cache or something like that
hopefully we'll never get into a modders war where people fuck with other peoples mods ๐
the potential is here though
yeah, there's still some evil stuff you can do with mods
I'm more concerned about being able to read passwords in plaintext in the cache folder than mod wars.
of course
oh my god that's actually a thing
It's been a thing for as long as profiles have been a thing for multiplayer.
It's phishable. That's been a issue.
Until that's fixed, I refuse to take any security solutions for PZ seriously.
that said it could be fun to use that to fuck with server owners who use modpacks ๐
I'm terrified to think of the number of multiplayer accounts that has the same password as something important as a bank account.
well the cool thing about it is we now have access to getUrlInputStream, so you can easily exfiltrate those passwords to an external server ๐
I'd like to stop talking about this subject. I don't want trouble..
I think it'll possibly hurt people to continue this conversation.
Idea. Decrypt string in anonymous function and evaluate.
Then loadstring(..)()
sorry but I fail to understand how that would be helping my case
If you can't IO your lua files, have your lua code be contained as an encrypted string.
it's already the case
but we just seen it's possible to read your lua files? So I'm looking for a decent hash function to check integrity of files
I would implement some sha stuff myself if we had access to bit operations, but don't want to implement those myself, for my own sanity
Share with the class when you're done.
I just said I won't do it ๐
decompiled the game, and I'm trying to find the code section that handles "Thump" targets for zombies.
@ancient grail So, you asked about making a backpack invisible. I found a solution. Using item:DoParam("BodyLocation = Back") I add the body location to all the backpacks
And by making the user wear an item with a specific body location, in my case group:getOrCreateLocation("Hide_Everything") I then set this bodylocation to hide the backpack using group:setHideModel("Hide_Everything", bodyLocationId)
And this makes the backpack disappear without having to use hacks or respawning the item!
Code example below
local allItems = getScriptManager():getAllItems()
for i = 1, allItems:size() do
local item = allItems:get(i - 1)
-- If can be canBeEquipped but not getBodyLocation, then it's a backpack!
-- So, we force the backpacks to have a BodyLocation, so that it can be hidden by pz using the group:setHideModel!
if item:getType() == Type.Container and item:InstanceItem(nil):canBeEquipped() ~= "" and item:getBodyLocation() == "" then
item:DoParam("BodyLocation = "..item:InstanceItem(nil):canBeEquipped())
end
end
hmmmm
hmmmm
oh you probably mean before that.
local function reportModpack(config)
if not config.report_url then
return
end
local url = config.report_url .. "?"
local modInfo = getModInfoByID(config.modID)
local params = {
modID = config.modID,
workshopID = config.workshopID,
serverIP = getServerIP(),
fakeWorkshopID = modInfo and modInfo:getWorkshopID()
}
for key, val in pairs(params) do
url = url .. key .. "=" .. val .. "&"
end
getUrlInputStream(url):close()
end
``` ๐ ๐ ๐
@thin hornet modders will be able to receive a notification when one of their mod is found in a modpack ๐
Yeah i saw what you did here
Thats sneaky hehe
how cool is that? ๐
Implement an API key system where server need to fill the field which then check if the api key is valid
Not that i would use this but its funny to see you achieve those things.
actually you could use it and keep your code in clear text, just to know the workshop IDs of the modpacks with your stuff in them
Yeah considering they do not edit the code
of course anyone could remove the code, assuming they know the mod is doing this
pretty sure modpackers don't expect this kind of stuff though ๐
modpackers are not developers
Yeah wow thats brillant
i should have done this for bag hider but still thanks for the info this is useful
that's rly smart
You are welcome!
And it's very much okay that you didn't do it, the game does not make it obvious that you can do this ๐ค
I took me months only working on clothing transmog to figure this out
So, I'm attempting to create a script that stops zombies from damaging doors when not targeting the player. So that when environmental attacks is on, they can still break windows, barricades and other obstacles without targeting the player, but not doors unless aggro-ed.
I found this thing which I think has something to do with the zombie target type, but all that I can find besides coordinate based references to the current target.
Am I looking in the right place?
Isn't the enviromental attack sandbox option only specific to zombies randomly breakin stuff, but still being able to destroy tiles when chasing a player? ๐ค
What if you make it so that when they attack a door, the door HP gets refilled?
maybe, but then wouldn't that prevent the zombs from breaking doors when arggroed?
Maybe there is a property that says if a zombie is chasing a player?
other then this here, I don't think so
butttt
maybe ittl lead to a check for whether the zombies are aggroed and breaking an object?
is this line required for fbx
Dont think so, it takes over the angles from blender
How to reload animation xml?
Or atleast you can update the model live in blender if you re-export in in fbx
@public
--- @param thumpable boolean
--- @return void
function IsoThumpable:setIsThumpable(thumpable) end ```
Maybe make the targetted door not thumpable?
hmmmmm. maybe?
And thumpable again when the player is next to it kindof
I think there's already a system for thumpability though.
depending on whether or not enviromental attacks is enabled, zombies will thump random objects and deal damage to them, however when disabled, they still thump doors and windows, just don't deal damage unless targeting a player
Hello! First time writing here. Iโm a total newbie when it comes to modding, and my code knowledge is rudimentary at best. That being said, would it be feasible for me to create a mod that allows me to do the following on a multiplayer server:
Creating a modded item to manage ticket items for events:
- Print (generate) tickets using unique names and preset colors.
- Punch/stamp used tickets.
~ Tickets can be readable (non-editable) items, but it is not necessary.
I realize thereโs a lot of logic involved here, and that itโs more complex than a beginner might imagine, but Iโm open to clever, simpler solutions as well. Let me know what you think might be the best approach.
Thank you! (edited)
if i understand correctly tickets are like passes for an event like a concert or theater?
Exactly!
that doesn't seem too crazy
You could make a single item and rename them in game
For the coloring i supose it could work like the clothing color picker?
Im not sure there are different color for item other than clothing item
Otherwise you make a bunch of different colored items
YellowTicket, OrangeTicket etc
to know if the ticket was used you can save data into the item ModData
id save the world date and time to know when it was used.
you could implement expiration the same way
That would be really cool!
Makes sense! I was thinking so as well. If I could have a few variations of a base ticket which has an editable name, and then if I could generate copies of it with the modded machine so that the new copies are not editable somehow, that would be ideal.
Generating would be easy
a custom context option on the ticket printer machine where you must have black ticket and ink? Then you fill info in a UI like the ticket name and expiration date, valid from date.
That would be even better than I imagined!
What's the first thing I would do to get started on something like this?
Learn how to add items, and creating context options.
Items are made into media/scripts/*.txt files
Context menu are Lua code into media/lua/client/
Hacky work around.
But it wil work
I suggest switching it only when player attacks
Theres an event for this right
Then switch back after the attack
I guess that might work
Is the spiffo bot auto detects hello
It does lol
Thank you for answering my questions! I will look to learn more about these, and finally begin my first modding project
this may help you get started with mod structure and also offer you insight with intelisense when it's time to code lua.
Thanks! Checking it out right away
Not all doors are thumpable ๐
no longer unlisted, give it a look ๐ https://steamcommunity.com/sharedfiles/filedetails/?id=2986272766
so many sick ass mods coming out today
can i see the fbx for the lab?
temporarily its a sprite I snagged from hydrocraft
here
one sec
oh so you didnt finish it last night?
but im working on a proper model
nah
you mentioned working on it
I gothe model
ah
just havent imported
my models are fucked rn
loll
Hey guys, is there a way to get an item with all it's variables untouched?
wdym?
guh, words. words are hard
Like, every time a player updates their clothing I wanna set their shoe's stomp power. If I don't reference the original variables for the shoe item, if they constantly equip / re-equip they'll have shoes that do like 2000 damage
so if I can get a copy of the shoes they have from like, a vanilla list of items and compare it, that'll solve my problem
lol
you can use the script item (ScriptManager.instance:getItem("Module.Type") -> Item), or if the thing you need isn't accessible on the script item but is on instances (InventoryItemFactory.CreateItem("Module.Type") -> InventoryItem)
needing to create an instance should be very rare though
based thank you. I knew that was a thing but I didn't know the syntax for it (or what words to search discord with lmao)
I'll reference the script. ty albion
is there a way to check whether the player emitter does not play any sounds at the moment?
@bronze yoke inventoryItems also have a getScriptItem()
oh damn, i've never seen that before
do you know of something to grab the squares infront of the player?
how many? if it's just one you could do something like player:getSquare():getAdjacentSquare(player:getDir())
oh I didn't think of that
I'm trying to reverse egineer which tree is getting hit
since ontreehit doesnt give the event the tree
had to reverse engineer WeaponLength because the item nor script has a getter for it
i know it's not needed in vanilla but why would we not want the tree u_u
also, get attacking square just gives you back the square your mouse is on
oh, I have improved glytch3r code for that in chainsaw mod.
oh?
It's a bit random though
It didn't need accuracy.
is that with getadjacentsquare?
no something more brutal
---@param owner IsoGameCharacter|IsoPlayer|IsoMovingObject
---@param weapon HandWeapon|InventoryItem
function loggingOnWeapon.hit(owner, weapon)
print("OnWeaponHitTree: weapon: "..tostring(weapon))
if weapon:getScriptItem():getCategories():contains("Axe") then
owner:getXp():AddXP(Perks.Logging, 2.5)
---@type IsoGridSquare
local square = owner:getSquare()
local wepLength = loggingOnWeapon.grabLengthOf(weapon) + 0.5
local ownerForwardDir = owner:getForwardDirection()
local ownerX, ownerY = owner:getX(), owner:getY()
local attackX, attackY = ownerForwardDir:getX(), ownerForwardDir:getY()
print("attack:"..attackX.." ,"..attackY)
for i=1, 10, 1 do
local iDiv = i/10
---@type IsoGridSquare
local attackSquare = getSquare(ownerX+attackX*wepLength*iDiv, ownerY+attackY*wepLength*iDiv, owner:getZ())
if attackSquare then
getWorldMarkers():addGridSquareMarker("circle_center", "circle_only_highlight", attackSquare, 0.8, 0.8,0,true, 1, 0.02, 0.2, 1.0)
print("ATTACK SQUARE")
square = attackSquare
---@type IsoTree|IsoObject
local tree = square:getTree()
if tree then
print("TREE")
local treeSquare = tree:getSquare()
if treeSquare then
print("TREE SQUARE")
square = treeSquare
end
end
end
end
end
end
return loggingOnWeapon
took apart the code for weapon hit scans

I'd have to test getadjacent
but that wouldnt account for weapon length I imagine
not even sure what the /10 is doing - I assume just running down the vector
nice
fortunately you can only have 1 tree per square
yeah this is probably better
or they could add the isoTree to the event call
LOL yeah
making this hour of my life wasted but I'd be happier
i wish we could PR the game
cough barotrauma cough
though can't blame TIS for not wanting their fans the ability to make direct code suggestions
No for sure
looking at whoever added prints to send commands with "1"
i wonder how much having their game source available has impacted piracy
i'm guessing 'barely if at all' but still
I sent them a formal letter suggesting a snippit of code to revolutionize the modding scene with graphics mods.
Truth is there is no way to prevent piracy

in baro's case i'm pretty sure they use steam as drm which is... not infallible
They don't actually use the drm tools Steam provides them.
Source: Trust me bro.
But serioiusly there's little going on there DRM-wise.
considering their source is open* why would there need to be one?
save the money on anti-piracy dev time for lawyers
Trust me when I say that there's more immediate security concerns / vulnerabilities than piracy right now in the game.
in PZ or Baro?
PZ.
Ah, I was talking about Baro this whole time
me too
What is Baro?
is source-available the proper term for what they do?
I've been using open-source* and having to explain
from what i understand, yeah
as you see, I always take the long way around
LOL
i'm sure most people would see 'source available' and read 'open source' anyway so that may be best
If only people could realize the true power of being able to document PZ as a modder and write non-English documentation as well.
If that doesn't catch on I see that as a huge L in the community.
That's a big reason why I made the PZ-Rosetta project.
https://projectzomboid.com/modding/zombie/world/moddata/ModData.html
hello, I have some questions about ModData()
Basically I need to understand the CRUD operations involving it if I use it in a mod.
(If you have examples, great and thanks in advance!)
How to create and save said data.
How to load said data.
How to remove said data.
My assumption on modData() is that all of it is functionally a kaluha table, and that means no functions can be saved to it.
But primary types such as boolean, string, and numbers (float/int) can be saved and referenced by mod functions.
You can save only kahlua types into modData, function can be saved but will be nil the next time it's loaded so it's not a valid type for modData.
IsoObject and some other things have functions to save mod data.
For global modData, you have events to check for changes. You also have a global object named ModData that offer functions to transmit, create etc
Player modData seems to be client side only. It doesn't seem to be transmitted on the server player object.
Item modData seems to only save when in a player inventory.
IsoObject modData needs to be transmitted from the square object if I'm not mistaken.
I wish we could register .pz domains ๐
Why @weary matrix
well for example I could register the domain modguardian.pz
isn't there a .pz tld available somewhere?
ez.pz
this is the official list of TLDs supported by IANA:
https://data.iana.org/TLD/tlds-alpha-by-domain.txt
idk if thats legit but
also applying for a new TLD usually cost quite a lot, so much it would be prohibitive for any non-large organisations. Up to $185K or something like that
working on blood transfusions for evergreenimmunes
Hm... thanks... I'm trying to see if a mod-created table can be saved to ModData() and loaded again when the application restarts and user loads a save.
as long as you only have pure lua objects in your table it should work IIRC
it sure can, but any reference to java object or functions will be nil in the loaded table.
๐ค
yeah many site propose "cheap" tlds, but problem is no one use their DNS, so basically nobody could resolve your domain unless they decide to add said company's dns server to their OS
also many of these sites are scams basically
@lone nest so for example saving an instance of obj:new() which is a lua object will work but when loaded later it will lose all reference to functions that it contained.
But all pure value will be there still
mhm... I think, I can make it work if that is indeed the case.
Think of modData like a json object, it cannot contain anything but table, number, string and boolean.
You could load and recreate an instance of an object based on the saved values.
So instead of saving a java object, you save its ID and find it again later from the ID.
or recreate it from the values of the object depending on the context
ya it all depend of what object it is or the end goal of the mod.
Yeah, I'm trying to understand how the CRUD works.
So MyModData = ModData.Create("tableName"); will create a ModData table if I understand correctly.
If ran on client it will be on client only. Until transmitted. And same apply for serverside.
that's fine, i'm not inclined on MP stuff currently.
@weary matrix btw did u solve problem is urlinputsctream?
and conditionally, create it if table doesn't exist?
MyModData = ModData.Create("tableName");
end```
yes, I use DataInputStream.readLine() but this method is deprecated in java
Look it up, I'm on my phone so it may be different
so it's not ideal but at least it works
yea, but I think for config it's fine but for utf won't work
I can't get why with geturlintupstream after init :available() returns false for it
I tried readUTF also but you're still getting an Exception at end of stream
yea, to get it works u need to read at least 1 byte
I tested
because it's java crap, most inputstream classes in java have this method but it's always returning 0 in most case
just read anything from there
but there's problem with that
u can't mark it
so and can't use reset
what do you think guys, shoud I register ModGuardian.me or ModGuardian.us or ModGuardian.xyz? or something else?
to go into start of stream
u didn't get any msg from mate that said what he tested urlstream and it working well?
what's type of content will be there?
@jaunty marten Welcome back. Check out Umbrella: https://github.com/asledgehammer/Umbrella
@red tiger glad to be back

plain lua
raw?
nope, but I'm pretty sure he used readLine() too, I don't think there's other ways
Umbrella is basically what PipeWrench is but for native Lua, without compiling & generics support obviously.
Thought you'd like it.
why do we need domain then? is u can't just open specific port on ur vds and just use it like http://ip:port? I'm not working with real servers so not sure about it but sounds like it can work in this way
yea, already checked the rep, amazing 
I want to make a website where modders can create an account. Then they can have 2 URLs, one to configure ModGuardian through Lua code, the others to receive modpack reports when their mod is detected in a modpack
good work 
Thanks.
ah, yea, it makes sense then
.xyz sounds good, I think
where's html render engine?

Too busy.

we need cef ๐
what do you think, good idea or not? ๐
btw after my pause it really useful for me cos I completely forgot full names of stuff 
don't worry pz modding is like using bikes ๐
it feels clumsy when you're getting back at it, but all your memories come back easily
so true
After 6 month brake it was even easier than before
Brain classes the information with time so you come back, feels lost a bit but then the magic happen.
Might happen again for me.
yea but my pause was for everything and mainly i'm gmod dev (there's lua too) so it's kinda hard thing to split my memories for them 
I open vs code for gmod and tried to create ui elements via DPanel:new and couldn't get what's wrong

You work for gmod?
not sure why do u need it. it's for sync between a few servers?

Explains the emotes.
ha-ha, yea
I'm probably going job hunting for a better job when I get things together.
I love gmod for I can override everything that I want
nah, I'm implementing some kind of copy protection mecanism for mods. Like it can detect when your mod is in a modpack, or it can make a mod exclusive to a server, you can also blacklist users by steam ID or blacklist servers by IP etc
I bet you have primitive wrappers too.
wdym?
yea, there're Vector, Angle, Entity
and there's huge amount of premade hooks (events) for almost literaly every action 
idk why tis can't add much events in code. when we will in vc with aiteron he said there's some problems with performance for adding more events
this rule works only for devs I think
while playing I'm feels awesome

I'm really waiting animals in new build 
Haunted schools pls
Reinventing The Sims 1
that was supposed to be my invention 
Hi!
I've been trying to make a mod to make bulletproof vests to hide under certain clothing that you can choose via context menu. Basically created a copy of each vest for each layer you want to use them at, assigned them to a newly created body location, and used hide model for each location accordingly. Everything is running fine, however, when assigning locations to your vest when not wearing that clothing (ie.: Wear Vests under Jacket without earing a jacket), this invisible backpack glitch occurs. Using default "vanilla" vest body location works properly. This is my first mod, I've been looking into other similar mods so I can build this one. Do anyone of you encountered this issue before?
Thanks!
Not sure, but maybe this conversation would be of interest to you:
#mod_development message
if not you could probably try to ping MX or Glytch3r
thanks, @weary matrix ! I'll take a look into it!
oh, I like modguardian.it ๐
Yes, this issue happens because the bodylocation of your new bulleproof vest is placed after the bodylocation of the Backpacks: Back
And the game has difficulties rendering items that where intended to be under a different bodylocation
You can create a bodylocation and move it under the Back using this code.
local humanGroup = BodyLocations.getGroup("Human");
local yourLocation = humanGroup:getOrCreateLocation("YOUR_LOCATION_HERE");
local list = getClassFieldVal(humanGroup, getClassField(humanGroup, 1));
list:remove(yourLocation)
local index = humanGroup:indexOf("Back") - 1;
list:add(index, yourLocation);
You could also use the transmog mod made by me, if that fits your needs.
I'm curious- what's your primary motivation behind that idea?
Check if you can use an .it domain without living in italy if you are not living there, cause some national domains will require you to live of work in the country.
But I don't remember if that applies to italy
.it is allowed for anyone in europe basically
Ah that's cool, I did not know that, and I'm italian lol
however, on the registrar I'm trying to use, they ask for a weird citizen code, so I'm a bit at a loss here ๐
but I checked here: https://www.nic.it/en/find-your-it/faq
What are they asking for?
Q: Who can register a .it domain?
A: The registration of a domain name in the ccTLD .it is permitted only to persons who have citizenship, residence or a registered office in the countries of the European Economic Area (EEA), the Vatican City State, the Republic of San Marino, the Swiss Confederation and in the United Kingdom.
fiscal code
Ah, the "codice fiscale."
Yeah, it's an ID on the Italian "health insurance card"
hum
Look for a different domain register that does not ask for it
so my social security number should be accepted?
I don't think so ๐
But try ๐คทโโ๏ธ
This website can generate random "Codice fiscale": https://thesvalvolati.altervista.org/index.php?req=codice-fiscale-random
Sito che offre molte funzioni riguardanti il codice fiscale: Generatore, Controllo validit๏ฟฝ, generatore inverso, generatore di codice casuale.
yeah well not sure it will help to add random information in there
Maybe ๐
Nice!
never seen a domain so cheap
I computed the price over 10 years of many registrar, this one is 66.5โฌ, the cheapest after this one is 87โฌ
https://tld-list.com/ feel free to buy me a coffee ๐
I'm kidding of course, but the website is really great
well, I want a refund
my stomach doesn't like .gif ๐
OOOOOF .gg domains are so fucking expensive ๐ฆ
ah yeah
I suspect discord bought the .gg tld
and they're making $$$ selling .gg domains
Ah goddamit ๐ฆ
maybe they didn't but at minimum they're responsible for the expensive price
Yeah that for sure
wow, thanks!
this code worked flawlessly!
Since I have 2 more bodylocations I did some adaptations. I have no knowledge of lua, just a bit of javascript for processing, but it seems to work properly.
local locationList = {"TorsoExtraVestUnderJ","TorsoExtraVestUnderJS","TorsoExtraVestUnderJSS"}
local arraylength = #(locationList)
local yourLocation;
local list = getClassFieldVal(humanGroup, getClassField(humanGroup, 1));
for i = 1, arraylength, 1
do
yourLocation = humanGroup:getOrCreateLocation(locationList[i]);
list:remove(yourLocation)
local index = humanGroup:indexOf("Back") - 1;
list:add(index, yourLocation);
end```
many thanks!
Also small trick to post lua code do this:
Say, what's the difference between the items and the junk?
Junk only spawns when items doesnt fill the container
Also, items spawn chance is affected by zombie population in the area and junk isnt
Ah. So what defines whether a container is filled? If it gets at least a single item from the items pull then does that count as filled?
Hmm... can anyone tell me why EveryHours() runs when the mod is being initialized on the mod screen, and how I could fix this error?
player is nil but getActiveNumPlayers gets 1.... soooo
that doesn't seem possible...?
but it also doesn't seem possible for you to be mistaken here ๐
The rolls value in that table
well you know i've done my research on events
everyhours shouldn't be able to be called early since the object it's called by shouldn't even exist, let alone be simulating
any other mods active? is there a chance some crazy mod is triggering the event?
yeah it works now... thank you albion lmao
public static int numPlayers = 1; well that was a shockingly quick answer
oh this is so much worse than i thought
numPlayers does not count the number of players
what
(when adding a new player)
IsoPlayer.numPlayers = Math.max(IsoPlayer.numPlayers, playerNum + 1);
it is equal to the highest active player number
i see no handling for when a player stops playing
i guess that does mean it's actually more useful than i thought, but the name is completely misleading
yeah, that's the name of the getter for that
yikies
Is it normal for items like TVs and Tables to have different amounts of HP? They're all 100 right.
@gilded hawk found a domain that suits you? ๐
@nimble spoke hi, can I talk to you in private please?
Sure. No problem
thx
Does anyone know what kind of function or statement I would need to use to say "if you have these mods enabled, include these items, if not, don't do anything"? I'll include a snippet of the code I'm working with in hopes that someone can try and help me figure this out
function Recipe.OnCreate.OpenRareLootBox(items, result, player)
rweap = {"Base.LeadPipe", "Base.Nightstick", "Base.MetalBar", "Base.Axe", "Base.PickAxe"};
rsup = {"Base.Bandaid", "Base.Bandage", "Base.Disinfectant", "Base.HandTorch"};
rarebox1 = rweap[ZombRand(5) +1]
rarebox2 = rsup[ZombRand(4) +1]
rarebox3 = rsup[ZombRand(4) +1]
player: getInventory():AddItem(rarebox1);
player: getInventory():AddItem(rarebox2);
player: getInventory():AddItem(rarebox3);
end
So I'm trying to add modded items into my loot box, and I'm trying to make it compatible with BGCTools/Rare Weapons and Shark's Weapon Pack, but I'm unsure how to implement what I want to do. I basically want to say "if you have those mods enabled, add these certain weapons to the rweap category, and if not, don't add them.
if getActivatedMods():contains("MyOtherMod") then
-- add item
end
Thank you. I'm guessing I would need to include this at the very top of the code? and I'm also guessing in the "add item" section of that, I would need to specify rweap = "BCGT.SurvivalKnife" for example??
Something like that would work yeah
local isMyOtherModActive = getActivatedMods():contains("MyOtherMod")
function Recipe.OnCreate.OpenRareLootBox(items, result, player)
rweap = {"Base.LeadPipe", "Base.Nightstick", "Base.MetalBar", "Base.Axe", "Base.PickAxe"};
rsup = {"Base.Bandaid", "Base.Bandage", "Base.Disinfectant", "Base.HandTorch"};
rarebox1 = rweap[ZombRand(5) +1]
rarebox2 = rsup[ZombRand(4) +1]
rarebox3 = rsup[ZombRand(4) +1]
if isMyOtherModActive then player: getInventory():AddItem(rarebox1); end
player: getInventory():AddItem(rarebox2);
player: getInventory():AddItem(rarebox3);
end
Would this work? Apologies for constant clarification, I'm really new to this whole coding thing ๐ฅฒ
local isMyOtherModActive = getActivatedMods():contains("BCGTools")
function Recipe.OnCreate.OpenRareLootBox(items, result, player)
rweap = {"Base.LeadPipe", "Base.Nightstick", "Base.MetalBar", "Base.Axe", "Base.PickAxe"};
rsup = {"Base.Bandaid", "Base.Bandage", "Base.Disinfectant", "Base.HandTorch"};
rarebox1 = rweap[ZombRand(5) +1]
rarebox2 = rsup[ZombRand(4) +1]
rarebox3 = rsup[ZombRand(4) +1]
if isMyOtherModActive then
rweap = {"BCGTools.HandHatchet", "BCGTools.SplittingAxe", "BCGTools.CheapSurvivalKnife", "Base.LeadPipe", "Base.Nightstick", "Base.MetalBar", "Base.Axe", "Base.PickAxe"};
rarebox1 = rweap[ZombRand(8) +1]
end
player: getInventory():AddItem(rarebox1);
player: getInventory():AddItem(rarebox2);
player: getInventory():AddItem(rarebox3);
end
Also, if that is correct, would I have to do that for each individual mod compat? or is there a way to set up the getactivatedmods to do multiple things at once and say "if this, this, and/or this are active, then add these things"
local activatedMods = getActivatedMods()
local isMyOtherModActive = activatedMods:contains("Mod1") and activatedMods:contains("Mod2") or activatedMods:contains("Mod3")
varying based on the exact combinations you want of course
You could also check for the count of item in the table.
rweap = {"Base.LeadPipe", "Base.Nightstick", "Base.MetalBar", "Base.Axe", "Base.PickAxe"};
rarebox1 = rweap[ZombRand(#rweap + 1)]
Right, so I can technically forgo specifying an exact amount of items, and just do #rweap and it'll automatically read the amount of items I have listed there?
ZombRand(#rweap) + 1 or else it can roll zero
thanks for clarifying
@proven bough So this way would be the cleanest i can think of right now.
--- check if other mod is active
local isBCGToolsActive = getActivatedMods():contains("BCGTools")
--- insert as many item to the table of your choice
local function insertMany(_table, ...)
for i, v in ipairs({...}) do
table.insert(_table, v)
end
end
--- this one must be global as this will be called by the recipe script
function Recipe.OnCreate.OpenRareLootBox(items, result, player)
--- Create listing that doesn't require mods
local rweap = {"Base.LeadPipe", "Base.Nightstick", "Base.MetalBar", "Base.Axe", "Base.PickAxe"};
local rsup = {"Base.Bandaid", "Base.Bandage", "Base.Disinfectant", "Base.HandTorch"};
--- If the mod is active add the items to the list
if isBCGToolsActive then
insertMany(rweap, "BCGTools.HandHatchet", "BCGTools.SplittingAxe", "BCGTools.CheapSurvivalKnife")
end
--- Picks items based on the table lenght using #tableName
local rarebox1 = rweap[ZombRand(#rweap) +1]
local rarebox2 = rsup[ZombRand(#rsup) +1]
local rarebox3 = rsup[ZombRand(#rsup) +1]
--- Add the 3 random items
player:getInventory():AddItem(rarebox1);
player:getInventory():AddItem(rarebox2);
player:getInventory():AddItem(rarebox3);
end
I see that your variable inside the function where not using local so they where global variables polluting the global scope. Just remember to add local if it is local to this function/file only.
Dude that is fantastic. I'm gonna test out this and see if it works. Thank you so much, you've been an invaluable help ๐
Is there a way to increase the width of the debug window in the upper right that shows the code? It's too short and there is no horizontal scrollbar
You can probably find it in here client\DebugUIs\
ah so mod the debug window lol
If you found Global Object too complex, too buggy, too obfuscated, you may wanna give it a new chance with the simplified interface from TchernoLib described here: https://steamcommunity.com/workshop/filedetails/discussion/2986578314/3812906855246163752/
how do i turn break on error back on after turning it off? i can't figure out how to manually open the screen where it appears
press F11
ty
the vehicle id for a given vehicle seems to change with each save game load, is where a consistent way to identify a vehicle across save loads? currently using vehicle:getID()
i think getId() is persistent? (lowercase d)
lowercase is vehicle id, uppercase is object id
ooh maybe getSqlId(), that would *have* to be persistent
and the fact that it's separate from getId() makes me think that one isn't
@bronze yoke I'm hoping to get a little clarification here
oh?
getItem wants the type of the item, not an item object
you can use shoes:getScriptItem() instead
and the arrows were just my way of showing that those two functions returned different things, i've been writing a lot of python and it's the return type annotation for a function there
this works, thank you
in other news
I thought stoppower was the same as STOMP power. I've seen spelling mistakes that are more or less the same so far in the codebase haha
however it is private. that might be an issue
hmm yeah, might need an instance then :(
I'm trying haha
will I be able to get the right name to get a new instance if I wrap "shoes" in a "tostring()"?
that will just get you the script item

though you'd need to use :getFullType()
to make a new instance i'd do InventoryItemFactory.CreateItem(shoes:getFullType())
ideally you wouldn't make a new InventoryItem, it's totally a waste, but it doesn't seem accessible on the script so oh well
ooh... this is a doozy
any issues?
yep--
for some reason taking off my characters shoes is resulting in... a _call variable not being set in a trait...?!
Hooking into this function was just supposed to increase the max time for some actions. I have no understanding why the stout trait would be involved here
I also see this in the console after getting out of the debug screen
yeah, that's a general error, whenever something goes wrong with an action it nukes the queue
there is no :create for the ISUnequipAction... no mention of stout (or any traits) in there that I can see
if it has no create, then it's calling the base one
the error implies that OriginalTimedActionCreate *is* the trait
which clearly isn't what any of the code i can see is doing
i mean
here's my object stack if it helps
the stout trait is there, for some reason, in memory
if you comment out line 426, does the error still occur?
it'll break the action of course but to confirm what's going on
one sec
commenting that line out crashes to main menu
when unequipping
this is line 61. So. The action itself gets really messed up haha
ah, that must be why it has so much better error checking than literally anything else in the game
okay, so. I moved line 426 down a bit and now I can do actions that aren't affected by my trait
I'm gonna take a wild guess and say that if I do an action that's covered by unweildy hands, it's gonna break. but maybe there'll be a more descriptive error
local OriginalTimedActionCreate = ISBaseTimedAction.create;
ISBaseTimedAction.create = function(self)
OriginalTimedActionCreate(self);
if self.character:HasTrait("AT_UnwieldyHands")
then
for _, action in pairs(AnthroTraitsGlobals.UnwieldyHandsAffectedTimedActions)
do
if self.Type == action
then
if getDebug()
then
print("UnwieldyHands activated. Old time: "..tostring(self.maxTime).." New time: "..tostring(newTime));
end
local newTime = self.maxTime * (1 + SandboxVars.AnthroTraits.UnwieldyHandsTimeIncrease)
self.maxTime = newTime;
break;
end
end
end
end
oh, now that i think about it it might be better that your code runs before, or the max time might not get modified?
for reference this is what it looks like now
That's an option. I can still modify it there, it's just a matter of preference I suppose
honestly 'why is my variable becoming Stout' is a new one for me
ok so million dollar mod idea
i need someone who can make it
totally accurate american healthcare
your character has an "insurance" stat that slowly drains over time, and you need to refill it with money
if you are uninsured for too long you lose health and die
cries in broke
You die because of no insurance.
Not sure if this is the correct place to post this, but I am really proud of this one!
It's a super simple mod that fixes melee combat so your context menu does not pop up while melee attacking zombies.
Please test it out! ๐
https://steamcommunity.com/sharedfiles/filedetails/?id=2986816238
Can any of the hair gurus help me? Ive been trying to make hair but the models arent showing up in-game. I followed Spongies hair mod tutorial to a T. What am I missing? I've included some pics to help
Hi everyone. Can anyone point me to a good resource of tutorials to get started in PZ modding? I've found a few different resources, but not sure which are the most up to date or most suited for a newbie.
Is there any way you can upload your mod to Steam Workshop as Unlisted so we can see your code and everything? (hard to help without that)
You know what would be cool?
A one-time BanHammer, a Sledge Hammer that upon attacking a target banned the target and then itself (the weapon vanishes)
Is there a way to ban a player for like, just 30 real life minutes?
If you figure it out I would like you to make a new type of Mohawk or two
lol ok XD
Not sure whether I should ask this here or in mapping but I'm currently using the Louisville only map. I was hoping to modify the map and add a few cells to create custom buildings, LV being a bit too cramped to add anything of any significant size. Is that doable or will that break everything?
Question for you, did you ever get this working?
Hey, if I wanted to change a items base values, say dropping the capacity of backpacks, do I just make a txt file in my mods scripts folder that's named after the txt file that handles bag values and have the changed code in it?
pretty sure i have this right but just to confirm since i'm new to PZ modding, there is currently no way to extend Java classes or copy instances of Java classes, right? It's just not supported in any way, correct?
Sorry I didn't see this earlier, going to sleep now... will check this out later and DM you.
Not yet. I've spent all my free time since then wrapping my head around metatables, etc. But ultimately I'm confused because I don't yet understand what Trait contains. Gonna try to dump the whole object in game later and see what I get. If I get to a point where I understand what's going on I'll be sure to let you know!
So far I understand the point of metatables and __index but I don't yet understand what Albion is looking for
ATM I'm at my MIL for dinner. Gonna dive back in when I get home
Anyone had any luck getting anywhere with adding medications, seems pain system is hardcoded in
i have it working between these two files https://github.com/demiurgeQuantified/Zombie-Contagion/blob/develop/Contents/mods/ZContagion_Traits/media/lua/shared/zcontagion/traits.lua
https://github.com/demiurgeQuantified/Zombie-Contagion/blob/develop/Contents/mods/ZContagion_Traits/media/lua/client/zcontagion/traitcode.lua
Sorry I should be more clear. Albion figured it out for the above two files. I'm sure you could copy and paste it pretty easily for your own trait. I just want to figure out why it works.
What you want is beyond the scripts
Shouldnt do things to other logos
Its basicslly disrespectful
I hope to God you aren't being serious.
Shit.
So is there no way to edit bag's? What about the players capacity?
you can edit them but it's very bad practice to overwrite the scripts of existing items
it's impossible for a mod like that to be compatible with other mods that do the same thing, and if the vanilla item gets updated your mod will fall behind
it's very easy to do in lua instead and dodges those issues
also overwriting scripts file means you'll have to redefine all vanilla items otherwise they'll be missing and it can fuck up servers
(happend to me once by mistake)
@TIS is there a way to make a camera follow another player in MP ? (a camera from a client following a player from another client, in lua)
blud tried to ping all the devs
i would ask aitrion
idk if he likes being pinnged tho
@thin hornet I've got this bit of code that I'm trying to optimise. You'll see what I mean when I post the code itself, but basically I'm trying to say "if this item is received, then add multiple of them". Here's the way it's been done originally, but I'm wondering if there's a better way...
if (legendbox2 == "Base.ShotgunShellsBox" or legendbox3 == "Base.ShotgunShellsBox") then
player: getInventory():AddItem("Base.ShotgunShellsBox");
player: getInventory():AddItem("Base.ShotgunShellsBox");
player: getInventory():AddItem("Base.ShotgunShellsBox");
end
if (legendbox2 == "Base.EngineParts" or legendbox3 == "Base.EngineParts") then
player: getInventory():AddItem("Base.EngineParts");
player: getInventory():AddItem("Base.EngineParts");
player: getInventory():AddItem("Base.EngineParts");
player: getInventory():AddItem("Base.EngineParts");
player: getInventory():AddItem("Base.EngineParts");
player: getInventory():AddItem("Base.EngineParts");
player: getInventory():AddItem("Base.EngineParts");
player: getInventory():AddItem("Base.EngineParts");
player: getInventory():AddItem("Base.EngineParts");
player: getInventory():AddItem("Base.EngineParts");
end
if (legendbox2 == "Base.SheetMetal" or legendbox3 == "Base.SheetMetal") then
player: getInventory():AddItem("Base.SheetMetal");
player: getInventory():AddItem("Base.SheetMetal");
player: getInventory():AddItem("Base.SheetMetal");
player: getInventory():AddItem("Base.SheetMetal");
player: getInventory():AddItem("Base.SheetMetal");
player: getInventory():AddItem("Base.SheetMetal");
end
there's an AddItems e.g. AddItems("Base.ShotgunShellsBox", 3)
Ahhhh I seeeee. So basically all I would need to do is
if (legendbox2 == "Base.ShotgunShellsBox" or legendbox3 == "Base.ShotgunShellsBox") then
AddItems("Base.ShotgunShellsBox", 3)
end
you'd still need to do player:getInventory():AddItems, but yeah
Ah right. So I'm guessing the AddItems part would go...after the getInventory?
also, if you cache the inventory at the start local inventory = player:getInventory() then you can just do inventory:AddItems("Base.ShotgunShellsBox", 3) it'll look cleaner and run a bit faster
Well, here's the first version of my furry traits mod!
If anyone has some tips on making the page look better, please let me know.
Also, I tried to post a link to my ko-fi in there and steam thinks it's malicious. I've seen other modders put their ko-fi's down--what am I missing?
About the ko-fi link, there was an errant quote in the url. oops
I'm almost done with my mod but I've hit another point where I don't know what I'm doing or doing wrong. I'm trying to make an emote make that emote reduce stress. I can make an option appear on the emote radial menu, but no matter what I do I can't make any emotes play in game from it. Looking at other emote mods they seem to pretty much just add the emote to the radial menu, add the anim and xml so I don't know what's missing. 
Did you make the xml file?
Yes I have an xml file. For testing I was trying to use an emote and xml file already from in the game renamed and edited to match the new name
is onplayercreated called every load or just initial creation?
I don't know if you're asking me. If so I don't know, as I said I don't know what I'm doing too well. 
just asking the channel
Ah, okay
I can't find this event. You should use OnCreatePlayer, it's for every time a player is loaded.
Anyway, search for link to Umbrella and Events files from Albion.
@woven brook @fast galleon
Thats what I meant
Said it from memory
3 am here just finished handling a 100 player server for4 hours
Only admin ๐
Lua language server extension on vscode. EmmyLua on IDEA
Ok ty
If I could get a microphone I could record a tutorial for setting up environments for modding PZ.
Eventually want to do that for java mods.
Wishful thinking.
I'm having a problem now where the game is not recognizing the clap emote. I have no mods active, files validated, fresh install, don't know what the problem is. 
I get warnings even when animation play.
