#mod_development

1 messages ยท Page 217 of 1

cosmic ermine
#

How's this for a mod icon?

#

What is the minimum size for a mod poster?

gleaming sorrel
#

Also it looks pretty good

cosmic ermine
#

Finally finished.

nimble yarrow
#

text, text color, text frequency, o snap. i wonder if you can trigger emotes

gleaming sorrel
cosmic ermine
#

I'll also need to check if you're doing anything, if you're just idle or moving then maybe.

#

Anyway, where do you guys get your Workshop ID?

nimble yarrow
#

i just recently got sick (the 80% heavy cold) for the first time today, and the player was coughing and breathing heavy, and moving his arms all around, as i was playing and doing stuff.

#

submit it to the steam workshop to get one generated?

cosmic ermine
#

How do I make a text bold?

nimble yarrow
#

[b] like this [/b]

cosmic ermine
#

So it's just HTML?

bronze yoke
#

it's html like

gleaming sorrel
#

Now that I've completed my state of decay re-texture
And my Knox Plague re-texture

I'll make a retexture of the JOY plague from the Amazing world of Gumball
I'll probably end up doing a full change of every damage texture as well
Like I didn't with the Knox Plague re-texture

#

I'll make all the wounds on the zombies leak rainbow blood
And change their general look to the rainbow drool
With large eyes

slow graniteBOT
#
mic.0 has been warned

Reason: Bad word usage

gleaming sorrel
#

Honestly I've had my eye on this for awhile because I know nobody is going to do it
And I think it will be extremely fun

gleaming sorrel
# cosmic ermine It's a fun mod idea.

I only recently discovered I can change the wound textures as well
And now I'll never been satisfied with my textures until I do a full wound re-texture based on what I'm making

#

And honestly doing the wounds is even more fun than doing the zombies themselves

cosmic ermine
#

How would you add these images? Is it after you publish the mod that you can customize it in the workshop instead of workshop.txt?

bronze yoke
#

yeah

gleaming sorrel
#

Once you have the thing uploaded this will be on the workshop page

cosmic ermine
#

Do you think this mod is Realistic?

#

I might add that tag to the mod.

gleaming sorrel
#

More is more better
After all

cosmic ermine
#
ImBleeding.bleedingTexts = {
    [BLEEDING_SEVERITY.minor] = {
        "The bleeding is minimal, but I must tend to it.",
        "The wound is minor, but I should address it soon.",
        "I'm bleeding a little...",
        "Ow! It kind of stings! I'm bleeding a little bit."
    },
    [BLEEDING_SEVERITY.moderate] = {
        "The bleeding is moderate, but I must tend to it.",
        "The bleeding is moderate, but manageable.",
        "I must apply pressure to stop this moderate bleeding...",
        "Although moderate, I must staunch the bleeding soon...",
        "Though moderate, I must find a way to stop this bleeding..."
    },
    [BLEEDING_SEVERITY.severe] = {
        "I CAN'T AFFORD TO LOSE ANY MORE BLOOD!!!",
        "I'M LOSING A LOT OF BLOOD!!!",
        "I FEAR I WON'T SURVIVE THIS IF THE BLEEDING DOESN'T STOP!!!",
        "THE BLEEDING IS CRITical, and i'm growing weaker...",
        "THE WOUND IS SEVERE, I MIGHT DIE SOON IF I DON'T ADDRESS THIS QUICKLY!!!",
        "I'M LOSING BLOOD RAPIDLY, I NEED HELP!!",
        "I'M BLEEDING SEVERELY!"
    }
}
```These are the texts for now.
gleaming sorrel
#

Alot of different text based on the severity

fast galleon
cosmic ermine
fast galleon
#

I guess IGUI, like the read action does.

cosmic ermine
fast galleon
#

No, it's hard coded.

#

Dynamic radio has more flexible prefixes if that matters.

cosmic ermine
#

Since the one I'm thinking right now is like this:

ImBleeding.bleedingTexts = {
    [BLEEDING_SEVERITY.minor] = {
        getText(),
        getText(),
        getText(),
    }
}
#

Which would be a fixed number of texts. Unless there's a function for that.

fast galleon
#

hm, you could get the translations and remove duplicate and empty variations.

cosmic ermine
fast galleon
cosmic ermine
fast galleon
#

I don't think they support dynamic texts like that, you would probably need a custom solution.

nimble yarrow
#
local function myLocalFunction --local
function myFunction -- not local. global?
cosmic ermine
#

Is there a way to read files using the game's code? Or do I have to use native Lua methods.

cosmic ermine
#

How do I get the current language the user is using?

nimble yarrow
#

what for? translations are automatic. (if thats what you're trying to do)

cosmic ermine
nimble yarrow
#

oh. for the 'not all languages have the same number of lines' thing. im bad at lua, buuuuuut i think you could just iterate through a list of strings

bronze yoke
#

i did this for a couple projects, i think there's a method on Core that returns a language code?

cosmic ermine
#

Ugh, the lack of documentation is annoying.

#

Don't know what a function does.

bronze yoke
#

looks like i used getCore():getOptionLanguageName()

cosmic ermine
bronze yoke
#

that returns a language code like 'EN'

cosmic ermine
#

Awesome.

cosmic ermine
# bronze yoke that returns a language code like 'EN'

Is it possible to make your own directory in your mod? Like instead of putting everything in media/lua/client, I can put a utility file in say media/lua/utils and then get those files by doing require("utils/FileName")

fast galleon
fast galleon
#

You could just read lines and use them instead.

cosmic ermine
#

I'll just put it in client then

#

Alright. So how am I going to do this?

  1. I need to get the language the player is currently using.
  2. With that language, I can do io.open("{LANGUAGE}/{fileName}_{LANGUAGE}") to access the file I need to read.
  3. After that I can do something like this:
fileName_LANGUAGE = {
  fileName_type_name_01 = "Text 01",
  fileName_type_name_02 = "Text 02",
  fileName_type_name_03 = "Text 03",
  fileName_type_name_04 = "Text 04",
  fileName_type_name_05 = "Text 05",
}

```4. I need to create a function that checks if the variable has an index suffix (`_01`), if it does then keep going down until you reach a line without that index suffix.

If the variable has an index suffix then keep looping and then return a list, otherwise just return the text/value.
fast galleon
# cosmic ermine I'll just put it in client then

assuming it's in client you can use

local texts = require(string.format("fileName_%s",getCore():getOptionLanguageName()))
if not texts then
    texts = require "defaults"
end

e.g. defaults file

return {
   myTexts
}
cosmic ermine
#

It's fine.

fast galleon
#

what is

cosmic ermine
hollow current
fast galleon
cosmic ermine
#

I'll just ignore that.

fast galleon
#

a preselected option adopted by a computer program or other mechanism when no alternative is specified by the user or programmer.

sour island
#

I do something similar for conditional speech -- where I load up all the possible phrases using getTextOrNull

#

So the translations are independent of each-other

#

Then you can have the phrase pulled from the translated table of phrases using zombRand or whatnot

cosmic ermine
#

Yeah, like I said, I have no idea how to get the length of the list.

#

Chinese minor texts could be 10 while English's is 5

sour island
#

That's where the getTextOrNull() comes into play

#

And my files for conditional speech don't have the same lengths either

cosmic ermine
#

I'm all ears.

sour island
#

This is a cropped snippet:

local phraseSets = {}

phraseSets.Phrases = {}

--- snip

phraseSets.Phrases.Drunk = {}
phraseSets.Phrases.HasACold = {}

--- snip

function phraseSets.LoadFromTranslation()
    for k,_ in pairs(phraseSets.Phrases) do

        local phraseNum = 0
        while phraseNum < 1000 do
            phraseNum = phraseNum+1
            local phraseID = "UI_Phrases_"..k..phraseNum
            local foundPhrase = getTextOrNull(phraseID)
            --[debug]] print("CND-SPEECH: phraseNum:"..phraseNum.."  foundPhrase:"..foundPhrase)
            if (foundPhrase) then
                table.insert(phraseSets.Phrases[k], foundPhrase)
            else
                break
            end
        end
    end
end


return phraseSets
#

This assumes you have a text file in the appropriate translation format -- it will start pulling phrases off the phraseSets.Phrases. table

#
--UI_Phrases_Drunk
UI_Config_Drunk = "Drunk",
UI_Phrases_Drunk1 = "feeling tipsy",
UI_Phrases_Drunk2 = "feeling good",
UI_Phrases_Drunk3 = "this is great",
UI_Phrases_Drunk4 = "that is the stuff",
UI_Phrases_Drunk5 = "that is the good stuff",
UI_Phrases_Drunk6 = "time to party",
UI_Phrases_Drunk7 = "I am wasted",
UI_Phrases_Drunk8 = "I could go for another",
UI_Phrases_Drunk9 = "I have no worries",
UI_Phrases_Drunk10 = "nothing can stop me now",
UI_Phrases_Drunk11 = "bring on the shots",
cosmic ermine
sour island
#

I use say() - I would suggest the same for your case

#

actually I lied

#

I use addChatLine

#
player:addLineChatElement(text, return_color.r, return_color.g, return_color.b, UIFont.Dialogue, vol, "default", true, true, true, true, true, true)

#

I swapped to addChatLine for MP support

#

Actually, if your mod doesn't need to be shown/work like dialogue -- I would stick to haloText
Actually x2 - I don't see a way to use other fonts with halotext - so use Say()/addLine

#

You'd need to use a network command to make it work in MP - so that part is up to your preference -- you can read through conditional speech for that too

swift moon
#

Anyone know what would cause this to happen with world models? Normals are fine on the model

cosmic ermine
# sour island ```lua player:addLineChatElement(text, return_color.r, return_color.g, return_co...
local bleedingText = PhraseClass:getRandomPhraseBySeverity(bleedingSeverity)

local textTintMultipliers = {
  [ImBleeding.SEVERITY.minor] = 1,
  [ImBleeding.SEVERITY.moderate] = 3,
  [ImBleeding.SEVERITY.severe] = 5
}

local textTint = (255 - (bloodLossRate * 55 * textTintMultipliers[bleedingSeverity])) / 255
textTint = math.min(textTint , 200 / 255)

