#mod_development

1 messages · Page 68 of 1

dull moss
#

ye it crashes in other place i think

thick karma
#

Gonna test both your version and the aforementioned while loop queue also

dull moss
#

TraitFactory.sortList();

#

this crashes the game now

thick karma
#

Alright Monsieur Duck let's see what this while loop's got. Can it do what the recursives have crashed me 20 times doing? We shall soon see.

sour island
#

oh i left off ""

dull moss
#

k lemme try edited

sour island
#

My best guess would be something with getText is failing for both instances

thick karma
#

lmfao

sour island
#

are any traits not all lowercase and not capitalised?

thick karma
#

Faaaair enough

#

Obviously this problem is less trivial than it seemed at first glance

dull moss
#

yes, that's the whole issue man, I've been trying to tell you it

thick karma
#

lmfao

dull moss
sour island
#

I mean on the UI side

dull moss
#

Yes

sour island
#

this should catch both those cases

dull moss
#

look

thick karma
#

When I decided to do this 2 hours ago I was like, "Oh I'll just finish expanding this little function right here..."

lusty marsh
#

I'll see if I can fix it, it doesn't work in the right order

thick karma
#

Now I'm dying of old age.

sour island
#

the name argument has to match the trait factory name

#

but the UI should be fine with what I wrote

#

btw why is "Marked" as thing? They have custom descs/names?

dull moss
#

explain to me how does your function converts
local Graceful = createTrait("Graceful", 4);
into
TraitFactory.addTrait("Graceful", getText("UI_trait_graceful"), 4, getText("UI_trait_gracefuldesc"), false); by lowercasing UI_traitgraceful (not G)
but if you pass it same thing
local Gardener = createTrait("Gardener", 4);
it now suddenly magically doesnt?
TraitFactory.addTrait("Gardener", getText("UI_trait_Gardener"), 4, getText("UI_trait_GardenerDesc"), false);

sour island
#

desc and Desc are also afflicted?

dull moss
#

oh fuck apparently it is

#

god damn

#

why cant they make their game consistent

#

but

#

even if desc is always upper case

#

explain why when u pass Graceful it makes it UI_trait_graceful and if u pass Gardener it makes it into UI_trait_Gardener

thick karma
#

Haha tested and it crashed. Jumper is unstringable unless I stop after 7 levels of depth.

dull moss
#

I don't see a single way that'd ever work

#

when you don't pass additional arguments

bronze yoke
#

the world if we could just change a trait's name normally

thick karma
#

@ This

dull moss
bronze yoke
#

why not grab the original trait and getDescription()?

dull moss
#

elaborate pls

bronze yoke
#

you're recreating the traits because you can't change their names right

dull moss
#

Nah I'm overwriting the base game trait

#

Im creating same trait with all the same values as base game except display name

#

So that way of some other mod uses those traits

#

it still works

#

player:HasTrait stuff

bronze yoke
#

so the vanilla traits are never created at all?

dull moss
#

they are

#

in base game

bronze yoke
#

i mean when your mod is running

dull moss
#

they are, im just overwriting their name

#

foraging buffs, descriptions, everything is taken from base game files

#

well except skill buff, that one i have to add manually

sour island
#
local function createTrait(name, cost, isProfExclusive, isDisabled)
    isProfExclusive = isProfExclusive or false;
    isDisabled = isDisabled or false;

    --overwrites the variable with the last 'true' case - if dynamic traits==true, continue to find "Marked", otherwise ""
    local marked = (getActivatedMods():contains("DynamicTraitsWorldMarkDynamicTraits") and "Marked") or ""
    
    --lowercase name argument ("Graceful"=="graceful") -- getTextOrNull("UI_trait_".."graceful"..marked) - if not translated then return null
    -- --same principle as above with dynamic traits and or "", if nil pass to the next returned variable
    -- -- --name:gsub("^%l", string.upper) == capitalise the first letter only ("Graceful"=="Graceful", "graceful"=="Graceful")
    local fetchedName = getTextOrNull("UI_trait_"..string.lower(name)..marked) or getTextOrNull("UI_trait_"..name:gsub("^%l", string.upper)..marked)
    local fetchedDesc = getTextOrNull("UI_trait_"..string.lower(name).."Desc") or getTextOrNull("UI_trait_"..name:gsub("^%l", string.upper).."Desc")

    return TraitFactory.addTrait(name, fetchedName, cost, fetchedDesc, isProfExclusive, isDisabled);
end
#

Is your creation overwriting old traits?

bronze yoke
#

i mean does the vanilla code to create the traits still run? because then you can just grab all the info you need from them

#

it'd likely be update safe too (not that we're getting any)

dull moss
sour island
#

TraitFactory.addTrait("Mechanics2", getText("UI_trait_Mechanics"), 0, getText("UI_trait_Mechanics2Desc"), true);

#

🤔

winter thunder
#

@ chuck I think you were the one to post them before- But do you know the lookup shortcuts in intellij?

bronze yoke
#

local fetchedDesc = TraitFactory.getTrait(name):getDescription()

sour island
#

You can overwrite the vanilla function as well - but what are you trying to correct for again?

#

Updating the old more traits and stuff

dull moss
#

If submod is enabled - update base game trait display name. Nothing else

sour island
#

and the dynamic traits mod gives vanilla traits new names?

bronze yoke
#

why not fork it before reaching this stage then? you don't need to recreate them for any other reason right?

sour island
#

You should also be able to grab and edit the trait

---@public
---@param arg0 String
---@return TraitFactory.Trait
function TraitFactory:getTrait(arg0) end
bronze yoke
#

there's no method to change the name

sour island
#

yeah just saw that

#

you can still decorate the vanilla function to check for those marked traits

bronze yoke
#

yeah that sounds like the easiest way

sour island
#

then you have all the mixmatched arguments already

dull moss
bronze yoke
#

oh, but can we run the decorator before vanilla? isn't the file that initialises the traits in shared?

dull moss
#

yes it is

sour island
#

you can decorate it in shared probably

bronze yoke
#

oh, it doesn't run immediately anyway, it runs OnGameBoot

#

so no concern

dull moss
#

I like how I had a working solution and then we spent 1h trying to make it better and still didnt manage to

sour island
#

fair enough

#

would still break on mechanics2 I think though

dull moss
#

i dont need mechanics 2

sour island
#

unless you're supplying the same information

dull moss
#

dafuq is even mechanics2

sour island
#

intermediate

bronze yoke
#

-2 traits are the profession specific variants, right?

sour island
#

from the mechanic job

bronze yoke
#
local altNames = {}
altNames.Gardener = 'Different Name'

local old_addTrait = TraitFactory.addTrait

function TraitFactory.addTrait(type, name, ...)
    name = altNames[type] or name
    old_addTrait(type, name, ...)
end
```something like this
sour island
#

testing it out

winter thunder
#

For editing player mod data, it is as easy as ?

player:getModData().Example.Something = 7

dull moss
#

throws error on line 11

#

only thing i changed is replaced mod condition to true

bronze yoke
thick karma
#

By descending deeper still into madness, I have discovered the root of the problem! @sour island

sour island
#

oh?

thick karma
#

Oh indeed!

#

Check it

#
--------children
----------3524
------------x
------------y
------------width
#
------------children
--------------3524
#

What is interesting about these you may wonder

#

What is interesting is that I accessed them by calling my function 6-layers deep on an arbitrary 4-layer deep table

sour island
thick karma
#

So I AM able to go deeper than 7 layers with my function, but I am in an infinite loop and it does make Project Zomboid very sad

dull moss
thick karma
#

Furthermore, that infinite loop is generated by Mod Options' references to presumably vanilla data objects that appear to be circular a.f.

bronze yoke
#

hmm, might be because addtrait has a variable number of arguments? no idea if that's handled on this end

sour island
#

I handled that

#

the issue is with the invoker

bronze yoke
#

how do you handle that? i've never had to mess with a method like that

sour island
#

doesn't seem to play nice

#
local addTrait = TraitFactory.addTrait
---@overload fun(arg0:String, arg1:String, arg2:int, arg3:String, arg4:boolean, arg5:boolean)
function TraitFactory.addTrait(name, UIname, cost, isProfExclusive, isDisabled, removeInMP)
    name = name.."TESTING"
    addTrait(name, UIname, cost, isProfExclusive, isDisabled, removeInMP or false)
end

Doesn't work on line 120:

#
TraitFactory.addTrait("Axeman", getText("UI_trait_axeman"), 0, getText("UI_trait_axemandesc"), true);
#

I'm guessing it's throwing a fit over kahlua stuff

dull moss
#

I still don't get how does your function magaically knows if name inside UI_trait_name should be lowercase or upperace

sour island
#

it's changing the string

#

and using getTextOrNull()

dull moss
#

Ok so it changes teh string

sour island
#

local a = (1==0 and 5) or 3 -- return 3
local a = (1==1 and 5) or 3 -- return 5

bronze yoke
#

oh i made a silly mistake

sour island
#

getTextOrNull(is this texthere, no?> then nil)

bronze yoke
dull moss
#

How come does it change Gardener to Gardener but Graceful is changed to graceful

bronze yoke
#
local old_addTrait = TraitFactory.addTrait

function TraitFactory.addTrait(type, name, ...)
    name = name .. 'TESTING'
    return old_addTrait(type, name, ...)
end
```with this code
sour island
#

