#mod_development

1 messages · Page 195 of 1

bronze yoke
#

in general, the 'new' scripts have the majority of items

tulip cipher
#

MyTrait:addXPBoost(Perks.Doctor, 4) adds 4 lvls, guessing its just MyTrait:removeXPBoost(Perks.Doctor, 4) to get rid of 4?

bronze yoke
#

i don't think there's a remove method

covert carbon
#

how do you reopen the command bar when you close it

undone tapir
#

the debug window? the ~ key

covert carbon
#

oh alright

#

if I did ZombRand(1, 100) will the numbers 1 and 100 be included?

median mantle
tulip cipher
#

is there a way to cap someone to a certain level of a skill or do i just have to detect them gaining a lvl to remove it

tulip cipher
#

so try that i guess

bronze yoke
#

ZombRand(1,2) doesn't work

#

1 is included, 100 is not

#

traditionally with rng functions the upper limit is exclusive

tulip cipher
#

just wait till you see my mod, nothing is traditional

#

how do i stop this from happening, seems odd

#

it happens completely randomly

#

is it just a glitchy system?

viral spire
#

I have no clue how to mod, but I'm willing to figure it out. How complicated would it be to make a submod for EHE and They Knew (and Antizin submod) to allow the medicines to appear in medical airdrops?

If it's not as complicated as I think it is, I'd like to put something like this together.

drifting ore
#

how do i check if there's a player in a certain area? its not the client itself. this relies on someone else NOT being there before getting executed

bronze yoke
#

you can loop through the player list and check if anyone's within that coordinate range

#

if it's going to be somewhere away from the player you should do it on the server because the client player list won't include players that client hasn't been in render range of at least once in that session

drifting ore
#

if there a built-in function that gives me the player list?

bronze yoke
#

getOnlinePlayers()

#

iirc it returns nil in singleplayer, so if your code runs in sp too you need handling for that

drifting ore
#

Thank you for your help

drifting ore
sour island
bronze yoke
#

functionA will technically exist on the client (assuming it's just in the server folder and you haven't used a client check to stop the file from running) but calling it just calls it on the client

drifting ore
#

oh damn, that will be a big headache to figure it out, but thank you.

drifting ore
#

i can DM you the area if you want to see it.

crystal terrace
drifting ore
crystal terrace
#

i can't draw a radius, but i tested in four directions N-S and W-E, roughly upto 90 tiles to be on safe side. I think it goes a bit further to 93 or 97. If you wanna test your self, start accessing tiles and increment a counter as long as the next square isnt nil. Print the counter var to console.

crystal terrace
#

to visualize it better, add broken glass to each square you access

drifting ore
#

the area im talking is about half of that.

vapid quest
bronze yoke
#

this would always return 2

vapid quest
#

ZombRand(0,2) +1 ?

bronze yoke
#

yeah, that would return 1 or 2

sour island
#

You only need 2 arguments if you want the number to be in between 2 things and the min isn't 0

covert summit
#
  1. Why can't I rotate the tiles I built? Even if you picked up the object, and then start to place it by holding the mouse button, the object can no longer be rotated, it will remain in the same position. Which parameter is responsible for this?

  2. And for some reason, the capacity of containers prescribed by me is ignored. Does this mean that the game engine prioritizes tile properties instead of mine?

Thx for your help

crystal terrace
limber onyx
#

Hi guys.
I'm Trying to make a set of sub mods that change the carry capacity and weight reduction of different bags, One sub mod would change the properties of backpacks, another sub mod would change the properties of handheld containers, but i noticed that both of those things are on the same script on the main game files.

I'm wondering if its possible to modify the same file multiple times through scrips so that the changes can be added on top or will one of them overwrite the other entirely?

limber onyx
#

Lol, i kept testing and my mods ain't doing a thing at all. I have no idea what's going on

#

I tested a single one of them and nothing is changing

#

OMFG I'm so stupid, I had the folder structure wrong, that was the issue the whole time

sand harbor
#

how would I activate a function as soon as I load into the world?

crystal terrace
sand harbor
#

every load on start

crystal terrace
#

i think try event OnCreatePlayer, i used it once and seemed to be triggered on each load.

#

actually OnGameStart might be a better fit

#

Im looking for some info on Timed Actions, how can i make one? Is there a mod i can refer to ? What if i wanted to override a Timed Action from base game?

bronze yoke
#

OnGameStart is better, OnCreatePlayer will fire for every splitscreen character

faint kestrel
#

So I backed up some mod files and changed some of the armor to include "Canhaveholes = false" but the same armor is still being damaged in testing. Any ideas?

vapid quest
#

if i want to set player's health i need to use getPlayer():getCharacter():setHealth(0.0)?

#

also if i want to add arguments to my command, what should i do?
command:
ISChat.allChatStreams[8] = {name = "addperk", command = "/addperk", tabID = 1};

sending command:

  sendClientCommand("cmd", "addperk", {});```
limber onyx
#

Guys, would you say Lua is better than Scripts at modifying item values such as weight, capacity, etc.?

bronze yoke
#

yeah

#

it's more compatible and future proof to do things that way

limber onyx
#

Gonna give it a try then. I've been banging my head against my desk for the past 2 days trying to make a mod that modifies Bag and Container values and it just wont work

#

I just need the Lua file alone for this or do i still need to create a script?

bronze yoke
#

you wouldn't need a script

#

the syntax is just

local item = ScriptManager.instance:getItem("Base.Apple")
if item then
    item:DoParam("Weight = 1.5")
end
limber onyx
#

I was trying to go through the ItemTweaker API but i don't know if that's too old already

TweakItem("Base.Bag_Schoolbag", "WeightReduction", "65") TweakItem("Base.Bag_Schoolbag", "Weight", "1.0") TweakItem("Base.Bag_Schoolbag", "Capacity", "15") TweakItem("Base.Bag_Schoolbag", "RunSpeedModifier", "1.0")

#

I think I'm gonna use your method instead

bronze yoke
#

itemtweaker basically just does this with different syntax

#

unfortunately when it does it prints a message to the log, for every single parameter for every single item, and prints are basically one of the laggiest things you can do - some servers were recording twenty second shorter load times when they edited to remove the print

#

i question whether it was even necessary to have an api for this in the first place, but especially with the performance impact i wouldn't recommend it

limber onyx
#

So performance wise I'd be better off using the code you showed me right?

bronze yoke
#

yeah

#

it's internally what itemtweaker does anyway, just without all the extra stuff that makes it lag

limber onyx
#

I know very little of this... so sorry for trying to be so reassuring.
An example would look something like this?

local item = ScriptManager.insance:getItem ("Base.Bag_Schoolbag") if item then item:DoParam("Weight = 1.0") item:DoParam("Weightreduction = 65") item:DoParam("Capacity = 15") end

bronze yoke
#

without the space after getItem and there's a typo in instance, but yeah

limber onyx
#

nice, thanks bro

#

Sorry again. Is there something I need to type at the begining of the Lua file like calling libraries or some stuff that usually comes before editing the indivdual items?

bronze yoke
#

no need, literally everything in vanilla zomboid is global

limber onyx
#

cool, thanks :)

vapid quest
# vapid quest also if i want to add arguments to my command, what should i do? command: `ISCha...

so i tried to do this:
ISChat.allChatStreams[9] = {name = "kill", command = "/kill", tabID = 1, arguments = {"plr"}};

sendClientCommand("cmd", "kill", {plr});
and now i have error in this lines:
killcmd(data)

getSpecificPlayer(plrnick):getCharacter():setHealth(0.0)
full code:

    print("addperk command called")
    local plrnick = data[1]
    local perk = data[2]
end

local function killcmd(data)
    print("kill command called")
    local plrnick = data[1]
    getSpecificPlayer(plrnick):getCharacter():setHealth(0.0)
end

function mycmds(module, command, data)
    if module == "cmd" and command == "addperk" then addperkcmd()
    elseif module == "cmd" and command == "kill" then killcmd(data)
    end
end

