#mod_development

1 messages ยท Page 33 of 1

hollow current
#

np

#

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

bronze yoke
#

like you want it to reset at midnight or something?

hollow current
#

yea something like that

bronze yoke
#

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

hollow current
#

I will check both functions out. Thanks so much!

austere finch
#

Re: running AwesomeTime + Le Gourmet Revolution concurrently, don't they have sharply conflicting farming frameworks?

hearty dew
hearty dew
hollow current
hearty dew
#

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()

hollow current
#

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?

hearty dew
austere finch
# hearty dew Yea, I've read that. I have yet to progress that far in the game though. Plannin...

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.

hollow current
#

ah so I don't actually have to import it manually into the files, it's just.. there

shadow geyser
hearty dew
low sky
#

someone should have told me making games in java is so hard

hollow current
#

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!

low sky
#

collisions are beating my ass rn

hearty dew
#
-- 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

low sky
#

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

hearty dew
hollow current
#

I really appreciate it though

low sky
#

don't feel bad lua is like deciphering moon runes

#

at least to me

hollow current
#

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

low sky
#

most things people don't get are the main function

low sky
#

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

hollow current
#

honestly python was the easiest I ever worked with

#

simple, on point, just makes you love your life

low sky
#

it's like saying scratch is easy. yes, because it is on purpose.

#

although scratch is a very heavy example

hollow current
#

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 ๐Ÿคฆโ€โ™‚๏ธ

hearty dew
hollow current
low sky
#

nooooooooooooooooooooooo

#

this_is_global

#

๐Ÿ˜ญ '

#

trash ah naming conventions

bronze yoke
#

anything that isn't declared local is global to the entire game's lua

hearty dew
hollow current
#

nice nice

hearty dew
hollow current
#

please

hearty dew
low sky
#

the only proper naming convention is camelCase

hollow current
#

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

low sky
#

"it worked and i'm happy" it takes nothing to get you happy i see

#

no dopamine having ass

hollow current
#

lool

astral dune
#

u32HungarianNotationIsGOAT

low sky
#

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)

hollow current
bronze yoke
#

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

hearty dew
austere finch
hearty dew
hollow current
#

ooo i get it

#

so its basically like

#

using ArendamethMod55 IF it exists, otherwise, create the table

hearty dew
ancient grail
#

i wish theres a mod that everyone is working on as a team . id love to colab with people

hollow current
#

alright, and its generally better to have that statement in the beginning of each file that will have/use global mod data?

hollow current
#

but I don't remember at all their names

ancient grail
hollow current
#

no i meant actual mods

#

where you could contribute by committing to the GitHub page

hearty dew
ancient grail
bronze yoke
#

that's why you're cautioned so much to use local whenever possible

hollow current
#

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)

ancient grail
#

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

bronze yoke
#

well anyone can start a project like that

#

be the change you want to see in the world

hearty dew
# austere finch I would be interested in what you did there, I resorted to commenting theirs out
-- 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

ancient grail
hollow current
#

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

dim hill
#

What's the mod that lets you use empty cans as water containers/boilers?

bronze yoke
#

i'm not sure i care much about documenting the lua and java, but documentation on the scripts would be nice

hollow current
#

+1

#

I want it to be more PZ oriented

#

and less Java/Lua Oriented

ancient grail
bronze yoke
#

i meant the pz code

hollow current
#

ye exactly

bronze yoke
#

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

ancient grail
#

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

bronze yoke
#

particularly vehicle scripts which don't seem to be finished

low sky
#

if you know java it is ez

#

pz is cool because they are not doing any crazy ah code

ancient grail
#

damn how many languages do u guys speak

low sky
#

the code for their game is pretty tight

dim hill
#

Was there a mod that let you put and boil water in empty tin cans?

bronze yoke
#

it could be a good way to encourage people to use apis/frameworks/whatever they want to call themselves

low sky
#

OR

#

hear me out

bronze yoke
low sky
#

they coudl just be super epic

#

and make us able to add java mods natively

calm acorn
#

So i can experience the joy of gradle all over again...

austere finch
low sky
#

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

astral dune
bronze yoke
#

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

astral dune
#

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

bronze yoke
#

huh

hearty dew
livid geode
#

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?

astral dune
#

I'm under the impression its actually just alphabetical at the file level, but maybe somebody else has a better idea

livid geode
#

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..

bronze yoke
#

later mods will overwrite earlier mods