oh the return lmao

bronze yoke
#

i got an error on a different line for some reason, one that made the missing return far more obvious

dull moss
sour island
#

if it can't find either lowercase OR capitalized it will return nil

#

that's an edgecase that shouldn't occur

winter thunder
#

so, if I were to set mod data on an item with the script, say I have a line that reads
Bar = "foo"

How would I use the getModData() to get that? trying to understand the interpretation

thick karma
#

You complete called it, kudos. Hidden circular references in data referenced within the options_data of Mod Options.

astral dune
#

me smrt

lusty marsh
#

@thick karma I'm almost there, only problem now is that pairs() is unstable so it sometimes is out of order

thick karma
sour island
#

much easier to maintain for you

dull moss
thick karma
#

And unfortunately attempts to store found objects are not stopping jt

lusty marsh
thick karma
#

That sort of array is not working in our functions duck

sour island
#

you can't compile this, it's calling on stuff from PZ

dull moss
#

getTextorNull is pz func?

sour island
#

yes

dull moss
#

ah

#

thought its lua stuff

thick karma
#

I understand the technique you're describing but it's failing us when we try to use the found objects as indexes (in an all-true table)

#

Maaaybe tostring could save the day, I'm out of time for trying stuff but I'll be back later

sour island
#

let the game do the work for you

bronze yoke
#
local altNames = {}
altNames.Gardener = getTextOrNull('UI_trait_GardenerMarked')

local old_addTrait = TraitFactory.addTrait

function TraitFactory.addTrait(type, name, ...)
    name = altNames[type] or name
    return old_addTrait(type, name, ...)
end
```this is the general concept
dull moss
#

ye, gonna try, thanks

dull moss
sour island
#

oh, damn you'd have to still do that shit cause getText is called as the argument

#

atleast its less of a headache

bronze yoke
#

yeah, linking the internal name to the new translation is much less work

sour island
#

I'd be curious if there's a way to pull out the argument from within that argument...

bronze yoke
#

you could also keep a table of affected traits, check if it's in that table, and use getText('NewString', name) where newstring is '%1 (D)' since that seems to be the pattern you're using

bronze yoke
#

basically, we hijack when the vanilla game adds the traits and change the names

dull moss
#

but where do I add if submod is enabled

bronze yoke
#

you don't need to really, getTextOrNull() will return nil if the string doesn't exist (which it won't if the mod isn't enabled), so the code won't activate

sour island
#

are all vanilla traits given a Marked version?

dull moss
#

it will, because I put them into main mod UI_EN

#

no

bronze yoke
#

oh, what does the submod do then?

#

you could put the entire block into an if mod enabled though

dull moss
#

i dont know any other way than submods to affect non-in-game stuff

#

like how do you make a toggle

#

that affects tratfactory

#

where do you put it

bronze yoke
#

hmm... actually that's a good point

#

sandbox options are loaded far too late

dull moss
#

yep

bronze yoke
#
if getActivatedMods():contains('DynamicTraitsWorldMarkDynamicTraits') then
    local altNames = {}
    altNames.Gardener = getTextOrNull('UI_trait_GardenerMarked')
    
    local old_addTrait = TraitFactory.addTrait
    
    function TraitFactory.addTrait(type, name, ...)
        name = altNames[type] or name
        return old_addTrait(type, name, ...)
    end
end
dull moss
#

andthen I jsut add vanilla traits that i want to have marked there?

#

do i need to addXPBoosts or recipes or anything?

bronze yoke
#

nope, all this does is hijack the original function and change the name

dull moss
#

damn that's gigabrain

#

praise the sun

#

or albion in this case

bronze yoke
#

well we wouldn't've got here without chuck

dull moss
#

praise chuck too

sour island
#

If the marked stuff is still giving you trouble let us know

#

I'm confused why they added new names but w.e.

dull moss
#

😄

sour island
#
function TraitFactory.addTrait(type, name, ...)

    local marked = (getActivatedMods():contains("DynamicTraitsWorldMarkDynamicTraits") and "Marked") or ""
    local fetchedName = getTextOrNull("UI_trait_"..string.lower(name)..marked)
            or getTextOrNull("UI_trait_"..name:gsub("^%l", string.upper)..marked)
            or getTextOrNull("UI_trait_"..string.lower(name))
            or getTextOrNull("UI_trait_"..name:gsub("^%l", string.upper))
            or name

    return old_addTrait(type, fetchedName, ...)
end
#

this would try to grab a number of shit

#

before defaulting the vanilla

#

first attempting to find Marked

winter thunder
bronze yoke
#

you can assign them as you wish as long as they aren't tables

dull moss
#

on the fly works

#

hey I got an axe Kpog

bronze yoke
#

moddata is literally just a lua table attached to an item, it follows all the same rules

bronze yoke
#

let's gooo

winter thunder
#

Nice!!!

dull moss
#

Do I even need to have this Events.OnGameBoot.Add(AddDTWTraits); inside my traitfactory lua?

#

I dont right

#

since its gonna run it anyway on game boot

bronze yoke
#

i couldn't say for sure without knowing what that function is

dull moss
#

traitfactory stuff

#

creating traits

#

setting mutually exclusive traits

#

and thats it

#

cuz I pput your code outside function just in the body of lua

#

and it worked xd

bronze yoke
#

yeah it's not supposed to be in a function

dull moss
#

ok, I'll just leave it as is

#

if it works dont touch it

bronze yoke
#

but yeah, unless you're doing it for another reason that code completely removes the need to mess with traits elsewhere

dull moss
#

ye i get it, uses same principle as overwritihg ISfix action

#

saves default function

#

and then edits it

lusty marsh
#

@thick karma tested and working ```reveal = function(inputTable, verbose, indentation, visited, printValues)
-- visited tracks tables that have been seen before to avoid loops.

local found = false
for _,t2 in pairs(visited) do
    if inputTable == t2 then
        return ""
    end
end

table.insert(visited, inputTable)

local s = ""
for k,v in pairs(inputTable) do
    if printValues then
        s = s .. indentation .. k .. " = " .. tostring (v) .. "\n"
    else
        s = s .. indentation .. k .. "\n"
    end
    if verbose and type(v) == "table" then
        s = s .. reveal(v, verbose, indentation .. "  ", visited, printValues)
    end
end
return s

end

local t = {
a = 1,
b = {c=1,d=2},
e = {f={g=1},h=1},
}