Events.OnClientCommand.Add(mycmds)```
mellow frigate
bronze yoke
#

in those cases they aren't even returned right

#

to my knowledge everything accessible is global

mellow frigate
#

yeah, it's a pain to tweak

limber onyx
#

How do you add comments in the lua file so it doesn't count as programming?

#

double dash?

bronze yoke
#

-- comment

#

if you need a block comment you can do

--[[comment
comment
comment]]
limber onyx
#

great, thanks

#

no double dash at the end?

bronze yoke
#

no, just ]] is enough to end the comment

weak sierra
#

now that i realize that was old im sure this was already gone over

#

:P

limber onyx
tepid dawn
#

Do you have to use client, server or shared lua to trigger an animation ?

#

I'm working on an animation that needs to be shown on the screens of all nearby players, where should I trigger that ?

keen silo
#

Hey everyone, does anybody know how to recompile java?

#

I'm trying to make a mod that allows to swap a player (or rather any characters) model at runtime

#

the problem is, It is not allowed by java

#

the issue was that the Reset(IsoGameCharacter) from ModelManager didn't take the values from HumanVisual, but from another function. I changed to try to tak the values from HumanVisual first, and if it fales from the other option

public void Reset(IsoGameCharacter gameCharacter) {
        if (gameCharacter.legsSprite != null && gameCharacter.legsSprite.modelSlot != null) {
            ModelSlot modelSlot = gameCharacter.legsSprite.modelSlot;
            this.resetModelInstance(modelSlot.model, modelSlot);
            for (int int1 = 0; int1 < modelSlot.sub.size(); ++int1) {
                ModelInstance modelInstance = (ModelInstance)modelSlot.sub.get(int1);
                if (modelInstance != gameCharacter.primaryHandModel && modelInstance != gameCharacter.secondaryHandModel && !modelSlot.attachedModels.contains(modelInstance)) {
                    this.resetModelInstanceRecurse(modelInstance, modelSlot);
                }
            }

            this.derefModelInstances(gameCharacter.getReadyModelData());
            gameCharacter.getReadyModelData().clear();
            this.dressInRandomOutfit(gameCharacter);
            Model model = gameCharacter.getHumanVisual().getModel(); //Modded By FedCap
            if (model == null)
            {
              model = this.getBodyModel(gameCharacter);
            }//Modded By FedCap
            modelSlot.model = this.newInstance(model, gameCharacter, gameCharacter.getAnimationPlayer());
            modelSlot.model.setOwner(modelSlot);
            modelSlot.model.m_modelScript = gameCharacter.getHumanVisual().getModelScript(); //Modded By FedCap
            if (modelSlot.model.m_modelScript == null)
            {
              modelSlot.model.m_modelScript = ScriptManager.instance.getModelScript(gameCharacter.isFemale() ? "FemaleBody" : "MaleBody");
            }//Modded By FedCap
            this.DoCharacterModelParts(gameCharacter, modelSlot);
        }
    }
#

Now, I just need to compile it and see if it works. does anybody know how to do that? @bronze yoke @sour island @weak sierra

weak sierra
#

you need to recompile the class it came from

#

only that class

#

but no, no idea really

#

i imgaine there's a compile button

#

someplace

fathom barn
#

do you guys know how can i make scenarios/challenges in pz?

#

for example the prison scenario, the cabin defence scenario.

keen silo
#

(it comes from zombie.core.skinnedmodel.ModelManager.java)

weak sierra
#

once compiled?

#

u'd copy it over the original in the game folder

#

i hope u didn't labor under the assumption that the game allows u to mod the java

#

like with a workshop mod

#

cuz it very dont

#

TIS man

#

they don't want us to have the power, hehe

#

any java mods on the workshop include the files someplace useless and have instructions to copy them manually

#

:/

#

and the server doesnt check them at all so ppl can cheat

#

kinda sucks

keen silo
#

excellent

#

ut

#

i do not know how to compile java 🙃

#

something about javac --class-path [path to root installation directory] -d [output directory] [path to source file], but have no idea really

tepid dawn
keen silo
#

I gather they have a checksum for the servers

#

so you would be kicked if it didn't match

#

(for lua, not javaclass)

tepid dawn
#

I mean, can't I hook a function to the event onPlayerJoin (dont know the name) and give the player in question an M16 if his name is Ultraviolet ?

#

how would the server check if its true or false if the code runs on serverside ?
I mean, it would be the server who's giving me the item.

keen silo
#

yes, but when you join, if you modified your lua, it wouldn't match the checksum with the server

tepid dawn
#

No I mean

keen silo
#

it will require you to get the mod or be kicked

tepid dawn
#

ohh i got it your misunderstood me

#

what I'm saying is

keen silo
#

if you modified your java.class then yeah,

tepid dawn
#

lets say that I'm a comissioned modder

keen silo
#

you would cheat

tepid dawn
#

and I'm making mods for a specific server

#

what's keeping me back from adding the aforementioned "cheat script" to the lua ?

weak sierra
#

unless they dont turn on the checksum thing

tepid dawn
#

oh i've explained it better in my last messages

weak sierra
#

it does a checksum of the file

#

server and client end stuff is all distributed to both

#

so it has to match or u dont get in

tepid dawn
#

im not saying if I modify luas on my computer, but what if I'm the modder

weak sierra
#

oh

#

nobody can stop u then

tepid dawn
#

aww

weak sierra
#

u have to trust a mod to install it kek

tepid dawn
#

guess ppl need to be awake

#

by the way does anybody know of a mod that makes you dodge attacks from behind ?

limber onyx
#

Mmmm nope, just a mod that removes stunlock, and also lower rear attack vulnerability in the vanilla sandox options but not dodge them

#

Guys. How do you make patches for items added by other mods? Do you need some special code or just add those items into the list on your lua file and place it after the required mod in the load order?

#

Example: Change the amount of bullets inside an ammo box from Firearms B41 and then change how many of those mod bullets can be stacked when using the Inventory TETRIS mod

#

'cause I think I know how to change them if they were vanilla items, but I'm not sure if you have to do something different if they are mod added items

mellow frigate
#

you can add the condition: is the mod loaded e.g. ```lua
local modInfoTK = getModInfoByID("TheyKnew")
if not modInfoTK or not isModActive(modInfoTK) then
return--handle : compat not required
end

limber onyx
#

cool, thanks!

limber onyx
mellow frigate
limber onyx
#

gotcha

keen silo
#

well, I keep getting compiler errors in java

#

and I haven't even changed the code I got from the decompiler ded

fast galleon
keen silo
#

I'm using Java SDK 17.0.13

fast galleon
#

that seems right, game uses azul 17.

limber onyx
#

Evening guys. How do you edit mod added recipes using lua commands?

limber onyx
#

Got these surgical mask boxes added by the SUSCEPTIBLE TRAIT mod. By default when you open a box, there's 100 of them. I want to nerf it down to 20

keen silo
#

im so close to getting it to work

#

but can't doittttt

#
PZArrayUtil.sort(this.m_lightsTemp, Lambda.comparator(movingObject, (var0,movingObjectx,lightSourceArrayx)->{
                                float iterator = lightSourceArrayx.DistTo(var0.x, var0.y);
                                float lightSource = lightSourceArrayx.DistTo(movingObjectx.x, movingObjectx.y);
                                if (iterator > lightSource) {
                                    return 1;
                                } else {
                                    return iterator < lightSource ? -1 : 0;
                                }
                            }));

THIS GODDAMNED LINE OF CODE BREAKS IT

#

C:\Users\Feder\IdeaProjects\FedCap\build\generated\sources\zomboid\zombie\core\skinnedmodel\ModelManager.java:1074: error: cannot find symbol
float var30 = var2x.DistTo(var0.x, var0.y);
^
symbol: variable x
location: variable var0 of type Object
C:\Users\Feder\IdeaProjects\FedCap\build\generated\sources\zomboid\zombie\core\skinnedmodel\ModelManager.java:1074: error: cannot find symbol
float var30 = var2x.DistTo(var0.x, var0.y);
^
symbol: variable y
location: variable var0 of type Object
C:\Users\Feder\IdeaProjects\FedCap\build\generated\sources\zomboid\zombie\core\skinnedmodel\ModelManager.java:1075: error: cannot find symbol
float var40 = var2x.DistTo(var1x.x, var1x.y);
^
symbol: variable x
location: variable var1x of type Object
C:\Users\Feder\IdeaProjects\FedCap\build\generated\sources\zomboid\zombie\core\skinnedmodel\ModelManager.java:1075: error: cannot find symbol
float var40 = var2x.DistTo(var1x.x, var1x.y);

It cannot find the symbols because it doesn't realize they are supposed to be IsoMovingObject

limber onyx
keen silo
#

three of this ` then java

#

`java
your code

limber onyx
#

thanks

#

I suppose it doesn't matter if my code is lua, does it?

keen silo
#

you can write lua

bronze yoke
#

```lua
your code
```

limber onyx
#

thanks

bronze yoke
#