livid geode
#

Thanks ๐Ÿ˜„

bronze yoke
#

(i think...)

astral dune
#

if the files have the same name and location, ya maybe

bronze yoke
#

i'm going to load up a bunch of mods to check

hearty dew
#

@livid geode

bronze yoke
#

this doesn't answer their question though

hearty dew
#

I think later mods in the load order win if multiple mods have files with the same path? I'm not sure about that

bronze yoke
#

oh my bad, you were still typing

hearty dew
#

Ah, nm. I'm talking about the order lua files are loaded

austere finch
livid geode
#

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

hearty dew
#

There is a mod that allows you to control the mod load order via the UI btw. Mod Manager

austere finch
# hearty dew 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.

hearty dew
#

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

hollow current
#

sooo umm

#

Should be relatively easy to anyone familiar with Github

austere finch
hollow current
ancient grail
austere finch
#

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.

hearty dew
hollow current
#

ah it's okay, thanks!

hearty dew
astral dune
ancient grail
hollow current
#

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

hearty dew
astral dune
#

ArendamethMod55 = ArendamethMod55 or {}, or better yet require ArendamethMod55

hollow current
hearty dew
#

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

hollow current
#

but that still poses the same issue, relogging into the game will reset the bool?

austere finch
hearty dew
hollow current
#

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?

astral dune
#

why not keep a timestamp in their moddata instead?

hearty dew
agile lily
#

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

hollow current
hearty dew
hollow current
#

I think the bools for moddata will be easier for me since I definitely have no idea how to compare times in lua lol

astral dune
#

assuming there is a way to get date and time, either RL or in game

hollow current
#

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

hearty dew
#

irl time is available in the os table. There's some function for in game time too, but I can't recall it atm

hollow current
astral dune
#

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

hearty dew
hollow current
#

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

astral dune
#

is this happening server side or client side?

hollow current
#

Well mod is intended to work both for SP and MP soo I guess best is to make it compatible for both

astral dune
#

sure, but thats not really related per se

hollow current
#

oo i see what you mean

#

It's client side

astral dune
#

anything you handle clientside only is going to get lost on relog, right? So you have to consider that

hollow current
#

.. except moddata, no?

#

anything defined in moddata stays there, even after you relog, right?

astral dune
#

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

hearty dew
#

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

astral dune
#

all the moddata on vehicles has to be transmitted manually

#

and the transmit functions don't all work, lol

#

but players are likely different

hollow current
#

ye its just "one piece of moddata" to be stored on the playerObj

astral dune
#

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

hollow current
#

lemme see if I can find anything useful on the PZ's official API or vanilla files

bronze yoke
#

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

hollow current
#

There's also apparently a getTimestamp()

#

lemme try to print both and see what I get

bronze yoke
#

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

hearty dew
#

getTimestamp() is irl time in seconds since epoch if I recall correctly

#

getTimestampMs() is same but in milliseconds

low sky
#

System.currentTimeMillis

low sky
#
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");  
   LocalDateTime now = LocalDateTime.now();  
   System.out.println(formatter.format(now));  ```
#

๐Ÿซ˜

#

โ˜• supremacy

bronze yoke
#

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)

hearty dew
low sky
#

gives time since like 1970 or something

#

i forgot

#

yeah Jan 1, 1970

hearty dew
astral dune
#

getGameTime():getDay() is the ticket, for this use case the time IRL doesn't matter

hearty dew
#

But I'm lazy like that ๐Ÿ™‚

bronze yoke
#

that's probably the better way of doing it

astral dune
#

i agree ๐Ÿค

hollow current
#

Yup definitely works

#

thanks so much

low sky
#

puffin on zooties and she calling me daddy

astral dune
#

One thing I don't get about vehicles is it appears that the engine overheats faster if there is no hood

hollow current
#

there is engine overheating system in PZ?

astral dune
#

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

magic nymph
#

Has anyone been able to find where the implementation of ILuaGameCharacter is?

magic nymph
#

If someone knows where it's at, please ping me. Thanks.

bronze yoke
#

i've seen how it's generated and stuff but not what it actually does

astral dune
#

I think the heat your heater puts out is related to your engine heat, but like I said I haven't really looked yet

neon bronze
#

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

summer rune
#

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 ... ?

midnight mica
#

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.

astral dune
#

hmmm.. I would think a player's sqlID might be useful for that, but doesn't look its accessible

thick karma
shadow geyser
#

not much to say other than its in the java decompile

dark finch
#

Any modders take commissions??

bronze yoke
#

i've been considering it

dark finch
#

Ive been looking for a modder for months

magic nymph
#

I'm looking for the class that implements it.

bronze yoke
#

isoplayer, isogamecharacter, isozombie, etc

#
IsoDummyCameraCharacter, IsoGameCharacter, IsoLivingCharacter, IsoLuaCharacter, IsoLuaMover, IsoPlayer, IsoSurvivor, IsoZombie, RandomizedBuildingBase.HumanCorpse```
gilded hawk
drifting ore
#

