#mod_development

1 messages Β· Page 322 of 1

queen oasis
#

dang, that returns a kahlua table.

nimble yew
#

I tried this, but it never gets called:

function VehiclePart:getTable(name)
    local tbl = old_getTable(self, name)

    print("Made it.")

    return tbl
end```
#

it's from Java, not a Lua function

queen oasis
#

yea that wouldn't work. getTable is a java function. There's a way without worrying about it. Worst case you grab the context menu and rip it out there. Let me dig around some more

nimble yew
#

Better Car Physics replaces BaseVehicle.class. Would it be too crazy to recompile VehiclePart.class to make getTable() call a Lua function that can be overriden?

#

I don't like it, but all other solutions I can come by result in overriding a shitton of Lua functions to mitigate this, and it end up being a potential compatibility issue with other mods. Being able to edit the table at run time would mean full compatibility. At least in my meager understanding of PZ and modding it (and Java and Lua also, loool)

queen oasis
nimble yew
#

for the moment, I know UninstallTest and that idea you gave me has a success path, even though I might need to rewrite a lot of vanilla vehicle lua code

queen oasis
#

if you can get the part script, you can remove the jack from the needed items, and then put it back after the action is finished

nimble yew
#

and other mods wouldn't even know it. oh, I just don't need a Jack...

queen oasis
#

it's something i haven't messed with much so I need to dig around and see what options there are

nimble yew
#

hey, thank you very much for your help. I didn't say it enough

#

you already gave me good ideas I didn't see before

#

I'll walk the dog and have a thinking session while at it

craggy nacelle
#

I was playing around with the IsoCell, thinking i might be able to change the loaded area, but i seem to go nowhere with that one.

There is a mod called Better FPS that changes the ChunkMap but it does so in java. Is it possible that it is... not possible to change the size of the loaded area with lua? Does anyone know?

queen oasis
#

stupid hashmaps

bright fog
#

Most likely the reason it's a java mod

#

We have zero control on map loading from the Lua

#

We can't even force load a specific area

#

Tho there might be some tricks no one has found yet for that who knows

#

But I'd be surprised...

craggy nacelle
#

Thx, thats what i feared, but its good to have confirmation. πŸ˜” Was kinda hoping for it to be possible, but was thinking that if someone does a java mod for it, then its probably not.

bright fog
#

Idk how many people dug on that aspect either

craggy nacelle
# bright fog Idk how many people dug on that aspect either

Yeah, i dont think ill succeed where so many others failed (probably ^^). Also i did jsut do a short comparison between what those guys do in their mod and what is done in the original. Turns out, most of it boils down to one line:

original:   private static int StartChunkGridWidth = 13;
1080p mod:  private static int StartChunkGridWidth = 8;

static eh... XD

bright fog
#

I think it being static isn't the problem, it's mostly just that you don't have any setter for these that exist I think ?

#

Tho I'm probably completely wrong

queen oasis
#

the problem is, 3 5 functions need to be modified for install and uninstall

craggy nacelle
#

I think if they gave us that, we could do some really nice stuff.

bright fog
#

I don't see any other application than just this single application of boosting FPS

#

There's literally 0 point to dynamically setting this value

bronze yoke
#

they don't usually like exposing internals like that

craggy nacelle
craggy nacelle
bright fog
#

Not just at a specific area of the map

#

So there's no point to dynamically increasing that value

#

Also at best you're probably to cause a fuck ton of problems by dynamically changing that value

#

Imo that's just pure hazard to leave such a parameter available to change by modders easily

storm trench
#

I wouldn't mess with chunks tbh.

#

Experimented a bit with that way back in FO3 modding. It's a slippery slope.

craggy nacelle
#

I agree on it being able to cause shit ton of trouble, also i dont quite know whate youre getting at with the committing thing? Wasnt it clear that its around the player? I just imagined how it would look if all of LVs population would suddenly march towards a certain point while you hide in some building and see the stream of zombies march down the street. Well, thats just my mind imagine me messing around with stuff, but still... ^^

bright fog
#

Zombies are "simulated" further than the loaded chunks

craggy nacelle
bronze yoke
#

i just don't get why you'd want to do that in the first place

bright fog
#

That's how they get lured from firearms for example

#

There's a lot of mods that utilize this

craggy nacelle
#

You mean the loading area? It came from my initial question about cars and performance - from where i went to: if i could reduce the loading area to a minimum around the car, would it help with the performance of multiple people driving all over the map.
Honestly, me messing with this stuff is mostly about me learning how things work. πŸ™‚

craggy nacelle
bright fog
#

Ah well desync is fucking insane to handle in PZ lol

#

Supposedly this is getting improved in B42

craggy nacelle
#

One can hope so. But yeah, meeting black areas while driving isnt a lot of fun. ^^

bright fog
#

Tbf I feel like we get in a part of the game where it's literally not even the job of modders to fix that

#

And it should one of the priorities of devs to fix render issues and desync issues. Which is something that was improved in B42 it seems

#

We'll see when MP comes out

silent zealot
#

example:

local index = __classmetatables[DevicePresets.class].__index
local old_addPreset = index.addPreset
index.addPreset = function(self, ...)
    local maxPresets = self:getMaxPresets()
    if self:getPresets():size() >= maxPresets then
        self:setMaxPresets(maxPresets + 1)
    end
    old_addPreset(self, ...)
end
#

That overrides DevicePresets:addPreset() when called from lua (i.e.: a java function calling DevicePresets:addPreset() will ignore it)

#

Credit to Albion for this deep magic.

#

Remember that making a mod that need java files replaced is a commitment from you to keep it updated as versions change, and requires extra work from every user... so it needs to be something important enough to justify that with no other option.

queen oasis
#

was I having a conversation with them and not understanding what they were after?

silent zealot
#

Unless I'm mixing people up, the goal is to not need a car jack when parked near a mechanics lift

queen oasis
#

yes

#

ok

silent zealot
#

Which is a really good idea!

queen oasis
#

ha, I thought I was having a stroke or something

#

The issue I saw is, they would also need to overwrite canInstallPart and canUninstallPart which just calls the test functions in the part script

silent zealot
#

but there should be no need for java mods since the mechanics interface is in LUA (possibly other than tooltip generation, but that might not be done the same as InventoryItem tooltips)

silent zealot
queen oasis
#

the way I did it was to catch it in the tests and the doMenu.

silent zealot
#

the test functions in the part script
WHere does that get defined? If the test function could be changed that's an easy fix.

queen oasis
#

I already undid my work but I have some notes

if liftNearby then
    for i = 1, #keyvalues.items - 1 do
        local item = keyvalues.items[i]
        if item.type == "Base.Jack" then
            table.remove(keyvalues.items, i)
            break
        end
    end
end

that would need to go in the lua tests and the context menu after part:getTable

silent zealot
#

Set a variable when opening the mechaincs menu if a lift is found, then the new test function takes that into consideration and falls back to the vanilla function if it does not need it

#

That looks good too

queen oasis
#

just zap it before it's checked

#

I really wanted to modify the part script on the fly but I think that would cause issues if say, you stopped the install before completion. it would turn in to a nightmare to get the script back to what it should be

silent zealot
#
if liftNearby or player:getStrength()=10 then -- motivation to exercise
queen oasis
#

I pulled weeds in my front garden and noticed today I'm player strength -2

silent zealot
#

I'm Flexability -2

queen oasis
#

meee tooo

silent zealot
#

"Pushed a shopping trolley around that is too low to be comfortable using so you have to bend over a bit the whole time? PAIN MOODLE!"

queen oasis
#

the ISVehicleMechanics.doPartContextMenu only calls canUninstallPart/canInstallPart which checks the install/uninstall tests anyways. The only way to ditch the red "you don't have a jack" is to get it out of the items table. I mean, it can mucked but you're going to have to get in to those test scripts anyway. From what I can tell.

silent zealot
#

I think that's an elegant approach

queen oasis
#

I like you. but not really elegant because there's 3-5 functions that need changed to make it work

silent zealot
#

So change 3-5 functions, not a big deal really.

#

Unless you mean "fully overwrite because it's not practical with a prefix" in which case I'd be looking at putting the mod in the too hard basket, because of risk of conflict with other mods just to not use a jack.

#

(or looking for another way even if it's harder to code)

queen oasis
#

only like 1/4 of it, unless there's a jack, then all of it

#

or a lift

silent zealot
#

I mean, if my mod add a prefix to the function will this approach wipe that out?

bronze yoke
#

depends on load order

queen oasis
#

you know it would. It's PZ

silent zealot
#

hooking VehiclePart:getTable() may be the elgant solution

queen oasis
#

it is, but that doesn't fix the context menu

#

it would let you uninstall it, but would still have red text saying you need a jack

#

you know

silent zealot
#

add a line to the end of the tooltip "jack requirment ignored due to lift"

queen oasis
#

maybe grab the menu on click, rip the jack out of the items table and then send it on it's way

#

the menu has to has to reference the part I would think

#

would still need the VehiclePart:getTable() override for the tests. idk, I'm over thinking it

#

this guy has a mod that overwrites like 5 java functions and 2 lua functions

#

and I can't even figure out how to center this damn text in the window

icy night
ancient grail
bronze yoke
#

only in build 42

#

also depends on what you mean by load order

#

the file load order always matters in build 41, but mod load order doesn't matter until b42

ancient grail
#

this is useful info..
i wonder why they made it so that it matters?
is it better this way?

bronze yoke
#

i think it's worse

craggy nacelle
#

What does that mean for mod development when the load order starts to matter? (Still doing .41)

silent zealot
#

There's a reason every sane developer uses some sort of easy-to-use framework instead of hand-coding each piece in Java with some lua sauce.

nimble yew
#

@silent zealot and @queen oasis those are great ideas. I will check the Java override example you gave, since I think all calls are from Lua

#

I also had another idea while walking the dog. Instead of removing the jack requirement, InstallTest and UninstallTest both call to VehicleUtils.getItems(). If a Lift is near, I could insert a bogus Jack (maybe a CarLift item) which will satisfy the Base.Jack need, and then both will call to ISVehiclePartMenu.transferRequiredItems() and ISVehiclePartMenu.equipRequiredItems(), where I could just ignore those items

#

that would keep the Jack on the Tooltip, and it will show green since it found a tool with the right type. And then just ignore getting that tool into inventory and then equipping it.

#

I just got out of MP server with some friends. I will cook some dinner and give it a go. I will try first overriding getTable() since I think it's the fastest and cleanest way

nimble yew
nimble yew
#

couldn't resist, it looks like this:

local index = __classmetatables[VehiclePart.class].__index
local old_getTable = index.getTable
index.getTable = function(self, ...)
  local keyvalues = old_getTable(self, ...)
  
  if carLiftNearby(self:getVehicle()) then
    for i = 1, #keyvalues.items - 1 do
      local item = keyvalues.items[i]
      if item.type == "Base.Jack" then
        table.remove(keyvalues.items, i)
        break
      end
    end
  end
  
  return keyvalues
end```
craggy nacelle
nimble yew
#

