#mod_development

1 messages · Page 269 of 1

grizzled fulcrum
#

You're going to need to be more specific on what you want but if getVehicleById isn't working, it might be because you have {} around the variable? It needs to be a string like getVehicleById("Base.ModernCar") (WRONG)

#

unless lua turns table into string automatically which would be really weird thing to do

#

Also if you transmit all the things properly, you shouldn't need to sync it to the client

indigo copper
#

no this -> {} just Example

#

-- server
local vehicle = addVehicleDebug("Base.ModernCar", IsoDirections.E, nil, getCell():getGridSquare(player:getX(), player:getY(), player:getZ()));
sendServerCommand(player, 'MY_module', 'MY_command', {vehicle = vehicle:getId()}); -- vehicle:getId() is not nil

-- client
function OnServerCommand(module, command, arg)
local vehicle = getVehicleById(arg.vehicle);
-- arg.vehicle is not nil
-- vehicle is nil <- WHY????
end

grizzled fulcrum
#

getVehicleById can return nil if the vehicle doesnt exist

#

check what the value of arg.vehicle is before the getVehicleById call

#

wait huh

#

I see what you mean now lol

#

Let me double check something

#

yeah I thought so

#

this is why the Java codebase is so bad rn

#

getId() doesn't return the Module.Type of the vehicle

#

It returns a number, assuming to be the id of the vehicle in the world, but in my testing it always returns 255

#

You probably want vehicle:getFullName()

indigo copper
#

wait

#

getId() is 0~255 limit?

grizzled fulcrum
#

yes it's a short

indigo copper
#

fuck

indigo copper
grizzled fulcrum
#

if you're just trying to sync the id, it should do it by itself

#

but currently there is no real known way to set a short in Lua as far as I know

fleet bridge
ancient grail
indigo copper
ancient grail
indigo copper
#

OnClientCommand()

ancient grail
#

you should probably not use players as source of sq and direction
unless you check if its the same player that sent the command perhaps

#

yeah nvm i think thats fine

#

if i would do this however ill just send the x y z to the server and not rely on player

indigo copper
#

thank you

ancient grail
indigo copper
#

but Not resolved my problem...

ancient grail
fleet bridge
#

are you trying to spawn a car for a player?

#

i dont really understand what you're doing

#

player can only "witness" something if its on a loaded chunk

#

no square means everything in that square is nil

#

your best bet is to have client send a command to server to spawn a vehicle, and client is the one issuing the x,y,z params

#

if you're doing it the other way, vehicle will be nil unless the square that the vehicle is on is loaded

#

so you can do

local vehSq = vehicle:getSquare()
if not vehSq then return else vehId = vehicle:getId() end```
#

but if the square isn't loaded then the client doesn't know a vehicle is there 🤷‍♂️

indigo copper
fleet bridge
#

No player has to load in a square that has the vehicle for the vehicle to exist

#

On client side

indigo copper
fleet bridge
#

if the vehicle is at 1000,2000,0

#

but the square does not exist for the client

#

then the vehicle will also not exist

indigo copper
#

spawn vehicle on player:getX,Y,Z()
this vehicle is not exist??

fleet bridge
#
addVehicleDebug(vehArgs.vehicleToSpawn, vehArgs.spawnDir, nil, getCell():getOrCreateGridSquare(vehArgs.vehicleX, vehArgs.vehicleY, 0))```
#

make sure your z is 0

#

it wont spawn at z=1 for instance

#

vehicleX and vehicleY is just getPlayer():getX() and getPlayer():getY()

indigo copper
#

vehicle is spawn success
but client side getVehicleById(vehicleId) is nil

fleet bridge
#

if you just spawned it in

#

that number might be something else

indigo copper
#

server side vehicleId === client side vehicleId
i'm check success

fleet bridge
#

so when you get the Id for the client and server it is the same id?

indigo copper
#

yes

grizzled fulcrum
fleet bridge
#

has to be less than 1

grizzled fulcrum
#

that's something I assumed, guess I'm changing stuff

fleet bridge
#

it can float in the air but it should drop to the ground

#

if you use debug tool for vehicle angles, you can sometimes see z is between 0 and 1, and you can drop it to set it to 0

grizzled fulcrum
#

but if there is a floor tile at z 1 will it just bug out?

fleet bridge
#

iirc it cannot be spawned above ground floors

grizzled fulcrum
#

oh

#

I did not know that, thanks

civic prism
#

is there a mod that reduces tv xp?

ancient grail
#

cuz i thought maybe its able to phase thru zeds and structure to make it seem its on higher z

bronze yoke
#

vehicles can go to zs higher than 1 but i don't think they spawn there, it's quite noticeable because they don't even collide with anything up there lol

#

there's a couple clips of people getting into crazy car crashes that launch their car into the air, and it clips through a second story wall and lands inside a building

ancient grail
#

yeah something messes with the vehicle physics during mp desync

#

maybe multiple clients are sending opposing commands
and it breaks

indigo copper
# indigo copper -- server local vehicle = addVehicleDebug("Base.ModernCar", IsoDirections.E, ni...

i'm find this
OnServerCommand -> CarController init
개 거지 같은거 샌드서버커맨드가 먼저 호출되고 그 다음 차량 동기화가 호출되네 진짜 개 빡치네

LOG : General , 1731088786352> 1,193,091,192> [test] vehicle_spawn_succ number 229
DEBUG: Vehicle , 1731088786378> 1,193,091,217> CarController.<init> > Vehicle vid=229 type=Base.CarNormal has been added at (8104.000488;11778.000977;0.333060) auth=vid:Base.CarNormal(229) pid:(-1) auth=Server static=false active=false

fleet bridge
#

so it seems to work fine

fleet bridge
queen oasis
#

I'm setting a couple things to mod data on an item. size and isoSprite. It works great until I restart my game and it loses the isoSprite.

local treeData = treeItem:getModData()
treeData.treeSprite = tree:getSprite()
treeData.treeSize = tree:getSize()

restart the game and:

local data = tree:getModData()
print("Planting da treez")
print(data.treeSprite)
print(data.treeSize)

and no isoSprite in mod data. treeSize is still there though. I'm lost. Do I need to transmit, even in SP?

bronze yoke
#

objects can't be saved

queen oasis
#

I love PZ. I could probably serialize what I need. Thanks!

red tiger
#

Oh you mean the object instancing.

queen oasis
red tiger
#

Not like data itself.

#

Gotcha.

#

Alright no problem. I read "serialize" first.

queen oasis
#

thought it would be nicer to store the whole object so I could plop it down later

red tiger
#

If you ever need one, know that one exists. =)

queen oasis
#

very light serialization

#

Thanks!

red tiger
#

I use JSON serialization for packet encryption.

queen oasis
#

did you have to write all that? The only real solution I've seen for Lua was written in C

#

nevermind, I just googled it. I guess it is feesible in pure lua

red tiger
#

I solve the issue of speed using coroutines.

#

It's slow but it works and I use it for situations that warrant its use.

queen oasis
#

I tried playing with coroutines but after a few I decided drinking was more fun

red tiger
#

Doing it inside the fake LVM (inside of the JVM), is an additional layer of security for virtual side-channel attacks since the Lua memory is jumbled around more.

#

It's easier to MITM a compromised client on the JVM level since bytecode analysis and modifications are very easy.

red tiger
#

PZ is one of the funnest sandboxes for writing & testing security solutions.

#

It's addicting haha

#

But yeah the tools I wrote for it are open-source if you ever want to pick at it.

#

coroutines helps a lot with single-threaded environments with limited calc time.

#

It's pho-async but it's better than nothing.

queen oasis
#

I've got a bunch of your git goodies bookmarked. some neat stuff

#

I'll get around to pythoid one day

red tiger
#

When I release a revised client-side anti-cheat I'll document my tools a bit to help people who may want to use it or further it in any way.

#

I wrote a solution that both the client and server work to create an encryption key and then update it ever-so-often.

#

Really neat for anyone who writes mods or their own anti-cheats in the future to secure their code.

red tiger
#

<3

scenic breach
#

i uhh can't get this to work somehow

TraitTest

TestProfessions = {}