Is there a mod that makes Project Zomboid look as much like the original The Sims as possible?

dark finch
bronze yoke
#

i'd like to hear what you're looking for myself

neon bronze
#

So does zomboid use a different java compiler than the usual ones?

astral dune
#

don't think so, I compiled some stuff with java 17 and its playing nice so far

astral dune
#

nope

low sky
#

are you making mods in java?

astral dune
#

no, I just patched some stuff thats currently broken

low sky
#

ah

#

i thought you were making some mods

astral dune
#

still doing that lua style for now

bronze yoke
#

gerald absolutely ravenous for any mention of java modding

low sky
#

yes

abstract raptor
#

Anyone have a problem where player built things dissappear when you leave a chunk and come back?

astral dune
#

from a mod you're making?

abstract raptor
#

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

thick karma
#

Extremely useful tool

astral dune
abstract raptor
#

was just about to check that

#

ye

astral dune
#

I assume that option doesn't show up if there is no graffiti?

abstract raptor
#

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

astral dune
#

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

thick karma
#

@hearty dew Did some testing, and getTimeSinceZombieAttack is independent of game speed... in fact I'm 99% certain it updates OnTick

elfin stump
#

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.

glad ridge
#

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    
  }
}
low sky
#

omfg i just had a cool idea for a mod

#

if i can't make it

elfin stump
# glad ridge ^

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.

low sky
#

someone else totally should

ruby urchin
elfin stump
# glad ridge ^

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.

glad ridge
elfin stump
spark crystal
#

@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?

calm acorn
#

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)
true vault
#

Any info to add multiple requirements to a recipe? Trying to require an elec level, as well as a custom skill tree level.

boreal crow
#

Multiple deleted, or mulitple kept

#

Ohh

true vault
#

Sorry, I should have been more specific... multiple skill level requirements

calm acorn
#

SkillRequired:MetalWelding=5;Electricity=5,

true vault
#

Okay, that's what I thought it was, but it has... issues.. lolz.. I'll keep workin at that, thanks

calm acorn
#

what are the issues you are experiencing?

boreal crow
#

He's trying to use a custom skill tree, does that not require more indepth

true vault
#

She* actually; and pretty much that yes.

#

(ZGal... Zed Girl...) lol

elfin stump
calm acorn
#

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

elfin stump
#

I will give that one a shot first. That is going to be really helpful.

calm acorn
#

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

abstract raptor
true vault
calm acorn
#

oh man

elfin stump
#

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

calm acorn
#

capitalizations and misspellings are my #1 enemy

true vault
#

Same tho lolz... I cannot even count the number of times a bug/error was caused by those two things...

calm acorn
#

i already did the trial by fire of cAsInG and sorting based on filename sorting order burning me for a week

#

lol

cedar anvil
#

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.

elfin stump
# cedar anvil Does anyone know where I could find 'WorldObjectSprite'? I'm trying to make a Mo...

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.

#

Sprites are in .pack files so you cannot get to them without looking into those files

cedar anvil
#

Oh my god Thank you so much

#

I found some tutorials but it was outdated. Will look into it. Thanks!

elfin stump
#

No problem! Good luck!

elfin stump
hearty dew
#

@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?
weak sierra
#

@elfin stump did u see this?

calm acorn
#

ugh big pain in the butt to not do it otherwise

elfin stump
#

Ohh yeah I saw it! ๐Ÿ˜„ I am excited about it

hearty dew
calm acorn
#

that is just replicating what is in the java

hearty dew
#

Ah

calm acorn
#

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

hearty dew
#

@calm acorn Hmm, would that cause any modifications to loot tables by later loaded mods to not have any effect?

calm acorn
#

i noticed when i was loading my loot with OnInitGlobalModData that it was in the loot table for lootzed but it would never drop

hearty dew
#