that's awesome!

#

how can I format a code block with color highlights?

craggy nacelle
#

thx. πŸ™‚

Hm, no idea. O_o Honestly didnt pay attention that being a thing, but youre right, how are they doing it?

nimble yew
#

found it

craggy nacelle
#

Oh pls tell!

nimble yew
#

you place the '''lua and then your code

#

'''language

craggy nacelle
#
DER.lSub = ISContextMenu:getNew(context)
nimble yew
#

add a newline after the language

#

'''lua
code'''

or

'''lua
code
'''

#

looks like it worked, just a not so fancy line

#

try if, then, end, local, function, etc

craggy nacelle
#

Yeah, no coloring for me, but its a step in the right direction

nimble yew
#

I'm starving, reduced strengh and health recovery. brb

nimble yew
#

how do you feel with this?

local function isCarLiftNearby(vehicle)
  local range = 3  -- how close the Car Lift must be
  local square = vehicle:getSquare()
  
  if square == nil then return false end

  for dx = -range, range do
    for dy = -range, range do
      for i=0, square:getObjects():size()-1 do
        local obj = square:getObjects():get(i)
        if obj and obj:getSprite() and obj:getSprite():getName() == "location_business_machinery_01_11" then
          return true
        end
      end
    end
  end
  
  return false
end
#

After the Jack requirement is solved, I will have to deal with the Car Lift item placement in itself... I already dug into it and it's a nightmare to deal with Moveables. I wanted to make it in 4 different items like a Large Shelves

craggy nacelle
#

Nice, you got the color going. Also, can you just put a minus before a variable like that? Not that i get why you'd do so or more precisely, for what: since i cant really see what youre using those lops for.

topaz tangle
#

perhaps would anyone know why i just, cannot open the door to get into a vehicle?

nimble yew
nimble yew
topaz tangle
#

modding issue, might be related to it being a left hand drive vehicle?

craggy nacelle
slow marten
topaz tangle
nimble yew
slow marten
nimble yew
#

I'm using VSCode with Lua and Umbrella

#
local function isCarLiftNearby(vehicle)
  local range = 3  -- how close the Car Lift must be
  local square = vehicle:getSquare()
  
  if square == nil then return false end
  
  for dx = -range, range do
    for dy = -range, range do
      local sq = square:getCell():getGridSquare(square:getX() + dx, square:getY() + dy, square:getZ())
      if sq then
        for i=0, sq:getObjects():size()-1 do
          local obj = sq:getObjects():get(i)
          if obj and obj:getSprite() and obj:getSprite():getName() == "location_business_machinery_01_11" then
            return true
          end
        end
      end
    end
  end
  
  return false
end
nimble yew
craggy nacelle
#

Dont think it makes a difference, but you should also be able to write:

local sq = getCell():getGridSquare(square:getX() + dx, square:getY() + dy, square:getZ())
nimble yew
craggy nacelle
nimble yew
#

I've been reading other mods' code for days now lol

craggy nacelle
#

https://theindiestone.com/forums/index.php?/topic/26228-of-chunks-and-cells-or-how-i-stopped-survivor-and-learned-to-love-the-custom-sandbox/

Here, that one holds a lot of back ground info. found it when i was looking for what cells and chunks are. Also in essence: getCell gives you the loaded are back (at least if i understood one of albions comments right)

nimble yew
#

And I only have 150hs on PZ. Probable 20 of those were testing mods or just idling

nimble yew
#

IT WORKED!!!! first try, both the getTable override and the isCarLiftNearby()

silent zealot
nimble yew
#

code is code

#

it gets spammed! some virulent checking for the part's table

#

only when the hood is opened, though

#

near the lift

#

a bit far from the lift

silent zealot
#

... and while I was writing that you discovered exactly what I was talking about πŸ˜‚

nimble yew
#

lol yes. I was thinking where could I store that. I will look into Auto Mechanics, since it does something like that storing the state

silent zealot
#

Just make a table to store it in

#

doesn't matter if it gets cleared when you quit and reload

#

or a single variable, but with a table you can index by vehicle:getKeyId()

#

but for single player only, no issues just having UsefulCarLift.NearALift = true/false

#

or whatever you want to call your variable

nimble yew
#

oh, I'm just an idiot. I was overthinking it because I placed the code on the server side

silent zealot
#

Just use a distinct name

#

hahaha

#

A robust way would be to make a table:

#

UsefulCarLift.CarsNearLift = {}

#

Opening the Mechanics interface clears the table

#

When you call isCarLiftNearby(vehicle) is says if UsefulCarLift.CarsNearLift[vehicle:getKeyId()] ~= nil then return UsefulCarLift.CarsNearLift[vehicle:getKeyId()]

#

And if it is nil, it does the check/stores it in UsefulCarLift.CarsNearLift[vehicle:getKeyId()] and returns it.

nimble yew
#

that sounds great. I will take some notes and implement them tomorrow maybe. I'm a bit drowsy now. And I can go to sleep with a small victory

silent zealot
#

getKeyID() was the best property of a vehicle I could find for indexing, since it's a number that persists and is unique per car.

nimble yew
#

yes, that sounds about right

silent zealot
#

Sleep well, mod is looking good and might make me regret sledgehammering my vehicle lifts for more space to work on cars. πŸ˜›

nimble yew
#

tomorrow I will get this cleaned up and start with the items and pickup/placement

#

I wanted to make a pickup/placement using vanilla mechanics, but I tried different mods and every one implemented their own Context Menu option 😦

#

picking up large multi tile objects and splitting them into items, like Shelves and stuff

silent zealot
#

FYI: there are probably 4 sprites, for each end of a north/south list and each end of an east-west lift.

nimble yew
#

yes, it was just a test. now only that, each tile has two different sprites

#

even thought it's a 1x4, it uses 8 sprites

silent zealot
#

yeh, top/bottom. Takes two sledgehammer destroys.

nimble yew
#

that's another challenge. I need to find out how to make an item that has two sprites

#

making it work was the easy part lol

silent zealot
#

You may be able to just check spritename starts with "location_buisiness_machinery_01_1

silent zealot
#

I guess the same way as a four-part bed does it, but putting more than one sprite on the same tile.

#

And hope it's not hard-coded to one item -> one sprite, and the 2/4 boxes for 2/4 tile items is just convention.

#

either way, get some well deserved rest.

#

And weld some sheet metal onto your hood before you drive anywhere.

nimble yew
#

I would love something like this. Split the lift in 4 different heavy parts

#

hahaha I crashed it several times trying to fit it in the lift. It is TIGHT

silent zealot
nimble yew
#

I might need to add an extra tile just to make it easier

silent zealot
#

Need an auto shotgun for MMMMMMMONSTER KILL!

south bear
#

Is there a way to "get" the AmbientStreamManager using lua so you can run its methods such as doAlarm(RoomDef room)? (This is for SP only atm)

nimble yew
#

gnight, folks. and thanks for you help!

craggy nacelle
# silent zealot Need an auto shotgun for MMMMMMMONSTER KILL!

Yeah, old memories can make nostalgic. Was a bit drunk when i started it, trying to find my way into the sound system, but now im quite fond of the whole thing and just keep adding stuff to it. XD Auto shutgun, hmmmmmmmmm, nice idea. πŸ™‚

craggy nacelle
silent zealot
#

Sound that the player hears and sounds in the world zombies can hear/that stress players are 100% seperate. Can confirm WorldSoundManager is the one to attact zombies.

#

It has no idea what sounds were actually played, just where and how loud.

ancient grail
south bear
#

Thanks for your help, friends! I figured it out - For anyone looking for it in the future it is literally just

getAmbientStreamManager()

LOL! kardderp <-- how I feel rn

So, for example, you could do:

getAmbientStreamManager():doGunEvent()

It doesn't get much easier than that I suppose!

late thicket
#