TestProfessions.addTrait = function ()
    
    local LuckyStart = TraitFactory.addTrait(
        "LuckyStart",                              
        getText("UI_trait_luckystart"),            
        1,                                         
        getText("UI_trait_luckystartdesc"),        
        false                                      
    )

        local weapon = {
            [1] = "Base.KitchenKnife",
            [2] = "Base.Spoon",
            [3] = "Base.PipeBomb",
            [4] = "Base.WoodenMallet"
        }

        function LuckyStart.OnNewGame(player)
            local Item = weapon[ZombRand(#weapon + 1)]
            getPlayer():getInventory():AddItem(Item)
    end
end
grizzled fulcrum
#

The return value of addTrait doesn't have anything to register events

scenic breach
#

yup, going through this chat looking for reference i could use

#

and also from mods

grizzled fulcrum
#

you need to do that separately like

function TestProfessions.OnNewGame(player, square)
    -- your code here
end

Events.OnNewGame.Add(TestProfessions.OnNewGame)
#
TestProfessions = {}

TestProfessions.LuckyStartWeapons = {
    "Base.KitchenKnife",
    "Base.Spoon",
    "Base.PipeBomb",
    "Base.WoodenMallet",
}

function TestProfessions.LuckyStartNewGame()
    -- your stuff here
end

function TestProfessions.addTrait()
    local LuckyStart = TraitFactory.addTrait(
        "LuckyStart",
        getText("UI_trait_luckystart"),
        1,
        getText("UI_trait_luckystartdesc"),
        false)

    Events.OnNewGame.Add(TestProfessions.LuckyStartNewGame)
end
#

something like that

#

but if you plan on adding lots of traits, I'd go the route of having a separate lua module per trait so in your main traits moduel you can just handle all of that in one place

scenic breach
#

okay, 👍

#

I don't plan adding more traits, just this one

grizzled fulcrum
#

.

#

.

grizzled fulcrum
scenic breach
#

Thanks 👍

grizzled fulcrum
#

those replies you only really need to do if you plan on spending a decent chunk of time for modding

finite badger
#

Hey guys, hope you can help.

I'm trying to add some specific settlement machines to my server. I haven't modded much zomboid before, but other games.

Criteria:

  • The machines should not be moveable by any other than admins. I've added 60 base weight to the items and tile assets for that reason.
  • Admins will place them by item viewer adding them to the map and then placing it, like normal furniture.
  • A bunch of recipe scripts are made and tied to the machines through NearItem.
  • Specific machine sounds play when the player makes a recipe.

Now, through trial and error I've come so far as to draw the assets in GIMP, make a .pack file, a tiles file, item icons, and the item and recipe scripts in /scripts.

But in-game, it doesn't seem to call the item and recipe scripts in /scripts correctly, and I dont know why. No item icon, no possibility to place the "furniture" even though i've tried to define it as "moveable"

Also the debug log gives me "cannot create recipe for this moveable item: Base.Refinery, warning, moveable not valid"

which is strange, since i've defined it as moveable.

My bet is I'm missing some lua code, but currently have no idea what to write.

Hope any of you can help! thank you.

Workshop page: https://steamcommunity.com/sharedfiles/filedetails/?id=3361737245

#

hmm might be a question of bad item naming in shared/translate

brittle geyser
#

zomboid really is the "coziest" game

finite badger
# grizzled fulcrum share ur item script

module Settlements

{
imports
{
Base
}

item Chemlab
{
    DisplayName        = Chemlab,
    DisplayCategory = Furniture,
    Type             = Moveable,
    Icon             = item_chemlab,
    Weight            = 60.0,
    WorldObjectSprite = Settlements_1,
}

item Cuisine
{
    DisplayName        = Cuisine,
    DisplayCategory = Furniture,
    Type            = Moveable,
    Icon            = item_cuisine,
    Weight            = 60.0,
    WorldObjectSprite = Settlements_0,
}

item Refinery
{
    DisplayName     = Refinery,
    DisplayCategory = Furniture,
    Type            = Moveable,
    Icon             = item_refinery,
    Weight            = 60.0,
    WorldObjectSprite = Settlements_2,
}

}

coarse sinew
# finite badger module Settlements { imports { Base } item Chemlab...

Remove the item_ from Icons, and rename the icons .png's to Item_. And the NearItem attribute in the recipes scripts actually are the moveable names, compose from "CustomName" + "GroupName", you can see this name in the object name filed (in debug press F2 and see the attached image). In this case the door isn't a moveable, but I assigned this name through my mod.

#

unfortunately I can't run your mod, I don't have all the requirements enabled, I see some items from other mods

finite badger
#

so;

  1. in items script change ot : "Icon =cuisine" and file name "Item_cuisine.png"
  2. in recipes script change NearItem to the Customname Cuisine
  3. do I need Groupnames?
#

thx so much, also for the f2 tip

coarse sinew
#

No, you just need GroupName or CustomName

#

This is how you use both

finite badger
#

thank you man, helps a lot

queen oasis
#

Video shows the issue and I can't figure out why the highlighted squares flicker on one side. Any help would be very appreciated. The code for highlighting, which runs off of the OnMouseMove event:

setBigDrag.mouseMove = function()
    if not setBigDrag.isDragging then return end
    local plZ = getPlayer():getZ()
    local endX, endY = ISCoordConversion.ToWorld(getMouseXScaled(), getMouseYScaled(), plZ)
    setBigDrag.endX, setBigDrag.endY = endX, endY
    local x1, x2 = math.min(setBigDrag.startX, endX), math.max(setBigDrag.startX, endX)
    local y1, y2 = math.min(setBigDrag.startY, endY), math.max(setBigDrag.startY, endY)
    for x = x1, x2 do
        for y = y1, y2 do
            local square = getSquare(x, y, plZ)
            if square and square:getFloor() then
                square:getFloor():setHighlighted(true)
            end
        end
    end
end
#

forgot to get my desktop off there

#

for reference, setBigDrag.startX and startY are set at OnMouseDown event:

local startX, startY = ISCoordConversion.ToWorld(getMouseXScaled(), getMouseYScaled(), getPlayer():getZ())
setBigDrag.startX, setBigDrag.startY = startX, startY
sand parcel
#

How would I apply custom eating animations for items under Type = Food?

bronze yoke
#

the item's EatType parameter sets what animation it uses

rich hearth
#

im trying to know how do i make a mod
i wanna make the game as 2d/3d as possible
im inspired by the road of the dead and doom
could anyone help me
???

sand parcel
rich hearth
#

for any cost

#

just tell me what steps i need to do

#

so i can make it possible

rich hearth
#

if yes we could work toghether

#

i can do the assets

sand parcel
#

i am being so so genuine right now when i say youll have a better time recreating the game from scratch in another engine

rich hearth
#

heck nah

bronze yoke
#

so are you saying you want to make the game first person? step one is 'rewrite half of the engine' and step two is 'recreate nearly every art asset in the game'

#

it's a game sized project

rich hearth
#

yes but people would love it

#

and we wouldn't need to be copying PZ

#

like vain did

sand parcel
#

please 🙏 just make a new game

#

what do you mean "we dont need to be copying pz"

#

its not pz if youre not copying pz

rich hearth
#

i don't wanna copy project zomboid

bronze yoke
#

what's your experience with game development

rich hearth
#

from scratch

#

0

#

but assets 50%

sand parcel
#

this is NOT a good first mod to try making

#

and especially not a good first game

rich hearth
#

demn it ima still try it

sand parcel
#

glhf

queen oasis
#

IsoTree is killing me. There's no way to set javafields is there?

grizzled fulcrum
#

trust me, don't rewrite the engine to support full 3d stuff, just use UE5 or something for the love of god

#

and also the fact that the game is made in java

#

should deter you enough

sand parcel
#

he is an experienced professional

bronze yoke
#

hey now they have 50% experience...

queen oasis
#

and there's no way to save an object? specifically an IsoSprite

#

maybe I'm thinking about this the wrong way

bronze yoke
#

you can't save an object but you can save whatever data you need to reconstruct it

queen oasis
#

IsoTree is just an object with a sprite name and some java fields. I can copy all of that just fine but I can't figure out how to piece it all back together to make a new IsoTree

#

I can get the tree to an item, but when I place it back it is a bare tree

bronze yoke
#

how do these things get set in the first place?

queen oasis
#

there's only a couple of setters on IsoTree.

bronze yoke
#

from looking at the class, setting its sprite should be fine, but the other properties are a little hopeless

#

the game must set them somewhere though and unless it's just randomised or something there may be a way in through that

queen oasis
#

I was wondering if sprites can by created on the fly

bronze yoke
#

sure they can, they have public constructors

queen oasis
#

because it looks like the "tree" gets most of it's constructors from the sprite

#

already looking through that. was just kinda banging my head for a minute thinking

sand parcel
#

Is there a way to make eating a Type = Food item instant? Or perhaps just make the time required very short?

bronze yoke
#

i think the eating action takes a fixed amount of time so you'd have to mess with the action to do it

sand parcel
#

Is there an easier way to just get a 'consume item' action in the context menu with a Type = Normal instead?

bronze yoke
#

not really easier but it can be done with context menus if the actual food stuff isn't needed

brittle geyser
sand parcel
#

I'm not making a food item, I just needed a way to run a function after using an item

#

Was using OnEat for running the function, but it seems a bit unnecessary now lol

bronze yoke
#

this is untested, but i would do it like this:```lua
local handleOptionClicked = function()
print("option clicked!")
end

---@type Callback_OnFillInventoryObjectContextMenu
local addContextOption = function(playerNum, context, items)
local primaryItem = items[1]
if not instanceof(primaryItem, "InventoryItem") then
---@cast primaryItem ContextMenuItemStack
primaryItem = primaryItem.items[1]
end

if not primaryItem:getFullType() == "Module.MyItem" then return end

context:addOption("My Option", nil, handleOptionClicked)

end

Events.OnFillInventoryObjectContextMenu.Add(addContextOption)

#

this creates a context menu option 'My Option' when you select an item of the type Module.MyItem, which fires handleOptionClicked when clicked

sand parcel
#

this script would go into client right?

bronze yoke
#

yeah!

visual abyss
#

does the event.OnFillContainer happen even if a container is empty?

bronze yoke
#

it should fire as long as the container did try to spawn items, even if none of them actually spawned

visual abyss
#

thanks

visual abyss
#

how large is the area for event.OnFillContainer?

sand parcel
bronze yoke
#

ohhh i forgot about operator precedence in lua

#

swap if not primaryItem:getFullType() == "Module.MyItem" then return end for if primaryItem:getFullType() ~= "Module.MyItem" then return end

sand parcel
#

Am I just reading the code the wrong way, and it shouldn't work like this lol?

bronze yoke
#

basically what this line does is ends the function early if the item *isn't* the item you want - if you add multiple then correct items will just trigger the other ones anyway

#

the easiest way to get it to accept multiple items would be to add a lookup table like this:

-- put this outside of the function
local items = {
    "RustRinges.PercentTenRinge" = true,
    "RustRinges.PercentTwentyfiveRinge" = true,
    "RustRinges.PercentFiftyRinge" = true,
    "RustRinges.PercentFullRinge" = true,
}

-- replace the old line with this
if not items[primaryItem:getFullType()] then return end
#

this checks if the item's type is in the table and returns early only if it isn't

sand parcel
#

Doesn't feel like = true should be necessary, right?

bronze yoke
#

it's needed here because the item type is the key

#

it's a little backwards but checking a specific key's value is a lot cheaper and easier than checking the table for a specific value

sand parcel
#

Sounds reasonable, I suppose lol

#

Lua feels like the type of language to do something like that

bronze yoke
#

basically if we did```lua
local items = {
"RustRinges.PercentTenRinge",
"RustRinges.PercentTwentyfiveRinge",
"RustRinges.PercentFiftyRinge",
"RustRinges.PercentFullRinge",
}

sand parcel
#

Ahh, I see

bronze yoke
#

oh come to think of it

#

it should be written as```lua
local items = {
["RustRinges.PercentTenRinge"] = true,
["RustRinges.PercentTwentyfiveRinge"] = true,
["RustRinges.PercentFiftyRinge"] = true,
["RustRinges.PercentFullRinge"] = true,
}

sand parcel
#

Figured something was wrong lol

#

But couldn't find anything online about dicts in Lua

bronze yoke
#

lua is all tables, which are basically dictionaries, other structures are implemented by just using tables in a particular way

gaunt meteor
#

I'm making a mod that conflicts with another mod. But the only conflict is 1 lua file, it would work perfectly fine if I could stop that other mod from using that lua. Can I achieve this?

I tried putting same name'd lua file with identical file path in my mod, then having it contain only

return;
end

idk I feel like im doing it wrong 🥲

bronze yoke
#

that should work

#

the override will only work if your mod is later in the load order - you can ensure this in singleplayer by requiring the other mod in your mod.info

#

servers will however need to manually place your mod later in the mod order

gaunt meteor
#

ooh requiring is what i need i think.. thank you! 🙏

ancient grail
ancient grail
ancient grail
gaunt meteor
ancient grail
#

requiring doesnt really stop it
anyways can you share the function youre tying to stop

cuz if that function is being called by other function outside of that lua file then the mod will throw error

#

you can overwrite it this way

function A()
-- original code
end

function A()
   return 
end

#

but if the function is local

local function A()
-- original code
end

then this


function A()
   return 
end

will do nothing

grizzled fulcrum
#

real

gilded hawk
#

Does anyone do unit testing for PZ lua mods? I would like to get better at unit testing, but in lua

grizzled fulcrum
#

It shouldn't be too hard to add your own unit tests

#

I thought about making a full testing library because mainly for performance reasons to test the speed of code (mainly for tick functions and such) but never got around to it due to me just jumping all over the place at different projects

mellow frigate
gilded hawk
#

🤣

#

Alternatively "It does not work with my 250 other mods, and I'm sure that it's your mod the broken one (it's actually not, and another mod is causing issues)"

ancient grail
#

i remembered @abstract raptor youtube vid about commenters
https://youtu.be/LVJeolLxFS0

Like a mod on the Steam Workshop for Zomboid? Well it's time your familiarize yourself with the types of commenters that already exist, least you fall into any of the wrong categories.
#zomboid

🎙️ Welcome to Tawky's Radio Show! 🎙️

Dive into the surreal world of Tawky, the hand-drawn radio with a direct line to... somewhere else. Whether it's...

▶ Play video
frank elbow
#

Theoretically would be possible to do so with a whole lot of mocking

red tiger
#

It'd be nice if the KahluaThread and platform objects were exposed to the Lua side. It'd be nice to control and execute my own threads to perform tasks outside of the main thread entirely.

#

I'd use this for encryption tasks or computationally-heavy tasks for my mods.

#

I can see others using this too for any async needs.

ashen mist
#

i got a question, how does the DB shotgun model work when reloading?

#

since it goes from closed to broken open

#

i'm trying to figure it out since a db shotgun i'm fiddling with is swapping models

bright fog
#

@tranquil kindle

#

Has more experience than me with the system, he should be able to explain it fairly easily

ancient grail
ashen mist
ashen mist
#

oh based

#

thanks man

ancient grail
#

you need to clone shotgun swing xml iirc

#

tho theres also another way i recently discover

i belive it was
setWeaponSprite()

ashen mist
#

mm, i think this might be out of my purview

#

i'm realizing what i'm thinking of doing would need some new modelling n' stuff

#

closest i've managed is slight texture alterations, i've still been unable to even figure out modelling

sand parcel
#

How do I heal an individual limb? As in if I want leftThigh health = 50

bronze yoke
#

you can use something like player:getBodyDamage():getBodyPart(BodyPartType.UpperLeg_L):SetHealth(50)

main adder
#

is there a command to change the value of the full health bar?? in this documentation, I saw a field for OverallBodyHealth but player:getBodyDamage():OverallBodyHealth(70) just brings up errors

bronze yoke
#

you can't access fields that way

#

in this case use the getter getOverallBodyHealth()

main adder
#

but for changing health?

bronze yoke
#

you can use AddGeneralHealth(amount) to add/remove health but keep in mind the game's health system isn't really as simple as a healthbar so it might not have the effect you want

ancient grail
#

anyone has a snippet that prevents player from being able to take stuff from container. (but can see it)

main adder
#

Perhaps I can calculate a percent number of health to add based on what getHealth() might give me?

gaunt meteor
# ancient grail requiring doesnt really stop it anyways can you share the function youre tying ...

yeah all good, i gotcha. its a specific farming function from yaki's weaving (to plant flax), but i have a farming mod that i want to use with their weaving mod.

my farming mod is not supposed to be used with other seed mods that aren't using BTSE_farming.

so, this is why i wanted to disable the farming function of yaki's weaving. i have my own flax being grown and the weaving mod is using that same flax. it is intentional ^^

at the end of the day just disabling that one farming lua from yaki's weaving was all my mod needed to make it compatible

grizzled fulcrum
#

hey @bronze yoke is there really no event which happens when a zombie spawns in the world?

#

I find that really bizarre, we have OnZombieUpdate but no OnZombieSpawned?

bronze yoke
#

there isn't

#

it's one of many major grievances with zombie modding

grizzled fulcrum
#

😮

#

noted

bronze yoke
#

if you're thinking about adding some, an event for getting hit by a zombie is pretty direly needed

ancient grail
#

and maybe onCharacterMeet
triggers once
when 2 characters are within same cell

grizzled fulcrum
#

Like OnPlayerEnterCell?

#

or OnPlayerCellEnter OnPlayerCellExit

#

no clue what that would be used for but it is interesting anyway

ancient grail
#

yes something like that

#

it can be used to turn on and off listener functions

grizzled fulcrum
#

because can't you just use getPlayerByOnlineID(id) and if it returns null then they're not in your cell?

ancient grail
#

like for example my sprite tag
i dont need to set it if the player is far

grizzled fulcrum
#

no, I figure there has to be a func for getting a player on the server from the client that returns nil because they are unloaded outside of your client's cell

ancient grail
#

i want to reduce the memory usage which is why i wanted this event

adding a looped check to do this beats the purpose

grizzled fulcrum
#

oh I see now

ancient grail
#

but when will you check during the game time when they are both on the same cell

grizzled fulcrum
#

well ideally I'd setup some sort of nametag api/thing that you don't need to use a sprite for or would just do the rendering and distance checks on the java side so there's no loss of performance

#

the game does it already for admin nametag/player username thing too

bronze yoke
grizzled fulcrum
#

so even if they enter and exit right after, it wont return nil?

bronze yoke
#

yeah

grizzled fulcrum
#

that's weird

bronze yoke
#

not knowing about unmet players isn't actually a 'feature', it was a last minute panic security patch

grizzled fulcrum
#

A whole drawback to current modding is not being able to access things outside of the client's cell/loading distance area without doing stuff on the server*, but even on the server if no one player has loaded it then you wont be able to do anything

#

so im gonna focus on this more after performance

bronze yoke
#

it didn't behave that way until very late into b41, people were pretty mad because it broke a bunch of mods (and is the reason radio voice chat rarely works)

#

it might even be reverted in the future

grizzled fulcrum
#

I think just being able to force load and unload square/chunk is already a big help for people who do that stuff

bronze yoke
#

it was to stop cheaters who could teleport to each player and instantly kill everyone on the server by simply not telling them where the players are

grizzled fulcrum
#

you ever familliar with mc modding?

#

I refer to it a lot because parts of zomboid remind me of minecraft, how it works in the backend like some networking stuff

bronze yoke
#

not from the development side

grizzled fulcrum
#

hmm well in minecraft, most servers usually have their own anticheat plugin on the server side

#

because minecraft is like zomboid, you can fly and phase through blocks etc without telling the server

ancient grail
grizzled fulcrum
#

that's another thing I find funny

#

cheaters can just make themselves admin lol

ancient grail
#

cuz of java injection i believe

grizzled fulcrum
#

like it really doesn't do any credential checks or something from the players.db?

ancient grail
#

or whatever you call it

ancient grail
bronze yoke
#

in the past i've patched the inventory transfer action

ancient grail
#

ill try that
will it patch rightclick, drag and double click?

bronze yoke
#

yeah

ancient grail
#

just one vanilla function?

#

cool

bronze yoke
#

i think you might also need to patch another function related to taking items when crafting a recipe

ancient grail
#

right right
good idea

#

i should just add moddata to the container if those functions can access it
if not the ill have to add moddata to the item

#

btw albion do you know why the global moddata acts weird

i mean when you reference to something using a variable
if you change that variable it wont affect the original data

but for moddata it does

#

its very weird

grizzled fulcrum
#

show example plez

tranquil kindle
#

Does anyone have idea what dictates delay between starting attack with weapon and it dealing damage and causing zombie to play reaction animation? I'm trying to make a bow, but i'd like for damage to target and reaction to be delayed. Thought that maybe messing with those files in anim XML could work, but setting one of these or both at 1000 does nothing.

    <m_Events>
        <m_EventName>SetVariable</m_EventName>
        <m_TimePc>0.0001</m_TimePc>
        <m_ParameterValue>ZombieHitReaction=Shot</m_ParameterValue>
    </m_Events>
    <m_Events>
        <m_EventName>AttackCollisionCheck</m_EventName>
        <m_TimePc>0.001</m_TimePc>
        <m_ParameterValue></m_ParameterValue>
    </m_Events>

I also found this in 2handed melee weapons, but it also does not seem to work, maybe because my weapon "IsAimedFirearm=True"

        <m_EventName>SetMeleeDelay</m_EventName>
        <m_Time>End</m_Time>
        <m_ParameterValue>12</m_ParameterValue>
    </m_Events>

I also tried changing some item script settings that could from the name of it delay it if it were high enough, but they seem to be no longer used.

#

I'd prefer around 0,5 s of delay if possible, but so far no luck.

hoary hawk
#

I'm confused, is it a gun?

#

I'm a moron, laugh at me for not reading

tranquil kindle
tranquil kindle
hoary hawk
#

Honestly that seems to be about the best way you could do it

#

Maybe some added animation work would help it feel more natural

tranquil kindle
hoary hawk
#

Could possibly find a way to make it load upon aiming, give it a slow aim speed and adjust animation.

#

I don't think that would be too difficult but can't think of an exact way right now.

tranquil kindle
#

That seems like more work, considering all i pretty much would want (if i can't, then whatever, its still pretty good in my opinion) is to delay damage/reaction of zombie by a bit.

hoary hawk
#

Oh, that I'm not sure is possible, you could make it compatible with atro to use projectiles though

tranquil kindle
#

I mean, melee weapons do have delay between start of animation and zombie reaction. Especially sledgehammer

tranquil kindle
#

Thought i ask since someone might've discovered/know something about it

hoary hawk
#

I don't wanna give a positive "not possible"

But I feel like if it were possible I would have figured it out

tranquil kindle
#

My question still stands, If by some miracle someone has any idea, i'd appreciate reply. If not, i still consider it "good enough" for what it is.

hoary hawk
#

@tranquil kindle how did you do your flamethrower?

tranquil kindle
#

Its a gun too, I just messed with Scales of gun in blender to make it stretch muzzle flash to simulate flame and added function on swing to set target on fire

ancient grail
ancient grail
ancient grail
ancient grail
#

and then just drop the item if they rolled it

fleet bridge
grizzled fulcrum
fleet bridge
#

i already went through this exercise lol

#

if you want to add a ton of logic to item transfers best bet is the transfer action function

ancient grail
#

ayt ill have a look rn so i can decide whether to go for items or strings

fleet bridge
#

i use item fulltype when i do it

fleet bridge
#

GrabItem is when you're yoinking stuff off the floor

#

and works for foraging and picking items up off the floor

ancient grail
#
local hook = ISGrabItemAction.isValid
function ISGrabItemAction:isValid()
    if self.item:getContainer():getModData().GatchaMod then
      return false 
    end
    return hook(self)
end
#

oh i hooked on the wrong thing ?

ancient grail
fleet bridge
#

grabbing

#

yea

fleet bridge
#

stuff that spawns wont have custom item mod data

ancient grail
ancient grail
tranquil kindle
#

Gatcha stressed

ancient grail
#

hehe

#

im already done with the tile

gilded crescent
#

Making a patch for my game that lets me saw logs with the chainsaws from britas, but for some reason it's giving me the option even when I have no chainsaw on me, anyone know what might be causing this?

ancient grail
#

youre missing a ,

gilded crescent
#

just noticed that as you sent that, thank you so much

limber harness
#

I tried to add a custom item to proceduraldistributions but it seemed to just break all the containers

#

Maybe I'm not supposed to do it like this?

#

I did it like that with the normal distributions file and it seemed to work there

ancient grail
#

@fleet bridge ```lua

local hook = ISInventoryTransferAction.isValid
function ISInventoryTransferAction:isValid()
local cType = GatchaMod.getCType(self.item)
if cType and cType == "GatchaMod" then
return false
end
return hook(self)
end

local hook = ISGrabItemAction.isValid
function ISGrabItemAction:isValid()
    local cType = GatchaMod.getCType(self.item)
    if cType and cType == "GatchaMod" then
        return  false
    end
    return hook(self)
end

this worked. i was able to put items but when i take them it just bugg action
fleet bridge
#

yea that works but iirc it gives you some error on timed action

#

doesnt seem to cause any issues, except the item may stay highlighted

limber harness
limber harness
#

nah still not working

#

I assume my method is just incorrect

#

this method seems alright but it doesn't seem to allow me to insert a quantity of items?

brittle geyser
#

hi all I'm trying to make a slingshot weapon that uses no ammo type and has unlimited ammo, is this possible via any of the properties?

item ZomboidCrossingSlingshot
{
DisplayCategory = Weapon,
ImpactSound = StoneKnifeHit,
MaxRange = 7,
WeaponSprite = ZomboidCrossingSlingshot,
SoundVolume = 75,
...
Icon = ZomboidCrossingSlingshot,
RunAnim = Run_Weapon2,
CriticalChance = 0,
CritDmgMultiplier = 0,
AimingPerkCritModifier = 0,
AimingPerkRangeModifier = 0,
HitChance = 100,
AimingPerkHitChanceModifier = 0,
AimingPerkMinAngleModifier = 0.05,
RecoilDelay = 25,
SoundGain = 1.5,
ClipSize = 25,
ReloadTime = 50,
AimingTime = 25,
BreakSound = WoodenLanceBreak,
MetalValue = 5,
MaxAmmo = 25,
AttachmentType = Hammer,
}

tranquil kindle
brittle geyser
#

very interesting, if it's melee could it still be ranged?

tranquil kindle
#

If you set range of it, i dont see issue

#

Though then it might be problem with XP gains

brittle geyser
#

thanks Nik I'll try it out

tranquil kindle
#

Since it no longer will be giving aiming EXP

#

Though making it infinte ammo isn't hard either, but a small lua code would do

bronze yoke
ancient grail
ancient grail
#

wait i think i am confused i didnt know table acts this way

bronze yoke
#

yeah this is just how tables work

ancient grail
#

i tested it on regular tables


DATATEST = {}
DATATEST["key"]  =  "var"
print(DATATEST["key"])

local DATATEST2 = DATATEST
print(DATATEST2["key"])


DATATEST3 = DATATEST

print(DATATEST3["key"] )
DATATEST3["key"] = nil

print(DATATEST["key"] )
bronze yoke
#

TESTDATA, TESTDATA2, TESTDATA3 are all references to the same table

ancient grail
#

so i didnt know all this time thats how tabled behaved

bronze yoke
#

lua never implicitly copies objects or tables (modding would actually be impossible if it did)

ancient grail
#

they dont just get reference the actual = represents the table itself

#

o shit

bronze yoke
#

variables don't contain tables directly, their 'value' is the address in memory of the table

#

so when you assign that variable to another one, it just becomes another pointer to that table

#

this is why setting a table variable to nil doesn't delete the table, you're just deleting the pointer

ancient grail
#

so you have to = {}

bronze yoke
#

no, that's just making a new table for it to point to

ancient grail
#

ah

bronze yoke
#

if you want to delete a table you just need to remove all references to it and it'll get garbage collected

#

so```lua
local t = {}
-- table created, 1 reference

t = nil
-- 0 references, table will be garbage collected

local t = {}
-- table created, 1 reference

t2 = t
-- 2 references

t = nil
-- 1 reference (t2) remains, table will not be garbage collected

ancient grail
#

i thought i understood tables
but now i dont think i did

grizzled fulcrum
#

if you know c pointers it's basically that but for tables and userdata only

#

because all other types get copied by value (string, bool, number, etc) but only table and userdata are copied by reference

#
-- Pass by value (copied)
local val = 123
local copy = val
-- val and copy here are referring to different memory (**sometimes), but both are equal to 123

-- Pass by reference
local t = {}
local t2 = t
-- t and t2 are referring to the exact same memory. t2 is actually a pointer that is referring to t
#

I'm not the best at explaining, but think about house and house address
in this case, t is the house (the physical block of land which has a house on it) and t2 is just the address of the house

bronze yoke
#

i would say that it is better to not think of t as the house, they're both the address

grizzled fulcrum
#

true, I just think it's easier to say it like that maybe

#

well easier to understand to someone who doesn't know what pointer is or memory stuff though I am kinda assuming that glytcher didn't know about pointers before

grizzled fulcrum
#

in that, I just meant an address being a pointer and the house being the memory which has the data

bronze yoke
#

they're both just pointers to the actual table in memory, the table isn't stored in the first variable

grizzled fulcrum
#

is that same behaviour in c too?

bronze yoke
#

depends, often but not always

#

you can pass pointers to regular variables but anything dynamically allocated is doing this

grizzled fulcrum
#

is it because the table can be allocated anywhere in the memory?

#

as in it doesn't have a static place in memory just because it's a variable

bronze yoke
#

that's sort of it yeah

#

variables never contain tables, just references to them - the first reference isn't special in any way

grizzled fulcrum
#

ok I think I was just confused with what you meant

bronze yoke
#

you can think of the table constructor as 'create a new table somewhere in memory and return a pointer to it'

#

rather than 'create a table in this variable'

grizzled fulcrum
#

oh yes that makes much more sense when you explain it like that, I thought you were talking about some weird thing I've never heard before lol

#

I see what you mean, I just explained it not that technically

#

It's hard to explain it in lua-like syntax when lua doesn't have pointers lol

bronze yoke
#

yeah 😭 the reason people get so confused about this is because it isn't really a concept lua bothers you with otherwise

#

i don't think PIL really explains it either

grizzled fulcrum
#

it has a small two sentence area explaining that tables and userdata are reference and not copy but that's it

bronze yoke
#

if you've learned a language where pointers are explicit and separate from regular variables it's much easier to disect the differences between them

grizzled fulcrum
#

and it's very easy to miss

grizzled fulcrum
ancient grail
ancient grail
grizzled fulcrum
#

but if you mean if t points to something else then yes t2 will also know

bronze yoke
#

no, t2 is a pointer to the table, it doesn't know or care about t or what it currently points to

grizzled fulcrum
#

oh I misread lol

ancient grail
#

cuz its weird right

when im using debug
and i have function lets say
ontick that prints stuff

if i remove it it will stop

but if you reset the lua file
it will still continue even if you try to remove it it wont work but its there
its just that the variable that used to be its pointer no longer exist so you can stop the event anymore

bronze yoke
#

yeah exactly

bronze yoke
grizzled fulcrum
#

ohh ok

ancient grail
#

whats &t

grizzled fulcrum
#

it's memory location

ancient grail
#

i dont know what language that is

grizzled fulcrum
#

the & is getting the reference (memory address like 0x1234...) of t

ancient grail
#

but i think i understand what youre sayin

#

i only have exp with this using cheat engine and task manager

bronze yoke
#

basically in other languages pointers are explicit and separate from regular value types, unlike in lua where some types are values and some types are pointers and they're treated mostly the same

ancient grail
#

if thats the same

well not task manager
but proccess hacker

grizzled fulcrum
#

cheat engine my beloved that brings me back a couple years lol

ancient grail
#

even the usedata thing is weird and also class

#

like you read from java

bronze yoke
#

kahlua doesn't really adhere to lua's concept of userdata (imo for the better, it is clearly designed for c) but java objects are userdata

limber harness
#

wanted to try something super simple first before trying anything else

brittle geyser
ancient grail
#

use onweaponswing event

brittle geyser
#

perfect

ancient grail
#

wpn:setAmmo(wpn:getMaxAmmo())

you have yo look for proper syntax tho

this is just to give an idea

drifting ore
#

someone should make a mod that replaces the pistol animation while walking with the one from watch dogs

#

make it locked behind aiming level 5

#

would work very well with the already established tactical aiming inside of the fancy handywork and brutal handywork mod

#

imagine it with the realistic trajectory overhaul mod

#

ngl it would work very well if the brutal handywork mod dev just made it.

#

i mean it is LITERALLY BRUTAL

#

another cool mod could be a execution mod (like the knife stealth kill/execute that the hunting knife uses)

#

but instead with a pistol

#

where you shoot them in the mouth blowing their brains out

limber harness
#

What if zombies had finishing moves they could perform on players

drifting ore
drifting ore
limber harness
#

Get fucking suplexed by a zombie

drifting ore
#

you would have the watch dogs pistol walk animation

#

god if i understood how zomboid does their stuff

#

id make a mod rn

#

i barely understand LUA

#

id called it brutal gunplay

#

it

#

would have reworked bolt action rifle animations

#

more military style animations for the m16

#

and a reworked pistol set of animations

#

it would have gun executions

#

for the bolt action you bang them on the top of their head

#

for the m16 you shoot them in the stomach than head

#

for the pistol you blow their brains out through the mouth

#

i also wanna make a mod that lets you climb onto car wrecks

#

and parked cars

#

so you can shoot zombies from on top of them

limber harness
#

has someone made like a singleplayer puzzle map for this game?

#

idk the limitations of creating mods for this game but I imagine that it could be possible to make special keys that only fit in certain doors

#

with specific spawns for zombies along with limited ammo

#

nah not seeing any puzzle maps

true nova
brittle geyser
#

hey is there a way to modify and increase the fish catch chance if you're using a special rod?

wheat pebble
true nova
scenic breach
#

am i doing this right?

#
local testitem = {
    "Base.Fork",
    "Base.Spoon",
    "Base.BreadKnife",
    "Base.ButterKnife",
}

local function AkidTestTrait(playerindex, player)
    if player:HasTrait("Smoker") then
        local inv = player:getInventory()
        local randomitem = inv:AddItem(testitem[ZombRand(0, #testitem)+1])
    end 
end

Events.OnNewGame.Add(AkidTestTrait)
fleet bridge
#

It should work

#

Haven't had my coffee yet drunk

#

You don't need the 0, in ZombRand tho

#

It's always from 0 to #

scenic breach
#

ah, noted

scenic breach
#

this one seems to be working as intended

local function AkidTestTrait(player)
    local testitem = {
        "Base.Fork",
        "Base.Hammer",
        "Base.BreadKnife",
        "Base.ButterKnife",
    }
    if player:HasTrait("Smoker") then
        local inv = player:getInventory()
        local randomitem = inv:AddItem(testitem[ZombRand(#testitem)+1])
    end 
end

Events.OnNewGame.Add(AkidTestTrait)
grim cedar
ashen mist
#

What are the common causes for items to vanish after a server restart?

#

Because I've been tweaking around with the scrap guns mod for server balance and stuff, and I'm noticing there's a single gun that just loves to vanish for no discernable reason without even leaving as much as an error when loading in on the clientside

quiet rain
#

Networking's always a fun one. I'm having trouble with global moddata that is being made, but not transmitted.
Not exactly sure where this is going wrong, but maybe someone can take a look with me.

I have ModData.getOrCreate("Data") running for everyone who doesn't have it yet.
When a specific action is done by a player, data is put the "Data" moddata by doing a remove, getOrCreate, add, and then transmit. Since this is sent by a client, the data should go to the server, correct?
Then I have requests called in by other clients, but they don't seem to receive any moddata.
I'm not sure what I could be missing. Any suggestions, or should I send up the codesnippets? 😄

bronze yoke
#

keep in mind that ModData.transmit doesn't actually do anything with the data, it just sends it to the server for you to handle

#

it just fires the OnReceiveGlobalModData event with the name of the table and the table, it doesn't e.g. copy that to the server's mod data

#

IMO these functions are not really all that useful and i don't personally use them at all

quiet rain
#

Ugh. Is there anywhere I could read up on how to have it actually copied to the server and other clients?

bronze yoke
#

to get it to do what you want with minimal changes you could do this:```lua
local function handleReceiveGlobalModData(name, data)
-- ignore other keys (e.g. from other mods)
if name ~= "MyModDataKey" then return end

ModData.add(name, data) 

end

Events.OnReceiveGlobalModData.Add(handleReceiveGlobalModData)

#

personally i recommend just sending the specific data you're changing with server/client commands though, so you don't have to send the entire table over the net every time

quiet rain
#

...Oh. Right. Yeah, I see the logic now.
The table is one that won't get changed very often, but may as well get that right in one go.
Thanks Albion, always a lifesaver 🙂

fleet cloak
#

How do I make a mod for custom VHS tapes

limber harness
#

working on my first gun mod

#

basically works, just doesn't exactly line up with the existing animations

#

It shoots automatic but not as fast as I was hoping

#

I set RecoilDelay to 0, what else affects firing rate? I hope it's not dependant on the shooting animation

limber harness
#

from what I am seeing, there isn't a real official way of increasing the fire rate of a weapon other than setting recoildelay

#

unless it's tied directly to the shooting animation time?

brittle geyser
# true nova So how the game checks for this id think modifying the ISFishingAction class to ...

yoooo I got it to work thanks!!!
It's jank (lua beginner here) but I wrote something like this

`require "Fishing/TimedActions/ISFishingAction"

local originalAttractFish = ISFishingAction.attractFish
function ISFishingAction:attractFish()
originalAttractFish(self)
local rod = self.character:getPrimaryHandItem()
if rod:getWeaponSprite() == "ZomboidCrossingFishingRodGold" then
return true;
end
... rest copied from original ISFishingAction.attractFish
end`

vagrant ledge
#

Ahem

#

Is there a max length to LUA files or something?

bronze yoke
#

i think somebody did run into something like that, but it is so high that you shouldn't be able to run into it unless you're doing something like mass generating huge amounts of code

vagrant ledge
#

For some reason the logic I wrote wasn't working correctly and it just wasn't acknowledging a huge chunk of the code, but when I removed some other unrelated functions it worked. Couldn't figure it out, but moving half the functionality to a separate file and cutting down the code from 500 lines to 300ish per file just. Fixed it.

#

¯_(ツ)_/¯

dry chasm
bronze yoke
#

a runtime error in the file's main execution could also cause it

ashen mist
#

Is there a way to force cycling with every reload?

#

I've made it so a rifle can load all its rounds at once with a 5x slower reload compared to normal to bypass the single loading getting janky with repeated reloads at higher levels

#

And it works fine reloading from empty, but it can reload at say, 1 in the chamber and it bypasses most of the intended slowness

vagrant ledge
quiet rain
fleet bridge
quiet rain
fleet bridge
#

so theres no data

#

thats why ModData.add is throwing an error

#

unless the data value is specifically false

quiet rain
#

Yeah, no. I understand that there's false means there's no data. But there is data in the moddata 😅 At least for the player who's executing the function.
I'm kind of stumped on where it's going wrong.

fleet bridge
#
local function OnReceiveGlobalModData(key, modData)
    if key == "key" and modData and type(modData) == "table" then
        --yourcode
    end
end
Events.OnReceiveGlobalModData.Add(OnReceiveGlobalModData)```
#

if you're on debug, you can just do ModData.request("key")

#

then look at the global mod data on client side and see what you're getting

#

if you open debug console and just type in ModData.request("yourtable") it'll get the mod data from server, then you can open the globalmoddata debug tool to see what your client gmd is

#

and you can see exactly what the info is

quiet rain
#

Wouldn't doing a ModData.request not have much point, since the server isn't getting the moddata in the first place?
The client running the function has the globalmoddata, and I can see that in the debug option.
Yeah, running the command does nothing to change it.

Well, I figured out why the server isn't getting it, bleh. 'Request for non-existing table' That's a new one.

fleet bridge
#

^ its just part of the debug process, but yea not having a table would generally be an issue

quiet rain
#

Which strikes me as odd. Both clients have the table in the GlobalModData menu. But the error would mean that the server doesn't have it?

fleet bridge
#

so GMD can exist purely locally

#

you can do ModData.transmit("key") to send the client mod data to the server

#

then you need the listener event on server to grab the moddata and add it to the server global mod data

quiet rain
#

Ahh... I do have ModData.transmit, and I thought the

local function handleReceiveGlobalModData(name, data)
    -- ignore other keys (e.g. from other mods)
    if name ~= "MyModDataKey" then return end
    
    ModData.add(name, data) 
end

Events.OnReceiveGlobalModData.Add(handleReceiveGlobalModData)

Would be the listener event to add it to the server data?

ancient grail
#

i just learned a weird thing


local sq = getPlayer():getSquare(); 
local corpse = sq:getDeadBody()
print(corpse)
print(getPlayer())

before running the code what do you guys think will print

grizzled fulcrum
#

that's how you can do relatively quick java type checking

#

but in reality you would mainly use instanceof

grizzled fulcrum
#

like you put that event callback on the server

#

I personally don't know what it means by receive, like is that adding, removing, transmit, request?

#

actually now thinking about it, you're probably right in that it's used for ModData.transmit

#

and then it will copy it to server ModData

quiet rain
#

I imagine onreceive is when it gets some new data in.
What just confuses me now is that I do a ModData.add and a ModData.transmit for the client who adds the data to the globalmoddata, and that shows up fine in the debug. But the server receiving the handle only gets the key, but not the data.

grizzled fulcrum
#

is data false by chance?

quiet rain
#

it outputs that data is false, yeah.

grizzled fulcrum
#

that means there was no mod data found

#

do you create it before you add anything to it?

#

Like ModData.create("blah")

quiet rain
#

ModData.remove("Zone")
ModData.getOrCreate("Zone")
ModData.add("Zone", zoneTable)
ModData.transmit("Zone")

grizzled fulcrum
#

wait why do you remove it right before you getOrCreate

quiet rain
#

That's what it runs every time when a client adds a new are

#

That's... a good question. I might have been trying things out of slight frustration with the removal function 😅

grizzled fulcrum
#

if the remove is needed, use ModData.create() instead of getOrCreate because you know it's not going to exist before that

#

but apart from that, I don't understand why it would be false

quiet rain
#

The moddata shows up fine in the debug, is what stumps me. I'd get if it's false because there's no data. But the data is there, and it's being updated properly for that specific player. But when they throw in an update, causing the handle to be called, the server just says 'nothing here'

grizzled fulcrum
#

did you add a print statement to see if it was false im guessing?

quiet rain
#

Yep

grizzled fulcrum
#

also I just want to make sure that you cahnged "MyModDataKey" lol

quiet rain
#

Oh 100% I did 😄

grizzled fulcrum
#

hmm this is weird

quiet rain
#

Huh. I think I got it working now

grizzled fulcrum
#

wat ;-;

quiet rain
#

Or well, progress.
Player A creates a zone A, Player B has no zones.
Player B creates a zone B, player B now has zone A and B

I need to make it sync to everyone the moment changes are made. And, well. Ensure that players who are offline also get the changes

#

The thing I changed now is uhh...

#
local function initGlobalModData(isNewGame)
    ZoneSync.Data.InfoStorageExample = ModData.getOrCreate("Zone");
end

Events.OnInitGlobalModData.Add(initGlobalModData);

I added this, is the only thing I modified. From an error earlier where the error said the moddata "Zone" was unknown to it

grizzled fulcrum
quiet rain
#

Yeah. When a player hops online is a fairly easy sync, just the changes online that need to be synced is what I gotta look into 😄 Probably the server calling a function to all players to request the data.

queen oasis
grizzled fulcrum
#

yep was about to say

#

that's really helpful so you don't have to do it forreach player

quiet rain
#

That... makes it much simpler than I imagined, probably? I take it I can just throw transmit after add in the 'onreceiveglobalmoddata' event?

queen oasis
#

Server gets the data, on receive mod data, do stuff then transmit

quiet rain
#

And just to be sure. From that point on, there's no need to further call requests from the client side? You transmit, and the players get it?

queen oasis
#

When the client starts, you might want to request. Depends on how often the server pushes

quiet rain
#

Yeah, aside from the people that are offline, I mean. But as far as people who are already online, it's considered done?

queen oasis
#

If you're updating clients when the data changes, you should be good

quiet rain
#

Alright. I'll hopefully figure it out from here. I don't consider myself particularly bad with coding, but networking always has, and always will break my mind 😅

queen oasis
fleet bridge
#

so everything is nil

#

assuming the player is dead of course

ancient grail
ancient grail
fleet bridge
#

this runs while the player is dead? on the "you died" screen?

#

so you're getting the player's dead body on death?

grizzled fulcrum
#

what did you learn about it?

fleet bridge
#

i always thought getplayer() wouldn't return anything when you're dead 🤔

grizzled fulcrum
#

so even if the player dies, the IsoPlayer still exists (idk for how long)

#

esp whben OnPlayerDeath couldn't give the player that died if IsoPlayer was deleted

fleet bridge
#

It passes the player object down on event

#

I guess I'm thinking of before game start that getPlayer will return nil

#

But if you're already in game then it should return something

ancient grail
grizzled fulcrum
#

lol what

ancient grail
#

i have a key press function that lets me move my players square when i press f
as i leave the corpse and the zeds disapear.. so that means the data doesnt exist for the player anymore

fleet bridge
#

it doesn't look like you're receiving any chunk updates

#

probably it returns the last known instance of the player object

quiet rain
#

Thnk you all for the help again. Works perfectly now 😄

bronze yoke
gilded yoke
#

Please someone tell me there is an easier way to externally track player kills without parsing players.db.

fleet bridge
#

getPlayer():getZombieKills()

#

send to server, have server write to file

gilded yoke
fleet bridge
#

no, you do it via lua and send the info to the server

#

you cant do it via rcon, rcon is very limited in what you can do

gilded yoke
#

oh!

#

thanks!

grim cedar
limber harness
ancient grail
hidden jungle
#

Steam isn't letting me update my mod. "failed to update workshop item, result=8"
anyone know whats going on?

#

today i learned that the steam workshop has an 8000 character limit for its descriptions.
and it doesn't tell you thats the error if thats the error.
even on the workshop page it just says "There was a problem trying to save the title and description"

rancid barn
#

is itemzed still a good program to use when making an item, like a gun?

bronze yoke
#

no, it is outdated and doesn't work

rancid barn
#

what should i use instead?

bronze yoke
#

we just write item scripts manually

rancid barn
#

oh

neon kiln
#

anyone know the item name of a walkie talkie?

bright fog
#

By using VSCode and the searching through the files feature you can search for instances mentioning "Walkie Talkie" and from that go back to the item script of the radio items

neon kiln
bright fog
ancient grail
#

any modder interested on co managing a server?
we can talk about the setup and all that ..
a client of nine offered
i kinda want to but im way too busy
so i was thinking maybe someone would like to try this

frank elbow
neon kiln
frank elbow
neon kiln
# frank elbow Yep, that's the full type

Awesome!

inside the server.ini file there is a line to give players' spawning items. I want to give me and my buddies a radio when we spawn, would i place it like this?

# Item types new players spawn with.\nSeparate multiple item types with commas.\nExample: Base.Axe,Base.Bag_BigHikingBag
SpawnItems=Radio.WalkieTalkie1,
#

Sweet, Thanks for your help!

wheat pebble
#

Heyaa, I wanna ask if the mods turned on reloads when you load a saved game or I need to restart the game everytime to reload a mod?

bronze yoke
#

if you're changing them from the main menu, your mods reload when you leave that screen

#

if you join a server your mods will also reload, loading a singleplayer save with a different mod list will also trigger a reload, as well as any time you return to the main menu

wheat pebble
#

I see, tysm for the info

#

I have been losing so much time restarting the entire game for a few changes

pastel sphinx
#

I'm not sure if it's weird that I can never find anything on google for simple problems or perhaps that's the norm because no one has trouble with simple little things that I can never get right and drive me bananas. Ok so I've tried calling this function OnGameStart and EveryTenMinutes but I get the same result. player is nil so the 'if' always fails.

local function PrintPlayerSkillLevelsAndModifiers()
local player = getPlayer()
print("STARSKY starting function")
print(player)

if player then

.......

bronze yoke
#

that's very strange, getPlayer() should not be returning nil as long as a player exists, which is always true when those events fire

queen oasis
#
print(getPlayer())

you can paste that into the command console in debug mode and see what it chucks back at you

bronze yoke
#

can you show how you're adding the function to the event?

pastel sphinx
#

Events.OnGameStart.Add(PrintPlayerSkillLevelsAndModifiers)```
#

I would have pasted that a lot sooner but I had to figure out how to do a code block so I don't look like a complete noob

#

That's at the bottom of the same file

queen oasis
#
local function PrintPlayerSkillLevelsAndModifiers()
    local player = getPlayer()
    if player then
        print(player)
    end
end

Events.OnGameStart.Add(PrintPlayerSkillLevelsAndModifiers)
bronze yoke
#

damn, there was a specific mistake i was hoping you were making but it looks right to me

#

a lot of people accidentally call the function instead of passing it to the event which would make the prints show up but the actual time it'd run would be far before there was a player

queen oasis
#

hopes were dashed

pastel sphinx
bronze yoke
#

```lua

```

pastel sphinx
#

ah thanks. Beautiful

pastel sphinx
queen oasis
#

the only thing I can think of is your folder structure maybe?

pastel sphinx
#

It's in Client? I dropped it into another mod's lua and enabled that mod

queen oasis
#

user/Zomboid/mods/yourmod/media/lua/client/yourmod.lua

bronze yoke
#

as long as it's not in server it should be fine (mixed up my events, anywhere at all is fine), the prints are showing so the file is definitely running

queen oasis
#

I think, I have whisky on my desk

pastel sphinx
#

I have scotch and beer on my desk

queen oasis
#

when that's all typed out, it looks so unnecessary

pastel sphinx
#

Oh yes I see I should put it under the user stuff, I was just cutting corners

#

trying to save the 10 seconds it would take me to create a new folder structure

pastel sphinx
bronze yoke
#

the folder structure in this game is stupid and neither of those will ensure it runs on the server

#

the client loads files from all three folders (including server!!), and the server loads from shared and server only

#

if you want to run code on the server start the file with if isClient() then return end to ensure it doesn't run on the client

#

i will say that, in the case of this specific code:
a) getPlayer() does not return anything on the server
b) OnGameStart does not fire on the server