the Parse() call. Or will it reparse again later and re-read the tables?

calm acorn
#

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

hearty dew
calm acorn
#

its like man... would be really cool if cough sandbox variables loaded sooner

hearty dew
calm acorn
#

yeah im currently in the process of pulling it out

elfin stump
elfin stump
calm acorn
#

no

elfin stump
#

Awesome I have not used it yet

calm acorn
#

the issue im having now my procedural loot lists are acting up

#

proc list has a min 0 and max of 1 lol

elfin stump
#

They don't spawn on their own though?

calm acorn
#

nah they do they have a really low chance

hearty dew
# elfin stump Me too, I ended up using dynamic loot and hardcoded sandbox settings in submods ...

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 ...

weak sierra
# calm acorn

that's in java tho im not sure u can call that..? or is it exposed

hearty dew
#

But it's not a great user experience

hearty dew
weak sierra
#

honestly id be surprised if that's exposed, but im guessing u know well enuff to have checked or tested it

calm acorn
#

no that method is public and you can grab the instance via getSandboxOptions() int he luamanager

weak sierra
#

huh

calm acorn
#

same with parse and the item picker

weak sierra
#

yeah i was talkin about ItemPicker.Parse

#

didnt kno

#

til

elfin stump
weak sierra
#

a generic mod that just loads that will fix a bunch of mods that uh.. don't work with sandbox options atm

calm acorn
#

you can see all the classes that are exposed in the luamanager

weak sierra
#

yeah

#

i just didnt look

calm acorn
#

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

hearty dew
#

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

weak sierra
#

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)

calm acorn
hearty dew
#

Hadn't thought about how to call static methods/fields. Hmm

#

That'd be handy to get fields like GameServer.instance, etc

astral dune
#

Scriptmanager.instance works for some strange reason, even though there is a getScriptManager

hearty dew
bronze yoke
#

i think class.instance usually works (when applicable)

bronze yoke
#

i think the getters look pretty so i use those

hearty dew
#

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

astral dune
#

if they can expose .instance fields I wish they would just expose all the public fields

hearty dew
#

The public fields should be exposed, if their class is exposed in the Exposer

astral dune
#

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

hearty dew
#

Yea, they should be exposed and readable. That's what I mean (not writable)

astral dune
#

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'

hearty dew
#

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) ๐Ÿค”

astral dune
#

I assume it a limitation of kahlua, but lord knows

hearty dew
#

weird asymmetry

calm acorn
calm acorn
astral dune
#

Try explaining that to someone downloading your mod on the workshop, lol

calm acorn
#

:p hey those java mods get traction, some one might be willing if it really does something they want

#

lol

weak sierra
#

im gonna make a version that uses a javamodded server to get better access to the vehicles.db

astral dune
#

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

weak sierra
#

and do more fancy stuff

weak sierra
#

technically u can distribute the files, someone would have to write a loader that would collect and relocate them and do waht is needed

astral dune
#

well if the Minecraft Forge team can make an api that lets you dump mods in a folder, surely the PZ community can too

weak sierra
#

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

astral dune
#

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

weak sierra
#

there's kahlua2

#

not sure which they use

#

i assume 2

astral dune
#

oh rly

weak sierra
#

dont think it's dead

#

they use the lua side for their own stuff

hearty dew
#

Pretty sure it is 2. Some of the changes in 2 I noticed in what pz runs

weak sierra
#

so i dont see them dropping it

astral dune
#

last commit is 11 years ago

weak sierra
#

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

hearty dew
#

It's a problem bc kahlua isn't even to lua 5.2 spec ๐Ÿ˜‚

weak sierra
#

lol

astral dune
#

kahlua doesn't support the full lua spec

#

ya

weak sierra
#

i never knew lua before this so that hasnt bothered me lol

calm acorn
#

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

astral dune
#

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 ...

weak sierra
#

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

astral dune
#

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

hearty dew
#

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

astral dune
#

ya, most of the physics stuff is client side, which makes sense

weak sierra
#

used to not be

#

and yeah, several servers do do that

astral dune
#

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

hearty dew
#

Since you're already modifying the java, you could add triggerEvent(onVehiclePartDamaged) to the java side while you're at it

astral dune
#

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

hearty dew
#

Hopefully they would fix it. Maybe could send a patch their way to increase the chances

astral dune
#

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

calm acorn
astral dune
#

I'm not clear on how this would be useful

calm acorn
#