print(reveal(t, true, "", {}, true))```

I was being stubborn with the while loop but it was making the memory complexity bad, turns out this is actually a case for recursion.

I can finally go to bedtired

dull moss
#

and then runs default with updated params

bronze yoke
#

if you want to do this on java objects usually the method is a bit uglier, but since traitfactory is a static we don't have to worry about it

dull moss
#

thanks god

dull moss
#

hm

#

ah i know

drifting ore
#

how do you make a custom/modded trait in project Zomboid

winter thunder
#

so, with the mod data- If I set a variable like local x = player:getModData() . That way I could do something like example = table.1 so that way I could pull the string from the table name like

local x.example = 10

Would that be the best way to have a custom variable for the mod data input? Because otherwise when I am writing out the getModData() function it is reading whatever I put as the thing to get, so I cant plug variables into it

bronze yoke
#

you shouldn't be having that problem, but you should pull it into the local space anyway since you don't want to call the java method repeatedly just for performance reasons and it's prettier

dull moss
bronze yoke
#

getModData() just returns a table, getModData().index is exactly the same as

local x = getModData()
x.index
winter thunder
#

Because my functions first step is to check which table it is pulling from, from a list of different tables. A variable on the table will define which moddata variable to tweak, but it seems to not like me trying to put the variable where ive defined the table

lyric turtle
#

Why is modding a simple shirt in so unintuitive 😔

bronze yoke
dull moss
#

but what if it already exists

#

wouldn't it override it?

bronze yoke
#

it's an or statement

#

it'll only override if it doesn't

#

there is a situation where this doesn't work though - if you change the format the new stuff won't be added to old tables

#

you shouldn't really worry about that until after the mod has been released though

dull moss
#

there'll be no additions to killcount, its finished mod

#

Im grabbing its data

#

well, grabbing/initializing if it's not there

#

cuz in other lua I got this

#

and i don't want any nils there

bronze yoke
#

ohh, then this might not work, yeah

dull moss
#

ye

#

i need to specifically initialize categories

bronze yoke
#

you could make a table of weapon categories and loop through that, it'd be a tiny bit prettier

dull moss
#

mah

#

meh

#

not worth

#

imo it looks pretty

bronze yoke
#

this is a niche case really, and it's fine as it is

dull moss
#

anyway, 5:30 am

#

time to slep

#

gn yall

drifting ore
dull moss
#

Yes. What kind of trait u were thinking about? Anything complex or entry level stuff like +2 to skill?

winter thunder
#

This is the issue I am juggling right now

#

@bronze yoke if that makes more sense

dull moss
#

I did some arrays with keys, lemme yeet u example, maybe it'll help

bronze yoke
#

keyValue[x].base

#

or

#

i don't know where i got that from

#

what's keyValue?

dull moss
winter thunder
dull moss
#

@winter thunder ^

drifting ore
winter thunder
#

This is my builder for it

#

Basically keyValue is how the table is defined, effectively it is the table ID

#

So i dont need to make a constructor module, but I can effectively make a dictionary of tables

dull moss
bronze yoke
#

so what's DrugID? a table?

#

in the moddata

dull moss
winter thunder
#

That is a variable going to be set in the item defs, the name of which matches the keyValue that the item should pull its information from

#

that way I can make a single function to reference all my drugs, instead of new ones for each drug

bronze yoke
#

so what is x.base supposed to do? x is going to be a string or a number or something right?

sour island
#

I missed some of the convo - but you can easily make pseudo-classes in lua

winter thunder
#

base is a string, x was just meant to be a way to combine the getModData() func with the name I pull from the table

drifting ore
bronze yoke
#

so in the item script, DrugID = NameOfADrug, right?

winter thunder
#

and yeah, basically

bronze yoke
#

item:getModData().DrugID will return 'NameOfADrug' as a string then, you need to use something to get from the id to the actual drug stats

sour island
#
---@class wallet Pseudo-Object
local wallet = {}
wallet.steamID = false
wallet.playerUUID = false
wallet.playerUsername = false
wallet.amount = 25

function WALLET_HANDLER.new(playerID,steamID,playerUsername)
    if not playerID then print("ERROR: wallet:new - No playerID provided.") return end
    if not steamID then print("ERROR: wallet:new - No steamID provided.") return end
    local newWallet = copyTable(wallet)
    newWallet.playerUUID = playerID
    newWallet.steamID = steamID
    newWallet.playerUsername = playerUsername
    newWallet.amount = SandboxVars.ShopsAndTraders.StartingWallet or newWallet.amount
end
#

copyTable can be used to copy k/v

#

without worrying about references

#

idk if that helps

#

I also use other objects as profiles/presets to pull info from

drifting ore
#

AKA custom traits

dull moss
#

yea that's a bit more complex, you have to write logic for them

#

All I can recommend is checking existing traits

#

im off to sleep xd

drifting ore
#

Good night

dull moss
#

but ye check logic on complex traits in bigger mods

#

thats how i picked stuff up

#

and asking here

winter thunder
# bronze yoke item:getModData().DrugID will return 'NameOfADrug' as a string then, you need to...

So, line 8 will get the DrugID string from the item. That string is the same as the keyValue of a table where I define the qualities of the different drugs. the keyValue is basically a variable in a table that acts as the ID of that table instance. So, in my case, the name of the drugs act as my keyvalue. So, I get the name of the drug from the item in line 8. Then use that to figure out the table to reference in line 9.

The two following variables on lines 10 and 11 pull two definitions out of the table.

bronze yoke
#

your mistake is that x is still just a string 'Meth', string.base doesn't mean anything

winter thunder
#

it does in the context of the keyvalue table

#

Because of this

bronze yoke
#

where does info come from? is info also a string?

winter thunder
#

info is just the name of the input, it is a whatever I want it to be. though, it is an array for my purposes afaik

#

An actual instance would look like this

#

I dont need to predefine it

bronze yoke
#

i think what you're trying to do is keyValue[x].base

winter thunder
#

Nah, so- The issue is that no matter what I put after player:getModData(). it doesnt let me enter anything, it just assumes that anything typed after that point is a definition for the mod data table

sour island
#

copyTable?

winter thunder
bronze yoke
#

getModData() returns a standard lua table, when you put a . after it it's expecting a string key

dull moss
#

When it's done

#

Xd

winter thunder
bronze yoke
#

like player:getModData()[var]?

winter thunder
winter thunder
bronze yoke
#

no, it's just a table

winter thunder
#

ok cool

bronze yoke
#

you don't need to do anything special to it

dull moss
winter thunder
#

Word- Right now the focus is the recreational/abusable side of drugs, but we wanna implement more medications and stuff too in the future

dull moss
#

Also you really should put all your mod data behind your mod name

#

So it doesn't get overlapped

winter thunder
#

for sure, I am just making a testing branch rn for the sake of making sure everything works as I expect it to

dull moss
#

getModData().YourModName.<do whatever here>

#

Ah

winter thunder
#

Since I would be calling a table

dull moss
#

If I'm not mistaken, yes

winter thunder
#

probably best to do that sorta stuff on character spawn, right?

dull moss
#

Dis mine

winter thunder
#

you are working on your own branch of dynamic traits?

dull moss
#

No

#

Separate mod

winter thunder
#

gotcha- meant to play along side, or on its own?

dull moss
#

Own

winter thunder
#

Word

dull moss
#

Not gonna be compatible with DT

#

Thing is

#

I want 2 words to be in the name 100%

#

Which are "traits" and "dynamic"

#

I also thought Dynamic Fiesta

#

But it missing one of two words

#

It's a bit rough coming up with a name for something so specific

#

When DT is already out there

winter thunder
#

me too

#

anyone know the variable to get the players weight?

#

I see that i have to use Nutrition:getWeight(), but I dont know if I need to define the player in there, or if it defaults to the client?

dull moss
#

I did that but don't remember from top of my head

#

Um

#

Check more traits workshop, go link to github, go dynamic submod, go client, check Lua there and ctrl+f for weight

#

That's the only way I can help from bed

#

xD

#

Anyway, done browsing memes before sleep, now i go sleep

bronze yoke
#

getPlayer():getNutrition():getWeight()

winter thunder
#

any idea where the game calcs the effects of injury on the players ability to fight? I know pain messes with it, but I think specific injuries do as well?

winter thunder
#

So... For some weird reason, my game stopped registering my function, and I am not sure why. I have been working on debugging, and the function is loaded in my mods\lua\client folder. But now when the game tries to call it, it claims that the function doesnt exist

neon bronze
#

Do you have it in the require?

faint jewel
#

anyone up for a challenge?

#

i need a way to attaach a vehicle to ANOTHER vehicle, and not like towing, like put it in other other cars roof.

#

it can be completely for looks.

#

but i'd want to look like it was PART of that car.

#

no jankl

agile vigil
#

Not up for the challenge, but it sounds like this could be achieved by making a model for whatever you want on the roof (like a bike or whatever), and then simply adding that as an installable part to every other car - without letting you actually install it in the Mechanic menu.

faint jewel
#

i have this.i want to attach cars to it for a player to haul

agile vigil
#

Ahh, yeah all right that's gonna be harder.

To get started, I'd suggest trying to just put some dummy car models on it? Then later you can work on making those cars match what the player actually put on it.

drifting ore
agile vigil
#

Woop woop. It's a Christmas miracle!

#

I feel like I've made a mistake. My character is, uh, gone.

viral karma
agile vigil
#

Thinking about it, towing used to be a mod back in the day, so perhaps it is still all in lua to this day? Definitely could be worth looking at that.

ancient grail
agile vigil
fast galleon
#

I think I've asked this before, but is anybody using a global api for ItemPickerJava.Parse() so that we don't all call it mutiple times?

sick yew
#

Morning, modders.

#

I would like to ask you all, specifically those who make traits the following:

#

Is there a mod that allows adrenaline junkie, agoropohic and cowardly?

#

Devs removed that combination, and how difficult would it be to bring it back?

sick yew
neon bronze
#

Anyone knows how exactly the transmitModData call works? Im trying to call it for my object but it doesn’t transmit it?

viral karma
# faint jewel i need a way to attaach a vehicle to ANOTHER vehicle, and not like towing, like ...

Threw this together, it probably won't work, but if you have time you can play around with it.

local attachments = {
    car1 = {0, 1, 2},  -- x, y, z
    car2 = {1, 2, 3},  -- x, y, z
}

--- Create car attachments for trailer
local function createTrailerAttachments()
    local vehicle_script = getScriptManager():getVehicleScript("myvehicle")

    for id, location in pairs(attachments) do
        local attachment = vehicle_script:getAttachmentById(id)
        if attachment == nil then 
            local attach = ModelAttachment:new(id)
            attach:getOffset():set(table.unpack(location))
            script:addAttachment(attach)
        end
    end

end

Events.OnGameBoot.Add(createTrailerAttachments)

-- in your context action or something
function attachVehicleToTrailer(playerObj, trailer, vehicle)
    -- do some checks on the objects (==nil)
    -- check if the trailer has attach points
    -- loop through attach points and find the first empty one
    local trailer_attachment = nil
    for id, _ in pairs(attachments) do
        -- get trailer attachment
        -- check if something is attached there?
        -- if not, break this loop, we have our id
        if attachment_open then
            trailer_attachment = id
            break
        end
    end
    if trailer_attachment == nil then
        -- uh oh!
        return
    end

    local vehicle_attachment = vehicle_origin_attachment?!?

    -- attach vehicles
    local vehicleA = getVehicleById(trailer)
    local vehicleB = getVehicleById(vehicle)
    vehicleA:addPointConstraint(playerObj, vehicle, trailer_attachment, vehicle_attachment)
end
waxen bay
#

any ideas if my ground mesh works ingame but my skinned mesh doesn't? i'm assuming my export and scale is ok if the ground mesh works

#

no path errors in debug either

sick yew
#

Where are the files of the base traits found?

#

I want to modify them directly.

waxen bay
#

i can't think of any mods that replace traits but looking into more traits files might help

jagged ingot
#

Good morning.

sour island
# winter thunder

I meant to ask yesterday but are you trying to store the drug info in the player? Wouldn't it be more advantageous to only store an ID with quantity?

jagged ingot
#

Codddinnggg on Christmas Evvvvveee

lusty marsh
#

Is there a function to get every item definition? I want to create a table of every food item in the game, I've seen getAllItems() being used elsewhere but it seems to be nil for me?

jagged ingot
#

Calls to that should be somewhere.

sour island
#

getScriptManager():getAllItems() returns an array of item script objects

jagged ingot
sour island
#

yes, unlike recipes, items can't share IDs

jagged ingot
#

\o/

lusty marsh
jagged ingot
#

Excuse me while I Lua in Java.

#

Honestly? A wrapper for all List instances that accepts pairs() would be nice.

#

I remember seeing something called PZArrayList somewhere..

#

I'm also having an itch to make a content mod for the first time in a while..

#

Anyone know of any attempt to make a mod that adds UI for PZ for advanced circuit / electrician repairs?

calm depot
#

If they moved to LuaJ, __pairs and __ipairs metamethods could be attached to the java types

jagged ingot
calm depot
#

it's currently a mess and switching to it would be non-trivial

jagged ingot
#

They could make their own implementation of those methods though. It'd involve using the kahlua.vm.* objects.

calm depot
#

since they don't have any pressing Lua performance concerns, I doubt anyone wants to tackle it

jagged ingot
#

It sounds like fun.. and I'd benchmark it if I got the time to do this.

calm depot
#

LuaJ have their own benchmarks, they outperform Kahlua

jagged ingot
#

If you want a performance boost in the game, modify the engine to use bitwise powers of two operations for chunk to world coordinates.

calm depot
#

they also outperform the reference Lua implementation in many cases, when JIT'ed code is enabled

jagged ingot
#

Sooo many calls to transformations of coordinates when looking up IsoGridSquare stuff in each tick. 🙂

calm depot
#

isn't that calling into Java?

jagged ingot
#

Regardless, doing decimal math vs bit-shifting is suchhh a performance difference.

stone garden
#

hey anyone want hear my mod idea?

calm depot
#

that depends on how smart the optimizer is

jagged ingot
calm depot
#

diassemble the JIT code the JVM generates before getting carried away 🙂

jagged ingot
#

I have a few optimization pitches for the game but that one is one of the biggest ones.

calm depot
#

have you run the game in a java profiler?

#

things that are worth optimising are whatever pops out at you on a flame graph

jagged ingot
# calm depot have you run the game in a java profiler?

I've worked mainly on the Java side of the game for clients in the past. One of the many things I did were performance adjustments to things like the database (Migrating to MySQL and also MongoDB), and fixing memory leaks. More recently, I've patched the game to fix exploits.

#

Profiling in the past yeah.

calm depot
#

from SQLite to MySQL/MongoDB?

jagged ingot
#

Yeah. Was nice. 🙂

calm depot
#

MySQL? sure

jagged ingot
#

Someone else also did SQL server recently.

calm depot
#

MongoDB? christ no

jagged ingot
calm depot
#

storing user accounts in a JSON-like document store sounds like hipster nonsense to me

#

and there I was thinking the NoSQL nonsense died off

jagged ingot
#

I just work on what I'm asked to do. 😛

calm depot
#

strikes me as a bit pointless though, the game will choke to death on many other things before SQLite becomes your problem

jagged ingot
#

It's good to know it when work is available.

calm depot
#

I just don't do work where I'm not part of architecting the solution 🙂

thick karma
#

(Car keys have to be on your keyring to work? Programmatically, makes sense, realistically boooooooooooooooooooooooo)

drifting stump
#

?

#

they can be used from the inventory itself and dont remember exactly but maybe also from a cars inside storage

fast galleon
#

when you drive key is not in inventory, is it? never checked

drifting stump
#

nope its moved to the ignition

quasi kernel
#

I don't think it works from other inventories iirc

#

Only the main and keyring (?)

#

Forgive me if I'm wrong tho

neon bronze
#

Anyone know how you can call up items from a world container?

bold locust
#

I've always had this idea for a mod since I started playing and haven't seen it. But I feel like random a random or picked allergy to any sort of food item would be cool, and then effects ranging from a rash moodlet to almost instantly killing you

ancient grail
thick karma
#

Anyone happen to know which functions animate the speedometer and the engine light and battery light when you turn on a car?

#

In vanilla, the car gauges and such stop working when you hide UI

ancient grail
#

If u remember

thick karma
#

I know ISVehicleDashboard.lua but I do not see where that file makes a decision to animate or not animate the speedometer, for example. Do you have the details or do you just believe it's in that file? I know the files but I do not see the details

ancient grail
thick karma
#

I see

bronze yoke
#

if you continue down this path you'll find the forbidden knowledge 😟

thick karma
#

lol I want the forbidden knowledge

#

It's so confusing... I cannot even figure out what aspect of hiding the UI causes this

#

I tried manually showing EVERY UI element (and the gd array was 80+ long at the time)

#

And I tried UIManager.setVisibleAllUI(true), which historically seems to hit more than one UI thing

fast galleon
#

I think I saw a VehicleGauge the other day

thick karma
#

But neither one of those seems to be responsible for making sure the dashboard animates

bronze yoke
#

like the gauges?

thick karma
#

ISVehicleGauge.lua is a file but I do not see how it would determine to animate on the basis of UI visibility

bronze yoke
#

that's a java object controlled by ISVehicleGauge

fast galleon
thick karma
#

oof

#

So what makes that render call happen becomes the question

fast galleon
#

Try setting the javaobj to visible

viral karma
#

The gauge is rendered in java using a line.

thick karma
#

Because SOMETHING about hiding every UI element OR something about calling UIManager.setVisibleAllUI OR something about the visibility of the UI more generally -- i.e., something I CAN do from Lua -- is disabling and enabling that animation

thick karma
bronze yoke
#

the gauge

viral karma
#

Odd, when you hide the UI doesn't it hide the vehicle ui?

fast galleon
thick karma
#

I see hold on it's called fuelGauge

#

That's how ISVehicleGauge gets operationalized in ISVehicleDashboard

#

Gonna try to access fuelGauge via dashboard brb

fast galleon
#

there's ~3 of them

thick karma
#

I see

#

fuelGauge, engineGauge, speedGauge

#

Those are the ones that are not animating

#

Hmmm

#

Lmao well I can hide and show the fuel gauge and such independently

#

For a truly borktastic Zomboid experience!

#

Publishing this TODAY!

#

lol

#

lol but unfortunately setting visible true does NOT resume the updates

#

In fact even if I hide and show the gauge is stays in its old incorrect state:

#

(I am not moving r.n.)

#

So showing the gauge doesn't even trigger whatever updates it

#

(even once)

ancient grail
thick karma
#

I see it, idk if I have their answer but I'll look later

fast galleon
#

you're trying to activate it after hiding everything, right?

thick karma
#

Yeah

#

i mean I can show the dashboard while UI is hidden but the animations stop while the UI is hidden

#

I am thinkin about manually adding prerender to UI drawing somewhere

ancient grail
#

Im not at home atm.. i would have posted your controller mod if i could

thick karma
#

Hmmm no it hated that (I think self didn't come through right)

thick karma
#

Trying to solve one thing at a time

ancient grail
#

Sure just wanted to advertise for u

fast galleon
#

dashboard:setVehicle(vehicle)
seems to setVisible to the fuelGauge, maybe that's important

thick karma
#

I manually setVisible on fuelGauge a few minutes ago, that's not it

#

I can turn the entire fuelGauge on and off but it doesn't affect its animation state

#

There is something else for that somewhere sneaky.

#

okay... setValue is used to update the way things look

#

I can change fuelGauge from empty to full via setValue

fast galleon
#

yeah in prerender

thick karma
#

I just manually triggered it and it DOES update the way things look even while the animations are off if I trigger it manually

#

Which means this is not necessarily not animating it's just not getting any updates that would tell it to look different in the first place.

fast galleon
#

Are you getting the dashboard from the playerdata?

thick karma
#

Yeah

#
function getPlayerVehicleDashboard(id)
    local data = getPlayerData(id)
    return data and data.vehicleDashboard
end

@fast galleon

fast galleon
#

I guess edit the pretender to see what happens there

thick karma
#

in ISPlayerData.lua

#

Calling :prerender() on the dashboard actually does nothing during this non-animating situation

#

afiak

#

Eh I'll add a print to it

#

Oh wow interesting

#

The prerender is still running but not drawing any of its updates.

#

Just spammed a print statement by adding one to the top of that function

#

So it's trying to run the function that seems to update values, but it decides to drop out and not do that because UI is off for some unknown more specific reason...

#

AHA

#

I FIGURED IT OUT

#

Ugh how did I miss that shit

#

So obvious in retrospect

#

if not self.vehicle or not ISUIHandler.allUIVisible then return end

#

Thanks for the moral support @fast galleon @ancient grail @bronze yoke

#

Sorry to waste people's time with that lol

#

Ugh what an annoying line of code... lmao I really don't want to have to lie about ISUIHandler.allUIVisible state NOR do I want to edit the vanilla prerender in a non-decorative way... gonna have to make an alternate prerender function that is almost identical to the original and swap them when I am in hidden-UI mode

#

Mega oof

fast galleon
thick karma
#

Mmmmmmmm that's a great idea.

#

I love it

#

Thanks

#

That did it @fast galleon

#

Yaaaaay another vanilla bug eliminated

#

Die bugs die

#

I am just using this with no conditions and no apparent errors... it's almost like the ISUIHandler visibility check is completely pointless and in fact wrong... can anyone think of any reasons WHY the dev believed they needed to check ISUIHandler visibility in that prerender?

#

Could it be strictly because they had no plans to let you see the dashboard with HUD off?

#

Is there a better reason I'm not seeing?

#

"this":

DOTZ.oldDashboardPrerender = ISVehicleDashboard.prerender

function ISVehicleDashboard:prerender()
    ISUIHandler.allUIVisible = true
    DOTZ.oldDashboardPrerender(self)
    ISUIHandler.allUIVisible = false
end
#

I am using it with HUD visible, HUD invisible, getting out of my car and back in, 0 issues. So now I'm confused why they even check allUIVisible at all

jagged ingot
#

Found a cool website with a bunch of useful functions for common tasks for data handling of things like color data types. (yay)

#

Am currently translating these color functions for my PipeWrench UI library. 🙂

fast galleon
#

and set it to what it was in end

thick karma
#

Oh of course doh

#
DOTZ.oldDashboardPrerender = ISVehicleDashboard.prerender

function ISVehicleDashboard:prerender()
    local oldVisibility = ISUIHandler.allUIVisible
    ISUIHandler.allUIVisible = true
    DOTZ.oldDashboardPrerender(self)
    ISUIHandler.allUIVisible = oldVisibility
end
#

There that's better.

#

Thanks again @fast galleon

neon bronze
bronze yoke
#
local items = -- put however you're getting the items here
for i = 0, items:size()-1 do
    local item = items:get(i)
    -- you can operate on them here, like looping through a table
end
neon bronze
#

Does that work for ItemContainers? I get i through IsoThumpable:getContainer but during the items:size call it fails

bronze yoke
#

the only reason i can see that failing is if the thumpable doesn't have a container

calm depot
#

an ArrayList is a Java type

#

it's just marshalled into Lua

#

you can call all the same functions it has in Java from Lua

neon bronze
#

Well not trough but i can call getContainingItem on it

narrow galleon
#

hi guys im new to zomboid modding could anyone explain to me how i should mod order

fast galleon
neon bronze
#

So getItems():size then?

bronze yoke
#

items should be (however you're getting the container):getItems()

lusty marsh
#

So I've got a user reporting an error that I am lost withded

Apparently id = style:getName(), is the problem line with the error Object tried to call nil
You can see a bit further up if beardStyle:getLevel() < currentBeardStyle:getLevel() and beardStyle:getName() ~= "" then where getName() is used but it doesn't cause any problems there?

I can't actually reproduce this error either. does anyone have any idea what is causing this?

This is the code that generates a list of beard styles for the user to select from.

lusty marsh
# lusty marsh So I've got a user reporting an error that I am lost with<:ded:72136153365702253...
-- if we have a beard long enough to trim it
if currentBeardStyle and currentBeardStyle:getLevel() > 0 then
    local beardMenu = context
    
    if isDebugEnabled() then
        beardMenu:addOption("[DEBUG] Grow Long", player, ISCharacterScreen.onTrimBeard, "Long");
    end

    local all_stlyes = {}
    local options = {}

    -- add all "under level" we can find, any level 2 beard/hair can be trim into a level 1
    local allBeard = getBeardStylesInstance():getAllStyles();
    for i=0, allBeard:size()-1 do
        local beardStyle = allBeard:get(i);
        if beardStyle:getLevel() < currentBeardStyle:getLevel() and beardStyle:getName() ~= "" then
            table.insert(all_stlyes, beardStyle)
        end
    end
    -- add other special trim (a goatee can become a moustache, etc.)
    for i=0, currentBeardStyle:getTrimChoices():size()-1 do
        table.insert(all_stlyes, currentBeardStyle:getTrimChoices():get(i))
    end

    table.insert(options, {
        id = "",
        display = getText("IGUI_Beard_None"),
        selected = false,
        getterName = "getBeardModel",
        setterName = "setBeardModel",
        requirements = {
            razor = player:getInventory():containsEvalRecurse(predicateRazor),
            scissors = player:getInventory():containsEvalRecurse(predicateScissors),
        },
    })
    for k,style in pairs(all_stlyes) do
        table.insert(options, {
            id = style:getName(),
            display = getText("IGUI_Beard_" .. style:getName()),
            getterName = "getBeardModel",
            setterName = "setBeardModel",
            selected = false,
            requirements = {
                razor = player:getInventory():containsEvalRecurse(predicateRazor),
                scissors = player:getInventory():containsEvalRecurse(predicateScissors),
            },
        })
    end
end```
dull moss
#