it just changes the keyword highlighting

limber onyx
#

I know, but it makes it easier to read for others 👍

keen silo
#

OHHHHHHHH GOOOOOOOOODDDDDDDDDD

#

it compiled

#

IT COMPILED

#

Im going to sleep

limber onyx
#

Congrats!

keen silo
#

goodbye now

#

I'm afraid of what it may break

limber onyx
#

That's gonna be tomorrow's problem

#

rest well

keen silo
#

most fixes been minor things

#

but this last thing

#

may be bad

#

real bad

#

PZArrayUtil.sort(this.m_lightsTemp, Lambda.comparator( var1, (IsoMovingObject var0, IsoMovingObject var1x, IsoMovingObject var2x) -> {
float var30 = var2x.DistTo((int)var0.x, (int)var0.y);
float var40 = var2x.DistTo((int)var1x.x, (int)var1x.y);
if (var30 > var40) {
return 1;
} else {
return var30 < var40 ? -1 : 0;
}
}));

#

essentially

#

I forced all three objects to be IsoMovingObjects

#

problem is

#

I dont know what Type they'll be

#

I also tried with IsoGridSquare, but didn't work

limber onyx
#

Too advanced 4 me. I barely know how to change item stats in lua 😅

#

I'm struggling with editing recipes added by another mod. Can't even imagine the kind of challenges that come with working with something like this

tepid dawn
#

Does anybody know if combat animations are hardcoded ?

#

I mean, I can see building animations and everything else but I can't see attack anims or animation that plays when you get bitten in Lua

mellow frigate
#

we can override the whole combat and add whatever animation so you can override combat animations. that said existing ones are called from java.

mellow frigate
# tepid dawn ohh alright thank you
under IsoPlayer
                    WeaponType weaponType = WeaponType.getWeaponType((IsoGameCharacter)this);
                    if (!GameClient.bClient || this.isLocalPlayer()) {
                        this.setAttackType((String)PZArrayUtil.pickRandom(weaponType.possibleAttack));
                    }
tepid dawn
#

I think I figured some things out, thanks for the help.

fading horizon
#

mod statistics tracking website should be live in a few days

#

so mod creators can track their mods and totals

mellow frigate
fading horizon
#

dang i didn't even know this existed

#

very similar to what i made

#

I think my UI is a little better though

finite rover
#

Hello! Does anyone have a backup of Dislaik's animation guide?

mellow frigate
tepid dawn
#

A similar question, what should I do for my animation to trigger ? Apparently PlayAnim(string) only works for idle anims, so I made a custom TimedAction but when I try to call my anim with the proper "condition" in the xml file it just plays a generic "raise hands" animation.

tepid dawn
mellow frigate
tepid dawn
#

thank youu

tepid dawn
#

do animation files have to be in .x ?

#

I cannot think of anything other than that, anim file plays perfectly in blender but for some reason console says "anim cannot be found"

#

or its the annoying file configuration, i think it doesn't see the anim clips because there is no "Bob" folder

faint kestrel
#

So still trying to change the "Canhaveholes" value. How can I get the lua to add the code in-between the existing code. I saw advice to use table.insert but it didn't work.

tepid dawn
#

clothing:setCanHaveHoles(true) ?

faint kestrel
# tepid dawn what code are you trying to insert ?

Trying to set to false. I just checked the steamapps workshop folder and for some reason the mod there wasn't updated to the changes I had made. Testing it now. Will update once I'm positive whether it works or not.

errant bluff
faint kestrel
#

Should I paste the lua file to be read?

sour island
# errant bluff Is it possible for you to open the code to the public to make other types of car...

The mod is designed to accomodate add-on mods.

As an example this is how Uno is added:

--- For anyone looking to make a sub-mod:

---First require this file so that the cataloger module can be called on.
local applyItemDetails = require "gameNight - applyItemDetails"

--- Examples of defining a table
-- this example is overly complicated as it pieces together a table for the sake of typing up a large list
-- technically you just need a table of strings corresponding to textures/names for items

--- UNO
-- (19) Red, Blue, Green, Yellow – 0, 1 to 9 (2x)
-- (8) Skip, Reverse, Draw2 – 2 cards of each color
-- (8) Black – 4 Wild cards and 4 Wild Draw 4 cards
local unoCards = {}
unoCards.cards = {"Red 0","Green 0","Blue 0","Yellow 0","Wild","Wild","Wild","Wild","Wild Draw 4","Wild Draw 4","Wild Draw 4","Wild Draw 4"}
unoCards.suites = {"Red","Green","Blue","Yellow"}
unoCards.values = {"1","2","3","4","5","6","7","8","9","Skip","Reverse","Draw 2"}

for i=1, 2 do --Two sets of 1-9, 0s are single
    for _,s in pairs(unoCards.suites) do
        for _,v in pairs(unoCards.values) do
            table.insert(unoCards.cards, s.." "..v)
        end
    end
end
applyItemDetails.addDeck("UnoCards", unoCards.cards)
  • item script for 1 item, model, and textures
#

Most of the work would be on visuals

faint kestrel
limber onyx
#

Morning guys.
Can anyone tell me how to edit recipes added by other mods in Lua?

limber onyx
#

Or is it just easier to do it with scripts?

frank elbow
sour island
frank elbow
#

I could see it, words of French origin are wacky sometimes (no offense, French)

sour island
#

I assumed it was French too 🤔

frank elbow
#

It is, and it's actually a doublet with suite 😄

sour island
frank elbow
#

Dibs on "mod no work??"

sour island
#

Going to make a graphic on my workshop pages to redirect people off steam and onto github

#

Not my proudest use of a couple hours

limber onyx
#

So... I was trying to edit recipes added by a mod. But now they display as 2 independent recipes despite having used the Override:true, command

#

I'm stuck

#

Vanilla stuff calls in for Base.item instances
If I wanted to edit stuff added by mods, should I be typing ModID.item instead?

bronze yoke
#

what matters is the module in the script file

#

mods might not use a module name that matches their mod id, they might use multiple modules, and in most cases they just use base

sour island
#

I underestimated how many I'd get lol

faint kestrel
#

So all the code is present, how do I get the lua file to run upon starting the game. The lua file is written in notepad btw.

sour island
sour island
limber onyx
digital anchor
#

What's the best way to test if your mod will work in MP quickly? Can running local co-op work or do I need to rope someone into helping me?

hollow current
#

hi, so, im trying to use a client command in a mod, as follows:

function Commands.knockPlayerOut(playerName)
    local playersList = getOnlinePlayers();
    for i=1,playersList:size() do
        local playerItem = playersList:get(i-1)
        if playerItem:getUsername() == playerName then
            local playerIndex = playerItem:getPlayerNum()
            ISTimedActionQueue.clear(playerItem)
            --ISTimedActionQueue.add(Knockout_TimedAction:new(playerItem, playerIndex))
            break
        end
    end
end```

The command is sent using:

```lua
local function forceKnockout(button, args)
    local playerName = Knockout.selectedItem
    sendClientCommand('RealKnockouts', 'knockPlayerOut', {playerName})
end```

Unfortunately, this returns an error of
```lua
ERROR: General     , 1694371213145> 21,360,901> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: attempted index: clear of non-table: null at KahluaThread.tableget line:1689.```
I have multiple tests and made sure there are no problems with the parameter I am passing to the command, so not sure what's going on here
mellow frigate
#

TimedActions are client side.

hollow current
bronze yoke
#

client does matter

mellow frigate
bronze yoke
#

it's only client that does anything special, otherwise it's just load order

#

server runs on clients but client doesn't run on servers

hollow current
#

so -- It should work correctly if I move the timed action file to the server folder?

hollow current
bronze yoke
#

the timed action queue is a client object

mellow frigate
bronze yoke
#

you need to send the client a message to start the action

#

on the client only the local players' queues exist, on the server no queues exist at all

hollow current
#

aah

sonic needle
#

👀

sage eagle
#

yay

hollow current
#

so how does one exactly send a command from the server to the client to reset a queue/start a timed action?

bronze yoke
#

basically the same way you're sending a command to the server

#

btw, you can send the target's onlineid and get the player object from getPlayerByOnlineID

#

searching with username is slower and iirc usernames aren't even guaranteed unique on steam servers

#
local player = getPlayerByOnlineID(id)
sendServerCommand(player, command, module, args) -- if you want to support splitscreen args should include the online id, since the receiving client won't know which specific local player it's targeted for
hollow current
#

Alright, will give that a go. Appreciate the time and help!

hollow current
#

Not sure If I am implementing it correctly (haven't gotten to the PlayerID yet), but:

local Commands = {}

function Commands.knockPlayerOut(playerName)
    print("test")
    local playersList = getOnlinePlayers();
    for i=1,playersList:size() do
        local playerItem = playersList:get(i-1)
        if playerItem:getUsername() == playerName then
            local playerIndex = playerItem:getPlayerNum()
            ISTimedActionQueue.clear(playerItem)
            ISTimedActionQueue.add(Knockout_TimedAction:new(playerItem, playerIndex))
            break
        end
    end
end

local function OnServerCommand(module, command, player, args)
    if module == 'RealKnockouts' then
        Commands[command](args[1])
    end
end

Events.OnServerCommand.Add(OnServerCommand)```

