#mod_development

1 messages ยท Page 79 of 1

humble oriole
#

but it doesn't update

bronze yoke
#

this just refreshes the ui, if the item isn't being synced it won't help

dark wedge
#

I think you still need to do the other things

#

just in addition, need to mark the UI as dirty

humble oriole
#

just requestSync()?

#

same symptoms

dark wedge
#

So, in debug mode there is the context menu to delete an item on right click. If I check that, I see:

        item:getContainer():removeItemOnServer(item);
    end

item:getContainer():DoRemoveItem(item);```
seems like you could just do the same thing? this is all on the client btw, seems to sync it to the server.  Found in `lua/client/DebugUIs/ISRemoveItemTool.lua`
bronze yoke
#

but we're trying to sync from the server, not to the server, right? that method won't even run on the server

humble oriole
#

hmm, can I just send the item to the client and remove it on both?

fast galleon
#

@humble oriole
have you seen what ISA does yet?

humble oriole
bronze yoke
#

you can actually pass inventoryitems as arguments in server commands, so it might be as simple as telling every client to delete it...? not sure what exactly the interactions are there

fast galleon
#

sendObjectChange("containers")
refreshes the container on clients

humble oriole
fast galleon
#

use that on isoObject

humble oriole
#

cause I've seen it used with ('name') and ('sprite')

bronze yoke
#

there's a lot of valid changes

bronze yoke
#

somebody should document them...

fast galleon
#

I hope it does what you want

humble oriole
#

Well, it removes everything from the inventory

#

and when I put something in, the first time gets replaced by the item I left in there

#

oh, if I refresh it it fixes it

#

hmm

#

looks like if I combine it with that inventory dirty variable it fixes it

#

thanks guys

polar prairie
drifting ore
#
local theTable = {}
theTable[1] = "Lua"
print(theTable[1])

local function Save()
    local fileWriterObj = getFileWriter("file_theTable.json", true, false);
    local json = Json.Encode(theTable)
    fileWriterObj:write(json)
    fileWriterObj:close()
end

Trying to use the tutorial from here: https://github.com/MrBounty/PZ-Mod---Doc/blob/main/Save data.md

I don't think I fully understand it. The file gets saved "file_theTable.json", but nothing is inside it. I thought the "theTable" was a lua table hence I wrote it like one, am I wrong?

GitHub

Contribute to MrBounty/PZ-Mod---Doc development by creating an account on GitHub.

bronze yoke
#

did you add the json library and require the file?

drifting ore
#

yep

#
local Json = require("Json");
#

And the Json.lua is inside the client folder

rocky jungle
#

Greetings, a question about trees. I don't quite understand how to place them.
For trees consisting of a single element, such as e_americanholly_1, I made a function based on BrushTool. I'm fine with them. But there are some trees that consist of two sprites - tree trunk and leaves. In the game they have the property "ATTACHED", but if put through BrushTool they will be separate. How to combine them?

kindred current
#

I've been trying to add traits but I can't figure out why it isn't working

bronze yoke
drifting ore
#

gonna try with a letter, gonna report back in a few mins

fast galleon
ancient grail
#

anyoneknows a vanilla function that checks howmany people are near the player

drifting ore
#

Gimme a sec still working it out, I think if I fix it now I'mma have to present myself as a big dumbass here in chat

ancient grail
#

or do i have to make own function

dark wedge
ancient grail
drifting ore
#

Well. It works now. The issue wasn't the table or the script or anything really, aside from my dumbass. The issue was that my mods folder was wrong, the setup actually. First I didn't even notice there's a zomboid folder in C:\Zomboid, and one in C:Users\Zomboid so I had to fiddle with that a bit. 2nd thing I had to adjust how I put the mods folder into the mods folder of the server. My mistake was that I put it like the modtemplate inside, aka with the Contents and workshop thing all together, when in reality I just had to put in the "modfoldername/media, mod poster in

#

Thank yall for the help, led me to figuring it out ๐Ÿ˜ฆ

dark wedge
# ancient grail just players

Not sure of a function that returns that. But you could iterate over the current MP players, and use: player:DistTo(otherPlayer) <= range as a condition if a player is near you.

hot patrol
# polar prairie

Looks really good. I will definitely be adding this to my bow collection

ancient grail
#
function plCount()
        local player = getPlayer()
        local cell = getPlayer():getCell()
        local x, y, z = player:getX(), player:getY(), player:getZ()
        local xx, yy, zz
        
        local rad = 6
        local square = cell:getGridSquare(x + xx, y + yy, z)
        local plCounter = 0
                for xx = -rad, rad do
                for yy = -rad, rad do                
                        for i=0, square:getMovingObjects():size()-1 do
                        local chr = square:getMovingObjects():get(i)
                                if instanceof(chr, "IsoGameCharacter") and player ~= chr then   
                                plCounter = plCounter + 1
                                end

                        end
                end
        end    
        return plCounter
end
function HermitTrait()

        if not getPlayer():HasTrait("Hermit") then return end
        
        if plCount() > 0 then
        local plPanicVar = 0.1
        local plPanicMultiplier = plPanicVar * (plCount+1)
        local plPanic = getPlayer():getStats():getPanic()        
        getPlayer():getStats():setPanic(plPanic+plPanicMultiplier)
        end
end

Events.OnPlayerUpdate.Add(HermitTrait) 
#

getSeeNearbyCharacterDistance()
is on the pz website but its not on the lua

agile vigil
#

It's in IsoPlayer.lua on line 707?

ancient grail
#

i should verify

#

i cant find that file

agile vigil
#

Should be in media/lua/shared/Library/IsoPlayer.lua

ancient grail
#

i dont have library folder

#

i really need to verify then

ancient grail
#

i just need to get howmany player are around the player

#

and also isCanSee() applicable for other players too right

fast galleon
#

yeah, if you want to know your *view distance based on fatigue

ancient grail
#
                        for i=0, square:getMovingObjects():size()-1 do
                        local chr = square:getMovingObjects():get(i)
                                if instanceof(chr, "IsoGameCharacter") and player ~= chr and  chr:isCanSee()  then   
                                plCounter = plCounter + 1
                                end

                        end
ancient grail
#

this part

#

chr:isCanSee()

#

am i using it right

#

cuz im thinking it might be.. tho i highly doubt
player:isCanSee(chr)

fast galleon
#

not sure, but didn't you want all players?

ancient grail
fast galleon
#

square:isCanSee(int) if you use that

#

hm isBlockedTo might be what you want

ancient grail
#

cuz it should increase a panic multiplier as more people is around the person

ancient grail
#

im thinking it will create alot of error if i do that

fast galleon
#

if not playerSq:isBlockedTo(checkSq) then
...check obj...
end

#

this would not count people behind walls for example

ancient grail
#

ok cool thnx

#
if instanceof(chr, "IsoGameCharacter") and player ~= chr 
                                and player:getCurrentSquare():isBlockedTo(chr:getSquare()) then   
                                plCounter = plCounter + 1
                                end
fast galleon
#

you can check that earlier, before getting square objects

dark wedge
#

Another way would be:

for i=0, onlineUsers:size()-1 do
    local buddy = onlineUsers:get(i)
    if player ~= buddy then
        if player:DistTo(buddy) <= 1.0 then
            -- Do things
        end
    end
end```
Can `break` out after a certain player count succeeds if that matters, and still check if they are blocked by their squares.  would just need to play with the "range" a bit
ancient grail
ancient grail
#

compare to mine

fast galleon
# ancient grail

it's because square is out of the loops, if you are wondering (xx would be nil)

ancient grail
#

ye i fixed that but i prefer to use dherts checker instead cuz its totally lighter on the ram load

#

and less prone to error

#
function plCount()
        local player = getPlayer() 
        local socialDistance = 6
        local plCounter = 0
        local onlineUsers = getOnlinePlayers()
                for i=0, onlineUsers:size()-1 do
                local chr = onlineUsers:get(i)
                        if player ~= chr then
                                if player:DistTo(chr) <= socialDistance then
                                plCounter = plCounter + 1                        
                                end
                        end
                end
        return plCounter
end
rancid tendon
#