local currentTime = getGameTime():getMinutesStamp()
if (ImBleeding._timeBeforeSayAgain <= currentTime) and (bloodLossRate > 0) then
  -- playerObj:setHaloNote(bleedingText, 255, textTint, textTint, 300)
  playerObj:Say(bleedingText, 1, textTint, textTint, UIFont.Dialogue, 0, "default")
  ImBleeding._timeBeforeSayAgain = currentTime + ImBleeding.BLEEDING_SEVERITY_DELAYS[bleedingSeverity]
end
```Can't get this to work, the color is always green.
sour island
#

For Say() you'd need to change the "default" to "radio"

cosmic ermine
#

Perfect.

#

Going to update this tomorrow.

  • Update poster/preview image.
  • Text is now larger
  • Added translation support

I may add multiplayer support but that's for when the mod gets popular enough.

cosmic ermine
#

The game really needs documentation for its API, quite difficult to mod especially with variable names like baseRange, I never knew that was the volume.

#

That aside, I'm gonna go catch some dreams. Got work tomorrow.

digital osprey
#
base_menu = context:addOption("Upgrade Stove", worldobjects, upgradeStove(stove, context));

shouldnt this fire the function when i actually click the button? upgradeStove is called on populating the context menu like this

neon bronze
#

Just pass the function name without the args

#

Rn the result gets called instead of the function

fast galleon
fast galleon
sour island
#

Looking around the codebase - would anyone know anecdotally if you can shoot vehicles? Does someone need to be sitting in one for it to work?

#

Which madman was rewriting vehicles to have better damage calculations?

sour island
#

I think it was @astral dune

#

But the reason I wasn't sure is because shooting at cars seems to be very very miss heavy

#

I assume it's cause my aiming is so low - can test that - but it feels weird to be so damn close and miss a car lol

digital osprey
#

cant seem to find much information on context menu stuff, is there a way to change the color of the button text?

outer crypt
sour island
#

That's a thing?

#

Trying to add something somewhat simple - but it's probably going to result in me rewriting how attacks are handled ๐Ÿ˜ญ

fleet bridge
#

the ability to shoot out someone's tires would be fantastic though ๐Ÿ˜‚

compact mason
#

Hi everybody. Does such a function addCorpseItem() exist?

cosmic ermine
# sour island That's a thing?

Advanced Trajectory allows you to shoot and damage cars with bullets, I am not sure if that's modded or vanilla though since I never shoot cars in vanilla, I only did it for fun while playing around with AT.

chrome egret
#

Am I totally off in thinking that I can add a function to Events.OnObjectAdded from a server file, or when it fires? I am never seeing my test logging for any item, let alone when I find a generator on the map

bronze yoke
#

it doesn't matter if it's a server file, files execute the same wherever they are

chrome egret
#

Do you know anything about this particular event, or OnNewWithSprite? I'm not being creative, this code is copped basically straight from vanilla's MOGenerator.lua, but never do my modded generators appear.

bronze yoke
#

hmmm, it might not still be used, i'd throw some prints into the vanilla file to see if it actually runs

#

this stuff is *usually* for global objects, there's a bunch of code for generator global objects but none of it is used, not sure if they previously did or something but generators don't use that system right now

chrome egret
#

Ack, I tried throwing one in vanilla and didn't see anything

#

That makes sense if it's crufty

bronze yoke
#

from what i've read on your github it doesn't look like this is tied to global objects, but

#

what exactly are you trying to do?

chrome egret
#

I thought I could hook into when generators are created and placed on the map, to modify some of them to run on propane or be dual-fual generators between gas and propane

#

I've not made custom items before, so that seemed like a simple way to change behaviors around them without having to create new item scripts. But I'm willing if it's necessary, just haven't learned that lifecycle.

bronze yoke
#

OnNewWithSprite is called when a tile with that sprite is loaded, it's probable that generators aren't usually created through that method

#

most generators are randomly generated so i imagine they just create the object directly for those

#

if there's a guaranteed spawn somewhere i'd expect that to go through this

chrome egret
#

Yeah, it's unclear at this point

#

How guaranteed? I use Rosewood for testing and usually find a generator in the school shed, though seemingly not always.

#

Maybe I haven't found a guaranteed spawn.

#

It also does not kick in when I add a generator from the Item List debug functionality.

bronze yoke
#

if i'm interpreting correctly it'd have to be a 100% guaranteed, map-defined spawn

#

yeah, i've found the part of the java where they add the random generators and that wouldn't trigger this

chrome egret
#

Hm, does that point to a more reliable method?

bronze yoke
#

not really, i can't see an easy way to catch it

#

i don't think you can even scan squares as they load as it happens after that, it fires OnSeeNewRoom but that's before it actually rolls for the generator

#

are the changes to the generator visible?

#

if the player wouldn't be able to tell, i don't think generators ever spawn on or anything so you can just change whatever you need when the player first interacts with it

gleaming sorrel
#

Does anyone know how to edit a .pack file?

#

Seems some textures aren't contained within the Texture folder
But instead the TexturePack
Folder

#

Inside something called a .pack

bronze yoke
#

why do you need to edit it?

gleaming sorrel
bronze yoke
#

you can overwrite images inside a pack without using one, i'm not even sure what the benefits to packing are

#

probably some loading or size optimisation

gleaming sorrel
bronze yoke
#

oh, Project Zomboid Modding Tools on steam has a utility for extracting them

gleaming sorrel
#

I also would think I need to repack it after as that's how they are in the game files

bronze yoke
#

tilezed

#

you don't need to repack it, and if you did you would be overwriting every texture in the game

#

images in a pack still have an effective filepath and putting an image loose in that filepath in your mod will override it as normal

gleaming sorrel
#

I honestly have no idea what that means

bronze yoke
#

if you want to override textures/myimage.png you put your own file on that path in your mod right?

#

you can still do that for texture packs, the images inside them still have paths

#

you will still need to extract it with tilezed though

gleaming sorrel
#

So would I just put it in the
texturepack folder same as the regular textures?

gleaming sorrel
bronze yoke
#

download Project Zomboid Modding Tools, it should be in your steam library if you have zomboid

#

it's included in there

gleaming sorrel
#

I have that downloaded
But it doesn't allow me to unpack the file

#

Hold up
It isn't installed
Odd

#

Would I just open the pack from within tilezed?

gleaming sorrel
gleaming sorrel
#

After figuring out how to open it in tilezed
I have no idea what a prefix is

chrome egret
fast galleon
#

Some maps come with pre-existing generators, the main map usually spawns them randomly with the OnSeeNewRoom event. Immersive solar arrays spawns more custom generators the same way.

gleaming sorrel
#

Some please tell me what the heck a prefix is

fast galleon
gleaming sorrel
#

I don't see any pack files that look like that

#

I'm trying to extract
UI.pack

fast galleon
#

go to view pack, hover over an image, what does it show you?

gleaming sorrel
fast galleon
#

argh, you probably want to export separately then without any prefix

gleaming sorrel
astral dune
# sour island I think it was <@280491134134779904>

its been a while since I've touched it, but ya it was me. For the record, afaik, you can't shoot a car unless you're literally standing in a spot that allows you to interact with a door, hood, trunk, etc. So point blank

sour island
#

Yeah I noticed that

#

Don't really feel like spending that much effort on the process ๐Ÿ˜…

#

Someone else mentioned advtradjectory does it - I wonder how

astral dune
#

dunno! the point of my mod was to build an event system to allow modders to tell what kind of damage the vehicle took (collision, off-road, zombie, weapon, etc), and alter, redirect or cancel it

#

worked good, the only challenge was high speed collisions between two vehicles. Didn't get the chance to properly test that, and moved on to other things. hopefully the next big release makes all that obsolete, but who knows

sour island
#

From previous comments it seems like Aiteron wanted to work on it

#

I think a vehicle refactoring is probably much farther down the line

astral dune
#

could be, I begged them to fix the hardcoded override of the engine's horsepower on the java side and they said they would for 4.2, if they remember, lmao

sour island
#

Yeah that's another thing - alot of stuff in under exposed

#

I was going to try and mess with the hitList when people swing their weapons - but it's all unreachable ๐Ÿฅน

#

So I'd need to recreate it in Lua

#

Several classes worth of stuff

astral dune
#

ya, me too, when trying to event-ize people hitting cars with bats and such

sour island
#

You should check out the logging skill mod I wrote - figured out a way to find/grab the tree object being struck

#

Maybe it could help with hitting cars?

#

My issue is related to ranged weapons - which I don't even know if that'd work

astral dune
#

hmm, ya, I vaguely remember doing a deep dive on that before I realized ranged weapons still only work point blank on vehicles. Didn't come up with much

sour island
#

Appreciate the 2nd opinion

#

back to board games I guess

bright fog
#

so many possible board games to adapt in the game, can't miss that ShibaNom

sour island
#

I like APIs and systems, feels nice to whip together a mod in a weekend since most of the hard work is done already

gleaming sorrel
#

Well I give up
Can't figure out what the heck I'm supposed to do
Every guide I find does nothin

bright fog
#

Because then it would be sooo easy to add more zombie types outside of just The Last of Us

bright fog
#

.pack files ?

gleaming sorrel
bright fog
#

no idea what that is sadly sry

gleaming sorrel
#

Well that's unfortunate
I'll probably try again tomorrow

#

I've spent way too long just trying to open a file

gleaming sorrel
#

I put in to directly into my mod template folder

fast galleon
#

no prefix; each tile is a separate image

gleaming sorrel
#

I tried without the prefix

#

Still no luck

fast galleon
#

๐Ÿชฆ

gleaming sorrel
#

I'm rather fucked aren't I?

bright fog
#

Is the prefix the name of the file maybe ?

gleaming sorrel
bright fog
#

Would have loved to help you but I've got no idea what those files are

gleaming sorrel
bright fog
#

lmao

#

those are for maps ?

#

also I'm a bad example, I've been modding for 2 months now

gleaming sorrel
bright fog
#

hmm

#

why'd you need that ?

gleaming sorrel
# bright fog why'd you need that ?

I wanted to redo the artwork for bites on the health panel to go with my mod for extra immersion
And do some new art for the zombie moodle just for fun

bright fog
#

Haaa

#

Oooh I just saw your mod of the zombie rextures

cosmic ermine
bright fog
#

The textures do look creepy, no idea how it looks in-game haha

nimble yarrow
#

i just Ctrl+F this discord for 'extract pack', lots of people struggling. here's one person who did it successfully:

#

though, he's extracting map tiles, not moodle sprites, etc.
not sure if this post is relevant. maybe?

gleaming sorrel
bright fog
#

would make for some cool retextures

#

I'm sure that would interest @median prairie ๐Ÿ‘€

gleaming sorrel
bright fog
#

skull textures ? The skeletons ?

gleaming sorrel
#

I need

cosmic ermine
gleaming sorrel
# bright fog skull textures ? The skeletons ?

I've redone the skull textures for all the zombies
So when they are damaged you don't see a fully intact skull

My zombies have a broken jaw so it make more sense for the jaw on the skull to always look broken

bright fog
gleaming sorrel
#

But I need it

bright fog
#

half of their skull showing, that's in the base game ?

gleaming sorrel
bright fog
#

didn't even knew that

gleaming sorrel
# bright fog didn't even knew that

I noticed when I used the Lovecraft re-texture where the face of the zombies is a hole
But some of them had skulls over the texture meaning they suddenly had a fully intact skull

#

It bothered me so I made sure nobody had that problem with mine

bright fog
#

hmm I see yeah

gleaming sorrel
#

It did give me something

#

Not the right thing but something extracted

bright fog
#

Also if you want to make some eldrish horrors like Mystery did with its occult zombie mod, I'm making a framework to easily add zombie types ShibaNom

gleaming sorrel
#

Interesting

gleaming sorrel
#

I still really need to figure out how they did this to make the eyeball zombies

median prairie
gleaming sorrel
bright fog
gleaming sorrel
#

Speak of the devil

bright fog
gleaming sorrel
bright fog
#

So if I'm not mistaken @median prairie you made your models clothings right like I did with my Bloater for my the last of us mod ?

bright fog
#

Haven't looked deeply in your mod

median prairie
#

Used regular masking with clothing, nothing fancy.

bright fog
#

exactly

bright fog
#

Then hide the body parts (if needed)

gleaming sorrel
#

I've noticed all have used clothing
I just need to figure out how to do that
And how to make the rather simple eyeball head model

bright fog
#

Fairly easy to do tbf once you got the hang of it

#

I can send you my (less than optimal) blender file of my Bloater if you want to have fun with it

#

You just link your model to the body parts of the player model

#

(the armature in Blender)

bright fog
#

Then export the model in .fbx with the right settings and done

gleaming sorrel
sour island
#

Figured out the issue with the alpha argument

bright fog
gleaming sorrel
bright fog
#

Chuck casually coming in the middle of a conversation showing his crazy board game stuff

sour island
#

No, the network code is not sound enough to do something that needs to be updated

#

Or alteast when I tried to make it server side the game kept trying to duplicate stuff cause it updates from clients lol

bright fog
#

Well, I'm definitely missing a part of the conversation here lol

sour island
#

GameNight has issues with desync if the people have high ping

bright fog
#

Right

sour island
#

If I make it possible for multiple people to mess with the ouija board it wouldn't really work

#

The biggest hurdle is that I want the objects in the world to move around

bright fog
#

yeah that sounds like hell

sour island
#

If I kept it only UI I would probably have no issues

gleaming sorrel
#

I still need find out why my key frames in blender seem to be broken
I have no idea what I'm doing

cosmic ermine
#

@sour island May I ask how you learned what a function does, did you have to read the source code most of the time? Also, any tips for a beginner PZ modder?

bright fog
#

Check out how others do stuff, try to replicate some bits to understand how it works

#

That's how I learned it

#

Wanted to make an addon and reintroduce Monkey's work on The last of us enhanced experience bcs it was broken but by doing it my own way, made 2 different mods and now I'm fully rewriting it lol

#

then suffer for hours when some weird shit happens

sour island
cosmic ermine
sour island
#

I use an older version (sort of) - which is de-compiled code + a lua library

#

Oh, yeah then you're off to a good start

#

And yeah, you kind of need the decompiled code

bright fog
#

Still haven't even looked into that ngl

sour island
#

The issue I was having with the alpha for textures was cause the overload for draw texture isn't actually ever called from the UI in Lua - so I had to add one -- wouldn't have known without just looking at the decompiled code

cosmic ermine
sour island
#

It's a side effect lol

#

The online java doc does actually get filled occasionally with the correct names

bright fog
#

TIS casually obfuscating their code

sour island
#

I wonder if a crafty person could tie those two together -- I would have assumed Umbrella/Candle to do this tbh

#

But scraping a website sounds like a pain

cosmic ermine
#

I don't really care how the decompiled code is written, I just need documentation for what a function does lol

bright fog
#

well...

sour island
cosmic ermine
sour island
#

I think having the actual decompiled code is nicer - atleast with IntelliJ - I can jump to it to verify what's going on

#

And the nice thing about Java is it declares the variable's type - so you can kind of put 1 and 1 together to follow along

cosmic ermine
sour island
#

There are Lua functions for when timed actions occur - timed actions are actually Lua centered

#

Not trying to be too anal, but 'events' are something else - java sided methods that can be interacted with using Lua -- You'll see them around like Events.XYZ.Add(functionthinghere)

#

You can also overload/overwrite Lua functions - which is probably what you'd want for messing with timed actions

cosmic ermine
#

Do you guys have a trait icon color palette?

#

What does these do?

nimble yarrow
#

you cannot be fat and skinny at the same time, they are mutuallyExclusive.
If you gain weight, the game will -remove- skinny and -add- fat (for example)
if thats what youre asking.

cosmic ermine
#

Thanks.

quartz holly
#

I need help, I want the item to stay still every time I craft something, for this I use keep and OnCreate to execute dialogs every time the recess is created, the problem comes that with each crafting the object changes its position, and if I apply the command RemoveResultItem: true, it doesn't render the text I need

Code:
recipe Entregar billetera
{
Wallet,
keep Capitana,
Result:Money,
CanBeDoneFromFloor:true,
OnCreate:ComercioCapitana,
}

recipe Saludar a la Capitana
{
    Capitana,
    IsHidden:true,
    Result:Capitana02,
    CanBeDoneFromFloor:true,
    OnCreate:SaludarCapi,

}

Code .Lua:

function SaludarCapi(items, result, player)
sayThis = ZombRand(5);
if sayThis == 0 then
player:Say("Buenas camarada!! que te trae por aqui??.");
elseif sayThis == 1 then
player:Say("B-buenas Armero~... espera quien eres?.");
elseif sayThis == 2 then
player:Say("Si si, trajiste lo que te pedi??.");
elseif sayThis == 3 then
player:Say("Hola!! que quieres??.");
elseif sayThis == 4 then
player:Say("Entonces le clave un tiro en la cabeza y.. mrda... que quieres tu??.");
end
end


Image1: before
Image2: after

cosmic ermine
#

Damn, this mod is going to be much more complicated than I expected.

bronze yoke
#

we'd have to actually hook up a decompiler but we already have all the data scraped for umbrella, i might try and get beautiful java to utilise it or something

#

definitely makes interpreting methods a bit easier

#

anyone using a decompile as a reference should remember there's no reason you can't edit the files, rename variables when you work out what they are and you'll be able to decipher the code much quicker

old ginkgo
#

Music unrelated, just couldn't be bothered to mute my audio while testing.

abstract cairn
#

yknow how theres debug mode with right clicking? like the ui box shows up with like the brush tool admin stuff like horde spawning etc?

How would one make a custom one of those

gleaming sorrel
#

I need

old ginkgo
#

Planning on having at least 15-20 of various different poses in each category of lying, sitting, standing, and 'holding props'. Such as guns, bats, etc.

gleaming sorrel
old ginkgo
#

I am working to ensure they're compatible with one another as well. So between Fuu's and mine, hopefully will cover a lot of bases!

gleaming sorrel
#

I need all the poses

gleaming sorrel
#

I made these
For my fellow State Of Decay lovers

#

Definitely my most simple re-texture out of the 3
But I feel people will enjoy it

abstract cairn
#

also again if anyone knows how to make my own debug UI menu thing like how they have how the ui box shows up with like the brush tool admin stuff like horde spawning etc or the more builds mod makes a tab for itself etc

How would one make a custom one of those would be very cool cause i cant seem to find any resources on how to do so online

gleaming sorrel
abstract cairn
#

ty mega chad

fast galleon
#

Probably a dumb question, but does music (and sound in general) play for all split-screen players?

thick karma
chrome egret
#
Events.OnSeeNewRoom.Add(function(isoRoom)
    log('OnSeeNewRoom triggered for a new room...');
    log('Room name: ', isoRoom:getName());
    local squares = isoRoom:getSquares()
    local squareCount = squares:size()

    for i = 0, squareCount - 1 do
        local square = squares:get(i)
        log('Looking at square with x: ' .. square:getX() .. ' and y: ' .. square:getY())

        local objects = square:getObjects()
        local objectCount = objects:size()

        for o = 0, objectCount - 1 do
            local object = objects:get(o)
            log('Looking at an object on the square')
            local name = object:getName() or 'N/A (Not Found)'
            local spriteName = object:getSpriteName() or 'N/A (Not Found)'
            log('Object name: ' .. name .. ', sprite name: ' .. spriteName)

            if "appliances_misc_01_0" == object:getSpriteName() then
                log('Found a generator!')
                if isModded(object) then
                    log('Generator is modded!')
                else
                    log('Generator is not modded')
                end
            end
        end
    end
end)
#

Unless someone knows of another event that's more applicable/fires after the objects all have their data, I'll probably have to do something more invasive (maybe an OnTick that checks conditions and sets things up to be resolved later, not sure).

#

This method just fills the log with junk

#
LOG  : General     , 1708351023674> [Propane Generators (PGGeneratorCreation.lua)]:     Looking at an object on the square
LOG  : General     , 1708351023687> [Propane Generators (PGGeneratorCreation.lua)]:     Object name: N/A (Not Found), sprite name: N/A (Not Found)
bright fog
#

It wouldn't fill the log with junk without your log functions ?

chrome egret
#

This is for testing purposes

#

I need to hook into when generators are put into rooms so I can modify them

bright fog
fast galleon
#

Albion said they are spawned after the event, so you would need to do it next tick.

#

But, why not spawn new generators instead?

chrome egret
#

What's an efficient method for doing so? My previous mod was just a custom UI for doing searches, so I'm not familiar with item lifecycles or map world object placement

fast galleon
chrome egret
chrome egret
fast galleon
#

Immersive solar arrays spawns new generators, regardless of vanilla generators. It has different chances for room types and sandbox scale.

fast galleon
chrome egret
#

Ah okay, so it is relevant, just not for Rosewood where I've been testing

fast galleon
chrome egret
#

Not really, it gets called with OnNewWithSprite when the generator sprite is used, with a direct reference to the object

sour island
#

New add-on for game night ๐Ÿ™‚

#

Thanks to Oppolla for starting the process

fast galleon
chrome egret
#

Events.OnPlayerMove.Add(checkSquaresForGenerator)

sour island
fast galleon
#

<@&671452400221159444>

digital osprey
#

is there a way to add a variable to an item? was saving and passing isostove reference to check if it has been upgraded already, but realized they change every time you load the game so i need something more permanent

neon bronze
#

Moddata

digital osprey
coarse frost
#

Hello! I have a mod whose role is to send a message to all players, but it seems to me that the playsound method doesn't do that.

Could someone advise me?

Here is an excerpt from my current code:

function SoundManager.playMySound(name)
    print("Attempting to play the sound:", name)  -- For debugging
    local emitter = getWorld():getFreeEmitter()
    if emitter then
        emitter:playSound(name)
        print("Sound played:", name)  -- Confirmation that the sound has been played
    else
        print("Emitter not available")  -- For debugging if the emitter is not available
    end
end

sleek hull
#

When hooking into a function like ISVehicleMenu.onSleep, my 'copy' of the function doesn't overwrite the vanilla function, so it won't cause issues with other mods, correct? Or how exactly does hooking into a vanilla function to change a tooltip for example play with other mods that also hook into the same function?

thick karma
#

Depends on how you do it. Wanna post the code? @sleek hull

thick karma
sleek hull
# thick karma Depends on how you do it. Wanna post the code? <@155881545113141248>

`
local old_ISVehicleMenu_onSleep = ISVehicleMenu.onSleep
function ISVehicleMenu.onSleep(playerObj, vehicle)
if not vehicle:isStopped() then
playerObj:Say(getText("IGUI_PlayerText_CanNotSleepInMovingCar"))
return;
end