pastel sphinx
#

That sounds important

#

Guys/Gals, I really appreciate your help. I try to help out as much as possible on the sub-reddit with in-game stuff I know, as I grow as a modder I will do my best to pay it forward

robust locust
#

Heyo, I'm trying to store the buildingID's between loads to mark which one's have been loaded before. I've tried creating a table but that gets reset when I reload the save. I've thought about using ModData, but does that use lots of save space?

queen oasis
#

if you're only storing the id's, I wouldn't think so

bronze yoke
#

not really yeah

#

if you're just storing numbers, you can expect each to cost ~20 bytes, it's not really a big deal at all

robust locust
#

cool. I didn't wanna do something that would end up maxing out people's hard drives

queen oasis
#

I've got this big ass module that keeps getting bigger to select multiple squares and returns them in a table. Right now it revolves around mouse events, which feels awful. is there a better way to this?

#

I've thought about trying to hijack UIElement

pastel sphinx
#

@queen oasis @bronze yoke Okay so what the effin poop nuggets. I created a new mod structure under users\zomboid and moved my file over there (it took 10 seconds) and now it finds player. wat? Anyway I'm getting a different error in my code, I'll work on that now. thanks humans. I have no idea why it would work now and not before

pastel sphinx
#

That's one of my middle names. Along with "so far, so good"