if SandboxVars.MFTEOTWC.blindMode then
Events.OnInitGlobalModData.Add(function()
    for i=1,#itemList do
        local item = ScriptManager.instance:getItem(itemList[i])
        if item then
            item:DoParam("Name = " .. Unlabelled Cassette)
        end
    end
end```
#

anyone have a clear idea as to why this code doesn't work?

ancient grail
#

looks like theres something wrong with my math or the way im doing it

fast galleon
rancid tendon
#

it doesn't produce an error or anything, just seems to silently fail

fast galleon
fast galleon
rancid tendon
#

oh huh i do have that event in completely the wrong spot don't i

#

glanced right over that

fast galleon
rancid tendon
#

oh no i just left that one out of the copy that's my bad

dark wedge
willow estuary
#

The field is DisplayName not Name

    item UnusableMetal
    {
        DisplayCategory = Junk,
        Weight    =    1,
        Type    =    Normal,
        DisplayName    =    Unusable Metal,
        Icon    =    UnsableMetal,
        WorldStaticModel = UnusableMetal,
    }
rancid tendon
#

OHHHHHH

#

i was about to post asking further because i fixed all the previously mentioned bugbears but THAT'S probably why it's just abjectly refusing to work

#

thank you blair!

willow estuary
#

Always check the vanilla code + scripts ๐Ÿ˜‰

rancid tendon
#

if i can get this to work then only one feature eludes me... figuring out how to get the game to accept sideways vinyls

#

hmm

#

vexingly it is still broken

#

here's the full lua file

fast galleon
#

which mod is this in, I don't see it

rancid tendon
#

it's currently contained within a separate test mod, this lua file and the sandbox settings for it are the only things in the mod

ancient grail
rancid tendon
#

it's intended to be for this mod once it's done

uncut meteor
#

damn 1000 tracks

fast galleon
#

I added this yesterday, which is why I tried finding the file.

ancient grail
#

is there a way to force trigger an item on_eat

#

ow nvm i think i know how lol

rancid tendon
#

yeah i'm just staring at this and can't for the life of me figure out why it's broken still

#

very frustrating

ancient grail
#

theres no event to check for what food you just ate or about to eat

polar prairie
#

does somebody know if it's possible to add a functional flashlight to a weapon without any of the external library mods?

fast galleon
#

I think I know the problem with the DisplayName but now my item list viewer crashes trying to sort the items

#

this was throwing errors as well, 2 edits

local function onFillContainer(_roomName, _containerType, container)
    if #itemList == 0 then return end -- <<<<
    local dummies = container:getAllType("Tsarcraft.BlankCassette") -- dummy item type
    if dummies:size() == 0 then return end
    for i = 0, dummies:size()-1 do
        container:Remove(dummies:get(i))
    end

    for i = 0, ZombRand(1 * SandboxVars.MFTEOTWC.maxCassettes) do
        local itemChoice = ZombRand(#itemList) + 1 --<<<<<
        local item = container:AddItem(itemList[itemChoice])
        container:addItemOnServer(item)
    end
end

0 is when you have core only, might as well not add / remove the function
ZombRand returns 0 to # -1, lua indexes start from 1 so we add 1 to itemChoice

#

@rancid tendon

rancid tendon
#

god i need to change my nickname in here. anyway: thank you for the help!

#

i didn't really account for anyone having core only because like, why would you only have core active anyhow

#

but i suppose it's good practice to account for it anyway

drifting ore
#

Am I right in assuming that sendservercommand and sendclientcommand is the only reasonable way to get items from another player?

#

I am trying to use them but they are hella confusing ๐Ÿคฃ

#

Lots of arguments in the brackets so trying to work out how to use both ๐Ÿ˜

#

I think if I right click a player, that's the way to obtain his ID, then send that ID via a client command to server, use a server function to get his items and send those items back to the client that right clicked him

tame mulch
drifting ore
#

Real quick, what is the server's role in all this? What can it obtain that the player himself cannot? The ID, the inventory contents?

#

As far as I'm reading this code I'm learning from, the server receives a message with the Player Object and then gets the ID from that, sends the ID to the client which then uses that ID to get the inventory contents

#

Kinda seems off, like the server should get the inventory contents itself and then send those to the client instead of the ID

#

Code is working btw, just confused irl ๐Ÿคฃ

thick karma
#

Anything in lua/server (in workshop mod folder or main install folder) is only running on the server, so anything like that is part of its role.

#

@drifting ore, e.g., you cannot send commands to other clients directly from a client afaik. Gotta tell the server to send the signal.

drifting ore
#

When things are saved in the Users/User/Zomboid/Lua folder on my PC, does that mean when I put the mod on a server it will be saved on each clients PC as well or in the server files?

thick karma
#

In general you don't put anything in Zomboid/Lua, you put them in Zomboid/mods/modName/media/lua/client, server, or shared.

drifting ore
#

No I mean I'm using Json to save files, and it saves the file in the Lua folder of Zomboid

#

By default

thick karma
#

Or you put them in Zomboid/Workshop/modName/Content/mods/modName(again)/media/lua etc.

thick karma
#

Do you create the save file using a client file or a server file or a shared file?

drifting ore
#

client file ๐Ÿ˜ฎ

#

I suppose that's my mistake

thick karma
#

If you have a mod that makes save files, the saves are generally local afaik. I don't know if any mods that create serverside save files. A client-saved file won't autotransfer to server. Server won't have access to file data unless it reads the file itself somehow. Not sure whether server has its own save files

thick karma
drifting ore
#

Trying to save player inventory information and values as his name, lastname etc to a json file

#

So anyone (in this case admins) can access that file to read it from within the game

#

But if it's stored locally that doesn't work ig

thick karma
#

Mmmmmm

drifting ore
#

I figured the Lua folder was a local folder on my PC that represented a folder in the server configuration if the server was hosted elsewhere

thick karma
#

Well servers may have something equivalent for their save files... I just don't know. I would try a similar process in a server file and see if you can read and write things using the server with some simple tests

#

Just try to write a single line and read it and print it from the server. If that works, server can do that stuff.

#

Might need to send the command to print to the client, idk if printing in a server file will print to debug console when you're hosting or not.

#

Just be aware that some events only happen clientside so if something doesn't seem to run, you may have triggered it from the wrong context.

thick karma
drifting ore
#

Yeah was just thinking about that

#

I remember others talking that mod data saves that stuff directly on the server in its mod config

#

I'm gonna spend some time researching that as well so I don't waste my time with Json if it's not possible to pull this off

thick karma
#

So are you using a JSON library to access your JSON or what?

drifting ore
#

Yeah

thick karma
#

Haha dang

drifting ore
#

I spent hours learning how to configure it too lmfao

thick karma
#

I dunno if that's worth packing into a mod or not. I mean probably not as big as some of these music mods but still

#

Seems like a lot of extra space and I'm not sure if it will deliver much function beyond what you can already do with a lua table

#

Intuitively, if modData does work, it seems like the more efficient path in terms of lines of code written

drifting ore
#

does anyone have a guide for getting items to appear in your character's hands, specifically backpacks? i have everything else down, but the model itself just won't appear.

#
calm depot
#

does anyone remember (approximately) when PZ stopped loading localisation strings on the server side for mods?

#

@sour island I take it Expanded Heli events still has broken AEBS strings?

drifting stump
#

clients also execute code in server

drifting stump
drifting stump
#

if clients run it itll go to the directory you said

drifting ore
#

Ha, damn, gotta restore that code lmao, luckily didn't get too far ahead anyway

#

Thanks for the info!

#

So a server side player database in the form of a json is possible if executed from a server lua?

drifting stump
#

if you want to prevent clients from running code in /server then at the top of the file put

if not isServer() then return end
drifting stump
drifting ore
#

Thank you, do you think you could elaborate for me how server command and client command works? I can't find much docs online. Like, when I get an ID from a player (still not even sure how to precisely get one with right click) and send it to the server

#

Do I run the scripts I want in the server luas?

drifting stump
#

again keep in mind player inventory is client sided so you have to ask each client to send over the info

drifting ore
#

Or do I send the ID and info I get from server back to client to run the luas

rancid tendon
#

bringing this one up again since its been a few hours

#

anyone know why this code just flatly doesn't work? doesn't change names as it should and i haven't seen any related errors

drifting stump
drifting ore
#

Thanks, will give it a read. Gotta work out how to get a player by right clicking somehow ๐Ÿคฃ

#

This game is elusive but I'm not gonna give up

drifting stump
#

got your back on that too gimme a sec to find where it is

fast galleon
drifting stump
# drifting ore Thanks, will give it a read. Gotta work out how to get a player by right clickin...
Events.OnFillWorldObjectContextMenu.Add(function(player, context, worldObjects, test)
  if test then return true end
  local playerObj = getSpecificPlayer(player)

  local clickedPlayer
  print("Number of Objects: " .. #worldObjects)
  for i, v in ipairs(worldObjects) do
    local movingObjects = v:getSquare():getMovingObjects()
    for i = 0, movingObjects:size() - 1 do
      local o = movingObjects:get(i)
      if instanceof(o, "IsoPlayer") then
        clickedPlayer = o
        break
      end
    end
  end

  if clickedPlayer then
    if clickedPlayer ~= playerObj then
      local option = context:addOption("View Bio", clickedPlayer, onBioMenu, false)
    else
      local option = context:addOption("Edit Bio", clickedPlayer, onBioMenu, true)
    end
  end

end)
drifting ore
#

I've seen the letter o used before

#

Is there any reason for that or just a variable

drifting stump
#

local o = movingObjects:get(i) just a var

drifting ore
#

Aha

rancid tendon
#

dang, i thought this would be a fun little feature but it seems zomboid is intent on preventing me from implementing it

fast galleon
rancid tendon
#

that'd be a lot of effort to put in for this particular niche feature, i think

#

... plus, something just occurred to me

#

this feature is predicated on the player finding items and renaming them to identify them, but this code would still run and probably revert those items back to unlabeled items even if it did work each time the world loads, huh

fast galleon
#

nah, if a player names something, it sticks

kindred current
#

what do I need to get a trait working?

#

I've examined the vanilla files and some other mods

#

but I can't scratch my head around it

fast galleon
#

they would just not know if a new item is same as something they found before, so every new item would be unlabelled

drifting ore
#

Btw when you update your mod, like, save the code etc. Do you have the restart the entire dedicated server or is there an option to reload the lua code? I've seen something online like a command that resets the lua but not sure if that's possible

#

as is now, I have to restart the server every change and log in with 2 versions of PZ nosteam to debug

fast galleon
#

open admin chat and do
/reloadlua MyFile.lua
works on same machine without much effort

kindred current
drifting stump
#

not a good idea to reload code with events

drifting ore
#

Just tried this and it keeps saying unknown lua file ๐Ÿคฃ

kindred current
#

does anybody know what the second false means for traits?

#

profession free trait?

ancient grail
#

cant a player apply mod data to another player

drifting stump
ancient grail
#

Ow damn

thick karma
# drifting stump clients also execute code in server

I thought client runs clientside, server runs serverside, and shared runs on both... do you mean that you run code in server when you call server code from client? Or do server files actually load on the client?* I recall various people suggesting files in client do not even load on the server... Is that not the case? Or do clients load server files, but not vice versa?

#

I seeeee

#

But does server load client?

calm depot
#

code is loaded in order to ensure equal checksums

#

clients don't execute server code though

thick karma
#

Okaaaay so it's only true in one direction, got it

#

So, just to be 100% clear, servers may execute client code but not vice versa, and both client and server load each other's code.

calm depot
#

no, don't think of it that way

thick karma
#

haha okay

calm depot
#

if you have code that needs to be referenced on either side, put it in shared

thick karma
#

I understand that much, but I am curious about the technical meaning of the folders

calm depot
#

the fact that code from an opposing side might be loaded and active in the lua state should not be relied upon

thick karma
#

So is it the case that clients may execute server code, but generally don't execute server code?

calm depot
#

they never really execute server code, a server function might exist within the Lua state of a client, but executing it is probably semantically meaningless, because the client isn't a server

thick karma
#

I am unclear regarding whether code in server can be called from a client.

calm depot
#

you shouldn't care

thick karma
#

...

#

lol

calm depot
#

for the purposes of structuring your mod, you should consider code on the opposing side inaccessible

#

the game may change in future where such a split is fully enforced

#

and your shit will then break because you were being stupid and relied upon code from the other side being in your state

thick karma
#

Okay, but I am also interested in things like the actual truth in comparison to convention

#

Perhaps I should not be

#

But I am ๐Ÿ™‚

calm depot
#

well, the answer there is to go make a mod, declare a function unique to each side and call it ๐Ÿ™‚

#

if you want to examine existing behaviour, go test it.

thick karma
#

lol fair enough I was only asking here because I thought someone might know.

#

No worries

calm depot
#

if you look through the game files, and some mods, you'll notice that there is occasional use of isClient() or isServer() to cause/prevent defining functions and data

drifting ore
lament canopy
#

where can i find the trait stuff for obese in the files

#

like the fall damage

#

or the fence climbing

ancient grail
#
function instaKillCheck(wielder, character, handWeapon, damage)
        if getPlayer() == character then
                if handWeapon:getModData()['instaKiller'] == true then                         
                getPlayer():getBodyDamage():setOverallBodyHealth(0)     
                print('yep '.. damage)
                end
        else 
                print('nope '.. damage)
        end
end
Events.OnWeaponHitCharacter.Add(instaKillCheck)
#

anyone know why this isnt working

calm depot
#

"isn't working"

#

does that mean it killed your cat? made your computer explode?

#

the two most useless words in computer programming: "isn't working"

#

describe what you observe.

sour island
#

Your mod broke my save, uninstalled and will not be clarifying

#

My response? 'ok ๐Ÿ‘'

drifting ore
#

lol

sour island
#

Did I get pinged? I got an alert

calm depot
#

"Please let me know who to make out the cheque for $0.00 to, thanks"

#

yes, it was me, I was asking if AEBS was still broken for expanded heli events

neon bronze
sour island
#

Ah, I thought I fixed it -- not sure why it's breaking in some peoples runs. I guess SOS is related

calm depot
#

I spun up a server and the strings still didn't localise for me with the latest release

sour island
#

Hmm

calm depot
#

it'd be nicer if the game added a hook-point for incoming strings so you could localise client side. kinda sucks for people who play on language X servers but play with the game in language Y

#

(the strings do localise with the mod I put out)

#

it's a very simple Translator.loadFiles() call in OnGameBoot

neon bronze
#

Is the fix for sp only? I wonder what it would choose for localisation on a server

calm depot
#

the opposite, it's for server only

#

if you're playing SP, there is nothing to fix

#

but, if you read the mod description, you would know that ๐Ÿ™‚

neon bronze
#

Ok

calm depot
drifting stump
#

servers run server and shared

drifting stump
calm depot
#

yes, I later clarified the isClient() check

sour island
#

Hmm so that's what was going on

#

It wasn't an impactful bug so I didn't look into it yet - but it's frustrating when you can't easily replicate it

#

I wish there was a way to send people settings and saves

#

Or something... Printout of non vanilla settings

calm depot
#

yeah, something like a minidump() you can call on server and client that generates a zip

sour island
#

I had a bug way back when that was caused because the notation for numbers in Spanish use a ,

#

I think for decimals? I forget the details lol

faint jewel
#

@fast galleon what you need?

calm depot
#

swapping , and . are a common European idiom

#

and other places too

sour island
#

Yeah my solution was just to replace , with . for it lol

#

It was already a hacky string extraction to number so I didn't bother with doing it "correctly"

calm depot
#

does PZ expose the digit grouping locale?

#

Java has it

sour island
#

Not sure, it was pretty early into EHE

#

And vector2 is scuffed for exposure as it's overwritten with a Lua file

calm depot
#

wait, what?

sour island
#

The vanilla files includes a vector2 that overwrites the exposed class

#

I use vector3 for the math stuff I need -- just ignore the Z

calm depot
#

really, I can't find it in media/lua

sour island
#

But vector3 doesn't have as many getters - hence I pull the info off a toString

calm depot
#

the exposed class is Vector2, vanilla doesn't appear to overwrite the table

sour island
#

They may have removed it by now - but there was a global named vector2

calm depot
#

a grep indicates they did indeed

sour island
#

Ah nice, I am planning to sit down with EHE -- so I can't maybe remove that ugly stuff with vector3

calm depot
#

although, vector2 wouldn't overwrite it, table keys are case-sensitive

sour island
#

It was the same name I'm not sure about capitalization

#

Had 3-4 functions related to math stuff but otherwise useless

#

Vector3 print also says vector2

#

So I think the util stuff is just super old and not really looked at lol

calm depot
#

yeah, that file is gone now

sour island
#

Awesome

kind fossil
#

Hello! Trying to find within the code of AuthenticAnimations how to stop some emotes to loop
For example the "Facepalm" emote loops itself
I have found that there are 2 files per emote one in a folder "actions" and "emote"
What are the purpose of each?

#

Found this line x_extends="looped.xml" but when I delete it the emote is not starting

<?xml version="1.0" encoding="utf-8"?>
<animNode x_extends="looped.xml">
    <m_Name>Cough</m_Name>
    <m_AnimName>Bob_EmoteCough</m_AnimName>
    <m_BlendTime>0.30</m_BlendTime>
    <m_Conditions>
        <m_StringValue>Cough</m_StringValue>
    </m_Conditions>
</animNode>
calm depot
#

by deleting it, you are breaking the whole animNode

#

it needs to derive from one of the bases

kind fossil
#

Ah crap

#

I think I won't have the knowledge then

calm depot
#

if you just don't want it to loop, I think you can make it extend default.xml

kind fossil
#
<?xml version="1.0" encoding="utf-8"?>
<animNode x_extends="default.xml">
    <m_Name>Cough</m_Name>
    <m_AnimName>Bob_EmoteCough</m_AnimName>
    <m_BlendTime>0.30</m_BlendTime>
    <m_Conditions>
        <m_StringValue>Cough</m_StringValue>
    </m_Conditions>
</animNode>
#

Like that?

calm depot
#

yes

kind fossil
#

no, the emote doesn't start

#

I can press escape to stop the emote even though nothing shows up

#

so the key hit is read

#

but no animation is performed

calm depot
#

hm, what about Ext01.xml

#

the default cough anim in the game derives from that

kind fossil
#

nope

calm depot
#

put it back to looped.xml then

#

just to verify that you didn't break it by doing something completely unrelated

kind fossil
#

yes it works back to normal

#

it's this line that breaks everything

calm depot
#

that was very quick

kind fossil
#

yes i'm testing live

#

in debug mod the game refreshes the file everytime i edit it

calm depot
#

ok, so, when you derive, it's obviously just inheriting the properties of the file you name

#

so, remove the extend directive and instead copy in the properties from looped.xml

kind fossil
#

okay i think I got it

#

was able to slow down the emote for example

#

<animNode> <m_Name>looped</m_Name> <m_AnimName>Bob_EmoteSurrender</m_AnimName> <m_deferredBoneAxis>Y</m_deferredBoneAxis> <m_Looped>true</m_Looped> <m_SyncTrackingEnabled>false</m_SyncTrackingEnabled> <m_EarlyTransitionOut>true</m_EarlyTransitionOut> <m_SpeedScale>0.80</m_SpeedScale> <m_BlendTime>0.50</m_BlendTime> <m_Conditions> <m_Name>emote</m_Name> <m_Type>STRING</m_Type> <m_StringValue>default</m_StringValue> </m_Conditions> <m_Events> <m_EventName>EmoteLooped</m_EventName> <m_Time>End</m_Time> <m_ParameterValue></m_ParameterValue> </m_Events> </animNode>

#

However I shouldn't copy everything inside anim node right?

calm depot
#

don't copy anything that you are already defining in your animnode

kind fossil
#

okay

calm depot
#

assuming it works after doing that (it certainly should) - you can set m_Looped to false

#

if it doesn't you broke something unrelated

thick karma
kind fossil
#

But what I don't get is that i have a blendtime in the xml file of the emote and also in the looped.xml

calm depot
#

that's an override

kind fossil
calm depot
#

have you verified it works after copying in all the properties without modifying them

kind fossil
#

yes

calm depot
#

so it just stops doing anything as soon as you change m_Looped to false?

kind fossil
#

no it still looped

calm depot
#

uhhhh

#

this is making me distrustful of editing it live

#

restart the game and try again

kind fossil
#

ok

calm depot
#

actually, I am generally distrustful of editing live; if something unexpected happens, I restart it to make sure nothing stupid like caching is happening

kind fossil
#

restarted and it still loops

#

even though loop is false

#

however I see that the break between two loops is smaller than before

#

so maybe it was about the "pause" between loops?

ancient grail
#

@thick karma thank you the code worked

thick karma
#

No worries

hardy fox
#

Hey there I have an idea for a mod, but I am not yet familiar with the Lua or Java API of PZ.

Is it possible to create new Custom Window/Dialogue (with an Icon to open them or a Keybind) with just Lua?

calm depot
#

yep

hardy fox
#

Great! Do you know any mod which has implemented something similar, so I have a reference? ๐Ÿ™‚

dark wedge
# kind fossil

It is the Event EmoteLooped in the action file that is triggering the Loop. All looped emotes trigger this event (inherited from looped.xml), which tells the Emote action to restart. In comparison, emotes that do not loop trigger the EmoteFinishing event (from default.xml).

kind fossil
#

I need to replace emotelooped by emote finishing ?

dark wedge
astral dune
#

IIRC it loads the Shared code first, then the Client, then the Server code. Which I assume is why you can't require a file from the Server folder from code in the Shared folder, for example

kind fossil
#

I also have a question about the meaning of Blend_Time?

#

It's the time to go from idle to animation?

dark wedge
kind fossil
#

I see, however I see that there is one in "action" files and in "emote" files

#

trying to find the difference between both

dark wedge
#

"action" is for TimedActions. "emotes" is for Emotes.

kind fossil
#

but I have same files for both

#

it's two different folders

#

files are not exactly the same by the way

dark wedge
#

Right, they wouldn't be the same because one is to define a TimedAction, and the other is for Emotes. Those might be unused? I don't think that mod uses TimedActions, just emotes. But could be wrong.

kind fossil
#

I have changed the blend time in the "asleep" actions file it changed the time from idle to asleep
When i change the blend time in the "emotes" it stops the emote from looping strangely

#

i think i am wrong in this actions/emotes

#

it seems that "action" is not doing anything

dark wedge
#

Correct. This mod does not use TimedActions, only Emotes. I'm like 90% sure those action files don't need to be there

kind fossil
#

yeah you're right

#

maybe for actions like washing etc

#

but they are already here in vanilla

dark wedge
#

they could be overriding some vanilla animation that gets triggered, not sure. but, they are definitely not used for the emotes. don't use the mod, so not sure on its full scope of changes

kind fossil
#

strange thing with awake when I increase blend_time, after 1 loop the animation stops

#

even though it must loop

kind fossil
#

but only using the part where he scrapped the emotes

dull moss
#

Anyone know why game might be doing this?

#

I don't think i overwrite anything there hmm

#
    TraitFactory.sortList();

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

this is my only interaction with base game trait factory

#

maybe it sets description twice? PepeThink

#

once in normal game creation methods

#

and 2nd one in mine?

#

probably it

#

yea ok that was the issue. I don't even remember why I had it

#

that for loop

drifting ore
#

Got a weird bug going on, managed to get the playerID from right clicking and getting his items and stuff.

#

But when I right click for example to get item count from the other player, nothing happens... UNTIL!

#

I switch to the other screen where the other player is

#

then it all happens at once, as many times as I clicked

#

I'm using the sendclientcommand and sendservercommand things so it must be something to do with that I just don't know what exactly could be causing such a weird "pause"

#

If you need some code lmk

kind fossil
#

Do you know where can I find the index with all the key numbers?

#

I need to set keybinds like "CTRL + ALT + xxx"
But the game doesn't let me in the settings

drifting ore
#

Something like this? idk

kind fossil
#

yes!

drifting ore
#

YAY I helped once in this chat as well ๐Ÿคฃ

kind fossil
#

now the question is can I add multiple keys in one keybind?

thick karma
kind fossil
#

thx

thick karma
#

Keyboard.KEY_LCONTROL, e.g.

kind fossil
#

I need for example to have a keybind like that : CTRL + ALT + XXX

thick karma
#

Alt is mysteriously absent, probably to discourage its use, idk

kind fossil
#

D:

thick karma
thick karma
#

You can reference it by its number

#

as in the screenshot on the forum post above

#

At least... right alt does. I use it in one of my mods.

kind fossil
#

So by following that
If I want an action to be toggled by CTRL ALT P

I should write "29 56 25" ?

#

what's the syntax?

#

(Emote) Clap=29 56 25
Like that?

thick karma
#

Ummm where are you trying to do this, I have no idea where you would try a syntax like that

kind fossil
#

keys.ini

thick karma
#

Mmmm I don't think that file allows binding multiple keys

kind fossil
#

crap

thick karma
#

I think it's used purely to get key numbers from names

kind fossil
#

My objective is to bind all emotes to strange keybinds so i can toggle them from my streamdeck

#

instead of using the wheel

thick karma
#

Word well if you want to do hold presses you may need Lua, but I don't know

kind fossil
#

damn it

thick karma
#

Only way I know to do hold press activations is Lua, but then again I activate custom functions rather than vanilla emotes, so I've never really tried looking into this method of triggering things.

kind fossil
#

at least I can use the far right keys from the keyboard

#

using modifiers like shift, alt, ctrl would have been the best

thick karma
#

In Lua, you could do something like if Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) and key == Keyboard.KEY_R then doStuff() end (for CTRL+R) during the OnKeyPressed event, but the catch is that you won't interrupt LCONTROL's default binding

kind fossil
#

yeah i see the catch

#

that's surprising that PZ keybinds don't have this

thick karma
#

You may be able to mod it in but yeah not in vanilla.

kind fossil
#

Or instead of doing I could directly connect the streamdeck keys to trigger emotes?

#

but I feel that it's wayyyy harder

#

cause it would need a plugin between streamdeck and PZ

thick karma
#

Well key signals are generally just integers so if you can get Zomboid to receive signals at all from the deck, you should be able to print them and bind them

#
local OnKeyPressed = function(key)
  print(key)
end

Events.OnKeyPressed.Add(OnKeyPressed)
``` @kind fossil
#

You can add this to any of your mods to just check what signals you get when you play

#

In the debug console

#

if you have any unusual keys that aren't named coming in from the deck, they should still have a number

kind fossil
#

But i think streamdeck uses an API to send information

#

they are not keys pressed like a keyboard

ancient grail
#

You are talking to burryaga the author of a joypad mod fyi

kind fossil
#

Didn't know that!

#

I already use some of your mod i think but not this one

dark wedge
kind fossil
#

Yes that's what I'm planning to do if I can't find a solution

#

the thing is that I have less than 20 keys available with that method

#

I wanted to find a solution to use modifiers in keybinds (ctrl, alt, shift...) to increase the amount of emotes I can bind

dark wedge
kind fossil
#

I don't think I have the knowledge for that

#

:/

elfin rapids
#

Hi guys, is there anyone who ever tried to change dynamic traits to make it fits his desire most? I'd like to remove one trait completely from this mod but i barely has any knowledge about mods

#

Or don't even remove, just make it never appears again cause it can be developed after killing 15k zombies

#

I can show./send LUA files in private message, thanks

dark wedge
# kind fossil I don't think I have the knowledge for that

This should do the trick:

    -- normal numpad keys
    [82] = "comehere", -- 0
    -- numpad + rshift
    [582] = "Burpees11", -- rshift + 0
    -- numpad + rcontrol
    [682] = "saluteformal" -- rctrl + 0
}
local doEmoteKey = function(key)
    local index = key
    if isKeyDown(Keyboard.KEY_RSHIFT) then
        index = index + 500
    elseif isKeyDown(Keyboard.KEY_RCONTROL) then
        index = index + 600
    end
    if emoteKey[index] then
        getSpecificPlayer(0):playEmote(emoteKey[index])
    end