anyone knows if bIsAimedFirearm in HandWeapon return true if you can generally aim the weapon or of it's aimed right now? Looking for ways to check if weapon category is firearm

bronze yoke
#

isRanged()?

dull moss
#

missed that one, thx

fast galleon
#

you can use ipairs in this place

ancient grail
viral karma
drifting stump
#

java arrays start at 0

lusty marsh
dull moss
#

how do i reopen lua log in-game

uncut meteor
#

hello does anyone know whats the type for floats so that sandbox ui apears
integers work but floats wont

dull moss
#

double

uncut meteor
#

thx

neon bronze
#

You mean the command line? I think its ^

dull moss
#

ah ty

rustic grove
#

so I was told I can't make StaticModel's use collision and I should use tiles
so I'm trying to associate a tile as an item like a chest or generator or fridge or anything so I can spawn it and make it addressable in-game with collision.
So is this possible and if so how would I go about accomplishing this as all I'm seeing/being told is I have to add things by hand in a tile editor?

neon bronze
ancient grail
#

what purpose you need to get the containers

neon bronze
#

Accessing the inventory of a container through the context menu

#

Well atleast for now printing the results to the command line but i got the hang of it how to call them

#

Now i just need to figure out the ISPanel stuff out to create a window

ancient grail
#
printItemsOnContainers = function(player)
    local containers = ISInventoryPaneContextMenu.getContainers(player)
    for i=1,containers:size() do
        local container = containers:get(i-1)
        for j=1,container:getItems():size() do
            local item = container:getItems():get(j-1);
            print(item)
        end
    end