I think it's goofy that our character just picks up a cow and moves around,
There should be a mod that makes it that you can't pick a dead cow or any big animal.
Instead you could winch the dead animal to ur carπŸ€” could that work?

silent zealot
#

Corpses are special objects, so... maybe.

quasi gazelle
#

Hi guys I am trying to make my first mod but it seems all over the place. I can't even load the mod properly. If anyone can tell me what I am doing wrong it'd be much appreciated.

..\Users\[user]\Zomboid\mods\TestMod1\42\media\lua\client\TestMod1.lua

require "ISUI/ISInventoryPaneContextMenu"

local contextMenu = {}

---@param player IsoPlayer
---@param context ISContextMenu
---@param items table
function contextMenu.onFillContextMenu(player, context, items)
  print("context menu")
end

Events.OnFillInventoryObjectContextMenu.Add(contextMenu.onFillContextMenu)

..\TestMod1\42\mod.info

description=Test Mod 1 desc
modversion=0.0.1
id=TestMod1
name=Test Mod 1
poster=poster.png -- this is a valid img
thin swan
quasi gazelle
#

I do

thin swan
#

Also, is the content: string actually in your mod.info? Because it shouldn't be there, unsure if that's what's messing it up though

quasi gazelle
#

oh yeah it's not that's a typo sorry

thin swan
#

Ah okay

#

Hmm, it should work from what I can see. Is it showing up in your mod list?

quasi gazelle
#

I don't know how to check

#

it's not in here:

thin swan
#

Ah okay, yeah it should be there

quasi gazelle
#

nor here

#

but I don't even know if it's supposed to be there

thin swan
#

Tbh I never really used the \mod folder, I always just go with the workshop folder directly, so I'm not 100% sure what's going on.

But maybe try just moving it to the workshop folder instead.
You'd put it like this
[user]\Zomboid\Workshop\TestMod1\Contents\mods\TestMod1 and that would be your new root folder where you put mod.info, b42 folder etc

quasi gazelle
#

nevermind it shows in the list now, I didnt move it to workshop

#

but I am guessing my lua is wrong now right

#

not a mod issue

thin swan
#

Your Lua looks fine to me, but I'm not quite sure when it's going to be loaded, so you might not see the print in the debug log in-game. But if you check the \Zomboid\console.txt and search for it you should see it

#

I'd go with a keyboard event to try stuff out instead, something like this:

contextMenu.onKeyPressed = function(key)
  if key == Keyboard.KEY_G (or whatever key you want to use) then
    -- your code to test
  end
 end

Events.OnKeyPressed.Add(contextMenu.onKeyPressed)

Then whenever you press G your code will run

quasi gazelle
#

nice thanks I should've gone with that indeed

thin swan
# quasi gazelle nice thanks I should've gone with that indeed

If you do indeed want to make a contextmenu mod and you need to trigger when it creates them, I noticed that I used this event:
Events.OnPreFillInventoryObjectContextMenu whereas you don't check for the PreFill event, just the Fill one.
Not sure exactly what the difference is because it just works for me, so maybe try that as well

quasi gazelle
#

oh my damn I am an ultra idiot

thin swan
#

I edited my comment above btw, I wrote the wrong thing first

quasi gazelle
#

I was reloading a save that didn't have the mod enabled

thin swan
#

Oh haha

#

been there!

quasi gazelle
#

but somewhere along the way we fixed it

#

because it didn't work before even though the mod was enabled

thin swan
#

Okay that's good! Now you should be all set to play around with it

quasi gazelle
#

yeah lucky me

#

thank you for the help πŸ‘

thin swan
#

No problem! Always good to have more modders πŸ˜„

thin swan
quasi gazelle
quasi gazelle
thin swan
quasi gazelle
#

I decompiled java for extra reference but I am so lost in it that I can't even tell how to plug in my own right click function.

#

caughing print at everything seems like a good way to do stuff tho

#

I'll try that

thin swan
quasi gazelle
#

yeah I reckon I won't need java it's too much of a hassle and I hopefully won't need it anyway as you say

#

alright thanks for the help, I am going to botch things up πŸ˜„

thin swan
#

Haha awesome, have fun! πŸ˜„

thorn brook
#

is anything about this code that could be depreciated in B42 or something?


PauseStart = {}

PauseStart.OnGameStart = function()
    
    if getActivatedMods():contains("Lifestyle") then
        LSMenuOnDestroy()
    end
    UIManager.getSpeedControls():SetCurrentGameSpeed(0)
end

Events.OnGameStart.Add(PauseStart.OnGameStart);
#

i wanna use this PauseStart mod, and i also happen to use Lifestyle

#

but it doesn't work while using it (i'm assuming this code was supposed to fix that?)

#

and i'm pretty sure it worked fine for me back in B41

#

so i guess something about this must be depreciated?

#

or maybe not, since the mod does work on it's own

#

so it has to be something about lifestyle

frank elbow
#

i.e.,

local lifestyleEnabled = false
local activatedMods = getActivatedMods()
for i = 0, activatedMods:size() - 1 do
  local id = activatedMods:get(i)
  if id:match('^%d*\\Lifestyle$') then
    lifestyleEnabled = true
    break
  end
end

You can run this once & then just check your flag. If you end up checking for more than one mod, it'd be best to extract them to a table (associated to true) instead

thorn brook
#

this is the code if anyone else ever needs it:

PauseStart = {}

PauseStart.OnGameStart = function()
    local activatedMods = getActivatedMods()
    for i = 0, activatedMods:size() - 1 do
        local id = activatedMods:get(i)
        if id:match('^%d*\\LifestyleHobbies$') then
            LSMenuOnDestroy()
            break
        end
    end

    UIManager.getSpeedControls():SetCurrentGameSpeed(0)
end

Events.OnGameStart.Add(PauseStart.OnGameStart)
queen oasis
#

making a mod to take all the money in your inventory on April 15th

topaz tangle
craggy nacelle
topaz tangle
#

thanks!

thin swan
bronze yoke
#

an apostrophe opens/closes a string

topaz tangle
#

makes sense!
wasnt even something that was consistent through all the different things for the trailer anyways, made more sense without it

still having the issue with it refusing to have a proper trunk but

thin swan
#

Is there a smooth way to set the volume of my custom sounds in the mod options?
Right now the volume is controlled by this sound block in my item script:

sound SkateboardRolling
    {
        loop = true, is3D = true,
        clip { file = media/sound/Skateboard/Skateboard_Rolling.ogg, distanceMin = 0, distanceMax = 30, volume = 0.40, }
    }

As I understand it the ambient category is no longer a thing in B42, so I can't just use that.
I noticed I can do setVolume on the sound when it's played by the emitter, but if there's an easier way where I can just change the volume param in the script, that'd be way better.
Does DoParam work on sounds for example?

bright fog
#

I remember a way to add your own volume sliders

#

Don't remember who did that tho

thin swan
#

I think I might have it figured out, need to just put it together

thin swan
#

Guess not lol, foolish of me to think that something as easy as setUserVolume on the GameSound would work. God damnit

craggy nacelle
thin swan
#

I guess it's not that big of a deal though, and I'm just wasting time trying to save on negligable performance gains

#

That is if setVolume is even gonna work lol

craggy nacelle
#

may i ask how you get the emitter? Im just using getSoundManager to play my sounds since it also has all the controls, but i guess having a specific emitter would allow more fine control? Not that im using it atm, but may come in handy to know. ^^

craggy nacelle
thin swan
#

This is working to change the volume:

local emitter = pzPlayer:getEmitter()
local sound = emitter:playSound("SkateboardRolling")
        emitter:setVolume(sound, 0.80)
queen oasis
#

I couldn't remember if it wanted the sound or the emitter

craggy nacelle
thin swan
#

Yeah it took me a minute to figure out what the hell the long param in setVolume(long, float) was supposed to be haha

queen oasis
#

I remember getting mad when playing with setPitch on my metal detector

#

in the end I hated it so just changed it to beeps

thin swan
thin swan
queen oasis
thin swan
#

Ah I feel ya

queen oasis
#

looks pretty useful

thin swan
#

I'm just trying to get a better understanding of all things animations. I really should decompile the java

nimble yew
thin swan
# queen oasis looks pretty useful

You never really know lol
I saw you could get an AnimationPlayer from the character object, and it gave me an object, but I can't call any of the methods on it
Probably just something I don't understand though

queen oasis
#

trying to find something not in debug

bright fog
#

Not a java object that you use in the Lua

#

I mean perhaps that's doable, but the way animations trigger sound is done directly in AnimSets

queen oasis
#

I was trying to find how it is used. I know absolutely nothing about animations, except I suck at it

bright fog
#

Check fence climbing AnimSets

#

Some of these have sounds that trigger at the end if you trip for example

thin swan
bright fog
#

Ah that I'm unsure how it exactly works tho

#

Idk what they refer to when triggering the sound

#

But at least animations triggering sounds is done from AnimSets from my understanding of it

#

Might some exceptions tho

#

Like in the case of walking I doubt it's done in AnimSets ?

#

Haven't looked too deep in it

thin swan
#

Oh wow, yeah I have no idea how I didn't notice that

<m_Events>
        <m_EventName>PlaySound</m_EventName>
        <m_TimePc>0.28</m_TimePc>
        <m_ParameterValue>LandLight</m_ParameterValue>
    </m_Events>