end
Events.OnGameStart.Add(function()
    Events.OnKeyPressed.Add(doEmoteKey)
end)```
Just build the `emoteKey` array to fill in what keybind you want to do what emote.  For a modifier key, you'll see i'm upping the index by an amount (500 for r-shift to avoid any overlap of keys, and so on).  keybind "82" (0 on the numpad) does "comhere" emote when pressed, "Burpess11" when shift+0 is pressed, etc.  You'll have to fill in the rest for the keybinds/animations you want.
kind fossil
#

damn!

#

so I just need to add all the keybinds in the emoteKey

#

and put the file in the lua folder?

#

No need to create a mod right?

dark wedge
kind fossil
#

ah crap

#

even though it's client sided?

dark wedge
# kind fossil even though it's client sided?

if its all client side then i guess it wouldn't matter. but an update to the base game or whatever mod you add this to will likely remove your change. also not recommended to be modifying vanilla lua

kind fossil
#

ahh okay

#

Oh and also I can just create a file with whatever name?

kind fossil
thick karma
dark wedge
kind fossil
#

okay thanks!

dark wedge
kind fossil
#

I can add that in keys.ini for example? Or better to just create a separate file?

thick karma
#

Oh dope I may adjust my mod in the future

kind fossil
#

so a file like : emoteKeys.lua in the "Lua" folder?

dark wedge
kind fossil
#

thanks

thick karma
dark wedge
kind fossil
#

since i'm not a modder myself, it's for personal use only

thick karma
#

Fair but not recommended haha for obvious reasons

#

The mods folder is specifically for non-workshop mods. @kind fossil

dark wedge
thick karma
#

In mods, you could make EmoteKeys/media/lua/client/emoteKeys.lua

kind fossil
#

oh cool so I can use client side mods from this folder on servers?

#

thanks for the info

#

By the way guys you don't do commissions ? We are looking for devs

thick karma
#

If you're hosting for multiplayer you can give your mods to your friends and if they have the same mod in Zomboid/mods, you're good.

kind fossil
#

it's not a personal hosted server

thick karma
# kind fossil By the way guys you don't do commissions ? We are looking for devs

Not usually, I prefer to focus on what I personally think the game needs most, and almost nobody wants to pay what I would want to take my time away from that in a committed way. I don't mind helping from time to time when I'm taking a break from stuff, but if I'm going to get involved in serious programming, I need to believe in it or be paid like it's a job. Too many people out here giving poor modders $50 for stuff that took 6 hours. Programming should pay better than that; it's taxing to code solutions to other people's problems, imo.

kind fossil
#

You're right ye

dark wedge
kind fossil
#

Totally understandable

#

We have been thinking of mod features that would help a lot our roleplay serie project, but we don't have the modding knowledge

thick karma
#

For sure, I second that. Part of why I wouldn't take commissions that pay less hourly than my job is that I feel it would kill the fun of the hobby quickly for me to reflect on that while I'm grinding at a mod.

kind fossil
#

But I totally understand your point

#

I just feel that asking people to dev something for free is just unfair

ancient grail
#

@dull moss dude

#

@kind fossil
https://pzwiki.net/wiki/Modding:Lua_Events https://theindiestone.com/forums/index.php?/topic/2530-mod-permissions/ https://github.com/FWolfe/Zomboid-Modding-Guide https://steamcommunity.com/id/Dislaik/myworkshopfiles/?section=guides https://projectzomboid.com/modding/index-files/index-1.html https://gist.github.com/Konijima/7e6bd1adb6f69444e7b620965a611b74 https://theindiestone.com/forums/index.php?/topic/15188-item-and-recipe-script-variables-brief-description/ https://www.lua.org/pil/contents.html

thick karma
# kind fossil I just feel that asking people to dev something for free is just unfair

My personal approach if I wanted a mod I couldn't make would be to float the idea to other modders and hope someone who knows how decides that it would be a fun and worthwhile task for them to add that to the game. If the feature is very personal rather than for the good of the game, I probably wouldn't bother pursuing it, but I don't think there's anything wrong with saying in a room full of modders, "Wouldn't it be cool if..." and seeing if others agree.

#

And then I might donate what I can

kind fossil
#

Sure

thick karma
#

However for me donation and payment feel different

kind fossil
#

That's why I have written a page with all our ideas so it can inspire people, since it's very roleplay related, it could benefit the community

thick karma
#

Because payment says, "I paid you so you owe me," and implies a sort of business fairness to the exchange that imo is rarely present in this sitch

kind fossil
#

yeah i understand

thick karma
#

Whereas donation says, "here's what I can give, I know it doesn't pay for what you put into this, but thanks."

kind fossil
#

It's a way to thank the dev

thick karma
#

Just my personal perspective but I don't think there's anything fundamentally wrong with offering lower-than-programming wages to anyone who is legitimately happy to do the job.

#

I just don't because I feel bad lol

ancient grail
#

Who donates anyways
Only time i recieved a donation it was from. Fellow modder
Thnx sigma vulcan. Its not the $ that matters when u recieve a donation

kind fossil
#

I did a few times to be honest

thick karma
#

Yeah honestly I wouldn't recommend modding as a way to make a ton of money. I do it when I already like a game and feel I know how to make the game better

kind fossil
#

I'm even subbed to a Modder's Patreon on Minecraft

#

since he has been developing a huge groundbreaking mod by himself for years

#

it's a way to say "mate, we are still here, keep up the good work!"

elfin rapids
ancient grail
#

@dull moss ?

elfin rapids
#

i also meant just "dynamic traits" mod

#

not Sauce edition

ancient grail
#

Ow ok then

elfin rapids
#

and cause i've no knowledge about this kind of stuff i need to somehow remove it by myself or with help from someone else

ancient grail
#

But do u have permission to do so

#

Cuz if u do you can create a mod patch

elfin rapids
#

Are you telling me that i can't change mod only for myself if i won't upload it?

#

Because i don't want to create mod patch

#

i just want to fix it for myself

dull moss
#

are you playing SP?

ancient grail
#

Ah u can if its solo

dull moss
#

what trait u dont want to see?

ancient grail
#

The bloodlust thing

elfin rapids
dull moss
#

ah ye

#

well either do that

elfin rapids
#

The problem that i literally like every other thing in dynamic traits

#

besides this one annoying trait

finite radish
#

so remove it

ancient grail
#

Just comment out on the lua file

finite radish
#

lol yeah

elfin rapids
#

comment out? You mean upload them here?

ancient grail
#

Just use

--[[ stuff u want removed ]]

#

No i ment comment out the code

#

Literally edit the lua files

elfin rapids
#

yea, that's the problem, i open it and i've no idea what i should safely remove to make bloodlust never appear again without also crashing my game

ancient grail
#

Alternatively you can just add
return
Just before the function starts

finite radish
ancient grail
#

You should hire a modder the

finite radish
#

...hire? KEKW lua is not that hard, it's very readable. just gotta read

elfin rapids
#

read and learn

#

the only thing i ever did with "modding" was changing values of weapons for already made mods in payday 2 kekLaugh

bronze yoke
#

yeah that would be a total waste of your money, it's a ten second change

elfin rapids
#

well, i'm studying these files right now

#

if i had any real knowledge about making mods then it would be easier, that's why i came here for help

finite radish
#

i think glytcher provided links above if you have specific questions, but otherwise the functions in the file are fairly self explanatory in most cases

#

although if they're being added dynamically it might cause issues, so I can see where that might be a problem

#

more or less just ctrl+F for anything you need to find

#

in your case, bloodlust

elfin rapids
#

not really, the code for bloodlust is that it has random chance of being added after every kill or it's forced to be obtained after x kills

finite radish
#

you can do a dirty edit if you just remove the trait though. you'll get a lua error, but it should be relatively harmless

sour island
#

What does bloodlust do

elfin rapids
#

you're getting sad, bored, angry if you did not kill any zombie for x time

#

after more time you're starting to hear zombies sounds

sour island
#

lol

finite radish
#

sounds like a shitty mod tbh

sour island
#

So an average PZ player

elfin rapids
dull moss
#

simple as that

ancient grail
#

Once you find the part where it sets it then just comment out that part

elfin rapids
#

it has a very different options to be set cause it depends on trait that you've started with

fast galleon
#

function bloodlustTrait(player)
return
end

ancient grail
#

It would look something like
Events.stuffstuff.Add()

elfin rapids
#

else
if not player:HasTrait("Bloodlust") and player:HasTrait("Desensitized") then
if DTrandomNumberForKills2(player, 15000) == 0 then
player:getTraits():add("Bloodlust");

fast galleon
#

that should stop ticking up counter

elfin rapids
#

that's how it works in file

ancient grail
#

There just add

--

#

--player:getTraits():add("Bloodlust");

#

But poltergeists suggest a better way cuz it not use up much ram
But if you cant do that then this would be an alternative solution

ancient grail
fast galleon
#

hm, there's also pure random chance to add it ๐Ÿ˜ฆ

elfin rapids
#

yea, there are two lua files related to getting this perk and there is also other one about how it works

ancient grail
#

Send all the function

#

Here

#

So we can advice i guess

elfin rapids
#

ok thanks everyone, guess coming here with literally no knowledge was bad idea, especially if i had no idea what commands/functions are

#

But i'm grateful that you wanted to help me

fast galleon
#

hm, what I wrote would stop the counter, so even though if you have the trait, it would do nothing

elfin rapids
#

yea but i had no idea where to add it and it's hard for someone else to explai nwhen he can't check lua file

#

I also thought about even other solution - i'll just change number in bloodlust from 24/72 hours to like 240000/720000 hours, this way i won't feel negative impact of this trait at all

#

so i won't remove it from game but negative effects won't ever appear

#

BLOODLUST TRAIT
function bloodlustTrait(player)
--print("DT Logger: running bloodlustTrait function");
if not player:isAsleep() then
player:getModData().DTtimesinceLastKill = player:getModData().DTtimesinceLastKill + 1;
end
--print("DT Logger: DTtimesinceLastKill value is " .. player:getModData().DTtimesinceLastKill);
end

function bloodlustTraitEffects(player)
--print("DT Logger: running bloodlustTraitEffects function");
-- CHECKS IF THE PLAYER READ ALL THE BOOKS TO LEARN HOW TO CONTROL THE EMOTIONS
if player:getModData().DTstressIntelligence == true and player:getModData().DTunhappynessIntelligence == true and
player:getModData().DTboredomIntelligence == true and player:getModData().DTangerIntelligence == true then
-- IF PLAYER HAVEN'T KILLED ZOMBIES FOR 72 HOURS, THEN THE MOOD WILL BE AFFECTED EVERY HOUR
if player:getModData().DTtimesinceLastKill > 72 then
--print("DT Logger: All the books were read");
-- STRESS
DTincreaseStress(player, ZombRand(5), 0.20);
-- BOREDOM
DTincreaseBoredom(player, ZombRand(5), 15);
-- UNHAPPYNESS
DTincreaseUnhappyness(player, ZombRand(5), 10);
-- ANGER
DTincreaseAnger(player, ZombRand(5), 0.30);
end
else
-- IF PLAYER HAVEN'T KILLED ZOMBIES FOR 24 HOURS, THEN THE MOOD WILL BE AFFECTED EVERY HOUR
if player:getModData().DTtimesinceLastKill > 24 then
--print("DT Logger: All the books were not read");
-- STRESS
DTincreaseStress(player, ZombRand(5), 0.20);
-- BOREDOM
DTincreaseBoredom(player, ZombRand(5), 15);
-- UNHAPPYNESS
DTincreaseUnhappyness(player, ZombRand(5), 10);
-- ANGER
DTincreaseAnger(player, ZombRand(5), 0.30);
end
end
end

ancient grail
#

Theres literally hundreds of ways u can disable it...

elfin rapids
#

and yet i'm struggling to find any that i can execute

ancient grail
#

On the middle of first and second line
Add
return
Which is what poltergeist was telling u to do

#

It wont run the code
Below the return

elfin rapids
#

Is return going to block only this command or whole lua file?

fast galleon
#

I have a patch file in lua/client named something like ~Patches.lua

if getActivatedMods():contains("DynamicTraits") then
    require "DTstaticTraits"
    function bloodlustTrait(player)
        return
    end
end
#

the script is for you

elfin rapids
#

thanks!

ancient grail
#

Surgical strike approach of solving the problem

#

Youre awsome @fast galleon ๐Ÿซก

elfin rapids
#

and just add script there?

fast galleon
#

make the name more unique

#

When you have more patches, you will probably make a separate mod to place your files separately

#

rather than edit the base mods

elfin rapids
#

ok got it, i'm happy that notepad++ was enough to create .lua

fast galleon
#

you can do the same for some of the other functions too, like the second one you posted

#

tweaking the values is also something you could do if you feel like it

elfin rapids
#

i've no idea what i can and what i can't do tbh

#

But i'm really grateful for your help

pulsar heath
#

i think i already know but hope is always the last thing to go... does pz lua has anything to read json string into a dic or do i have to do the function myself and go mad with gsub or something like that?

bronze yoke
#

nothing vanilla, just find a library online

dark wedge
pulsar heath
#

i can load lua libs in the game? i thought that was... restricted due to security reasons

#

thanks @bronze yoke and @dark wedge

dark wedge
pulsar heath
#

oh that makes my life a lot easier then ๐Ÿ˜„

#

was even thinking about saving the json in another format easier to read from base lua...

fast galleon
#

any ideas which one is better?

pulsar heath
#

for me it will be the 1st one to work without any hastle...

#

nice nice... app is done... working on the mod code...

#

and was thinking the json bit was gonna be a hastle...

#

since im exporting on twitch event a json string to a file that contains the data of what the mod has to do
{"title":"Presentinho","zombies":true,"zedquant":999,"gifts":3,"helicopter":3}

#

so with this... life is easier

dark wedge
pulsar heath
#

so ill use the mrbounty then, only need to decode json and store it into a dic

#

then use that dic to fill the values of the function that triggers the game event

vast veldt
#

Hi - I'm interested in intercepting all actions a player performs; to do so I'm currently planning to intercept calls to ISBaseTimedAction:perform() - but currently doing so is causing the game to report a "bugged action" when I do this... but it also runs my custom code whenever the player does an action, so I feel I'm on the right sort of track.

I wondered if anyone else had experience intercepting function calls from the vanilla LUA in a way that behaves as "politely" as possible to the base game. I feel like the context of "self" is part of what I'm messing up that's breaking the base functionality, but this is where my knowledge of the syntactic sugar of . vs : is getting to it's limits!

bronze yoke
#

can you show your perform function?

vast veldt
#

Sure

#

This is my interceptor class. It only works on the first load (because afterwards it ends up swapping the base method for itself recursively I guess - but before solving that I just want to intercept calls in a way that plays nice with the base

#

I say class, that's probably the wrong way to describe it in LUA...

bronze yoke
#

so the problem is using : passes the object before it as self: in this case, you're calling the original perform with PGMG.Client.Action as self

#

try PGMG.Client.Action.originalCall(self) instead of PGMG.Client.Action:originalCall()

vast veldt
#

Giving it a go, thanks - this part of LUA has always been a bit dicey for me!

#

My word, that's done the trick, no more bugged actions. Perfect. Now I just need to figure out how to not screw up the injection if the LUA is reloaded (i.e. end up in a loop back to myself) and the baseline should be there.

dark wedge
bronze yoke
#

i think they meant when you reload a single file

vast veldt
#

Ah ... yes, I might be overthinking; the client will only ever reload all of the LUA, correct? (Short of using the debugger to ask it to reload just one?)

astral dune
#

ya, you don't have to worry about someone reloading your file otherwise

vast veldt
#

Perfect

limber oar
#

This works a dream, by the way. Thanks again.

drifting ore
#

I am still struggling with sendservercommand and sendclientcommand

#

Browsed multiple mods how they use it even the lua files in the game

#

I'm not sure how to send a request with it for an argument and then get it back

#

To be completely honest not even sure which one of those requests and which one sends

vast veldt
#

sendServerCommand sends from the server side, sendClientCommand sends from the client side

drifting ore
#

Yeah but for example theres isoplayer, module, command and args

#

For servercommand

#

Does this mean that isoplayer is the one youre sending it to

#

Amd args what you're sending him?

vast veldt
#

Yes on both - module and command are just strings used to detect if this is the call you're interested in. Player matters on the server side, on client side, I've always just used getPlayer() - other more experienced modders may be able to elaborate if that's entirely appropriate, but I know that works. Args is a LUA table with the arguments and as far as I can tell, it reaches the other side essentially intact.

drifting ore
#

Oh also my bad, servercommand is the client sending the server a command

#

so in "theory", its player - who is sending it

#

and args - what he's sending the server in the form of a command when that function is executed (when he does something to execute it)

#

no wait

#

got it wrong again

#

๐Ÿคฃ

vast veldt
#

args can take any LUA Table as far as I know.

drifting ore
#

I think I got it right the first time around but yeah in essence

#

I'm gonna try and think of it like that like you said, this dude sends this in a lua table and module command is just something to identify what is sent when

astral dune
#

depends whats in the table, not everything will make it

vast veldt
#

Yeah I've only generally sent primitives in the table.

astral dune
#

primitives are fine, but no userdata. From what I understand, inventoryitems are an exception and should send

vast veldt
#

I didn't know you could pass anything other than primitives to be fair

drifting ore
#

Are you allowed to leave some things in that function blank? I'm looking at a sendclientcommand in a function right now that just has module, command and args

#

Whereas on the project zomboid . com website it says it should take in player, module, command & then args

vast veldt
#

I don't think player should be blank. if you want to send to all, iterate from a player list i.e. getOnlinePlayers()?

astral dune
#

there are two versions. One sends to a specific player, the other I think broadcasts

bronze yoke
drifting ore
#

Oh yeah you're right @astral dune

#

I'm looking at one right now that takes module, command and table

vast veldt
#

I'll defer to @bronze yoke here as they seem to know the LUA of this game backwards XD

drifting ore
#

One was from Global Object and one from CGLobalObjectNetwork

dusk bridge
#

Hi! So, i have a problem with a mod. I can Ask questions here, right?

astral dune
#

if you're the one making it, sure, otherwise you probably want #mod_support

dusk bridge
#

So, uh, first i wanna know what "mask" is in clothing settings

#

I didnt find any information about this

#

And i really cant understand what it is, and what is it doing.

dull moss
#

ok, logic-related question. I might be smolbrain here but trying to figure if its possible to combine those 2 ifs somehow?

if A == true and B >= 10 then
  if C == true and D >= 20 then
    XYZ
  elseif C == false then
    XYZ
  end
end```