This basically doesn't do anything except printing ping pong statement
drifting ore
#

how do you call InventoryItemFactory? i'm trying to add & remove items to player's inventory

bronze yoke
#

all of its methods are static so you can call them directly e.g. InventoryItemFactory.CreateItem("Base.Apple")

#

but that's not a necessary step in adding items to a player's inventory

#

if you're just going to add it to the inventory afterwards you can just call AddItem("Base.Apple") on that inventory object

drifting ore
#
function remove_arena_weapon()
    local player = getPlayer();
    local inventory = player:getInventory();
    local item = 'Base.HandAxe'
    for item in ipairs(inventory) do
        print("PlsMan")                    
        if item:getFullType() == 'Base.HandAxe' then
            itemUser:RemoveItem(item);
        end
    end
end

I'm trying to remove certain items (hand axe as placeholder) from player inventory. This doesn't do anything, Can anyone help?

sage eagle
#

@bronze yoke any idea why arendameth is having these ping pong printing issues

bronze yoke
#

OnServerCommand handlers only have three arguments

#

String module, String command, table args

hollow current
hollow current
drifting ore
#

What i'm trying to do is, Iterate over the player's inventory and remove any of the specific items i add to a table.

bronze yoke
#

RemoveItem doesn't seem to exist

hollow current
#

its np you get it by practise. Over one year here and still have barely any grip on the methods lol

bronze yoke
#

oh, weird, never seen this class

#

they're static so you would call it as ItemUser.RemoveItem(item), but not really sure what this does or if it's even exposed

drifting ore
#

i'll cross that bridge when i get there, i need to first figure out why it doesn't iterate over the player's inventory

#

time for a lot of head bashing, i heard it works wonders.

bronze yoke
#

oh, well that's because ipairs is used to iterate over lua tables

#

inventory is a java object

#

you'd want to get the item list from the inventory object and then iterate over that as an array

hollow current
bronze yoke
#

can i send the sending code?

hollow current
#

um what

bronze yoke
#

where are you sending the command

hollow current
#
local function forceKnockout(button, args)
    local player = Knockout.selectedItem
    sendServerCommand('RealKnockouts', 'knockPlayerOut', {player})
end```
bronze yoke
#

oh, are you just trying to send a server command from the client?

hollow current
#

what Im trying to achieve is, have a player remotely activate a timed action on another player

bronze yoke
#

you can't do that - the only way to send a command to another client is to send a command to the server which then sends a command to that client

hollow current
#

Figured that out, which is what I have been trying to achieve past 2 hours or so with no luck Pepe1

#

so basically, use SendClientCommand from player one

#

-- then what?

bronze yoke
#

sendClientCommand from the sending client, then a client command handler on the server sends a servercommand to the target

hollow current
#

Sounds simple enough. Thanks!

limber onyx
#

======
Still working on this issues guys. Maybe you know what I'm doing wrong. (Sorry to interrupt)
This screenshot here is from the orignal mods adding some recipies to add boxes containing surgical masks, but when you open them it gives you 50

#

I wanted to change the amount of masks to 20. I wrote another script using the override command

module Susceptible { imports { Base } recipe Open Box of Face Masks { destroy MaskBox_Blue, Result:Hat_SurgicalMask_Blue=20, Time:5.0, Category:Misc, Sound:PutItemInBag, OnCreate:OpenMaskBoxBlue Override:true, } recipe Put Face Masks in Box { Hat_SurgicalMask_Blue=20, EmptyMaskBox_Blue, Result:MaskBox_Blue, Time:5.0, Category:Misc, Sound:PutItemInBag, Override:true, }

#

However, when I test the mod out. the game gives me both the original recipe from the mod AND the one from my file. I thought it was supposed to replace it. I dont't get it

bronze yoke
#

i think stuff like override is handled when the game reads that line, so maybe try putting it at the start of the recipes instead of the end

limber onyx
#

I'll give it a try, thanks

#

but still inside the brackets or the line above "Recipe"?

bronze yoke
#

inside the brackets

drifting ore
#

Sup! does anyone know if there is any way to handle the network class zombie.network.DiscordBot?

crisp kettle
#

!rank

slow graniteBOT
#

🚫 whitetailwolves, that command is disabled in this channel.

drifting ore
#

So, i have this code to actually teleport a player with a command, but can't make it work, any advise?

local Commands = {};
Commands.Test = {};

local function onClientCommand_Test(module, command, player, args)
    if Commands[module] and Commands[module][command] then
        Commands[module][command](player, args);
    end
end

Events.OnClientCommand.Add(onClientCommand_Test)

Commands.Test.Teleport = function(player)
    player:setX(11746)
    player:setY(923)
    player:setZ(3834)
    
    player:setLx(player:getX())
    player:setLy(player:getY())
    player:setLz(player:getZ())
end

Using it like this:

sendClientCommand("Test", "Teleport", {player})
median mantle
#

Should use something like onlineID

#

sendClientCommand("Test", "Teleport", {player:getOnlineID()})

drifting ore
#

Sure, will try, thanks

limber onyx
#

The name of the script file doesn't have to be the same as the original, does it?

drifting ore
median mantle
#

If you want player to teleport, send Server Command to the player you want to teleport

#
    if Commands[module] and Commands[module][command] then
        sendServerCommand(player, module, command, {})
    end
end

Events.OnClientCommand.Add(onClientCommand_Test)```
#

Teleport the player on client side

median mantle
bronze yoke
tepid dawn
#

Hello its me again, does anybody know of a way to get the closest zombie to the player in an efficient way ?

#

I've tried "getVeryCloseEnemyList()" and also "getClosestZombieDist()" but none of them worked

true crown
#

I am about to give up, I made one recipe for a modded item which works flawlessly, I can also still change it a bit, but another recipe I added below never gets loaded despite being identical in structure. I even copied a working recipe from another mod and that one also somehow does not work when it is in mine

tepid dawn
#

I've also been bothered by it for a long time

true crown
tepid dawn
#

Sure, would like to help.

true crown
#

What I can say my second recipe that doesn't work is a replacement for crafting vinegar. I wanted to test it first so I took the same structure from my first already working recipe and just replaced the single input item to Stone and the result to Vinegar. Still, it won't show up :/

#

Anyway, night night yall

proven vortex
#

jaques_beaver now, why?

faint kestrel
#

So I was able to find a version of Lua for my computer and when I run the script it keeps trying to define to lua file itself but gets a nil value. How to I make the script execute upon game startup and not search for a value for the lua file.

sour island
#

To have stuff occur you mostly have to use game events which are defined by the devs - for game start there are a few depending on what you need.

#

Anyone make a container that has loot inside of it in the distro?

#

I'm using FirstAidKit as an example - and I don't seem to net any loot

#

Never messed with distros as they seem to be super flakey - and sure enough

bronze yoke
#

are you spawning it or testing natural spawns? i think spawned containers are always empty

sour island
#

natural

#

did some whacky stuff to replace the vanilla game items with my boxes

#

in the distro

#

but it doesnt seem to fill the containers

#

chance for items are 9999

#

the format is SuburbsDistributions.itemType right?

sage eagle
#

Backgammon?

sour island
#

I feel like I get the whole SuburbsDistributions vs other one mixed up

#

interesting that loot zed doesnt have an option for bags

keen silo
#

I need a Hero PLZ

fading horizon
keen silo
#

Please, I'm so close to making it work flawlessly. has anybody experienced this issue with any mod before?

#

does anybody know which lua and classes are part of the Info Window (specifically the place where it renders the player)?

sour island
#

Figured out the issue @bronze yoke

#

I was inserting tables with no keys

#

Seems like the 9999 chance works

bronze yoke
#