local playerNum = playerObj:getPlayerNum()

if findNearbyPillow() then
    options.addPillowComfort = true
else
    options.addPillowComfort = false
end

local pillowNearby = options.addPillowComfort and getText("Sandbox_ComfySleeping_Yes") or getText("Sandbox_ComfySleeping_No")

local currentComfort = getCurrentComfort()
local formattedString = getText("IGUI_ConfirmSleep") .. "\n\n" .. getText("Sandbox_ComfySleeping_Comfort") .. " " .. getComfortString(currentComfort) .. "\n\n" .. getText("Sandbox_ComfySleeping_PillowNearby") .. " " .. pillowNearby

local modal = ISModalDialog:new(0,0, 250, 150, formattedString, true, nil, ISVehicleMenu.onConfirmSleep, playerNum, playerNum, nil);

modal:initialise()
modal:addToUIManager()

if JoypadState.players[playerNum+1] then
    setJoypadFocus(playerNum, modal)
end

end
`

#

As far as I figured and was told it was just a 'save a reference to the original function, then redeclare it with the modifications you need' type deal

coarse frost
thick karma
#

Ahhh I was thinking of playClip... Idr who hears playSound. I thought it was similarly local.

#

What triggers SoundManager.playMySound(name)?

#

@coarse frost

thick karma
covert carbon
#

Hello. Does anybody know where I can find the variable that determines clothing condition and the textures that add holes to clothing?

thick karma
#

You have overwritten all original behavior.

#

It will not be compatible with other modifications of that function.

#

Is the entire purpose of your function replacing the text of the sleep modal?

sleek hull
#

Yes

thick karma
#

Do you only want it to apply to the English version of said text?

sleek hull
#

No, the rest of my mod is currently in English/German/Italian/Simplified Chinese/Traditional Chinese and French

#

So I'd have to be able to replace it with a formatted string with getText() calls to get the respective translated text

#

Looking at the wiki, hookinh into the function is more or less saving a reference to the old function, redeclaring it, then calling the old function at the beginning of the one I've redeclared to keep the original behavior, yes?

coarse frost
#

and thinking it could be my solution

thick karma
thick karma
sleek hull
coarse frost
#
local SoundManager = require "SoundManager"
local TimeModule = require "TimeModule"

local lastTriggeredTime = nil  -- Variable pour stocker l'heure de la derniรจre lecture

local function stringToTable(str)
    local result = {}
    for match in string.gmatch(str, "[^;]+") do
        table.insert(result, match)
    end
    return result
end





local function manageRestartTimes()
    local times = SandboxVars.AdvancedRestartAlerts.RestartTimes -- Assurez-vous que les horaires sont au format HH:MM pour correspondre au format de getCurrentTime
    local timesTable = stringToTable(times)
    local currentTime = TimeModule.getCurrentTime()
 

    for _, scheduledTime in ipairs(timesTable) do
        if TimeModule.isCurrentTimeEqualToSubtractedTime(scheduledTime, 10) and lastTriggeredTime ~= currentTime then
            SoundManager.playMySound("Jingle_Chuck_10_min")
            lastTriggeredTime = currentTime

        elseif TimeModule.isCurrentTimeEqualToSubtractedTime(scheduledTime, 5) and lastTriggeredTime ~= currentTime then
            SoundManager.playMySound("Jingle_Chuck_5_min")
            lastTriggeredTime = currentTime
        end
    end
    

  
end

Events.EveryOneMinute.Add(manageRestartTimes)

coarse frost
thick karma
#

Rather than transferring the sound over the server.

sleek hull
thick karma
# sleek hull Yes

You could do something like this instead:

local ExampleModule = {}

ExampleModule.ModalDialog = {}

ExampleModule.ModalDialog.new = ISModalDialog.new

-- Do not add self below; it is implied by ":" between "ISModalDialog" and "new".
function ISModalDialog:new(x, y, width, height, text, yesno, target, onclick, playerIndex, ...)
    if text == getText("IGUI_ConfirmSleep") then
        -- Optional, but you would need this for splitscreen to work right:
        local player = getSpecificPlayer(playerIndex)

        -- Use player to find distance to nearby pillow; I'm guessing you used `getPlayer()` or something, which only gets player 0.
        if findNearbyPillow(player) then 
            options.addPillowComfort = true
        else
            options.addPillowComfort = false
        end
    
        local pillowNearby = options.addPillowComfort and getText("Sandbox_ComfySleeping_Yes") or getText("Sandbox_ComfySleeping_No")
        
        local currentComfort = getCurrentComfort()

        text = getText("IGUI_ConfirmSleep") .. "\n\n" .. getText("Sandbox_ComfySleeping_Comfort") .. " " .. 
            getComfortString(currentComfort) .. "\n\n" .. getText("Sandbox_ComfySleeping_PillowNearby") .. " " .. pillowNearby
    end
  
    -- self below passed by : because Lua does that; very important to remember it.
    local modal = ExampleModule.ModalDialog.new(self, x, y, width, height, text, yesno, target, onclick, playerIndex, ...)
    
    return modal -- Very important.
end

return ExampleModule
#

Would decorate the modal call to replace the sleep text with what you want at that point of entry.

#

Can't easily intervene on ISVehicleMenu.onSleep in a highly compatible way because the value of getText("IGUI_ConfirmSleep") is used as a literal parameter in the middle of the function.

#

But you could catch it in ISModalDialog:new and no modal call that didn't have the translation of IGUI_ConfirmSleep would be affected.

fluid palm
#

hello friends, i am not sure if this is the right place to post this but i am searching for someone to commission a mod. if anyone has a better place to direct me or takes comissions please let me know โค๏ธ

gleaming sorrel
#

It might be here I'm not sure though

covert carbon
#

Hello, I am looking for help on one of my functions that I have made.
getPlayer():addHole(Torso_Upper, true)
I am trying to make a hole in the person's clothing of the Torso_Upper section of the body. When I use this function, a hole is created, however, it is in a random spot of clothing (ex. a hole is made in the pants, shoes, shirt, etc). Does anybody know a fix to this?

sleek hull
sleek hull
covert carbon
mellow frigate
covert carbon
#

Thank you

thick karma
covert carbon
#

There is no way I just wasted 2 hours of my life because I had the letter "y" in the wrong spot

#
parthit:setHaveBullet(true, getPlayer():getPerkLevel(Perks.Doctor))
getPlayer():addHole(BloodBodyPartType.parthit, true)``` Okay so this is the code. It is meant to cause a person to be shot somewhere on their body and cause a rip in the clothing where they got shot
#