Basically, I always want to check A and B condition to execute XYZ. But on top of that, IF condition C is enabled, it should have additional requirement D.
#

I mean I can do something like

bronze yoke
#
if A == true and B >= 10 then
    if C == true then
        if D >= 20 then
  
        end
    else

    end
end
dull moss
#

if (A == true and B >= 10) and ((C == true and D >= 20) or C == false) then

#

think that should work?

bronze yoke
#

oh yeah

#

i didn't realise that was what you were going for

dull moss
#

I typed this out and i was like "wait a second"
if (C == false and A == true and B >= 10) then

drifting ore
#

So if I can get another players ID from a client side, by right clicking on that person
I can then also use this ID to get that players inventory since the inventory is client sided (someone said)
What is the use of the server in this instance? What can it provide that I cannot obtain via client-side code?

bronze yoke
#

the inventory is on their client

drifting ore
#

Or does client-sided mean that it's on HIS client, not everyones client

#

Ahhhh

vast veldt
#

Although even if they can be combined, there is almost no overhead in doing those checks so, do they make the code more readable?

bronze yoke
#

we can't send commands directly to other clients, so you need to ping things off of the server

dull moss
#

Advantage is that I don't have to have 2 instances of XYZ

bronze yoke
#

repeating code is a bad idea

dull moss
#

