#mod_development

1 messages ยท Page 65 of 1

faint jewel
#

BROWSER!

drifting stump
#

When an item is created it copies from the script item and becomes its own instance

#

SKIZOT

ancient grail
faint jewel
#

aint seent you in a minute!

drifting stump
#

Currently just pop my head in once in a while

faint jewel
#

i see that.

fast galleon
#

random idea, add dungeons: can be done now, but will shine when we get basements

neon bronze
#

Shouldnt the basements be procedurally generated?

fast galleon
#

Yeah, and you get one that acts like dungeon with levels or something.

faint jewel
neon bronze
#

Make a DnD style mod for pz with procedurally generated basements

thorn cipher
neon bronze
#

doubt

#

Maybe When their code for the generation drops, it would be interesting to see how they do it

drifting stump
#

From what theyve said the basements themselves arent randomly generated but instead picked from a bunch of prefabs

drifting ore
#

Where are the professions defined?

vast nacelle
sour island
#

I could have sworn there was a video about map making tools that used prefab/generation -- specifically that you could make any sized house and assign the entire house or each room a profile and it would try to fit stuff inside with some logic. I can't find the video anytime I recall it.

bronze yoke
#

not at all :( you can replicate the behaviour with your own programming but when i had a look nothing at all about vanilla meta events was exposed to lua

sour island
#

Tbh there isn't really much to them

#

And I think Konijima made an API to replicate them

jagged ingot
#

You can use the sound emitters from fmod.

upper helm
#

i imagine this has long since been done, but has anybody looked into radio stations ie. editing transcripts, changing times, making their own?

jagged ingot
#

Taking a look at making a custom JSX factory for ISUI Lua API for PipeWrench.

#

Basically using React, but with PZ UI. x)

ancient grail
#

how do i create a table containing a pair like this?

VaultTileList = VaultTileList or {}
table.insert(VaultTileList, {close = 'krp_glytch3r_safe_0', open = 'krp_glytch3r_safe_1'})
print(VaultTileList[1][close])
        

i need to create a table that every entry holds 2 sprite datas close and open

#

this i snot working

#

i think im doing it wrong

#

or the only way to get is thru pairs loop?

#

ahh i think i need do do the pair twice for outer and inner table right

#
VaultTileList = {}
table.insert(VaultTileList, {close = 'krp_glytch3r_safe_0', open = 'krp_glytch3r_safe_1'})

        
for k, v in pairs(VaultTileList) do 
    print("k: ", k, "   v: ", v) 
    
        for i, s in pairs(v) do 
              print("i: ", i, "   s: ", s) 
        end
end
#

got it

drifting stump
#
print(VaultTileList[1]["close"])
drifting stump
#

pointless to iterate on the second when you already know it can only be open or close

ancient grail
#

ahhh nice thnx

drifting stump
#

ipairs is for iterating indexes aka 1,2,3,... and pairs is for key values

ancient grail
#
VaultTileList = {}
    table.insert(VaultTileList, {close = 'krp_glytch3r_safe_0', open = 'krp_glytch3r_safe_1'})
    for _,s in ipairs(VaultTileList) do 
            for k, v in pairs(s) do 
                print("k: ", k, "   v: ", v) 
            end
    end
ancient grail
#

without iterating?

drifting stump
#

what do you mean

#

if the table contains the value?

#

if you know itll always be for close you can do

VaultTileList[1]["close"] == "krp_glytch3r_safe_0"
#

other than this not really any way with your approach

ancient grail
#

wwoops needed to iterate after all.. but thnx i got it

#
for i = 1, #VaultTileList do 
    local closeTile = VaultTileList[i]["close"]
        if closeTile then
            return true
        end
end
astral dune
#

this will return true all the time, based on what you said the structure of the table would be, is that really what you want?

drifting stump
#

if you explain what youre trying to achieve we could help you have a better data structure

faint jewel
#

i'm trying to make a function in one ui fire from another ui,

#

it's fun.

ancient grail
#

i want to change the sprite

#

once i right click on the obj

#
function getOpenSprite(sprite)
            for i = 1, #VaultTileList do 
                local closeTile = VaultTileList[i]["close"]
                if closeTile == sprite then
                    return VaultTileList[i]["open"]
                end
            end
    end
    function checkCloseSprite(sprite)
        for i = 1, #VaultTileList do 
        local closeTile = VaultTileList[i]["close"]
            if not closeTile then
                return false
            end
        end
    end
#

do i need to create checker functions anyways heres the whole code atm

drifting stump
ancient grail
#
function TileNameContext.ContextMenu(player, context, objects, test)
-- if not (isDebugEnabled() or isAdmin()) then return  end
    local sq = nil

    for i,v in ipairs(objects) do
    
        local square = v:getSquare();
        
        if square and sq == nil then
            sq = square
        end

        if instanceof(v, "IsoObject") and checkCloseSprite(v) then
        --print(v:hasModData()) --check if has moddata
            context:addOption("Show tile name", v, (function() 
            local closeTile = v:getSprite():getName()
            print(closeTile)
                 getOpenSprite(closeTile)
            end))
                
        end
    end
end
Events.OnFillWorldObjectContextMenu.Add(TileNameContext.ContextMenu);
#

this is working for now

#

im just asking if i need to simplify ๐Ÿ™‚ i havent added the change sprite

jagged ingot
faint jewel
#

well, my main otr ui has a function to generate jobs based on the location you opened the ui from. the problem is, it wont generate for your CURRENT town on the first try, it will generate from the last one until you tell it to generate again.

#

if there was a "onOpenUI()" i'd be set.

astral dune
#

I'm ok with walls of code, as long as they're formatted, this is a programming channel

drifting stump
#

not sure since youre using that api but should be quite trivial

#

can you send me the code for it

faint jewel
#

me?

drifting stump
#

aye

jagged ingot
#

Make sure it'd minified Lua code.

drifting stump
astral dune
ancient grail
#

yey it works

#

now i need to do the reverse and close it lol

drifting stump
#

why more?

ancient grail
#

imean to the table

drifting stump
#

yes but why more

astral dune
#

there are more open and closed pairs

#

baffled at how this works, did you change the code after you posted it?

drifting stump
#

elaborate a bit more

ancient grail
#

yes

#

a biut]

#

jus tthe sprite

astral dune
#

looks like he wants to open/close safes by swapping their textures, safes can face different ways so they have different textures

ancient grail
#
function TileNameContext.ContextMenu(player, context, objects, test)
    local sq = nil
    for i,v in ipairs(objects) do    
        local square = v:getSquare();
        
        if square and sq == nil then
            sq = square
        end

        if instanceof(v, "IsoObject") and checkCloseSprite(v) then
            context:addOption("Show tile name", v, (function() 
            local closeTile = v:getSprite():getName()
            print(closeTile)
            local openSprite = getOpenSprite(closeTile)
                v:setSprite(openSprite)
                v:getSprite():setName(openSprite)
                v:transmitUpdatedSpriteToServer();
                v:transmitUpdatedSpriteToClients();
            end))
                
        end
    end
end
Events.OnFillWorldObjectContextMenu.Add(TileNameContext.ContextMenu);
drifting stump
astral dune
#

is your checkCloseSprite function the same as you posted, there is no way that works?

ancient grail
#

it works its not returning error and when i right click it ands a context menu and when i click that menu it changes the sprite apearance

astral dune
#

but it just returns false or nil all the time? that if statement should never fire

ancient grail
#

ow sorry i added return true

#
function checkCloseSprite(sprite)
        for i = 1, #VaultTileList do 
        local closeTile = VaultTileList[i]["close"]
            if not closeTile then
                return false
            end
        end
        return true
    end
#

when you mentioned it

#

๐Ÿ™

#

even i f i change its sprite its still the same isobject right?

astral dune
#

ok, so now checkCloseSprite returns false if you have an entry with no close, or true otherwise, so its probably always returning true

ancient grail
#

how do i hide the contents? when its close

#

no it says if not

astral dune
#

yes, if not closeTile will be true if VaultTileList[i].close doesn't exist or contains false, in which case your function will return false. Any other situation will return true

weak sierra
#

i know this isn't strictly modding content, but i feel this would be heavily appreciated by many people here, this little meme:

#

PZ is a confusing mess sometimes but we love it

astral dune
#

to make things easier on yourself, and to remove the need for iterating, I would do something like this:

local VaultLookup = {}

local function invertTable(tbl)
  local output = {}
  for k,v in pairs(tbl) do
    output[v] = k
  end
  return output
end  

local closed = {
["safe_closed_N"] = "safe_opened_N",
["safe_closed_S"] = "safe_opened_S",
["safe_closed_E"] = "safe_opened_E",
["safe_closed_W"] = "safe_opened_W"}
local opened = invertTable(closed)

function VaultLookup.checkClosedSprite(sprite)
--returns true or false instead of a texture name or nil, could just use getOpenedSprite
  return VaultLookup.getOpenedSprite(sprite) and true or false 
end
function VaultLookup.checkOpenedSprite(sprite)
  return VaultLookup.getClosedSprite(sprite) and true or false
end
function VaultLookup.getOpenedSprite(closedSprite)
  return closed[closedSprite]
end
function VaultLookup.getClosedSprite(openedSprite)
  return opened[openedSprite]