nice! it's just a roll against that number so in theory as long as it's high enough to compensate for loot settings any high number should be 100%

sour island
#

I prefer to slip into the vanilla distros when I can

#

Hate seeing the loot tables getting overwhelmed

bright hawk
late hound
fading horizon
#

❤️ ❤️

fading horizon
fading horizon
bright hawk
fading horizon
#

read description of the mod

#

it explains it all

#

his history

#

the stu lore

frank elbow
#

Still calling him a rat despite him canonically being a mouse ||(or a mouse-looking human, in the original work)||, shame

young orchid
#

is there a way to reload textures of your own mod ingame?

so when you changed them you dont need to restart the game everytime?

drifting ore
#

Hey guys! Did any of you tried sending messages to Discord through webhooks? Maybe using openUrl()?

fallow osprey
#

Hey modders, I need advice on making a moveable item. I see my custom tiles in the debug tile picker so my texture pack is added correctly, but how do I make an inventory item become placeable and use those tiles?

balmy terrace
#

Could anyone give any advice for adding a non-binary option to the character creation screen? How do the models work with gender? Do the male and female character models have unique meshes for every kind of clothes, and will I then need to make new models for every single clothing item?

If anyone complains about this idea than I will slap you with a fish

bronze yoke
#

i mean, what would a non-binary option actually do? the game never refers to you by pronouns as far as i'm aware, i'm pretty sure it's effectively just a body type selector

#

if you're suggesting a more androgynous body type... yes that is exactly the case, good luck

balmy terrace
#

well, it’s something to do

bronze yoke
#

you'd also need to java mod

balmy terrace
bronze yoke
#

the renderer picks the character model based on an 'is female' boolean, and lua can't change it at all

balmy terrace
#

well I know Java thank god

#

setting up the workspace might be harder but eh

tulip cipher
fallow osprey
tepid dawn
tepid dawn
#

Does anybody know how to convert an object's position local to another object ?

#

I want to know if a zombie is in front of or behind the player

#

i don't know the mathematical formula for it neither lol, maybe i should search for a mathematical solution

frank elbow
#

For relative position I believe all you'd need is subtraction, but for determining “in front of or behind” you'll also have to consider the direction the player is facing

tepid dawn
#

However, I don't know if there is a similar function in Zomboid, so my best bet is to replicate it in a function by myself but i don't know the name of the concept.

elfin olive
#

Can anyone help a noob out? You can DM me if you don't wana blow chat up.

fast galleon
fallow osprey
#

seems like it

frigid mantle
#

Ola i need help

#

can somebody make a mod where i can butcher and cook zomboids so i can provide food for my friends

tepid dawn
#

I remember someone telling me to inserting functions while in-game

#

through lua console

#

how was that ? I think it was something like Events.Event.Add(func) but just inside the lua console window ?

tulip cipher
#

anyone know what is called when entering this screen?

tulip cipher
#

or can i at least call something similar

faint kestrel
#

Could someone explain this to me?:

lua -e "io.stdout:setvbuf 'no'" "Armor_Durability.lua"

sour island
sour island
#

You can tweak the vanilla Lua files to get more familiar with Lua

#

If you want to package your changes as a mod you need to format the files as in the mod template

#

Are you working in an IDE, notepad++, vscode?

faint kestrel
sour island
#

Debug menu being the F11 error window?

faint kestrel
faint kestrel
sour island
#

Using Lua?

faint kestrel
sour island
#

I don't know what that looks like, but it sounds like you are better off using notepad++ and a Lua extension 😅

#

I personally use IntelliJ for modding - but I understand if that's overkill/daunting

faint kestrel
#

I had originally made the Lua file in notepad. But none if the scripts I had wanted it to change were being edited.

tulip cipher
#

(VSC on top!)

sour island
#

My setup is IntelliJ + EmmyLua plugin + CAPSID (outdated annotater for PZ)

tulip cipher
sour island
fast galleon
#

@faint kestrel
Most things you write for lua will not work in PZ, same applies in reverse.

faint kestrel
sour island
#

You made a Lua file in notepad and had it where? In the install directory/media/Lua/subDirectory?

faint kestrel
tardy wren
#

Ah, so you're patching script items with Lua

faint kestrel
tardy wren
#

Fun times. Watch out for Item.Type. it's the item's subclass. Use Item.FullName

drifting ore
#

hi, is ProceduralDistributions the method that adds loot to zombie corpses?

faint kestrel
#

But when I check the file the script isn't changed

tardy wren
#

You can modify the items after they're loaded from the file as scripting.Item objects

faint kestrel
#

So if I want the lua file to modify a txt script it needs to occur once they appear in-game?

tardy wren
#

You cannot modify the txt file. You can however, modify the data loaded from the file after it's loaded

tardy wren
#

ScriptManager lets you get Scripting Objects

faint kestrel
#

I had ScriptManager entered in the lua file but it kept trying to attribute a value to it and spat out nil

tardy wren
#

ScriptManager.instance is the reference to the... instance

#

ScriptManager.instance:getItem(String name) is how you can get your item

faint kestrel
#

Thank you. I kept looking for a good tutorial but none actually just said how to do this

tardy wren
#

I recommend loading the lua file in media/lua/shared

faint kestrel
#

That is where I put it in the mod folder

tardy wren
#

yes

faint kestrel
tardy wren
#

Okay

#

This is your home now

faint kestrel
tardy wren
#

Question: if I want to add custom tiles to the game, I will have to pack them into a .pack file?

atomic crow
#

Welp, I've had my first taste of modding and now I will subject myself to more: I am going to attempt to make a tweak for Brita's.

#

More specifically I'm making a tweak for Gunfighter, not Brita's itself.

#

Time to figure out how to make a mod require another mod...

neon bronze
#

There is a require for mod.info you’d need the mod id from britas

drifting ore
#

is there a pinned post or something that shows how to add loot to zombies?

sour island
#

Also I wasn't aware what you're trying to do - that's somewhat advanced for just starting out.

#

You can safely overwrite scripts by using the same ID type and writing overwrite=true -- this is done as a .txt

#

But you'd need to include the entire script that way -- otherwise doParam and script manager are the way to go about changing 1 thing

tardy wren
#

And complexity doesn't equal scope

sour island
#

Yeah but there seems to be issues with approach

#

Might also be a good idea to open up ItenTweaker as an example

#

You can study how mods are structured

#
  • it does what you want - although I don't know if it was ever updated to be in shared as opposed to only client
faint kestrel
sour island
#

Do param takes a string

#

I would use getScriptManager() instead of using the instance like that

#

ItemName shouldn't have quotes if that indicates you're using them

#

Is that the exact error?

#

What do you mean by run?

faint kestrel
sour island
#

That error isn't how PZ would declare that issue - and by saying run - I assume you're compiling the Lua file in your editor? That won't do anything to the game, and won't impact a session already running.

sour island
#

You have to reload the Lua in game, you can do this in debug mode

#

Or simply restart the game

faint kestrel
#

Should I remove quotations from just the Item ID or the Parameters too?

tulip cipher
#

getScriptManager():getItem(itemName) is there a way to get every item?

faint kestrel
sour island
tulip cipher
sour island
tulip cipher
sour island
#

It's an exposed java ArrayList - so any exposed methods work

#

You can iterate over it using size and get

#

Contains works where applicable

tulip cipher
#

ahh okie, so a simple i, v in pairs will work to itterate over it to get all values

faint kestrel
#

Should the lua file work on game startup itself or do I need a line of code so it will run?

#

I've tried Event.OnGameBoot and os.execute

cobalt fiber
#

Using OnGameBoot you can define a function to run

#

Remember that the file is executed, but every function you declare will only be declared. If you want the content of a function to run, you need to call it somewhere in your file

cobalt fiber
#

If you want to get the value it is in now, you use myList():get(i) and handle it as you want

atomic crow
#

Hmm, seems the item tweaker API should be able to handle what I'm attempting to do, assuming it can adjust modded items and modded values. Still gotta make it require the base mod though.

#

Ah now here's an issue, I've no clue how to format the file organisation, I know item tweaker API mods need to be lua but I've no clue whether to just put them in the mod's lua folder raw or in another folder...

#

I guess we'll just raw dog it and see what happens

faint kestrel
bronze yoke
#

just put the file in lua/client/, lua/shared/ or lua/server/

#

files execute upon lua loading/reloading, you don't need to do anything special

faint kestrel
#

But he did just say functions need to be defined and called

bronze yoke
#

functions that you define need to be called to run

#

if your code isn't in a function it runs when the file executes