end

#

here you go

#

just got home

#

goodluck

#

ah you want to use that on context menu? you can just convert it

#
printItemsOnContainers = function(player)
    local containers = ISInventoryPaneContextMenu.getContainers(player)
    for i=1,containers:size() do
        local container = containers:get(i-1)
        for j=1,container:getItems():size() do
            local item = container:getItems():get(j-1);
            print(item)
             context:addOption(item, nil, nil);
        end
    end
end
#

try this not sure if it will work

neon bronze
#

Oh no i got that part i just need the window popup

ancient grail
#

like a ui?

#
context:addOption(item, nil, nil);
neon bronze
#

Nono i mean an actual window that pops up after you click the option its of the samt type as the player stats window in debug

ancient grail
#

the panels?

#

u want to make new panel?

#

or open the loot/inventory panels

#

?

neon bronze
#

A whole new panel

sour island
#

:<

#

Getting weird errors after hitting confirm and the number I entered in input sets to 0.01 or -0.01

#

Is it a number issue?

sour island
#

Also, I can't seem to enter . in inputs?

#

Figured out the float issue

#

managed to get a float in my wallet while testing

#

threw off all the numbers going forward

#

The min/max of the slider is still 0.01 off hmmm

last flax
vast nacelle
bronze yoke
#

it seems to be there in the image