yep

drifting ore
#

So Albion, in this case, let me just break it down to see if I get it.
I get his ID from my client for example by right clicking
Send that ID to the server - should I then make a function within the server code to get for example an item count
And then send that item count back to my client?

vast veldt
#

If it reads easier, make it more readable, the overhead of an extra iteration or two in the state machine will mean little?

drifting ore
#

Via another send---command line

bronze yoke
drifting ore
#

lmao that's cool, I'm gonna experiment with that now, thank you a bunch โค๏ธ

bronze yoke
#

like player a -> server -> player b -> server -> player a

dull moss
# vast veldt If it reads easier, make it more readable, the overhead of an extra iteration or...

I have 2 92 lines function that are identical and only difference is that one variable is different

    if SBvars.WeightSystem == true and SBvars.SleepSystem == true then Events.EveryTenMinutes.Add(weightSystemAdvanced) end
    if SBvars.WeightSystem == true and SBvars.SleepSystem == false then Events.EveryTenMinutes.Add(weightSystemBasic) end

I usually opt out for readability, but fixing this shit was trash cuz I have to make adjustments in 2 same functions

drifting ore
dull moss
#

So I'd rather have more complex IF and 1 instance of function

drifting ore
#

Inside the sendclient/servercommand

astral dune
drifting ore
#