faint kestrel
#

I have the following code written repeatedly with different Item names

local scriptItem = ScriptManager.instance:getItem(Base.Armor_Dozer)
if scriptItem then
scriptItem:doParam(canHaveHoles = false)
end

I looked for many tutorials online if this is written wrong

tardy wren
#

pass a string

#

Same with the contents of doParam

faint kestrel
tardy wren
#

They were wrong

bronze yoke
#

DoParam should be capitalised too

tardy wren
#

stuff outside of quotes are markings. Inside are string literals

faint kestrel
tardy wren
#

Yes, the entire thing in quotes

faint kestrel
#

Okay, all string names have quotes and all doParam(s) were changed to DoParam

#

Should the fie start with Event.OnGameBoot.Add(ScriptManager)?

cobalt fiber
#

I just don't know for sure if the Item Scripts are loaded before Lua is...

bronze yoke
#

they are

cobalt fiber
#

So yeah, just writing all those lines on the file should work

faint kestrel
#

Reloading lua...

#

Starting new world, clothing degradation: normal

#

Loading...

#

Loaded in, going to stress test armor

#

Mod didn't appear in Steam folder, retrying

#

Mod is now in folder

#

Resetting lua again to be sure

bronze yoke
#

steam folder?

faint kestrel
#

Yes. Steam>steamapps>workshop, where it puts all mods

#

Game loading

bronze yoke
#

that's only for mods installed from the workshop

#

local mod development isn't done from there

faint kestrel
bronze yoke
#

i would not recommend doing this or you'll have to update all versions every time you change something

faint kestrel
#

I'm aware, every update I've done it

#

Game started...
Going to test armor

drifting ore
#

Hey, does anyone know if there is any way to take screenshots?

faint kestrel
#

Mod didn't work armor got a hole torn..
unhappy

atomic crow
drifting ore
#

Not tricky, im doing an anti cheat, it's working great. But would like to add some way to look at the user game screen if he tries to apply god mode (example)

#

@atomic crow

#

I've seen takeScreenshot method, and TakeScreenshot, but couldn't make them work correctly. If anyone tried before, would be helpful

atomic crow
#

I’m pretty sure both of those save locally rather than to a server side source.

drifting ore
#

I can show the anti cheat code if necessary, very simple but effective.

drifting ore
#

Couldn't I take the screenshot and then upload it?

atomic crow
#

If you’re the one on the receiving end of the anti cheat sure, but if someone’s actually suspected of cheating it wouldn’t be hard to hide any wrongdoing

drifting ore
#

Maybe uploading it through a discord webhook?

bronze yoke
#

we don't really have access to stuff like that

drifting ore
#

I've been experimenting with JNI modding, external is easier. But I wasn't people to use some kind of launcher to enter the server, would like to make it as a mod.

#

Sadly, internal (mod) makes it harder since you only have what the games wants you to use

bronze yoke
#

as a lua mod?

drifting ore
#

Yes

bronze yoke
#

a lua anticheat seems a little pointless, any cheater can just read the source and disable your anti-cheat pretty easily

drifting ore
#

Yeah, with JNI ive done that before

#

But, that's not my point at all

#

Even if it can be hooked and disabled

#

Would like to add an extra layer

bronze yoke
#

i don't really believe it's possible, if the screenshot ends up in a folder lua can access (which feels unlikely to me) you can read the image file and send the entire raw data as a client command but i can't imagine the network performance is acceptable on that

atomic crow
#

Hmm, uh, are there any repercussions to an item having negative encumbrance?

#

Because I have accidentally achieved this somehow

bronze yoke
drifting ore
#