However, while the bullet does hit the person and the fabric does rip, they arent in the same location

bronze yoke
#

BloodBodyPartType.parthit is null

#

parthit is a local variable, not a member of BloodBodyPartType

covert carbon
nimble yarrow
#

Don't give up, @SubLight, I know you were in here September 2023 tying to add holes. You can do it! It looks like you're getting really close?

#

I was also trying, and read all of your posts to try and gain insight on how to do it

gleaming sorrel
#

Would make using a gun much more satisfying

bright fog
#

Don't guns already do that ?

#

I know blade weapons will create more holes in zombie clothing

#

So wouldn't it also be the same thing against players and for guns maybe ?

gleaming sorrel
#

Even with bladed weapons it's not very accurate with were it puts the hole

open drum
#

dear modders, may i get some advice from thee?

#

function sayhi(player)
local player = getPlayer()
player:Say("complete")
end

function SecretMapCheck(playerID, context, items)
    local player = getPlayer()

    print(items)
    print("Name of the clicked item",items[1].name)


    if items[1].name == "Secret Treasure Map Pieces" then 
        readoption = context:addOption("Check the Map",sayhi,1)
    else
        return
    
    end

Events.OnPreFillInventoryObjectContextMenu.Remove(SecretMapCheck)
end
Events.OnPreFillInventoryObjectContextMenu.Add(SecretMapCheck)```
#

So, i have this code inserted into my file. and tried to make the game character to say "Complete" when I click an option "Check the Map" which appears after right clicking an item called secret treasure map pieces

#

However, the option "Check the Map" appears but when I click on it.. the button does not do anything.

#

Myabe it's cuz i put the args. within the addoption () wrong

#

Could anyone help me to solve this question?

covert carbon
nimble yarrow
#

where can I find more information about getVariable?
The lua API just lists IAnimationVariableSlot

bright fog
#

It's related to animsets

nimble yarrow
#

Trying to find the player's current animation. searching this discord for find animation, get animation, return animation, player animation, your post looked promising, where you recommended using getVariable to check for idle.
would the animset... include m_Name, m_AnimName, m_StringValue, or the filename, or something else?
or maybe it IS the XML, or perhaps inside of an XML, i'll look around in media\animsets

bright fog
#

getVariable gets the status of a variable for a character

#

So you can 't get what animation the character is playing exactly

#

But because every animations are defined by a variable you can it's value and check if the conditions are right for the animation to play

nimble yarrow
#

is this variable a string? is it a filename? a condition?

bright fog
#

Did you look at AnimSets ?

nimble yarrow
#

yeah i have a few opened up right now

bright fog
#

well some variables are boolean, other strings

nimble yarrow
#

so I would use a variable found under m_Conditions, then. I'll try that out

digital osprey
#

is there any function i can use to get how many items a player has (like how much scrap electronics) preferably inventory + surroundings, or do i have to do it with loops?

bright fog
#

a variable is a condition

#

m_conditions is just one of those

#

idk what it defines

digital osprey
#

tried getCount() but it always returns 1 ๐Ÿ˜„

nimble yarrow
digital osprey
#

yeah i went through that list of getters 5 times, but was worth a shot ๐Ÿ™‚ thanks!

nimble yarrow
digital osprey
#

scrap electronics and aluminum

#

when going through the inventory with a loop they just show one by one so id say im stuck doing it this way

gleaming sorrel
#

Does this look alright?

#

Trying to get a general look for the eyes

bright fog
#

You're exploring custom models ? ๐Ÿ‘€

bright fog
gleaming sorrel
gleaming sorrel
nimble yarrow
#

there isn't a player:getStats():getGodMode() or anything like that.
Maybe lua has a way of detecting if I'm in debug?

bronze yoke
#

player:isGodMod()

#

you can check debug with isDebug()

#

no, wait, that's getDebug() ๐Ÿ˜…

#

isClient, isServer... getDebug unhappy

nimble yarrow
#

In yesterdays mod,
I made an enum in the sandbox options, then passed that integer into a table, as an argument, and the table calls a unique function per sandbox enum. cool huh >.>

bronze yoke
#

the beauty of lua

nimble yarrow
#

though, the 4 functions are global, as they reside in another lua file.
should I instead call 1 global function, which then splits into the 4 local functions...?

bronze yoke
#

or use modules and never touch globals again...

nimble yarrow
#

if by module, you mean the 'requires', then creating a local var of the class, and then calling className.Function,
yeeeah i spent several hours trying to get it to work, and gave up ๐Ÿ˜‰
I'm sure I could learn it, in lua, outside of PZ modding, then come back and get it working

bronze yoke
#

that's fair

nimble yarrow
#

speaking of spending a few hours, I'm been trying to detect an item in inventory.

It seems like this would work, but something is wrong.

local itemFound = getPlayer():getInventory():FindAndReturn('Pen'); print("was the item found? " ..  itemFound)

And then once I got that working, I was gonna hide it in my backpack, which I assume would cause FindAndReturn to come up empty handed, so then I'd try ContainsRecursive

#

nevermind, the FindAndReturn is suddenly working.........

#

@bright fog thanks for suggesting I check out AnimSets, it works perfect

local function playerReading()

--[[    TranscribeJournal.xml
    <m_Conditions>
        <m_Name>PerformingAction</m_Name>
        <m_Type>STRING</m_Type>
        <m_StringValue>TranscribeJournal</m_StringValue>
    </m_Conditions>
--]]

  local performingAction = getPlayer():getVariableString("PerformingAction")

  if performingAction == "TranscribeJournal" then
    return true
  else
    return false
  end
end
bright fog
#

๐Ÿ‘Œ

#

Which animation is that from ?

nimble yarrow
#

skill recovery journal

bright fog
#

๐Ÿ‘Œ

gleaming sorrel
#

I'm quite sad that I can't figure out how to extract those textures
Because for this re-texture I was hoping to turn the bite marks rainbow

abstract cairn
#

Does anyone know how to make a UI similar to this? I can't for the life of me figure out how to add an "admin menu" like this (trying to make a mod for custom admin commands and this seems like the best UI system for it but I cant find out how to do it lmao)

gleaming sorrel
# bright fog rip

I can at least change the damage to rainbow
So I can make the bites on the character look rainbow

#

And all the blood on the zombies

bright fog
#

That's at least that

nimble yarrow
#

is there an easy way to wait in lua?

getPlayer():Say("message 1")
--wait, pause, sleep / coroutine ... 1 second later
getPlayer():Say("message 2")

I'm assuming this is NOT how the in-game radio broadcasts / VHS tapes work, but I might try looking there.
(or would a generic lua response from the internet work fine here, in zomboid lua?)

bronze yoke
#

zomboid can't really do this because it runs mostly singlethreaded and the lua would hang the entire game, you need to use some kind of timer like the above

nimble yarrow
#

To find an item in your inventory, call FindAndReturn(string) and pass in a string, easy.
To find an item in your backpack, call containsRecursive(InventoryItem) and pass in an InventoryItem. but where do I get that InventoryItem?

Can I just... name it?
local desiredItem = somehowSpecifyInventoryItemByNameOrSomething
getPlayer():getInventory():ContainsRecursive(desiredItem)

bronze yoke
#

getPlayer():getInventory():containsTypeRecurse("Base.Apple")

nimble yarrow
#

ah i was trying
local testItem = getPlayer():getInventory():getItemCountFromTypeRecurse('Weapon'); print (testItem )

#

adding the Base prefix resolved the issue, thank you again

bronze yoke
#

apparently the crash handler managed to get itself into a loop

nimble yarrow
#

is adding modData to the player bad?
edit: also, good thing it only made 14? lol

bronze yoke
#

it was a black screen that kept adding two errors every time i pressed f11, so i guess i pressed it 14 times

gleaming sorrel
#

After working non stop for about 5 hours I have completed and published the joy retexture

nimble yarrow
#

edit: workshop page needs in-game screenshot(s), same for SOD Black Fever !!

gleaming sorrel
#

I'll get screenshots for both of em

#

I will slow down on the re-textures for now
Just so that burnout doesn't destroy me

#

I'm tempted to look into map making because my state of decay obsession drives me to want to recreate Danforth

open drum
#

i managed it to work by placing correct args. inside the method

#

variable = context:addOption("String", itemobjectRightClicked, Method, player)

gleaming sorrel
#

Without ever saying how

open drum
#

hahah yea

plucky pond
#

Hello everybody! i'm trying to figure out how get "uncovered by clothes" BodyParts, i'm find some method that should return an arraylist BloodBodyPartType with zombie.inventory.types.Clothing.getCoveredParts(). but i don't understand how to call it, could somebody helpme with that?

abstract cairn
#

send help im confused

open drum
abstract cairn
open drum
#

and reverse engineer it

open drum
plucky pond
abstract cairn
open drum
plucky pond
#

But there is only name of methods

open drum
open drum
#

then see how they are used in the game

abstract cairn
open drum
abstract cairn
bronze yoke
# abstract cairn

you are passing _worldObject as the first argument to Test but the function expects a player

abstract cairn
#

any idea on how I'd make a submenu as well?

open drum
# abstract cairn any idea on how I'd make a submenu as well?
   local subMenu3 = ISContextMenu:getNew(context)
    context:addSubMenu(submenu2, subMenu3)
    local sizeKey = "Purchase a 20x20 Land"
    local sizeKey2 = "Purchase a 40x40 Land"
    local sizeKey3 = "Purchase a 50x50 Land"

    subMenu3:addOption(getText(sizeKey), worldobjects, createSafeZone, square, playerss, 1)
    subMenu3:addOption(getText(sizeKey2), worldobjects,createSafeZone2, square, playerss,1)
    subMenu3:addOption(getText(sizeKey3), worldobjects,createSafeZone3, square, playerss,1)```