Basically deciding on who you choose, to who to send that command to?

dull moss
dusk bridge
dull moss
#

even though this one is shorter

ancient grail
astral dune
#

oh, I'm not reading it right

dull moss
astral dune
#

lua nonsense would be to do

if SBvars.weightSystem then
  Events.EveryTenMinutes.Add(SBvars.SleepSystem and weightSystemAdvanced or weightSystemBasic)
end
bronze yoke
#

that's evil

vast veldt
dull moss
#

did you even read what I said

#

I literally said that I'll opt out for more readable variant

vast veldt
#

Absolutely, yes, sorry, I was trying to support the comment

dull moss
#

Ah

astral dune
#

I think its perfectly readable ๐Ÿ˜›

dull moss
#

I thought you thought I thought that less readable is better

(yes I tried to put as many thoughts as possible in that sentence)

ancient grail
vast veldt
#

No, indeed, - although, as a good example of readability, even in plain English, I communicated it incorrectly.

vast veldt
#

Sometimes a picture paints a thousand words?

ancient grail
#

Lol
That made my day

vast veldt
#

Well, let us all rejoice in the joy that is programming machines

drifting ore
#

I think I just wrote the most scuffed ass lines of code ever to be written in Lua for zomboid. Jumping back and forth sending commands from server to client to server made me lose 10 IQ points easy