last flax
#

I mean, dont appear in the game and appears an error

sour island
#

Any people familiar with more nuanced math stuff know why 'math.floor(n*100)/100' is producing really tiny floats?

dull moss
#

floor(65.0251 * 100) / 100 = 6502 / 100 = 65.02

#

where issue?

jagged ingot
#

It's a floating-point calculation, so nothing is wrong.

#

You'll need to format your string.

sour island
#

it's meant to be a number though

jagged ingot
#

Sure. When you print it, it transforms into a string. Floating points often have trailing errors in several decimals. You'll need to format the string before printing it.

#

This is normal behavior.

sour island
#

So the numbers are correct it's just displaying incorrectly?

jagged ingot
#

math.round(myVal * 1000) / 1000 will give you 3 decimal places.

jagged ingot
sour island
#

They don't show in the display only in debug stuff

#

but it's creating issues for the UI

jagged ingot
#

Again, all floating points "float". It appears that this value that you've calculated met the threshold of floating points that when printed will show more of the value.

#

Most languages check floating point values when printed or turned into a string.

sour island
#

I understand, just not sure how to address it

jagged ingot
#

tostring(math.round(myVal * 1000) / 1000)

sour island
jagged ingot
#

Isn't there a round?

sour island
#

Math.round might work

jagged ingot
#

Different languages all in my head.

#

Either way, round will work the same.

winter thunder
#

The drug info is stored in its own lua file, the stuff I’m storing in player mod data is in regards to the accumulated effects for the sake of tracking the degree of use, addiction, overdose, that sorta stuff

sour island
#

I wasn't sure as you had screeneffects listed

#

Just trying to get a better picture of what you were trying to get

winter thunder
# winter thunder

Oh ye, so this is in a lua file. I have a constructor module, and each drug will have its own table. All that is stored in the lua.

Goal is that I can get the name of the table to reference from item mod data, which will tell me everything I need. Screen effects is a Boolean I am going to check in the future- for now I’m not touching the effects until I can get the rest of the framework built

sour island
winter thunder
#

The files you see up there tho have been changed, the keyValue system doesn’t play well with the lua interpreter for PZ

#

So I swapped back to a constructor module

sour island
#

Ah, I misunderstood and thought you were adding screen effects as a list to each player

#

I was thinking of ways to improve the medical system using medications and such - so I was curious about your approach

ruby urchin
winter thunder
#

So we are all ears on any medication stuff 😂 always down to work with others on mods too

sour island
#

Glad to hear

#

I was going to focus more on in world items - more uses for them - more injuries/illnesses

#

one specific feature I had in mind was not knowing what each medication does unless you have enough medical skill

#

but as a philosophy/foundation I would want it to scale easily

#

so I was thinking tables that can cross check for drug interactions

stone garden
#

i liked this mod

#

before it even release

winter thunder
sour island
#

I think keeping it simplified/gamified is the best approach

ancient grail
#

Guys can u help me with math

Convert the weight into~~ 8$~~ 6cash based on every .1 weight

So that math would be math.floor(weight/6)

#

Or is it *

winter thunder
#

What are you getting the weight of?

#

Like, a single “money” item?

bronze yoke
#

you want every .1 weight to be worth 8$? just do value = weight * 80

ancient grail
#

Ye changed to 6

sour island
#

Maybe I should release my money as a separate mod lol

ancient grail
#

Forgot to change the problem only the solution ill fix that

winter thunder
sour island
#

I think it has a few benefits

dark wedge
#

Hey y'all. Anyone know of a way to set the replacePrimaryHand on an item's definition at runtime? Source: https://projectzomboid.com/modding/zombie/scripting/objects/Item.html#replacePrimaryHand
Seems this is something that can only be set in the ".txt" file that defines the item, and the game keeps it internal to Java. Looks like an "ItemReplacment" JavaObject is required to be set, but there is no "new()" function for it in Lua so can't make one. Hopefully I'm missing something, or maybe there's another way to do it?

bronze yoke
#

i'd honestly rather work with your money if it came out separately, but it's not my decision to make unfortunately

ancient grail
#
for k, v in pairs(getScriptManager():getAllItems()) do 
local goldItem = v:getFullType():contains("Gold")
print(v..": "..goldItem)
 end 

@bronze yoke will this work

sour island
#

You're trying to value jewelry based on weight?

bronze yoke
#

if you're trying to print all the items with the word 'gold' in their name then yes

ancient grail
#

Yes

sour island
#

I made it so you can disable wallets and you could not put up shops - so technically you could just have the money from shops and traders

winter thunder
#

What is your current money mod, btw?

ancient grail
#

If i get the full type then thats the thing i need to put on a table

sour island
#