``` is a thing you can just straight up give a sound name to
#

Hmm, how to change the volume of these then

broken kayak
#

Quick question for y'all, I've been wondering if I should keep the character facing the location where you want to place the item, by default your character looks at it, but I'm afraid that it could lead to some annoyance in junction with my mod, what do y'all think ?

bright fog
bright fog
#

Yes you can definitely do that !

#

Wait unsure

#

What are you doing for draging the item visually like this ?

#

Is this a kind of Lua object ?

#

The method I know to forcing the player to look in a certain way will cause more issues than anything and not worth the work with it

broken kayak
#

Well I was wondering the other way around, by default the character face, but I disabled it

queen oasis
#

me, I would keep the player still until putting it down

bright fog
#

However if you're using a Lua object to moving the item in 3D (place item basically), you could always modify that Lua object to not change the direction the players looks

broken kayak
#

Yeah I'm using the Place3DItemCursor

bright fog
queen oasis
#

mod option... πŸ™‚

bright fog
broken kayak
#

xd

bright fog
#

-_-

broken kayak
bright fog
#

The code that modifies the player looking direction is simply triggered by the Lua object, most likely. If you force the player to look in a direction with setDirection and shit, the player will be stuck like this and won't be able to rotate their character bcs you're blocking commands

#

It's not a question of mod options

queen oasis
#

in reality, the game spins you around when you're placing an item, no reason to change it

bright fog
#

Just properly doing it so the player can still use their movement keys to change their character rotation

broken kayak
broken kayak
#

I'm already successful in stopping the player facing the 3d cursor

bright fog
#

You can derive that object and modify where needed

bright fog
#

Oh you're just asking our thoughts lol mb

broken kayak
#

yeah xd

#

its actually the IsValid function changing the direction

bright fog
#

I agree it would cause issues if players can suddently rotate

#

Tho isn't that already an existing issue with placing objects from context menu ?

broken kayak
#

It is, but you have way more control over when you're doing it

bright fog
#

Yea I see what you mean

broken kayak
#

Like if my mod start to cause problems in normal gameplay, it's a swift uninstall to happen xd

sonic needle
#

i would have it as an option toggle πŸ™‚

queen oasis
#

mod option

topaz tangle
thin swan
#

It also doesn't seem to add a sound, so it won't attract zombies when played

nimble yew
#

if I create a git repo inside Workshop/FunctionalCarLift, will the .git (an other git related files) be uploaded? Or only the files inside "Content" are uploaded?

bronze yoke
#

only files inside content are uploaded

nimble yew
#

ooh, great. I hated the idea of having to copy files manually all the time

topaz tangle
#

if you just updated it it might just be in the approval process

nimble yew
#

when I first shared the link, I didn't even accepted the workshop tos

queen oasis
#

it shows up now. nice work!

nimble yew
#

later, or tomorrow, I will create the github repo and link it in description. I will add a credits section too. Can I add you there?

#

this part of the mod was the easiest. the hardest part will be the pickup and placement handling. I have no clue how to do it, since I couldn't find references of existing vanilla items in any file like Large Metal Shelves or Beige Large Shop Shelves, which drop part items to the ground

#

if anyone knows of a mod doing something similar where I could look for inspiration, I would appreciate it

queen oasis
#

I can math just fine, thank you

#

he-man running around with 990 kg of thingies

#

so yea, I forgot I had my capacity override mod on this save and was messing with the player inventory capacity

#

much more reasonable

nimble yew
#

I placed just half a couch with the brush, and when I try to pick it up, the second half phantom appears, but I won't let me pick it up

nimble yew
#

I found where to start. TileZed and check the properties on newtiledefinitions.tile

broken kayak
#

So I kinda trailed of into making changes to the item placing, like rotating with the mouse instead of having to hold R or Shift+R, but I don't know if I should instead move this to a separate mod πŸ€”

bright fog
#

That would be cool

#

I don't doubt some will use it

thin swan
#

Anyone happen to know how to make a weapon be guaranteed to spawn with attachments already on it?

sonic needle
#

that particular feature can break gun mods if you use the default method,

so its gotta be done manually

silent zealot
silent zealot
#

though, a gun light would make a little headlight.

thin swan
ancient grail
#

anyone knows the syntax to fetch the doors property if its metal or wood

sonic needle
silent zealot
#

The Vanilla method is to put possible upgrades into the lua WeaponUpgrades table, java loads that when parsing scripts, yadda yadda yadda, DoWeaponUpgrade picks upgrades at random from the list with no way to influence how many or probability.

#

If weapons can have an OnCreate function that would be an easy way to do it.

#

And they can! So you make an OnCreateKicksScooter(scooter) function, add OnCreate = OnCreateKicksScooter to the item definition, and that function creates wheels and attaches them.

nimble yew
#

let's goooooo

#

It doesn't let me pick it up, though. But we are going forward!

#

I did get an error while loading the save

#

LOG : General , 1744767263220> tiledef: loading C:\Users\maria\Zomboid\Workshop\FunctionalCarLift\Contents\mods\FunctionalCarLift\media\carlift.tiles
LOG : General , 1744767263223> MOVABLES: SpriteGrid dimensions error for multi sprite movable, group: (Car Lift Car Lift) sheet = car_lift_01
LOG : General , 1744767263224> MOVABLES: Error in multi sprite movable, group: (Car Lift Car Lift) sheet = car_lift_01
LOG : General , 1744767263224> Missing translations in Moveables_EN.txt:
Car_Lift_Car_Lift = "Car Lift Car Lift",

silent zealot
topaz tangle
topaz tangle
# silent zealot

when i was doing the v2 of my cabover mod, i said basicly this verbatum

nimble yew
#

I'm looking into the tile properties and comparing them with other similar tiles, and I find no big difference yet.

silent zealot
#

I once got very happy when my mod got to the point where putting underpants on crashed the game.

nimble yew
#

there are times for underpants and times for breeze...

topaz tangle
#

the cabover mod was such a mess, cant wait to have to clean that up when i go to port it into my current mod

#

i currently have what i concider to be a crutch but may just be how it is for my loot distribution

wheat oyster
#

Hi, does anyone know a modder? I need help fixing a mod or practically creating one.

tired jackal
#

There appear to be some modders in this channel... Thinkge

silent zealot
#

More seriously: there are lots of modders in here, so feel free to ask about whatever you're stuck on/need help with.

sonic needle
broken kayak
sonic needle
#

Chonky Dogmeat

topaz tangle
silent zealot
#

Who needs riddable horses when we have GIANT DOGGO

queen oasis
queen oasis
thin swan
#

Well shit now I kinda want to get into the animal system and make a cat companion that roams around your house/farm and kills rats

queen oasis
#

always nice to find out it's probably not your mod that causes the game to crash. Also nice to know that some people read the mod description.
"I had that character getting stuck in a freeze frame bug without using your mod. ...Was caused when I opened a door with a zombie in-hand - the zombie was dropped on the floor. Next time I picked up the zombie the freeze frame began."

#

Maybe I can quit chasing that "bug" now

mellow frigate
slim swan
queen oasis
#

bursting my bubble

slim swan
#

I got comments almost every day like: β€œWhy is this mod not showing up on my server?”

queen oasis
#

"Your mod doesn't work" and I ask "What other mods are you using?" - always crickets after that

slim swan
#

Whenever someone reports an issue and includes a screenshot,
I swear, it almost brings a tear to my eye.

queen oasis
#

now that's fake

queen oasis
#

where the heck are the speed control buttons hiding in code? I swear I've looked at everything
nvm, I can't read

rich reef
#

Been trying to figure this out all day. Old post, but thank you!

bronze yoke
#

you can just use screenToIsoX and screenToIsoY

hollow vector
#

this all looks awesome. Sucks I have no idea how to code in the slightest because I'd love to make mods

topaz tangle
#

its not too hard to learn

silent zealot
#

None of us were born knowing how to code.

bright fog
#

Exactly :)

topaz tangle
nimble yew
#

vibe code it lol

#

after the car lift is done, next mod will be a dolly

vocal grotto
#

Eww

silent zealot
thin swan
#

Vibe coding PZ mods with 0 prior coding experience is gonna be tricky, but not impossible!
AI loves to hallucinate up some methods and functions that just flat out don't exist

silent zealot
#

It's also going to annoy this channel when peopel ask for help with their code but have no idea what's happening or why.

thin swan
#

Oh yeah, there's that aspect haha

silent zealot
#

And the person can't follow basic advice because all they can do is ask an AI to change stuff

#

So anyone who wants to Vibe code, you need to commit to it and not push work onto other humans.

thin swan
#

Yeah they're better off taking a Lua course and using AI as a personal tutor, to ask about concepts and clarifications etc

bronze yoke
#

if you have to get me to write ai prompts for you i'm not sure what your part of the process even is πŸ˜…

silent zealot
#

Just keep asking the AI to fix things until it does.

#

prompt: "The code you gave me does not work, please do the needful"

vocal grotto
#

Or just don't use AI to flat out write code.

thin swan
#

Idk, I use it all the time and find it saves me a lot of time, but I also know if it's giving me some bullshit

silent zealot
#

That's "I use AI as a tool", not vibe coding.

vocal grotto
#

Like assisting in writing or making art, it should be used to help create, not be the thing that creates.

thin swan
#

Ah I get ya, fair enough

topaz tangle
thin swan
#

I honestly feel very lucky that I learned to code just before ChatGPT popped up, because I know I would have been too lazy to learn the hard way lol

topaz tangle
#

I’ll drop in my obligatory AI opinion

#

Wrong image lmao

silent zealot
#

How I learned to code.

thin swan
#

80s?

silent zealot
#

This is what we got instead of downloaidng code

topaz tangle
#

I learned to understand coding from hour of code, but learned how to actually do it from many kind people in this server and many others

silent zealot
#

Probably why I like modding, I grew up with the idea you could tweak games because you were typing out all teh code yoruself lol

silent zealot
#

...so yes, 80s.

thin swan
topaz tangle
#

I love that fucking cat

silent zealot
#

What do they use to tyeach programming in school these days? There was no consistent plan (and I moved abot a bit) in the 80s/early 90s so it was bits of BASIC, Logo, Hypercard...

topaz tangle
#

Do not sully the good name of scratch

topaz tangle
silent zealot
#

What language(s) does that use?

thin swan
thin swan
queen oasis
topaz tangle
#

Though you can also use Java

silent zealot
#

I did (half of) and electrical engineering degree at Uni, and that used C and Miranda... which was pure functional language

#

pure functional languiages are horribel to do anything with

#

absolutely no access to anything other than the function inputs, and then your function can return exactly one thing.

#

It was designed for solving recreational math puzzles.

#

C was cool though. "You want an array? GO BUILD ONE. You want a string? GO BUILD ONE You want to write to an arbitrary memory address? Sure thing."

thin swan
#

I tried taking C++ in college but my teacher was terrible. Every time I asked her to explain something she just said "it's in the book" and if I told her I still don't understand then I was met with "google it".
The fuck are you here for then??
Got so fed up I just dropped the class and didn't try coding again for like 3 years

#

The only redeeming thing about that teacher is that she looked exactly like a rounder version of this lady from The Incredibles

bronze yoke
#

i had a computer science teacher who was the same way and it became apparent pretty quickly that she just didn't have any knowledge of it to begin with

#

it wasn't a poor school and it's a good area for tech so i don't really get how that happened

thin swan
#

And it won't stop them from forcing you to pay $300 for a textbook published 15 years ago

sour island
#

My first and only computer class was an intro and we just learned about history and manually wrote binary ciphers

#

😐

topaz tangle
#

thats really cool actually

sour island
topaz tangle
#

im in a computer class rn, but its about wiring and such

did a fusion class and another class but idk how to explain it

thin swan
#

God damnit, going back to ts and I keep typing print instead of console.log every single time

icy night
#

Fixed my sound radius tracker. I was just overcomplicating things

clever quarry
#

Hi guys, can anyone tell me if Zomboid triggers any event to the server by receiving a message from the game chat?

nimble yew
#

My brother teached me Basic when I was 11, and then I bought this book when I was 16

#

Then learned C playing with microcontrollers, PHP on my first job, last stuck to C and C++ for my last job at embedded systems, doing some C# now and then (super specific low level features), and some other languages for code reviewing my team

clever quarry
queen oasis
#

going to age myself here.

clever quarry
#

I'm trying to make a mod that listens to the chat on the server side

nimble yew
#

I saw some content creator talk about a bot he did for connecting the game chat with discord

#

grep -r media/lua/client/ -e 'chat' got me a lot of hits. none on server

clever quarry
#

I want to trigger an event using specific words from the game chat

bronze yoke
clever quarry
rich reef
#

Hello all. I am trying to debug an old mod of mine which used the B41 ModOptions mod for settings. It seems that the settings are saved into the .ini file once applied, but they do not load the correct settings again on restart. All the values are adjustable in-game and change when applied, but are not loaded correctly when reloading back into the game. Any ideas? Thanks in advance!

bronze yoke
#

are you on linux?

rich reef
#

No, Windows 10.

rich reef
#

It seems that the .loadModOptions function runs after I go into the options menu and Apply/Accept some changes, but not upon loading the game itself.

topaz tangle
#

idea ive had (that is probably impossible)
do yall think you could use the radial menu to open a liquids ui in b42 for fuel trucks?

silent zealot
silent zealot
silent zealot
topaz tangle
#

yeah i know you can do that, filis does it and so does PZK

#

just unsure if you could prompt it to open the liquids ui

rich reef
bronze yoke
#

you definitely could, the trouble would be actually having a fluid container in the vehicle

silent zealot
#

Not a problem - each removable vehiclePart holds an InjectoryOject that is teh part that has been installed

#

And IntentoryItem can have a fluidcontainer attached.

bronze yoke
#

i'm not sure if persistence is universally implemented but now that i think about it nearly anything in the game can have a fluid container anyway

silent zealot
#

So you make a "fueltank" VehiclePart or similar name, then Vehicle -> getpart("fueltank")-> getIntentoryItem-> getFluidcontainer

bronze yoke
#

they're doing a kind of ECS now so everything should be able to have one, though i don't expect them to fully work in most weird cases

silent zealot
bronze yoke
#

any entity should be able to have one

#

persistence would be the issue in most cases (i assume) but vehicle parts being items gets around that for sure

silent zealot
topaz tangle
#

oh wow thats alot simpler then i wouldve thought tbh

bronze yoke
#

yeah, it's kind of late in the game for it but they're using an entity component system now so optimistically most newer features should benefit from this

silent zealot
#

I hope so!

#

Would be a big improvement to flexability

topaz tangle
#

glad they are making improvments like this!!!!

silent zealot
#

If I want a hammer with built-in whiskey flask I can.

topaz tangle
#

thats actually so peak

#

there is ALOT you could do with the liquid stuff and im glad they added it

it will probably be a bit before i go and try to actually impliment a fuel truck to see if the idea would work (unless someone else does it first lol) but i dont see any reason it wouldnt
wish TIS would impliment it as a game feature, could be cool to see a new vehicle and would fit with the new companies they have added

#

ive added it into my notes though so i dont forget in five seconds

gusty pasture
#

Hi! Trying to create a trait mod but am having trouble, could anybody help me?

#

Basically I wanted to create a mod where you can select to be a "licensed gun owner" and start with a +3 aiming, +2 reloading, and begin the game with a pistol and 2 boxes of ammo. I created profession mods but haven't done a trait and can't seem to get it to work or show up in the game

silent zealot
#

It's pretty easy.

#

(code for B42, but probably the same in B41)

#
local function initNepLumberManTrait()    

    local Fisher = TraitFactory.addTrait("Fisher", getText("UI_trait_Fisher"), 6, getText("UI_traitdesc_Fisher"), false, false);
        Fisher:addXPBoost(Perks.Fishing, 2);
        Fisher:addXPBoost(Perks.Cooking, 1);
end

Events.OnGameBoot.Add(initNepLumberManTrait);
#

That adds a trait that gives some skill boosts and costs 6 points

#

description goes in a translation file, and you need a texture media\ui\traits\trait_fisher.png

#

For giving the player extra stuff at teh game start see lua\shared\Items\SpawnItems.lua for examples

#

basically, attach a function to the OnNewGame event that says "if player has trait("BinxGunShopOwner") then player:getinventory:additem("Base.Pistol") end"

#

You should also add "Unlicensed Gunshop Owner" who starts with two assault rifles, a stack of cash and a suspicious package. 🀣

topaz tangle
#

Gina be having a bit of fun re-texturing the Powell tomorrow!

Not sure what vehicle to do next yet, maybe one of the semi trucks

queen oasis
silent zealot
#

We had Advanced BASIC!

queen oasis
#

Atari Basic was ok - but we had ANTIC! and Pokey!

silent zealot
#

It had some support for sprites!

#

I think there were 32 16x16 sprites and some rules about not having too many on a single horizontal row

queen oasis
#

it did. I had graph paper everywhere for years, looking like Beautiful Mind or something

silent zealot
#

For defining the sprite using numbers?

#

Something like conveying each row to 16 but integer

#

It's been a while!

queen oasis
#

yep, I don't remember the math exactly now. I just remember 7-0, add em up and poke them somewhere

silent zealot
#

Oh god... PEEK and POKE.

#

Who needs graphics drivers when you can write directly to video RAM?

#

That was more of a Commodore 64 thing, at least for me

queen oasis
#

I never got that in to it. By the time I was old enough to grasp any of that, I had gotten a 486DX running 100 MHz in turrrrboooo

#

played pascal for a high school class, quick basic, visual basic(ptsd) and then perl, php, js and finally settled on python. I still suck at all of it tho

#

just remembered DHTML. them the days

queen oasis
#

I was hoping to grab when the player clicked on the "Play" button:

if UIManager:getSpeedControls():getClickedValue() == "Play" then
    JB_SpeedKeeper.newGameSpeed = getGameSpeed()
end```
which works. except I think when the game changes speed, it sends a "click" to the speedControls hud. if I stick a print in there, it's a waterfall of phantom clicks
#