grizzled fulcrum
#

classic

sand parcel
#

I've got a timed action that needs to remove the item from the inventory after it's done. do I put that in end() or perform()? I tried both with

if self.item then
    self.item:doRemove(self.character)
end

but it didn't work, so I'd also like to know how to do that too

bronze yoke
#

use perform(), stop() fires when the action is cancelled/stops early for any other reason

#

to remove an item use self.item:getContainer():Remove(self.item)

bronze yoke
#

huuuh, is self.item not an InventoryItem..?

#

containers definitely have a Remove so the error must be that self.item:getContainer() does not exist, which would imply that self.item is not an item (but also not nil)

sand parcel
#

If it helps any, this is the Items.txt and is under module named RustRinges

bronze yoke
#

i think the error here is in the lua, where is self.item defined? i assume it's in a new() function, if it's just being passed in where is it being passed in from?

#

adding a print(self.item) on the line before the error occurs would give some helpful information too

sand parcel
bronze yoke
#

it sounds like you just passed the string "RustRinges.ThePristineCondition" in then, not an actual instance of the item

sand parcel
#

probably lol, this is what the code looks like

#

I wasn't sure if there was a better way to do it

#

itemName gets defined as o.item in :new()

bronze yoke
#

i think if you just changed primaryItem:getFullType() to just primaryItem it would all start working

