#mod_development

1 messages ยท Page 253 of 1

bronze yoke
#

always call obj:transmitModData() after changing mod data

prisma harbor
#

๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘

plush dew
#

Im trying to put a test mod into my game and I have it in the right address users/my name/ zomboid/ mods and its not showing up at all
I am new into modding on PZ and have been watching yt guides but all of them are from a few years ago so I assume my code is just either outdated or not the right format anymore

topaz tangle
#

If anyone could help me fix the last few issues with my mod it would be greatly appreciated!!!!!!!!

inters and exits from the car via the frame rails,

headlight texture doesnt work,
the glass doesnt change,
Damage texture doesnโ€™t work

drifting ore
#

hellooo, is there a guide on how to get started with making mods for zomboid?

I know quiet a bit of lua and java, but dont know where to begin

plush dew
topaz tangle
drifting ore
#

i want to do a shopping cart of deeath and trolley of doom

#

upgradable trolley and shopping cart

topaz tangle
#

so probably a vehicle mod then?

drifting ore
#

i mean does trolley count as a vehicle?

topaz tangle
#

a shoping cart is a vehicle in my opinion

but like..... you have to be less specific for mod making

mystic vessel
#

Would anyone here happen to have the model of the duffelbag that the player equips on hand in .fbx?

I'm trying to make a duffelbag in a larger size, but I can't use the .X

#

I tried going to Blender with a plugin, and importing .X but the file in the game breaks completely

#

I wanted the player to be able to equip the item at this same size, but I'm not able to

grizzled fulcrum
#

one sec

#

ther eare multiple duffel bag models pepeSob

#

Honestly instead of messing with x and fbx stuff I'd just change the scale property in the model definition

#

just match them up as close as possible or something

plush dew
#

Im trying to put a test mod into my game and I have it in the right address users/my name/ zomboid/ mods and its not showing up at all
I am new into modding on PZ and have been watching yt guides but all of them are from a few years ago so I assume my code is just either outdated or not the right format anymore
does anyone know what I might be doing wrong

mystic vessel
#

I tried using the default duffelbag directory and just increasing the size, it didn't work. I tried to increase it directly using Transport_bag.x it also didn't give any results

grizzled fulcrum
#

As long as you have a mod.info it should load tho

#

Make sure you are enabling it in the game!

mystic vessel
#

In red, it was a copy of the file

Duffelbag_Ground.fbx

What I did, I made a copy, renamed it and put it in the folder and the new size settings worked perfectly. I'm trying to do this now with the duffelbag in hand or in this case
Transportbag

grizzled fulcrum
#

Why make a copy? Is there no entry there for the ground item?

mystic vessel
#

Basically I want this item, which uses the vanilla models, to be bigger. But I've been racking my brain all afternoon about this

grizzled fulcrum
#

Do you have your transport bag item?

#

Like do you have a definition in item script somewhere

mystic vessel
#

sure

grizzled fulcrum
#

hmm

mystic vessel
#