maybe have to go back to a mousedown event and check from there

#

might help if I looked at the java functions before opening my mouth

silent zealot
#

The UI does a lot of "phantom" stuff, sometimes you can just trigger and set a variable somewhere to not trigger 500 more times

small osprey
silent zealot
#

Glad I never had to do that. Except for exams. Writing code in paper for exams was so stupid.

#

I also missed the punch card era, aka give your stack of cards to the guys that run the computer and then will put them in sometimes in the next week and give you output cards, hopefully those don't just say "syntax error"

small osprey
#

And some people may know that the term "bug" comes from actual real AF aphid getting squished in a relay hence causing .. unintended program behavior πŸ˜„

#

Q: When steam updates workshop mods, how can I see which mods actually updated?

queen oasis
#

the easiest way I know is to go to the steam workshop folder and sort by modified date

#

too late

drifting ore
#

Let's just pretend like that didn't happen

blazing slate
#

@drifting ore infused WHAT!?

queen oasis
#

devil's lettuce

drifting ore
queen oasis
#

be careful kids, you'll get reefer madness

drifting ore
#

TELL YOUR CHILDREN

#

Making recipes for 41 kind of sucks

#

I’m finally done though

queen oasis
#

me and these speed controls are gonna fight

gusty pasture
#

Hey! What’s the correct dimensions and plug ins to have the photos show up in game? For example, I made a profession mod for a reporter and wanted to add the picture to it like all the rest of them have. What do the dimensions have to be and such because what I currently have in there won’t appear. Same for the trait mod I made

