#mod_development
1 messages ยท Page 33 of 1
Any idea what function to use to reset a bool after each in-game day? (not each 24 in-game hours)
e.g. I want to allow the player to do x action only once a day
like you want it to reset at midnight or something?
yea something like that
you can just set it to whichever value lets you do the thing EveryDays
if you wanted it to be at a slightly different time, you could use EveryHours and just check the time
I will check both functions out. Thanks so much!
Re: running AwesomeTime + Le Gourmet Revolution concurrently, don't they have sharply conflicting farming frameworks?
Events.EveryDays.Add(function()
MyMod.MyBool = false
end)
Yea, I've read that. I have yet to progress that far in the game though. Planning to address the conflicts once I get there, if they aren't too time consuming
just to double check my knowledge of how Lua operates, this should work as well?
function setBool()
MyBool = false
end
Events.EveryDays.Add(setBool())```
The () you have after setBool will cause the function to be called and the return value of that function call will be passed as an argument. You want to pass the function object to Add(), so don't want to invoke setBool there
otherwise it will work, yes. You probably want to make setBool local, unless you plan on calling it outside of that lua file..```lua
local function setBool()
Actually that brings me to another question. That bool will be used in another file, a TimedAction. When that timed action is complete, the bool will be set to True
.. How can I exactly have the same bool work across 2 files?
By using the same identifier, and not declaring it local, which you haven't done
FYI one of the subtle problems with Snake's mods and the reason they have such wide-ranging compatibility issues is that they replace instead of supplement a number of core game lua including tooltips.lua for example -- so if you're running Snake's mods without explicitly maneuvering around that you'll eventually discover mods orphaned from the UI because there's nowhere for them to hook in, since broad swaths of vanilla engine are replaced.
ah so I don't actually have to import it manually into the files, it's just.. there
that last line is equivalent to the following
setBool()
Events.EveryDays.Add(nil)
So how I'd set it up is to put your stuff into a global table (to namespace it to avoid name collisions with other mods). Then initialize the boolean. Then in the files you intend to reference the boolean, you can require that file that initializes it
someone should have told me making games in java is so hard
Alright got it. Gotta do some research about global tables but the concept is pretty clear to me. Thanks so much for the help guys!
collisions are beating my ass rn
-- media/shared/ArendamethMod55_initializestuff.lua
ArendamethMod55 = ArendamethMod55 or {}
ArendamethMod55.MyBool = true
function ArendamethMod55.setBool()
ArendamethMod55.MyBool = false
end
Events.EveryDays.Add(ArendamethMod55.setBool)
-- media/server/ArendamethMod55_importantthings.lua
require("ArendamethMod55_initializestuff")
local function doFancyThings()
print(ArendamethMod55.MyBool)
end
@hollow current
god lua makes me want to cry
it's a mish mash of weird naming conventions
MyBool
setBool
i bet somewhere in there is a do_thing
Yea, I fixed that tooltips.lua issue.. At least the one I saw anyway
wow thanks so much! Now it makes me feel guilty because I didn't give it the effort to try to put it together myself beforehand ๐
I really appreciate it though
i kinda agree
I remember the first time I started playing around with java
took me a freaking week to get 3 lines put together that imported data from an online .json file
most things people don't get are the main function
this is kinda hard
but i think i know how i would do it
i have never done it, but i have an idea already on how i would
honestly python was the easiest I ever worked with
simple, on point, just makes you love your life
yes, because it is made to be that way
it's like saying scratch is easy. yes, because it is on purpose.
although scratch is a very heavy example
ah well its all a learning curve. You eventually get used to it
2 weeks ago I couldn't put a proper if condition together because I was so used to writing it in the form:
if:
#do stuff
else:
#do other stuff```
took me a couple of hours to realise its a different language and not same concepts apply ๐คฆโโ๏ธ
btw, by global table, all I meant was a table that isn't local.
Nearly all variables you declare without the local keyword are global.
this_is_global = {}
local this_isnt = {}
function foo()
this_is_global_too = 5
end
and its global across all files of the mod, yea?
anything that isn't declared local is global to the entire game's lua
all lua in that process, vanilla code, other mods
nice nice
MYNaming_conventions_AreGreat = "okay"
please
||I used underscore to fish for this remark btw, and it worked and I'm happy ๐ ||
the only proper naming convention is camelCase
those aren't even the worst
I had a project going on once and I went back to it after a month and I had to spend an entire hour deciphering my OWN code
"it worked and i'm happy" it takes nothing to get you happy i see
no dopamine having ass
lool
u32HungarianNotationIsGOAT
u32HungarianNotation is just weird imo
i like to know what everything is when i am calling it
not just bool1 and var1
i get you can also do it like bBoolName but that is still kinda weird to me
since i use intellij so i can see what kind of variable it is before i call it anyway (thanks intellisense)
quick question.
ArendamethMod55 = ArendamethMod55 or {}
We initialized ArendamethMod55 as a table using {}, but I don't really get the or statement. Why the ArendamethMod55 = ArendamethMod55?
if you start each file that way, it doesn't matter which order they load in
if the table already exists it'll use that one, otherwise it'll create it
It's a lua convention to initialize it only once (e.g. if you reload the lua file while debugging, ArendamethMod55 will already have a non-nil value, so it will use that existing value)
I would be interested in what you did there, I resorted to commenting theirs out
The first time that statement is run, ArendamethMod55 will be nil (which is a falsy value), so the right hand side of the or will be used ({})
ooo i get it
so its basically like
using ArendamethMod55 IF it exists, otherwise, create the table
I did some shenanigans with filenames and require to load snake's util mod's code first before other mods. That way mods that decorate the function will decorate snake's implementation (instead of the vanilla implementation, which snake's will overwrite when it loads)
i wish theres a mod that everyone is working on as a team . id love to colab with people
alright, and its generally better to have that statement in the beginning of each file that will have/use global mod data?
I think I came across a couple of mods from the workshop before where before can contribute
but I don't remember at all their names
what if its inside a local function?
is it still global?
is it to do the wiki page?
no i meant actual mods
where you could contribute by committing to the GitHub page
yea, that or require a file that initializes it
ahh i see
or atleast a collection of well organized snippets and functions and what not
that's why you're cautioned so much to use local whenever possible
Would be nice though to start a more thoroughly organised wiki page of PZ's functions/tutorials where everyone here can contribute
it'd be so much better for beginners (like myself)
public on github or something
that modders can use as reference
basically disected vanila lua and moders orginal stuff
and libraries and utils and what not
well anyone can start a project like that
be the change you want to see in the world
-- media/lua/client/!_miscpatches_bugfixes_SnakeUtilsPack.lua
local PATCHED_MOD_ID = "SnakeUtilsPack"
if not miscpatches_utils.initializePatch(PATCHED_MOD_ID, function()
-- Load SnakeUtilsPack's ISToolTipInv:render modifications first because it tramples over other mods
require("tooltip")
return ISToolTipInv.MakeFishState
end)
then
return
end
The filename starts with ! so that it loads before other mods. The miscpatches_utils function basically just calls that getActivatedMods():contains() api in that instance and the function return verifies the snake utils mod loaded successfully
im too noobish to execute haha
Well I guess imma do it
ReadTheDocs is a good host for documentations and stuff
I could try getting one up and running, as long as everyone's interested
What's the mod that lets you use empty cans as water containers/boilers?
i'm not sure i care much about documenting the lua and java, but documentation on the scripts would be nice
ill contribute what i know
i meant the pz code
ye exactly
i think the vanilla code is fairly easy to read and search with a bit of general knowledge of the game's workings, but the scripts are a total mystery to me
very true
be like the go to source for mod related stuff since we will also link it to other github pages that are public. wiki guides etc
particularly vehicle scripts which don't seem to be finished
damn how many languages do u guys speak
the code for their game is pretty tight
Was there a mod that let you put and boil water in empty tin cans?
it could be a good way to encourage people to use apis/frameworks/whatever they want to call themselves
i think so, but i don't know what it was called; try asking in #mod_support
So i can experience the joy of gradle all over again...
Did you happen to publish this on the workshop, or just use misc. patches locally? I play with a half dozen friends on a dedicated server but this is much more elegant than quashing the lua unilaterally and appears to still pass through the fishing components.
this game i am making is turning out to be a lot more work then i signed up for
anyone know how to convert the speed of the mouse into a hVelocity?
on the x plane
ya its pretty clear the vehicles are more WIP than other things in game. Stuff in the vehicle scripts like gear ratios aren't even used and other things are called from the script every time so you can't even modify them at runtime
i was messing around with the install table for vehicle parts for a bit until i found out:
a) drainables aren't supported yet
b) the keep=true/false keyword doesn't do anything
c) the ui doesn't actually show if you need multiple of an item (unsure if it still works, just noticed this was hardcoded in the ui)
but to be fair, vehicles aren't supposed to be finished, like not just from the limited flexibility of the scripts, they don't have their animations and stuff yet
Ya, my "parts" code doesn't actually use parts for some of those reasons
everything is just strings and doubles in the ModData until you go to pull it out
huh
I can later if you want. It is just a random collection of little tweaks and mod compatibility fixes
I've got a quick question.. how does the mod loading order work?
If I put my mod as last in the list will it overwrite the one behind it or is it the other way around?
I'm under the impression its actually just alphabetical at the file level, but maybe somebody else has a better idea
I can change in pzserver.ini and adapt the list and make the order myself.. I just don't know which one overwrites the other..
later mods will overwrite earlier mods
Thanks ๐
(i think...)
if the files have the same name and location, ya maybe
i'm going to load up a bunch of mods to check
@livid geode
this doesn't answer their question though
I think later mods in the load order win if multiple mods have files with the same path? I'm not sure about that
oh my bad, you were still typing
Ah, nm. I'm talking about the order lua files are loaded
I'd appreciate that, I'm sure a lot of folks could use the assist with Snake compatibility too! FWIW I have posted a more thorough english translation mod for Snake's
Well I'm getting a weird thing where the texture for ALICEpack_Camo_Pink cannot be overwitted by the next mod in the order.. whereas others are.
Speaking about LoliAlicePacks mod texture change
There is a mod that allows you to control the mod load order via the UI btw. Mod Manager
Oh, I'd be interested in that
https://steamcommunity.com/sharedfiles/filedetails/?id=2866697618 There was a surprising amount that was still Spanish in the EN translation, I also spent a lot of time trying to go through to thoroughly tweak and clean up the existing EN translation for consistency on capitalization, phrasing, tooltips etc. to match PZ.
https://steamcommunity.com/sharedfiles/filedetails/?id=2868734860 Better Sorting for Le Gourmet Revolution
https://steamcommunity.com/sharedfiles/filedetails/?id=2869324238 Better Sorting for a -lot- of other things.
https://steamcommunity.com/sharedfiles/filedetails/?id=2810180951 AFAIK this is the only mod so far to try to tackle farming crop compatibility for Le Gourmet Revolution, though the approach here is just a recipe option to convert one itemID of seeds into the same seeds provided in LGR. I would like a more elegant solution to ideally bring some of the other modded crops that LGR doesn't have into coherency with the same framework though, e.g. Rugged Recipes has Cucumbers and LGR doesn't.
Thanks
Yea, next thing I was going to do it make the hunting feature in snake's mod compatible with britas/arsenal firearms
But still haven't really progressed far enough to be able to need it (died in the last save I had that found the hunting gear), so might be a long while before I get around to that
sooo umm
~~https://projectzomboid.readthedocs.io/en/latest/~~
For anyone happy with the idea and willing to contribute!
not an efficient way of doing things, never mind
Should be relatively easy to anyone familiar with Github
There's a mod that has tackled this as well, fortunately; crossbows get a little trickier in general because none of the Brita crossbows want to play nice with other mods for bolts as ammo etc.
shouldn't Events.EveryDays.Add(ArendamethMod55) be Events.EveryDays.Add(ArendamethMod55.setBool)? To specify the specific function, assuming we have multiple funcs?
they say mod load order is important so if its alphabetical then it wouldnt make sense that we need to arange them acording to individual mods nature
If I can get Fx Clothing Tweaks to not use another renamed ItemTweaker that'd save 20 seconds; ideally it'd just use the default ItemTweaker API anyways, but it could also probably use an update for a bit of additional coverage generally.
yea, I missed that when typing it up
ah it's okay, thanks!
for britas? I found one for firearms b41, but not britas
There is a reason people put !!! or zzz at the beginning of their file names. Mod load order may matter for which file gets loaded first if they have the same location, but there is more to it
if u use ArendamethMod55.setBool
u will need
ArendamethMod55 ={}
correct? i e started learning tables and still not sure about how things work
I believe so, as setBool will be stored in the table if I am not mistaken
this is literally my first day with tables too lol
That's probably doable, since you can overwrite that mod's file containing the copy
ArendamethMod55 = ArendamethMod55 or {}, or better yet require ArendamethMod55
by the way, ArendamethMod55.MyBool = true
Assuming the player is in, say, SP. Wouldn't loading into the world intialize the mod, and thus setting it true immediately, even though its intended, for example, to be set to true only when the setBool is called on the EveryDays event?
The lua files are loaded before entering the world. You can use the OnGameBoot (think I spelled that right) event to know when it starts
but that still poses the same issue, relogging into the game will reset the bool?
The real trick is trying to scratch the surface of phasing out Better Sorting's item tweaker copy cc since so many things explicitly reference it, whereas the Fx clothes tweak + Eliaz better bags 1.Item Tweaker lua forks are just identical to the regular API and don't add / change anything (apart from 20 seconds of extra game boot time, grrr)
So it would be initialized to true prior to entering the world. I understood you said you'd be using the boolean potentially before setBool is ever called, so figured you want to initialize it in some way
correct
what i basically mean is
Player is intended to do x action only once every in-game day. Once he does that action, the bool will be set to false, so he can't do that action again, until the bool is set to true using the setBool function after one day has passed. Now, assuming that player does that action, then relogs, technically he can do it again, no?
why not keep a timestamp in their moddata instead?
Sounds like you probably want to initialize it to what's in moddata if moddata is available. If not available initialize it to true.. if I understand your requirements correctly
Aye fellas! I've got a question regarding modding. Is there any way to extract the 3d models from PZ? I'd like to get a player model so modeling becomes less of a pita when deciding on scale and such. If my memory servers me right I think I've seen these resources online as well, but now I can't find them for the life of me :o
Check pinned messages in #modeling, there are a few models there, player character included
Yea, could do that too, and just check if enough time has elapsed since last usage
I think the bools for moddata will be easier for me since I definitely have no idea how to compare times in lua lol
assuming there is a way to get date and time, either RL or in game
plus it'll be tricky since its intended to reset at midnight of each in-game day, and not technically after every 24 in game hours of doing the action
irl time is available in the os table. There's some function for in game time too, but I can't recall it atm
Thank you! :)
My pleasure!
if the game time is retrievable, and I assume it is because things like whether the power is still on rely on it, then you could just compare which day it was done last to what day it is now
this would break if the admin rolled the day back, but I'm not sure that's even possible
and you can tell if you went back in time more than a day anyway
Just to overwhelm you with more options (๐), in your EveryDays event handler, you could set a boolean in the player's moddata to true. Then in the function that checks whether the action can be performed, if the boolean is not in the moddata or if it exists there and is true, it can be performed. After performing the action, set it to false. That should work too
I guess I could try implementing either ways and whatever works, just works
okay gimme a min to process that
Might need more than a min
is this happening server side or client side?
Well mod is intended to work both for SP and MP soo I guess best is to make it compatible for both
sure, but thats not really related per se
anything you handle clientside only is going to get lost on relog, right? So you have to consider that
.. except moddata, no?
anything defined in moddata stays there, even after you relog, right?
still has to be transmitted to the server to be stored, I'm not sure if that's handled automatically or not
hmm I may be lying, it may get stored locally, which is a great way to enable cheating but w/e
My understanding is most moddata is automatically persisted. The exception is global moddata (moddata not associated to any object), which you have to call a function to explicitly transmit to server / to client
all the moddata on vehicles has to be transmitted manually
and the transmit functions don't all work, lol
but players are likely different
ye its just "one piece of moddata" to be stored on the playerObj
I would still advocate for a timestamp, a boolean has no context and if they aren't logged in when the day rolls over it won't get reset properly, a timestamp just requires a simple comparison
I wish I had the API on hand to tell for sure if you can get a useful timestamp
lemme see if I can find anything useful on the PZ's official API or vanilla files
getGameTime()
there's a getGametimeTimestamp() but i'm not sure exactly what format that would return and that would actually make things harder for this specific usecase
There's also apparently a getTimestamp()
lemme try to print both and see what I get
you can set the player's mod data to getGameTime():getDay() after they do the action, and then only allow them to do this action if the current getDay() is greater than their mod data
that would work through relogs and in multiplayer
getTimestamp() is irl time in seconds since epoch if I recall correctly
getTimestampMs() is same but in milliseconds
i love java
System.currentTimeMillis
lemme see if that works
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
LocalDateTime now = LocalDateTime.now();
System.out.println(formatter.format(now)); ```
๐ซ
โ supremacy
oh and you'd probably want to set it to -1 when they create their character, Events.OnCreatePlayer (check that they don't already have one as this event runs when loading a save too)
os.time()
gives time since epoch I believe. I just wasn't sure of the function name
same as System.currentTimeMillis
gives time since like 1970 or something
i forgot
yeah Jan 1, 1970
Might be simplier imo to infer moddata not existing implies the action was never taken so it should be available to perform
getGameTime():getDay() is the ticket, for this use case the time IRL doesn't matter
But I'm lazy like that ๐
that's probably the better way of doing it
i agree ๐ค
puffin on zooties and she calling me daddy
One thing I don't get about vehicles is it appears that the engine overheats faster if there is no hood
there is engine overheating system in PZ?
overheat is probably the wrong term, but yes there is engine heat, I think its related to how well your heater works, I haven't looked too deeply yet
Has anyone been able to find where the implementation of ILuaGameCharacter is?
If someone knows where it's at, please ping me. Thanks.
i've seen some stuff to do with engine heat, but does it actually do anything?
i've seen how it's generated and stuff but not what it actually does
I think the heat your heater puts out is related to your engine heat, but like I said I haven't really looked yet
Anyone knows how the vision cone of the character is created/calculated? If im not wrong it has something to do with the IsoObjects$VisionResult but i cant get more out of it
can i put my item definitions under media/scripts in an arbitrary subfolder like media/scripts/mysubfolder. And basically the same question for media/textures/mysubfolder and media/textures/WorldItems/mysubfolder ... ?
does anyone know if theres a way to get a unique value from a character (id)? if one player for example creates multiple characters by dieing, i'd like to get a unique value for each character that is also unique on the server.
hmmm.. I would think a player's sqlID might be useful for that, but doesn't look its accessible
I don't know about anything built into the game but you could use a save file and this https://pzwiki.net/wiki/Modding:Lua_Events/OnCreateSurvivor
thanks, i'll have a look
its Iluagamecharacter.java
not much to say other than its in the java decompile
i've been considering it
Ive been looking for a modder for months
If we're looking at the same thing, that's the interface.
I'm looking for the class that implements it.
isoplayer, isogamecharacter, isozombie, etc
IsoDummyCameraCharacter, IsoGameCharacter, IsoLivingCharacter, IsoLuaCharacter, IsoLuaMover, IsoPlayer, IsoSurvivor, IsoZombie, RandomizedBuildingBase.HumanCorpse```
Add me on discord maybe I got some free time
Is there a mod that makes Project Zomboid look as much like the original The Sims as possible?
my man
i'd like to hear what you're looking for myself
So does zomboid use a different java compiler than the usual ones?
don't think so, I compiled some stuff with java 17 and its playing nice so far
you using storm api?
nope
are you making mods in java?
no, I just patched some stuff thats currently broken
still doing that lua style for now
gerald absolutely ravenous for any mention of java modding
yes
Anyone have a problem where player built things dissappear when you leave a chunk and come back?
from a mod you're making?
Well, in my new graffiti mod placing the graffiti works fine, but when I left the chunk and came back all the graffiti was "gone", as in still there but invisibile. The option to remove it even though you couldn't see it was there. I have no idea why it wouldn't just persist
I wasn't sure if this was a problem with the mod or a problem with the server I was using
FYI, that info and info like it is easily available at https://projectzomboid.com/modding/ or in your specific case https://projectzomboid.com/modding/zombie/characters/ILuaGameCharacter.html. See section at the top called All Known Implementing Classes
package index
Extremely useful tool
is the option to remove it still there if you log out and back in?
I assume that option doesn't show up if there is no graffiti?
it persists but it has become invisible on a server. Apparently my friend just tested and it persists and doesn't become invisible in single player.
Yeah that option only shows up if there's graffiti on a tile
I dunno how to confirm if it's a MP issue with the mod or if it's just my server though X_X
running a different server locally would probably be your best bet
I can't imagine you have to do anything special to transmit the tiles from the server, but I suppose you could look at another mod that adds tiles to be sure
@hearty dew Did some testing, and getTimeSinceZombieAttack is independent of game speed... in fact I'm 99% certain it updates OnTick
Anyone have a guide for overriding vanilla items? I thought I understood how to do it but all the items I try to add that should override don't show up at all.
i've seen people just use ```
module Base {
item PUTITEMYOUAREREPLACINGHERE {
UPDATED INFO GOES HERE
}
}
but I'm assuming this would also work and is probably better to do, just test out both ways
module whateverthe.txtfileiscalled {
imports {
Base
}
item PUTITEMYOUAREREPLACINGHERE {
UPDATED INFO GOES HERE
}
}
^
Thanks - there must be some other issue here. The top one is the method I have been using but doesn't seem to override. The second one creates the item as an additional item when I try that. Not sure what is causing it tho.
someone else totally should
IIRC the game adds it (imports)
Okay I just did some testing on this. It seems to work with regular items, doesn't seem to work with Weapons. I will do some more testing and try and figure out why - the example I was looking at was a weapon so there must be something else breaking it that I don't understand.
I just did it with crowbar using my first example and it seemed to change the base item and attributes, but if any of the names and values they = inside of the items { } are wrong you will get some weird errors or it will just straight up fail, gl
Cool. That sounds right. I am honing in on it... I think I may see the problem so I have a couple things I will try. Thank you for your help!
@abstract raptor Hey Aza, I think your issue with the new Graffiti mod, might also be the same issue that seems to be occurring in the Repair Wall Cracks mod - assuming that both yours and theirs are replacing/adding map tiles or overlays, maybe to certain layers? I haven't looked in to the inners of how either work, but I can understand it's likely to be similar.
With the Wall Cracks mod, can repair them, but you leave the area/come back after a while and suddenly they're all back again - thought it might just be the erosion progressing - but it's not.
Although on that note, could be something to investigation - when the erosion kicks over, if that might be clearing or overriding whichever layer you're using?
So apparently you can force sandbox vars to load before OnDistributionMerge and OnPostDistributionMerge
local EarlyBootSandbox = function(newGame)
if not SandboxVars and not isClient() then
print("Attempting to load sandbox options earlier than normal")
getSandboxOptions().load()
end
end
--Events.OnPreDistributionMerge.Add(EarlyBootSandbox)
--Events.OnPostDistributionMerge.Add(DoStuffWithSandboxVars)
alternatively the safer way appears to be
local EarlyBootSandbox = function(newGame)
-- ~stuff~
ItemPickerJava.Parse()
end
Events.OnInitGlobalModData.Add(OnInitGlobalModData)
Any info to add multiple requirements to a recipe? Trying to require an elec level, as well as a custom skill tree level.
Sorry, I should have been more specific... multiple skill level requirements
SkillRequired:MetalWelding=5;Electricity=5,
Okay, that's what I thought it was, but it has... issues.. lolz.. I'll keep workin at that, thanks
what are the issues you are experiencing?
He's trying to use a custom skill tree, does that not require more indepth
Awesome. I will test this. I would love to get those sandbox settings working for distribution.
eh the second one seems safer
the first one reloads the files from disk
then gets called a second time
the second one does this which you can infer what it does from most of the names
I will give that one a shot first. That is going to be really helpful.
you actually would just need ParseSuburbsDistributions() and ParseProceduralDistributions() but those methods are private
lol same i have been beating my head for my next update to carwanna
im so close
Thanks for this -- I know the graffiti is actually overlays and not like a proper constructed tile
That did it, thanks for confirming.. the issue was entirely on me; I used the wrong perk name. ZedCraftChemistry versus ZedSmithChemistry
- facepalms -
oh man
Yeah that one loot table / sandbox setting issue is the only thing in my mod that I couldn't figure out without a bunch of extra crap I don't like haha
capitalizations and misspellings are my #1 enemy
Same tho lolz... I cannot even count the number of times a bug/error was caused by those two things...
i already did the trial by fire of cAsInG and sorting based on filename sorting order burning me for a week
lol
Does anyone know where I could find 'WorldObjectSprite'? I'm trying to make a Moveable item but have no idea where I could find Sprite images or files.
I have not done moveable items but I have done sprites, I think start here: https://pzwiki.net/wiki/New_Tiles and here: https://theindiestone.com/forums/index.php?/topic/44033-latest-tilezed-and-worlded-december-21-2021/ - there may be newer tilezed, but I think that is where I got mine.
Tiles Tileset images For Windows TileZed + WorldEd 32-bit TileZed + WorldEd 64-bit For Linux TileZed + WorldEd 64-bit This was built on Ubuntu 20 and won't work with older versions of glibc. If WorldEd is crashing when opening cells, try turning off the "Use hardware-accelerated drawing (OpenGL)"...
Sprites are in .pack files so you cannot get to them without looking into those files
Oh my god Thank you so much
I found some tutorials but it was outdated. Will look into it. Thanks!
No problem! Good luck!
I may have figured it out haha... looks like it caused other issues though.
@sleek saffron ```lua
local function OnZombieUpdate(zombie)
local zombieModData = zombie:getModData();
--if not zombieModData.TrippingZInit then
local zombieData = getZombieData(zombie);
zombieModData.TrippingZInit = true;
zombieModData.TrippingZombiesSpeed = zombieData.speed;
zombieModData.TrippingZombieCrawler = zombieData.crawler;
zombieModData.TrippingZombiesFakeDead = zombieData.fakeDead;
--end
I need to do something similar, and was curious what you learned that led you to recalculate the zombie data on every `OnZombieUpdate` rather than rely on the data already cached in the zombie's moddata?
hell yes
@elfin stump did u see this?
ugh big pain in the butt to not do it otherwise
Ohh yeah I saw it! ๐ I am excited about it
Why the need for the not isClient() check?
Ah
honestly though i think hitting the itempicker with parse is the lesser of two evils, that only seems to rebuild a the distribution tables in java from what i can tell
@calm acorn Hmm, would that cause any modifications to loot tables by later loaded mods to not have any effect?
i noticed when i was loading my loot with OnInitGlobalModData that it was in the loot table for lootzed but it would never drop
the Parse() call. Or will it reparse again later and re-read the tables?
no its only called once in isoworld.java on line 1661
the issue is you cant read sandbox options until they are loaded and i really dont want to use lua config mods for my endusers
That makes sense if the tables were modified (during OnInitGlobalModData) after the tables were Parsed
its like man... would be really cool if cough sandbox variables loaded sooner
Mm, I hit something similar with the sandbox vars not being available early enough for some mod patches, so I just went with Mod Options, even though it is quite awkward
yea
yeah im currently in the process of pulling it out
Me too, I ended up using dynamic loot and hardcoded sandbox settings in submods that disable my dynamic loot if you use them. - How did you use Mod Options to do it?
Is your fix still hitting snags?
no
Awesome I have not used it yet
the issue im having now my procedural loot lists are acting up
what is dumb is i can sit there and just bam bam bam hit refill container and all of sudden the game will be like boom https://puu.sh/JoNJt/721d11f7bc.png
proc list has a min 0 and max of 1 lol
They don't spawn on their own though?
nah they do they have a really low chance
I didn't need it specifically for loot tables. I needed config options very early in the lua load sequence (at the beginning of when shared lua files are loaded, which are loaded before client (and before server)) files. Did this:```lua
-- Not necessary atm since this file is alphabetically after !ModOptionsEngine.lua
--require("!ModOptionsEngine")
if ModOptions and ModOptions.getInstance then
ModOptions:getInstance(miscpatches_utils.MOD_OPTIONS, miscpatches_utils.MOD_ID, miscpatches_utils.MOD_ID)
end
miscpatches_utils.initializePatch = function(patchedModId, verifyIsLoaded)
if not miscpatches_utils.ModOptionsLoaded then
miscpatches_utils.ModOptionsLoaded = true
if ModOptions and ModOptions.getInstance then
ModOptions:loadFile()
end
end
-- etc ...
Awesome thank you.
that's in java tho im not sure u can call that..? or is it exposed
But it's not a great user experience
The user has to config mod options before starting the world. That's an extra pain if it's on a dedicated server, bc there is no UI
honestly id be surprised if that's exposed, but im guessing u know well enuff to have checked or tested it
no that method is public and you can grab the instance via getSandboxOptions() int he luamanager
huh
I see, thanks for the info it is helpful.
a generic mod that just loads that will fix a bunch of mods that uh.. don't work with sandbox options atm
usually those have a method to grab a instance of them
some times they have a static ref on them that you can just grab them directly
oh man honestly the only reason im able to do half of what i can figure out is cause i keep the java open
And you can print out the metatable to see what methods are exposed as functions in lua @weak sierra
once you have an instance of the java object in a lua object
The lua object pretty printer I pasted here a few times will print them out
i have it open too, have done things
and reflected to do things that i shouldn't do when i can't do things
and keeping the option to java mod the server open when i still can't do things
:|
(at least for my own server, can't really redist that)
oh man i saw some of that naughty java on that respawn mod, gave me some ideas i didnt know i could get into trouble with
A static method? How do you call those? Through the __classmetatables table?
Hadn't thought about how to call static methods/fields. Hmm
That'd be handy to get fields like GameServer.instance, etc
Scriptmanager.instance works for some strange reason, even though there is a getScriptManager
Oh, don't even need to mess with that. It's right there in _G, heh
i think class.instance usually works (when applicable)
yea, exactly. Nice
i think the getters look pretty so i use those
That's a lot easier than the hoops I was jumping through before
They are also arranged in java namespace e.g. zombie.characters.IsoPlayer, zombie.inventory.ItemPickerJava, etc
if they can expose .instance fields I wish they would just expose all the public fields
The public fields should be exposed, if their class is exposed in the Exposer
no fields are exposed, only methods
except for rare instances, no pun intended
we went through this the other day, even with reflection shenanigans you can only write to public fields in debug mode, outside that its read only and kinda nasty
Yea, they should be exposed and readable. That's what I mean (not writable)
You can do ScriptManager.instance:getBlaBla(), which is what I would consider the minimum level to be considered exposed, tbh. Having to use the reflection library to access a variable doesn't count imo
thas cheetin'
Oh, I see where you're coming from ๐
So public static fields are exposed that way (readable, not writable). public instance fields are not however (only methods, as you say) ๐ค
I assume it a limitation of kahlua, but lord knows
weird asymmetry
i think thats cause its exposed in the luamanager and instance is a public static in ScriptManager
you could boot the server in debug mod but your console would get really chatty
Try explaining that to someone downloading your mod on the workshop, lol
:p hey those java mods get traction, some one might be willing if it really does something they want
lol

im gonna make a version that uses a javamodded server to get better access to the vehicles.db
Its a bit of a catch 22, nobody uses the java api because it has no support, it has no support because nobody uses it. I don't think java mods can be distributed through the workshop, but I don't know why, surely someone could flange it up to work right
and do more fancy stuff
they can't be distributed because u have to actually inject them into the game files which is outside the workshop folders
technically u can distribute the files, someone would have to write a loader that would collect and relocate them and do waht is needed
well if the Minecraft Forge team can make an api that lets you dump mods in a folder, surely the PZ community can too
tho if ur using a java hook like stormapi
then u can just put it in a workshop mod yes
but since there's no java hook in PZ
u have to install that hook first by hand
which is a huge barrier to entry for most users
if TIS would give us a java hook we could basically do anything we want
would be more like modding rimworld
Thats a lot of hooks, the would sit side-by-side with the kahlua hooks... it would probably be ok, but no reason to maintain both. They'd likely want to drop kahlua, which would tick some people off... I dunno its a mess
kahlua as far as I can tell is also a dead, unsupported project, something's gotta give
oh rly
Pretty sure it is 2. Some of the changes in 2 I noticed in what pz runs
so i dont see them dropping it
last commit is 11 years ago
doesn't mean it's a problem
lua is a simple language
it's not like some huge new feature gonna drop tomorrow and break everything
nor is it like we couldnt sit on 5.1 or whatever
It's a problem bc kahlua isn't even to lua 5.2 spec ๐
lol
i never knew lua before this so that hasnt bothered me lol
same boat, blessing/curse i guess lol,
welp nope turns out my loot tables are working im just tired and never realized when you have a range of min=0, max=1 that you get 0 loot some times even when your table is set to 100% lol
went in and set it to 1/1 and bam works.... turned that back off
I may look closer at Storm. If they were smart enough to make it work somewhat with workshop it may be worth it. They say they have some 150+ events you can listen to, if even one is onVehiclePartDamaged ...
you can javamod the server by hand on a particular server and then expose whatever u want in lua or make whatever events u want
and use non-javamodded clients
just can't easily javamod the clients
w/o technical users willing to do a thing
thats true, if as long as whatever hooks you put in are server-side only, you could possibly make it compatible with vanilla clients in a dedicated server setup
couldn't legally distribute your server changes though
Can do that and rely on server/client commands to do quite a bit, perhaps. Things like mechanics of vehicles being the exception since those are executed largely in client-side java code
ya, most of the physics stuff is client side, which makes sense
My main point of frustration is that I can listen for the incremental "wear and tear" damage on a vehicle, and I can listen for when one crashes into an inanimate object, but the only way to track damage from hitting zombies is to attach to OnTick and check all the parts on the vehicle every tick. Its gross, and I'm fairly certain why I get like 10fps in some modded cars. But it may just be the rendering engine for all I know
Since you're already modifying the java, you could add triggerEvent(onVehiclePartDamaged) to the java side while you're at it
haha I could... I haven't decided how far I want to distribute my mod yet, but if its "further than my circle of friends" I have to keep the jar hacking to a minimum. Currently all I change is how Engine Power is handled, in anticipation of them fixing it in build 42
Hopefully they would fix it. Maybe could send a patch their way to increase the chances
they are aware of the issue and may fix it for 42 according to their forum. The fix is literally commenting out a single line so I'm sure they can handle it, lol. If we're lucky they'll also take out the magic number gear ratios and actually use the ones in the script
VehicleHit might be exposed to AddXP
I'm not clear on how this would be useful
looks like it the description of the xp source should have Vehicle in it
is this called lua-side?
i can't say i've tried, but i didn't think we could access that stuff
I assume the lua function that would get called to add xp is IsoGameCharacter_XP:AddXP() but I don't see any instance of it being called by the lua for anything besides the admin console or doing things that increase your perks.... actually, XP is only for perks right? What XP would you get for running over a zombie?
longblunt I suppose
Events.AddXP.Add(owner, type, amount)
maybe type == Perks.Driving fires off when you hit something
driving is a modded perk, isn't it
oh damn yeah i think your right, eh thats just a sign i need to go to bed, have a good one mate.
have a good night, thanks for the idea though. I'll root around a bit
anyone familiar with how the chat system works
i made custom commands but when u hit enter they sit in the chat box
also maybe just checking for blood intensity cause i think those get set when you hit things
need to know how to clear the chat box
or maybe defocusing clears it..
probably something on textEntry anyway..
why am i even asking i know waht im doing im just too tired to think

I thought about listening for when the vehicle texture gets damaged, but that only happens past a certain threshold. I assume blood is the same, but maybe not...
i don't think there's anything useful you could hook into for that either way
my only hope atm is looking for some single variable that changes when damage happens, so I can check one thing per tick instead of every part
either that or what I'm currently doing, which is hooking into part updates and just partially reverting/redistributing batches of damage
yeah that's how mine works
it's not perfect but it's definitely the best way of doing things i can find
have you figured out a nice way to handle windows breaking? I was thinking of just storing what window was in the spot and putting it back if it disappears
no i haven't really thought about that yet, but that's probably what i'll do
that or freeze the part's condition at 100 so it just doesn't happen, which may be a better way of doing it
by just topping it up every update?
well it'd be exactly the same code as the protection already uses
even if you replace the window it'll still make the smashing sound
also worth looking into is why windows are deleted when other items aren't, might be able to just turn that off
now that you mention it, in the part damage code there is special mention of windows..
of course right now I can't seem to find ANY of the relevant code, may be bedtime for me too
god i need to get up in three hours lol
here it is
function Commands.damageWindow(player, args)
local vehicle = getVehicleById(args.vehicle)
if vehicle then
local part = vehicle:getPartById(args.part)
if not part then
noise('no such part '..tostring(args.part))
return
end
if not part:getWindow() then
noise('part ' .. args.part .. ' has no window')
return
end
part:getWindow():damage(tonumber(args.amount))
else
noise('no such vehicle id='..tostring(args.vehicle))
end
end
this command is unfortunately hidden in a local table, BUT part:getWindow():damage() should be injectable
oh well that makes things easy
if we can verify nothing else damages windows that's most of the updates gone
hmm, this command may only fire when you break a window with the vehicle context menu
ya, BaseVehicle.addDamageFrontHitAChr(), which is what is called when you hit a player or zombie, doesn't issue any commands or trigger any events
that sucks
worth mentioning though is that Brakes and shocks never take damage from a zombie impact, so thats a small handful of checks that can be avoided
i wasn't actually planning on protecting those
Tires, headlights and taillights, engine, hood, trunk, gastank are damaged by zombie hits
everything is damaged by crashes
and I imagine that damagewindow command is called when a zombie tries to get you through the side window
๐คฏ What Xyber said on his way out might actually be the ticket. Every single zombie hit increases the blood intensity, which I think is set with VehicleCommands.Commands.setBloodIntensity(), if so, hooking into BaseVehicle:setBloodIntensity() should fire every single impact... gonna try right now
Thats what I'm going to test. If the blood intensity is set by that command, we're good. If not then we're SOL
well i'm ever hopeful!
crashing into an object is handled this way, so we may get lucky
dang, no go
ok, so this is what I've found re: detecting and/or stopping damage to a vehicle from the lua side
- Crashing into stationary objects aka trees, fences, building etc:
BaseVehicle.crash()is called, from the lua, every time this happens. Hooking into it lets you reduce the damage or negate the crash altogether - Hitting zombies
So far no secret sauce, but if you're going to run aOnTickorOnPlayerUpdateevent listener that checks the vehicle, storing and comparingBaseVehicle.getBloodIntensity("Front")andBaseVehicle.getBloodIntensity("Rear")will tell you at least when an impact has happened, or at least one large enough to cause damage. At which point you can then scan through the parts to see what got damaged and revert it if you choose. This is more performant than checking the parts every tick, but how much more performant? I don't know. Also could run into an issue if blood intensity has a cap, because after that obviously it wouldn't change again until you clean the car. If thats the case you may have to check if its hit the cap and revert it a little - Zombies breaking windows to eat your brains
Hooking intoVehicleWindow.damagewill let you know every time this happens and alter it. Unfortunately, you'll have no idea what window on what vehicle is being damaged. Using the Reflection library, you could get a hold of the part the window is in, and if you make a habit of marking a vehicle's parts with its ID then you could retrieve it, but its all kind of a mess. Personally I'm just going to go back to overwritingVehicleCommands.luaand adding the linereturn VehicleCommandsat the bottom. By doing this, you can just hook into the commandsVehicleCommands.Commands.crash()andVehicleCommands.Commands.damageWindow()and still have painless access to the vehicle being damaged
tl;dr
you can detect and sometimes alter all damage a vehicle takes, fairly efficiently, by watching a couple things. But there are challenges
Oh i almost forgot, there is another kind of damage, wear and tear, that can be intercepted by overwriting each part's update function. The only kinds of damage left are from guns and potentially players smashing a window. I'm not sure if the zombie window protection will work in that instance
i have my icon of a new item in media/textures/subfolder/Item_BusTicket.png
and this is the content of items_BusTicket:
module Test
{
imports
{
Base
}
item BusTicket
{
Type = Normal,
Weight = 0.01,
DisplayName = Bus Ticket,
DisplayCategory = Junk,
Icon = subfolder/BusTicket,
WorldStaticModel = PaperNapkins_Ground,
}
}
But in the game the icon is not showing up. any idea?
I am not sure if folder names matter, but here's how I got my custom item icon to work:
--Battery Jumpstarter\Contents\mods\Battery Jumpstarter\media\scripts\item_jumpstarter.txt
module Base
{
/************************ Mechanic Items ************************/
item Jumpstarter
{
DisplayCategory = Tool,
Weight = 5,
Type = Drainable,
UseDelta = 0.2,
DisappearOnUse = FALSE,
UseWhileEquipped = FALSE,
DisplayName = Battery Jumpstarter,
Icon = Jumpstarter,
MechanicsItem = TRUE,
Tooltip = Tooltip_item_Jumpstarter,
WorldStaticModel = Jumpstarter_Ground,
}
}```
then I put the icon in the following directory:
Battery Jumpstarter\Contents\mods\Battery Jumpstarter\media\textures\item_Jumpstarter.png
You also want to make sure your icon is .png
i have the exact same structure, except everything 1 level deeper in subfolders. hmm.
try to not make it 1 level deeper and see if that changes anything
any idea where I can find the vanilla code for adding the "randomise" and "play" buttons in the character customization window?
ProjectZomboid/media/lua/client/OptionScreens/CharacterCreationMain.lua: local button = ISButton:new(self.outfitCombo:getRight() + 20, self.yOffset, 15, comboHgt, "Randomize", self)```
Thanks!
Off the top of my head, I believe it's to cater for mods that alter zombie lore mid-game.
Ah, that makes sense
new to the game how do you deconflict mods in this game?
You can create a mod that patches the conflicting mods. Among other things, that may include patching functions, overwriting files, change the lua file load order by using require and deliberately naming files to load a certain way, changing/merging recipies/items.. Lots of stuff. Depends on the nature of the conflict
well let me be more precise I have a modd causing issues how do I find out the trouble maker, everytime a cutscene starts my game closes back to menu.... but most of my mods are vehicles
I tyried using the debug but its not showing is there a log file?
What errors are you getting? It will be logged in Zomboid/console.txt in your home directory
im not seeing a console.txt in ProjectZomboid in my steam directory
do I have to have debug on to dreate file?
Zomboid/console.txt in your home directory
i do not have a console.txt file in my home directory. Do I have to enable it? Purchase through stream
no, it is always created when starting pz
You looked in the Zomboid directory within your home directory?
That would be C:\Users(yourname)\Zomboid
within ProjectZomboid there is no file or subfile labeled console.txt, i just searched and even unhidden filed to verify. No just to make sure Im not stupid by home directory you mean roughly \SteamLibrary\steamapps\common\ProjectZomboid
ok thanks found it, hold while i read up on the problem
shows the mods being added, and exiting to main screen but doesnt say why?
Tons of errors in there. Here is the first:
LOG : General , 1665522336725> -----------------------------------------
STACK TRACE
-----------------------------------------
function: POETBagsBuffMODDED.lua -- file: POETBagsBuffMODDED.lua line # 12 | MOD: [POET] Carry More Stuff
ERROR: General , 1665522336730> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: Object tried to call nil in POETBagsBuffMODDED.lua at KahluaUtil.fail line:82.
ERROR: General , 1665522336730> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: Object tried to call nil in POETBagsBuffMODDED.lua
at se.krka.kahlua.vm.KahluaUtil.fail(KahluaUtil.java:82)
at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:973)
at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:163)
at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1980)
at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1782)
at se.krka.kahlua.integration.LuaCaller.pcall(LuaCaller.java:76)
at se.krka.kahlua.integration.LuaCaller.protectedCall(LuaCaller.java:117)
at zombie.Lua.LuaManager.RunLuaInternal(LuaManager.java:555)
at zombie.Lua.LuaManager.RunLua(LuaManager.java:501)
at zombie.Lua.LuaManager.RunLua(LuaManager.java:487)
at zombie.Lua.LuaManager.LoadDirBase(LuaManager.java:334)
at zombie.Lua.LuaManager.LoadDirBase(LuaManager.java:261)
at zombie.Lua.LuaManager.LoadDirBase(LuaManager.java:380)
at zombie.GameWindow.init(GameWindow.java:1203)
at zombie.GameWindow.mainThreadInit(GameWindow.java:575)
at zombie.GameWindow.mainThread(GameWindow.java:488)
at java.base/java.lang.Thread.run(Unknown Source)```
Im not sure code wise as im new to this game, bu what is the killer one here looking for critical error or something to that end
LOG : General , 1665567112634> EXITDEBUG: MainScreenState.enter 2
DEBUG: Animation , 1665567112635> FileTask_LoadMesh.loadFBX > Loading: G:\SteamLibrary\steamapps\common\ProjectZomboid\media\models_X\vehicles\Vehicles_SmallCar02.FBX
LOG : General , 1665567119789> EXITDEBUG: onMenuItemMouseDownMainMenu 1 (item=MODS)
LOG : General , 1665568079961> EXITDEBUG: RenderThread.isCloseRequested 1
LOG : General , 1665568079961> EXITDEBUG: GameWindow.exit 1
SmallCar02 comes up alot
The moment of the error was during the execution of POETBagsBuffMODDED.lua. You look to pay attention to this line especially: Object tried to call nil in POETBagsBuffMODDED.lua at KahluaUtil.fail line:82.
Specifically, Object tried to call nil means the function called by an object was perceived not to exist, perhaps because referenced it incorrectly, or perhaps because it truly does not exist.
Question. How would you go about editing a container? As in furniture. I'm trying to simply increase the capacity of various bookshelves, but I don't really know where to start.
I've never done it, but, shot in the dark, you might need setCapacity(int capacity) in zombie.inventory.ItemContainer (https://projectzomboid.com/modding/zombie/inventory/ItemContainer.html)
declaration: package: zombie.inventory, class: ItemContainer
That's the thing, I looked there but setCapacity is not in ItemContainer.
This guy might have solved it: https://steamcommunity.com/sharedfiles/filedetails/?id=2719850086&searchtext=container
Do you know how to look at his code by subscribing to the file?
Yeah I do, I did it here and there. I'll give it a look
GL
@thick karma @hearty dew Thanks for your time and help
No worries, you make progress solving that error?
That mod didn't really help as it doesn't touch furniture items from what I can tell. An idea would be to replicate the Organized trait behavior, maybe.
I don't think you can modify container size in a way that will save in the container through lua. you would need to make a new tile with the new size. I faintly remember that someone tried to modify them in code, and it was possible for existing containers, but that it would get reverted when the tile is unloaded and loaded. Im guessing because when being saved and unloaded, the tile is saved as the original tile rather than a new thing with the adjusted properties. so depending on how variable you want to be able to expand the capacity it might be easier to just make for example 4 more copies of the bookshelf with varying capacities in the tile sets, then when your character upgrades a bookshelf, you would replace the tile with the upgraded ones, rather than trying to modify the existing bookshelf
Mhmmm. This is annoying because I do it easily with wearable items :/
That method you described would only work for any new item that I create, while I'm trying to make work for all containers, to help with mod compatibility.
How does Organized do it then? Clearly it boosts container sizes without editing them prior, right?
unfortunately that stuff is hardcoded in the javaside so I don't think it would be easy to manipulate
public int getEffectiveCapacity(IsoGameCharacter var1) {
if (var1 != null && !(this.parent instanceof IsoGameCharacter) && !(this.parent instanceof IsoDeadBody) && !"floor".equals(this.getType())) {
if (var1.Traits.Organized.isSet()) {
return (int)Math.max((float)this.Capacity * 1.3F, (float)(this.Capacity + 1));
}
if (var1.Traits.Disorganized.isSet()) {
return (int)Math.max((float)this.Capacity * 0.7F, 1.0F);
}
}
return this.Capacity;
}
Maybe not manipulate, but replicate. I won't touch anything that's hardcoded
What class is this from, if you don't mind?
ItemContainer.java
Thanks, I'll give it a look. Looks like something I might be able to use or just learn from.
Yeah that's what I thought. There is the getter for capacity but not the setter. Without it I'm stuck
Simple question, how do you get the user name client side. getPlayer().getUsername() doesn't work
You mean the name of their character or the Steam user name?
Are you running in steam mode? If so, I wonder whether username even supposed to be set in steam mode
using :getUsername() returns the name of the player you're controlling
I just tested it before replying to Sal
I am trying to figure out if he just needs a colon instead of a dot, or if he needs different info entirely
"doesn't work" is ambiguous
oh, yea, should use : syntax there
ok will try that...
lol, NFI what i'm doing but managed to make good progress anyhow
Persistence is half the battle. (The other half, of course, is knowing. GI Joe.)
Hey, does anyone know where I can find a list of all names that can be randomly generated? Like their first and last names separately
FWIW Organized / Disorganized in multiplayer don't revise a container's capacity for all players, only for the players with those traits interacting with something -- doubtless to prevent a situation where disorganized players grief people by shrinking containers, or people insisting someone with Organized go rifle through all the boxes like King Midas' touch.
So it worked.. thanks guys. My mod is done!
How to get items AFTER death?
getPlayer():getInventory():getItems() -- empty list
When I want to test a mod online with another player, do I need to upload it to the workshop first?
Or can I share the file directly or something like that?
you can share the files directly
Nice... is anyone bored enough to help me test my Meditation mod? I'll give you credit on the Workshop page to move people who see my mod in the direction of your mods...
I've seen other mod code that accesses the inventory on the death event Events.OnPlayerDeath. Might try that?
After death, maybe the inventory contents is no longer on the IsoPlayer object? Perhaps it moves to a zombie object? Just a hunch
Hey, when I try to Host, I get a weird error...
What's weird is I'm only running one version of Mobile Reader on server and it comes from the Steam Workshop tab
So how would it be referencing the old one?
if you have it installed to both folders, then some weird stuff might happen
the priorities for which it loads are weird
I see. Okay, so in general, just develop in Workshop and ignore mods if a mod is intended for online play?
it depends, i find it easier to test locally with two non-steam clients, and they won't load anything in workshop
just make sure to stick to one (or at least only have one in its folder at a time), the load priorities can be inconsistent
Do you have to buy the game outside of Steam to launch it independently of Steam?
no, you just use the launch argument -nosteam
or maybe -nonsteam i don't remember exactly
I see, okay thanks
this way you can join a local server with multiple clients without steam auth tripping out
Oh wow so I can launch a second Zomboid using -nonsteam (or something) and join my own hosted server for testing?
Also, can the nonsteam client join a Steam host?
no, everything needs to be nosteam
Got it, appreciate all info
I give up on my furniture thing. Can't figure out a way to change that without editing one a java class.
Hello, this is probably a dumb question but where can one find the scripts for the different medical items? In the "items" .txt there are some, but they do not define what should happen to the character once they get used. Any ideas?
The ItemTweaker api prints a line for each item it tweaks. With all the mods I have, it comes out to 5521 items.
The function to apply all those tweaks takes around 22 seconds with a print for each of those tweaks.
After changing the code to append each line to be printed into a table and doing one big print at the end, print(table.concat(printOutput, "\n")), it only takes 0.1 seconds ๐คฏ
There is a newitems.txt. Might check that. If not, you can search all the scripts files for what you are looking for, bandage, alcohol, etc
yeah, prints are really really slow
You will be my hero forever if we can somehow manage to encapsulate all these various rogue duplicate copies of ItemTweaker and its derivatives and just make a cohesive package with more efficient code.
I'm running 390 mods so you can imagine how long itemtweaker takes for me when I have basically four variations of it all running ongameboot
Oh, this is awesome. I had a function running for like 5 mins to print out some info about objects before I finally gave up and killed pz. Now it prints in about a second
Yea, that's what I've done heh
DarkSlayerEX hasn't updated ItemTweaker since 2015, if they'd be willing to pass the custodial torch that would be a huge boon for the modding scene in general I think.
strings and printing are always the slowest part of anything, good job
@bronze yoke Issue just occurred to me... if I run with no Steam, it won't connect my controller via Steam, will it?
Seems like an obviously or at least probably not...
if you're launching the game through steam i think it still will
Okay, so I just launch game once through Steam, and then once through Explorer, and host from Explorer version and test on Steam nonsteam? That should work afayk?
i think so!
suppose to be
getPlayer():getUsername()
Yeah, it's working now. I assume : is because it's LUA calling Java?
Appreciate the direction, will try that
: is used for functions that have self as their first argument. This would be any non-static method being passed from Java, but you'll also see it from lua stuff as well
aka Something:setValue(input) === Something.setValue(self, input)
I mean you don't really need itemtweaker. its basically just a one liner
Even so, it is ubiquitously used in a lot of mods.
right but, there is basically no reason for it to be used in mods
because it doesn't really do anything other than change a getitem call and doparam call into a a tweakitem call
Most of what I'm getting at is that if you can update and correct some of the core issues in the API you can effectively eliminate those issues in multitudinous mods that otherwise are never going to update on their own.
The trouble is mods like this end up having 10 different abandoned versions from 10 different Devs and nobody knows which one to use, better to just start over and put in some compat with the original
well, I guess that is true. the way I see it, the problem is caused by using itemtweaker, and itemtweaker really doesn't provide anything IMO.
It's all well and good that there are better standard practices that could be conveyed to modders who are actively working now, but so many servers and players are sitting on ancient and obsolete versions of legacy staples that are never going to get updated, and once b42 hits there's likely to be all sorts of fallout from people being confused and ornery that 40 mods that haven't been updated since 2016 don't work anymore.
(Referring to broader issues than just ItemTweaker having more efficient alternative implementations now.)
yes, itemtweaker is not as useful as it seems, but patching itemtweaker is by far easier than patching every single mod that uses it
Right now the biggest problem is that over the years several mods decided 'I use ItemTweaker, but what if ItemTweaker goes missing or gets edited in a way that affects my mod? I know, I'll just pack in my own renamed variant of it for myself.' and then all of them have ongameboot copies of the same routines but they're separate so suddenly a large loadout has four different versions of ItemTweaker all re-running on boot and adding 80 seconds to launch time when it could be 5.
yeah bundling dependencies is really annoying
ya think the author will remove it?
Unlikely, many of them haven't looked at PZ or responded for going on a year or longer.
This most glaring example of this is probably Better Lockpicking + Profession Framework and the dozens and dozens of visually similar duplicates all trying to fix the same problems but breaking them in different ways.
that one profession framework offshoot is so annoying
it was made to fix a bug that isn't even in profession framework anymore, it overwrites the original completely, and is now a massively outdated version of it that totally breaks one of my mods
its very annoying. could have uploaded a single line of lua that would have fixed that bug (ie: a proper patch) but instead uploaded the whole thing causing numerous issues.
There are a whole lot of core modding staples in PZ that could badly use actively maintained githubs nowadays
Steam's Workshop is kind of awful for trying to have multiple contributors working on things though
i recall some other games having workshop items that used a bot that would automatically update from github
That sounds fairly slick
yeah, I feel like if steam would let accounts properly transfer ownership of a workshop item, it would be amazing for keeping those older mods alive
and nor requiring filling steam with clones
like for example the irrigation mod I think has 4 different mod pages, as people picked it up then abandoned it after a while
I mostly feel bad for most of the typical users who (really not blaming them) have no clue of what to look for or how to distinguish what is or isn't a maintained / working copy of something, blind-subscribe to an assortment and then wind up helplessly frustrated when things don't work and not knowing how to troubleshoot it.
local function tick()
if ... then
Events.OnTick.Remove(tick)
end
end
Events.OnTick.Add(tick)
why does this not work?
xceptionLogger.logException> Exception thrown java.lang.RuntimeException: Object tried to call nil in tick
Whereโs my fellow Java modders
Some variable with nil value in the ... part being called perhaps?
It should give you a line number to help narrow it down
Soooo, I don't like the way the context menu is popolated, but apparently this code works
-- This using this globals IMHO is awful, but this is also how TIS does it so, idk it's free code I guess
---@diagnostic disable-next-line: lowercase-global
clickedPlayer = nil;
function TMCOnFillWorldObjectContextMenu(player, context, worldobjects, test)
local playerObj = getSpecificPlayer(player)
if playerObj:isAsleep() then return end
for i,v in ipairs(worldobjects) do
ISWorldObjectContextMenu.fetch(v, player, true);
end
if clickedPlayer and clickedPlayer ~= playerObj and not playerObj:HasTrait("Hemophobic") then
if test == true then return true; end
local option = context:addOption(getText("ContextMenu_Medical_Check_Mx"), worldobjects, ISWorldObjectContextMenu.onMedicalCheck, playerObj, clickedPlayer)
if math.abs(playerObj:getX() - clickedPlayer:getX()) > 2 or math.abs(playerObj:getY() - clickedPlayer:getY()) > 2 then
local tooltip = ISWorldObjectContextMenu.addToolTip();
option.notAvailable = true;
tooltip.description = getText("ContextMenu_GetCloser", clickedPlayer:getDisplayName());
option.toolTip = tooltip;
end
end
end
Events.OnFillWorldObjectContextMenu.Add(TMCOnFillWorldObjectContextMenu);
clickedPlayer is a global inside ISWorldObjectContextMenu and if you the fetch using ISWorldObjectContextMenu.fetch(v, player, true);, it populates the global in your file too , odd but it works
that sounds similar to a problem someone else had, they couldn't access a global until they required the file, maybe there's something i don't understand about globals
Anyone want to enlighten me to how the game sends signals to close popup windows? Is it unique for different kinds of windows or is there a universal function that works? Does the game have any built-in function to close all windows (inventory health, server info, etc.) on screen?
doesn't everything close when you die? worth looking into
Oooo good idea
I dunno if server info and such would
I usually close all that before I die
I'll look into it when I'm home but I'm afk so brainstorming remotely r.n.
it's possible that it just stops the ui entirely when you die, which wouldn't be any good for what i think you're trying to do
it populates the global in your file too , odd but it works globals are globals... accessible to all files and functions. if the vanilla is defining the global clickedPlayer theres no need to also define it in your file (all your doing is changing the value, which was probably nil at that point anyways)
Since I have joy pad detection almost working (may have to work out a bug for MP, but working in SP), i want to assign a button press to close-all
@bronze yoke
That's what I'm trying to do
hm yeah i guess you'll just have to look into exactly how death does it, at worst you might have to manually call whatever function closes each window individually
Interesting, thank you fenris
because it's possible that death just kills the ui entirely
For sure, and I am aware of the latter option but hoped maybe y'all's collective genius could spare me the pain if I asked haha
Definitely doing this asap
Nobody needs to use item tweaker; it's actually simpler to just use the vanilla functions that it serves as a wrapper for.
The code can just run raw in a lua file in the shared or server directory.
local item = ScriptManager.instance:getItem("Base.Vest_BulletPolice")
if item then
item:DoParam("Weight = 8")
end
If the item exists; it will be tweaked, otherwise nothing will happen.
Technically it's slightly more onerous because that's multiple lines for TweakItem hitting something on a single line, but nevertheless I'll work to convert at least my own patches to just use that instead of ItemTweaker.
Add and Remove seem to take an Event object according to the doc online, but whenever I call Add, I do not create an Event object, I just send it a function... Maybe Add has a way of turning a function into an Event, but it doesn't work backwards?
Hello, is there a file i can reference to make something that is similar to a clothes dryer in game?
An Event has an index apparently... Having no index to tell it what to remove could mean remove doesn't work
I do not know... these are guesses
remove does work, a mod of mine uses it
i don't see anything different about this code though so i can't offer any help
Assuming I'm still defining these categories in the translation file, is this valid as an example if I'm undertaking disassociating applying sorting categories from requiring any version of ItemTweaker?
which one is the good one?
ok, that one is the one I'm subscribed to, good. Its a good thing that mods that list the other one as a prereq don't force you to load it
That depends entirely on if the mod itself listed something as a prereq-- prereqs on steam workshop are a separate thing
If you run a mod that wants the antiquated b41 profession framework version it'll force it in-game.
obnoxiously, that version has more than twice as many subscribers
Yep
Hello, is there a file i can reference to make something that is similar to a clothes dryer in game?
like i want to make a clothesline so people can dry their clothes off the grid but am having trouble finding any kind of tutorial or anything for help
Considering you can dry clothes in an oven, you may be able to accomplish something like that by making a container that warms its contents as a surrogate clothesline -- though it'd also technically cook food placed on it. ๐ค
you probably just need to setWetness() periodically, i've never done anything with containers so i'm not sure exactly how you'd do that though
thank you for the advice! ill have to look into those.
Hello, how do you set the model and texture of an item you've created yourself? I've followed some tutorials who (barely) explain how to do this and looked at some other workshop mods as an example, but I still can't figure it out. Anyone got a link to some sort of wiki for this or knowledge on this topic they'd like to drop for me? <3
I wonder how much the total workshop count for PZ is inflated by Brita's requiring servers to publish their own separate settings mod
probably a couple hundred ๐จ
Does Lua have the functionality to pick something randomly from a .json table? Or is there a better way of doing it?
Google suggesting to me you'll need an external library to play with JSON n LUA but I could be wrong
At a glance lunajson might help
@hollow current
Will look into it, thanks!
@austere finch steam://openurl/https://steamcommunity.com/sharedfiles/filedetails/?id=2874475795
If you want to test out the patches to make ItemTweaker load faster
an idea came to me. if you intend to make a modification to make itemtweaker faster, one thing you can to mitigate issues from people packaging in their own mod, is to clear the ItemTweaks table so any further inserts into OnGameBoot will have an empty table to parse through. ofc it won't work if the modders also renamed the table but many probably haven't. then you just need to manipulate the event tabel to make sure yours is first
I use JSON.lua http://regex.info/blog/lua/json
MyMod = MyMod or {}
MyMod.JSON = require("lib/JSON")
local jsontext = MyMod.JSON:encode({"foo", bar = "baz"})
local object = MyMod.JSON:decode(jsontext)
It serializes well to files too using getFileWriter / getModFileWriter / etc
I have a couple mods that "require" the knockoff version, but they work with the original since they both use the same function names and variables. I think the only way they'd be incompatible is if they checked the workshop id or if it relied on some function that only exists in one or the other
one of my mods needs a few functions that are only in the official version
i don't think the official version lacks anything in the forked version though, i'm pretty sure it's just a one-line change of a now very outdated version of the framework
To indentify a user, should I use :getUsername() or :getSteamID()? ๐ค
getSteamID() will only work on steam
It depends on what you want to do, but usually, it's through his id getOnlineID
Isn't that just a small integer?
I'm looking to set the "owner" of an item and I need it to work in SP and MP
if u have a function with a local variable
and within thay function u called another function (without the "return")
will the parent function absorb the local var from the function i called
or will it pass to the child function its local var or only "return" can send variables this way?
At the moment I'm doing it like this:
local bodyMeasurementsItem = self.character:getInventory():AddItem("TailorMadeClothes.BodyMeasurements")
local name = "Measurement of " .. self.otherPlayer:getUsername()
bodyMeasurementsItem:setName(string.sub(name, 1, MAXIMUM_RENAME_LENGTH));
local itemModData = bodyMeasurementsItem:getModData()
itemModData["bodyMeasurementsID"] = GetBodyMeasurementsID(self.otherPlayer)
function GetBodyMeasurementsID(otherPlayer)
return otherPlayer:getSteamID() ~= 0 and otherPlayer:getSteamID() or otherPlayer:getUsername()
end
for single player you can just do something
if getPlayer():getUsername() == "the userneme" then
for mp u have to make a read write files i guess
only return
Oh I see, in this case, getting the id will not help you much, you can try with what you mentioned above
can we return multiple var?
or we do that by array containg the var?
yes
ok thnx alot
return a,b,c
a,b,c = function()
I'm wondering if this would work
function GetBodyMeasurementsID(otherPlayer)
if not isClient() then
return 'localPlayer' -- for SP Only
end
return otherPlayer:getSteamID() ~= 0 and otherPlayer:getSteamID() or otherPlayer:getUsername() -- for Steam and NoSteam
end
local tick;
tick = function()
if ... then
Events.OnTick.Remove(tick)
end
end
Events.OnTick.Add(tick)
Note that RELOAD such a lua file in debug mode will cause glitches.
and it's broken, too
lol
This should work: ๐ lua function GetBodyMeasurementsID(otherPlayer) return otherPlayer:getUsername() end
Would this work even In SP? ๐ค Does the player have a username in SP?
Sure. It's just name + surname
yeah
who would be the otherplayer in SP?
๐ฎ interesting
herobrine
There is also
player:getFullName() -- first name + " " (space) + surname
๐คฏ
Thanks man
Has anyone tried using getMaintenanceMod()?
This is the code from 41.68, I'm not sure if anything has changed.
int var1 = this.getPerkLevel(PerkFactory.Perks.Maintenance);
var1 += this.getWeaponLevel() / 2;
return var1 / 2;
}
I'm on 41.71 and calling that method gets a value of 2 for Maintenance 5 with a weapon at level 5. Expected value should be 3.
given that its integers it looks like the outcomes are being truncated
Yeah, I tested it and Java floors any double to int coercision, but it should still be 3, no?
ya I suppose so, unless += is somehow evaluated before the /2, which would strike me as odd
do either perk level or weapon level start at 0 instead of 1?
they both do, but that's how it's displayed in-game anyway
I didn't even know weapons had levels ๐คทโโ๏ธ
isn't getWeaponLevel() just shorthand for getPerkLevel(whatever perk the weapon you're holding uses)?
ah, I see, so BaseballBat.getWeaponLevel() would return your long blunt perk
I double checked getPerkLevel(Perks.Maintenance) and it returns 5. I'll try out getWeaponLevel now.
Literally my first day attempting to mod PZ. I want to create a whitelist of destroyable objects. I may be naรฏve but so far I think I could do this by overriding the ISDestroyCursor:isValid function in ISDestroyCursor to only work for a set list of objects/tiles if the user isn't an admin but I'm a bit stuck on how to find the objects/tiles I want to be able to destroy.
Yeah, it also returns the proper weapon level
All I can think of is that there's a method that overrides it and that it's getting called. But I haven't found that method, yet.
FWIW, I'm using the getPlayer() function to get the values in Lua.
Either way, I appreciate the help.
If someone could dump a print statement in a mod and check the return value of getPlayer():getMaintenanceMod(), I'd appreciate it. Maybe it's something on my end, but I have tested with only 1 mod running, so it could be that that the code is different for 41.71 or who knows.
it's actually part of IsoGameCharacter, but yeah, i think so
hello, I'm wanting to learn to program and I really like pz, is starting with mods a good start?
on 41.77 , with maintenance 5 and long blunt 5, I get a maintenance mod of 3 on a baseball bat
Desperately searching lua's for any details on death or dying events, or more directly for any details on UI closing events, and coming up empty-handed ๐ญ
I wish there were a LUA/client/UI folder or some equivalent that just dealt with all of the popup interface crap
Create a item or something like that, also you can see other mods to get exp or check game files
lua is mostly pass by reference when it comes to tables, right?
where do you develop?
I like VS Code because it's dark and almost as fast as notepad and has autoformatting for many things, including LUA
And it's free
thank u bro
I've seen people using notepad lmao, I can't understand that
I just hate how it looks and the lack of autoformatting is in general a huge waste of my time
The tenth of a second saved opening Notepad is paid for 100-fold by autoformatting.
My best code is written in notepad with my monitors brightness and contrast maxed out at 3am.
That sounds like a personal problem. ๐
This would likely be of great assistance to you in learning to do what @ruby urchin recommended. https://www.youtube.com/watch?v=N6tZujOPnDw
This tutorial video will show you how to make a simple drink in Project Zomboid. I will go into the steps involved from start to finish. Read more below.
0:00 intro
1:08 Start
1:44 Searching for images to use in game
2:30 Searching for the Sound Effect
3:06 Creating mod file directory
3:54 Creating mod.info
4:34 Creating a poster
7:14 Adding ne...
(Expect to pause often.)
this will be very useful, thx 
๐
i have quit doing stuff in mc tho
because i quit playing mc
i quit like a month ago since i only played anarchy mc and that finally got to a point where it was so dead it wasn't even worth to play anymore
shit was boring af
every time i start looking at mod packs i start getting that itch but then i remember all the hell i went though with just getting stuff working with forge and gradle, but i was using eclipse at the time.
just use intellij
there is a plugin on intellij now
that will set up the project for you
and you can just jump straight into coding
im using intellij now but mainly to decompile pz so i can look at all the fun undocumented stuff
i won't make pz mods until i can learn how to use storm api
i refuse to learn lua
i won't kneel down to the devs wanting to make the game easier to mod for kids
well im more a c# guy now but i guess 90% of the time the same.. ish code lol
@slow granite just wondering do you think there will ever be native java modding?
or at least a official api to do it instead of having to use a back doored method like storm api
i just prefer java
it looks cleaner imo
and i prefer the way it operates
that's why i kinda want to learn whichever c lang is closer to java i forgot if it is c++ or c#
c# is just msjava
i think it might be c#
ye
i am about to try and add a event bus to my game i am making
any hints?
I have more use for it at work, im a IT system admin so i deal with powershell and .net at work
i want it to be able to be able do the @SubscribeEvent call
ah that's dope
that is what i want to be when i get out of college
atm i am a senior
in hs*
any hints?
i could def use some
i have the general idea of going into computer science in college but just wondering if there is something more specialized you would recommend to get a more higher chance at acquiring a it system admin job?
theres an debug tool on the context menu that lets you push zed or stagger them
but this is only happens to the one doing the command . on other players eyes it didnt happen right?
do you guys think its possible to make it for real i mean make it so that it actually happened?
How do I go about changing animations for zombies based on their current speed (Sprinter, Shambler, Slow Shambler) and tying that to a sandbox setting as well.
this has been done by UdderlyEvelyn when she made a patch on Bikini's mod
i knew you were lying about the company lol
check out other zombie mods for reference i guess
is it possible to send a message to a particular radio in game, or is it all channel based?
I tried to find death-related UI closing events or other UI closing events of any kind in the LUA earlier @bronze yoke... Alas, I failed to find anything. I have no idea whether a window-close call can be sent to Zomboid on the LUA side. Have you ever seen anyone do custom menus in this game, or can you think of any other mods that might have a hint about how it could be done if it is possible?
sorry, i have no idea
No sweat just thought I'd ask
i've been lucky enough to avoid ui for the most part
Your idea was legit but I am failing to find anything good unfortunately
it must be from java or something
My thoughts too
if you have the object, yeah
WaveSignalDevice:AddDeviceText()
Hello! @undone elbow just saw that you are the creator of Mod Options mod, and just saw (and checked to confirm) that since today's hot fix the mods that adds options are throwing error (I'm also getting this with Customizable Zombies), I switched to public branch and no problems, also tried with the mod isolated. If you are interested in checking ๐
Yes, getCore():getVersionNumber() doesn't work
I guess this function has been removed
nice, I'll give that a go
Ohh, makes sense why Bow and Arrow also throwed that error. Gottcha ๐ thanks for the explanation
not sure what the last argument is but the first five should be text, r, g, b (as values from 0-1), codes
codes?
I can add backwards compatibility patch to ModOptions, so all that mods will work fine, if you use ModOptions ๐
Yeah, some of the mods I use, uses the Mod Option so is always there in the modlist xD
stuff like stress reduction
if you're just using it as a fancy print like you mentioned a while back, you can probably just pass an empty string
ya, more or less, I want debug messages about a particular vehicle to come out of that vehicle's radio
first var is a player, hmm
I guess only a single player can see the message, little odd
weird! that's not how it shows up on the javadoc
deaf players can't hear debug messages I guess
ah, looks like the one without the player is an overload
WaveSignalDevice has no implementation for the non-player version, so I guess its up to whatever implementation the vehicle radio has
oh that's right, that's an interface
ya, they didn't follow the i prefix convention, smdh
well the vehicle radio is implemented in VehiclePart
triggers an event, so its completely different than the other one. That's neat. Looks like the last var may be the channel
oh, no, its a distance setting of some kind, not sure what it does I'll just have to mess with it
oooh, the interactions let you do the perk points or buffs/debuffs, thats kinda cool
Fixed. Update ModOptions, it should fix all the mods.
It was easy enough. ```lua
-- Path the core, so fix all the mods causing errors.
local core = getCore()
local m = getmetatable(core).__index
if m.getVersion then
m.getVersionNumber = m.getVersion
end
Oh, that was fast ๐
Awesome!
been trying for 30 minutes to get some code with table.unpack() to work, only to find its just unpack() in kahlua apparently ๐คฆโโ๏ธ
Show your example. What is your goal?
Is there a way to somehow temporarily increase the chance a player misses his shot (guns) and miss his swing (melee weapons)?
I think the accuracy perk looks like be directly related, did you check it?
Nope, gonna check it out
I didn't test and not sure u can use it via lua but only java
but u can try to use getAimingPerkHitChanceModifier/setAimingPerkHitChanceModifier
whelp, after sorting out the table.unpack vs unpack issue and fighting through some client/server shenanigans, I finally got debug messages to come out of a vehicle's radio
kinda neat, even if a bit pointless in the long run
Can't successfully put it to use. Can't find either in vanilla files either
thank you. that worked. ๐ฅ
aa i see, but doesn't this set the hit chance modifier for a specified weapon only, rather than making it apply to all weapons?
u can add mod on equip and remove on unequip
makes sense, gonna try putting that to use in that way. thanks!
yeah it's pointless but it's cool as hell
yep gl
I think the latest one is working
lmao someone forgot to remove some prints on ...\ISUI\ISInventoryPaneContextMenu.lua#L448-L459
Hey gang I am hyper new to lua, coming in from quasi-intermediate C#. I'm getting a "tried to call a non-function" error from line 31. Anyone able to spot why that is? My "ask google" skills have failed me here
(ps I'm 99% sure that someTable[i] is not at all what I want, but I was playing around with that one in desperation.)
Line 30 should be for i, v in pairs(someTable) do
also in Line 31 you will want set the value and not the key
soo im trying to get text from the forenameEntry textbox (the textbox where you enter your name in character customization), and use it in another textbox modal. My code doesn't seem to be working correctly. Any idea what I am doing wrong?
Here's the error:
ERROR: General , 1665641709506> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: attempted index: getText of non-table: null at KahluaThread.tableget line:1689.
ERROR: General , 1665641709506> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: attempted index: getText of non-table: null```
and here's my code:
function CharacterCreationMain:onBackgroundButton()
self.modal = ISTextBox:new(660, 250, 600, 500, "Test Modal", self.forenameEntry:getText(), nil, self.buttonConfirm);
self.modal:setNumberOfLines(15)
self.modal:setMultipleLine(true)
self.modal:initialise();
self.modal:addToUIManager();
end```
the problem is primarily with self.forenameEntry:getText() since changing it to a simple text works
aaand ofc I find the solution right after I post the problem.
had to change it to MainScreen.instance.charCreationHeader.forenameEntry:getText()
Pairs! Thanks lots, working now ๐
Also would encourage you to encapsulate your reimplementation of TweakItem somewhat, rather than overwrite the global TweakItem function. That's used by 100 other mods. Something like: ```lua
MyModNamespace = MyModNamespace or {}
MyModNamespace.TweakItemData = MyModNamespace.TweakItemData or {}
function MyModNamespace.TweakItem(itemName, itemProperty, propertyValue)
MyModNamespace.TweakItemData[itemName] = MyModNamespace.TweakItemData[itemName] or {}
MyModNamespace.TweakItemData[itemName][itemProperty] = propertyValue
end
MyModNamespace.TweakItem("Base.Apple", etc etc)
Hmm I'm not going to touch the TweakItem function, I'm just implementing a new "TweakTable" function in there. Should be alright I think?
@hearty dew
I don't understand the context. How are you only adding a new function? Is not the entire file within your mod? Or is it mostly duplicated from ItemTweaker_Core.lua?
Or are you modifying another mod locally? (which is going to cause issues in multiplayer, because it does lua file checksums)
Duplicated from ItemTweaker_Core.lua yeah. Just following what I've seen some other mods do where they've entirely duplicated tweaker core at the top of their lua for the item adjustments
And adding another TweakTable function isn't a problem, no. It's the overwriting of TweakItem that can cause issues (It's an issue because many mods do this, they make little changes, and overwrite the same global function that many mods use)
Okay should be good then, not touching that!
No, you are touching it. lol. That's the issue ๐
Ohhh no haha I don't get lua at all ๐คฃ
So if you want to add a copy of ItemTweaker_Core.lua inside your own mod without overwriting any other implementations, this is how you can do that (thought I wouldn't do this personally, but it won't cause any big issues):
Oh wow I think I got it already
-- This is the copy of ItemTweaker_Core.lua. It shouldn't have your additions in it
-- It must be placed in your mod at this file path: media/lua/client/ItemTweaker_Core.lua
-- If multiple mods have a lua file at the same path, pz will only load one file from the
-- mod that's last in the mod load order
function TweakItem(bla) end
-- leave this untouched
-- This has your additions. It can go in media/lua/client/mymod_ItemTweakerAdditions.lua or where ever you want
require("ItemTweaker_Core")
function TweakTable(blah)
...
end
So I don't need an "import" or "using" like Python or C#, just do a require and then I can use the global functions without addressing them as extention methods?
Got it got it awesome, thanks!
๐
can you gimme a quick example of how to put getFileWriter to use? Can't seem to get it to read json text from a json file
ArendamethUtils = ArendamethUtils or {}
ArendamethUtils.readFile = function(filename, createIfDoesntExist)
if createIfDoesntExist == nil then
createIfDoesntExist = false
end
local reader = getFileReader(filename, createIfDoesntExist)
if not reader then
return nil
end
local lines = {}
local line
repeat
line = reader:readLine()
if line then
table.insert(lines, line)
end
until not line
reader:close()
return table.concat(lines, "\n")
end
ArendamethUtils.readModFile = function(modId, filename, createIfDoesntExist)
if createIfDoesntExist == nil then
createIfDoesntExist = false
end
local reader = getModFileReader(modId, filename, createIfDoesntExist)
if not reader then
return nil
end
local lines = {}
local line
repeat
line = reader:readLine()
if line then
table.insert(lines, line)
end
until not line
reader:close()
return table.concat(lines, "\n")
end
ArendamethUtils.writeFile = function(filename, contents, createIfDoesntExist, append)
if createIfDoesntExist == nil then
createIfDoesntExist = true
end
if append == nil then
append = false
end
local writer = getFileWriter(filename, createIfDoesntExist, append)
if writer then
writer:write(contents)
writer:close()
return true
else
return false
end
end
ArendamethUtils.writeModFile = function(modId, filename, contents, createIfDoesntExist, append)
if createIfDoesntExist == nil then
createIfDoesntExist = true
end
if append == nil then
append = false
end
local writer = getModFileWriter(modId, filename, createIfDoesntExist, append)
if writer then
writer:write(contents)
writer:close()
return true
else
return false
end
end
Let me know if you have any issues with those. Just wrote them the other day and haven't tested most of them yet
I assume I only need the .readFile part, since I am not looking to do anything but to fetch JSON table form a JSON file?
Yea. So getFileReader/Writer looks in Zomboid/Lua. The getModReader/Writer looks in the mod's folder.
So if you have ~/Zomboid/Lua/somejson.json,
MyMod = MyMod or {}
MyMod.JSON = require("lib/JSON")
local jsontext = ArendamethUtils.readFile("somejson.json")
if not jsontext then error("do your error handling") end
local object = MyMod.JSON:decode(jsontext)
Think that'd do it
missing the json error handling
Actually haven't written any error handling for it myself either ๐
That library has an involved interface for error handling. It's written inside the JSON.lua file if you want to dig into it. As I recall, by default, it will just call error("error message"), which may be sufficient for your use case
jsontext returns nil. probably something's wrong with my implmentation
Is your file at ~/Zomboid/Lua/somejson.json?
no its in Lua/client
Are you trying to read a file from ~/Zomboid/Lua/client/ or from media/lua/client/ inside your mod?
the latter, inside my mod
Okay, you need lua local jsontext = ArendamethUtils.readModFile("MyModID", "media/lua/client/somejson.json")
does the same concept apply to MyMod.JSON = require("lib/JSON")?
I have JSON in ~/media/lua/client/lib/JSON.lua
Yes, you'd put JSON.lua at media/lua/shared/lib/JSON.lua to use it as require("lib/JSON.lua")
that's fine too
makes a little more sense conceptually in shared/ but it should work either way
Also, just fyi, ~ means user/home directory. I see that's causing some confusion
aaah got it
lemme place in shared
aand also I am getting error thrown at local reader = getFileReader(filename, createIfDoesntExist)
from ArendamethUtils
lemme add error handling
hmm i am not sure what the problem is, doesn't print any error in console
let me test it out, sec
Hmm, worked for me when tried with a non-existent file (returned nil) and with an existent file (returned the file contents).
You're getting an exception on that line? If so, can you get it from ~/Zomboid/console.txt?
Trying to but doesn't seem to print any exceptions in console.txt
it looks normal
It gives me the "error window" in game
ah
also hold on I may have found the issue
With that error UI, you have to continue the execution for the error to print in the log or the 'error' window. It's kind of annoying
I realised I had entered the Mod ID incorrectly (it was with space in mod.info, while in the code there was no space), but that apparently wasn't the issue either
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.
this is the error
f = ArendamethUtils.readModFile("miscpatches", "mod.info")
ArendamethUtils.inspect(f)
Typing that in the console prints out the mod.info for my 'miscpatches' mod
welll the mod works when you're in the customization window of the character soo not really any console to use