looks like it the description of the xp source should have Vehicle in it

astral dune
#

is this called lua-side?

bronze yoke
#

i can't say i've tried, but i didn't think we could access that stuff

astral dune
#

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

calm acorn
#

Events.AddXP.Add(owner, type, amount)

#

maybe type == Perks.Driving fires off when you hit something

astral dune
#

driving is a modded perk, isn't it

calm acorn
#

oh damn yeah i think your right, eh thats just a sign i need to go to bed, have a good one mate.

astral dune
#

have a good night, thanks for the idea though. I'll root around a bit

weak sierra
#

anyone familiar with how the chat system works

#

i made custom commands but when u hit enter they sit in the chat box

calm acorn
#

also maybe just checking for blood intensity cause i think those get set when you hit things

weak sierra
#

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

astral dune
bronze yoke
#

i don't think there's anything useful you could hook into for that either way

astral dune
#

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

bronze yoke
#

yeah that's how mine works

#

it's not perfect but it's definitely the best way of doing things i can find

astral dune
#

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

bronze yoke
#

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

astral dune
#

by just topping it up every update?

bronze yoke
#

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

astral dune
#

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

bronze yoke
#

god i need to get up in three hours lol

astral dune
#

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

bronze yoke
#

oh well that makes things easy

#

if we can verify nothing else damages windows that's most of the updates gone

astral dune
#

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

bronze yoke
#

that sucks

astral dune
#

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

bronze yoke
#

i wasn't actually planning on protecting those

astral dune
#

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

bronze yoke
#

you can't hook into that though

#

it's being called from java half of the time right

astral dune
#

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

bronze yoke
#

well i'm ever hopeful!

astral dune
#

crashing into an object is handled this way, so we may get lucky

astral dune
#

dang, no go

astral dune
#

ok, so this is what I've found re: detecting and/or stopping damage to a vehicle from the lua side

  1. 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
  2. Hitting zombies
    So far no secret sauce, but if you're going to run a OnTick or OnPlayerUpdate event listener that checks the vehicle, storing and comparing BaseVehicle.getBloodIntensity("Front") and BaseVehicle.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
  3. Zombies breaking windows to eat your brains
    Hooking into VehicleWindow.damage will 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 overwriting VehicleCommands.lua and adding the line return VehicleCommands at the bottom. By doing this, you can just hook into the commands VehicleCommands.Commands.crash() and VehicleCommands.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

astral dune
#

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

summer rune
#

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?

hollow current
#
--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

summer rune
#

i have the exact same structure, except everything 1 level deeper in subfolders. hmm.

hollow current
#

try to not make it 1 level deeper and see if that changes anything

hollow current
#

any idea where I can find the vanilla code for adding the "randomise" and "play" buttons in the character customization window?

hearty dew
hollow current
#

Thanks!

sleek saffron
hearty dew
#

Ah, that makes sense

still spoke
#

new to the game how do you deconflict mods in this game?

hearty dew
# still spoke 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

still spoke
#

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?

hearty dew
#

What errors are you getting? It will be logged in Zomboid/console.txt in your home directory

still spoke
#

im not seeing a console.txt in ProjectZomboid in my steam directory

#

do I have to have debug on to dreate file?

hearty dew
#

Zomboid/console.txt in your home directory

still spoke
#

i do not have a console.txt file in my home directory. Do I have to enable it? Purchase through stream

hearty dew
#

no, it is always created when starting pz

#

You looked in the Zomboid directory within your home directory?

flat cipher
#

That would be C:\Users(yourname)\Zomboid

still spoke
#

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