I have tried most of the alternatives
The conclusion I reached (and I'm probably wrong) is that X files cannot have their ownership changed

grizzled fulcrum
grizzled fulcrum
plush dew
grizzled fulcrum
plush dew
#

no its not in there at all

grizzled fulcrum
plush dew
#

mod info has this in it
name=DannyCola
id=DannyColaMod
description=Adds a new drink called DannyCola to the game.
version=1.0
author=Doodle

grizzled fulcrum
#

and I am not sure if this is necessary but media folder shouldn't have capital letters in it

mystic vessel
#

i dont know how to do it

mystic vessel
#

:/

grizzled fulcrum
#

like with the duffel bag

#

oh you want to make duffel in hand bigger

#

I thought it was other way

mystic vessel
#

the vanilla duffelbag dont have the "scale" line it's a only size

mystic vessel
plush dew
grizzled fulcrum
#

which each have separate scale and offset and other stuff

mystic vessel
grizzled fulcrum
#

You can change scale of individual one by adding them to your model script definitions like:

model DuffelBag_R
{
    mesh = myMesh,
    texture = myTexture,
    scale = 1.234,
}

model DuffelBag_L
{
    mesh = myMesh,
    texture = myTexture,
    scale = 0.1234,
}

model DuffelBag
{
    mesh = myMesh,
    texture = myTexture,
    scale = 1.0,
}
#

so changing scale of model for ground will not change model in hand etc

#

There are separate model for LHand, RHand, Ground, and equipped

#

I could be wrong one sec

#

I am not (hopefully Luka_cry), this is how u do it

mystic vessel
grizzled fulcrum
#

yes, thos eare placeholder

mystic vessel
#

ex: media/worlditems/allalalal

grizzled fulcrum
#

you need to fill

mystic vessel
#

Here is supposedly the correct left hand model? In these two files everything is set correctly, right?

plush dew
#

@grizzled fulcrum can i send you the code its a very small bit of coding its just a test mod for a drink but i might have something wrong or whatever and its not showing in my mods for that reason

#

or just ss of it all

grizzled fulcrum
#

It has to be the mod.info as that is what defines the mod basically

#

Does it not work with the .txt removed?

plush dew
#

well is it supposed to be a text document

grizzled fulcrum
plush dew
#

the .txt only shows because i have my file directories on in file explorer

#

so i can see if a file is txt mp3 etc

grizzled fulcrum
#

Yes, it needs the file extension .info

plush dew
#

how do i change it to that lol

mystic vessel
#

still looks small :/

grizzled fulcrum
mystic vessel
#

.X

#

I dont have the duffelbag left hand on .fbx

grizzled fulcrum
#

You need to add .X file extension in model xml like

<m_MaleModel>WorldItems\Transportbag_LHand.X</m_MaleModel>
#

and same for female

plush dew
#

is it .nfo or .info

grizzled fulcrum
plush dew
mystic vessel
#

i need to put .X here too?

grizzled fulcrum
#

no

grizzled fulcrum
plush dew
#

okk i got it now thanks

grizzled fulcrum
#

@mystic vessel you fix it?

mystic vessel
#

When I copied the duffelbag_ground which is FBX, I renamed it and pasted it into my mod, nothing happened, but doing the same with the X file didn't work so it's possible that X files can't be edited

#

In the original game folder, the ones that change "scale" are all in fbx

#

And I have no idea how to import a .X file into Blender and have it in the correct proportion and not break within the game

grizzled fulcrum
#

I think there's a guide somewhere

robust briar
#

Is there something special I need to do to use getText on the server side in MP?

For somereason, my translations do not work when I call getText on the server.

bronze yoke
#

why are you calling it on the server?

#

i didn't know it doesn't work there but it kind of makes sense

robust briar
#

๐Ÿ˜ข

#

I am renaming items at time of spawn to randomize them

#

the name is dynamic, like "built" of multiple parts

thick karma
#

Your server can't know the user's language...

robust briar
#

Oh yeah, I know. I was just going to let it default to english on MP

#

seems I wll have to rethink this

bronze yoke
#

i would've expected it to default to english since the game falls back on english when translations are missing but i guess it doesn't load translations whatsoever

#

which is wise really!

robust briar
#

Dang :-(

#

I wonder.. if I can let the client rename it once it "sees" it

#

well, thanks for the answer

#

off to the think tank we go

thick karma
#

    local scriptManager = getScriptManager()

    scriptManager:getItemForClothingItem("Japanese_Jacket_Overshirt-Black"):setDisplayName(prefix .. getText("UI_TraditionalJapanese_Kimono") .. suffix)
    scriptManager:getItemForClothingItem("Japanese_Jacket_Overshirt-Black_Tuck"):setDisplayName(prefix .. getText("UI_TraditionalJapanese_KimonoTucked") .. suffix)
    scriptManager:getItemForClothingItem("Japanese_Jacket_Overshirt-Dyed"):setDisplayName(prefix .. getText("UI_TraditionalJapanese_KimonoDyed") .. suffix)
    scriptManager:getItemForClothingItem("Japanese_Jacket_Overshirt-Dyed_Tuck"):setDisplayName(prefix .. getText("UI_TraditionalJapanese_KimonoTuckedDyed") .. suffix)
#

@robust briar

robust briar
#

That works on server?

thick karma
#

Wait oh individual items?

bronze yoke
#

i think for one of my mods i hooked whatever method returns their name to return the custom one instead

thick karma
#

Or types?

bronze yoke
#

it should be language safe that way

robust briar
#
-- this complicated shit is needed because PZ called OnCreate everytime an item
-- is initialized, instead of just the first time the item is created, but worst
-- of all, it calls it before the moddata is applied, so we can not know if at
-- time of OnCreate if this is actually a new item or not.
local toInitializeItems = {}
local isChecking = false

local function MOTW_CheckMusic()
    for i = #toInitializeItems, 1, -1 do
        local item = toInitializeItems[i]
        local md = item:getModData()
        if not md["MOTW_Song"] then
            MOTW_RandomizeSheetMusic(item)
            table.remove(toInitializeItems, i)
        end
    end
    if #toInitializeItems == 0 then
        isChecking = false
        Events.OnTick.Remove(MOTW_CheckMusic)
    end
end

function MOTW_OnCreate_SheetMusic(item)
    table.insert(toInitializeItems, item)
    if not isChecking then
        isChecking = true
        Events.OnTick.Add(MOTW_CheckMusic)
    end
end

function MOTW_RandomizeSheetMusic(item)
    local randomSong = MOTW_Core:getRandomSong()
    item:setCustomName(true)
    item:setName(getText("IGUI_InstrumentType_" .. randomSong.instrumentType) .. " - " .. getText(randomSong.name))
    item:getModData()["MOTW_Song"] = randomSong.name
end
#

that gives me this on server side

thick karma
#

Ohhhh you want individual items to have special names when you find them

robust briar
thick karma
#

(Sorry for ping)

bronze yoke
#
local metatable = __classmetatables[Literature.class]
local old_getName = metatable.getName
function metatable.getName(self)
    if Literacy.PlayerHasReadBook(getPlayer(), self) then
        return getText('IGUI_ReadIndicator', old_getName(self))
    end
    return old_getName(self)
end
robust briar
#

Yes

#

ooffff now thats what I call hack

thick karma
#

lit

#

goat

bronze yoke
#

the game fakes some item names (mushrooms showing as poisonous if you know but normal if you don't) but it's not something that's mod friendly to hook into

#

so this was my workaround

robust briar
#

Yeah, I can see what you did there

#

This is a "normal" item.

bronze yoke
#

also the benefit is that the name never gets changed so it's translation friendly

robust briar
#

that seems like a lot scary thing if a lot of people did that

#

like, one or two mods

bronze yoke
robust briar
#

but you chain like 10-20 mods all overriding that over and over you get call stacks 20 deep called 1000's times everytime an inventory is open

#

I wonder if I can add translations at runtime...

#

like "build" translations

bronze yoke
#

for what purpose?

robust briar
#

well, my item is a combination of two translations

#

name1 - name2

#

if I could just generate all possible name1 - name2 combinations

#

on client

bronze yoke
#

you can just do that in lua and store them somewhere, it could be wasteful of memory though

robust briar
#

Yeah... I suppose

#

back to the drawing board

#

I say we ditch all world languages, and every learns esperanto? Sound good?

#

no more i18n

drifting ore
#

internationalization is unavoidable

robust briar
#

iiiiiii knooooowwwwww but i can dream of a day that I don't have to worry bout it

drifting ore
#

different groups of people use different words and the diffusion is slow, so eventually they separate so far that they can no longer even understand each other

#

nowdays diffusion is wider, but not faster. It takes an entire generation of people to adopt a change.

bronze yoke
#

in this case it'd be optimal to do something likegetText("IGUI_Template", getText("IGUI_Prefix"), getText("IGUI_Suffix")) although i don't love the triple java call

robust briar
#

still would have to do that client side

bronze yoke
#

yeah

robust briar
bronze yoke
#

yeah, most likely

robust briar
#

Here goes nothin!

#

Damn! Didn't work

bronze yoke
#

try printing the item, it might not be a comboitem

robust briar
#

it is a comboitem, checked it in debugger, but...

#

Combo item is empty

#

it has like nothing in it

#

so maybe I need to override InventoryItem.class

bronze yoke
#

yeah i don't really know what the game even has these subclasses for, potentially a legacy feature

#

i don't think that works, lua metatables are created for each class individually even if they technically point to the same inherited methods

robust briar
#

๐Ÿ˜ญ

bronze yoke
#

so like InventoryItemMetatable.getName ~= ComboItemMetatable.getName even though they call the same method

#

(potentially at runtime the jvm would duplicate the methods anyway? no idea how it works internally)

robust briar
#

do you do the metatable override just in root, or in an event?

bronze yoke
#

just in root

robust briar
#

[31-07-24 22:28:01.327] LOG : General , 1722479281327> 714,268,793> WastelandMusicians: Patching ComboItem.getName.
[31-07-24 22:28:01.328] LOG : General , 1722479281328> 714,268,794> WastelandMusicians: ComboItem.getName not found.

#

so.. it the original getName doesn't exist

#
local metatable = __classmetatables[ComboItem.class]
local old_getName = metatable.getName
print("WastelandMusicians: Patching ComboItem.getName")
if not old_getName then
    print("WastelandMusicians: ComboItem.getName not found")
end
function metatable.getName(self)
    if self:getFullType() == "MOTW.SheetMusic" and self:getModData()["MOTW_Song"] then
        local song = MOTW_Core:getSong(self:getModData()["MOTW_Song"])
        if song then
            return getText("IGUI_InstrumentType_" .. song.instrumentType) .. "-" .. getText(song.name)
        end
    end
    return old_getName(self)
end
bronze yoke
#

huuh...

robust briar
#

Same thing for inventory item

#

weeiirrrddd

#

๐Ÿ˜•

bronze yoke
#

oh!!!

#

local metatable = __classmetatables[Literature.class].__index

robust briar
#

Oh lord haha

bronze yoke
#

i rewrote this section since last i tested it

robust briar
#

yup

#

there we go

#

<3

topaz tangle
#

today is truly a day, ive managed to get down to one issue with my mod!!!!!!!

copper bough
#

i got a bit of an issue theres an annoyingly persistent ISOregion on a particular map addon how do i make the purple (the one where the player is) go away it causes horrendous lighting issues and building detection issues

#

also is it possible to load existing workshop maps in world edit to fix them

topaz tangle
#

YOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO

jovial scaffold
#

the fleet

topaz tangle
#

YEA!

#

working on the new rust textures

#

i no no wana :(

#

in the morning i will i thnk

coarse sinew
#

<@&671452400221159444>

lost slate
#

โค๏ธ

thick karma
#

Has anyone ever seen a warning in logs that says "ZNet: workshop item 3198206479 is not installed"

#

Or whatever number

#

I am wondering what caues that state and how to reset it... No such id is referenced in any the normal directories afaik (ProjectZomboid/steamapps, Steam/steamapps/workshop, etc.)

bronze yoke
#

<@&671452400221159444>

lost slate
#

grrrr ty albion

topaz tangle
#

sooooo close to being done with my mod!

topaz tangle
#

i will hopefully be pushing it out today!!!!! just re-texturing left to do!

thick karma
topaz tangle
#

all the colors are done!!!

analog breach
#

Looking good

#

Planning on adding any other cars?

topaz tangle
#

i want to do more vehicles !!!
im going to release the c series on its own, then maybe add it to a bigger pack if i decide i want to do that!

#

now i have do to the difficuly textures, damaged and bloody

#

(the standalone release is mostly because i want a server im in to add it tbh)

robust briar
#

As always, so many new things learned along the way

topaz tangle
#

ai :(

robust briar
#

Hey, I am a programmer. I have zero art skills

bright fog
#

Me too ๐Ÿ˜Ž

topaz tangle
robust briar
robust briar
bright fog
blazing pond
#

hey wanted to ask if there's a guide on changing animations and the like?

i tried before but it's alot of trial and error

#

was able to change an animation just want it to be far less painful

#

and so far any animation guides are dead

#

atleast the links are

bright fog
#

Doesn't go too much into the detail, but it teaches some bits

blazing pond
#

have to reload the entire game each time for it to work it seems

mystic vessel
robust briar
mystic vessel
#

Also for playing as well

#

It's pretty fun to play with this

bright fog
#

The animation actually updates in real time

bright fog
mystic vessel
#

There will be 2 versions, one that is this one, and another with a subtler filter that is not as strong.

#

I need a name suggestion for the mod

#

I dont have any idea about it

tulip valve
#

Russo Mod

frozen ember
#

VHS Graphics type shit

topaz tangle
#

vhs screen overlay

bright fog
#

(for the name)

lofty monolith
#

hii, I have the text files of the folder ("mod\media\shared\Translate") of a mod translated into my language. I would like to create a mod in the workshop as a translation of that mod but I have never done anything like this or uploaded anything to the worshop, how or where can I start?

blazing pond
#

i did not know that

#

seemed to not work like that but i guess i was just doing it based on how other games are loading

mystic vessel
bright fog
blazing pond
#

that helps alot though and should hopefully help in actually adding animations

bright fog
#

AnimSets too can be updated in real time

blazing pond
#

all movement

#

although idk if even sleeping and sitting anims can too

#

oh wait sleeping anim is a mod but still sitting

blazing pond
#

figured i'd ask

#

i saw kate as an ender and was thinking it was separating

drifting ore
#

so apparently my UI is causing memory leakage

#

for simplicity's sake i update the window contents by clearing all children and filling it again

#

is this an issue, if these children contain their own children?

bronze yoke
#

it shouldn't be

drifting ore
#

well I have what's basically a "show all" button and each time I press it, it deletes the old containers and creates new ones which populate themselves with relevant categories. And each time I do that memory usage goes up by 50-100 megabytes. Until eventually the game just crashes.

#

"deletes" as in calls "removeChild" on the parent object and sets the reference table to {}

drifting ore
#

i'm using UI3Dmodel objects if that matters

blazing pond
# bright fog idk ngl

hey gonna ask here just incase you know if there's anyway to import x files besides 3dsmax

bleak portal
#

hi, how are you?
question, how usually you do mods? I mean with external programs, methodology, I'm new in modding and wanted to learn more about how to make 3D model interactive with code, like animations and more

bright fog
# blazing pond hey gonna ask here just incase you know if there's anyway to import x files besi...

To import .X files from PZ into Blender, you can use this addon which works in the latest versions of Blender (4.1, need confirmation for 4.2).
https://github.com/poikilos/io_import_x

Note that importing animations doesn't work this way and you have to use weird technics which involves FragMotion and will give you barely usable animations in Blender. (a guide is in #908614746071248916 in pinned)

DON'T EXPORT IN .X !!! EXPORT YOUR MODELS AND ANIMATIONS IN .FBX !

There is no point in using .X format, .FBX is way easier to use and widely used by everyone (but PZ dev :| ).

GitHub

Import/export .x files in Blender 3.0 (and some earlier versions). The Poikilos fork attempts to maintain compatibility with the latest stable Blender and allows install via GUI (Click "...

blazing pond
#

thanks chief

reef portal
#

where do i find documentation on native java methods for PZ?

bronze yoke
#

i'm sad to say you don't

#

you might be able to find resources for specific things, the modding page on the wiki should link to most

reef portal
#

ripperoni

thick karma
rigid mauve
#

If I'm making an item and I want to create a new tag, is it as simple as typing a tag name in it's "tags" field and then referencing it in lua, or do I need to declare/initialize the tag somewhere else as well?

agile vigil
#

Actually making progress on my bulk storage mod. The plan is to make all kinds of vanilla (and mod) objects capable of storing stuff in a compact way so they take up less space on shelves or world tiles, and you can really cram your kitchen / wardrobes full ๐Ÿ˜„

topaz tangle
#

Vehicles I would add to a vehicle pack if I decide to do one

reef portal
#

noob question: how do i get a characters name? I have the isoplayer object for the respective character.

#

.Surname? or?

#

hmm or GetUsername()

bleak portal
thick karma
fleet bridge
#

Or drainables?

agile vigil
bronze yoke
#

tags are literally just a list of strings attached to the item, they don't have any inherent functionality

drifting ore
#

hehe check it out

bright fog
#

An edit button in the sandbox options ?

drifting ore
#

yes

granite glade
#

How do you set it so that your mod says it requires another mod when you're downloading it?

granite glade
#

Thank you

dawn portal
#

does zomboid ui has a concept of containers? like ui elements that sort their children in a dynamic way? I come from a background of using ui libraries that support containers that for example allow you to dynamically sort children vertically or in a grid or at center etc.. or is it more like html where the sorting functionality is done by the ui elements themselves? I'm lost ๐Ÿฅฒ

grand wigeon
#

I have a mod im working on that boosts all traits except fitness/strenght, by +1 for 15points, +2 for 25 points, and +3 for 45points, just curious about peoples opinions for point balance, and if i should make all the traits so that you can only use 1 of the 3, or if i should keep it at able to grab all 3 for +6.

( I made the mod initially cause i tried making all my characters previoulsy with that intent of a xp boost on all skills, but it took crazy amount of points, so i just made this to make it eaier and simple)

lean flower
#

does any1 know a good mod that can be used only by admins?

drifting ore
#

zomboid windows don't even resize their contents automatically

#

web browsers's one and only job is displaying UI so they're good at it. Everything else basically just sucks. It's why even frickin OSes use web browser engines to display UI.

keen silo
#

Hey, I've been working on a dynamic body shape mod, And wanted to try making the changes be continuous (instead of discreet jumps). for that I used Shape Keys.

My question is if there is any posible way to import this into the game (either via animation adding bones, or anything)

topaz tangle
drifting ore
topaz tangle
#

true....

#

unfortinate it will probably be used to be mean

i may have to use it in a challenge mode though

drifting ore
#

(imagine looney tunes but revolving around people graphically committing sins for which they eventually went to hell to become the deadly sins, starting off with humans making anime catgirls real)

topaz tangle
#

i think i know what that is?

#

unsure

drifting ore
#

it's from the same guy who made The Screaming Barrel

past trout
#

Hello, comrades, maybe someone did a custom *Animation Event, please tell me how to implement it

*This is the event that is triggered when the animation is playing

Example :

<m_Events>
<m_EventName>CustomEvent</m_EventName>
<m_TimePc>0.1</m_TimePc>
<m_ParameterValue/>
</m_Events>

robust briar
#

My only issue is.. it takes until the next 10 minute tick for it to reset when leaving the zone

mellow frigate
#

that's nice, do you achieve that from lua ?

robust briar
#

100% lua

mellow frigate
#

awesome

robust briar
#

there is an "override" which you can set

mystic vessel
#

Good evening, could anyone answer a question for me?

robust briar
#

Ask away

mystic vessel
#

Well, this is a somewhat complicated topic, but I wanted to use crafting to remove the clothing penalties

#

I suppose this is not the way

#

In the original game there is a recipe, which identifies whether you have cotton clothing in your inventory and if so, you can tear it up.

Basically I wanted the game to do the same identification but not tear the clothes, and just remove the movement and combat debuffs

#

So much so that I put "keep" on it so it doesn't tear the clothes. But it also doesn't have the function of removing the debuff, which could be missing (I don't know anything about LUA, I'm learning now)

robust briar
#

hmm

#

I mean

#

at quick glance that could work

#

idk if runspeed and stuff stays with the item. I have found some things reset at restart and have to applied to the scriptitem and not the inventoryitem

#

I suppose, if you are running into that, you could do something with OnClothingUpdated and OnCreatePlayer

mystic vessel
robust briar
#

oh no, those are events

mystic vessel
#

Like I said I still don't understand lua so it's a bit confusing

mystic vessel
robust briar
#

and the wiki

bronze yoke
#

are you using a mod that fixes the speed penalties?

#

because they don't actually do anything in vanilla anyway

muted garnet
#

Please tell me if I understood correctly, the getNumActivePlayers method gets players who play from one screen (splitscreen), and getMaxActivePlayers gets all players on the server at the moment?

mystic vessel
mystic vessel
thick karma
#

Doesn't work in solo

grizzled fulcrum
muted garnet
#

thanks guys!

bronze yoke
#

it never goes down, except resetting to 1 when exiting the game

#

the only real consequence of this is that using it to loop through all players can cause errors since those players aren't guaranteed to exist

grizzled fulcrum
#

that is kinda misleading oof

grizzled fulcrum
bronze yoke
#

does it check for nil?

#

usually you want to do something like this to avoid errors:```lua
for i = 0, getNumActivePlayers() - 1 do
local player = getSpecificPlayer(i)
if player then
...
end
end

muted garnet
#

does you mean that getNumActivePlayers will output either 4 or 1?

#

players

bronze yoke
#

it can output 1, 2, 3, or 4, it's just that if a player leaves the count doesn't go down

#

also if they die i think there's a period where their object won't exist

#

usually doesn't matter because your code isn't going to be running when the only player on the client is dead but if there are also alive players it is an issue

grizzled fulcrum
#

I was talking about the java side

bronze yoke
#

no null checks?

grizzled fulcrum
#

not that I was aware of

#

I will check again

muted garnet
bronze yoke
#

if you're looping through other players then yeah it can be an issue

grizzled fulcrum
#

ok most places it does do null check

#

I just happened to view the code that didn't do null checks which is just coincidence I guess

#

there is a lot of places in IsoCell that dont do null check for IsoPlayer.numPlayers

muted garnet
bronze yoke
#

the example code is good because it checks if player before trying to use the object

bronze yoke
#

come to think of it i don't even know for a fact that you can actually drop out in splitscreen

#

the null checks might only be necessary because players might be dead

muted garnet
bronze yoke
#

if you have a player to call isAlive on you don't need to worry in the first place

bronze yoke
#

the isocell methods that don't null check are dealing with keeping chunks loaded and rendering, dead players can still see the area around them until their new character is finished

grizzled fulcrum
#

yes im dumb

reef portal
#

any ideas what calling :setNPC(true) does on a character?

grizzled fulcrum
#

It creates a new GameCharacterAIBrain for the IsoGameCharacter if it doesnt have one already, then sets IsoGameCharacter.isNPC to true

reef portal
#

I see

grizzled fulcrum
#

isNPC controls soem things like whether to use NPC defined stuff like IsoGameCharacter.NPCSetAiming() function

#

*in java

reef portal
#

interesting

#

Im working on a utility ai mod so this info is v helpful

grizzled fulcrum
#

but it's weird, because the AI stuff isn't used (or like doesn't seem to beu sed)

reef portal
#

yeah like its placeholder or smth for now

grizzled fulcrum
#

ya, literally most if not all of the AI functions are not used anywhere

reef portal
#

I have my ai spawning (as far as I know), but Im not sure they are actually defending themselves because I just find bodies lmao

#

also no threats found >:U

grizzled fulcrum
#

This is so weird now looking at it

bronze yoke
#

i didn't look at every reference but it seemed like it pretty much just disables input stuff

#

prevents a couple events that i guess are meant to be actual player only from being fired too

grizzled fulcrum
#

basically

#

like it checks if npc when the game character does WeaponHit/swing but

#

it's like pretty nothing burger

#

I don't see why we can't make NPCs in Lua, sure it would be difficult and I think the hardest part would be networking them

#

as long as you can spawn in an IsoGameCharacter then ya

bronze yoke
#

the problem is non-players Just Don't Render in multiplayer

#

most existing npc mods actually do work fine in multiplayer, you just... can't see them

grizzled fulcrum
#

whaat'

#

what stops them from rendering

bronze yoke
#

i've never really worked that out

grizzled fulcrum
#

I wonder if you could make an NPC a IsoPlayer somehow instead

bronze yoke
#

to my knowledge all existing npc mods use isoplayers

grizzled fulcrum
#

oof

bronze yoke
#

isogamecharacter is abstract anyway

grizzled fulcrum
#

I'd expect maybe it's because can't change how the npc sends packets or something

bronze yoke
#

and in general the structure is just kind of insane

grizzled fulcrum
#

like we can't do anything network related much on the lua side

bronze yoke
#

there is no meaningful separation between what should be in isogamecharacter and what should be in isoplayer

#

there's actually a class specifically meant for lua to be able to render skeletally animated character models! it crashes the game instantly if you use it :D

grizzled fulcrum
#

well that is anticlimactic..

bronze yoke
#

it inherits from IsoGameCharacter, IsoGameCharacter expects this.Moodles to be initialised by subclasses but this one doesn't, so it null pointers, panics and exits to main menu

grizzled fulcrum
#

what is tye class?

bronze yoke
#

IsoLuaMover

grizzled fulcrum
#

I couldn't find IsoLuaMover in the java, I found a reference to it in the Lua code but there is no actual definition of it I could find

bronze yoke
#

it definitely exists

#

your decompile may be incomplete

grizzled fulcrum
#

Possible, also I found ISBaseMover in lua but not IsoLuaMover

bronze yoke
#

it's meant to be a wrapper around IsoLuaMover

#

like they use for ui and timed actions

grizzled fulcrum
#

ISBaseMover does IsoLuaMover:new() but there seems no new function defined anywhere

bronze yoke
#

i'm looking at it now, and i've called these methods before

#

do you see the line exposing it?

grizzled fulcrum
#

I found it now

#

idk why idea just hid it lol

#

I reopen it and I can search it fine, sorry

bronze yoke
#

it intelligently detects when a class is useless and hides it to save your time

grizzled fulcrum
#

sarcasm or no sarcasm

bronze yoke
#

sarcasm

#

though with all the ai features they're adding ๐Ÿ˜ฐ

grizzled fulcrum
#

oh I see, so IsoLuaMover doesn't create Moodles for itself (IsoGameCharacter) and it doesn't like that

#

so theoretically if you could initialise that would it work?

bronze yoke
#

yeah, i recall not being able to find a way though

grizzled fulcrum
#

well even if I do, maybe it panics too early before I can

#

I have a small idea

bronze yoke
#

it only panics when you try to call a certain method, i don't remember which one

grizzled fulcrum
#

ok time to neglect my studies and find out if my idea is good or if I am schizophrenia

bronze yoke
#

good luck ๐Ÿ™

grizzled fulcrum
#

OnGameStart will be ok to create the luamover object right?

bronze yoke
#

should be!

grizzled fulcrum
#

because world is created and stuff

muted garnet
#

Can someone please explain to me why if I creating a context option name now takes an argument this way?

local option = context:addOption(getText("ContextMenu_Action" .. " " .. name), context, option, arg)

and it doesn't work that way, although in the game files this method works:

local option = context:addOption(getText("ContextMenu_Action", name), context, option, arg)
bronze yoke
#

they seem like they're doing two different things

#

the first one finds the translation string with the identifier resulting from "ContextMenu_Action" .. " " .. name, the second one finds the translation string with the identifier "ContextMenu_Action" and inserts name into it

muted garnet
#

even with the translation, only ContextMenu_Action showed up for me

grizzled fulcrum
#

in the top one, the translation key you are passing is effectively "ContextMenu_Action test" assuming name = "test"

#

in the bottom one, the translation key you are passing is "ContextMenu_Action" and name is a formatting arg that you are passing to getText

#

so if ContextMenu_Action = "This is a test and name is %1" and name = "test" then getText will return This is a test and name is test

#

I basically just regurgitated what albion said but tried to explain it more (if that even helped idfk)

#

so im calling IsoLuaMover:setX(player:getX()) and all that and I try call IsoLuaMover:playBloodSplatterSound(). No errors but I don't hear the sound and don't see the mover at my location

#

I'd only assume I need to call the render func myself or something

bronze yoke
#

maybe try that, i remember not calling it because it expected a Shader argument but it doesn't even use it so nil should be fine

#

however since it expects a Shader it's somewhat likely that it's meant to be called by the renderer and calling it manually won't actually render anything

#

i think the crash occurs when you addToWorld(), that causes the update function to start running which i think was the one that crashes

#

but that was my bet on how to get it to start rendering properly

grizzled fulcrum
#

Is there a debug option to display player coordinates

#

I really hate printing them to the console every single time

bronze yoke
#

i can swear i've seen coordinates drawing to one of the corners of the screen but i have no idea

grizzled fulcrum
#

ikr I have seen it up the top left near the fps counter but it was on a modded server

#

It might jsut be a mod?

bronze yoke
#

it must be... ๐Ÿ˜”

acoustic stratus
#

anyone here make a TrueMusic addon?

#

or... does anyone know what image(name) i need, to change the preview image for a mod?

#

the "your preview here"

grizzled fulcrum
#

look at how example mod does it or anotehr mod

#

Unless truemusic has a specific file you need to override or something, then idk

#

albion I am calling render perfectly fine no errors, but one problem is I cannot see the mover sobwhy

#
function events.on_render_tick()
    if events.mover ~= nil then
        logger:debug("Rendering IsoLuaMover!")

        local player = getPlayer()
        events.mover:render(player:getX(), player:getY(), player:getZ(), events.mover_col_info, false, false, nil)
    end
end

[...]

Events.OnRenderTick.Add(events.on_render_tick)
bronze yoke
#

yeah, i didn't think it would do anything, it's probably meant to be called by the renderer only

grizzled fulcrum
#

it's literally just not there lol

#

So now I've got a IsoLuaMover and I cannot see if it's actually working, but calling mover:getX() is correct location

bronze yoke
#

adding to world would probably add it to whatever list the renderer draws from, but then the game crashes

#

or at least that's what i think caused the crash

acoustic stratus
grizzled fulcrum
bronze yoke
#

but no moodle crash...?

grizzled fulcrum
#

nop 0_0

#

I do just these:

-- Call some stufffff
mover:setX(player_x)
mover:setY(player_y)
mover:setZ(player_z)
logger:debug("Set mover to:\nX=%s\nY=%s\nZ=%s",
    tostring(mover:getX()),
    tostring(mover:getY()),
    tostring(mover:getZ()))

mover:addToWorld()
mover:playBloodSplatterSound()
bronze yoke
#

ok, i'm gonna get in debug and see if i can get it to crash again

#

it was quite a long time ago, all i remember is that moodles was the reason

grizzled fulcrum
#

I do not see it at the location and I do not hear the splatter

#

maybe its because its onGamestart

#

I will use a keybind callback to see if it works triggering it later

bronze yoke
#

i think i was just using the debug console the whole time

#

yeah, okay it's getCell():addMovingObject(mover) that crashes

#

i was trying that because that's what ISBaseMover does

grizzled fulcrum
#

so that will add the mover to the cell the player is in?

#

I will try it

bronze yoke
#

it just adds it to the global moving object list, but it crashes the game

#

something in IsoGameCharacter.updateInternal is not prepared for Moodles to be null

#

oh you're kidding

#

it crashes because of unused crap

grizzled fulcrum
#

wait so it's not moodles that crashes?

#

or it does, but not related

bronze yoke
#

it's because Moodles is null

#

there's no null check before it does this

#

but the only reason this code exists is to update sanity, which doesn't do anything

grizzled fulcrum
#

o

#

lol

#

ok I called addMovingObject and instead of crashing to menu the process died

bronze yoke
#

๐Ÿ˜จ

grizzled fulcrum
#

If there was a setMoodles() func for the mover this would easily be fixed

#

but noo

#

have a getMoodles() but no setMoodles

bronze yoke
#

i tried to do some stuff with reflection to see if i could set it but i just noticed Moodles is final anyway

grizzled fulcrum
#

OOF you are right

#

ok there's no way my thing is working if that is the case

bronze yoke
#

sad...

#

this would be a really cool thing to let us do, it looks like it was intended for animals so it'll probably be either fixed or replaced in b42

grizzled fulcrum
#

I mean if we could somehow prevent IsoGameCharacter.update from running then it is ok right

#

nvm even if the pcall errors it still does update

#

im just abandoning this

bronze yoke
#

yeah, i don't think it's possible sadly

#

frustrating that it's really just one step away

grizzled fulcrum
#

yeah im thinking "if only I was employed by TIS I could fix all these issues" but then that's saying they haven't already fixed these issues for the new update

vast flint
#

hey what is the survivor and isNPC stuff in the game code ?

grizzled fulcrum
#

not sure about survivor but isNPC is a whole nothingburger, most of it is placeholder and is seemingly unfinished (note GameCharacterAIBrain or whatever the class is)

vast flint
#

there is even a survivor creation thing so survivor dont seem like it's a player

bronze yoke
#

survivors are used for the main menu character preview

#

a lot of older code refers to human characters in general as survivors

vast flint
#

sorry I was stuck loading the game but thanks !!

#

also I dont understand how the map works like, is it possible to know Im on a road, on a vehicle scene, can you path to distant roads, can you know what distant map looks like (I heard the map has cells and chunks and the code can only see nearby cells/current chunk??)

vast flint
bronze yoke
#

IsoGameCharacter is an abstract base class for characters, it isn't its own thing

#

IsoSurvivor is used for the character preview in character creation (though from discussion with other modders it seems like it's redundant even there), IsoLivingCharacter is a base class for living humans which is also largely redundant

#

99% of human functionality is packed into IsoPlayer

bronze yoke
vast flint
#

I see. Can I outline what I would need to know what could help my goal ? Im trying to do a mod but I dont know to start. 1- Im not sure where to look for a vehicle radial menu, V option to select a vehicle as an AI follower 2- Im not sure how to detect that Im on a road and the road comings up in the current cell so I could prioritize following the road rather than the guide vehicle the player drive. 3- Id need some sort of very dump human-looking driver for those ai vehicles that I can dress up and who can optionally shoot 4- I dont know how to detect if the vehicle is towing something, the guide vehicle could be an AI (to be able to form convoys of 10-20 cars)

#

ie: the guide vehicle would provide the waypoints for pathing, the only goal is for the AI to follow them if the lead vehicle is above X where X is the lead distance. SO if you say 10m and there is 3 nodes every 5m it would follow you 2 node vehind

#

So far I have these thing in my notes: getTowedVehicleID / sendTowing / getVehicleTowedBy / BaseVehicle / CarController . It seems like just simulating it by towing is a bad idea, and Id need to keep a list of all the ids of the vehicle in the convoy in a list

#

I also tried to find what manage the cruise speed but I couldn't. This could help to saves fps by using cruise when the player keep going straight in nodes/to follow the nodes at says 30mph to save fps/avoid crashing

#

as far as being able to do that --- farming simulator has no AI at all just like zomboid, yet this was able to be done with less than 1000 lines of codes and no external A* dll in a mod and this include seeing the driver/being unable to get in driver position

bronze yoke
#

i don't really know if it's reliable enough for this but there's a special foraging zone for roads

#

the biggest problem though is i don't think you can even control cars from lua

vast flint
#

not really a problem there are java mods on the workshop like betterfps

#

also lua is interpreted like 1980 gwbasic so I doubt it would be fast enough for anything AI (that's the mistake pzns and superb makes imho rather than using c++ native from java)

#

I expected that lua might only be useful for the frontend to set up the follow thing / convoy from a UI

#

like telling the following cars to be offset 10m back, 1m to the left to not get stuck into 4-width garage doors like when towing

#

also it's not fully self-driving it's just following very close nodes from the player driving and removing them as it pass over so it just imitates the player driving in a way

bronze yoke
#

oh, well, you can do whatever you want with java, yeah, it's just not really the common route

vast flint
bronze yoke
#

the in-game map uses some information baked during the map compiling process

#

that data may be more helpful

grizzled fulcrum
#

Random question but I'm just laying in bed and thought about properly reversing LightingJNI code and thought 'what does the JNI in LightingJNI mean?'. If anyone knows please lmk. I thought it might have something to do with like java interface but I've got no solid idea.

vast flint
#

JNI means it uses native code, like when above I mention using C++ to make the AI faster that is what I meant

#

where as java normally compile precompiled bytecode to a final platform specific .exe in memory / native code

reef portal
#

yeah I kinda think my AI mod is dead in the water if npcs don't show up in MP

reef portal
#

I wonder if PZNS works in mp, hm

drifting ore
reef portal
#

nah, Im working on my own ai mod

drifting ore
#

what mod is it?

reef portal
#

UtilityZ which is a utility ai mod that uses scores to determine behaviour

drifting ore
#

aight

reef portal
#

say ur hunger score is low, but ur fear score is high, youll probably decide to run away until your fear score lowers

#

its simple but robust

reef portal
#

the real trick is figuring out the actual native methods needed to bring about the desired behaviour

#

I have the npc spawning down, now to figure out idling and pathing about

reef portal
#

hmm for some reason the npc will attack the zombie but will just clip thru it?

#

i wonder what I have to set to enable collision

granite glade
#

Is there a specific modding discord? Im looking for help with making a mod edit for personal use and generally better understanding code.

granite glade
#

appreciated

tranquil reef
#

How can I stop a zombie from being able to be shoved over

thick karma
#

Idk beyond that

torpid compass
#

Is there any way to prevent vehicles from fading out when the line of sight is blocked?

bright fog
thick karma
#

Hmm maybe there's a flag then?

#

Yeah I don't see anything

drifting ore
#

I can't get UI to register key events. I've added ui:onKeyPress(key) and called self:setWantKeyEvents(true) but the event handler is never triggered.

#

well specifically i'm trying to add keyboard shortcuts for UI buttons

hollow current
#

@drifting ore I haven't personally worked with keyboard shortcuts all that much, but, if you're trying to trigger certain UI functions while the UI instance is active, why not use OnKeyPressed event?

#
function OnKeyPressed(key)
  if myUI.instance then
    print(key)
  end
end

Events.OnKeyPressed.Add(OnKeyPressed)```
#

idk if the event is intended to be used with UIs though

drifting ore
#

global event would work but i'd need to manually keep track of which elements are consuming the events or not and it'll become a huge mess in no time flat. You can just imagine how it would go when you have multiple windows with multiple text entry boxes.

#

UI code has this all handled already, I just can't configure it properly.

lapis stone
#

does anybody know how to change textures on objects? like tvs, paintings

bronze yoke
#

i think the event only fires for 'root level' ui elements added to the ui manager directly

#

if that's any help

lapis stone
#

not really ๐Ÿ™‚

drifting ore
grizzled fulcrum
lapis stone
#

there are no textures for the tv

#

i'm talking about the animation for the tv

drifting ore
#

it's probably in the pack

lapis stone
#

how do i open it?

#

i can't even make a pack file

#

either i don't know how to use tilezed or it is broken

#

because when i try to place something it doesn't show on the grid, however it shows on the minimap

grizzled fulcrum
#

In the menu bar there's a dropdown that lets you open pack

#

or view pack or something

stray owl
#

New to PZ mod development and coming across some confusion with variables and scopes. Is there a way to store the current player into a global variable I can access from different functions throughout a file? I need the player data stored to work in both Solo and Multiplayer.

bronze yoke
#

local variables will be available to all scopes below them, so you can declare a local outside of any functions, loops etc if you want to access it throughout the entire file

#

variables that aren't explicitly declared as local are global by default (accessible to all files) but it's recommended to literally never use globals if possible

#

in your case it's easier to just call getPlayer() whenever you need to access the player, but you can cache it doing something like this:```lua
local player
Events.OnCreatePlayer.Add(function(_, playerObject)
player = playerObject
end)

function myFunc()
-- do stuff with player
end

drifting ore
#

besides polluting global namespace, you run the risk of overriding someone else's globals and destroying their mod or in some cases core PZ functionality

#

globals are necessary to use if you specifically want to expose your data to everyone. But same caveats apply.

bronze yoke
#

they're not necessary to use

stray owl
#

Right when I said global I should have mentioned I'd still be using it as local just be outside the functions.

bronze yoke
#

the only situation you should be using globals is for certain java systems that look for globals, otherwise globals are 100% avoidable

drifting ore
#

technically yeah but i'm not gonna split hairs over require globally_available_moddata vs globally_available_moddata = {}

#

it's effectively the same

bronze yoke
#

the global method is slower, still pollutes the namespace (even if only by a little bit), still risks name conflicts, etc

#

modules are preferred for a reason

stray owl
#

If I use the getPlayer() will that be an issue in a server game at all? I've seen there's another way by using the index of the player that's online but wasn't sure if that was a required method for a server to get the correct player

bronze yoke
#

if your code is running on the server then you're asking a much more complicated question

bronze yoke
thick karma
tacit carbon
#

hey guys, what are the parameters of context:addOptions()?

thick karma
#

getSpecificPlayer(index) is for respecting splitscreen @stray owl

bronze yoke
#

most code concerning players can run client side fine so i'd stick to that if possible, depends on what your mod is actually doing

stray owl
thick karma
#

Not if you are unconcerned about splitscreen, and not if the code is running on a client connected to the server

#

Serverside it would not work afaik

#

I imagine it would be meaningless or misleading even if it did

bronze yoke
#

both return nil on the server, it has no concept of local players

thick karma
#

Figured

bronze yoke
#

if your code has to run on the server you'd most likely either wait for an event or command that passes a player to trigger it or you'd loop through getOnlinePlayers()

stray owl
#

Currently I've configured it to loop through getNumActivePlayer() which gives me the index of the player and then sets variables based on that player but I can't figure out getting that data to be useful outside the function that i'm running to loop threw the players.

bronze yoke
#

getNumActivePlayers() returns the current number of splitscreen players

#

the getPlayer() getSpecificPlayer(index) getNumActivePlayers() etc methods only care about people playing on that client

tacit carbon
grizzled fulcrum
#

Name is the translation string of the option, the target is the target to add it to (like if you are adding it to WorldObjectContextMenu, then the target would be an IsoObject), onSelect is the callback for when the user selects the entry and param1, param2 etc are params sent to the callback

tacit carbon
grizzled fulcrum
#

so the target would be an InventoryItem I think

tacit carbon
#

ah, so param are the parameters for the select?

grizzled fulcrum
#

yes

tacit carbon
#

okay thanks

grizzled fulcrum
#

they are optional

bronze yoke
#

oh, target is a bit of a misleading name

#

it's just the first parameter sent to the callback you gave it

grizzled fulcrum
#

I thought it had some alternate meaning apart from also being the first param ;-;

#

plus why would target be before the callback lol its so weird

bronze yoke
#

you'd think the special name and weird placement would mean it does something special and important ๐Ÿ˜ญ

tacit carbon
# grizzled fulcrum they are optional

what is happening is that I want to have an option to add an enchantment to a weapon, but if I have multiple weapons in my inventory, it shows one for each weapon I have on me, how do I make it appear only one for the respective item?

bronze yoke
#

my guess is they made addOption(name, target, onSelect) first, realised they needed more arguments and didn't want to make a breaking change

tacit carbon
#

the issue im having is how do I add this to a specific item, because it is adding the options to every item in my inventory for some reason

bronze yoke
#

could you show your code?

tacit carbon
#

how do i send code in discord again?

bronze yoke
#

surround it like this: ```lua
your code
```

tacit carbon
#

local function addEnchantment(weapon, player)
    weapon:setDisplayName(player:getDisplayName().."'s "..weapon:getDisplayName())
    player:getModData().LevelUp_enchantedWeapon = weapon:getDisplayName()
    player:getModData().LevelUp_currentXP = 0
end


local function addContext(player, context, items)
    local playerObj = getSpecificPlayer(player)
    local inventory = playerObj:getInventory():getItems()
    for i=1, inventory:size() do
        local item = inventory:get(i-1)
        if item:getCategory() == "Weapon" then
                context:addOption(getText("UI_Enchant"), item , addEnchantment, playerObj)
        end
    end
end

Events.OnFillInventoryObjectContextMenu.Add(addContext)

#

ignore the lua lmao

bronze yoke
#

yeah, you're looping through the player's inventory looking for valid weapons instead of checking which item they actually selected - you can get which item they clicked with this snippet:

local primaryItem
if instanceof(items[1], "InventoryItem") then
    primaryItem = items[1]
else
    primaryItem = items[1].items[1]
end
#

something like this might work:```lua
local function addContext(player, context, items)
local primaryItem
if instanceof(items[1], "InventoryItem") then
primaryItem = items[1]
else
primaryItem = items[1].items[1]
end

if primaryItem:getCategory() == "Weapon" then
    context:addOption(getText("UI_Enchant"), primaryItem, addEnchantment, playerObj)
end

end

tacit carbon
#

ohhh nice, Ill try, thank you very much

graceful fern
#

Hi everyone, I have a quick question, i've my global mod data stored in GameTime():getInstance():getModData and works pretty well in SP, but when I start debugging it for hosted MP I use it in server-side. First it works well but when I reload the world all that modData is not saved. Is that normal or I missed something?

bronze yoke
#

that's not normal

#

you shouldn't use GameTime's mod data anymore though, it's a legacy feature

#

look at the ModData class instead, it's intended for this kind of thing

drifting ore
#

me bashing my head against the wall thinking why won't my translation file work

#

when PZ only looks for translations in the hardcoded set of file names

#

๐Ÿคฆ

verbal yew
#

guys, how to write code to show tooltip with full type item?

#

I'm being stupid

thick temple
#

Sup, is there any kind of documentation about modding?

thick karma
#

I pinged him into them

stray owl
#

So I did some more testing last night and still no luck. I just need my mod to get the data from the individual players of the server for example a player joins my server and is running around playing with others. I need the mod to only trigger events on that player based on there personal stats etc. I know it's probably got to be the most simplest things and most mods probably do this but I'm just having no luck with getting it to work.

red tiger
#

Dumping a thought here:

#

The zombie.ui.* API should take into consideration passing an AngelCodeFont argument alongside UIFont so custom fonts can be more readily used in mods, instead of overriding the UIFont enum values when loading mods.

#

Reasoning: Access to the current ISUI font-rendering API. With custom fonts, AngelCodeFont API has to be used manually inside of the render thread-executed code.

#

It's fairly easy to create AngelCodeFonts.

#
mod = LuaManager.GlobalObject.getModInfoByID('pymod')
modDir = mod.getDir()
self.font = AngelCodeFont(
    modDir + '/media/fonts/daggersquare.fnt',
    modDir + '/media/fonts/daggersquare_0.png')
# ..
font.drawString(x, y, text, red, green, blue, alpha)
#

There's the files for anyone who wants to test / use this font.

#

I'll be making a tutorial for all of this since it seems like this part of the game's exposed API isn't known or fully understood.

red tiger
#

Surprised to see no reply or messages since my post right before heading to work. =/

#

I might be the only one with an opinion on this lol

zenith lava
#

I wanna try and look at a map's loot table setup, is there a way to do that?

#

Because I got all of about piss all in a police station, 3 boxes of ammo and a gun a zombie had. I'm not on apocalypse, and I want to figure out why the map maker had it so the police armory had clothes in it.

thick karma
#

I think people interested in font stuff are probably just few and far between

#

Personally I was annoyed by the lack of a largish font with even-height numbers when I was writing Position Breakdown

#

All the numbers in most PZ fonts go up and down in a way that looks dumb to me lol and doesn't make text look properly balanced vertically

#

You're not entirely alone but I will admit it's sometimes hard to see you from here. ๐Ÿ˜‰

topaz tangle
#

its done

ended up naming it C-series Ford cabover on steam

analog breach
#

Shit bet

#

I'll look at it

grizzled fulcrum
#

I've got a timed action that I transfer the item that is used from a backpack (I search inventory recursively) to the main character inventory, should I do this transferring to and from the backpack inside the action itself in perform() and stop() or in the place where I add the timed action to the queue?

#

Also, is there any way to get the lua extension to recognise what the type is after an if statement checking the type like in the image attached, or is it purely static??

bronze yoke
bronze yoke
grizzled fulcrum
#

wth that exists

bronze yoke
#

unfortunately widening casts from functions like instanceof doesn't seem to really be something on luacats' roadmap

grizzled fulcrum
#

I've literally been doing like

--- @type myType
self = self
``` for the LONGEST time
grizzled fulcrum
bronze yoke
#

it's just not an implemented feature

grizzled fulcrum
#

I am unsure if lua natively has instanceof

bronze yoke
#

yeah it's a pz thing

#

most environments do have something similar but apparently it's very difficult to implement in the language server

grizzled fulcrum
#

I just do this and it work fine ty

#

I see that this works too, but I guess it's not checking for parent class like instanceof does right

bronze yoke
#

oh, that works?

grizzled fulcrum
#

yes but its not the same right

bronze yoke
#

if it doesn't check parent class that's a pretty handy option

grizzled fulcrum
#

Unless it just returns a table because lua doesn't actually know what IsoObject is but only the primitives

#

I will test

bronze yoke
#

in regular lua you'd expect to see userdata from this but i know pz mostly obscures that

grizzled fulcrum
#

it is just userdata ๐Ÿ˜ฆ

bronze yoke
#

a shame...

grizzled fulcrum
#

I have idea

#

ok its kinda messy but this technically works

--- @param obj IsoObject
--- @return string type
local function getType(obj)
    return obj:toString():trim():match("%a+%.%a+%.(%a+)@%x+")
end

--- @type IsoPlayer|IsoObject as long as it inherits IsoObject in some way
local obj = getPlayer()
if getType(obj) == "IsoPlayer" then
    print("It's a player!")
end
#

though I don't think I can recommend it lol

#

I mean I guess it doesn't technically check for parent class like instanceof and it actually gets the Java class type unlike Lua's type(v) but it should probably only be used for that specific purpose because why wouldn't you just use instanceof in literally all the other cases

#

I edited to a func so its more elegant but thats the best I could think of to achive it lol

bronze yoke
#

in an unreleased update for accessible fields i build a map of metatables to typenames at load time and use getmetatable to determine what class an object is

grizzled fulcrum
#

sounds interesting

bronze yoke
#

i didn't really consider this much simpler solution but it already has to traverse the metatables for its main functions so it made sense to do it that way

lapis stone
#

can someone tell me what is "WeaponSprite"?

jolly fulcrum
lapis stone
#

Like the 3d blender item?

jolly fulcrum
# lapis stone Like the 3d blender item?

it's the model block in your scripts file.

e.g. Saucepan has WeaponSprite = SaucePan
Which I think points to the below

    model SaucePan
    {
        mesh = Weapons/1Handed/SaucePan,

        attachment world
        {
            offset = -0.0490 0.1370 -0.0490,
            rotate = 0.0000 -45.0000 0.0000,
        }
    }
grizzled fable
#

hi, someone knows the lua file that manage the wrecked car salvage/dismantle in vanilla? ty

jolly fulcrum
thick karma
grizzled fable
#

tyvm

grizzled fulcrum
#

Is there literally any reason why multiple mods have to use multiple of their own custom UIs for moodles when the game's one already exists

#

Like it infuriates me genuinely even though it shouldn't

thick karma
bright fog
#

(what?)

bright fog
#

But there's some limitations to adding your own I believe

grizzled fulcrum
grizzled fulcrum
bright fog
#

No the game

sour island
#

The base game's traits, skills, professions, and moodle systems are some of the oldest systems, and I feel like have those that have modding APIs were implemented after the fact and one at a time for each

severe crane
#

I threw a mod together quickly for my server, just to add a number of currency options for us, but when I loaded it onto the dedi after checking it worked in local host (no issues) it proceeded to essentially nuke the server, to the point where people no longer showed up on admin map / deleted key rings etc.
I followed a guide, so I have no idea how such a tiny mod managed to screw everything up so bad? Could anyone with free time have a look over my work to see where I've gone wrong so badly?

severe crane
#

Isn't this for making mods? and the other one is for end user support?

bright fog
#

mod support is for help regarding mod issues that users have

severe crane
#

yeah its my mod, I made the mod

sour island
bright fog
sour island
#

Any errors?

severe crane
#

When looking through the server debug log, it shows errors for a couple other mods but nothing that would/should indicate it deleting keys, stopping admin map from working etc.

sour island
#

And if you remove the mod the problems go away?

severe crane
#

Yeah

#

Everything is peachy now

#

second I add my mod, all goes to shit

#

Just fetching the dumpfile from local host quickly

severe crane
# sour island And if you remove the mod the problems go away?

[05-08-24 18:59:29.112] LOG : Mod , 1722880769112> 170,261,005> mod "BluegrasssCW1" overrides media/scripts/newitems.txt.

Have I biffed up inheritance somewhere and this is causing the issue? Because there's a base file called newitems.txt in media/scripts for PZ?

#

I don't think in any of the logs I've seen that message for other mods.

bronze yoke
#

if you use the same filename as a vanilla file, you override that file

#

which in this case deletes nearly every item in the game

severe crane
#

fml I had no idea there was a newitems file until I looked a second ago

bronze yoke
#

name your file something unique to your mod e.g. MyMod_items.txt or MyMod/items.txt

severe crane
#

lesson learned.

sour island
#

Sorry stepped away, glad you figured it out.

severe crane
#

If I hadn't gone through the steps to get a log, I wouldn't of figured it out, so thank you for offering insight ๐Ÿ™

echo lark
#

is it bad to save a .txt file to the server to use as a "backup" for something? kind of like how the vahallla vehicle claim saves the car claims?
Im making a welcome package mod and using a folder to keep track of who got a welcome package. Each username gets their own .txt file in the folder. but i realised that folder could quickly creep up to like 600-1k+ files. would that be bad for the server in general?

woven wren
#

Hey so I'm currently making an True Music mod and I have already added the music but I was wondering if you had to delete the mp3 files after the OGG files are created?

bright fog
#

You only need one music file

woven wren
bright fog
#

I'm not familiar with True Music tho

twin locust
#

Iโ€™m pretty sure the mp3 is redundant

thick karma
#

True Music uses the oggs in game

woven wren
thick karma
# woven wren Gotcha

If you DM me when you're done I'll look over your setup before you Workshop it

#

Or you can post unlisted and I'll review it

tacit carbon
#

hey! how can I know who killed a zombie and with which weapon? do I use OnZombieDead()?

grizzled fulcrum
#

you can use OnZombieDead but that will call for every zombie, so if you don't want that you'll have to check against that

grizzled fulcrum
#

I guess IsoZombie.lastPlayerHit might help you get the person who killed the zombie I guess?? (its player index)

#

Though there is this too, idk if it useful

#

maybe you could somehow pair that with OnZombieDead

muted garnet
#

Please tell me the method for forcibly lifting the character from the ground during TimedAction and is it possible in the faceThisObject(object) method to calculate the object by coordinates or is there a more precise method of determination?

thick karma
#

I know player:getLastTargettedBy() works in the opposite direction

grizzled fulcrum
thick karma
grizzled fulcrum
#

does lastPlayerHit even work? I think it would be more reliable if it does because the last person that hits a zombie is usually the one to kill it whereas targeting may switch between players before it dies?

#

Like if you sneak attack a zombie and it's targeting doesn't switch to the player that attacked it, does it become nil or does it refer to the last player that hit the zombie (possibly far away)?

drifting ore
#

i don't htink that's a thing

#

lastplayerhit is set in the same function that triggers the onhitzombie event

#

that said this only appears to trigger in online game, otherwise it's -1

lilac idol
#

give more mods

#

or ill shoot a man

tacit carbon
#

I dont know if it its working

#

I think it is just for zombies

tacit carbon
#

I tried it to check if the player was the last person to hit it to get the kill but it isnt working

drifting ore
#

i couldn't find zombies using setLastTargetted to player but i didn't look very hard

tacit carbon
#

all of them returns IsoZombie

#

Ive made a bad work around that doesnt work all the time to count kills, if anyone has any idea how I can do that please let me know

drifting ore
#

setTargettedBy only accepts IsoZombie and it stores the value as IsoZombie. Which I don't think is compatible with IsoPlayer since it's in a different inheritance branch

#

then again my OOP is super rusty so maybe you can cast it so it accepts this anyway

#

but that would require downcasting IsoPlayer to IsoLivingCharacter or lower, and then upcasting to IsoZombie

#

and I have an inkling that it's not a thing in Java

grizzled fulcrum
#

I don't think you can cast java types in lua at all

#

well not explicitly

drifting ore
#

getAttackedBy might work. It works in IsoGameCharacter level.

#

particularly, this is set when the character dies

tacit carbon
#

you think this might work for zombies attacked by players?

grizzled fulcrum
#

also im wrong, lastPlayerHit isn't even exposed to lua at all

tacit carbon
#

because from what I see here it is on players

grizzled fulcrum
tacit carbon
#

does zombie have isoGameCharacter methods?

#

ok

grizzled fulcrum
#

yes

tacit carbon
#

ill try

#

thanks

#

it worked thank you so much

#

its being a bit inconsistent tho, for some reason sometimes it doesnt count

grizzled fulcrum
#

Do you notice any patterns to when it counts and when it does not?

tacit carbon
#

actually it was spawned zombies from the admin tools that werent counting

#

some of them werent counting

#

but random zombies from map were

#

can I use math.floor() in lua?

#

Im getting mixed answers in the internet

thick karma
drifting ore
grizzled fulcrum
#

Has anyone actually tested the speeds of all the math functions in PZ?

#

I know someone tested math.pow which is slow but if not I will test those myself in due time

muted garnet
#

Please tell me the method for forcibly lifting the character from the ground during TimedAction and is it possible in the faceThisObject(object) method to calculate the object by coordinates or is there a more precise method of determination?

bronze yoke
#

insanely slow

#

@ the math functions question

#

most of them are equivalent to one line of code anyway so just write them out when your code is performance sensitive

grizzled fulcrum
#

like get an object based on it's xyz?

muted garnet
warm hemlock
#

I got no idea how to mod but I need to make a mod that lets me change the percentage of being bitten, scratched, and lacerated

#

or atleast know what file to change

grizzled fulcrum
#

vector2 being the IsoGameCharacter.getTempo()

muted garnet
#

so this method already receives x and y of the object?

grizzled fulcrum
#

vector2.x is not the object x, and this.getX() is the player's X

#

so not really

#

I am unsure myself on how this code works

#

It seems object.getFacingPosition(vec2) uses the object's X and Y

#

but this is the X and Y of the grid square I just realised

bronze yoke
#

most objects don't have a sub-tile position

grizzled fulcrum
#

I was just about to ask if an object can even be misaligned from a grid square

bronze yoke
#

only like, moving objects, world inventory items, etc do

muted garnet
#

thanks, can you pls also tell me how to force the sitting player to stand during animation, without stopping this animation?

grizzled fulcrum
#

I have no idea at all

#

is there like a vanilla game action that does this??

grizzled fulcrum
tacit carbon
grizzled fulcrum
#

I was thinking combining events OnZombieHit and OnZombieDeath and that would work all the time (or should in theory)

quiet fulcrum
#

hey, I have the following:

local function OnPlayerUpdate(player)
    print("OnPlayerUpdate START")

    player:setHealth(100)
    player:getBodyDamage():setInfectionLevel(0)
    player:getBodyDamage():setOverallBodyHealth(100)

    local bodyParts = player:getBodyDamage():getBodyParts()
    for i = 0, BodyPartType.ToIndex(BodyPartType.MAX) - 1 do
        local bodyPart = bodyParts:get(i)

        bodyPart:RestoreToFullHealth()
    end

    print("OnPlayerUpdate END")
end

Events.OnPlayerUpdate.Add(OnPlayerUpdate)

In the health menu, all my bodyparts are full health. My characters health constantly stays at 100 but eventually, with enough zombie attacks, they die (despite still having 100 health). Purely for the sake of understanding the health/death system, I'm just trying to make my character unkillable through code. What stat or mechanic am I overlooking that is causing their death?

drifting ore
#

isDead can return true if either character health is at 0 or the bodydamage health (which is separate from that) is at 0

#

to start with I would change the iteration definition to for i = 0, bodyParts:size() - 1 do

#

it seems unlikely that your version would cause an off by one error, but this is a more direct way to do this

#

or it could be that the way you do this, it doesn't triggers bodyDamage health recalculation so it's allowed to deplete despite you resetting limb health

#

you can try overriding it with setOverallBodyHealth

quiet fulcrum
#

I thought I covered the character, overallbodydamage and individual bodypart healths in that code, something else is "killing" my character but actually it's a sort of death state but not actually dead. The UI changes to having the New Character button (no Quit button though unlike normal) and the normal moodlets are still showing on the side. Interestingly, when exit the game and come back, my character is fine

thick karma
#

Oh wait what

quiet fulcrum
thick karma
#

You appear to die, rejoin, and are not dead?

quiet fulcrum
#

not even the death moodle

thick karma
#

๐Ÿค”

quiet fulcrum
#

the character "dies" as in drops to the floor, UI changes so only "New Character" button is shown but no other UI buttons. Quitting and rejoining has a seemingly fine live same character again

#

during that "death" state, sometimes the character gets up but I cannot move or anything

#

I gotta pop out for 10-15, will revist this in a bit

drifting ore
#

try using restoreToFullHealth on bodyDamage as well as limbs

#

well actually calling getBodyDamage():RestoreToFullHealth() would internally reset all bodyparts to full health too

#

also pardon me for suggesting using setOverallBodyHealth even though you literally already do exactly that. I'm very tired.

quiet fulcrum
#

no worries, definitely seems like there is another mechanic at work that is causing the UI to think the character is dead when the engine doesn't

thick karma
#

Did you try using player:getBodyDamage():RestoreToFullHealth() out of curiosity? I haven't checked the Java but perhaps there is something it checks that you're missing.

drifting ore
#

player:setHealthCheat(true) might work if the object is to simply become invincible

twin locust
#

My approach would be, getSpecificPlayer(0), getStats(), getBodyDamage(), set all individual stats appriopriately (example: setHunger(0), but setSanity(1) etc). Then end with RestoreToFullHealth()

thick karma
grizzled fulcrum
#

Maybe this will help you?

echo lark
#

anyone ever have their imports in a script file cuase the server to not boot up?

{
    imports
    {
        Base,
        GalacTac,
        VCEW,
    }```
that crashes the server but removing GalacTac and VCEW and the server boots up just fine
#

im realy confused cuz ive added imports like that several times and they worked just fine

grizzled fulcrum
#

That in theory should work, only thing I can think of is those modules dont work (or are nonexistent)?

#

or maybe the last element cant have a comma (VCEW and not VCEW,) but I doubt thats issue

echo lark
grizzled fulcrum
#

i have no idea ;-;

echo lark
#

yeah thats literally where im at lol

#

im about to just do it the other way without importing just to see if it works or not

grizzled fulcrum
#

anything script related is a pain in the ass, I might write a vscode plugin for it when I get the chance because its just straight agony

echo lark
#

im just literally trying every combination or comma no comma just VCEW/GalacTac

#

hopefully something works

#

nope nothing works. as soon as i add 1 of the imports it wont boot up. i give up. im just gonna write the module name before the item ids and not import it

fleet bridge
#

might need to separate the imports @echo lark

#

or just use the module

echo lark
grizzled fulcrum
#

module base imports base is a bit weird now that I look back on it

#

since you are in the base module already, you shouldn't need to import it

plucky phoenix
drifting ore
#

no hablo espanol

plucky phoenix
#

traslate man xD

twin locust
quiet fulcrum
#

so here's my updated code a little more condensed:

local function KeepAlive(character)
    character:setHealth(1)
    character:getBodyDamage():RestoreToFullHealth()
    for _, bodyPart in ipairs(character:getBodyDamage():getBodyParts()) do bodyPart:RestoreToFullHealth() end
end

Events.OnPlayerUpdate.Add(KeepAlive)

and still, it just cannot keep the player alive. My player's body parts health and character health stays full when under attack by zombies but he still will drop to the ground screaming and die. The "You have survived for x time" text comes up and I cannot move but quitting and coming back in my character will be fully alive, mobile and in perfect health again. Any other ideas what mechanic is "killing" me?

twin locust
quiet fulcrum
twin locust
#

that if you health <= 0

#

print something

#

In theory it should never hit 0 right?

quiet fulcrum
#

at the end? setHealth and RestoreToFullHealth is already pumping it back to full

twin locust
#

I'd try at the start first

quiet fulcrum
#

it never gets close to 0, it does drop a little from each hit, but never drips below 90 before going back up

bronze yoke
#

you can't loop through bodyparts with ipairs, it's not a table

#

you should be seeing an error

quiet fulcrum
bronze yoke
#

are you getting dragged down by a horde of zombies?

#

that's just a special instant kill thing, and i guess the bug is coming from healing after dying

quiet fulcrum
bronze yoke
#

i think it's just called drag down

quiet fulcrum
#

actually I tried setDeathDragDown(false) and that didn't help but maybe it's too late already

#

I wasn't sure what that was when I tried it. I think you've pinpointed the issue, thanks, I'll dig into this more

#

so by the time OnPlayerUpdate is trigged, the check for updateDeathDragDown() has already fired. I wonder why OnPlayerUpdate fires so late in the update chain

ancient grail
#

since its animation related

marble folio
#

Hello @pulsar rock
I'd like to know if I can DM you to ask some questions about the Skill Limiter Mod? I'm having an issue with it and the Occupations-Mod I made

ancient grail
#

you could add another xml file same as the one with dragdown but remove the players hit react
and add a bool condition for it to checks

if that condition applies to your player then it will use that xml instead of the vanilla one. so you get to avoid the dragdown that way..

quiet fulcrum
ancient grail
#

yeah so the animation files can also check and set variables to players and zeds
so the zed is the one setting the hitreact to the player via xml
check the animset folder

#

just duplicate the zombie xmls that contains dragdown related stuff and modify em

#

goodluck

quiet fulcrum
#

thanks. I'm a RimWorld modder trying my hand at some PZ but I feel like a modding noob again trying to figure all this out

ancient grail
#

alternatively you can do the same thing but with the players hitreact xmls

i think this is s better solution

#

oh another thing
if you applied the setDragdown to the player and it didnt work
try it to apply it on the zed maybe?
im on mobile rn so i cant check

quiet fulcrum
#

for now I'm just going to disable drag down globally but I'll definitely check out the xmls

buoyant pasture
#

Is there a mod out there or in development that lets you shovel snow? I'd really like to keep my parking lot cleanish with Canadian winters and it could be another good way to train fitness

mental shadow
#

Hey, does anyone know where the magazine "The Herbalist" defines its TeachedRecipes as "Herbalist"? I was going to try use it to make a Nutritionist Magazine that would appear on the Training Materials and count as read if read.

bronze yoke
#

like where is the item defined? it's in scripts/items_literature.txt

mental shadow
#

No, as in what it's "recipe" is like how recipe.txt defines some of the recipes.

bronze yoke
#

oh, so known recipes is just a list of strings attached to the character, it doesn't technically have to correspond to an actual recipe

#

the foraging system itself checks if the player has that recipe and allows them to find the items as if they had the trait - there isn't an actual recipe going on here

#

there isn't really an equivalent for nutritionist, you'd have to actually give them the trait when they read the book

mental shadow
#

If I set the TeachedRecipes as something random that is not attached to anything else, will it still be able to be marked as read and unread?

bronze yoke
#

that's basically what the herbalist magazine is doing so yeah

mental shadow
#

Thank you!

untold turtle
#

Having a small rigging problem with the female model on blender, if someone wouldnt mind me dming them can you @ me Here ๐Ÿ˜ฎ

drifting ore
#

how do I delete file previously created by getFileWriter?

bronze yoke
#

you can't

grizzled fulcrum
#

If only ZomboidFileSystem was exposed to lua you could to tryDeleteFile but its not ๐Ÿ˜ฆ

grizzled fulcrum
#

chocolate coated oreo thumbscat

muted garnet
# grizzled fulcrum is there like a vanilla game action that does this??

If this was a reply to my message, do you know a way to raise a player without stopping the action? I know there is a setSitOnGround method but the problem is that during this time the player is applying the animation and can't stand up until the animation is finished, is there a way to get the player up during the animation without interrupting the animation or not letting him sit down?

grizzled fulcrum
#

does setSitOnGround only work while the action is not playing?

#

@muted garnet

#

sorry I forget to ping

#

I don't think I know of a way to do that

#

You might be able to do some thing in the action's update if there is such a method to like pause the animation or something then stand up and resume though im out of idea

autumn sierra
#

does anyone know where i can go to find the game's temperature system? im looking to make a mod for copper state that makes the temperatures more akin to a real desert and i've dug around eveywhere - can't seem to find anything that will allow me to do this aside from just changing the ambient lighting and such

grizzled fulcrum
#

like biome/weather temps?

autumn sierra
#

yeah, like the game's general outside temperature systems

grizzled fulcrum
#

what about getWorld():getGlobalTemperature()

#

wait no thats the whole entire temp

#

The temperature system is ClimateManager I think

#

like yo ucan do

local cm = getClimateManager()
cm:getAirTemperatureForSquare(square)
muted garnet
grizzled fulcrum
#

I honestly dont know

#

I've only done a tiny amount of animation stuff and its a very basic one

autumn sierra
grizzled fulcrum
#

To my knowledge, the weather system is based on randomness and doesn't have set values for per-month climate stats

autumn sierra
#

interesting, thank you!