Shops and Traders (if you're asking me)

winter thunder
#

Yee haha

#

Is it already published?

sour island
#

The money isn't alone - but yes it's out

#

going to be pushing an update and a sub-mod for it soon

winter thunder
#

Oh! Nice!!! It looks clean!

#

Oop

#

Googled it before you posted lol

sour island
#

Yeah, meant to paste it sooner

dull moss
#

what am I missing here?

player:getModData().DynamicTraitsWorld = player:getModData().DynamicTraitsWorld or {};
local modData = player:getModData().DynamicTraitsWorld
if modData.Bloodlust.BloodlustProgress and player:HasTrait("Bloodlust") then
    modData.Bloodlust.BloodlustProgress = SandboxVars.DynamicTraitsWorld.BloodlustProgress;
else
    modData.Bloodlust.BloodlustProgress = modData.Bloodlust.BloodlustProgress or 0;
end
print("BLP:"..modData.Bloodlust.BloodlustProgress);```
if moddata value doesn't exits and player has trait it should set it to sandbox value. otherwise it should use existing value if it exists or 0 if it doesn't. This is called on OnCreatePlayer. It sets it to 0 when player has the trait. What am I missing here?
bronze yoke
#

is the sandboxvar zero?

dull moss
#

no

#

default is 1000

bronze yoke
#

oh this is happening because

#

if modData.Bloodlust.BloodlustProgress and player:HasTrait("Bloodlust") then
this says 'if the moddata DOES exist and they have the trait'

dull moss
#

oh im pepeg

#

certified MM classic

winter thunder
#

Yeah haha, I thought that was the issue. Gotta love the way modding has its way of making you feel like an idiot sometimes 😂

Spent like 3 hours yesterday trying to figure out why a function was failing to pull the mod data from an item.

I had it typed as item.getModData().DrugId

It took me so damn long to realize I put item. Instead of item:

dull moss
#

been there done that

#

spent earlier 5 min trying to figure out why character:IsZombie() not working

#

cuz it's isZombie()

bronze yoke
#

you two need intellij bad

dull moss
#

ye

#

fuck it

#

im doing it

#

what's better time to migrate to other IDE than midnight on xmas eve

#

good news that I already have itelliji

winter thunder
#

With full Java decomp…

#

I’m just dumb lol

bronze yoke
#

did it not complain about number of arguments?

winter thunder
#

I don’t remember, it was honestly like 2am… so I was just coding on full monkey brain

bronze yoke
#

actually mine doesn't 😥

winter thunder
#

Damn… guess IntelliJ is bad, I’ll just have to go back to coding in notepad 🥸

ancient grail
#

Anyone has a snippet of a function like this

Remove the entries of a table if its an entry of this table

#

Like a black list thing

bronze yoke
#
for k,v in pairs(t) do
    if blacklist[v] then t[k] = nil end
end
#

if your table uses numerical keys you can use

for i = 1, #t do
    if blacklist[t[i]] then t[i] =nil end
end
```which is a little faster
ancient grail
#

Ah for loops are faster?

bronze yoke
#

pairs is a function so it's always going to be a bit slower

ancient grail
#

ah i see thnx alot albion

dull moss
#

why emmylua documentation is some asian language

#

partially, at least

bronze yoke
#

because it's a chinese project

dull moss
#

pog it works

bronze yoke
#

let's goo

dull moss
#

idk why it wants to highlight true, gonna go dig in code appearance settigns

bronze yoke
#

yeah emmylua has some ugly and unnecessary formatting by default

dull moss
#

save me some time and tell where to find settings?

bronze yoke
#

i don't recall

dull moss
#

color scheme

drifting stump
#

honestly i see why it would highlight that

#

if boolean == true is some of the most cursed code possible

bronze yoke
#

it just highlights true and false no matter what

dull moss
#

I was promised auto-fill and I was let down sadge

bronze yoke
#

yeah, events are created at runtime so you still need to remember those

dull moss
#

ah

#

hey since we talking about events

#

can i add events like midgame

bronze yoke
#

you can probably just drop a table into your lua docs honestly

#

like new events? or new functions to the existing events?

#

the answer to both is yes

dull moss
#

cool

#

then instead of initializing events on game start i'll do it on create player and add events only for perks that they have

#

or capable of gaining

#

micro-optimizing go brrrrrr

dull moss
#

anyone knows how to make inteliji fold {} blocks in .txt files?

#

cuz not being able to fold 600 lines sandbox options is gonna make me unalive myslef YEP

dull moss
#

in PZ thunderstorm can ONYL be present if its raining right?

finite radish
#

people use intellij for things that aren't java/kotlin? wtf

#

that's wild

winter thunder
#

Is it possible to automatically add something to the auto - clear list?

waxen bay
#

is there a limit to the amount of types an item can have?

dull moss
#

if it's a table i don't see why there would be one cuz i'd guess it's safe to assume that anything that checks for item types goes through array

waxen bay
#

i thought that but then i remembered that the most variants i've seen on a single item is 20, so i was wondering if that was a coincidence or some kinda cap from the game

dull moss
waxen bay
#

i have 30ish technically so imma just try doing all of them since its just one line each lol

dull moss
#

i'm like 99% sure they are not capped

#

disclaimer: havent done any items so idk

#

but it's just be plain dumb if it's table but for some reason it's allowed to have only 20 entries

waxen bay
#

ya im sure its uncapped if its a table

#

this is my first time doing a clothing mod so i'm just doing a ton of textures, make the item work for as many outfits as possible i guess haha

#

plus tintables but that has to be its own items each so its nbd

dull moss
#

ok whoever told me to use inteliji

#

you better tell me how to make text fold to next line'

#

i dont want to scroll

#

left and right

#

in 2022

tough crag
#

How plausible is it to make a mod that immediately pauses the game world when you first log in to the game? I need to do just that for divine intervention with the debug console to save a dying character that otherwise dies immediately.

dark wedge
dull moss
#

fuck this inteliji bullshit

#

cant even softwrap lines

#

and now it fucking hardwraps my translation files

#

and breaks them

#

great IDE

bronze yoke
#

how have you got it to do that??

dull moss
#

i dont fucking know, i was trying to dind option to softwrap

#

this is actually malding

#

k i jsut reset settings to default, at least it doesnt break my translation files anymore

tough crag
sour island
#

softwrap? pretty sure it's got that feature and more

dull moss
#

im not scrolling left and right

#

in my IDE

#

I'd rather stay in VSCode than scroll left and right

#

god this shit was hidden

sour island
#

Yeah, there's alot of features - almost too many

#

hard ot find stuff

#

it has it's own search bar

dull moss
#

spend 20 min trying to find fucking softwrap
it's right there
mfw
dented

#

Also today I learned to use this syntax/wrap/whatever its called
local rainGain = 5 * rainIntensity * (player:HasTrait("Pluviophile") and 1.2 or 1) * (isThunderstorm and 3 or 1);

bronze yoke
#

yeah and statements are evil

dull moss
#

in a good or bad way

bronze yoke
#

in a good way

#

but it looks evil

dull moss
bronze yoke
#

like it doesn't really make any sense to look at but oh my god am i glad it exists

dull moss
#

agree

#

well that's enough modding for today, time to sleep, tomorrow big mod update in Imperator Rome happychamp
Literally a Christmas present PauseChamp

grizzled cedar
#

Does changing the hitrate from like 25 to 80 increases the accuracy of the weapon? Like ill be able to hit better? Also how does aiming skill affect hitrate?

#

Im not exactly a modder nor do i know codes, but i could understand the scripts on mods that i downloaded, well kinda since im abit familiar without those kinds of scripts

waxen bay
#

seems like the type thing has no limit*, that's all the textures i added

rustic grove
#

hello: trying to get an answer to what I hope is an easy question.
I can make a 3d model, name it, spawn it in game and interact with it.
I wish to do the same with a simple tile. I can create the tilepack, definitions, place and confirm that the tiles are in-game. What I can't seem to find an answer to:
Like a generator or mini fridge, etc. How can I address the item in Lua to place/spawn it or any interaction really, or associate it as an item?
Like surely I gotta be missing a step to just say something like
local my_customitem = getItemOrTileOrAnythingAtAll()
? Any help would be appreciated

tough crag
ancient grail
#

u guys know why i cant seem to capture the atms sprite

bronze yoke
#

are you trying to revive a dead player with some database trickery?

dark wedge
#

Your code should go in:
media/lua/client/InstantPause.lua

tough crag
tough crag
bronze yoke
#

oh, yeah, the file won't even load if it's not in client, shared or server

#

i can tell you that what you are doing is possible

#

i've done it before with a slightly different method that i don't remember the exact details of

dark wedge
#

That said, I would think you should be able to accomplish the same thing by spamming the "Pause" keybind on game start. 🙂

bronze yoke
#

i think i edited the player's data with a hex editor to flip god mode on? that might have been one of the things i tried that didn't work though...

tough crag
bronze yoke
#

actually i think it could've ended up being as simple as 'open another save, turn on god mode, load the actual save'...? i remember 'things i tried' a lot clearer than 'this thing actually worked' 😅

ancient grail
tough crag
bronze yoke
ancient grail
#

i know the sprite names

#

atmTiles = {"location_business_bank_01_64", "location_business_bank_01_65", "location_business_bank_01_66" , "location_business_bank_01_67"}

#

im trying to capture them via context

#

onfill

#

i got it

tough crag
tough crag
drifting ore
#

Is there a way to make the drunk effects last A LOT longer?

#

I get sober with 20 minutes usually

pulsar apex
#

Trying to figure out where to start with modding the base map to create a building for it

#

There's a distinct lack of fire lookouts

agile vigil
# pulsar apex Trying to figure out where to start with modding the base map to create a buildi...

From what I hear, you need to recreate the cell you want to modify in the editor, then add in your fire lookout.

Players using your mod will also need to worry about your fire lookouts either overwriting other modded locations they may have in that cell, or having the fire lookout overwritten by the other modded location.

So I'd suggest looking into using the map editor, and once you've decided on a place for your fire lookouts, make sure each one is in just a single cell, so if a user overwrites it, they won't have, say, half-a-staircase hanging at the edge of a cell.

As for tips to actually get started, I'm afraid I don't know 😦

pulsar apex
#

This is actually very useful information, I know I would need to keep an eye out for other modded locations in the game but knowing the deal with the cells is very helpful, thank you

grizzled cedar
#

How does aiming skill affect hitrate chance of range weapons?

agile vigil
grizzled cedar
#

The normal txt file or something

agile vigil
grizzled cedar
agile vigil
#

I think it reduces the Minimum Spread Angle by 0.05 per level in Aiming.

In other words, it should let you aim longer to get a more precise shot at the zeds.

#

There's also two stats for Crit and Range

        AimingPerkCritModifier = 10,
        AimingPerkRangeModifier = 1.5,
grizzled cedar
#

Hmm i see, so its that orange green outline on b41, idk about b40 tho

grizzled cedar
agile vigil
#

Yeah it should be. Never played b40, so I couldn't speculate on that.

bronze yoke
agile vigil
grizzled cedar
#

Yep that sounds more like it

agile vigil
#

I reckon this is why shotguns have a huge HitChance, because there's already plenty risk your angle will make you miss at intermediate range.

But I don't know this for sure, I'll admit.

grizzled cedar
agile vigil
#

First line is how many projectiles to try to hit with per shot, and MaxHitCount is how many projectiles are allowed to hit and/or the overpenetration chance. I forget which one exactly.

pulsar apex
#

Is there a certain spot of the zomboid folder where the cells are stored? I just wanna see if there's a "get out of work free" kind of card so I can take the cell and change it to my likings while keeping it flush with the environment instead of having to recreate it fully

#

fair enough

bronze yoke
#

no

pulsar apex
#

fudge

grizzled cedar
#

Are cells different from chunk?

bronze yoke
#

the editable format is not available for the vanilla map

pulsar apex
#

damn, so would have to recreate it one for one

#

alright makes sense actually

#

seeing how most mods have weird cell differences with the building mods that make my ocd go crazy

#

thank you all anyways

agile vigil
#

Perhaps knowing that will let your ocd rest a bit, now 😛

pulsar apex
#

yeah, at least i know it isnt a purposeful choice
unless it isnt stressed

agile vigil
#

Perhaps ask in #mapping for some advice, too 😄

#

Took me a hot second to realise we have a dedicated channel for, well, what you're doing!

grizzled cedar
#

Is learning lua important on creating pz mods?

bronze yoke
#

for most types of mods yes

grizzled cedar
bronze yoke
#

if you just add a generic item or something you might not need any special programming

grizzled cedar
#

Hmm

#

Ill just keep editing mod scripts then drunk

agile vigil
#

Lua isn't too bad a language to learn. I remember it being one of the first scripts I toyed with way back with Stranded 2.

grizzled cedar
#

But itll still take months to learn, ill try learning it bit by bit tho

agile vigil
#

Start small. Try out doing just some small stuff at first.

Oh, and are you familiar with IDEs or anything like that already?

grizzled cedar
#

Nop

#

If i learn lua, itll be my first programming experience

#

Unless u consider a certain game's command block axe

agile vigil
# grizzled cedar If i learn lua, itll be my first programming experience

Then I suggest just getting a good text editor (my preference is Visual Studio Code - or VSCode for short), and once you feel like you're ready for some supporting setups, you can look up PZ-Libraries and use that with IntelliJ IDEA which is a full-fledge IDE.

It's a bit much to jump into an IDE day 1, imo. Too much setup and you'll lose the will to program before you get anything done 😄

robust jetty
#

I started making mods 3 days ago and with the basics of Lua I more or less managed to understand the lua files of pz, what is difficult for me now is to understand the parameters of the methods

#

i started to learn lua two weeks ago

agile vigil
# grizzled cedar I have note++

I'd suggest opening a whole folder in Notepad++ to make your life a little easier (just drag and drop your mod directory).

Once you have your mod folder open, you can also open the full Zomboid/media directory so you can search in all the vanilla files for existing uses of things.

agile vigil
agile vigil
robust jetty
#

I'm currently using vscode, I think so, it's time to switch

agile vigil
#

There's a very lovely in-depth tutorial on the PZ-Libraries GitHub on how to set things up. You can just google it.

robust jetty
#

Yes, i find it, ty

#

😊😊

pulsar apex
#

Knock on wood but

#

This is actually really simple

#

Very good very nice

#

Created a little forest area and pond in less than an hour

#

er about an hour correction

robust jetty
#

Nice

pulsar apex
#

I jinxed myself

#

thanks tilezed

robust jetty
pulsar apex
#

worldzed is being weird

#

im following the instructions of tilezed > tools > worldzed > new window popup instance of worldzed

#

but this pops up infront of worldzed

#

and no matter what i click

#

it just closes worldzed

#

dunno what do

agile vigil
#

😦

pulsar apex
#

if anyone knows what to do, please @ me the response or respond to it with the respond feature or any way because i have a cold and i am not gonna work all night on this for christmas drunk

#

goodnightfolks

agile vigil
#

Good night, MF, and Merry Christmas + swift recovery!

pulsar apex
#

thank you very much, and thank you again for the help!

agile vigil
#

I have a question of my own, just a simple one: Is getServerModData safe to use for MP, or should I store ModData on items and players instead?

#

I think my brain shortcircuited on that one. getServerModData doesn't even return a value, so that wouldn't work anyway.

faint jewel
#

lol

agile vigil
#

So, time to try a strategy that'll (hopefully) give me a list of all players, even the offline ones 😄

#

Actually, I think I have a solution. Since we have Lua script checking so users don't modify scripts:

I can run (on each client) a tick every X minutes, and just use that to increment some info I need. Excellent.

Trying to create an XP log of sorts so I know roughly when you earned a specific amount of XP for different things, then let you write that down in your diary.

#

... There's an AddXP event.

robust jetty
#

F

agile vigil
#

This makes my life much easier, so all in all, this is good 😄

ancient grail
#

imanage to create a function to convert the atms into containers but i can seem to make it solidtrans

#

i can still pass thru it even if i set it to canpassthru false

#

any ideas how i set it so that i cant run thru it

agile vigil
ancient grail
#

hmmm

#

how exactly did you convert it

#

cuz mine i used manual method

#

to so that default atms dont have the feature cuz im going to convert it to a cash trading thing

#

allows player to convert gold to cash

agile vigil
#

Unsure, sorry 😦

neon bronze
#

Anyone knows by coincidence where TIS put their music? Trying to change some tracks but they are all linked to NewMusic and OldMusic paths in their scripts

agile vigil
#

No audio equipment to listen for myself, but looks like it is all in ProjectZomboid/media/music/?

neon bronze
#

Yeah thought so too but it seems there are no folders for either NewMusic or OldMusic

#

Im gonna verify rq

agile vigil
#

Right, I see what you mean now.

neon bronze
#

Tried looking through the banks but neither are they there

agile vigil
#

I'm not seeing anything in the Java code, either.

neon bronze
#

TIS black magic

robust jetty
#

Someone knows how to copy a filtered table? i have
`local equippedClothes = {}
local count = 0
for i = 0, items:size() - 1 do
local loopitem = items:get(i)

    if loopitem:isClothing() and loopitem:isEquipped() then
        equippedClothes[count]  = loopitem
        count = count + 1
    end

end`

#

tried this one but can´t use index to copy table
for index=0, items:size() -1 do print(index, items:get(index)) end

crystal briar
#

someone help

#

this truck is from that one car mod

#

and I put my clothes in the passenger seat

#

then i got in from the other side and it sent my clothes to the back seats that dont exist

#

bro

#

🤣

#

how tf Do i get em back

robust jetty
#

download backrooms map

jagged ingot
#

Good morning and merry Xmas.

robust jetty
#

Good morning and merry xmas @jagged ingot

sour island