open drum
#

Hey guys, is there a way to make a custom object (inventory item or instance ) without using the script.txt ?

#

for example, i know if i use```lua
local spray = InventoryItemFactory.CreateItem("Base.Plank")

it creates an instance of a plank object. However, If i change the "Base.Plank" to any random name that doesn't exist in item.txt script it will produce "nil"
#

is there a way to do like... inventoryItemfactory.new = function()
and give diff. attributes to it like... name, type, weight etc ??

bronze yoke
#

you can, but items created this way cannot save

abstract cairn
#

is there a way to have a table of saved ID's on the server/client? IE can I save an ID to a custom table that persists through logins and server restarts?

cosmic ermine
#

How do you overwrite a vanilla function? I know about the:

local original_func = originalFunc
local function newFunc()
  if condition then
    ...
  else
    originalFunc()
  end
end
```But I don't quite understand the structure of the files in `TimedAction` folders.
#

There are .start .stop and .perform functions.

#

I want to modify the player's stats like Stress and Unhappiness when they finish a TimedAction.

bronze yoke
#

start is when the action begins, stop is when the action is cancelled or otherwise ends before completion, and perform is when the action is completed successfully

cosmic ermine
#

Anything else I should keep in mind?

#

How do you guys overwrite a function?

bronze yoke
#