end
function VaultLookup.addSprites(closedSprite, openedSprite)
  if not (closedSprite and openedSprite) then return end
  closed[closedSprite] = openedSprite
  opened[openedSprite] = closedSprite
end

return VaultLookup

or something like that

#

@ancient grail

#

obviously you'd have to put real texture names in there

quasi kernel
#

Dictionary quick indexes my beloved

astral dune
#

lua is so fast with string comparisons and table access its the only way to go, lol

ancient grail
#

Aslong as the index matches is that how u did it?

bronze yoke
#

they aren't connected, they don't need to be

astral dune
#

yes, all they do is relate closed sprites to open sprites in one table, and vice versa in the other

#

I assumed you'd want to get closed sprites from open ones even though you haven't shown any code doing that yet

#

by using the names of the textures as keys, you can find them instantaneously, and also use them to get the other texture if you use those as values

#

the checkCloseSprite function I wrote explicitly returns a true or false, but you could use if getOpenSprite(sprite) then in the same places as if checkCloseSprite(sprite) then thanks to how lua handles truth

#

as for constructing the tables, if you have lots and lots of sprites you may want to find a way to automate it, but if there is only a couple dozen or so it should be fairly easy to do by hand. You could even just do one by hand and then let a function create the other one by inverting it

#

like this

function invertTable(tbl)
  local output = {}
  for k,v in pairs(tbl) do
    output[v] = k
  end
  return output
end  
ancient grail
#

To get the other part of pair

ruby urchin
#

Does somebody know some event when a player leaves a game?

bronze yoke
#

OnDisconnect

ruby urchin
bronze yoke
#

probably not

thick karma
#

OnDisconnect looks like the only hope and I'm not any more optimistic than albion about it, although it might work

#

You could hook the function that quits the game in the Options menu but I think Alt + F4 and crashing would bypass @ruby urchin

bronze yoke
#

alt+f4 and crashing will bypass most things

#

ondisconnect is a client event

jagged ingot
#

Make a periodic tick function to check?

thick karma
#

Out of curiosity, what are you hoping to do when the client quits the game? @ruby urchin

astral dune
#

depends on what you're doing of course, but you could check on load if whatever you meant to do on exit was successful

thick karma
#