limber oar
#

Hey, Step 1 is always "get it working," you can refactor it later. :P

vast veldt
#

That's pretty much how all of us feel writing LUA

drifting ore
#

lmao

drifting ore
#

I gotta say it's fun as hell tho when it finally works

limber oar
dull moss
#

Question: how can I NOT break ppl saves if I change sandbox variable type from boolean to dropdown menu (assuming there's a way to make a dropdown menu, think I saw in some mods, haven't researched it yet)

bronze yoke
#

sometimes i write insane code on purpose hoping that someone one day will look through my source and go 'what the fuck'

frank elbow
#

Beyond evil

vast veldt
frank elbow
#

You're going straight to jail

dull moss
bronze yoke
#

i've been on the run for years

#

if they catch me i'm going straight to the chair

thick karma
drifting ore
#

I'm gonna start putting memes in ascii format in the code I write because if I ever get this working I might as well get some form of fun from it

dull moss
#

finally a way to unalive Copium

thick karma
#

But I second your notation, lol.

vast veldt
dull moss
frank elbow
#

I keep my code's chaos low by just including jokes in explanatory comments

dull moss
#

albion is pat, answered like a hundred of my questions

dark wedge
vast veldt
#

albion has my tips all day long ๐Ÿ˜

dull moss
#

what if

#

i do it in few releases

#

Like 1st update i make new var
2nd update i delete old
3rd i change new var to have same name as old var

#

1st and 2nd can be combined

#

ah fuck it, too much hustle, new var name it is

#

Christmas is over, time go go back to old pfp WICKED

drifting ore
#

How do i make a virus like a cold???

#

but you get it randomly

vast veldt
limber oar
#

Beat me to the smartass response

dull moss
vast veldt
limber oar
vast veldt
#

Yay

#

So first, we need a virus. I suggest common cold.

drifting ore
#

i just started to mod

vast veldt
#

CommonCold:infect()

fast galleon
#

Dynamic Traits has a "Cold" Sickness

dull moss
#

You mean this?

drifting ore
dull moss
#

I was asking @fast galleon

#

๐Ÿ˜„

drifting ore
#

oh

fast galleon
#

similar I guess, vanilla is so rare I forget about it

drifting ore
limber oar
#

I just spent ten minutes writing out my problem to you guys to try and get help and then while writing it out I figured out what I'd been missing

vast veldt
#

CommonCold:propagate()

drifting ore
#

all right

vast veldt
#

Spread the illness

#

Soon everyone will have a slightly annoying illness that impedes perhaps 25-30% of motor functions. Aahhaaahahhaahhahhhaahaha!

#

My evil plan is complete

drifting ore
#

i love where this is going

vast veldt
#

Soon the world will know my fury. Or about 25% of my fury.

#

But that's quite a lot of fury! Spread over a reasonably absorbent crowd.... but still!... Fury!

drifting ore
#

true

dark wedge
#

I don't think the game differentiates vehicles like this, but is there an easy way to tell if a vehicle is a van, truck, car, etc?

drifting ore
#

what are all the all cold stuff like affects

#

for example

#

if player:getBodyDamage():getColdStrength() >= 75 then
player:getBodyDamage():setPoisonLevel(player:getBodyDamage():getPoisonLevel() + 1);
-- player:getBodyDamage():setFoodSicknessLevel(99);

dull moss
#

when initializing moddata for example we can do multiple or right?

like
modData.NewOutdoorsmanCounter = modData.OutdoorsmanCounter or modData.NewOutdoorsmanCounter or 0;

#

ah but then i have to make sure i set old counter to nil

#

so it doesnt overwrite again after 1st load

drifting ore
#

ok

astral dune
dark wedge
limber oar
#

Okay, here's a new one. Maybe someone can help me bring a little order to chaos myself.

Long story short, I'm trying to build some ZombieZoneDefinitions programmatically. IF sandbox option selected, THEN spawn X zombies in this zone, etc. For reference, here's what I want the declaration to look like:

ZombiesZoneDefinition.School = {
    maleChance = 100,
    Student = {
        name="Student",
        chance=70,
    },
    StudentSwimmer = {
        name="StudentSwimmer",
        chance=10,
    },
    StudentAthlete = {
        name="StudentAthlete",
        chance=20,
    },
}

I'm building the ZZDs using table.insert, but while I've got the outfit definitions working fine I just can't seem to get male/femaleChance plugged in correctly.

ZombiesZoneDefinition.School = {}

-- This part doesn't work
if SandboxVars.ModName.GenderRatio == 1 then
    table.insert(ZombiesZoneDefinition.School,{maleChance = 100})
etc.
end

-- This part does
if SandboxVars.ModName.StudentType == 1 then
    table.insert(ZombiesZoneDefinition.School,{name = "Student", chance=70})
    table.insert(ZombiesZoneDefinition.School,{name = "StudentSwimmer", chance=10})
    table.insert(ZombiesZoneDefinition.School,{name = "StudentAthlete", chance=20})