sand parcel
#

after solving the few errors that that change caused, can confiirm it works as intended

#

thanks albion!! youre the best

bronze yoke
#

glad to help!

brittle geyser
grizzled fulcrum
fierce trench
gilded yoke
fleet bridge
fleet bridge
#

There's a mod that displays leader kill boards

#

You can look there to see how it transmits kills

humble elbow
#

Does anyone know how to integrate discord bot with the server?
I tried a few things I found on github, but it didn't turn out exactly how I want it to
If someone knows how to set it up, I pay for the bot

quasi nebula
#

They mentioned B42 will use a unique random seed (or multiple) to determine animal trails and fishing spots, so I was wondering if that is currently already in use for other randomised aspects of world generation, like traffic jams or zone stories.

If so, anyone know a mod to set a world seed, or know how to make one?

barren lily
#
ancient grail
#

i was too tired i fell asleep as soon as i upload

slr

quasi nebula
ancient grail
queen oasis
# queen oasis I've got this big ass module that keeps getting bigger to select multiple square...

I am resigned to using OnMouse events. I modularized my code a bit more but I'm not getting my table back from the OnMouseUp function. I'm sure it's something obvious but I'm not seeing it.

-- called from context menu
Forestry.clearTrees = function()
    local selectedSquares = setBigDrag.startBigDrag()
    -- table is empty?