Could use ModData to track whether the close function fired when the player last left the game (not sure if this would allow you to capture what you're trying to capture)

ruby urchin
#

OnSave works to SP apparently

thick karma
#

Are entities a technical object in this game or are you using that word literally?

#

What kind of entity's info are you trying to save?

bronze yoke
#

oh if it doesn't matter if the player didn't disconnect you can just do that

thick karma
#

Idk "entities" in this game

#

Yeah game uses OnSave when you quit, that would definitely store what you wanted to store, it would just store it frequently, so if the process of saving is long enough to slow down the game, hooking the quit function directly might be better.

#

(I'm still unclear how much info / how many entities we're discussing)

ruby urchin
#

is about the mod about dogs that I'm working on, I need to save his info to make persistent on a game

thick karma
#

1 dog?

#

How many fields?

ruby urchin
#

Yeah, dont worry, just basic info

thick karma
#

Like 20-30 max? Fewer?

ruby urchin
#

coords, id, hungry and things like that

#

10 max

thick karma
#

Oh yeah you could routinely OnSave that I would expect no issues

ruby urchin
thick karma
#

nice to know

#

noted

bronze yoke
#

i meant that if your code doesn't actually hinge on the player leaving the game, you can use onsave

thick karma
#

Sounds like it doesn't @bronze yoke

bronze yoke
#

i only suggested ondisconnect because i thought that was an important part of it

jagged ingot
#

Doesn't some code execute, even on Alt+F4?

#

Hook into it and sendClientCommand?

thick karma
#

In servers with PvP, is there a way to opt out (outside of roleplay)?

#

Or can anyone with PvP on kill everyone?

modern dune
#

Is there any event for when the player first picks up an item?

jagged ingot
#

But maybe I'm thinking Minecraft logic.

astral dune
#

there is an event when a player takes damage, and it tells you what kind of damage it is, but I don't think it will tell you who did it if its a zombie or player. Could be wrong though I haven't looked at it in a bit

modern dune
#

is there an event for when the player goes to sleep? i cant find anything on the lua events page

weak sierra
thick karma
weak sierra
#

that's one of the main reasons my server is gated

#

'cuz anyone can come in and start killing random people with no rp

thick karma
#

For sure

#

Anyone know the function off the top that makes your player enter hostile mode?

#

/ checks whether you are in hostile mode actually

#

(really I need the latter)

modern dune
#

does the moodle modifier not work unless you do something first?

#

im trying to change my fatigue to max but the slider bar wont move

#

oh nvm god mode stops you from modifying some of them

#

im trying to figure out how to detect when the player goes to sleep

#

there is no sleep-based event on the lua events page that i can find

#

IsoPlayer has a public boolean called "Asleep" and a getter called ".isAsleep()"

fast galleon
#

can somebody remind me how to set a float, trying to remove my weird comparison of if multiplier - xmultiplier > 1e-7 then

modern dune
#

So i tried checking those every 10 minutes... but they only check positive when the game loads, strangely enough

#

so how on earth can you detect when a player sleeps

fast galleon
modern dune
#

oh wait a minute

#

aaaaaaaaaaaaaaaa fucking lua!!!!!!!!!!!!!

#

what is with obj.method() and obj:method() anyway?

fast galleon
#

here it's kahlua
if it's static you do class.method, otherwise you do obj:method

modern dune
#

ok

#

hmm it seems that the game always thinks the player "wakes up" when they get created

#

oh no, im just an idiot

#

any idea on how to get the character's first and last name?

#

getForname() and getSurname() always seem to return "Bob" and "Smith"

#

even though the character has a different name

ancient grail
#

getPlayer():getDescriptor():getForename()
getPlayer():getDescriptor():getSurname()

#

getPlayer():getUsername()
getPlayer():getDisplayName()

#

@modern dune

modern dune
#

boff i would have never thought of that

#

thanks

ancient grail
#

๐Ÿซก

ancient grail
modern dune
#

like the source lua file? where can i find that?

ancient grail
#

Wow i just noticed your katana @bronze yoke
Youre a specialist now

ancient grail
wet gorge
#

Looking for the code that is responsible for PvP zones when a player enters one etc. Found the code for adding zones here: media\lua\client\ISUI\AdminPanel\ISPvpZonePanel.lua, although cannot find the code that handles if a player enters the zone.

#

Searched all of media for "pvp" in every file but could not find anything remotely close to what I'm looking for.

jagged ingot
#

I'm having an "Oh God.." moment right now.

echo sky
#

hey guys, got a question for you. Making a compatibility patch for something, I've done the actual patching bit, just trying to work out the best way to implement it. basically making the cereals added by More Cereals to recognise milks added by other mods. Now, in my existing save, if I make the one file I have in the scripts folder the same name as his, all the cereals I had in my invtory/containers near me disappear, and I'd need to find new ones. Is there a way to avoid doing this so its save game friendly?

jagged ingot
#

Starring at my code and going "I could implement CSS and JSX for reactive Project Zomboid UI."

#

I... I might want to do that.

thick karma
#

Is there any easy way to make an ISTextEntryBox submit on Enter and cancel on Escape?

#

Or is keyboard utterly locked while you're focused on it?

jagged ingot
#

I think that lock is in UIManager, right?

thick karma
#

Idk

jagged ingot
#

There's a focus check for keyboard stuff IIRC.

hollow delta
#

Does anyone else think that the UI to add mods is very uncomfortable?

astral dune
#

thats the one, fixes everything. My only gripe is there is no link to the workshop pages in the server version of the mod manager

jagged ingot
#

lol.

bronze yoke
#

and i wish server and singleplayer presets were shared

jagged ingot
#

AFK writing my own Lua UI alternative.

bronze yoke
#

if i set mods for my server, i then i have to go enable all my mods to change the sandbox options

hollow delta
thick karma
#

(or gamepads ๐Ÿ˜ญ)

hollow delta
#

Thank god

#

I love the community

thick karma
#

Is there anywhere in vanilla where pressing "enter" submits some text?

#

Oh the chat

#

Duh

#

Let me see how chat does it

astral dune
#

since I've gotten a few DM's now about how getOpenedSprite(sprite) and true or false works, I figure I'll do a mini tutorial right here and meow

#

Lua's and and or operators allow you to use operands other than the booleans true and false.
The rules for it are very simple, nil and false are false, and everything else is true. Everything, including 0, -1, {} and the string "false"

Lua's and and or are also short-circuiting. What this means is that it will only evaluate the minimum amount of operands required (evaluated left to right) to find the solution.
true or waitOneHour()
false and waitOneHour()
both evaluate immediately instead of an hour from now, because the first operand is all that's needed

The main peculiarity of Lua's boolean comparators is that they don't evaluate to true or false, but instead return the last operand they had to look at
0 or x => 0
nil or x => x
nil and x => nil
0 and x => x

#

so, to go back to the question, getOpenedSprite(sprite) and true or false is meant to convert the returned value from getOpenedSprite(sprite) to an explicit boolean value
getOpenedSprite(sprite) returns either a string, or nil, which would then evaluate thusly

"sprite" and true or false => true or false => true
nil and true or false => nil or false => false
thank you for coming to my Tedx talk

jagged ingot
#

Will be useful for linking people when asked.

vast nacelle
astral dune
#

I hearby release that tutorial under MIT license if they want to set something like that up, lmao

jagged ingot
#

Load a config lua file in the cache dir and then load the right code based on that?

thick karma
astral dune
#

sure, but the point was to get explicit true or false.

getOpenedSprite(sprite)

would work just as well, don't need the and true either

thick karma
#

Right

#

Okay I see now

#

You don't want the string for some reason

astral dune
#

sometimes you want actual booleans, especially if you're going to be providing the output to a java object that expects it, for example

thick karma
#

Got it makes sense now I didn't understand you needed the boolean for some reason outside of Lua logic

astral dune
#

I don't think he needed it for that in this particular instance, but if I give someone a code snippet I figure its good form to make it work in the majority of cases. So functions that start with things like check or is I typically convert to booleans to be safe

bronze yoke
#

or false is still redundant, getOpenedSprite(sprite) and true returns true or false to begin with

jagged ingot
#

mmm.. love that !! syntax.

astral dune
#

nope, nil and true evaluates to nil

bronze yoke
#

this stupid language

astral dune
#

lol

jagged ingot
wet gorge
#

The arrays trigger me in lua.

astral dune
#

honestly once you have a handle on it you can do neat stuff, I don't mind lua at all

jagged ingot
bronze yoke
jagged ingot
#

Lua is fine but not meant to be used at this scale.

astral dune
#

not at all, you can do stuff in lua very quickly and elegantly that you can't do in more restrictive languages, there is no handicap here

#

but ya, there are some challenges in modding in a different language than the main game for sure

jagged ingot
#

Scalability is my biggest concern in our environment here.

#

That's my main push for using something like Typescript for say UI models.

astral dune
#

๐Ÿคทโ€โ™‚๏ธ thats just a different layer of abstraction on the same thing, doesn't really gain anything

jagged ingot
#

Lua works just fine.. until you can't remember your own design 100% and change something accidentally or reuse a variable name and cause unknown collisions when performing certain actions down the road.

jagged ingot
#

Doing Lua by itself is great for like 95% of the work here if I'm only considering the issue of scalability. ๐Ÿ™‚

astral dune
#

can you give an example of a scalability issue

jagged ingot
#

Sure. ISUI.

astral dune
#

its written fairly OO compared to most of it, seems like the least offender in that category. It is a little jank though

jagged ingot
#

Each subsequent derive of say the ISUIElement class hosts (In the current code), some overlapping, reused fields that do different things. There's also the issue of deprecated code that isn't called that could otherwise be pruned using strict interfaces.

#

A lot of it is old mouse event functions.

bronze yoke
#

the way i get around this is by not writing ui because i hate it

astral dune
#

lol

jagged ingot
#

Also, clarity on things like what Joypad objects actually store and what they do.

#

That's a huge one for me.

astral dune
#

I have the same response to UI in pretty much any game I've ever modded, its always a fustercluck

#

docs are definitely lacking. Until they added actual variable names to the method signatures on the javadoc it was less than useless. now its just useless

jagged ingot
#

I'm not going to tell you to change your ways or what not. I was serious enough to invest passively over 8 months to try to fix this issue for when I develop mods for PZ.

astral dune
#

some comments in the lua wouldn't hurt neither

bronze yoke
#

i think the javadoc is pretty useful

astral dune
#

if you don't have the code on hand, sure

bronze yoke
#

it's just one part of a greater process

jagged ingot
astral dune
#

I use intellij so method signatures, the only thing the javadoc provides, autofill

jagged ingot
#

I'm also for third-party documentation.. which I still need to smooth some edges on my tool for my works.

bronze yoke
#

the javadoc is still far more searchable

jagged ingot
#

This topic of mod discussion is actually pretty much what I obsess over so I thought I'd give you my full take on it.

#

๐Ÿ™‚

#

Oh and I want this stuff too. This removes countless time doing lookups.

astral dune
#

ya, emmylua does that for my own code, since I write the annotations, but only has the same kinda basic signatures the javadocs have otherwise, for the lua stuff

jagged ingot
#

I'll never get used to the Lua environment since by default it doesn't have error prompts prior to running code.

#

In a way that's less process which is good for what Lua is meant to do: Be a small-scale script solution for C / everything else that hooks into Lua or emulates Lua.

astral dune
#

I simply just don't make mistakes

bronze yoke
#

LOL

fair grove
#

How difficult is it to get into making mods? No experience here, just know some coding, and I was wondering how difficult it would be to make a mod that added a disassemble action for corpses that would generate a new item, e.g. "bones", and add new recipes like "cooking bones into glue" and "crafting glue and ripped sheets into duct tape". Does this mod already exist? If not, are there any close examples I could work off of?

astral dune
#

there is a zombie to glue mod, and a different mod that does bones to glue, but crafting duct tape I think only exists as a profession perk atm

#

none of those things are terribly hard to implement, as pz mods go

fair grove
#

Awesome, thank you, are those mods available on github or something so I could look at the code? Or could I just open up the mod if I have it from steam workshop? Guess I'll go look into it haha

astral dune
#

all the mods on the workshop are lua based, which is not compiled and is human readable. I think there is a tool somewhere to pull down mods without steam itself, but otherwise you can just find the mods on the workshop, subscribe to them, then open them from your workshop folder

jagged ingot
#

Oh and if you want to code mods with Typescript, that's an option as well.

fair grove
#

Excellent, thank you guys!

jagged ingot
#

No problem and good luck. Feel free to ask questions in here.

fair grove
#

Gotcha

jagged ingot
#

Going AFK for the day. Cya guys. Fun convos.

heady sparrow
#

Bad hair day?!

Was using the Improved Hair Menu mod and suddenly scissors weren't registering. Thought it might be the mod so turned it off. Still can't cut hair. Can anyone tell me if this is a bug in game or a result of the mod?

ruby urchin
#

but not on crash

thick karma
#

Oh wow v cool! Thanks for the info

#

I actually... Did not expect that. Haha working was unexpected.

bronze yoke
#

alt-f4 doesn't force programs to close like a lot of people assume

#

i imagine if you use super-f4 it won't be able to handle that

thick karma
#

I am actually aware it's not forceful because I have grumpily encountered games that did not properly follow Windows protocol for what Alt F4 is supposed to do even a little damn bit. ๐Ÿ˜พ

#

But I was suspicious about things being saved right on Alt F4 in Zomboid.

astral dune
#

IIRC it is a forced close by default, but as a dev you can choose to handle it yourself. Been a while since I've written a window handler so I'm not sure if I'm misremembering

#

java also just does whatever it likes, of course

viral karma
#

I've been working on an ISUI abstraction that makes UI a bit more intuitive.
Adds some features like object grouping, grid views, and a couple other goodies, in addition to trying to document and clean up a lot of redundant functions.

Modeling it a bit after a GTK/QT4 workflow, and playing around with half-baked damage tracking to prevent re-rendering every tick unnecessarily.

#

Also on topic of documentation, I spent an hour earlier today writing a working markdown output template for ldoc.
The plan is to iterate over all the media/lua files, generate whatever documentation is available, including modules, functions, params, and potential returns, and having some sort of linkage between them.
This will kind of build on top of that event list I generated yesterday, linking events to lua docs, and providing searching for the lua docs

thick karma
viral karma
fallen pendant
#

im hosting and mods dont seem to apply to the server

#

?

viral karma
thick karma
#

By sending input to a window via textbox, I mean call the submit function of a panel based on hitting enter in the box WITHOUT knowing the exact instance variable that will be used to encapsulate it.

#

In vanilla ISChat you'll see what I mean. When you hit enter it calls ISChat:onCommandEntered which might lead you to believe that it can simply access its own onCommandEntered function through a self call, but nay (!), the onCommandEntered function of ISChat has to access ISChat.instance instead of self because the necessary info doesn't get passed to its own function.

#

Meaning if you have four separate instances of some ISChat equivalent... No obv way to resolve which when you land in their function

#

My workaround is to just check which instance is visible and operate on that but it is nontrivial and annoying lol not smooth and silky

viral karma
#

Ah, I see what you mean. I'll play with a joypad when I'm closer to buttoning up the ui framework.
I'll keep the textbox onCommandEntered event in mind when I'm going through my next phase of the ui stuff. First phase is just a QOL class, so instead of doing o = ISPanelJoypad:new(...) directly you do o = CkyUI:new(ISPanelJoypad, ...), which will override some of the functions of the root class, exposing new functionality that still calls the base class functions as needed.
First focusing on ease of use and documentation, then fixing bugs/issues (like the onCommandEntered event), then rendering/tick performance, then eventually decrufting, better events, and a few other things.
My aim is to at least get the first part (qol + docs) done sometime this week, open source it with a todo/issue list, and eventually work on the other features. That way if anyone wants to contribute, they can help out.

limber oar
#

Is there a way to prevent random underwear from spawning in addition to an outfit defined in clothing.xml? Something like <m_Pants>false</m_Pants> but for underwear. The swimsuits are defined as underwear, but so are separate random UnderwearTop and UnderwearBottom clothing items, so I'm getting briefs and bras over bikinis and swimsuits...

viral karma
#

This snippet got my gears spinning for some sort of in-game unit testing framework.
I might draft up a document on a design for some in-game testing framework that could be used for regression testing, and potential mod compatibility checking/testing.
media/lua/tests/{client,server,shared}/... to define a testing environment an actions (eg. spawn player, add item to ground nearby, player picks up item, check if item is in inventory) with a media/scripts/tests/{scenario}.txt that defines some environment (eg. coordinates, modids, initial game state, sandbox seed/options, etc)

thick karma
viral karma
limber oar
dull moss
#

So I know that if files named the same in different mods, during game load one of them will overwrite another. Is it the case for stuff like sandbox-options.txt and translations? Cuz I'm looking at my console atm and see a lot of overwrites

bronze yoke
#

no

dull moss
#

is that a special case?

bronze yoke
#

the translator runs through every mod directory manually

#

the same must be true of sandbox-options.txt and perks.txt, and maybe some others

dull moss
#

I see

sour island
#

Kind of concerning I have to ask this once and a while lol

wet sandal
#

"I'm running 878 mods and your mod broke my save, downvote"

opal rivet
#

You did an amazing job in a way

viral karma
opal rivet
#

Don't let these peeps bother you

wet sandal
#

On my first mod, Left Click Redux, someone was complaining my mod broke their ability to attack.

#

They had the weapon in their left hand.

bronze yoke
sour island
#

It doesnt bother me lol, I just feel bad* for the guy

#

whoops left off the end cause my doorbell rang

wet sandal
#

I get that, I like to do what I can to help users. It bothered me a bit early in my modding career though.

#

Definitely care a lot less now, too many users to satisfy them all.

sour island
#

Yeah, Ive taken to conditioning and training commenters.

#

a little bit of preparation can mitigate alot of comments

#

Tempted to take it all on github and have issues templated

#

But then you'll get people who don't bother at all

wet sandal
#

Yea for real, I've gotten in the habit of downloading the top mods for the area i'm modding and ensuring compatibility in advance

sour island
#

oh, I just meant telling people how to report errors

wet sandal
#

Ah lol

sour island
#

trying to compat mods is kind of hard to predict

#

your time is probably better off just enjoying the modding and catching issues as they come in

wet sandal
#

I have 1 rule, I don't know your mod exists. But I'll go the long way through the code if I have too to have no impact on the end result as far as other mods can tell

viral karma
#

Main issue with github is having to make Yet Another Account โ„ข
I've learned from working open-source for a long time that it's best to work at your own pace. If someone wants to prioritize a bug fix, they can submit a patch or pay for the work. Burnout sucks

bronze yoke
#

i tend to only go as far as 'if other mods are written with compatibility in mind, it will be compatible with this', and only add specific mod compatibility when someone complains (and if it seems worth my time)

wet sandal
#

Most of my mods so far are QoL stuff, I don't mind doing some work on being highly compatible.

bronze yoke
#

some modders will write their mods in weird ways that i couldn't possibly account for, and it's just not really my problem...

wet sandal
#

Doesn't mean i'm not swearing at the monitor when someone raw bulldozes a function though.

bronze yoke
#

omg yeah, my literacy mod wasn't working with CDDA reading because it straight up removes multiple functions from the reading timed action

sour island
#

there's a few reading mods that do that for some reason

#

I've taken to forcing those mods to load first using require

#

handling timed actions can be daunting for first time modders I imagine

bronze yoke
#

that timed action seems to be very popular for modding, so naturally it has a lot of mods that will break things

sour island
#

I think reading is one of those game mechanics that there isn't really a way around not "sucking"

#

people get impatient and want it done faster/differently lol

#

Idk if there's even a better way to do it tbh

bronze yoke
#

yeah, even i don't think my mod really makes it much better as a part of the game as a whole

#

'sit still for a long period of time so that grinding becomes viable' is hard for me to justify

sour island
#

One of those lesser evils tbh

#

I've definitely seen worse mechanics

#

QTE arrows to ensure people aren't AFK on some games

wet sandal
#

lmao, a mod to turn reading into an endless QTE that lets you read as fast as you can play DDR on your keyboard

bronze yoke
#

LOOL

wet sandal
#

Or even worse, "mash R to read"

#

1 R = 1 page

viral karma
#

I kinda wish skills had more of a sort of logarithmic increase to them. Like, instead of integer level multipliers, they could scale, from 1->2 - so it would be more like every 10 steps 1, 1, 1.1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.7, 1.9, 2.0.
Level-locked items (like construction) could be altered similar to maintenance, so the higher level the more chance of successfully constructing in addition to having stronger construction.

wet sandal
#

Whats the proper require for a script located at lua/server/FILENAME

bronze yoke
#

require 'filename'

wet sandal
#

Keep running into it not existing yet

bronze yoke
#

not existing yet? that's half of what require is for

wet sandal
#

Hmm, maybe I just need to wait for game load

#

I doubt the mod i testing now will ever release, but im disabling basically all the normal game functions

sour island
#

The format should be after server/client/shared AND be in the same directory

#

It gets weirder regarding shared

wet sandal
#

Ah, the back half of the and is probably my issue

sour island
#

Yeah, the game is loaded in segments afaik, depending on SP or MP the setup looks/works differently

wet sandal
#

Yep that was it

#

I wasn't taking this particularly seriously so I went slack on the folders

#

Didn't realize it was literally required

sour island
#

I forget which folder is loaded first

#

But you could just get lucky and not need a require

bronze yoke
#

shared -> client -> server, i think

sour island
#

Sounds about right

astral dune
#

ya, thats right

#

not being able to require across folders has bit me a few times, but usually its easy to account for

bronze yoke
#

you can always require from shared as far as i can tell

limber oar
astral dune
#

as in require a file from the shared folder? ya, thats probably because it is loaded first

sour island
#

Would be careful about it in MP

#

gets a bit less predictable

limber oar
#

Same logic has gotta apply for the Strip Club zombies w/ bunnysuits, etc. -- those are treated as "Underwear" too, but as far as I can tell they aren't being overridden by Top/Bottom underwear items.

rancid panther
#

is there a language i can add to my mod to make it translate to english by default if it is missing a translation

bronze yoke
#

that's the default behaviour

rancid panther
#

oh okay. thanks

bronze yoke
deep hedge
#

Anybody got a working modpack I can use?

bronze yoke
#

i messed around with this for a bit and i can't find any code about it, and spawning swimmers with the horde manager had many of them wearing underwear

tribal osprey
#

hey all this might be a little bit of a dumb question but uhm. how does one add a context menu option to fire off a timed action? i tried to figure it out on my own but i've hit a brick wall and i'm not sure why context:addOption's returning a null type index ...

bronze yoke
tribal osprey
#

yeah just gotta redact some stuff gimme a sec

limber oar
# bronze yoke are you sure the swimmer outfit does deal with it?

Hmm. It's possible I just somehow got really "lucky" with my spawn testing of the swimmers; I didn't try very hard since I assumed they worked. Makes me feel better if they don't handle it...I still wanna fix it, but at least I know I'm not missing some obvious solution.

tribal osprey
#
local function myactionaction(playerObj)
    ISTimedActionQueue.add(ISmyaction:new(playerObj))
end

local function myactioncontextmenu(player, context)
    local playerObj = getSpecificPlayer(player)
    option = context:addOption(getText("UI_myaction"), playerObj, myactionaction(playerObj));


end
Events.OnFillWorldObjectContextMenu.Add(LMMain.myactioncontextmenu);```
#

i'm probably missing something obv

bronze yoke
#

try

local function myactionaction(playerObj)
    ISTimedActionQueue.add(ISmyaction:new(playerObj))
end

local function myactioncontextmenu(player, context)
    local playerObj = getSpecificPlayer(player)
    local option = context:addOption(getText("UI_myaction"), playerObj, myactionaction);


end
Events.OnFillWorldObjectContextMenu.Add(LMMain.myactioncontextmenu);
tribal osprey
#

will do, thanks

limber oar
#

Related question, did the strip club get deactivated in some past update? The outfits are still around in clothing.xml but it looks like the zone is gone from ZombiesZoneDefinition. I'm not getting any zombie strippers to spawn in there no matter how many I plunk down.

#

...I swear this mod isn't what it sounds like.

bronze yoke
#

when you write myactionaction(playerObj), you're calling the function and passing the return value, which is nil as your function doesn't return anything; to pass a reference to the function you just use myactionaction with no ()s

tribal osprey
#

ohh i was just going off my python knowledge that it absolutely needeed to have a passed variable that makes sense yeah

bronze yoke
#

the context menu calls the function when the player clicks on the context option, for now we're just telling it which function we want it to call

tribal osprey
#

sadly still an attempt to index a nil value :(

#

null*

#

im gonna try a full restart but darn

#

thanks for the help tho

late hound
limber oar
#

I've seen mods reference that room in their own ZZD files but I can't find any reference to the space in vanilla. Are those spawns determined somewhere other than the ZZD file?

bronze yoke
#

it's java

limber oar
#

...Thanks, guys. ๐Ÿ˜…

#

It's always the easy solutions that stump me.

tribal osprey
bronze yoke
#

which line does the error point to?

tribal osprey
#

#11 now, which makes sense since it's the event trigger, but there's no index on that line

bronze yoke
#

LMMain.myactioncontextmenu is a table index

tribal osprey
#

oh i see

tribal osprey
bronze yoke
#

LMMain isn't defined anywhere in what you showed, and the function isn't called LMMain.myactioncontextmenu, is that a mistake you made cleaning up the specific names in the code to show or...?

toxic hollow
#

anybody else getting a normal termination error when trying to use brita's weapons/armor?

tribal osprey
viral karma
tribal osprey
#

thanks for the help

limber oar
ruby urchin
#

Does anyone know how to get the X or Y limit of the map?

rancid panther
#

idk what i did but when i add my mod it gets stuck on a blank main menu background image

#

there was for some reason a shortcut to my mod folder within the folder, so i removed that but it still happened. so now im revalidating my files

#

figured it out. caused by something in my exclusive traits

rancid panther
#

i was missing a comma

#

i hate coding

bronze elk
#

Does anyone know if there's a mod to light fires with just friction or something?

agile vigil
#

Isn't it possible to make a Drill Plank in vanilla?

agile vigil
#

Yeah, you can just use the drill plank option and a sturdy stick to light fires ๐Ÿ™‚

bronze elk
#

ooooooooooooooooooooooooooo

#

I see

#

I've always seen that recipe but never understood what it was lol

agile vigil
#

You're welcome ๐Ÿ™‚

ancient grail
#

@astral dune
bro wasnt able to make your code work so i had to device something else.. i did the sprite odd even thing i told you about


TileNameContext = {}

local VaultTiles = VaultTiles or {}

local VaultTileList = {}
for i = 0, 21 do 
    if i % 2 == 0 then  

        table.insert(VaultTileList, {close='krp_glytch3r_safe_'..i, open='krp_glytch3r_safe_'..i+1})
    end
end

local c = 0
for i = 1, #VaultTileList  do 
c=c+1
    print(c..':    close: '.. VaultTileList[i]['close'] ..'   open: '.. VaultTileList[i]['open'] )
end

function getKey(table, value)
  for key, val in pairs(table) do
    if val['open'] == value then
      return VaultTileList[key]['close']
    end
    if val['close'] == value then
     return VaultTileList[key]['open']
    end
  end
  return nil
end
print('') --adds bunch of spaces for clarity
print('')
--to test, you can test this using any lua console since it doesnt really used any pz related stuff
print('convert odd#  open to close   '.. getKey(VaultTileList, 'krp_glytch3r_safe_5')) --should return krp_glytch3r_safe_4
print('convert even# close to open   '.. getKey(VaultTileList, 'krp_glytch3r_safe_8')) --should return  krp_glytch3r_safe_9


#

but big thanks tho i learned alot still

#

problem with what i did is i wont be able to havbe anyone else add to the thing

#

this is how i use to view the table entries

local c = 0
for i = 1, #VaultTileList  do 
c=c+1
    print(c..':    close: '.. VaultTileList[i]['close'] ..'   open: '.. VaultTileList[i]['open'] )
end
ancient grail
#

now i only need the function to set hidden the contents like how padlock does it

sour island
#

Unless your vaults are isoThumpable, then you can just use the vanilla locking system I rhink

ancient grail
#

idk how to set it to thumpable using tilezila

sour island
#

But the code I provided works

#

I use it for Shops, and in that mod you can turn any isoObject into a shop

ancient grail
#

i dont know how to add that to my code tho ill try when i reach a dead end ๐Ÿ™‚ i thinkk i might have found it..
thnx alot...

sour island
#

๐Ÿ‘

sour island
#

Have you reached out to the already existing mod authors?

chilly steppe
#

Are you able to add a custom radio station with custom text and mark the player when they listened to it?

sour island
#

You can add custom radios stuff - the rest is handled by the system

#

There is a tool for it I believe

chilly steppe
#

Do you know what that is?

#

I know you can add music but I want one with like talking

sour island
#

Trying to find it but my phone isnt getting enough data

finite radish
#

does the following code always equal n if n is less than 256?
final int n2 = (int)Math.floor(n - Math.floor(n / 256.0f) * 256.0);
need someone to clarify if I'm missing some floor or other Java math behavior, or maybe some behavior with the casting going on here, but from what I can tell my understanding is right

jagged ingot
#

Surprised that it isn't 255.0. Usually is for these kinds of lines of code.

sour island
jagged ingot
#

It looks like one of those RGB clamps.

sour island
#

Actually now that I think about it the tool might be integrated into the game

finite radish
jagged ingot
finite radish
#

so either 0-255 or 1-256

jagged ingot
#

Yeah.

finite radish
#

yeah, RGB's lowest value is 0 so definitely

jagged ingot
#

I don't think n would be more than itself there, given that it would subtract less than n if n has 0.0 to 0.999999... more than a whole int.

#

Too early in the morning to even PEMDAS.

finite radish
#

in this case that code actually relates to erosion - n is the seed value passed in, and they vary from 16 to 64 to 128 etc.

so in every case, that code is actually redundant - because it'll return the input value (n) for every possible seed

jagged ingot
#

Yeah.

#

That's my suspicion.

#

It looks like scaffolding code from prototyping.

finite radish
#

i even wrote a quick test in java to make sure i wasn't losing my mind but nah it's correct

jagged ingot
#

PZ has quite a bit of scaffolding in their code.

#

I mentioned this yesterday with ISUI code.

finite radish
#

might report it, could genuinely be a bug. all that'd need removed is the Math.floor in the middle for it to work

jagged ingot
#

Honestly all it looks like to me is it needs to be floored... and that's it.

finite radish
#

or, "work" I guess - I still have yet to determine the effects of the value in general since it gets mixed in with a bunch of others

finite radish
jagged ingot
#

Don't rule out that this is probably trying to round the lower decimal values on the number.

#

Just a lingering thought.

finite radish
#

not sure what you mean by that

#

Math.floor rounds down to integers

jagged ingot
#

Oh. Multiply a decimal value by 100 then round it then divide it by 100.

#

Unless I'm misreading the line in my head since I haven't looked at it in like 10 min.

finite radish
#

maybe, not sure. take another look - it's flooring n / 256

jagged ingot
#

But the int at the front of the assignment would remove that.

finite radish
#

the int at the front is just an unnecessary cast, isn't it?

jagged ingot
#

What a weird line.

#

Made me think of 4 different things lol.

faint jewel
#

int alt bit megabyte baud

#

download the garbage file

jagged ingot
finite radish
jagged ingot
#

Erosion was originally made in Lua exclusively. Whenever the mod got hired on to the TIS team, they rewrote it in Java.

finite radish
#

yeah. i thought about asking turbo about it, but I don't want to bother him until I'm more certain that it's unintentional

#

he's the one who wrote both of them

jagged ingot
#

If you know something that very likely would improve on their work, I'd hardly call it bothering.

#

I've reported critical zero-day security exploits in the past that've been patched. ๐Ÿ™‚

#

Finding ways to help improve the game for others is what makes modding fun.

gritty oak
#

any recommendations for where to learn lua?

#

I want to learn modding this game I have some experience with programming

#

but not a programmer

jagged ingot
#

Otherwise there's some guides out there that helps you with setting up a modding environment for Lua modding.

#

(Wishing there would be some bot commands for showing links to these guides here)

faint jewel
#

hack the planet! hack the planet!

jagged ingot
#

It's going to be freaking hilarious when I start writing PZ UI in TS React. xD

#

Wish that PZ had shaders for UI. All they'd need to do is enable the shader for it during the render pass. ๐Ÿ˜ฆ Would open up a ton of options like possibly backdrop-filters such as frosted glass for UIs.

#

One can dream...

drifting stump
drifting stump
jagged ingot
gritty oak
#

simple programs like vba that can calculate complex data

#

but I think I can learn it though I am good at figuring it out I just wanted a direction

#

regarding where to start learning because I never learned lua

#

or heard*

drifting stump
#

there is the official documentation but might be a bit too boring to read

jagged ingot
# drifting stump you can do it with prerendered images

Dug up a screenshot from when I modded the Java code to make a working UI shader. I didn't get the game's frame buffer to sample though. ๐Ÿ˜ฆ This is me manipulating the vec4 color from the frag shader to be more red.

Can't ask people to patch their games so I can do fancy UI stuffs though..

sour island
jagged ingot
sour island
#

There used to be a blue role, workshop mechanic?

jagged ingot
#

Konijima had it IIRC.

sour island
#

I think they had/have the ability to add pins

#

Could be wrong on that last one

jagged ingot
#

He helped get PipeWrench on the PZWiki but IDK what they could do here.

#

Yeah Konijima has that role.

sour island
#

I'd be down for the role if it's still a thing

#

Are adding commands something built into discord?

#

Or would one need to edit/modify/configure a bot?

jagged ingot
fast galleon
#

If you have a function that needs to run on an event like OnInitGlobalModData, should you also remove it from that event so it's garbage collected?

jagged ingot
#
local func = function(..)
  -- ..
  Events.OnSomeEvent.Remove(func)
end
Events.OnSomeEvent.Add(func)
fast galleon
#

So it's preferable to remove the functions you need to run once on load, right?

jagged ingot
#

I actually don't know. It'd depend on the nature of the event. There isn't much overhead from a Lua event.

#

It's stored internally as a LuaClosure in an ArrayList.

bronze yoke
#

what's the purpose of the func = nil line?

jagged ingot
#

It was out of habit.

#

But that was in compiled languages like Java so it might not be needed.

bronze yoke
#

it's not needed in lua

fast galleon
#

in PZ it fails if you do
local myfunc = function() ... end
but works if you do
local function myfunction()... end

and intellij also catches that, so must be a Lua thing

jagged ingot
#

Awesome. Editing my code..

bronze yoke
#

that's interesting to keep in mind for other languages

jagged ingot
#

Yeah so think about how the language has to calculate and initialize the variable to assign. If you try to call it before it assigns from itself, things get weird.

sour island
#

I recycled objects in a mod before - didn't seem to mstter

tropic tide
#

Hi all, is there a lua solution to read a textfile or a database on my hd with a mod ?

sour island
#

There's a file reader/writer but it only points to specific locations

bronze yoke
#

you want getModFileReader(string modid, string filename, boolean createIfNull)

sour island
#

There's one for the Lua folder (that afaik is broken)

#

And one for the current save

bronze yoke
#

no the lua folder one definitely works

sour island
#

For me it throws errors related to L's capitalization

#

Can be read but not written tho

bronze yoke
#

one of my mods writes some statistics to a json there

willow estuary
# sour island I think they had/have the ability to add pins

If stuff needs to be pinned it should be posted on the pz wiki page which is pinned, and anyone can edit and contribute to.

We used to pin stuff, and then we had so much stuff pinned that nobody could find it, and people were asking for stuff to be pinned that was already pinned regularly.
We had so many pins that the pinned posts became unsuable, and that is why people are encouraged to post stuff to the wiki instead.

sour island
#

Fair enough

#

Who's in charge of the discord stuff? In relation to adding a !intro command or something

#

Could even link to the wiki

fast galleon
#

why not pin a meta pin with pins ๐Ÿค”

willow estuary
#

nasko is the one to talk to for that stuff.

jagged ingot
#

Suggestion: Discord forum controlled by trusted people to author posts for resources, guides and tools. (But then the Wiki already solves that)

#

If there would be a portal for this content here, I think that would be the best method.

#

A bot with keyword tags to then post something in the channel for those resources would also be good and prevent things like pinned post spam.

faint jewel
#

blair... did you ever see my update to your carry mod?

sour island
#

I wonder if the #thread could be used

drifting stump
sour island
#

I've written bots before, but surely there's a simple keyword message

#

There's some in pzchat for memes lol

drifting stump
#

discord only has auto moderation

#

and commands triggered by keywords are highly discouraged

ancient grail
#

i wonder???

sour island
#

?

fast galleon
#

probably the guy in Skizot's mod with the cat hat

sour island
drifting stump
#

like i said have to make a bot

ancient grail
#

I saw a lua with a rabbit function

drifting stump
#

and those kinds of commands shouldnt be made

sour island
#

Out of curiosity, how come?

drifting stump
#

they require message content intent which is very very discouraged by discord

#

requires a manual review application to pass to get access to the intent for large bots

astral dune
agile vigil
#

What you typically see on other Discord channels (e.g. Enigmatica for the Enigmatica modpacks for Minecraft) is you have a command, e.g. !tip and then a password for the tip. !tip export textures would give texture info for example.

I think the new bot API lets you make /-based commands with preview and auto-complete and all.

ancient grail
#

And i really learned alot. Im gona learn your return boolean technique thing

ancient grail
#

Ahmm if i have an item thats moveable and i added moddata to its script
If i place it will it still hold that moddata?

fast galleon
ancient grail
#

Thnx another Q
Is it possible to hide my sprites from the tilepicker
Cuz i cant find a way to convert it into thumpable. And i really cant comprehend chuck's code
So i think ill have to make it item only and thrn as the place/build it will convert into thumpable

sour island
#

My code intercepts when items get transfered or try to be

#

All you have to change is the validStoreObject(mapObject) function to be what you need

#

The rest should remain the same

#

I basically took the UI/item related events with locked containers and copied the results with a different condition check

finite radish
#

intellisense cracks me tf up sometimes

drifting ore
#

With my mod that edits Metalworker profession - some people state that after they die they can't see any other profession but the one I edited... I tried replicating the issue by adding some mods that tweak/add professions but with no luck... What might cause that on their part?

jagged ingot
sour island
finite radish
#

if I had to guess, they're using the profession framework (if that's still a thing) and there's a conflict where it's overwriting the professions factory functions. iirc that framework uses some stuff like that to remove the base professions and re-implements them using the framework

drifting ore
#

Yeah I asked, but I usually won't get any second replies ๐Ÿ˜„

#

AHh, thanks, I'll try that too.

finite radish
#

(that framework was made with good intentions, but if it's that incompatible with mods that don't use it then it's a bad implementation imo)

#

not even sure if that's the case though, but yeah def worth testing out

drifting stump
#

whats the name of your mods lua file

drifting ore
quasi geode
drifting ore
#

They said other professions got removed after they died and tried doing a new character on the same save.

drifting stump
quasi geode
#

if i was going to guess on the issue, the problem is the vanilla function was overwritten without calling the original vanilla one, and only includes the changes in the function - not the full original content:
the vanilla function is stuck into a OnGameBoot event (if i remember right) before another mod can overwrite it
when the player dies and restarts the function is called (but not necessarily the original one)

drifting stump
#

well if fenris says it calls any overwrite then it wont be file name

drifting ore
#

look like this

#

tested framework too, works fine

finite radish
quasi geode
drifting ore
quasi geode
#
local original_doprofessions = BaseGameCharacterDetails.DoProfessions -- copy the original
BaseGameCharacterDetails.DoProfessions = function()
    original_doprofessions() -- call the original

    -- now do the stuff

end
Events.OnGameBoot.Remove(original_doprofessions)
Events.OnGameBoot.Add(BaseGameCharacterDetails.DoProfessions)
drifting ore
drifting stump
quasi geode
#

yes. i was about to mention that

#

almost slipped my mind haha

jagged ingot
#

Ahhhh crud. I thought there was masking API for UIElements.. Basically not rendering overflow of children elements being possible.

fast galleon
#

ok, is overwriting neccessary? can't you just add a single profession with your own function?

sour island
jagged ingot
#

I didn't notice those methods.

sour island
#

Yeah that's how I did errorMag

jagged ingot
#

Good. Standard OpenGL stuff.

#

Now I can hook that up with my CSS library.

ancient grail
#

Its possible to do css? For ui? Wtf ?!

quasi geode
jagged ingot
finite radish
ancient grail
#

I wont hate making UI after thats built

finite radish
jagged ingot
#

It uses TypescriptToLua to do the final transpilation from TS to Lua. They have custom JSX Factory stuff.

finite radish
#

dear god

jagged ingot
#

I wrote PipeWrench. I can do this too.

finite radish
#

i both love and hate that concept entirely

jagged ingot
#

So I'm writing a primitive HTML engine right now with CSS.

finite radish
#

fuck it, go all the way. implement SASS/SCSS

jagged ingot
#

Why not let SaSS do SaSS in a Node package and then compile it to CSS?

finite radish
#

(it all bakes to css anyw-

#

yeah

jagged ingot
#

You wouldn't hate the part that allows you to see this:

#

I heard that EmiLua does some stuff like that too.

#

Having a UI that can be built in React would save a lot of headaches though.

finite radish
#

god that's beautiful

finite radish
jagged ingot
#

DOM objects as actual Types / Classes.

finite radish
#

that makes some sense, but I feel like React wouldn't be my first choice there

#

not that I can really think of what would be my first choice at the moment

jagged ingot
#

A parser can always be used in its place.

fast galleon
#

interesting Professions are reset only for Mouse

jagged ingot
#

The idea is to have rules and have rulesets for UI.

#

I think modeling my solution around HTML and CSS with some utility from JSX would be a decent place to start.

finite radish
#

yeah for sure

jagged ingot
#

It can be done and that's what I'm doing right now.

ancient grail
jagged ingot
#

@finite radish If you scroll up my msg history in here you'll see a screenshot of a Java core mod I made that shows me inserting a GLSL shader program for UI.

If we had that...

#

I could do things like frosted glass.

fast galleon
jagged ingot
#

Also like-jQuery shenanigans for animation functions could be built into that.

#

Maybe I'll finish up that core mod and allow it as an optional, "experimental features" like Chromium likes to call it.

#

๐Ÿ™‚

finite radish
#

and that's from the perspective of wanting java mods really badly, for the record. just being realistic

jagged ingot
#

If people want something enough, they'll get it.

#

So don't count that out.. especially with server-side patches.

finite radish
#

that's the first I'm hearing of any successful java mods tbh, outside of projects like CocoLabs and Storm (which also don't/didn't have much traction)

sour island
#

Someone once told me that if they exposed the java reflect it would basically allow one to modify anything? I'm not well versed in Java, but would that be the case?

finite radish
#

eh, sorta - you can do that with reflection already, it's just unsafe

sour island
#

I imagine it would be very unsafe

jagged ingot
finite radish
#

you don't really need to "expose" reflection (since it wouldn't be a Lua process) but I suppose you might be able to get some sort of reflection attached to the lua exposure - but it'd defeat the purpose of the security of managed Lua execution

jagged ingot
#

Reflection is slow.

finite radish
#

that too

jagged ingot
#

You can dynamically inject bytecode into any Java process before it starts and keep files clean.

sour island
#

I think they wanted a silver bullet to hitting Lua hook roadblocks

finite radish
#

(and messy, and difficult)

jagged ingot
#

I could literally throw you an environment I built just for this for PZ.

finite radish
jagged ingot
finite radish
#

i'm working on mapping/data tools for PZ in .NET 7 at the moment, but nothing like interacting directly with the game like your TS layer/Java bytecode stuff

jagged ingot
finite radish
#

only reason I mentioned that was I saw Java bindings mentioned on the github readme, but I figured it was pretty barebones

or is it just implementing linting/type defs for the Java code for when objects are returned/used via Lua?

#

(also was partially referencing what you mentioned above, separate from the TS stuff)

jagged ingot
#

I built both.

#

The Java one going deep into and pulling up generic types for class implementations.

finite radish
#

exposed Java API as in "anything that's public" or exposed as in "exposed to Lua bindings"? either way that's neat

jagged ingot
#

Consequently, updating the typings also creates an API changelog for the game's API via Git diffs.

finite radish
#

that makes sense, yeah

jagged ingot
#

Every change to the API in the core engine of PZ shows up with every version change. =3

finite radish
finite radish
#

v nice

#

that'll be super helpful once B42 starts rolling out

jagged ingot
finite radish
#

facts. my pokemon framework is gonna be sick

drifting ore
#

Kind of went wild with the Events :D:D Just to be sure

sour island
#

So if I understood - this will show new exposures or changes to existing ones?

fast galleon
jagged ingot
#

The documentation is also automated.

#

Shows all parameter options for calling the method.

drifting ore
#

Or creating a new character withing a save?

#

I tested it with my character death and with crating a new character within a save and they both worked. Showed other professions and added proper recipes.

fast galleon
#

when you die, there's an option to make character before quitting to main menu. If you don't have joystick, it resets the professions.

drifting ore
#

one sec

drifting ore
#

Thats why I went wild with the Events. So it can work in different situations.

fast galleon
#

honestly, I usually don't use that option since it seems to cause bugs with a number of mods.

mild onyx
#

Hi so I am thinking of making a pz mod to either reskin the zombies into the flood from halo or make new zombies in general
Looked info up on zombie modding to see if its even possible but I only saw a reddit post from 5 years ago that wasnt very helpful
Have never modded a game before either so I dont know anything here

ancient grail
mild onyx
#

nope

ancient grail
#

U might want to start with looking at some simple mods.
And you should learn the folder structures
Files types and then then syntax. Then learn lua..

But you you can create mods without even learning lua . Basic mods i guess

mild onyx
#

I know I know
right now though I want to know if my idea is possible at the moment

winter thunder
#

Hey, does anyone know where to find the list of abbreviated skills/stat code for the Recorded Media functions?

dull moss
#

Hey, I'm digging through some code, can someone explain to me how does overwriting game actions work?
code in question:

local original_fix_perform = ISFixAction.perform;
function ISFixAction:perform()
    local player = self.character;
    local item = self.item;

    local hasRestorationExpert  = player:HasTrait("RestorationExpert");

    if(hasRestorationExpert) then
        self.item:setHaveBeenRepaired(0);
    end

    original_fix_perform(self);

end

As I read it, it stores what original repair function would do in local variable, then replaces it with custom function that as a part of it runs original code?

winter thunder
dull moss
#

ye i get the mid part, was just wondering if I read the other part correctly

#

Now the fun part: where do I get code for what exactly base game perform actions do, for example

winter thunder
#

What do you mean?

dull moss
#

cuz fuck knows what ISFixAction:perform() does

winter thunder
#

So- That is probably in the Lua, I can check where it is if you want

#

found it

dull moss
#

So basically go search base game files?

winter thunder
#

Steam\steamapps\common\ProjectZomboid\media\lua\client\TimedActions

#

Go here

dull moss
#

cheers, will look it up

winter thunder
#

IsFixAction is defined there

#

yup yup!

dull moss
#

Now where would I find FixingManager PepeThink

#

FixingManager.fixItem(self.item, self.character, self.fixing, self.fixer);

#

Tried searching for file name, got 0 hits

winter thunder
#

Wait- So what is the end goal?

dull moss
#

General curiosity at this point KekW

bronze yoke
#

sounds like a java object

winter thunder
bronze yoke
#

yeah, it's java

dull moss
#

yea im not gonna go into decompiling stuff

winter thunder
#

Yeah, but the framework for making a new fix action already exists lol

#

If you are trying to change the items needed to fix something, those are done simply through script files

dull moss
#

yea i know that one. I generally was just researching how higher mentioned part of code works

winter thunder
#

all good! I figure that if you wanted to mess with it, you could also just go through and insert your own new function similar to how the code you sent did. Basically just modify the fixing action in some way to do what you want instead

#

Also- Would it be wrong to @ someone from TIS that is named in a file to ask where on earth they pulled variables from? LMFAO

dull moss
winter thunder
#

Because I am trying to find all the shorthand codes for recorded media

dull moss
winter thunder
#

You can see how each line has a dif effect- Most reduce boredom, but there is also the CRP+1 which is giving carpentry xp

dull moss
#

trynna make vhs for other skils? ๐Ÿ˜„

winter thunder
#

Yeah, I had someone ask me about it. So I am deep diving trying to figure it out lol

dull moss
bronze yoke
#

those are in client/RadioCom/ISRadioInteractions.lua

winter thunder
#

HOLY SHIT I LOVE YOU

#

THANK YOU

bronze yoke
#

every stat and skill has one, even things like thirst lol

dull moss
#

can't wait to watch some VHS to quench my thirst

bronze yoke
#

'drink'? dude i have Thirst for Beginners

dull moss
winter thunder
#

While we are here, is it possible to give someone muscle fatigue as a condition?

#

Like- Without working out

thick karma
#

You know, if you did want to...

dull moss
bronze yoke
#

it's referred to as stiffness internally

dull moss
#

steamapps\common\ProjectZomboid\media\lua\shared\Definitions\FitnessExercises.lua

#

in here

#

ye

#

damn exercising with equipment gives like twice exp

dull moss
thick karma
#

@dull moss IntelliJ lets you independently search all the text of all the files in the Java decompile (case-sensitivity and regex optional), and also search each file that turns up in that search the same way... Pretty useful.

#

(While the parent (directory/file level) search is still live)

#

idk lmao I am describing this poorly but try it

winter thunder
#

I have worked on project zomboid mods in NotePad++, VSC, and Intellij. For simply opeing and reading a file, I will always recommend NP++, but for the actually coding, it is so worth it to decompile and use Intellij. Just being able to look up, and have the entire codebase referenced easily is so nice

bronze yoke
#

i use np++ if i need to look at another mod briefly, otherwise always intellij

#

in some cases i might open a script folder or a mod in vsc but that's it

thick karma
#

That's main reason I use Code... pure short-term simple-minded impatience

#

I have not thoroughly analyzed this decision lmao

#

But nevertheless it serves many purposes well for me and I would recommend if you've never tried it

bronze yoke
#

maybe it's time to close your np++ tabs?

thick karma
#

No I mean fresh install

bronze yoke
#

๐Ÿ˜Ÿ

thick karma
#

Code just boots faster

#

I think seconds faster iirc

#

But even if it's fraction of a second, it's palpable to me

bronze yoke
#

vsc is noticeably slower for me but np++ i don't consider even useable for writing code

#

it's not even that good for reading it

thick karma
#

Hmmm Idk Notepad++ opening pretty fast now

#

Maybe I misremember why I passed on it

#

I just redownloaded it to test

ancient grail
thick karma
#

I am actually noticing something else that I did not notice last time I used Notepad++

#

Another thing that slightly bugged me was I would type "Not" and see "Notepad" until I got all the way to "+" in the Windows key menu

#

and making a shortcut for notepad feels excessive.

#

Whereas "Co" hit on Visual Studio Code off the rip

#

HOWEVER

bronze yoke
thick karma
#

I am noticing that Windows is legit remembering my preference

#

If I type "Not" enough times and select Notepad++ from menu, Windows notices I prefer Notepad++ on Not

thick karma
#

Smart Windows, good job Windows.

ancient grail
#

Ya better catch some shut eye

thick karma
#

(Or a new feature, who knows)

bronze yoke
#

for notepad++, i'm always using it from right clicking a file anyway

thick karma
#

Word haha

#

Anyway maybe I won't uninstall it immediately long story short

ancient grail
#

I use note++ as a scratch paper . As a thing where i keep snippets and notes
Cuz it stays there after u close and it has bunch of diffrent tabs of files from various directory so i dont use it as a workspace unlike vscode where the main project is opened . But i usually run 2 instances

So my setup is
Vscode javadocs and lua folder on
vscode modproject workspace
Notepad++ with snippets and stuff

I run all from a autohotkey gui which contains bunch of usual snippets too. I prefer to use ahk compare to extension they have. Its just so that its universal for me

bronze yoke
#

i was reluctant to switch to intellij but really quickly found the benefits after only a couple days

dull moss
#

I'm sitting in Visual Code atm

ancient grail
#

How do you search stuff with intellij? I cant seem to find it

sour island
#

Ctrl+shift+F for words

#

Ctrl+shift+N for files

#

If you've used the libraries tutorial

ancient grail
#

I never bothered . I did try for a few mins and tried to install gradle and stuff but couldnt make it work so i gave up

#

But i might be able to figure it now . K didthis back when i wasnt modding yet. And wanted to learn how

bronze yoke
#

the setup is pretty annoying honestly but it's very much worthwhile

ancient grail
#

Ah so it wasnt just me who thinks its frustrating then

bronze yoke
#

i had to mess with it to force it to use more ram and stuff, it was such a pain

ancient grail
#

I thought it had to be learned as a basic thing for IT professionals

bronze yoke
#

being able to find the source code for anything in the game in a handful of seconds pays off though

ancient grail
#

U mean like auto complete?

bronze yoke
#

i mean like the actual lua/java source code

winter thunder
ancient grail
#

Is it really that good? Cuz you can search using vscode and it has right click reference thing
Not really sure wht intellij has that cant be done by vscode

bronze yoke
#

the main thing is the libraries generated by that tool don't quite work as well in vsc, and searching the lua/java isn't nearly as convenient

ancient grail
winter thunder
#

using intellij you can decomp the zomboid files and set them as external reference libraries. It is SUPER helpful

ancient grail
#

Ye thats gota be it

#

Ahhh no shit can u run debug too?

#

I might try to install it again then

#

And are you like able to for example
Type in getPlayer():

Then a bunch of possible entries show up? If thats the thing then ill defntly install it

#

Imean gradle ..

winter thunder
#

@ancient grail

dull moss
#

time to switch to inteliji

winter thunder
#

it is super helpful

dark arch
#

i just did

dull moss
#

I like my vscode sadge

#

but tbh inteliji is also nice

dark arch
#

Someone should put it in the pinned section

dull moss
#

used it before

tough stag
#

hey, I'm a noob trying to use ISChat.addChatLine like ("Message", 1, 1, 1) but got an error,
ttempted index: addLineInChat of non-table: null at KahluaThread.tableget line:1689., what is the correct way to use it?

thick karma
#

Not splitscreen friendly for multiple Jumpers FYI, fair warning (also on the page). I fear someone will be tempted to try and it will be a bit borky.

#

Multiplayer online is fine

ancient grail
thick karma
#

P sure

winter thunder
#

so, with my current drug mod I am working on- I am looking to trigger effects upon the consumption of the drug. So- Would it be better to use a custom onEat function, or should I make something new from scratch? I want to implement custom sound and animations for the mod, so I dont want to be hard limited if that is not the best approach

tough stag
# thick karma P sure

nah still the same, what is this complain about table stuff, I thought it was simple stuff lol
Stack trace: java.lang.RuntimeException: attempted index: instance of non-table: null

thick karma
#

Hmmm weird

winter thunder
dull moss
#

bruh why unhappyness is in BodyDamage and all other stats like boredom or stress are in Stats

#

this game sometimes

bronze yoke
#

most likely your file is in shared so it's running before ISChat is created

winter thunder
#

that would make sense ^

dull moss
#

so folders matter?

bronze yoke
#

although that might not be it, i'm not sure why you would be calling that function while the game is booting anyway

dull moss
bronze yoke
#

folders only matter a little bit

dull moss
#

Zomboid mods have three different  lua folders:

client 
shared
server
These folder's purpose is code organisation. Simply putting code into server doesn't mean it is executed on the server and not on the client. In single player for example all code is executed no matter in which folder you placed it. ```
tough stag
# winter thunder What is the full code you are typing?

I'm using this thing https://steamcommunity.com/sharedfiles/filedetails/?id=2825060402, trying to setup some command, without that line the message is printed on the console

    -- Check if the correct number of arguments are passed.
    if #args ~= 1 then
        return '/'..CMD_NAME..' [message].'
    end
    -- NOTE: The helper only becomes visible in global scope when the first lua server command is fired.
    --       Make sure to reference the helper inside of the command's handler function.
    local helper = LuaServerCommandHelper
    ISChat.instance:addChatLine("Message", 1, 1, 1)
    return 'Message: ' .. message
end)```
bronze yoke
dull moss
#

kek

#

then where do we put our stuff?

winter thunder
astral dune
#

whats wrong about it?

bronze yoke
#

client files aren't run on the server, and the game loads vanilla shared -> modded shared -> vanilla client -> modded client -> vanilla server -> modded server

dull moss
#

bruh

bronze yoke
#

the folders actually matter a fair bit

dull moss
#

so I need to think where i put my luas?

bronze yoke
#

also from what i've seen, require calls only work in the same folder or in shared

#

e.g. client folder can only require client and shared, server can only require server and shared, and shared can only require shared (not sure about this last one)

winter thunder
#

... Wait, fr? damn- Good to know! Now I know where my drug modules go :)

astral dune
#

I imagine you can require a client file in the server folder, but of course only on the client

dull moss
#

every single mod i worked on has everything in client with exception of traitfactory which is in shared and they all work on server and sp

#

so how do they matter

bronze yoke
winter thunder
#

Depends what mods you have made, tbh

dull moss
#

trait stuff mostly

bronze yoke
#

it just didn't matter for your mods

dull moss
bronze yoke
#

you can usually get away with making the majority of things client sided

dull moss
winter thunder
bronze yoke
#

i didn't respond because i wasn't sure ๐Ÿ˜…

winter thunder
#

Ah- lmfao, all good!

bronze yoke
#

the simplest solution is usually the best, so i would try OnEat first, but i don't know if you'll run into limitations

winter thunder
#

I was thinking of piggybacking on the onEat because it would make the entire system a lot easier

#

Yeah, thanks! Honestly that was the confidence I needed lol

#

Also- Have yall seen the OpenAI chat bot?

tough stag
winter thunder
#

oh... Weird... Might be the way you are calling the chat then

bronze yoke
#

does this run on the server?

tough stag
bronze yoke
#

the server doesn't run the client folder, so ISChat doesn't exist there

#

from the description of the mod i'd guess that it does run on the server

winter thunder
#

Sorry for the spam- But I mentioned that chat AI earlier because I asked it to explain to me how LUA modules work, and had it explain to me what the module I had written would do, and explain how the module can be referenced in different ways

astral dune
#

my experience with ChatGPT and lua is that it doesn't really understand the concept of pass-by-reference vs pass-by-value. It can tell you the difference, but not implement it in sample code

winter thunder
quasi geode
#

heh, it fails to localize the initial DInfo table in the first file. odd mistake

dull moss
#

heh

#

I actually never used it

#

but holy hell this is fun

winter thunder
#

The variables are defined as local in the module itself, not the new instance afaik

dull moss
#

bro no more manually editing shit in UI files

#

holy shit KekW

winter thunder
#

RIGHT? It is incredible

dull moss
#

bro

#

it

#

is fucking insane

winter thunder
#

I had it write me a rap song about south american animals yesterday, and got it to explain to me its process for seizing control of the global cheese market

#

Like- Just the universal functionality of it is insane

astral dune
#

I asked it for a joke about Dante's Inferno, it said

Why are there so many circles in Dante's Inferno?
Because its a round hell
winter thunder
#

Hold up.... Am I able to just call ANY function with the onEat trigger in an item? From what I looks like, I dont need to do anything fancy... I just set the onEat = to whatever function I want, and then it run it?

bronze yoke
#

yeah, anything global

winter thunder
#

You know of a good way to add delay? Like- Function starts, x time passes, then the rest of the function occurs?

unreal bane
#

dumb question: say i want to make a new occupation mod using the vanilla ones as a base. where in the world do i started?

bronze yoke
#

the most basic way to do this is to count ticks on the OnTick event

#

if the time is particularly long and doesn't have to be exact you can use a different event

winter thunder
#
#

Seems like fWolf cooked up a system awhile ago

ruby urchin
#

Does anyone know what happens when an NPC is removed naturally from the player's instance? I see the IsoPlayer still exists, but his model disappear

#

I tried this, to bring it from to cell

public IsoPlayer(final IsoCell isoCell) {
    this(isoCell, null, 0, 0, 0);
}

but it doesn't works as expected

dark arch
dull moss
#

You have to disable that specific check for your folder

bronze yoke
# winter thunder https://theindiestone.com/forums/index.php?/topic/23554-lua-timers-adding-repeat...

i wrote this for a project of mine, no idea how performant it is compared to that one

local Delay = {}
Delay.currentTick = 0
Delay.Delays = {}

Delay.DelayFunction = function(func, time)
    Delay.Delays[Delay.currentTick + time] = Delay.Delays[Delay.currentTick + time] or {}
    table.insert(Delay.Delays[Delay.currentTick + time], func)
end

Delay.OnTick = function(tick)
    Delay.currentTick = tick
    local delaysThisTick = Delay.Delays[tick]
    if not delaysThisTick then return end
    for i = 1, #delaysThisTick do
        delaysThisTick[i]()
    end
end

Events.OnTick.Add(Delay.OnTick)

return Delay
dull moss
#

It's cuz you call functions that are in PZ

winter thunder
dull moss
#

So vscode be like dented

bronze yoke
#

it can't do anything except call a function after a certain number of ticks (like even pass arguments), that's all i needed it for

dark arch
#

guess ill just ignore it

dull moss
#

Click on lightbulb next to line with error

#

There you can disable it

#

Or define that thing that vscode doesn't know about as global

#

So it will know that it's somewhere else

#

And it doesn't need to worry about it