craggy nacelle
#

Id like to make zombies attack a non player target like a dummy/mannequin but dont really know where to begin. Does anyone know a few commands or better a mod that does that so i can have a look?

small osprey
#

ffs lua. I just spent an hour debugging a case where I defined a function and a field with the same name in the same table πŸ«₯ . . .

small osprey
craggy nacelle
#

Hm, no that wont work for me, i want to use world objects... like bomb looking dummies... ^^

queen oasis
# queen oasis me and these speed controls are gonna fight

got it whittled down to

local function clickedSpeedControls()
    local sc = UIManager:getSpeedControls()
    return sc:isMouseOver() and Mouse:isLeftDown()
end

if getGameSpeed() > 1 then
  if clickedSpeedControls() or isKeyPressed("Normal Speed" then
    -- change speed to one "Play"
  else
    -- set var to game speed
  end
end
#

I fought with the speed control buttons and the HUD but they won.

#

just have to implement a keyboard check for speed changes but that should be straightforward

clever quarry
#

Can someone help me with the SendCommandToServer function, I know what it does but I have doubts about how to use it, and is it possible to use it on the server side, if not how do I trigger a command like 'createhorde2' and in the case of using it on the client side the client needs to be an administrator?

small osprey
#

Is it me or is setGameSpeed() pretty much binary , everything below 1 pauses the game?

small osprey
# clever quarry Can someone help me with the SendCommandToServer function, I know what it does b...

Phu that is a deep rabbit hole Gusteivos.

First of all, you are on b41 or on b42?
Be aware that, at least on b42, the SendCommand functions (at least one of them, can't remember if the to client or to server) are NOT executed in single-player. You can and need to call your code directly then.
Secondly, to test true multiplayer, you have to run the dedicated server version of the game and the client separately. I have not done that so I cannot comment.
Thirdly, I am not so sure about client-permissions but changing game-world-authorative state you should always do on the server (it will automatically have all the god powers).

My recommendation: Download a mod that does some of that and study it. And you may have a cautious conversation with an AI of your choice about the general concepts of Zomboid server/client, however don't trust its specific code or detailed recommendations.

bronze yoke
#

the argument is an integer so anything below 1 is going to get rounded to 0

clever quarry
#

I'm starting to study how to make mods

small osprey
#

And there is probably no way to suppress/replace the "Game Paused" text 😬

frank elbow
small osprey
clever quarry
#

linux is life

small osprey
bronze yoke
#

the server does barely anything in the current version of multiplayer

clever quarry
#

sad

clever quarry
bronze yoke
#

i think the game still shows you a 'do not play on public servers' warning when you start it up πŸ˜…

clever quarry
#

Now for simpler things like how do I save information on the server side? Does Zomboid have a Lua API for this?

small osprey
bronze yoke
#

you can save stuff to mod data

#
-- returns a table that will be saved automatically
local myModData = ModData.getOrCreate("my unique key")
clever quarry
bronze yoke
#

you can use their username to differentiate the data per player, or save it clientside if appropriate

clever quarry
#

Cool but how do I flush this data?

long beacon
#

Uploaded yesterday but it never showed up on the workshop, didn’t get any errors on initial upload but whenever I updated it also apparently fails, anybody know how to fix it? Formatting should be fine for the files

icy night
#

Released

#

If yall try it, lmk if yall have any suggestions

#

much appreciation for all the helpful tips during production

gusty pasture
#

How do I get an image to work with my profession mod in the character creator? I have the image but I’m guessing the properties are not correct

storm trench
late thicket
gusty pasture
icy night
#

Yeah, my mods not for everyone

#

But I mean irl you can't exactly shoot hundreds of zombies every day without repercussions lol

tired jackal
topaz tangle
#

not something id use in my runs but i can see alot of people liking this

nimble yew
#

came here to make a quick question and found those new gems, congrats!

#

I'm working on replacing vanilla car lift tiles with my own now. I'm hooking on Events.LoadGridsquare to delete the vanilla tile objects and replace them with the moveable ones. Does someone know in which order the world loads squares? I'm about to test it, but maybe someone has insights on this

#

since the vanilla car lift has repeating tiles, it's not a one on one replacement. So I want to wait for the first or last vanilla car lift tile, and then replace them all at once

#

also, being hooked to LoadGridSquare would mean I should keep this converter mod on all the time, right? because it's loaded as it's discovered?

#

that would explain why Water Dispenser doesn't have a "converter" mod.

trim skiff
bronze yoke
trim skiff
trim skiff
# bronze yoke <https://pzwiki.net/wiki/Recipe_(scripts)>
Result
The result of crafting (item type and quantity). Example:

Result:FishingHook=10,
If the result of crafting is an item in a single copy, then the number of items can be skipped.

Result:Hat_TinFoilHat,

sir, can i add 2 type of result in 1 recipe?
for example

Result:FishingHook,Hay_TinFoilHat,
bronze yoke
#

no

#

if you want more than one result type, you can spawn the items in the player's inventory with the oncreate function

gusty pasture
# nimble yew woah, great writing there

Thank you! I’m a news reporter in real life so I wanted to add the profession to the game lmaoo then for some reason, I think maybe because I have superb survivors downloaded, when I choose that profession a bug happens where you spawn with an armed military NPC bodyguard so I came up with that whole lore 🀣

spiral tapir
#

Does anyone know how to make a trait mod? Like I can add my own traits. I want to make a Korean War Vet trait mod.

gusty pasture
spiral tapir
#

Oo very cool !

silent zealot
silent zealot
#

That discussion covered the trait having skills & starting gear, but anywhere you can patch in code you can add a "if player has trait XXXX then do something"

spiral tapir
#

Keeps saying I got a mod info file missing but I have it and it's filled out wtf

topaz tangle
#

Might be in the wrong spot?

spiral tapir
#

this is the correct place right

tacit pebble
spiral tapir
#

im on B42

tacit pebble
tacit pebble
# spiral tapir im on B42

Zomboid\Workshop\Korean War Vet Trait\Contents\mods\Korean War Vet Trait\[[42_or/and_common]]\mod.info

spiral tapir
#

it shows up now thanks

bright fog
#

Wiki links don't use this format

#

Where did you get it ?

spiral tapir
#

what do i do 😭 im no coder so dont make fun of me pls

sharp pendant
#

gonna fix the crusty pictures in the page tho, didn't notice how bad they looked

silent zealot
small osprey
silent zealot
#

Something I didn't see mentioned that would be easy to add: give the player a Base.PressID along with the other gear when they spawn.

#

Those exist in the game,. but only get used for special named reporter zombies.

nimble yew
# silent zealot If you're using your own tiles you can just make two tiles that look identical.

I did exactly that. But when loading the grid, two consecutive squares will have the exact same sprites, so I can't just replace them one on one with my own. I have the place mine in order. So I thought to wait until the last square was loaded and then replace all four at the same time. For that I need to know in which order de squares load, so I don't tru to replace sprites on squares that didn't load yet. Does that make sense?

#

And, is there a chance where a grid is loaded and only half a lift is on it? I could just assume there is a chance, and just replace one by one with some logic around it

small osprey
#

This week I learned:

  • ISUI/ISRichTextPanel is cool (not yet fully explored)
  • I shall not rely on complicated/unreliable game-or-real-world timers in ISUI render functions, per-frame counting ends up smoother
  • Building and using simple runSequence to make async nesting more flexible and readible can be nice, thanks chatGPT
  • assert is cool
  • lua scripting = nice and flexible but oh the type checking during prototyping is important and ends up faster

Looking back, not such breakthrough-learning relative to all the self-inflicted stupidity I ran into. πŸ™ˆ

trim skiff
thin swan
#

35 animations later and the skateboard is starting to feel pretty smooth! Now I can finally focus on making tricks

silent zealot
#

That's an impresisve number of animations for a mod

brave bone
topaz tangle
#

Love this!!!

small osprey
#

So .. whats the status of playMusic(trackName) - doesn't seem to do anything - and I have a hard time determining what a valid track name could even be.
I downloaded and patched https://github.com/zatherz/fevlist to so it doesn't demand a master file and to work with recent v2 of fmod and when I run it against ZomboidMusic.bank all I get is a bunch of GUIDs (because string names may not have been included when TIS build them). I did a sample check in the game files for a reference but to no avail.

GitHub

Small tool to list event paths from FMOD .bank files - zatherz/fevlist

small osprey
thin swan
kind fossil
#

Hey there do you know if it's possible to embed a browser page in a PZ UI Panel?

#

Opening a panel that displays a browser page

#

basically I want a way to display images without having to reload the server and update mods
For example creating a camera mod that would take pictures, upload them to a server and then looking at the item picture would open a panel that would display the image from the server
So not displaying advanced wep pages, only images

bright fog
coarse sinew
kind fossil
#

damn 😦

#

so now way to open even a simple html page ?

#

what about a gettexture?

coarse sinew
# kind fossil so now way to open even a simple html page ?

Unfortunately PZ doesn’t support rendering HTML pages in the UI, there's no embedded browser or web rendering engine exposed to Lua or Java modding.

As for getTexture(), it only works with images that are already part of the game or mod files, so you can't use it to load external images from the internet at runtime. It just fetches preloaded textures from the game's internal texture cache, which includes .png files bundled with mods or the base game.

Also worth noting, there's no real-time image generation capability in Lua. You can't create images from scratch (like drawing pixels manually) because Lua in PZ has no access to pixel-level manipulation or a canvas API. The closest you might get is taking a screenshot, but that's done through internal Java functions (used, for example, to generate the savegame thumbnails), and I'm not sure if that functionality is exposed to Lua at all. I've only seen the Java code handling it.

If you really need to show dynamic web-based images, the only real option is to open the image link using the Steam overlay browser, like via openUrl(url), which will open the link in the Steam overlay (not in a UI panel).

kind fossil
#

damn that's a real bummer

#

yeah I've seen the steam overlay method but it ruins immersion

#

Yeah didn't work 😦

thick bobcat
#

Hi all
Do you know of any mods pulling hordes towards the Player for No respawn Runs?

Like gathering Zeds in a big ball and letting them wander "through" the Players Position?

#

Made a Thing for learning modding with Project zomboid and it works pretty good.
Now i am wondering if thats already been done

fleet bridge
#

and/or stopping people from displaying nsfw content

small osprey
kind fossil
winter bolt
kind fossil
#

so no way to get pictures in game without having to reload the data

thick bobcat
#

If Theres No such Mod i will try to polish and publish it πŸ˜„
The Journey hast been Fun so far

thick bobcat
bright fog
#

<@&671452400221159444>

thick bobcat
#

F***ing fishy the lad

#

Sry

kind fossil
#

it's not the real link don't click

thick bobcat
#

`local modID = "WalkerTest"

GameTime = getGameTime()
WorldSoundManager = getWorldSoundManager()
player = getSpecificPlayer(0)
Radius = 1000

function playSound()

print(GameTime.getStartDay())
print(GameTime.getDay())

local x = math.floor(player:getX())  
local y = math.floor(player:getY()+startVal)   

print(x)
print(y)

WorldSoundManager:addSound(nil, x, y, 0, Radius, Radius)
startVal = startVal - 10
print( "SoundPlayed")


if startVal < -500 then
    startVal = 1000
end

end`

#

i know its bad but using a world sound to move them around works like a charm

drifting ore
#

How is this shit where you can send a fake link in discord still a thing?

#

How does it even work?

thick bobcat
#

i hope it just doesnt in the end

bright fog
small osprey
# thick bobcat Thanks for the immediate Input in how to solve the problem πŸ˜„ Since in am a blo...

Not such a stupid idea for performance if zombies are plenty TBH. for the cell-scanning approach, triggering it once per second might be enough.
Problem might be that when zombies come close and the player moves, the "target" may be not exactly on the player and I also have no idea if it could screw with Z close-range attacks etc. so excluding a small radius around the player may be necessary. All which complicates things so .. if the sound works for you, go for that man!

bright fog
#

Unless playing a world sound causes something you don't want to happen, incompatibility etc then yes you should switch it. But this is a method used in a lot of mods and what this achieves is move both load AND unloaded zombies that are in the player cell and a bit further out

#

Overall, that's your only solution to properly move zombies without being dependant on the player cell range limit which is different in:

  • solo
  • MP
  • modded with a java mod
#

Considering you don't want zombies to target the player directly and just wander around, you should use that yea

gusty pasture
# silent zealot

I did not know this, thank you very much for sharing! I’ll for sure have it updated with this, very thankful!

wary tinsel
#

guys, can someone help me with a scripting situation?

drifting ore
#

Maybe

bright fog
wary tinsel
bright fog
#

That's the whole point of the channel, simply throw your question and someone will check it out

wary tinsel
#

i was just waiting for someone to awnser

bright fog
wary tinsel
#

i need a script that bypasses the sandbox settings and changes the temperature, darkness, precipitation, fog, clouds, and windspeed of a map

#

done

#

i'd do that script myself, but i just don't know the terms

wary tinsel
#

so that's the help i need

#

alright thanks

bright fog
wary tinsel
#

i was about to ask if i should just make weather manager as a required mod

bright fog
#

No idea lol

wary tinsel
#

but i realized that the weather manager mod is b41

bright fog
#

I don't know how any of it work

wary tinsel
#

i'm doing a map for b42

wary tinsel
#

anyway, thanks for helping

bright fog
#

np

lavish zenith
#

New to modding, so this might be ignorant but is there an elegant way to tell a recipe to take ingredients by weight instead of by number of items?

thick bobcat
#

this should work definitely

wary tinsel
#

thanks

thick bobcat
#

Lua Method is global

#

@LuaMethod(
name = "getClimateManager",
global = true
)
public static ClimateManager getClimateManager() {
return ClimateManager.getInstance();
}

wary tinsel
#

ok, another question

thick bobcat
#

oh wait.. maybe not the

wary tinsel
#

how do i make a b42 compatible mod

thick bobcat
#

i think you have to do:

wary tinsel
#

oh

#

forget that question for a sec

#

continue

thick bobcat
#

thats how the ClimateManager.class looks inside

wary tinsel
#

looks confusing for me

thick bobcat
#

maybe its weather:updateFx

thick bobcat
#

but if no one can help we have to solve it on our own

wary tinsel
#

when i did my other maps for b41 for testing i put the files in my zomboid folder it worked

#

now i made a map for b42, but when i put it in the same place as the others it doesn't show up in the unstable version

thick bobcat
#

structure has to look like this if that helps

#

Horde\42\media\lua\client\StrollingHordes

wary tinsel
#

oh

thick bobcat
#

the 42 folder is new

#

but inside that its the same as b41

wary tinsel
#

so i thought it'd be the same now

#

instead it was named shared

thick bobcat
#

i dont think you need one but what u need is that 42 folder

wary tinsel
#

i'm confused

thick bobcat
#

that is what i wanted to point out

#

yeah sry

#

texting is not my strong suit

wary tinsel
#

understanding is not my strong suit

thick bobcat
#

ha xD

wary tinsel
#

if i'm not seeing a person doing it infront of me i can't really learn well

thick bobcat
#

ok i try visually

#

C:\Users\Countrydoge\Zomboid\Workshop\TestMod\Contents\mods\TestMod

wary tinsel
#

anyway

#

thanks

thick bobcat
#

basically you just have to move your mod inside the 42 folder

#

the rest is just coding it so it works with b42s base code

wary tinsel
#

oh wait

#

i just realized i put it in the wrong folder

#

or did i

#

because the mods i put in the same folder didn't appear in the unstable version

#

just gotta wait for it to update since i keep switching normal to unstable and verse versa frequently

thick bobcat
#

hope it works now πŸ™‚

#

found another thing

topaz tangle
#

i dont evven know how this has happened

thick bobcat
#

hahah was that a scooter?

topaz tangle
# thick bobcat hahah was that a scooter?

semi truck 😭

i need to figure out the attachment system so the texture isnt done but i have absaloutly no idea why it has decided 90% of the model just doesnt exist

thick bobcat
#

has to be mitsubishi if its that narrow xD

topaz tangle
#

dodge LN 1000

got a few of these SUPER thin semis im gonna do
it will have a more regularly shaped varient

thick bobcat
#

yesss i like that

#

the super thin ones actually

topaz tangle
#

they are SO funny looking

thick bobcat
#

share a sneak peek please

topaz tangle
#

this is what the model SHOULD look like

thick bobcat
#

is that a SPOILER

topaz tangle
#

nope!

thick bobcat
#

ah the hinge

#

damn

topaz tangle
#

yeah the 5 wheel

thick bobcat
#

i will further pretend to see a spoiler

topaz tangle
#

i might so some goofy stuff like that on a couple vehicles in the future but right now i no no wanna

storm trench
ornate fulcrum
#

i dont know how to make mods or if this is the right chat for this but i had an idea for a mod that replaces some of the zombie spawns with npcs to simulate a more realistic day one. have people running in the streets, a group fighting zombies in spiffos, people in their homes, etc. some could be friendly some could be hostile. if enough group up they fortify, have premade blocks on the map set up that they go to and set up a base over time.

topaz tangle
topaz tangle
ornate fulcrum
#

you guys are amazing im not sure how i didnt find this before

craggy nacelle
#

So i was playing around with recipes and OnCreate/CanPerform & OnTest - but is it normal that these functions are called from all over the place? heck its own module seems to trigger OnTest, or in my case Log_DMA_OnTest multiple times, what are the chances for outside modules to do that? Same for the other two functions, also not that often. I just dont get whats going on, can someone enlighten me pls?

bronze yoke
#

ontest is called for every single ingredient that could possibly be considered for the recipe every time it is tested

#

i'm not entirely sure when oncanperform is called, but it's used to check if the player is allowed to craft a recipe (basically any condition that isn't to do with the ingredients, which is what ontest is for) so i'd imagine it's nearly constantly (as it has no idea what these conditions are or when they might change)

#

oncreate should only be called once, when the recipe is crafted

craggy nacelle
#

Huh, hm, OnTest makes sense, and i guess OnPerform too if it just checks if the recipe can be used, but why would the OnCreate be called from outside then? Hm, ill test it again, maybe i made a mistake somewhere (which isnt unlikely ^^) Thx. πŸ™‚

#

Ok, youre right, the OnCreate is really just called once. Also the debug says its called from a nother mod? Hm, ok that clears it up. Thx again. πŸ™‚

gusty pasture
#

Hey guys, I’m trying to add the press badge into the reporter mod but for some reason it isn’t working. I’m using:

Events.OnNewGame.Add(function(player, square)
-- only for Reporter
if player:getDescriptor():getProfession() ~= "reporter" then return end

local inv = player:getInventory()
inv:AddItem("Base.Notebook")   -- notebook
inv:AddItem("Base.Pen")       -- pen
inv:AddItem("Base.Camera")    -- camera
inv:AddItem("Base.PressID")     -- press badge
craggy nacelle
#

Do you only want to use it when the game is new?

#

Scratch that, didnt use that event before, so i had to look it up. uhm whats the error in your debug?

gusty pasture
#

Not sure, how could I check that? And I was trying to do it like that so when you start a new character you spawn with it on you

craggy nacelle
#

Yeah, thought so. The debug has an, whats the word, error window? You could look it up there.
Also, maybe just to test it out, move the function to its own place, give it a proper name and call it through that. Not sure if it helps, but it will help you to see if the function has a problem if you couple it with something else too, like keypress or mouseclick (just to make sure its not the function itself that has a problem).

#

Easier to track errors if you dont have to relog with a new character everytime.

gusty pasture
#

found it

#

it says: LOG : General , 1745025668188> ERROR: ItemContainer.AddItem: can't find Base.PressID

topaz tangle
#

if your mod is in b41 that might be why

eternal loom
#

you ever get that mod done by chance?

gusty pasture
topaz tangle
#

im not sure,
i believe there is a tutorial out there somewhere

gusty pasture
#

Is b42 the current version of the game? I made this mod a few days ago so I think it should be in b42 unless thats not the current version

topaz tangle
gusty pasture
#

When you say unstable, how unstable we talking lmaooo

bronze yoke
#

mostly balance issues, unfinished content, and the occasional save breaking update

#

the really severe bugs get cleaned up fast but they are often there

topaz tangle
gusty pasture
#

Thanks! How do I make my mod appear in that version?

#

Where do I put the files and is it the same as the previous version? Can I just copy and paste the folders?

orchid star
#

Hey uh you guys know how I can make custom VHS tapes?

icy night
orchid star
silent zealot
#

Short version is make a folder names "42" that you copy everything into, make a fiolder named "common" that you leave empty, then try it in B42 and see if you need to fix anything.

#

Recipies will 100% break, your mod will likely be fine or just need a very small tweak.

gusty pasture
#

Perfect thanks for the guidance πŸ™πŸ½

spiral tapir
silent zealot
#

I can see why the Aiming and Reloading stuff is not working:

#

Koreavet is the variable that gets assigned to the new trait (really a profession, but internally it's a trait)

#

but then you call ww2vet:addXPBoost()

#

instead of Koreavet:addXPBoost()

#

@spiral tapir tagging to make sure you don't miss that, since I didn't reply to your message when I started the comments

#

Also, what is this for? Events.OnPlayerUpdate.Add(playerUpdate);

#

Your function for adding the items is created inside the arguments list of Events.OnNewGame.Add() which is fine, LUA is crazy like that... so there's no need to call any additional Event.Add stuff.

#

Also... congrats on your first mod!

#

...I probably should have opened with that. πŸ˜›

spiral tapir
#

I'll have to change it then when I get the chance

silent zealot
#

Easy to fix.

spiral tapir
#

Im laying in bed rn for sleep lol but I'll fix it tomorrow first thing

#

Thanks for pointing that out though I missed it

spiral tapir
#

And it did

#

It got some stuff working like making it show up on the info and making the gun spawn

#

I literally have no knowledge of programming so I slapped random things together from other mods and A.I. 😭

spiral tapir
# silent zealot

Wait where did you get this from?? It's all koreavet for me already

silent zealot
#

subscribed on steam and looked at the downloaded files.

#

If you already pushed a new version to steam sometime the client doesn't immediately update, sometimes it gets "stuck" until you unsubscribe and resubscribe.

lavish zenith
#

Is there an elegant way to tell a recipe to take ingredients by weight instead of by number of items?

silent zealot
#

Nothing about the recipe system is elegant.

#

You can use "uses" if the ingrediant has a UseDelta,

#

And the fluid system allows for "X mL"

#

But I don't think any recipe does "use X weight of this item"

long beacon
#

How might one make a mod that allows for radio messages to be seen with the deaf trait

silent zealot
#

So you'd have to write a custom OnTest and a custom OnCreate to reduce the weight

lavish zenith
silent zealot
long beacon
#

can't find the reference for the function switch that interacts with the deaf trait to prevent messages coming through either

silent zealot
#

It's not going to be in a singel neat place, it will be everywhere being deaf has an effect.

long beacon
silent zealot
#

...bad news. looks like it's in java.

long beacon
#

it's ok I'm relatively familiar with java

#

programmed minesweeper in it in two hours for my final in high school

silent zealot
#

It's not OK, because making a java mod is a very big deal.

long beacon
#

oh true

silent zealot
#

You can do it, but you're committing to extra ongoing work to keep it up to date and requiring users to do manual installation, so it needs a big payoff to justify that.

long beacon
#

not viable for a server

silent zealot
#

Also there's no neat way to have two mods update the same Java file.

#

yeah.

long beacon
#

a workaround mod might be preferable then

#

maybe an extra tab or a redirect to a different tab in chat

silent zealot
#

Maybe if the mesages are in lua at some point you can create a whole parallel display of them, instead of relying on the EmitterSound or whatever the proper system is

long beacon
#

which displays incoming radio messages, that is

silent zealot
#

How are these radio messages being generated? The built-in radio stuff, or other players using radios?

hexed stirrup
#

Spawn points lua, it lists spawn coordinates for various professions

#

Im editing one rn to have only one spawn coordinates, for all professions. How do i set up the "any profession" bit

silent zealot
#

I used that and it worked for every profession.

#

I see a lot of mods list every profession with the same co-ordinates, but... that was fine for me.

#

(in B42, though it is probably the same in B41)

hexed stirrup
#

oh you answered before i got hte screenshot

#

thanks

silent zealot
#

Looks like a different syntax, 5 numbers - presumably "cell" and "location within the cell" - is that B41?

hexed stirrup
#

yes

#

im tryna get the coordinates fromthe online map but im not sure what to input where

#

there are 3 sets of coordinates

silent zealot
#

enable the grid overlay

hexed stirrup
silent zealot
#

My guess:

#

worldX & Y are the cell

hexed stirrup
#

they are

#

okay i got them down now imma try if this spawn point works

#

brb

silent zealot
#

Exception thrown java.lang.RuntimeException: can't create player at x,y,z=7732,11899,1 because the square is null at IsoWorld.init line:2799.

#

Looks like bad co-ordinates.

#

Z 1 == 0ne level above ground, is that correct?

hexed stirrup
#

the spawn i want is on first floor so i assumed i should input z=1

#

this the spot

silent zealot
#

what numbers did you put in?

hexed stirrup
silent zealot
#

Looks rigth

#

a groundlevel, mayeb B41 can't spawn on levels onter than ground?

hexed stirrup
#

ill try 0

#

look how the new spawnpoint appears ingame

silent zealot
#

The structure for "maps" is weird. (and spawn point mods are technically maps)

hexed stirrup
#

No error this time

#

I spawned in the prison

#

But a few cells off

#

Not cells uhh the small squares idk what theyre called

#

I spawned outside the room

silent zealot
#

Maybe the web map is slightly wrong on nuimbers

#

When I looked up the chef earlier using teh map I was ~5 tiles east of a kitchen, in a book shop

#

Are you in debug mode? rigth click the gorund, check the X & Y coordinates.

hexed stirrup
#

How do i get debug mode?

silent zealot
#

Start the game with -debug as a command line parameter

#

Debug mode is very very very handy for working of mods and testing stuff

#

(that link is not the only way to enable debug mode, but it's an easy way)

hexed stirrup
#

I got it im loading into the world now

hexed stirrup
silent zealot
#

even when right clicking on the ground?

hexed stirrup
#

Yeah there are some menus i looked through all of them

#

No coordinates

silent zealot
#

Must be a new B42 thing. Just a sec, you can use the lua console.

#

p=getPlayer();print(string.format("%d, %d, %d", p:getX(), p:getY(), p:getZ()))

hexed stirrup
#

thanks

silent zealot
#

B42 brings up this when you click on the ground:

hexed stirrup
hexed stirrup
#

i should have the right coords now

hexed stirrup
#

It worked

#

Even with z=1

#

Im exactly where i wanna be

#

Thanks for the help

hexed stirrup
#

Imma see if it workd

#

im making a thumbnail for it now in photoshop

#

close enough

#

could this be my first mod

#

Even if its a small tweak for personal use

silent zealot
#

Plenty of mods on the workshop are very small.

#

Don't forget to make a 256x256 preview.png (for both the mod AND the workshop folder)

#

The workshop folder is what shows up on steam, the mod.info one is what shows up in-game