hearty dew
#

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)```
still spoke
#

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

thick karma
#

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.

kindred dagger
#

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.

thick karma
kindred dagger
#

That's the thing, I looked there but setCapacity is not in ItemContainer.

thick karma
#

Do you know how to look at his code by subscribing to the file?

kindred dagger
#

Yeah I do, I did it here and there. I'll give it a look

thick karma
#

GL

still spoke
#

@thick karma @hearty dew Thanks for your time and help

thick karma
#

No worries, you make progress solving that error?

kindred dagger
#

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.

shadow geyser
# kindred dagger Question. How would you go about editing a container? As in furniture. I'm tryin...

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

kindred dagger
#

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?

shadow geyser
#

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;
   }

kindred dagger
#

Maybe not manipulate, but replicate. I won't touch anything that's hardcoded

#

What class is this from, if you don't mind?

shadow geyser
#

ItemContainer.java

kindred dagger
#

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

ornate flax
#

Simple question, how do you get the user name client side. getPlayer().getUsername() doesn't work

thick karma
#

You mean the name of their character or the Steam user name?

hearty dew
#

Are you running in steam mode? If so, I wonder whether username even supposed to be set in steam mode

thick karma
#

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

hearty dew
#

oh, yea, should use : syntax there

ornate flax
#

lol, NFI what i'm doing but managed to make good progress anyhow

thick karma
#

Persistence is half the battle. (The other half, of course, is knowing. GI Joe.)

viral vale
#

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

austere finch
#

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.

ornate flax
#

So it worked.. thanks guys. My mod is done!

undone elbow
#

How to get items AFTER death?

getPlayer():getInventory():getItems() -- empty list
thick karma
#

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?

bronze yoke
#

you can share the files directly

thick karma
#

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...

hearty dew
#

After death, maybe the inventory contents is no longer on the IsoPlayer object? Perhaps it moves to a zombie object? Just a hunch

undone elbow
#

May be. The issue is the mod data on clothes is removed on death.

#

In multiplayer

thick karma
#

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?

bronze yoke
#

if you have it installed to both folders, then some weird stuff might happen

#

the priorities for which it loads are weird

thick karma
#

I see. Okay, so in general, just develop in Workshop and ignore mods if a mod is intended for online play?

bronze yoke
#

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

thick karma
#

Do you have to buy the game outside of Steam to launch it independently of Steam?

bronze yoke
#

no, you just use the launch argument -nosteam

#

or maybe -nonsteam i don't remember exactly

thick karma
#

I see, okay thanks

bronze yoke
#

this way you can join a local server with multiple clients without steam auth tripping out

thick karma
#

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?

bronze yoke
#

no, everything needs to be nosteam

thick karma
#

Got it, appreciate all info

kindred dagger
#

I give up on my furniture thing. Can't figure out a way to change that without editing one a java class.

agile lily
#

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?

hearty dew
#

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 ๐Ÿคฏ

hearty dew
bronze yoke
#

yeah, prints are really really slow

austere finch
#

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

hearty dew
#

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

austere finch
#

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.

astral dune
thick karma
#

@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...

bronze yoke
#

if you're launching the game through steam i think it still will

thick karma
#

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?

bronze yoke
#

i think so!

ancient grail
ornate flax
#

Yeah, it's working now. I assume : is because it's LUA calling Java?

thick karma
astral dune
#

aka Something:setValue(input) === Something.setValue(self, input)

shadow geyser
austere finch
#

Even so, it is ubiquitously used in a lot of mods.

shadow geyser
#

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

austere finch
#

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.

astral dune
#

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

shadow geyser
#

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.

austere finch
#

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.)

bronze yoke
#

yes, itemtweaker is not as useful as it seems, but patching itemtweaker is by far easier than patching every single mod that uses it

austere finch
#

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.

bronze yoke
#

yeah bundling dependencies is really annoying

ancient grail
austere finch
#

Unlikely, many of them haven't looked at PZ or responded for going on a year or longer.

austere finch
bronze yoke
#

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

quasi geode
#

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.

austere finch
#

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

bronze yoke
#

i recall some other games having workshop items that used a bot that would automatically update from github

austere finch
#

That sounds fairly slick

shadow geyser
#

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

austere finch
#

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.

summer rune
#
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

low sky
#

Whereโ€™s my fellow Java modders

hearty dew
hearty dew
gilded hawk
#

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

bronze yoke
#

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

thick karma
#

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?

bronze yoke
#

doesn't everything close when you die? worth looking into

thick karma
#

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.

bronze yoke
#

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

quasi geode
thick karma
#

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

bronze yoke
#

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

bronze yoke
#

because it's possible that death just kills the ui entirely

thick karma
willow estuary
#

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.

austere finch
#

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.

thick karma
rugged glade
#

Hello, is there a file i can reference to make something that is similar to a clothes dryer in game?

thick karma
#

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

bronze yoke
#

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

austere finch
astral dune
bronze yoke
#

the one that's just called Profession Framework

astral dune
#

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

austere finch
#

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.

bronze yoke
#

obnoxiously, that version has more than twice as many subscribers

austere finch
#

Yep

rugged glade
#

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

austere finch
#

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. ๐Ÿค”

bronze yoke
#

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

rugged glade
#

thank you for the advice! ill have to look into those.

agile lily
#

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

austere finch
#

I wonder how much the total workshop count for PZ is inflated by Brita's requiring servers to publish their own separate settings mod

bronze yoke
#

probably a couple hundred ๐Ÿ˜จ

hollow current
#

Does Lua have the functionality to pick something randomly from a .json table? Or is there a better way of doing it?

thick karma
#

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

hollow current
#

Will look into it, thanks!

hearty dew
shadow geyser
# austere finch I wonder how much the total workshop count for PZ is inflated by Brita's requiri...

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

hearty dew
hollow current
#

Gonna give this this a go

#

thanks!

astral dune
bronze yoke
#

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

gilded hawk
#

To indentify a user, should I use :getUsername() or :getSteamID()? ๐Ÿค”

bronze yoke
#

getSteamID() will only work on steam

ruby urchin
astral dune
#

Isn't that just a small integer?

gilded hawk
ancient grail
#

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?

gilded hawk
# gilded hawk I'm looking to set the "owner" of an item and I need it to work in SP and MP

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
ancient grail
#

for mp u have to make a read write files i guess

ruby urchin
ancient grail
bronze yoke
#

yes

ancient grail
bronze yoke
#

return a,b,c
a,b,c = function()

gilded hawk
undone elbow
#

Note that RELOAD such a lua file in debug mode will cause glitches.

undone elbow
low sky
#

where is my java devs at

#

โœ‹

gilded hawk
weak sierra
#

yes

#

it's their char firstlast

undone elbow
#

Sure. It's just name + surname

weak sierra
#

yeah

astral dune
#

who would be the otherplayer in SP?

gilded hawk
#

๐Ÿ˜ฎ interesting

weak sierra
undone elbow
#

There is also

player:getFullName() -- first name + " " (space) + surname
astral dune
#

๐Ÿคฏ

magic nymph
#

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.

astral dune
#

given that its integers it looks like the outcomes are being truncated

magic nymph
#

Yeah, I tested it and Java floors any double to int coercision, but it should still be 3, no?

astral dune
#

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?

bronze yoke
#

they both do, but that's how it's displayed in-game anyway

astral dune
#

I didn't even know weapons had levels ๐Ÿคทโ€โ™‚๏ธ

bronze yoke
#

isn't getWeaponLevel() just shorthand for getPerkLevel(whatever perk the weapon you're holding uses)?

astral dune
#

ah, I see, so BaseballBat.getWeaponLevel() would return your long blunt perk

magic nymph
#

I double checked getPerkLevel(Perks.Maintenance) and it returns 5. I'll try out getWeaponLevel now.

wanton dirge
#

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.

magic nymph
#

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.

bronze yoke
neat kraken
#

hello, I'm wanting to learn to program and I really like pz, is starting with mods a good start?

astral dune
thick karma
#

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

ruby urchin
astral dune
#

lua is mostly pass by reference when it comes to tables, right?

thick karma
#

And it's free

thick karma
ruby urchin
#

I've seen people using notepad lmao, I can't understand that

thick karma
#

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.

wanton dirge
#

My best code is written in notepad with my monitors brightness and contrast maxed out at 3am.

thick karma
thick karma
# neat kraken thank u bro

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...

โ–ถ Play video
thick karma
#

(Expect to pause often.)

neat kraken
low sky
#

๐Ÿ˜›

#

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

calm acorn
#

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.

low sky
#

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

calm acorn
#

im using intellij now but mainly to decompile pz so i can look at all the fun undocumented stuff

low sky
#

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

calm acorn
#

well im more a c# guy now but i guess 90% of the time the same.. ish code lol

low sky
#

@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

low sky
#

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#

calm acorn
#

c# is just msjava

low sky
#

i think it might be c#

low sky
#

i am about to try and add a event bus to my game i am making

#

any hints?

calm acorn
#

I have more use for it at work, im a IT system admin so i deal with powershell and .net at work

low sky
#

i want it to be able to be able do the @SubscribeEvent call

low sky
#

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?

ancient grail
#

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?

mellow gust
#

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.

ancient grail
bronze yoke
#

i knew you were lying about the company lol

ancient grail
astral dune
#

is it possible to send a message to a particular radio in game, or is it all channel based?

thick karma
#

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?

bronze yoke
#

sorry, i have no idea

thick karma
#

No sweat just thought I'd ask

bronze yoke
#

i've been lucky enough to avoid ui for the most part

thick karma
#

Your idea was legit but I am failing to find anything good unfortunately

bronze yoke
#

it must be from java or something

thick karma
#

My thoughts too

bronze yoke
#

WaveSignalDevice:AddDeviceText()

worldly olive
#

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 ๐Ÿ™‚

undone elbow
#

Yes, getCore():getVersionNumber() doesn't work

#

I guess this function has been removed

astral dune
worldly olive
bronze yoke
#

not sure what the last argument is but the first five should be text, r, g, b (as values from 0-1), codes

astral dune
#

codes?

undone elbow
#

I can add backwards compatibility patch to ModOptions, so all that mods will work fine, if you use ModOptions ๐Ÿ™‚

worldly olive
#

Yeah, some of the mods I use, uses the Mod Option so is always there in the modlist xD

bronze yoke
#

if you're just using it as a fancy print like you mentioned a while back, you can probably just pass an empty string

astral dune
#

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

bronze yoke
#

weird! that's not how it shows up on the javadoc

astral dune
#

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

bronze yoke
#

oh that's right, that's an interface

astral dune
#

ya, they didn't follow the i prefix convention, smdh

bronze yoke
#

well the vehicle radio is implemented in VehiclePart

astral dune
#

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

undone elbow
#

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

worldly olive
#

Awesome!

astral dune
#

been trying for 30 minutes to get some code with table.unpack() to work, only to find its just unpack() in kahlua apparently ๐Ÿคฆโ€โ™‚๏ธ

undone elbow
#

Show your example. What is your goal?

hollow current
#

Is there a way to somehow temporarily increase the chance a player misses his shot (guns) and miss his swing (melee weapons)?

ruby urchin
#

I think the accuracy perk looks like be directly related, did you check it?

hollow current
#

Nope, gonna check it out

jaunty marten
astral dune
#

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

hollow current
summer rune
hollow current
#

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?

jaunty marten
#

u can add mod on equip and remove on unequip

hollow current
#

makes sense, gonna try putting that to use in that way. thanks!

bronze yoke
shadow geyser
ruby urchin
#

lmao someone forgot to remove some prints on ...\ISUI\ISInventoryPaneContextMenu.lua#L448-L459

stray yacht
#

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.)

ruby urchin
#

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

hollow current
#

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()

stray yacht
hearty dew
# stray yacht

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)

stray yacht
#

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

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)

stray yacht
#

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

hearty dew
#

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)

stray yacht
#

Okay should be good then, not touching that!

hearty dew
#

No, you are touching it. lol. That's the issue ๐Ÿ˜‚

stray yacht
#

Ohhh no haha I don't get lua at all ๐Ÿคฃ

hearty dew
#

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):

stray yacht
#

Oh wow I think I got it already

hearty dew
#
-- 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
stray yacht
#

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!

hearty dew
#

๐Ÿ‘

hollow current
hearty dew
#
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

hollow current
#

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?

hearty dew
#

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

hollow current
#

jsontext returns nil. probably something's wrong with my implmentation

hearty dew
#

Is your file at ~/Zomboid/Lua/somejson.json?

hollow current
#

no its in Lua/client

hearty dew
#

Are you trying to read a file from ~/Zomboid/Lua/client/ or from media/lua/client/ inside your mod?

hollow current
#

the latter, inside my mod

hearty dew
#

Okay, you need lua local jsontext = ArendamethUtils.readModFile("MyModID", "media/lua/client/somejson.json")

hollow current
#

does the same concept apply to MyMod.JSON = require("lib/JSON")?

#

I have JSON in ~/media/lua/client/lib/JSON.lua

hearty dew
#

Yes, you'd put JSON.lua at media/lua/shared/lib/JSON.lua to use it as require("lib/JSON.lua")

hearty dew
#

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

hollow current
#

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

hearty dew
#

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?

hollow current
#

it looks normal

hearty dew
#

How do you know it is causing an error if there is no exception?

hollow current
#

It gives me the "error window" in game

hearty dew
#

ah

hollow current
#

also hold on I may have found the issue

hearty dew
#

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

hollow current
#

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

#

this is the error

hearty dew
#
f = ArendamethUtils.readModFile("miscpatches", "mod.info")
ArendamethUtils.inspect(f)

Typing that in the console prints out the mod.info for my 'miscpatches' mod

hollow current
#

welll the mod works when you're in the customization window of the character soo not really any console to use