you've got it there, but in most cases you run the copy of the original no matter what and just add more code before/after that call

#

rather than only running the original under a certain condition

cosmic ermine
#

So you do this?

local original_func = originalFunc
local function newFunc()
  originalFunc()
  -- your own code
end
open drum
cosmic ermine
#

What is getModData? Is it for your own custom variables stored in a way where you can get them in any file without having to require a module?

open drum
#

in vanilla an item is obj. zombie is an obj, and a player is an obj.

#

modData saves any variables, tables, etc into itself

#

so if you do player:getModData(), it calls info box of the player

cosmic ermine
#

Well, can you make your own variables?

open drum
#

yes

cosmic ermine
#

OK, cool.

open drum
#

for example, data = getPlayer():getModData()
data.myowncustomvariable = "hello"

cosmic ermine
#

So I can do:

local playerObj = getPlayer()
local playerModData = playerObj:getModData()
local playerModData.customVariable = 0
open drum
#

yep

cosmic ermine
#

Awesome, I will use this for my trait mod.

bronze yoke
#

it is a table

cosmic ermine
bronze yoke
#

the java implementation of lua zomboid uses

open drum
#

everything is table in lua :(((

#

which makes it so confusing

#

especially when you want to do OOP

cosmic ermine
bronze yoke
#

it's classic lua that objects are implemented by adding a table to a table

open drum
#

yea

#

table within a table within a table within a table XD

cosmic ermine
open drum
#

haha

#

@bronze yoke could you give me direction about the question earlier?

open drum
#

any file i could look at ?

bronze yoke
#

i found it in a weird vanilla lua file wrapping this function but i don't think the file did anything interesting

open drum
#

i see thanks

#

what will be the main diff, with InventoryItemFactory.CreateItem("Base.Plank")???

bronze yoke
#

doesn't that just instance an existing item? this creates a new Item script object, you can DoParam/use setters to set properties on it, and then use the factory to instance it

open drum
#

but thought, if I change its name, values, and other properties, it can be used as (act as) new script item

#

like a work around method

abstract cairn
#

Is ModData supposed to be like this?

#

with the squiggles of death

bronze yoke
#

unless you're using umbrella, yes

bronze yoke
#

however those edited item instances would be able to save, these cannot

abstract cairn
open drum
#

like until you restart a game?

bronze yoke
#

restart, i think they were fine to be unloaded and loaded (e.g. left in a container and walk away)

open drum
#

oh.. i see ty

cosmic ermine
bronze yoke
#

yeah

cosmic ermine
#

What is sendClientCommand?

bronze yoke
#

it's for client->server communication

#

it fires an event on the server with the module, command and args table passed to it

#

it's the only way for lua to network things

cosmic ermine
#

I see.

abstract cairn
#

how would I run these commands from a client mod/custom function? Also does the string userAccessLevel mean the level the client running the command has or the access level to set? [RemoveAdminCommand and GrantAdminCommand]

#

nvm i think i found somethin

nimble yarrow
#

the userAccessLevel string is likely which set of rights you want to give. observer, gm, overseer, moderator, admin

cosmic ermine
#

How does the Smoker trait give you stress overtime? I wanna make something similar.

abstract cairn
nimble yarrow
#

i commonly use
setaccesslevel userName admin
...but ive never tried from within a custom function

abstract cairn
nimble yarrow
#

chat, or into the dedicated server command prompt, only. never tried from a function

abstract cairn
#

kk is there a way to make a custom command thats run on the server/console?
or rather a function that is run from the server so it always accepts it/completes it?

[I'm thinking if I send a "GrantAdmin" command from a player without admin it wont let it happen, and likewise a "RemoveAdmin" command from an admin to oneself might not work]
[[also for the record im doing this cause i have a server and i want to make custom admin tools for custom events lmao]]

cosmic ermine
# cosmic ermine How does the Smoker trait give you stress overtime? I wanna make something simil...

I can't believe I have to read this to figure it out, but hey, at least it's readable even though I don't code in Java.

if (this.getParentChar().Traits.Smoker.isSet()){
  this.getParentChar().setTimeSinceLastSmoke(this.getParentChar().getTimeSinceLastSmoke() + 1.0E-4F * GameTime.instance.getMultiplier());

  if (this.getParentChar().getTimeSinceLastSmoke() > 1.0F) {
    double double1 = Math.floor((double)(this.getParentChar().getTimeSinceLastSmoke() / 10.0F)) + 1.0;
      if (double1 > 10.0) {
        double1 = 10.0;
      }

    this.getParentChar().getStats().setStressFromCigarettes((float)((double)this.getParentChar().getStats().getStressFromCigarettes() + ZomboidGlobals.StressFromBiteOrScratch / 8.0 * double1 * (double)GameTime.instance.getMultiplier()));
  }
}
nimble yarrow
#

lol the scientific notation

chilly flint
#

Hey quick question.
Why is it that mod-developers make one single mod with optional dependencies already installed?
Like when you have a mod to repair weapons and then put optional dependencies for everything that is popular and not vanilla.

There are also devs who upload one mod and then a separate one for the dependencies. Thats how I know it.

If anyone answers, i'm down to hear more technical stuff since I'm learning a IT job

bronze yoke
#

it's just much less complicated for users and for maintenance to use only one mod

#

it depends on the mod but most of the time these optional dependencies aren't things anyone would want to disable so there isn't really any benefit at all to making them separate

chilly flint
#

and why not make it so it turns on and off automaticly, maybe enable / disable via sandbox

bronze yoke
#

i thought that was assumed in the one mod solution, that's what i do

#

some content types can't easily be toggled though, there are a few reasons you might have to use multiple mod ids

chilly flint
#

okey thanks very much

cosmic ermine
#

Is the event OnGameStart triggered when you load/create a new save?

cosmic ermine
#

The icon is not showing?

desert kelp
#

Does anyone know how Events.EveryDays work? I try below but it isn't working. Even used the Events.EveryDay just to check if i have wrong syntax, but both doesn't work. Hourly is good though

local function DailyRewards()
print("Daily Rewards In Progress..")

end

end

local function HourlyRewards()
print("Hourly Rewards In Progress..")

end

end

Events.EveryHours.Add(HourlyRewards)
Events.EveryDays.Add(DailyRewards)
Events.EveryDay.Add(DailyRewards)

cosmic ermine
desert kelp
#

It says in the wiki it should occur every 12 midnight but the print logs is not popping up

desert kelp
#

wait do we have an IDE for PZ? ๐Ÿ‘€

cosmic ermine
#

Probably because you have two?

desert kelp
#

yeah i was trying the other one jsut in case of incorrect syntax because it isnt working

cosmic ermine
#

That doesn't exist. Remove that.

desert kelp
#

or debug?

cosmic ermine
desert kelp
cosmic ermine
desert kelp
# cosmic ermine The icon is not showing?

might be the casing?

local gunnut = TraitFactory.addTrait("gunnut", getText("UI_trait_gunnut"), 6, getText("UI_trait_gunnutdesc"), false, false);

I have this sample from mine

cosmic ermine
cosmic ermine
#

Can you put methods/functions into modData?

bright fog
#

I've stored functions in tables for my mod but it's not what you think

cosmic ermine
#

It returns nil

bright fog
#

You link a function to a module then you call that function via a string key:

MyModule = {}

function MyModule.myfunction(variable)
-- do stuff
end

-- elsewhere
stringinmoddata = "myfunction"
MyModule[stringinmoddata](variable)

Store the stringinmoddata in ModData and call it the way I did above

#

Sry writing that on phone so taking ages

cosmic ermine
#

Oh, so it's MyModule[ModData.variable]()?

bright fog
#

No sry forgot (variable)

cosmic ermine
#

Let me try my method one last time and I'll try yours.

bright fog
#

I don't have the function you try to call so no idea if your thing is right

cosmic ermine
#

What is the variable parameter?

bright fog
#

Anything you want

#

Put one or not if you have parameters for your function

#

If you don't have any it's just that:

MyModule = {}

function MyModule.myfunction()
-- do stuff
end

-- elsewhere
stringinmoddata = "myfunction"
MyModule[stringinmoddata]()
cosmic ermine
#

What if it's a method?

#
Class.staticmethod or Class.function

Class:method
bright fog
#

Can not this be rewriten like that ?

Class:method
-- ===
method(Class)
cosmic ermine
#

I have no idea, I'm experienced with Python.

bright fog
#

I believe when you use methods you can write it like this

#

So would possibly still work idk

fleet bridge
#

playerModData.workaholic.setTimeSinceLastWork = setTimeSinceLastWork(...)

open drum
#

Question

#

is anyone familiar with using

#

luautils.walkAdj(PLAYER_OBJ, square) method??

#

for some reason when i execute that method, it stop during the move..

#

does it automatically get canceled if other methods like "print" or "getPlayer():Say("hi")" gets executed?

coarse frost
#

Hey everyone. Can someone provide me with a Lua method to play an audio file for all players on the server?

wraith lake
#

If I just wanted to make a mod that alters the charactercreationprofession lua, how would I do that? My friends on MP want to be able to get more traits than the hard 100 limit in config.

wraith lake
#

I was just trying to alter the lua to give more points. I've done it for myself for SP before, but asking all the MP friends to change it seems silly when I could just set the server to run it. I just don't understand the mod format beyond "contents"

wraith lake
#

do I just put the folder tree of the file I'm altering under contents, with the same named file? I just want to replace "charactercreationprofession.lua" with an altered version. That's all.

digital osprey
bronze yoke
#

overriding the file wholesale causes a lot of compatibility issues but for personal use it's usually fine

wraith lake
#

When I edited it myself directly, there were no issues, so I assumed the same mod list would not cause an error for mp

#

Literally just trying to change the trait point count in that lua.

gleaming sorrel
#

I'm trying to add an icon to my mod
But it doesn't seem to show up

I also found out how to unpack .pack files
By putting in the first word of the Icon as the Prefix
And changing it from spritesheet to single image

#

The zombie moodle isn't showing up either however

wraith lake
#

So to change it to the higher count, I would just put the Lua in the contents, with the same folder hierarchy as the originals?

bronze yoke
#

yeah

wraith lake
#

So media->etc. Under contents, cool. I appreciate it. It's just for a small friend group.

bronze yoke
#

the problem with file overrides is that if two mods override the same file only one of the overrides is going to work - for personal use you can easily ignore this

wraith lake
#

but start with the media folder, only incude the tree to the lua, and drop the altered lua in, and good?

bronze yoke
#

oh you will need the mod structure with a mod.info and everything if you don't have that

wraith lake
#

I think that's the one thing I haven't added yet. Not sure how to structure that exactly, but I'll figure it out. That seems more straightforward

bronze yoke
#

Contents/mods/MyMod/media/lua/client/TestFile.lua overrides media/lua/client/TestFile.lua

digital osprey
#

you can grab the example mod folder i think it has the correct structure

gleaming sorrel
#

I unpacked the texture and changed it
I put it into a texturepacks folder
But the texture hasn't been changed after updating the mod

#

Do I need to re-pack the textures?

bronze yoke
#

you can just put it in textures

#

texturepacks is for texture packs

#

internally the game treats them the same

wraith lake
#

went contents->mods->media, with mod.info in the mods folder, and it's saying "no mod info" Do I need to give the mod it's own folder like mods->TraitPointsYes->media?

gleaming sorrel
digital osprey
wraith lake
#

It let me upload. Going to fire it up to test it now that I'm subscribed.

#

Thank you all so very much.

digital osprey
#

and why would this not execute? ive been stuck for like 30 minutes ๐Ÿ˜„ before the loop everything prints ok, size > 0 and all

local destContainerItems = self.destContainer:getItems();
print("items in oven: ", destContainerItems:size());
print(destContainerItems);
for i, item in ipairs(destContainerItems) do -- this never executes
    print("item ", i, item:getFullType());
end
bronze yoke
#

destContainerItems is not a table, you can't iterate through it with ipairs

#

this is the equivalent:```lua
for i = 0, destContainerItems:size()-1 do
local item = destContainerItems:get(i)

end

digital osprey
#

damn it thought that might be the case but the fact that it reacted to size made me stick to this

#

thank u

#

didnt think of trying this

bronze yoke
digital osprey
#

ahh ok thanks for clearing that out i wasnt sure when to use which

#

this is an array or?

bronze yoke
#

in general, i would expect almost anything coming from a java method to be an arraylist like this

digital osprey
#

cool ill keep that in mind thanks a mil ๐Ÿ™‚

gleaming sorrel
#

The Icon isn't showing up either

chrome egret
#

<@&671452400221159444>

gleaming sorrel
chrome egret
gleaming sorrel
#

My password is changed

#

Help

chrome egret
#

uh-oh

chrome egret
gleaming sorrel
#

My password was changed WHAT DO I DO

#

HELP

chrome egret
#

Contact support immediately

bright fog
#

Fuck Discord and their links hidden in links

gleaming sorrel
#

Fuck I am an idot

chrome egret
#

That is really bad UX

bronze yoke
#

absolutely horrific addition

bright fog
#

yes it's terrible, it's being plaguing Discord for a few weeks now

#

Worst thing they could have done

gleaming sorrel
#

Ok I need help

bright fog
gleaming sorrel
#

How

bright fog
#

Go change your Discord password

#

Connect to your mail and go change the password

#

At least change that one

#

<@&671452400221159444> hey sry to ping again, could you please delete his messages ?

#

Before others fall for it

gleaming sorrel
#

Done

#

Email changed

chrome egret
#

Which password was changed, Steam?

gleaming sorrel
#

Steam

chrome egret
open drum
chrome egret
#

<@&671452400221159444> really need to clean these up

#

And for anyone else

bright fog
#

I keep forgetting you can report people now

chrome egret
#

I'm about to re-implement creating custom generators through the new method Poltergeist helped me uncover, I can't be having any of you losing your rights to try my new mod

gleaming sorrel
abstract cairn
#

is there a way to make a custom command thats run on the server/console?
or rather a function that is run from the server so it always accepts it/completes it/has permission?

[I'm thinking if I send a "GrantAdmin" command from a player without admin it wont let it happen, and likewise a "RemoveAdmin" command from an admin to oneself might not work] (haven't tested yet, just thought it would be common sense that it wouldnt lol)
[[also for the record im doing this cause i have a server and i want to make custom admin tools for custom events lmao]]

gleaming sorrel
#

I'm so fucking scared

abstract cairn
#

i remember when CS2 came out it so far to date was and has been the only link I clicked where I actually logged in/got tricked (they made the youtube channel look like it was Valve somehow/that the video was being live streamed from valve) attempted login from Russia lmao 2FA ftw tho instantly was able to just unsign out of every possible location/system and then reset password n enable steamguard lol

gleaming sorrel
#

I can't access my steam account anymore

#

It's not letting me use my email to change the password

late bolt
#

Thanks for the spam reports spiffo Not sure why there's been influx of them and they're not being picked up

gleaming sorrel
#

Someone please help I can't lose this account

chrome egret
gleaming sorrel
bright fog
#

Always have 2FA

bright fog
#

Also if you bought games you can use those to prove Steam it's your account

abstract cairn
#

Sorry for pinging you from multiple months ago,

I'm looking to make a function that's run on the server/has authority that can be called from admin clients (IE have the admins send a message/command to the server, have the server execute that command)

Reason why im pinging is cause this looks like the only lead I can see (as im keyword searching through the entire channel) so I thought I'd ask if you knew how I could achieve such a feat. [I'm making a custom admin and I want to be able to call commands like you could from server console]

abstract cairn
# gleaming sorrel Alright I'll try thank you

also similar to what doggy jvla said, if you have any used gift cards in person it can also be used to validate your claim (I recovered an account/disabled 2FA for my own account when I lost access to the phone because I had like 4 steam gift cards still lying around that i had used)

digital osprey
#

can i use ISTimedActionQueue to add my function to queue? (or execute it somehow when the queue is done)

#

ISTimedActionQueue.OnCompleted(TurnStoveOn); weirdly enough like this seems to work and also throw errors at the same time

gleaming sorrel
vague raven
#

yea they are

gleaming sorrel
#

Was that thing a virus or something?

#

Or did it just steal my account

vague raven
#

ยฏ_(ใƒ„)_/ยฏ

digital osprey
#

steam servers seem up to me

vague raven
digital osprey
#

ah fair

cosmic ermine
#

Is there a general way to overwrite all TimedActions instead of overwriting them one by one?

#

Actually never mind since I'll choose which ones are modified but just in-case I need it in the future.

gleaming sorrel
#

I would like to inform anyone here
Not to subscribe to any of the things posted until I can reclaim the account

#

Consider it compromised

bright fog
#

I don't think viruses can go through steam workshop

#

Would be a minefield if it wasn't protected

#

At least one good news I guess ?

gleaming sorrel
#

At least there's that

#

I'm at least glad they can't infect others though my steam account

bright fog
#

Imagine how hell it would be lmao

gleaming sorrel
#

Then my account would be nuked

bright fog
#

well let's hope that doesn't happen at least

gleaming sorrel
#

That link was so obviously a trap
That is probably one of the stupidest things I have ever done

bright fog
#

tbf happens to anyone

mystic vessel
#

Hi everyone, good evening, I needed a little help, I wanted to extract the image of this specific saw tile.

but I didn't find out how, I don't know if it's a different method.
but I even tried to search in the tile program, but supposedly where this saw was supposed to be located is invisible
(As in the second example image)

bright fog
gleaming sorrel
nimble yarrow
#

my modules are only working one way.

Snippet from JournalReminder.lua

JournalReminder = {}
local PlayerTimer = require ("PlayerTimer")
print("PlayerTimer should be a table... " .. type(PlayerTimer)) --prints "table"

PlayerTimer.DoSomethingImportant() -- works!! o snap

return JournalReminder

Snippet from PlayerTimer.lua

PlayerTimer = {}
local JournalReminder = require ("JournalReminder")
print("JournalReminder should be a table... " .. type(JournalReminder)) --prints "nil"

JournalReminder.MyFunction() --does not work
--ERROR:    attempted index: MyFunction of non-table: null
--(This error was expected, because the type, as seen above, is not 'table')

return PlayerTimer

writing this out to try and rubber duck the answer

bronze yoke
#

you don't have both of these requires at the same time right? you can't have circular dependencies

#

(also keep in mind that module tables should be local in their own file too or there isn't much point to using them)

outer crypt
#

If you have more than one radio, is there a way to send information to a server and back so that the exact one you are working on is the one you sent? Maybe a unique key shared by clients and server?

nimble yarrow
#

I'm confusing myself, let me double check the snippets above to see if I properly wrote them out here

outer crypt
nimble yarrow
#

@bronze yoke ok I made sure the snippet above properly reflects my 2 lua files, I had some labels reversed when I first posted the question to discord.

...are you saying the two files cannot require each other?
JournalReminder.lua can properly call the 'start timer' function on PlayerTimer.lua, nice!!
PlayerTimer currently has no way of telling JournalReminder that the timer has finished.
(unless I just make a global function, then we're good to go)

If PlayerTimer is not allowed to require JournalReminder as a module...
that would be strange, wouldn't it?

"module tables should be local in their own file too or there isn't much point to using them"
I don't actually understand this sentence at all, but I'm trying to do the right thing, and only use local functions

bronze yoke
#

if file a requires file b, then file b must load before file a does (or more specifically before the require function can return)

#

if file a requires file b, and b requires a, both of them need to load before each other

nimble yarrow
#

I see, that's too bad.
(so instead of loading files alphabetically, it forces the 'required' lua files to go first)?

bronze yoke
#

yeah, that's right

bronze yoke
#

the idea is that by using return/require, you never actually have to touch the global namespace at all, and can still communicate between files

nimble yarrow
#

man, the limitations of lua are really frustrating.
...and if I'm not mistaken, functions need to be written from the bottom of the document, moving upwards,

Can you think of a way for my timer to signal that it has finished?

solution 1: Just put all code into a single lua document
solution 2: use a global function, so that the timer, when finished, can notify the main script
solution 3: ??

cosmic ermine
#

What are the benefits of declaring your own variables in ModData?

bronze yoke
#

they're attached to the object and they save and load with the save file

cosmic ermine
#

Ah, I see.

cosmic ermine
#

Though you can declare functions below and use it above, I don't recommend it.

bronze yoke
#

whenever you have a circular dependency it usually means either you need to split shared code into a third module, the two modules shouldn't be separate to begin with, or your code is tangled needlessly

nimble yarrow
#

I mean.. I could be wrong, but I'm pretty sure lua doesn't know "what is under it" at any given time.

local function myFunction()
  AddOnePlusOne()
end

local function AddOnePlusOne()
  print ("1 + 1 = 2")
end

I feel like this snippet would throw an error. lua doesn't know what AddOnePlusOne() is, because like... the file hasn't been read that far yet.

maybe im wrong tho. I know so very little about lua

bronze yoke
#

i'm not sure exactly what your modules are doing but if you want a timer that calls a function when it ends, you could pass a callback function upon starting the timer

cosmic ermine
bronze yoke
cosmic ermine
#

It works with methods but please don't do it with functions.

bronze yoke
#

local variables (including functions) are compiled as part of the code itself, so it needs to exist when it's being compiled, whereas globals/table accesses (even in local tables) are looked up every time that code runs, so as long as the thing is there by the time the code runs it's fine

nimble yarrow
#

the code isn't tangled, and It just seems cleaner to separate out the timer logic. I'll look into what it is, and how to use a callback function, that sounds promising, maybe

bronze yoke
#

you basically just pass a function reference to the timer, and then when the timer ends it calls that function

cosmic ermine
nimble yarrow
#

or, wait, so when I call FunctionB, I can leave a reference to FunctionA somehow. Actually I think this makes sense

bronze yoke
#
-- no idea what the structure of this module actually is, i'm guessing you keep active timers in a table or something? but this is a simplified example
PlayerTimer.callback = nil
function PlayerTimer.startTimer(time, callback)
    PlayerTimer.callback = callback
    -- etc
end

function PlayerTimer.timerFinished()
    -- you can pass some arguments here too if you want
    PlayerTimer.callback()
end

-- in the journal file
PlayerTimer.startTimer(5, JournalReminder.onTimerFinished)
#

remember that functions are just like any other variable

#

you can pass them around and do whatever you want with them

cosmic ermine
#

What is GameTime:getMultiplier()?

I've only used getGameTime():getGameTimeMinutesStamp()

bronze yoke
#

it's a time delta

cosmic ermine
#

It takes the game speed into account?

bronze yoke
nova socket
#

de fuck

#

who pinged me?

#

oh that was probably one of those everyone abusers..

gleaming sorrel
#

I got my account back
Woo

#

I'll do everything now to make sure it stays that way

slow graniteBOT
#
ppazzi has been warned

Reason: Bad word usage

cosmic ermine
open drum
#

Help please

#

Could anyone tell me why the "player" variable at line 40

#

produce error

#

because it's considered as nil??

#

if i change that player into getPlayer()

#

it works fine

gleaming sorrel
cosmic ermine
open drum
#

hmm when i checked

cosmic ermine
#

not an actual IsoPlayer.

open drum
#

it shows that

#

isoObject

gleaming sorrel
#

I want to download an anti-virus but even though I'm fairly certain the website is legit
I'm afraid to download anything right now

open drum
#

is considered as player

#

i don't know why

#

why in checkZombie(player,isoObject) the player info is passed to isoObject?

gleaming sorrel
#

Why is it
Isoplayer
And not
Isaplayer

open drum
#

i guess it's short term of Indie stone object player

cosmic ermine
#

Will this work?

open drum
#

i see why not

#

dont' see any problem

cosmic ermine
#

Yoo! It finally works!

#

stressFromWork was not updating yesterday.

open drum
#

well done

#

now help me

#

XD

#

why at function checkZombie

#

it won't recieve player argment??

#

i mean the parameter

#

it's only recieving isoObject argument info

#

into Checkzombie function parameter

granite glade
#

Can anyone help me understand where I'm going wrong with introducing the ground model for this weapon? When the lines that are marked with a "///" are introduced, only the ground version of the model will show up, but the held version will not. When the lines are removed, the standard model appears appropriately. Am I stupid?

open drum
#

in this method

#

it passes isoObject first then player next

#

so the function parameter need to be in the same order

#

function example(isoObject,player)

open drum
granite glade
cosmic ermine
#
function Workaholic.update()
    -- sources/zombie/characters/BodyDamage/BodyDamage.java
    local player = getPlayer()
    if player:HasTrait("Workaholic") then
        local playerModData = player:getModData()
        WorkaholicModData.setTimeSinceLastWork(playerModData, WorkaholicModData.getTimeSinceLastWork(playerModData) + 0.0001 * getGameTime():getMultiplier())
        if WorkaholicModData.getTimeSinceLastWork(playerModData) > 1 then
            local timeSinceLastWork = math.floor(WorkaholicModData.getTimeSinceLastWork(playerModData) / 10) + 1
            if timeSinceLastWork > 10 then
                timeSinceLastWork = 10
            end
            local stress = WorkaholicModData.getStressFromWork(playerModData) + ZomboidGlobals.StressFromBiteOrScratch / 8.0 * timeSinceLastWork * getGameTime():getMultiplier()
            WorkaholicModData.setStressFromWork(playerModData, stress)
        end
        print("stressFromWork: "..playerModData.stressFromWork)
        print("timeSinceLastWork: "..playerModData.timeSinceLastWork)
    end
end

Events.OnTick.Add(Workaholic.update)
```Guys, `stressFromWork` is not updating for some reason, it's so frustrating.
#
---@param modData table
---@param stress number
function WorkaholicModData.setStressFromWork(modData, stress)
    modData.stressFromWork = PZMath.clamp(stress, 0, WorkaholicModData.getMaxStressFromWork())
end
#

It's always 0.

cosmic ermine
cosmic ermine
#

It works when I restart the game and not just the Lua. WTF?

abstract cairn
#

I'm looking to make a function that's run on the server/has authority.

Anyone know anything/any leads on that? I cant seem to find much of anything..

cosmic ermine
#

Help, how do you properly overwrite a function or inject a code into a function?

#

My bad, I guess it was overwriting the vanilla file because the name of my file is the same with the vanilla one.

cosmic ermine
bright fog
cosmic ermine
#

Are there any other ways to save data without using ModData? The thing I'm doing is really inconsistent.

bright fog
cosmic ermine
#

It's like stress from Smoker trait.

bright fog
#

But the answer is yes you can store data with other ways, but making them persistent ? Not exactly

#

The only way to make data persistent is via moddata

#

What's your issue with it ?

cosmic ermine
#

It is really frustrating.

bright fog
#

wdym not being touched ? Are you sure you coded it to make you access it when you need ?

#

There's no such issues with moddata not responding or idk what

#

I'm using them alongside local data base that I need to reset every save launch

#

So persistent data base thx to moddata and non-persistent thx to local tables

cosmic ermine
#
local WorkaholicInit = {}


---@param playerIndex number
---@param player IsoPlayer
function WorkaholicInit.onCreatePlayer(playerIndex, player)
    if player:getModData().stressFromWork == nil then
        player:getModData().stressFromWork = 0
    end

    if player:getModData().timeSinceLastWork == nil then
        player:getModData().timeSinceLastWork = 0
    end
end


---@param player IsoPlayer
function WorkaholicInit.onPlayerUpdate(player)
    if player:getModData().stressFromWork == nil then
        player:getModData().stressFromWork = 0
    end

    if player:getModData().timeSinceLastWork == nil then
        player:getModData().timeSinceLastWork = 0
    end
end


Events.OnCreatePlayer.Add(WorkaholicInit.onCreatePlayer)
Events.OnPlayerUpdate.Add(WorkaholicInit.onPlayerUpdate)
```Here's the init code.
bright fog
#

Explain where's the issue, will be way easier for me

chrome egret
#

IsoObject has a getModData method. IsoGridSquare has getModdata and it makes me want to weep.

cosmic ermine
#

I have no idea what the issue is. Sometimes when I restart the game and load the save, it works perfectly fine, but then when I quit the save and go to the main menu and then back then it stops working.

bright fog
#

Did you use prints to check your moddata is not nil ?

cosmic ermine
#

Uhh, no.

#

Let me try.

bright fog
#

Go methodically to fix stuff

#

Try verifying your variables are the right one

cosmic ermine
#

I'm already checking them on initialization so I didn't see the point of doing a nil check.

bright fog
#

Yeah well you never know

open drum
#

Guys

#

is there a table or something

#

that saves all the items that exists in the game??

cosmic ermine
chrome egret
#

Is math.random totally unavailable in favor of ZombRand?

bright fog
bright fog
chrome egret
#

I can use ZombRand for one of my purposes which needs to generate round integers to pick items from a table, but I need a random number in the distribution of [0, 1)

#
local function getRandom(table)
    -- With input n, generates a random int from 1 to n inclusive
    return table[math.random(#table)]
end

local function getWeightedRandom(probabilityTable)
    -- [0, 1) generation range
    local p = math.random()
    local cumulativeProbability = 0
    for hitRegion, probability in pairs(probabilityTable) do
        cumulativeProbability = cumulativeProbability + probability
        if p <= cumulativeProbability then
            return hitRegion
        end
    end
end
bright fog
#

Yeah

chrome egret
#

Obnoxious, but will do it

bright fog
#
value = ZombRand(0,100)
value = value/100
cosmic ermine
#

I have no idea why it works sometimes.

bright fog
#

Do you have a github repo perhaps so I can easily read it ?

chrome egret
bright fog
#

Bcs rn reading through Discord code boxes is fucking me up

cosmic ermine
bright fog
#

No

#

My point was to allow me to read it in VScode or something like that

#

Reading it through pastebin will not help me read it lol

cosmic ermine
cosmic ermine
bright fog
#

did you check player:getModData().timeSinceLastWork actually has a value ?

#

That was my point with the prints