end

-- these 2 are in a seperate local module
setBigDrag.startBigDrag = function()
    return Events.OnMouseUp.Add(OnMouseUp)
end

local function OnMouseUp()
    -- the table is verified populated at this point
    return selectedSquares
end
bronze yoke
#

adding to an event doesn't return anything

#

you would want to trigger any code you need to handle that table in OnMouseUp

#

(also, if they are declared in the order shown here, you are essentially calling Events.OnMouseUp.Add(nil) because you didn't declare OnMouseUp yet)

fleet bridge
#

setBigDrag.startBigDrag() this highlights an area of the ground?

queen oasis
#

I was trying to make "local selectedSquares = setBigDrag.startBigDrag()" into local selectedSquares = Events.OnMouseUp.Add(OnMouseUp) but if it doesn't return anything, blah

fleet bridge
#

Events.event.Add(fn) just adds a function to that trigger event

#

you're not doing anything except adding it to the lua trigger event schedule

queen oasis
#
Events.OnMouseUp.Add(function()
    local selectedSquares = setBigDrag.mouseUp()

how I had it before but there's so much going on with the code

queen oasis
fleet bridge
#

iirc a few vanilla debug functions use the ground highlight tool to get x,y coordinates

#

i assume you're just doing the same

queen oasis
#

I was thinking about using setDrag() but I think that only works with moveables. idk, I haven't dug in to the java

queen oasis
fleet bridge
#

the admin add safehouse tool has a drag tool to set safehouse boundaries, highlights the floor and grabs the corner coordinates

queen oasis
#

oooh

fleet bridge
#

and the item removal tool does something the same

#

if thats what you're looking for you can just follow that

queen oasis
#

I remember looking at the remove tool last week and gave up for whatever reason. I'll look at the safehouse tool

pastel sphinx
#

Yo yo hi everyone. I'm working on an RP mod that, among other things, adds xp to certain skills on the start of a new run. I get that PerkBoost is attached to each skill, and it's given by occupations and traits. Ie: Lumberjack gives the axe skill a PerkBoost of 2.
Question: Is PerkBoost used anywhere other than to assign initial XP to that skill? Does PerkBoost ever change or (in Lumberjack case) is Axe PerkBoost always gonna be 2?

bronze yoke
#

it just gives you that level when you start, it's not something that's like stored on the player permanently

#

though keep in mind that starting levels do affect xp gain permanently

pastel sphinx
bronze yoke
#

oh my bad i got confused, yeah perkBoost is that permanent multiplier

#

if you want it to be considered 'starting' xp you may want to give the corresponding perk boost but it's up to what you want really

pastel sphinx
#

yeah I tell you what, it's so easy to get confused with all this stuff, especially since nothing is named like what I think it should be named. Like Perks

bronze yoke
#

but yeah in normal gameplay perk boost never changes

pastel sphinx
#

Do you know if the PerkBoost multiplier is used on Life & Learning XP or VHS tapes?

bronze yoke
#

i'm pretty sure it is, book boosts are applied and i think they have the same toggle when granting xp

pastel sphinx
#

Ok thanks for your help Albion.

bronze yoke
#

if you do interact with it the way it works is a little odd, the number you set/get from it is just the level of the perk boost, not the actual multiplier (so setPerkBoost(Perks.Woodworking, 1) gives carpentry the 4x multiplier you'd get from starting at level 1, not a 1x multiplier)

pastel sphinx
#

Level 0 — 25% (default for all skills)
Level 1 — 75% Greenblits.png
Level 2 — 100% Greenblits.png Greenblits.png
Level 3+ — 125% Greenblits.png Greenblits.png Greenblits.png

#

Green bits. Nice. Isn't that what we're talking about?

bronze yoke
#

yeah but the claimed numbers are just lies lol

#

the multipliers are actually:
0.25x
1x
1.25x
1.33x
or, effectively:
1x
4x
5x
5.32x

pastel sphinx
#

Yeah I get that part. Multiples of 25. Kinda dumb way to do it, but okay.

#

But wouldn't it be:
1x
3x
4x
5x

bronze yoke
#

actually i misremembered, it's 1x, 4x, 5.32x, 6.64x

#

the in-game displayed numbers are just inaccurate entirely

#

in-game level 1 is displayed as +75%, which is already an issue because nowhere at all does the game tell you the base rate is 25% so this looks way less significant than it is, but the others are displayed as +100% and +125% which just aren't in any way the actual numbers used

pastel sphinx
#

Huh. Okay well thanks again. So bizarre

#

Just for poops and snot rockets, and because I'm still learning about all this stuff, I decided to create a character with Carpenter occupation and Handy trait. Keeping up on skill books, I watched all the L&L shows to see how far I could get. I was level 10 carpentry on day 4.

teal nacelle
#

very new to lua, how can i detect sound levels (how loud a sound is) and give debuffs if it's too loud? I'm trying to make a mod that adds sensory overload

pastel sphinx
#

Some sounds bug the heck out of me as well. Especially gun sounds when the gun person is outside and I'm inside

teal nacelle
#

I meant like, a trait that gives the character sensory overload

#

Panicking when they're close to loud sounds and getting stressed

#

I really like the gun sounds, they're pretty realistic

I've been near guns firing a couple times without ear protection, and it sounds pretty close to that

bronze yoke
#

the OnWorldSound event fires when sounds that attract zombies play

#

but i don't think it would be possible to detect other kinds of sounds

teal nacelle
#

I'll try it, does it have different volumes that you can specify or just that?

bronze yoke
#

it passes a volume and radius but keep in mind this is just gameplay data and doesn't necessarily have anything to do with how loud the sound actually is

#

radius is how far zombies can hear the sound from and volume is basically just a tie breaker, if a zombie hears two sounds they're more likely to go towards the louder one

teal nacelle
#

I've noticed mods that add temporary deafness having a problem like that, where mods that play "sounds" to attract zombies make your character deaf for no reason

bronze yoke
#

yeah you'd probably run into the same problem with this

#

if you turn on a light switch at night i'm pretty sure it plays a 'sound' lol

teal nacelle
#

You said it has a volume setting, so could I say it only makes you panic over a certain volume?

pastel sphinx
bronze yoke
#

yeah, just warning you that that 'volume' is really just a zombie attraction parameter and might not line up with reality

teal nacelle
#

Yeah, I thought making an autism trait would be interesting for players that want to challenge themselves, and I'm basing it on my own experience

One of my biggest symptoms is sensitivity to sound

#

Especially sudden sounds

#

I might try a special interests function eventually but I'm working on it one piece at a time

#

Maybe I could have it so ear protectors or headphones that you can wear muffle the sound and remove the panic?

#

Could be an interesting trade-off, your hearing gets worse but your character won't lose their shit around loud noises

#

How do I add panic?

red tiger
#

I'm still xmas-wishing for encryption tools to be exposed & provided to Lua for build 42.

#

🙏

robust locust
#

hiya, I'm a little confused with buildingID... does it give each building an incrementing number from 0 as it loads that house from your position? Or does each building have a hardcoded number?
I'm storing the ID's, and noticing that they start from 0 no matter where I am. Just checking if this is just how my code is set up or if that's correct.

robust locust
#

I'm trying to save them to modData, so they aren't being recycled. I was testing with new saves. I thought I would see long ID numbers for each building. I'm not sure if the game assigns a number to each new building as it's loaded, incrementing by 1 each time.

queen oasis
#

reloaded and 774 is now 801

robust locust
#

hmmm, interesting...

queen oasis
#

no idea. just got the source opened to find out because I'm curious too

#
public IsoBuilding() {
    this.ID = IDMax++;
    this.scoreUpdate = -120 + Rand.Next(120);
}
#

IDMax starts at 0

#

restarted again and now it's 2

#

and it's sequential

#

2, 3, 4, 10 .. I'm sure it has to do with buildings you've seen into. maybe it was 772 before I didn't restart the game, just made a new game

robust locust
#

It does seem like it's either to do with the buildings you've seen, or it counts them in a clockwise route (or something) from your position when the cell is loaded. I get quite a long list without moving or looking into buildings

#

Also, does anyone know if it's possible to get the number of rooms in a building?

queen oasis
#

getRooms() maybe. That's under BuildingDef tho.

robust locust
#

do you know if it has a size() property?

queen oasis
#

Maybe, it's an arraylist I think which I think has size, get, etc

teal nacelle
#

Hey y'all, just wondering

How do I make a character panic? I know how to detect zombie attracting sounds now, but don't know about adding the debuff I want to

queen oasis
teal nacelle
#

Guessing that float means the number?

queen oasis
#

Yep, I believe from 0 to 1 but don't quote me on that

#

Float basically means it can have decimals

bronze yoke
#

panic is one of the older ones so it's 0-100

teal nacelle
#

So, would the code be like OnWorldSoundEvent:getPlayer():getStats():setPanic(float)?

Do I also need to check for the trait?

queen oasis
#

Events.OnWorldSound.Add(function to check for trait and add panic)

#

I'm on my phone or I'd give something more refined but that's the gist of it

teal nacelle
#

How do you check for the trait?

pastel sphinx
#

This is driving me crazy. I'm trying to update a perk with a new XP value. The function setXP is giving me 'nil'. I found some documentation that says setXP() has been deprecated. I also tried addXP but that doesn't work either. How should I be doing this?
player:getXp():setXP(perk, newperkstat)

#

both perk and newperkstat give me values when I print them

teal nacelle
#

for some reason the trait isn't showing up in the character creator.

#

here's the code:

Autism = {}

Autism.DoTraits = function()
local Example = TraitFactory.addTrait("Autism", getText("Autism"), -1, getText("A mental disability. This trait is not a 1-1 recreation of the real experience, nor is there only one unified experience for everyone with ASD. This is simply based on my own."), false);
TraitFactory.sortList();
local traitList = TraitFactory.getTraits()
for i = 1, traitList:size() do
local trait = traitList:get(i - 1)
BaseGameCharacterDetails.SetTraitDescription(trait)
Events.OnWorldSoundEvent.Add(if player:hasTrait("Autism") == true
then getPlayer():getStats():setPanic(25))
end
end

Events.OnGameBoot.Add(ModExample.DoTraits);

bronze yoke
#

Events.OnGameBoot.Add(ModExample.DoTraits) but your function is called Autism.DoTraits

teal nacelle
#

Ah

#

I was following a tutorial, so that's probably why lol

#

Still not showing up,,

vagrant ledge
#

Question! I'm having some trouble with another mod and how it interacts with mine. Is there an easy-ish way to remove their outfits from the outfitManager or prevent zeds from spawning with those outfits?

neon kiln
#

Hi everyone,

I am looking around the the Distributions.lua file.

Are these different zomboid types that spawn in the world (the white lines)?

vagrant ledge
neon kiln
vagrant ledge
#

xD

neon kiln
#

I just want zomboids to have more cigarettes >:)

ancient grail
wind wasp
#

is there just any way to "hot reload" lua file that is a server component? i have to restart server manually each change. "reload" from debug menu doesnt work

ancient grail
#

if this is for you to debug your mod i think its possible to reset server side lua
but if you want to do this to avoid the need of a server restart then its not gona work (just saying)

#

you have to figure out how to find the specific lua tho
im not sure how
but aiterons AUD mod is able to to do that iirc

#

@wind wasp

wind wasp
# ancient grail <@282578761856057344>

whats aiterons aud mod?
also do you have any idea if i can speed up server restart then? it loads in like 5 minutes, and it would be great if i could just launch it without generating whole world and stuff.

#

i see why there are so many server with little custom scripts the development is pain in ass lol

fleet bridge
#

you probably want to overwrite noise and eliminate mods that print billions of debug logs on load

#

my test server runs like 300 mods and boots up in 2 minutes

teal nacelle
queen oasis
wind wasp
teal nacelle
#

It might be an older tutorial, so the hasTrait thing might be outdated

#

I probably messed up while changing the variables to fit my own mod

queen oasis
bright trail
#

does anyone know how to configure NPC Bandits mod

ancient grail
#

any other way to add image? cuz i use a button
and looks small

queen oasis
# teal nacelle It might be an older tutorial, so the hasTrait thing might be outdated

I didn't test this but I think it should work:

-- if you want an icon for this trait, put an 18x18px PNG 
-- named trait_Autism.png into media/ui/Traits

local Autism = {} -- don't pollute, keep it local

Autism.doTraits = function()

    local addTrait = TraitFactory.addTrait("Autism",
          getText("Autism"),
          -1,
          getText("A mental disability. This trait is not a 1-1 recreation of the real experience, nor is there only one unified experience for everyone with ASD. This is simply based on my own."),
          false,
          false)

    TraitFactory.sortList()

    local traitList = TraitFactory.getTraits()
    for i = 1, traitList:size() do
        local trait = traitList:get(i - 1)
        BaseGameCharacterDetails.SetTraitDescription(trait)
    end
end

Events.OnGameBoot.Add(Autism.doTraits)

Events.OnWorldSound.Add(function()
    if getPlayer():HasTrait("Autism") then
        getPlayer():getStats():setPanic(25)
    end
end)
queen oasis
#

"stack overlow" - noice
ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: Stack overflow at Coroutine.ensureStacksize line:131..

digital sail
#

I want to know when an object is over a shelf/table or anything that makes it higher on the square. Any idea how to know that?

ancient grail
#

PlayWorldSound is MP only

 
-- i just learned that PlayWorldSound doesnt work on SP
function GachaMod.playSpin(pl)
   if pl == nil then pl = getPlayer() end
   local sfx = "GachaMod_Spin_"..tostring(ZombRand(1,4))
    if sfx then
      if isClient() then
         getSoundManager():PlayWorldSound(sfx, pl:getSquare(), 0, 5, 5, false);  
      else
         getSoundManager():playUISound(tostring(sfx))
      end

    end
end
bronze yoke
#

why are you even using a world sound for a ui sound anyway?

#

the purpose of world sound is spatialisation, you should only use it for in-world sounds or it'll sound weird

teal nacelle
#

How do I check the volume?

queen oasis
teal nacelle
#

What volume do you think would be a good lower limit for the panic?

#

Is there's an add panic function, and not just set?

robust locust
#

Is this a thing?
local customName = object:getCustomName()

ancient grail
teal nacelle
queen oasis
#
Events.OnWorldSound.Add(function(x, y, z, radius, volume, source)
    if volume > whatever then

Keep in mind that a lot of mods that attract zombies use a "silent" sound

teal nacelle
#

Yea I know about that

#

I saw the issue with a temporary deafness mod

#

Character would randomly go deaf

ancient grail
teal nacelle
#

Is there a way to make the panic stack?

#

Might try putting it as +25 instead of just 25

ancient grail
#

sets panic to 25


getPlayer():getStats():setPanic(25) 

adds 25 to panic

local stats = getPlayer():getStats()
local panic = stats:getPanic() 
stats:setPanic(panic + 25)
ancient grail
teal nacelle
#

I'll try it, thanks!

#

What volume is a gunshot?

#

I'm probably gonna set the lower limit for the panic to slightly lower than the average gunshot

queen oasis
barren kraken
#

Dickies coveralls from Dawn of the Dead

queen oasis
teal nacelle
#

How do I print the volume?

bronze yoke
#

print(volume)

teal nacelle
#

Where can I read the print?

queen oasis
teal nacelle
#

Do y'all have any clue why guns stopped making sound, though?

#

I tried firing a gun to test it out and it just stays silent

tranquil kindle
teal nacelle
#

Does ghost mode do that?

tranquil kindle
#

Yea

#

I think if you Press N in debug mode you enable both?

#

God mode and Ghost mode

teal nacelle
#

I have a cheat menu that lets you enable stuff like that, I might have ghost mode enabled to avoid getting mauled for making noise lmao

bronze yoke
#

many such cases

teal nacelle
robust locust
#

does anyone know, or can point me to, how to get the custom name property to a sprite?
I'm checking if a square has an object with a custom name listed in a table.
Do I use object:getCustomName()?

bronze yoke
#

use the launch parameter instead

teal nacelle
#

Putting -debug in the launch options doesn't work either

#

It worked once, and then stopped

bright fog
queen oasis
#

I had that thing where getPlayer() returned nil until I restarted the game. Must be a solar flare.

grizzled fulcrum
#

nice you already removed it 😂 I knew I saw it somewhere

bronze yoke
#

not the strangest thing i had to remove from that page today

vagrant rampart
digital sail
#

Thank you, it took forever to record those phonemes. :'D

bright fog
digital sail
vagrant ledge
red tiger
#

Good job.

#

A real QoL mod.

rancid barn
#

what programs would u guys use to make pixel art for 3d models?

#

would go with blender but that dont seem like an option

sour island
#

The Supportive Saturday is an event where you share mods once a week. Currently the suggestions go out to a handful of other discord servers by means of discord news function. So a great way to share new projects. 👍

main pasture
zenith glacier
#

hello guys im struggling with a lua code, im using an OnContainerUpdate function , and i want to get the container name, but it keeps giving me a Nul result in the logs.

zenith glacier
bright fog
zenith glacier
#

Events.OnContainerUpdate.Add(OnContainerUpdate)

#

the idea is that , when someone updates a container , this function get's the player name , and current square.
then it searches the cells around the player to look for containers.
then it saves somewhere that the player touched the container

#

Stack trace

STACK TRACE

function: OnContainerUpdate -- file: logcontainers.lua line # 83 | MOD: Vedo_Tutto

ERROR: General , 1731769137581> 134.102.627> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: Object tried to call nil in OnContainerUpdate at KahluaUtil.fail line:82.

bronze yoke
#

if you're trying to log item transfers that's not really what OnContainerUpdate does

zenith glacier
#

im trying to log the player that have updated the container , and the container name/id

bronze yoke
#

that event is fired when a container is added to/removed from the world, mostly to update the ui to show/hide it