etc.
end

It's probably because male/femaleChance isn't a table like Student, StudentSwimmer, etc. but I'm not sure how to plug it in properly in that case. Anyone know how to get this WAD?

astral dune
#

well, weight and size too, I supposed you could try to make up some rules

dark wedge
astral dune
#

lol, no I don't think you'll find anything interesting there. There are a few ways to tell if it takes heavy duty, normal or performance parts, that may help you figure it out, but its likely going to be a lot of guess work or mapping each vehicle individually with compatibility code

dark wedge
drifting ore
#

How do you make a virus with moodle framework

#

or with out

#

been saying 1 more debug run for the past 3 hours it's 2am here now

#

ffs

#

still stuck on the same thing, cannot figure out for the life of me how to operat sendclient/servercommand

#

it must be something hella obv because that's how it be

dull moss
# dark wedge The `enum` sandbox variable type lets you make a dropdown menu. As for not brea...

found mod with it,

{
    type = enum,
    numValues = 4,
    default = 1,

    page = AutoDrop,
    translation = AutoDrop_LootMode,
    valueTranslation = AutoDrop_LootMode,
}```
```    Sandbox_AutoDrop_LootMode = "Loot Mode",
    Sandbox_AutoDrop_LootMode_tooltip = "Allows to override Mod Options client selection",
    Sandbox_AutoDrop_LootMode_option1 = "Mod Options client selection (Default)",
    Sandbox_AutoDrop_LootMode_option2 = "Auto Loot",
    Sandbox_AutoDrop_LootMode_option3 = "Auto Drop",
    Sandbox_AutoDrop_LootMode_option4 = "Instant Loot",```
can't find it being used in lua though, 
I assume its something like `SandboxVars.AutoDrop.LootMode` and it returns value from 1 to 4?
#

by value i mean number, aka which option was used

dark wedge
drifting ore
#

How do you make a virus with moodle framework or with out

dark wedge
dull moss
#

if its sneaky virus then dont use moodle

drifting ore
limber oar
dark wedge
# drifting ore How do you make a virus with moodle framework or with out

My friend, we're not going to be able to tell you how to make a full mod like that. Additionally, removing/re-adding your comment is not productive.
High-level overview:

  1. make a trait (can be added or removed on demand on a player) -OR-
    track custom sickness values in your own scripts for a player (this would be "hidden)
  2. Every x ticks or x minute events, do something if the player has that trait or something.
  3. After x amount of time, you die or get better.
    If you want to use the Moodle Framework: https://steamcommunity.com/workshop/filedetails/discussion/2859296947/3380536561724844838/
dull moss
#

oh u said sneaky

drifting ore
#

Ok

limber oar
pulsar heath
#

now time to take a break...

ancient grail
#

im trying to trigger a recipe using lua

#
RecipeManager.PerformMakeItem('Take Meat', Nuka.ZedMeat, getPlayer(),nil)
ISCraftAction:new(getPlayer(), Nuka.ZedMeat, 250, 'Take Meat', getPlayer():getInventory(),true )
#

any ideas how

#

heres the recipe

#

i want to make it available on the world context menu which is why im wondering if its posstibe to trigger the recipe

dark wedge
#

You need to actually do the TimedAction:
ISTimedActionQueue.add(ISCraftAction:new(getPlayer(), Nuka.ZedMeat, 250, 'Take Meat', getPlayer():getInventory(),true ))

#

Also, just to clarify the "item" parameter for the ISCraftAction is a reference to an actual item the player has/can grab, not just the internal name of an item.

ancient grail
dull moss
#

Gold I love that because they have typos in their code I have to do shit like this

local function checkStartingTrait(startingTraits, player, trait)
    if trait == "Claustophobic" then
        if startingTraits.Claustrophobic == nil then
            startingTraits.Claustrophobic = player:HasTrait(trait);
        end
    elseif startingTraits[trait] == nil then
        startingTraits[trait] = player:HasTrait(trait);
    end
end```
#

instead of just

local function checkStartingTrait(startingTraits, player, trait)
    if startingTraits[trait] == nil then
        startingTraits[trait] = player:HasTrait(trait);
    end
end```
ancient grail
#

something like this but replace the function on the context menu with the craft trigger

local function NukaCannibalContext(player, context, worldobjects, test)
    if isCannibal() == true then
        local sq = nil
        for i,v in ipairs(worldobjects) do
            local square = v:getSquare();
            if square and sq == nil then
                sq = square
            end
            if instanceof(v,"IsoDeadBody") then
                context:addOption("TakeZedMeat", v, TakeZedMeat)
            end
        end
    end
end

Events.OnFillWorldObjectContextMenu.Add(NukaCannibalContext);
wide oar
#

Would it be possible to create a zombie mod and have it be a singular unique zombie that spawns in the world (amidst other zombies, obviously) and only once, that has a unique outfit, plays music when it aggros onto the player (this would be heard in a short-ish radius, so it doesnt blast across the entire map) and can only walk slowly, attacks with a weapon (or looks like it does, like could i have it spawn with a weapon in its hand? would i have to make a special model for this?) and never loses aggro no matter how far the player goes, so eventually it would catch up? i want it to have really high health and not stagger unless it takes a lot of damage at once. for reference, im making a Michael Myers zombie mod that includes his lootable mask and knife and outfit when you kill him.

#

like are these things doable? i feel like they should be, given how moddable zomboid seems to be.

dark wedge
dull moss
#

ah yes let me add 2 special cases cuz someone cant type in english

        if trait == "HeartyAppitite" then
            if startingTraits.HeartyAppetite == nil then
                startingTraits.HeartyAppetite = false;
            end
        elseif trait == "Thinskinned" then
            if startingTraits.ThinSkinned == nil then
                startingTraits.ThinSkinned = false;
            end
        elseif startingTraits[trait] == nil then
            startingTraits[trait] = false;
        end
dull moss
#

that'd be gigantic waste of resources

#

and unneeded

#

you could forcibly teleport zombie to stay at least 300 range within player

#

I think

#

again, havent worked with zombies

#

casual 102 lines moddata.lua MonkaS

#
  • How much moddata entries do you use?
  • Yes
ancient grail
#

Just an idea

#

Not a bad concept too i think

dull moss
#

Ye i like the Myers idea

#

but infinite aggro seems undoable without teleporting Z closer to player

#

cuz I'm like 99% sure PZ only does zombies within few cell range of you

#

Simply from logic perspective

#

Unless they found some smart way which I don't think they did cuz then we'd have NPC system by now

dull moss
#

lmaooo

#

"they manage to be worse than my ex-wife"

finite radish
#

has anyone tried to make a manual transmission yet? I think I'm gonna put that on my to-do list if not, seems like it'd be fairly straightforward to implement, but I haven't looked into the code that handles gear shifts yet

dull moss
#

iin lua u can do this, right?
local lowerCounterBoundary = -SBCounter ;

#

or do i have to
local lowerCounterBoundary = SBCounter * -1;

#

I usually ask chatGPT and it's down

#

oh nevermind its back up

bronze yoke
#

yes

dull moss
#

I ofc knew it Kappa

#

it's so much easier than googling

#

and looking some stackoverflow

opal rivet
#

Yep coding is no more

wide oar
dull moss
wide oar
#

haha

opal rivet
#

It's a horrible future

dull moss
#

The plan is to live a little and then die before humans become obsolete so we're fine

#

Think we got another 5-15 years

#

Unless you're younger than 20

#

then you're not fine

wide oar
#

I wonder how i would handle aura-music. anyone have any ideas? ._.

dull moss
#

@bronze yoke worrypat

wide oar
#

I was considering taking apart the true music mod to see how it handles boombox radius and then see if i could attach something like that to the zombie that spawns. im reverse engineering that nemesis mod to figure out the special/uniqu part, but yea

dull moss
#

boi that's a lot of work

dark wedge
wide oar
#

my knowledge of coding is pretty shit, i took a python class last year(?, 2022 january i think) so its been a while.

#

i can still understand what it does when i look at it, for the most part tho

dark wedge
drifting ore
#

would this work as a trait?

faint jewel
wide oar
#

By the way, does anyone know if zomboid hides the players arms/w/e when a hoodie is placed on?

rustic grove
wide oar
#

like does the player body stop rendering when clothes are on

#

wondering cuz im trying to get clothes to fit perfectly over the base model for a mod, and i am having trouble with clipping due to the shoulders being weird, so i am wondering if that matters or not

drifting ore
#

i put the cold code to try to change the cold when the trait is picked

dull moss
#

trait needs to be in shared/NPC i think?

#

and the rest in client

wide oar
#

oh yeah, do cloth physics exist in zomboid

dull moss
#

oh wait maybe not

#

disregard my answer i have no fucking clue

dark wedge
#

no

drifting ore
jagged ingot
wide oar
wide oar
faint jewel
wide oar
#

maybe if resistant to cold, burns up faster, and vice versa

drifting ore
wide oar
dull moss
#

no I mean you create trait

#

it should in shared/NPC

#

your lua with trait

jagged ingot
#

mmmm

#

Backdrop shader pass with UI is a very sweet treat.

#

Time to make frosted blur UI backdrops..

drifting ore