And, have you tried sending messages to Discord through the server integration? (I think this is impossible but I'm unsure)

atomic crow
bronze yoke
tardy wren
#

As far as my knowledge goes, it reads the /all chat and sends it to a discord channel

drifting ore
drifting ore
#

Imagine sending your server logs through it.

tardy wren
#

Yeah...

#

We wanted to make a bot that sends the active player list and current weather and time to discord

#

Not possible without writing to a file

drifting ore
tardy wren
#

Yeah

#

But you have to write a mod that saves the info you want to a file first

#

Can't even send it over a loopback ethernet connection

drifting ore
#

Couldn't you mod the host java client and then expose the information? I'm unsure if that could work, but in local you can mod your client and enter any server

bronze yoke
#

yeah there's no java validity checks or anything

tardy wren
#

I don't know any Java, so I can't make a java mod. It is possible to write a Lua mod that writes to a file

#

And then an external program can handle the rest

#

Right now I'm trying to figure out how to make a barrel be able to be filled with liquid

drifting ore
#

Yeah but if you wasn't to add mods to the server, that's not an option

tardy wren
#

Without mods, my players can have maxed out panic reduction Day 1 since it's bugged

#

And can't patch holes in their damn backs

sour island
#

Dumping the info to a text file and having a discord bot pick it up isn't that crazy of an approach

#

You'd need the bot and server to be hosted on the same machine or able to access the file though

drifting ore
#

But he does not want to use mods

tardy wren
#

It's not crazy. what is crazy is that it's the only approach you can do

sour island
tiny karma
#

Im working on a render pipeline remake mod (Java) that’ll allow for real-time per-pixel lighting, improved graphical fidelity (SSAO, SSR, SSS) and dynamic shadows

sour island
#

Actually that's a lie - there's two ways to do that

tiny karma
#

is there any sort of HTTP interface in PZ Lua?

tardy wren
#

Nope

tiny karma
#

yikes you’re out of luck for lua then

sour island
#

Lua isn't really the place to make render engine changes tbh

faint kestrel
#

Not sure why the lua file didn't work. Wondering if the game overwrites the changes made to the armor. Or the changes just aren't being made

tiny karma
tardy wren
#

Because editing the scripts files, changes won't apply to existing items

faint kestrel
faint kestrel
tardy wren
#

And you start the new game each time?

faint kestrel
sour island
drifting ore
sour island
#

Client manager has all the data

tardy wren
sour island
#

Climate*

tardy wren
sour island
#

Peeling info out of a save for weather 🤔

faint kestrel
drifting ore
tardy wren
# sour island Custom how?

You know how generators and composters and campfires have custom behaviors attached to them? They're done internally via Java. You can do stuff via Lua, but it's uncharted territory for me

sour island
tardy wren
#

I want to have a tile that the player interacts with to do something not doable in vanilla

bronze yoke
#

they use lua global objects

sour island
#

I mean, my stores mod does stuff

bronze yoke
#

well generators don't, there's stubs for them so either they used to or were planned to

tardy wren
#

Is... Is that necessary? I saw FuelAPI doesn't use the global objects

sour island
#

IsoObjects can transmit modData

#

I think isogridsquare can too

tardy wren
#

I know, I know

#

I know there's enough stuff

#

I just... Need more examples to make my own

bronze yoke
#

it depends

sour island
#

That's all there would be to it, can you give an example?

tardy wren
#

assume those are used so that the tiles process while no players are arouind?

bronze yoke
#

fuelapi doesn't use global objects because it really doesn't need to, it just needs to keep track of a number

sour island
#

So it updates when interacting - unless there's a visual component over time -- then you'd have to actually check it more often

tiny karma
bronze yoke
#

when possible yeah

tardy wren
sour island
#

You can generate context menus on the fly

tardy wren
#

Yes, I have made a context menu

bronze yoke
#

rain barrels are fully lua afaik, the purpose of using a global object there is because they need to fill while it's raining, not just based on time

tardy wren
#

So I should... Analyze Rain barrel code harder?

sour island
#

The stuff in java is holdovers afaik

bronze yoke
#

not quite sure if traps and campfires make full usage of it actually, not sure what they do that can't just be done with time since last loaded

tardy wren
#

No, Composter is still mostly Java

#

Inconvenient since I need to make my onw

sour island
#

I mean, if they had made them now it would probably all be lua

tardy wren
#

Yeah, and sadly a lot of the mechanics date back to sprite-based game

tiny karma
#

many items are built off of templates in Java

tardy wren
sour island
#

IsoObjects are really open ended and exposed - you can do virtually anything you want

tiny karma
tardy wren
#

No, it's an engine bug

#

I want it fixed

sour island
#

What bug?

tardy wren
#

Mind if we do DMs?

faint kestrel
#

Does DoParam: work if the value isn't defined in the item script?

tiny karma
tardy wren
#

I just want to undo that change to make VOIP work again... But I can't get a file to compile

bronze yoke
#

i'm kind of shocked they left it in that state

sour island
tardy wren
#

They did...

bronze yoke
#

i know they had to pick a time to just focus on the future, but that seems like a crazy significant issue to me

sour island
#

VOIP is broken?

tardy wren
#

Yes

sour island
#

Since?

bronze yoke
#

last year

tardy wren
#

Last it worked was 41.78.7

bronze yoke
#

you can't hear players on radio who haven't been within your cell at least once that session

sour island
#

Hmm, I could have sworn I've seen streams with VOIP on ... but idk

#

Ooh the radio thing

bronze yoke
#

because of the security improvements

tardy wren
#

Yes

#

Admins can hear everyone as usual, but players cannot

sour island
#

Ah, that would explain it

tardy wren
#

Because... I think it's a client side change

#

Clients simply clear their list of players occasionally now

sour island
#

Simple solution, make everyone an admin while mic activity is detected 🤓

tiny karma
faint kestrel
#

So if DoParam: doesn't work without the variable already be present in the script, how can I add that from a lua file?

tardy wren
#

Unless something went wrong with decompilation, I have ~40 files in differences

tiny karma
tardy wren
tardy wren
bronze yoke
#

i'd be somewhat surprised if it were an exclusively client side change, changing the client isn't really a good way to enforce security, especially when there's no client validity checks

tiny karma
#

^

tardy wren
#

Again... about 40 files difference

tiny karma
#

it’s likely more complex than you think

bronze yoke
tiny karma
#

also it’s wayyy more than 40 files

tardy wren
#

But the server side change we found ddin't do it

faint kestrel
tardy wren
#

Well... Again, I tried decompiling both versions and comparing them directly

bronze yoke
#

could be something erroring, could be the file isn't loading, idk

#

check the log for errors, throw a print into your file to make sure it's actually being executed

tardy wren
#

sophie, mind if we take this to DMs? I don't want to share links to code

tiny karma
#

Eh I will later, sorry I got work to do

tardy wren
#

Okay... I just don't want to lose you

faint kestrel
cobalt fiber
#

You don't need Lua if you just want to change some items

bronze yoke
#

all i'll say is if it really does turn out to be a client-only change, reverting it will only re-introduce the awful hacking exploits that justified breaking it in the first place

faint kestrel
cobalt fiber
#

Well, if you use Lua, you are doing the exact same thing (just in a different path)

#

The ending is the same, you are editing someone else's work

faint kestrel
cobalt fiber
#

You don't need to take the whole file, just the item you want to change

#

The .txt you will make don't need to be the same as the exact same as the original

bronze yoke
#

doing it through lua is preferable as it doesn't introduce compatibility issues on nearly the same scale

cobalt fiber
#

Inside the scripts, there are lots of entries for each item, you just need to copy the entries of the items you want to change

cobalt fiber
#

But, if he's getting problems with it, maybe will be easier with scripts

#

I personally would just use ItemTweakerAPI

bronze yoke
faint kestrel
bronze yoke
#

it's the only error because it stops running when it reaches an error

faint kestrel
#

...

bronze yoke
#

ScriptManager is nil because your program is for writing standalone lua programs and scriptmanager is from pz

#

running it in your program will not accurately test it as a mod

faint kestrel
#

I've tested it each time I've made a change to the file

cobalt fiber
#

You didn't got any errors when loading the Lua?

#

You can check it better by putting a print(something) in your file, if it works, that will get printed to the console.txt file

#

You can put it maybe on the end of the file, if it prints, means that all your lines got executed without errors

#

I always put a tag to find easier with Ctrl+F, something like 'MODTEST: '

faint kestrel
cobalt fiber
#

Yeah, if the print works, after reloading Lua you can check if it appears in the console.txt

faint kestrel
#

What file path is console.txt under?

cobalt fiber
#

Users\YourUsername\Zomboid

#

You said that you was uploading to the workshop every change.
If you want, there a mods folder under \Zomboid for local mods, you can put your mod there to test without needing upload

#

But you'll need to unsub from the workshop

faint kestrel
#

Cannot find "Data_Value_Changed"

cobalt fiber
#

What is that?

faint kestrel
#

The tag I chose

muted garnet
#

Is it possible to somehow tie animation time to skill level, trait or something like that? For example, so that the animation of a character getting up from the ground will only speed up if he has a certain trait or a certain level of fitness skill

cobalt fiber
#

If the variable don't exist you get that error

faint kestrel
#

It was inside quotes

cobalt fiber
#

Well, if the print is returning a error, at least it is running

#

Means that every line above it got executed correctly

faint kestrel
#

No error, the filename didn't appear

cobalt fiber
#

Filename?

faint kestrel
#

The lua

cobalt fiber
#

The console.txt doesn't print a filename

#

It prints literally what you put inside it's bracket

faint kestrel
#

It shows all other filepaths

cobalt fiber
#

Like print("I like apples") will print a line in the console.txt with the text "I like apples"

#

console.txt is the whole log of Project Zomboid, it gets reset everytime the game opens

faint kestrel
#

changed it to print("APPLES")

sour island
faint kestrel
#

In the Steam workshop folder, and the Zomboid Workshop folder

sour island
#

In an appropriate file folder structure?

faint kestrel
#

Yes, same file structures as other mods installed

sour island
#

Is your mod showing up in the mod menu?

sour island
#

Can you take a screenshot of your mod's folder directory with the file path at the top visible?

#

you can blur or write over your username if you wouldnt want that shared

#

Also, just to clarify - you dont need to compile lua if that's what you're trying to do in that program. For the most part lua is plaint text.

#

I am getting the impression you have prior experience programming?

faint kestrel
#

file path is
ThisPC > C:\ > Users > username > Zomboid > Workshop > Armor_Durability_Patch > Contents > mods > lua > Armor_Durability - original.lua

sour island
#

you need a sub directory under lua

#

client or server or shared

#

oh yeah that too 😅

#

the file structure for workshop is partly the steam conent package - everything in the mods/ folder is the actual modules the game can read

faint kestrel
#

So ...mods>shared>lua>shared>Armor_Durability.lua?

sour island
#

you need a folder under mods/ with a mod.info

#

You should check the modTemplate

faint kestrel
#

I actually found out the game doesn't like non-folders in the mod folder

sour island
#

Not sure what you experienced

#

I made a copy of the modTemplate folder to explain that the workshop package can house multiple modules (sub-mods / optional mods in some cases)

#

There's a rather large learning curve so some of the terms because multiple things use the same term

#

Doesn't help there's two ModTemplate folders

faint kestrel
#

I have the files there, Contents, mod.info, preview.png, and workshop.txt

sour island
#

Yes but everything after that is wrong

faint kestrel
#

What should be in contents?

sour island
#

a folder named mods

faint kestrel
#

Yes, have that

sour island
#

inside that folder you need another folder that is your actual mod

faint kestrel
#

I should rename the folder in mods to ModTemplate?

sour island
#

your lua files need to be inside of one of the 3 sub directories in the lua folder, in the media folder, of one of your mods

#

The images above showcase the folder structure - I renamed the workshoppackage folder for the sake of readability

#

It may seem complicated but the structure is to allow for multiple mods under the same workshop package

#

Are you familiar with programming prior to this?

#

Idk if that question was read/answered

faint kestrel
#

Okay, I changed the structure, it is now

PC > C:\ > users > username > Zomboid > Workshop > Armor_Durability_Patch > Contents > mods > ModTemplate > media > lua > shared > Armor_Durability.lua

I did some html coding but that was a long time ago. Just got into lua

sour island
#

You should see your mod appear in the menu

faint kestrel
sour island
#

I can't imagine that being the case given the folders were not in the right place

faint kestrel
#

No clue

sour island
#

if you have the original modTemplate still present they may overwrite

faint kestrel
#

It's place or what's written?

sour island
#

or well conflict

sour island
faint kestrel
#

The mod.info is the same as it was before

sour island
#

So you're expecting to see your mod as modtemplate?

faint kestrel
#

No the ID is still ArmorUpgrade in the mod.info

sour island
#

Ah ok

#

And when you try to test it - you boot up the game and then?

#

check the logs?

faint kestrel
#

Yep

sour island
#

Is it enabled?

faint kestrel
#

The logs?

sour island
#

the mod

faint kestrel
#

Game is still booting

sour island
#

Yes, but have you been going into the mod menu to activate the mod?

faint kestrel
#

Yes

sour island
#

And you see the lua reload after?

faint kestrel
#

Yes

sour island
#

But your print of apples doesnt appear?

faint kestrel
#

That was a recent change, but no

sour island
#

If the file isnt large can you paste it here?

#

discord can format code if you use
```lua
code

faint kestrel
#

Sure

#

Says it couldn't be delivered

muted garnet
#

Is it possible to somehow tie animation time to skill level, trait or something like that? For example, so that the animation of a character getting up from the ground will only speed up if he has a certain trait or a certain level of fitness skill

sour island
faint kestrel
#

Console.txt says "attempted index: getItem of non-table: null"

muted garnet
sour island
#

There's a method for IsoGameCharacter called SetVariable() that sets vriables for xmls to read and interact with

#

You can see this being done with some vanilla files

#

I've only sparingly used it to make unique seating animations in cars work, to make sprinting zombies incapable of tripping, and disabling trees from damaging you

#

If combat helps swing speed you could check the attack animations

#

the vanilla file might already do what you'd like

sour island
cobalt fiber
#

If this is the current code, you should do getScriptManager()

sour island
#

Also, if you're just leaving it in the lua - if it runs on load before the scriptmanager is loaded in - there won't be an instance of it ready

#

You have to hook your functions on exposed events

faint kestrel
faint kestrel
#

So maybe .OnGameStart:getScriptManager()

sour island
#
local function MYFUNC()
    ---code
end

Events.OnGameBoot.Add(MYFUNC)
#

Are you familiar with what functions are?

#

If you just have calls made in the lua file outside of functions the game will attempt to make those calls when the lua is loaded

cobalt fiber
# faint kestrel Where would I add that?

You can make a local variable like local ScriptManager = getScriptManager() on the start of your code
Then you can replace every ScriptManager.instance to ScriptManager

#

But as @sour island said, maybe the script manager will not have a instance yet

#

If that's the case, you will need functions and Events also as he said

faint kestrel
#

I added lua_load as the function

cobalt fiber
#

You can use then Events.OnGameBoot.Add(lua_load)

#

On the end of the file

bronze yoke
#

all scripts are read before lua

sour island
#

Then he probably has a typo

weary knoll
sour island
#

😮

#

drawn texture?

weary knoll
#

manipulating the object

#

but I think it could be done other ways too

sour island
#

Just curious

weary knoll
#

no problem 😄

faint kestrel
#

new error

sour island
#

On line 4

#
Armor_Durability - original.lua:4: '<name>' expected near `:`
#

file name : line : cause

#

you probably have a : where it's not supposed to be

#

maybe a space before it

faint kestrel
#

Should the code be ScriptManager.getItem?

sour island
#

is ScriptManager a variable you're defining?

#

otherwise it should be getScriptManager() as the object

#

exposed methods are called using :

bronze yoke
#

ScriptManager.instance is acceptable too

sour island
#

getScriptManager():getItem(TYPE)

sour island
faint kestrel
#

Current Code

#
local scriptItem = ScriptManager.getItem("Base.Armor_Dozer")
    if scriptItem then
        scriptItem:DoParam("canHaveHoles = false")
sour island
#

you have to call the getter for script manager or use the class.instance

faint kestrel
#

The File begins with

#
local ScriptManager = getScriptManager()
sour island
#

ok, then it should still be :getItem()

#

What does the function look like that this code is in?

faint kestrel
#

lua local function lua_load()

sour island
#

the lua shouldn't be there

#

probably what the error is from

faint kestrel
#

I don't know why I wrote lua, it's not in the code

sour island
#

can you paste the entire function?

faint kestrel
#

local function lua_load()
local ScriptManager = getScriptManager()print("APPLES")
end

Events.OnGameBoot.Add(lua_load)

#

there's suposed to be a linebreak there, between () and print

sour island
#

so where is this:

    if scriptItem then
        scriptItem:DoParam("canHaveHoles = false")

?

faint kestrel
#

That is after local ScriptManager = getScriptManager()

sour island
#

Ok, what is line 4

#

also :getItem

faint kestrel
#

Line 4 was local scriptItem = ScriptManager.getItem("Base.Armor_Dozer"), it looks like ".:" was left in the code after I removed "Instance" from each line. So each line should now have a colon instead of a period between ScriptManager and getItem?

elder cradle
#

Hey guys! I'm new here.
I've been diving into PZ modding a bit deeper lately, and I was wondering if there is more info somewhere about ModData, or maybe mods I could look at to see how it's used.
I've been able to use it successfully for my needs with items, but I also need to store some data on the player (or globally somewhere that persists when closing the game). For some reason modData that I add on the player does not seem to persist.

sour island
#

If the data isn't being saved to the player you're probably using a direct reference

bronze yoke
#

you can get non-object mod data with ModData.getOrCreate("unique string key") which behaves basically the same but isn't attached to a specific object

faint kestrel
#

Just checked and the console.txt looks promising

#

no errors following the lua file
found tag:APPLES in the txt file

elder cradle
#

Ok that one uses Global ModData I guess.

sour island
#

Same rules apply though - you can't save direct references to objects

elder cradle
#

This what I've been using to test persistence on the player:

`function OnLoadTest()
if getSpecificPlayer(0):getModData()["toto"] ~= nil then
print("OnLoadTest = ", getSpecificPlayer(0):getModData()["toto"] )
else
print("OnLoadTest = toto does not exist")
end
end

function OnSaveTest()
getSpecificPlayer(0):getModData()["toto"] = "TOTO"
end

Events.EveryOneMinute.Add(OnLoadTest)
Events.OnSave.Add(OnSaveTest)`

sour island
#

that should be persistent

elder cradle
#

I tried different variations of that and it never retrieves the data.

sour island
#

Not sure about the onsave event

bronze yoke
#

i would guess that onsave fires either after character destruction or after moddata is saved

#

unfortunately my documentation on it was very non-specific 😅

sour island
#

Once you define the entry it is waiting to be saved

#

Try using OnPlayerMove

elder cradle
#

I also tried storing with Events.OnPlayerUpdate but same results.

sour island
#

So you just see "OnLoadTest = toto does not exist" ?

elder cradle
#

Ok thanks, at least now I know that it's supposed to persist on the player. 😄

#

Yeah exactly

sour island
#

Odd, must be something else

#

Is this code in client?

elder cradle
#

For context. I'm making a small mod that adds a small batteries charger tile with a container. And when it's on an electrified tile, it charges the batteries inside.
So I need to persist a list of all chargers that are currently placed in the world.
Yes it's in the client folder.

bronze yoke
#

yeah, onsave is after characters save, so it shouldn't actually work on that event - not sure why it doesn't work on update though

elder cradle
#

Ok, I'll try again with update.

#

Oh by the way, there's no way to add a custom update function on a tile object or a container by any chance?

#

Currently my planned approach is to store a list of all chargers and on Events.EveryOneMinute or every 10 minutes update the charging of all batteries in those chargers.

sour island
#

There's a few issues with that approach

#

you don't even need a global list

elder cradle
#

I'm all ears! 😄

bronze yoke
#

if these objects don't need to react to things in real time, you can simulate time passed when the player reaches them - if they do, you have to use global objects, which are one of the most annoying systems, there's no documentation and almost nobody has any experience using them

sour island
#

also as mentioned with a prior concept - its better to update the object when it's interacted with - and store a time last seen to calucate the differences

#

however with power things can be a bit tricky

elder cradle
#

That's what I did initially but it was problematic to manage electricity outages. Like knowing how long the generator was off to substract that time period.

bronze yoke
#

well, even vanilla doesn't account for this

elder cradle
#

Lol

#

Maybe I'm nitpicking too much.

sour island
#

shutoff day and time is stored I think

#

well - it's predetermined when the world is generated I think

#

oh - you mean a genie - yeah nvm,

elder cradle
#

I already use that in the condition to know if there is elctricty on a tile.

#

Yeah a gene

sour island
#

You'd have to track alot for that to work

#

having it simulated in realtime wouldn't be any easier tbh

#

stuff gets unloaded if you're far away

elder cradle
#

Ok, I can bring down my expectations a bit. I felt like I was close to a solution, but maybe it's overkill and a bit too taxing on perfs.

#

Do items persist their modData?
item:getModData().BatLastTime = curTime item:getModData().BatLastCharge = item:getUsedDelta()

bronze yoke
#

yep

sour island
#

It's doable - just, if you leave the cell the tracking will have to be simulated anyway

bronze yoke
#

all moddata is persistent, that's its purpose (except in some niche cases where it wasn't working, but i'm not sure there's many of those left...?)