#mod_development

1 messages ยท Page 549 of 1

drifting ore
#

i want to remove whats inside the weapons

halcyon marlin
#

thanks, this is super helpful, and I am afraid that your second message is the case, but I am going to keep looking

halcyon marlin
# jaunty marten

also should have mentioned that i spotted this, but i do appreciate your help

jaunty marten
halcyon marlin
#

i am trying to make some adjustments to the Please Don't Feed the Zombies mod that just hit the front page for my own use to make it a bit more like the walking dead. I have tried a couple times to mod PZ but couldnt get past scripts really, so you are a big help

jaunty marten
sour island
#

you use the menu to enter?

#

and not just E

jaunty marten
#

need to aim to vehicle door xp

#

even in one of ur last gifs from ur last mod u entered in vehicle only after 5 times

sour island
#

while it was moving?

jaunty marten
#

tbh u professional

sour island
#

๐ŸคŒ

#

ty

jaunty marten
#

I not always can enter by one time even in not moving vehicle

sour island
#

you dont really need to wait for the green to come up

jaunty marten
#

maybe I have bugged keyboard

#

but doesn't work for me

#

only with green

viral flame
halcyon marlin
# viral flame Hey I made that! I'm curious why you don't want zombies eating humans that were...

lol i havent really tried it with multiplayer but i was trying to get it so that the zombs would only munch on npcs who died (until they would turn into zombies themselves) or zombies who spawned dead in the world already because i guess in The Walking Dead lore they dont eat other zombies after they died because of rotting flesh and whatnot. I think your mod is really cool, i was just trying to tailor it to my preferences a little more

viral flame
#

Ahh, makes sense - hadn't thought about NPC mods. I'll make a note to add a config for only non-zomboid corpses to be eaten.

Thanks!

halcyon marlin
#

thanks for reaching out! if I can get it to work as I'm intending I will let you know how I did it. I'm not an expert or anything, so honestly you would probably beat me to it, but I'll try

viral flame
#

Lol, sounds good

random finch
#

Ah ha, appreciate that.

random finch
# sour island

My man. You made a mod that allows you to pull people out GTA style?

sour island
#

ye

random finch
#

When is this going up on the workshop? I wanna test it.

sour island
#

probably like in a hour

#

gotta work on the most important part - the workshop poster

random finch
#

yehh yuhh

random finch
#

There a simple way to get rid of a players shadow without impacting any other shadows? Used masks on an item to hide the model.

thin hornet
#

Item EatType
doesn't seem to work properly when
ReplaceInSecondHand and/or ReplaceInPrimaryHand is set.

#

kind of prevent the EatType animation to works.

jaunty marten
#

how to use bit lib in pz?
Bits returns nil lsk_suicidekotik
utils same Suicide

viral flame
#

you can't, you can only access classes that are exposed

#

take a look here if you have decompiled the game

jaunty marten
thin hornet
#

yo wheres that new ATM tile

jaunty marten
#

now I have to create bit lib in game where one already exists but I haven't access to it

#

what a shit

thin hornet
#

I found the new safe

#

but no atm yet

#

ah there it is

#

jeeez its tall lol

tidal kayak
#

atm machine ๐Ÿ‘€

viral spire
#

Is there a mod out there where we can set a weather/season event to last for a specified period of time? Say I start the game in July but I want a winter event to kick off in 30 days, but it'll last for 6 months, so I need to prepare in that time and then work to survive the time after that. This is to simulate events such as an impact winter from asteroid impact, or a nuclear winter from a nuclear war (with subsequent mods added for effect).

stark cradle
#

How can I add a new type of zombie? I want to replace most if not all zombies with a certain few models that I made for enemies. I just want them to spawn like other zombies and maybe have a few special actions like lunging themselves at players. I'd be grateful just for a way to add a new zombie type though, really.

wooden falcon
#

Anybody know why my solo world mods are all of a sudden using my steam workshop versions of my mods and not the local versions in my /Users/*/Zomboid/workshop folder? Any changes I make to those mods don't get picked up by game unless I unsubscribe from the steam workshop version of that mod.

thin hornet
wooden falcon
#

Do you remember it always being like that? I'm pretty sure I used to be able to be subscribed to my mod, but still able to tweak it from my /Users/ folder and still get the change effects after a lua reload.

thin hornet
#

If I recall correctly it was not like that in the past

#

But its been a while since i test my mods in SP, usually use local server or host

static girder
#

Hey all. I'm fairly new to modding PZ and I'm trying to find a way to increase the base capacity of containers (such as crates). However, I was unable to find where the base capacity of furniture is defined.

Alternatively, I tried looking into modifying the "Organised" trait's multiplier (to effectively increase the capacity of all containers) but I was also unable to find where this variable is defined.

Any help on either of the above issues would be greatly appreciated!

thin hornet
#

TileZed

static girder
#

@thin hornet Thanks! I'll set it up and see if it helps

thin hornet
#

Im not sure you can edit vanilla tiles tho

pearl prism
static girder
#

@pearl prism That would definitely explain the lack of mods tweeking base capacity of containers. What about going down the route of modifying the value for the Organised trait?

thin hornet
static girder
thin hornet
#

So for example:
zomboid\zombie\inventory\ItemContainer.java

   public int getEffectiveCapacity(IsoGameCharacter var1) {
      if (var1 != null && !(this.parent instanceof IsoGameCharacter) && !(this.parent instanceof IsoDeadBody) && !"floor".equals(this.getType())) {
         if (var1.Traits.Organized.isSet()) {
            return (int)Math.max((float)this.Capacity * 1.3F, (float)(this.Capacity + 1));
         }

         if (var1.Traits.Disorganized.isSet()) {
            return (int)Math.max((float)this.Capacity * 0.7F, 1.0F);
         }
      }

      return this.Capacity;
   }
#

you can create new traits but you cannot add the effect to that function getEffectiveCapacity

#

You will need to research there is maybe a function or something that would allow you to do something but not that I know personnaly

pearl prism
#

I believe the big problem is that the game first reads the original code and then reads the mods' codes, so any attempt to change any vanilla system tends to give an undesired result. The way it is possible to change contender storage capacity would be to simply create an entirely new furniture from scratch, that way the game would only read the mods codes.

thin hornet
#

Well basically the game engine is made of Java, it include a Lua interpreter that exposes a set of functionality that we can use in our Lua mods. So we are limited to what is exposed and cannot overwrite any thing of that java stuff.

outer perch
#

hi, I am having an issue where any items I drop on the ground get deleted, any ideas?

thin hornet
#

@outer perch dropping like mouse dragging it down?

outer perch
#

yeah

thin hornet
#

you are using mods?

outer perch
#

yeah a lot

static girder
#

@thin hornet @pearl prism I see. Got it, thank you both!

outer perch
#

but it just started happening

#

when it wasnt

thin hornet
#

you are on the unstable or stable beta?

outer perch
#

stable as far as I know

thin hornet
#

try changing for unstable

#

thats the latest released

outer perch
#

ikr

#

but

#

will that not break any other mods doe?

thin hornet
#

it can

outer perch
#

:(

thin hornet
#

So you are having that issue in SP or MP?

outer perch
#

mp

thin hornet
#

anyone else having it?

outer perch
#

yeh

#

my friend

#

I found this: The mod causing it is Arsenal/Brita's Weapon pack. Unsubscribe and resubscribe to it to fix the bug from the integrated Eris Nightvision mod.
but probably outdated eh?

thin hornet
#

no idea

outer perch
#

meh

#

Paw Low and Britas are causing issues. Redownload Britas and download this unofficial patch for Paw Low to stop disappearing item issue.

#

I guess that might make some sense

#

will try this

#

got both oth them

outer perch
#

fix above helped^

drifting ore
#

can someone help me when i try to start my server with mods mods just dont load?

random finch
#

How is the guid for custom items produced?

#

Ah it appears I can use a generator. ItemZed also produces a guid but Ive never used it, not sure if its still updated.

willow estuary
random finch
#

Very good. That's the one I came across.

cosmic condor
jade musk
#

are there any mods that increase the storage size of containers?

cosmic condor
#

A LOT

jade musk
#

i havent found any that have been updated. can point me to one?

stark bone
#

Hi, I have a question. Does anyone know how to make a mod pack? I did like to play with my friends with some mods but usually its like one of us have late version and we cant play

cosmic condor
cosmic condor
#

if you mean the first option then go here

#

when you have a problem just sub and unsub all mods in the collections

#

and delete all workshop in local folder

#

then resub again

stark bone
#

its like all in one

cosmic condor
#

but remember modders dislike the idea because it takes all of their time and effort

#

ask for permission first

stark bone
cosmic condor
#

better add those mods into your collection, good for everyone

#

also take a little effort

halcyon walrus
#

Hey, working on making a gun mod but run into a slight issue with the positioning of the rifle. Its kinda low down on the character and doesn't sit right in the hands. I tried adjusting the models position in blender but all that seemed to do was distort the model in game. I'm pretty sure it's a script I'm looking to edit in the firearm.txt file but I really have no idea.

cosmic condor
dapper vector
#

Is there some replacement to the UseItem event?

heady crystal
#

Anybody know how to get the item or item name of a vehicle part?

heady crystal
sour island
#

Anyone know of a way to ensure your mod is loaded before someone elses? like an anti-require?

placid hinge
#

local vehicle = playerObj:getVehicle()
local vehiclePart = vehicle:getPartById("Part_name")

#

@heady crystal

heady crystal
#

That'll give me the part

#

I need the item specifically

#

The inventory item

placid hinge
#

Oh thought you meant just in the lua, should be able to spawn it in by the ID too

#

local playerObj = getPlayer()

#

local vehicle = playerObj:getVehicle()
local vehiclePart = vehicle:getPartById("Part_name")

heady crystal
#

I have the vehicle but I want to get it's parts and give it to the user as items

#

But inventory:AddItem(PARTHERE) won't work with anything I tried off the part

#

ID won't work, getfulltype only returns the part not the item, etc.

placid hinge
#

Oh yah than this should work, use vehiclePart and put the ID in getPartByid()

#

to do inventory:AddItem(vechiclePart)

heady crystal
#

That doesn't work

#

I already tried it

#

It expects the item name string

#

Say I want to add a vehicle's front left wheel

#

I'd have to do for instance inventory:AddItem("Base.NormalTire1")

placid hinge
#

Oh really and yah that should work to get it in item form if thats its name

heady crystal
#

Yes the problem is how to get it's name off the part?

#

How to get it's name at all

#

Nothing works

placid hinge
#

Oh you mean just the display name?

heady crystal
#

No, like this

#

Which translates to Base.NormalTire1

placid hinge
#

Yah thats its normal name, should be able to work with it as such, otherwise idk really

heady crystal
#

Yes but how do you get that property off the part?

opaque ocean
#

can someone please explain to me what the heck MetalValue is? I keep seeing it in a bunch of unrelated mods but I can't figure out what it's used for.

sour island
#

Metalworking recipes

#

metalworking was/is a planned skill - there's alot of stuff referencing it in the files - alot of modders added it in/make use of it.

opaque ocean
#

alright, so it's a useless item property until 2025?

sour island
#

alot of modders added use for it

#

if you want your item to be interactable/metled down/etc idk not really a big deal

opaque ocean
#

fair enough. Thank ya for the quick response my dude! Working on an overwrite to integrate ISA into hydro right now to replace Hydro's bugged solar generators. Finally got around to testing the ISA patch and it actually fixes the cell unloading issues that Hydro still has.

wooden falcon
#

For Events.OnKeyPressed, is there somewhere where we can see the mappings between keys and their corresponding numbers?

sour island
#

Added support for magazines to Named Literature

#

Was debating on whether or not to pull issues/volumes from some database but no real gain I guess

drifting ore
#
ISPaintMenu.onPaint = function(worldobjects, player, thumpable, painting)
    local playerObj = getSpecificPlayer(player)
    local playerInv = playerObj:getInventory()
    if true or JoypadState.players[player+1] then
        local bo = ISPaintCursor:new(playerObj, "paintThump", { paintType=painting })
        getCell():setDrag(bo, bo.player)
        return
    end
    local props = thumpable:getProperties()
    thumpable:setIsThumpable(false);
    local isWall = props:Is("WallN") or props:Is("WallW") or
        props:Is("DoorWallN") or props:Is("DoorWallW")
    if isWall then
        local north = props:Is("WallN") or props:Is("DoorWallN")
        if not luautils.walkAdjWall(playerObj, thumpable:getSquare(), north) then
            return
        end
    else
        if not luautils.walkAdj(playerObj, thumpable:getSquare()) then
            return
        end
    end
    local paintCan = nil
    if not ISBuildMenu.cheat then
        local paintBrush = playerInv:getFirstTypeRecurse("Paintbrush")
        ISWorldObjectContextMenu.transferIfNeeded(playerObj, paintBrush)
        paintCan = playerInv:getFirstTypeRecurse(painting)0
        ISWorldObjectContextMenu.transferIfNeeded(playerObj, paintCan)
    end
    ISTimedActionQueue.add(ISPaintAction:new(playerObj, thumpable, paintCan, painting, 100));
end
#

ISPaintMenu.onPlaster = function(worldobjects, player, thumpable, square)
    local playerObj = getSpecificPlayer(player)
    local playerInv = playerObj:getInventory()
    if true or JoypadState.players[player+1] then
        local bo = ISPaintCursor:new(playerObj, "plaster")
        getCell():setDrag(bo, bo.player)
        return
    end
    if luautils.walkAdjWall(playerObj, thumpable:getSquare(), thumpable:getNorth()) then
        local plaster = nil
        if not ISBuildMenu.cheat then
            plaster = playerInv:getFirstTypeRecurse("BucketPlasterFull")
            ISWorldObjectContextMenu.transferIfNeeded(playerObj, plaster)
        end
        thumpable:setIsThumpable(false);
        ISTimedActionQueue.add(ISPlasterAction:new(playerObj, thumpable, plaster, 100));
     end
end
#

trying to make painted and plastered walls invincible and untouchable by zombies, but this code doesn't seem to work, do you guys know the issue?

tranquil reef
#

Would it even be remotely possible to get blender shape keys to work in zomboid

rancid verge
#

Does anyone know the function for modifying the speed a zombie is able to walk through trees? I'm new to modding and not sure where to look

drifting ore
#

can i overwrite existing walls to not be thumpable via plastering/painting or both?

cosmic condor
#

those who want their mod to load later, can also apply this method

#

I saw someone recently asked here but deleted the text

cosmic condor
heady crystal
#

That's not even remotely close to what I asked, but it's ok, I already found a way out. Thanks anyways.

cosmic condor
#

... and what is your question exactly? I read many times and still don't understand what you really need

shadow geyser
opaque ocean
#

unless you wanna hitup Radx5 and Neznajka and fully bring ISA into hydro, it's not something you want in the main mod

unique goblet
#

I'm having trouble sending ModData from client to server. Wiki says that OnReceiveGlobalModData is triggered only on client side whereas indiestone forum says that OnReceiveGlobalModData is triggered on both client and server side. I am suspecting that first option is true, because is seems that client is transmitting ModData but server isn't receiving it.

Code shared by client and server:

    if key~= "MyModData" then
        return; 
    end
    if not modData then
        print("modData table is missing");
    else
        ModData.add(key, modData);
    end
end

Events.OnReceiveGlobalModData.Add(OnReceiveGlobalModData);```

When I send ModData from server to client using `ModData.request("MyModData")` it works just fine. But when try to send modData the other way around from client to server using `ModData.transmit("MyModData")` then modData table on server doesn't update and stays in same state as before `ModData.transmit("MyModData")`

So does transmitting ModData work differently depending on direction of transmission or it does work the same way and I am missing something else?
thin hornet
#

Client:

-- if ModData.exist("MyModData") -> ModData.delete("MyModData")
-- ModData.create("MyModData")
-- ModData.request("MyModData") -> we get the most up to date
-- OnReceiveGlobalModData -> set moddata on this client

Server:

-- ModData.getOrCreate("MyModData") -> persistant moddata
-- OnClientCommand -> handle client command -> update MyModData fields
-- sendServerCommand -> tell everyone online about the changed field

only the server should be trusted, so if a client was sending a whole modata table, it would replace the server one with it and could potentially cause loss.

thin hornet
# unique goblet I'm having trouble sending ModData from client to server. Wiki says that OnRecei...

CLIENT/SERVER WITH GLOBAL MODDATA
Made to work in single-player, host or dedicated.

CLIENT

MyMod = MyMod or {};
MyMod.Data = MyMod.Data or {}; -- storing modData tables in here
MyMod.ServerCommands = MyMod.ServerCommands or {}; -- storing server commands handlers here

--- client function to send changes to the server
function MyMod.sendSomeChange(key, value)
    local args = { key = key, value = value };
    sendClientCommand("MyMod", "MyCommand", args);
end

--- Server Command Handler : UpdateSomeData
function MyMod.ServerCommands.UpdateSomeData(args)
    MyMod.Data.InfoStorageExample[args.key] = args.value;
end

--- handle initializing moddata
local function initGlobalModData(isNewGame)
    -- clear only if its a client, if it's single-player we dont need to clear
    if isClient() and ModData.exists("InfoStorageExample") then
        -- clear the current copy for a client cause it might be outdated
        ModData.remove("InfoStorageExample");
    end

    MyMod.Data.InfoStorageExample = ModData.getOrCreate("InfoStorageExample");
end
Events.OnInitGlobalModData.Add(initGlobalModData);

--- handle receiving moddata
local function receiveGlobalModData(name, data)
    if MyMod.Data[name] and type(data) == "table" then
        if #data > 0 then
            -- if the received data is an array table
            for _, value in ipairs(data) do
                table.insert(MyMod.Data[name], value);
            end
        else
            -- if the received data is a key/value table
            for key, value in pairs(data) do
                MyMod.Data[name][key] = value;
            end
        end
    end
end
Events.OnReceiveGlobalModData.Add(receiveGlobalModData);

--- handle receiving server commands
local function receiveServerCommand(module, command, args)
    if module ~= "MyMod" then return; end
    if MyMod.ServerCommands[command] then
        MyMod.ServerCommands[command](args);
    end
end
Events.OnServerCommand.Add(receiveServerCommand);
#

SERVER

MyServerMod = MyServerMod or {};
MyServerMod.Data = MyServerMod.Data or {}; -- storing moddata table here
MyServerMod.ClientCommands = MyServerMod.ClientCommands or {}; -- storing client command handlers here

-- Client Command Handler : MyCommand
MyServerMod.ClientCommands.MyCommand(player, args)
    if isDebugEnabled() or player:getAccessLevel() == "Admin" then -- example of possible check to validate client commands
        -- data will be changed on server, if its single-player it will be changed on the "client" too.
        MyServerMod.Data.InfoStorageExample[args.key] = args.value;

        -- send the change to all clients, will not send if single-player not needed anyway
        sendServerCommand("MyMod", "UpdateSomeData", args);

        -- if we want to simulate sending it to a client in singleplayer we can just triggerEvent OnServerCommand
        -- triggerEvent("OnServerCommand", "MyMod", "UpdateSomeData", args);
    end
end

--- handle initialization of moddata
local function initGlobalModData(isNewGame)
    MyServerMod.Data.InfoStorageExample = ModData.getOrCreate("InfoStorageExample");
end
Events.OnInitGlobalModData.Add(initGlobalModData);

--- handle receiving client commands
local function receiveClientCommand(module, command, player, args)
    if module ~= "MyMod" then return; end
    if MyServerMod.ClientCommands[command] then
        MyServerMod.ClientCommands[command](player, args);
    end
end
Events.OnClientCommand.Add(receiveClientCommand);
steel locust
#

Does anyone have any idea where I could find the Lua code that deals with weight loss and gain? I've scrounged around the code and came up empty. I really want to make some kind of "weight loss pills" mod for multiplayer specifically. ๐Ÿ™ƒ

drifting stump
#

its java side

#

instant weight loss should be simple however

steel locust
thin hornet
#

๐Ÿ˜„ ty

jaunty marten
thin hornet
#

yeah thats a bit anoying but can also help

#

cause inside lua/client and lua/server we often have other stuff like Translate Items etc

#

so submodname directory help separate your logic from all the rest of it

#

it also help with the require require 'ModName/file

jaunty marten
#

yea, rn it's no way to remake cos will break everything xp

sour island
thin hornet
#

Load order should really be handled with require

#

require force the required script to be loaded first, if using require on a already loaded script it wont run it again it will just return its cached value

#

reloading a script re-run that script and update its cached value

#

A mod depending on an other:


if getActivatedMods():contains("TheRequiredMod") then
  require("TheRequiredMod/script"); -- ensure that mod script is loaded now before continuing
  
  -- we gucci

else

  -- we gucci without it

end

#

When making a mod a possible pattern to ensure files load order:
client/Main.lua

require 'Utils'; -- ensure utils has been loaded first, will be available in all other files then
Main = {};

shared/Utils.lua

Utils = {};

client/Module1.lua

require 'Module2'; -- ensure Module2 has been loaded first
if Main then print("Main exist"); end
if Utils then print("Utils exist"); end
if Module2 then print("Module2 exist"); end

client/Module2.lua

require 'Main'; -- ensure Main has been loaded first
Module2 = {};
if Main then print("Main exist"); end
if Utils then print("Utils exist"); end
drifting stump
#

that isnt a module

#

and stop using globals already

#

client/Main.lua

local Utils = require 'Utils'; -- ensure utils has been loaded first, will be available in all other files then

local Main = {};

return Main

shared/Utils.lua

local Utils = {};

return Utils

client/Module1.lua

local Module2 = require 'Module2'; -- ensure Module2 has been loaded first
-- if Main then print("Main exist"); end
-- if Utils then print("Utils exist"); end
-- if Module2 then print("Module2 exist"); end
-- these are not a good way of doing things, require is how you ensure something is loaded. Check instead if a mod is loaded to make sure the require can happen

client/Module2.lua

local Main = require 'Main'; -- ensure Main has been loaded first
local Utils = require 'Utils'
local Module2 = {};
if Main then print("Main exist"); end
if Utils then print("Utils exist"); end

return Module2
#

for a file to be a module it needs to return something
whatever is returned is given when requiring somewhere

jaunty marten
#

when invokes event OnObjectAboutToBeRemoved? I'm using next part to delete obj but event doesn't invoke

square:transmitRemoveItemFromSquare(obj)
square:RemoveTileObject(obj)
square:DeleteTileObject(obj)
#

or mb there's other event when obj deletes

#

nothing else but OnObjectAboutToBeRemoved on wiki

#

ah, it's lua event
but then how to catch real remove of object? basically I need to catch event when object about to remove by sledgehammer so need to catch transmitRemoveItemFromSquare or RemoveTileObject

shadow geyser
# jaunty marten ah, it's lua event but then how to catch real remove of object? basically I need...

looking at the pz code, I think you want to use OnDestroyIsoThumpable. That is the sledge hammer action calls atleast. However it calls it in an unusual way by using sendClientCommand. But I think that should work for the sledgehammer case. However for the :transmitRemoveItemFromSquare(obj) and the rest. you can just call the function you would insert to the event handler instead, as they might not trigger the an appropriate event anyways

pulsar rock
#

Hey all. Not new to programming / LUA / etc..., definitely new to Zomboid modding. How do I get the PZ Library jars?

jaunty marten
shadow geyser
jaunty marten
#

@willow estuary sorry for ping but mb u know how to catch when object is about to be remove?

pulsar rock
#

So, why is CAPSID running some kind of "createDiscordIntegration" gradle job? hmm

#

Nvm, found it

#

For anyone curious

willow estuary
jaunty marten
jaunty marten
#

the only thing I'll wait in future updates

fast galleon
jaunty marten
#

yea, u should do triggerevent here

fast galleon
#

oh right, I was thinking about remove event since I've had issues with that

jaunty marten
#

my issue is to remove object from cluster when it was broken by sledgehammer cos I don't want to check if object is valid in iteration of this cluster

pulsar rock
#

So, what function should I override to prevent XP gain for certain skills?

#

Would I override the AddXP function?

#

Or is there an event that is raised when a player gains XP?

#

Could just reduce XP by the same amount when it happens hmm

#

Thought that feels like it'd be somewhat performance-problematic, potentially

#

Ah, found it

thin hornet
thin hornet
drifting stump
#

everything wrong with using globals

thin hornet
#

pz is 90% made of globals

drifting stump
#

and?

thin hornet
#

and because of that you can hook and mod it

drifting stump
#

and?

thin hornet
#

and the same apply to a mod

pulsar rock
#

Right, but LUA's philosophy is keeping scope as small as possible

#

It's bad practice to use globals if you don't need to

drifting stump
#

^

thin hornet
#

Yeah that why i said if done properly

pulsar rock
#

"Done properly" is a very vague statement

drifting stump
#

but using a global is always not done properly

thin hornet
#

basically use a single global that contains everything else

drifting stump
#

look

pulsar rock
drifting stump
#

if you do

local var = {}

return var
local var = require "whatever that file is"

you have access to the same var

thin hornet
#

sure

drifting stump
#

why would you ever use a global instead of this

pulsar rock
#

Deja vu

thin hornet
#

i mean i know this

#

lol

drifting stump
#

then why are you advocating for globals

thin hornet
#

coz we live in a globalist world now

#

lol

pulsar rock
#

So, question; I'm new to PZ modding. I'm working on a mod that caps your maximum skill level based on your traits / profession.

thin hornet
#

mhm

pulsar rock
#

Where would I grab the list of skills, traits, and professions?

thin hornet
#

the global Perks

pulsar rock
#

I'm currently just planning on hooking into the AddXP Event. Can you "cancel" an event somehow?

thin hornet
#

you can hook into onAddXp

#

and there you kind of cap/max it

pulsar rock
#

onAddXp?

#

The wiki has an "AddXP" event, but I can't seem to find an onAddXP one

drifting stump
#

gonna write the localist manifesto
we localists now

pulsar rock
#

I guess I could also grab LevelPerk hmm

#

So, how does one "cancel" an event?

thin hornet
#

Events.AddXP.Add
Events.LevelPerk.Add

pulsar rock
#

Aye, but you can't cancel the event somehow, can you?

shadow geyser
thin hornet
pulsar rock
#

How would I limit the perk level?

#

Or simply reduce back to my limit if they level up?

thin hornet
#

well if > limit = set it back to X

drifting stump
#

you could use the perk level event and bump it back down

pulsar rock
#

I guess

#

Is there any unlocks that happen if you level up? hmm

#

/ any weirdness to take into account

thin hornet
#

i dont see where AddXP event is triggered but LevelPerk is triggered at the end of the functions so if something was added it will probably already be added when LevelPerk is triggered

pulsar rock
#

Ah well

#

I guess I can just hook into LevelPerk for now

thin hornet
#

i suggest you read zombie\characters\IsoGameCharacter.java

pulsar rock
#

Not too hard to change it to AddXP, if necessary

#

And saves on a fair number of calls

thin hornet
#

LevelPerk is triggered when Losing a level and Gaining a level

shadow geyser
#

@thin hornet hi wasn't sure what the best way to communicate with you, but I was having some problems while following your guide for decompiling. after executing the setupWorkspace it ran all task mostly the same stuff except it ran "compileZomboidLua" instead of "compileZomboid" (not sure if that matters)? but ultimately I dont see the build folder and therefore no sources directory. Is there some mistake that needs to be fixed? I dont have any previous experience with gradle so im not sure what information is relevant

thin hornet
#

dm me with a screenshot of intellij workspace

#

just wanna see what you see

pulsar rock
#

That's fine @shadow geyser

#

Or, well, the name difference is fine

#

Refresh your directory?

#

Also, @thin hornet, is there some way to get the amount of "pips" a player has per skill?

#

Like, what do these represent data/code-wise?

thin hornet
#

the green bars?

#

each bar is 1 level

thin hornet
#

youll find reference about how to set level etc

jaunty marten
thin hornet
#

did you try OnTileRemoved

jaunty marten
#

okay I just tested again and it start to invoke func

#

wtf

thin hornet
#

Sometime when using Reload button

#

it just fuck it up

#

so you have to go back to menu and log again

jaunty marten
#

I press this button 3-5 times each time roflanEbalo

jaunty marten
thin hornet
#

XD

jaunty marten
#

pz klass

thin hornet
#

press only once

#

xD

#

you should see in the console that it reloaded it

#

but even tho

#

Events dont like reload

#

especially when using anonymous function

jaunty marten
thin hornet
#

Events.OnTick.Add(function() end);

jaunty marten
#

idk how it even can work cos it haven't any id for event

jaunty marten
thin hornet
#

๐Ÿ˜ฎ

#

dont ๐Ÿ˜›

#

use globals

#

xD

#

nah but better store that function in a var before passing it

jaunty marten
#

but anonymous func is better... PB_peepo_cry

thin hornet
#
local function onTick()
  Events.OnTick.Remove(onTick);
  print("run just once")
end
Events.OnTick.Add(onTick);
#

also when reloading your script with this, the old onTick reference become nil

#

anonymous i dont think it nullify it

jaunty marten
#

Yea, Ik but for func that shouldn't be removed I want to use anonymous func :(

thin hornet
#

Just try to use local function instead from now on

jaunty marten
thin hornet
#

its not javascript xD

#

๐Ÿ˜›

jaunty marten
#

why are u making me cry

thin hornet
#

My plan is to start using globals and anonymous functions everywhere

pulsar rock
#

For example iterating over traits + profession and checking what they add?

#

Or is it not that simple?

thin hornet
#

You mean from the character creation menu?

pulsar rock
#

Aye

#

At any point during the game, being able to check "What was this character's starting level"

thin hornet
#

Well you could save a player moddata the first time the character has spawned

pulsar rock
#

Hm, preferably a more dynamic solution

thin hornet
#

what do you mean

pulsar rock
#

Like, one that works even if the mod is added mid-playthrough

#

By calculating what the starting skill level is.

thin hornet
#

cant im pretty sure

pulsar rock
#

Couldn't you check what the traits add on character creation?

thin hornet
#

depend if traits are dynamic

pulsar rock
#

Oh?

thin hornet
#

and for example obese

#

would change if player loses weight

pulsar rock
#

I'm excluding fitness and the like

#

Only "technical" skills

thin hornet
#

but again, what if he gained a technical trait midgame

#

i mean adding mods midgame you cant expect it to be perfect

#

People will die and start a new character, unless the server is set to easy

pulsar rock
#

They're generally not gaining traits, afaik?

thin hornet
#

depend if dynamic traits mods is installed

pulsar rock
#

Unless they're using dynamic traits; But I'd say that's a fair enough interaction.

thin hornet
#

its a pretty popular mod

pulsar rock
#

Gain the trait, your max skill level goes up.

#

Works for me

thin hornet
#

and yeah depending what you want to do why not

pulsar rock
#

ยฏ_(ใƒ„)_/ยฏ

#

So, how would you fetch what perk points a trait adds?

thin hornet
#

traits stuff is set in lua\shared\NPCs\MainCreationMethods.lua

#
local function getTraitPerkLevels(traitName)
    local traitLevels = {};
    local trait = TraitFactory.getTrait(traitName);
    local map = trait:getXPBoostMap();
    if map then
        local mapTable = transformIntoKahluaTable(map)
        for perk, level in pairs(mapTable) do
            traitLevels[perk] = (traitLevels[perk] or 0) + level:intValue()
        end
    end
    return traitLevels;
end
pulsar rock
#

I see

#

getXPBoostMap is what I want, I believe

thin hornet
#

yeah

#

i checked the \lua\client\OptionScreens\CharacterCreationProfession.lua for reference

#

get your text editor find tools ready

#

you gonna have lot of research to do ๐Ÿ˜›

pulsar rock
#

@thin hornet setPerkLevelDebug just sets the perk level, right?

#

Also, how would I go about logging something to the console? How about a server's console?

thin hornet
#
 
print("my message");
pulsar rock
#

Right, but does that log properly to a server's debug.log?

#

Or do I grab a Logger object from somewhere and write through that?

thin hornet
#

well it take a string

pulsar rock
#

Right, I'm wondering what to call to log to the game's logfile, though.

#

ZLogger:write(...)?

#

Or writeLog? hmm

jaunty marten
#

DebugLog.log(DebugType, "blablabla")

#

debug types u can find on pz javadoc

pulsar rock
#

๐Ÿ‘Œ

#

Much appreciated

jaunty marten
pulsar rock
#

Like this?

jagged ingot
#

Apparently you can write TypeScript PZ mods now.

pulsar rock
#

Oh?

jagged ingot
pulsar rock
#

So

#

I wrote my mod

#

Do I just toss it into the mod folder and load it up?

jaunty marten
pulsar rock
#

?

jaunty marten
#

DebugLog:log > DebugLog.log

jagged ingot
pulsar rock
#

Like this, you mean?

DebugLog.log(DebugType.Mod, "message goes here")
#

That seems to expect the first argument to be a self, though.

jagged ingot
#
      /**
       * @noSelf
       *
       * Method Parameters: 
       *  - (String arg0): void
       *  - (Object arg0): void
       *  - (DebugType arg0, String arg1): void
       */
      static log(arg0: any, arg1?: string): void;
#

Pretty cool that I can look this up using the typings from that project I linked.

pulsar rock
pulsar rock
#

IDE seems to imply it expects it to be

jaunty marten
pulsar rock
# jagged ingot ```ts /** * @noSelf * * Method Parameters: * ...
---@public
---@param str String
---@return void
---@overload fun(o:Object)
---@overload fun(type:DebugType, str:String)
function DebugLog:log(str) end

---@public
---@param o Object
---@return void
function DebugLog:log(o) end

---@public
---@param type DebugType
---@param str String
---@return void
function DebugLog:log(type, str) end
#

This is what I'm getting from DebugLog.lua

jagged ingot
pulsar rock
#

Ngl, first time I'm properly working with LUA

thin hornet
#

Its annotation

pulsar rock
#

So, some of this feels a bit wack

jagged ingot
#

No I know what LuaDocs is.

#

It's empty functions that made me think that lol

pulsar rock
#

Yeah, they're just annotations for type hinting

#

@thin hornet You got a clue here?

thin hornet
#

What do you want to do?

pulsar rock
#
DebugLog:log(DebugType:Mod, "SkillLimiter.LimitSkill: " .. character.getFullName() .. " | " .. perk.getName() .. " | " .. level .. " / " .. max_skill)
#

Really just log to the debug log

#

I'm just not quite sure whether or not I'm calling the log function correctly

#

And whether or not the DebugType is passed properly

#

I'm not 100% on the whole . vs : thing in LUA

#

Like, I've used C++ / C#, so I'm assuming it's comparable to :: there

#

Like a static call of some kind rather than to an instantiated object?

thin hornet
#

is DebugLog a new feature?

#

i always used print()

jaunty marten
#

I said DebugLog.log

#

why are u using method

#

btw how do u even compile the file with DebugType:Mod

pulsar rock
#

Because my IDE, and the doc, seem to imply that would cause the first argument to expect an instantiated object.

jaunty marten
#

wtf is this

pulsar rock
#

Also, mind just replying in English? hmm

jaunty marten
#

forgot to change lang on keyboard

pulsar rock
pulsar rock
#

This is what I'm referring to

pulsar rock
jaunty marten
pulsar rock
#

Alrighty then

jaunty marten
#

if ur ide says DebugType:Mod variable is correct then I'm done

pulsar rock
#

It doesn't seem to accept either DebugLog.Log nor :Log tbh

jaunty marten
jagged ingot
#

So PZ has a DebugLog in their Lua too?

worldly olive
#

I'm interested in this (just read it the latest comment). So is it possible to debug and print things to the console without using the print? ๐Ÿ˜‚

jagged ingot
#

Weird to have two.

pulsar rock
#

It seems like it's exposed to Lua at least

jagged ingot
#

It is. I showed the typings earlier.

pulsar rock
#

Not entirely sure if I need to instantiate something first though hmm

jaunty marten
pulsar rock
#

Or if it's just some wacky definition hinting

jagged ingot
#

I didn't think that someone would've made LuaDocs for Java API of the game.

worldly olive
pulsar rock
#

Not the faintest clue

#

I'm new to Lua

#

Not new to programming, though.

#

But I haven't really touched Lua, nor interacted with Java with it before.

#

So some of the syntax is still a bit peculiar to me.

jagged ingot
#

I think Lua complicates invocations more than it should honestly.

pulsar rock
#

Like, is DebugLog in this case an instance we're accessing? Or just a class definition?

jagged ingot
#

This is why I write in OOP languages.

pulsar rock
#

Same ๐Ÿ™

worldly olive
#

Yeap, same

pulsar rock
#

But, yeah

#

So

#

Is DebugLog an instance? In that case .log makes sense

jaunty marten
pulsar rock
#

No clue why my IDE is hinting at the first arg being self in that case though.

#

If it's not an instance, calling it through ":" might make sense?

#

Headscratcher for sure

jagged ingot
jaunty marten
pulsar rock
#

Metatables look like pure pain, thank you

jagged ingot
jaunty marten
pulsar rock
jagged ingot
#

I was confused initially because of the fact that there're two DebugLogs? Or those docs aren't correctly mapping static calls.

pulsar rock
#

The docs might just not be mapping things correctly, is what might be going on

jaunty marten
#

but if u can't get to use function not like method but just static then yea it's will be really pain

jagged ingot
jaunty marten
novel mountain
#

is there anyway to know which mod is this ? Can't launch server because of this

pulsar rock
#

I see

jaunty marten
pulsar rock
#

I've used :: and the likes before

jaunty marten
#

I'm crying

jagged ingot
#

All var.func(..) calls are static. Using : is a simplification of passing the object's instance to the function.

pulsar rock
#

I see, thanks. That explains things a fair bit.

jagged ingot
#

It's sort of like what I recall python did with self parameters for pseudo-classes, however my Python days were back in Python 2.

#

Everything that's in the Lua codebase for PZ are pseudo-classes btw.

pulsar rock
#

Sounds a lot like class methods in Python

jagged ingot
#

Lua literally doesn't know what a class is.

pulsar rock
#

Which hurts

#

On a lot of levels

#

:')

jagged ingot
#

Which is why I'm hyped about writing mods in TypeScript now.

pulsar rock
#

I can imagine

jaunty marten
pulsar rock
#

Not much of a JS/TS person, myself

#

But it's at least better than Lua

jagged ingot
pulsar rock
#

^

worldly olive
pulsar rock
#

Apparently

jagged ingot
pulsar rock
jagged ingot
pulsar rock
#

Fair fair

worldly olive
#

Well... gotta give it a try ๐Ÿ‘€

jagged ingot
#
/** @noSelfInFile */
import * as Events from 'ZomboidEvents';
import { getPlayer } from 'Zomboid';
Events.onGameStart.addListener(() => {
    print(`Hello, ${getPlayer().getFullName()}!`);
});
pulsar rock
#

But just to get back to my issue:

Simply doing DebugLog.log should work, then? Regardless of the IDE assuming it needs a self argument?

jaunty marten
#

I said twice the final answer to u wtf

jagged ingot
#

You should be fine using DebugLog.log. It's exposed as a public static method.

pulsar rock
#

Mhm, might be an issue with the docs then

jaunty marten
jaunty marten
jagged ingot
#

I'm going off of what I know as I've seen the decompiled source code for DebugLog.

jagged ingot
#

Lua is as weak with OOP as JavaScript ES5.

drifting stump
#

which can all be accomplished in lua

#

the difference is lua doesnt hold hands

jagged ingot
#

It's a fun language.

#

It's great for scripting and works well in a lot of ways. This one is the one I like to focus on for my personal work though so that's why I have a less than stellar opinion of it.

jaunty marten
drifting stump
#

funny though when you clearly didnt read how that typescript modding framework works

jagged ingot
#

Reinventing those concepts only creates more trouble. With scaling, possible issues only grows.

drifting stump
#

it uses typescript to lua

#

which inherently means anything that can be done in ts can be done in lua

jagged ingot
jaunty marten
#

XD

drifting stump
#

its literally just an abstraction to hold peoples hands

jaunty marten
#

ั‚ัƒะดะฐ ะตะณะพ

jagged ingot
#

You're forgetting the compilation process which gives actual errors for support for development.

#

Selling the idea short.

drifting stump
#

and tbh fine by me if it will improve the quality of mods code

jagged ingot
jaunty marten
#

hmmm

#

yea

#

it's faster

#

u even can install lua-linter to catch errors in real time

#

wtf

jagged ingot
#

Well if you use something like Visual Studio Code, those errors are provided in a panel and auto-refreshed.

jagged ingot
jaunty marten
#

which errors do u get after compile the file?

#

not only syntax?

jagged ingot
#

Yes. You see type errors. You see problems when accidently referring to a wrong type or a class declaration doesn't have a method.

drifting stump
#

i am however a firm believer in what a wise man once said

safety checks are useful to prevent crashes but if you just program well you don't need to prevent crashes
jagged ingot
#

You see a lot more.

jagged ingot
jaunty marten
#

if it runs unit-test on each of my funcs then I going to use typescript

jaunty marten
#

I'm used linter only once just to test it

jagged ingot
jaunty marten
#

just don't code with closed eyes

drifting stump
#

it really doesnt matter most of the issues will be prevented by not letting you do something wrong in the first place or having way better code than most mods

jaunty marten
jagged ingot
#

I use JSON linters when writing my own quick export code.

jaunty marten
jagged ingot
#

I'm content to know I have more options now.

jaunty marten
#

btw I want to see how u will create mods on typescripts without auto-refresh in pz

#

I mean

#

it's really pain in da ass

#

XD

jagged ingot
jaunty marten
#

so I need to compile the file each time?

jagged ingot
#

The project I read has a compiler watcher built in.

drifting stump
#

reloading files is a lie it shouldnt be done

jaunty marten
jagged ingot
# jaunty marten it's yes or no

It's a yes if you want to be techincal. It's a no if you're asking if you have to run a command everytime you change your code.

#

File watchers are a common thing to use for NodeJS environments.

jaunty marten
#

so if I change the line in ts file it will pull changes in lua file without compile? wut?

drifting stump
#

detects source changed > compiles to lua

jagged ingot
jaunty marten
#

so answer is yes

#

thanks but anyway useless

jagged ingot
jaunty marten
#

XD

#

k

#

lmao

#

and etc

drifting stump
#

@jaunty marten do you have your mods on a repo or can link me one

jaunty marten
#

server addons

#

what's u want?

drifting stump
#

can i look at the source?

jaunty marten
#

there're used global table not modules so better to u don't look XD

drifting stump
#

yeah so point i wanted to make is valid youd benefit from that typescript thingy simply because it would produce better quality code

drifting stump
jaunty marten
drifting stump
#

using globals tho

jaunty marten
#

it's not so reduce performance and it's a bit annoying (I mean doing modules) so PB_peepo_shrug

#

the most important to optimise the calls of it

#

I have it so it's fine

#

I think

#

I can send my current mod after I finish it to u check the code if u want

tired phoenix
#

hello guys

#

do you know any tutorials that could help me implement beards into the game?

#

i mean

#

add hairstyles

round stump
jaunty marten
pulsar rock
#

I can write solid code in C/++/# and Python. I'm new to Lua and my code most definitely isn't the best it can be. Some people might have more experience with TS.

#

Seems reasonable to assume they'll have a much better time (and better quality code) working in TS.

#

In any case, more options is always a good thing.

jaunty marten
#

I mean if u beginner

pulsar rock
pulsar rock
dapper vector
#

Is there an OnReplace function when you eat an item?

shadow geyser
atomic kiln
#

Could anyone help me with getting started modding? I'm aiming to add a powered appliance but I can't find anything relating to power use in the game files

shadow geyser
atomic kiln
#

I've looked through the wiki modding page and through similar mod files. Do I need to be working in LUA or Java to make a powered item?

drifting stump
pulsar rock
#

How does one get a character's profession? hmm

Found it

round stump
pulsar rock
#

Hm, how do you iterate over a TraitCollection?

#

Doing a pairs/ipairs doesn't seem to work?

midnight mica
jagged ingot
round stump
#

TIS hasn't updated the JavaDocs in ages

midnight mica
#

thanks, i'll check it out

pulsar rock
#

@jagged ingot You got a clue as to why this piece of code would throw a MethodArguments.assertValid?

#
local trait = TraitFactory:getTrait(trait_str)
#

trait_str is the correct string

jagged ingot
#

I'll look.

pulsar rock
#

Not sure if I'm once again misusing :

jagged ingot
#
/**
       * @noSelf
       *
       * Method Parameters: 
       *  - (String arg0): zombie.characters.traits.TraitFactory$Trait
       */
      static getTrait(arg0: string): zombie.characters.traits.TraitFactory$Trait;
      /**
       * @noSelf
       *
       * Method Parameters: 
       *  - (Empty): java.util.ArrayList<zombie.characters.traits.TraitFactory$Trait>
       */
      static getTraits(): java.util.ArrayList<zombie.characters.traits.TraitFactory$Trait>;
pulsar rock
#

Aye, it takes a string

jagged ingot
#

It's static.

#

Try using TraitFactory.getTrait(..).

pulsar rock
#

Will do

#

That did it, thanks!

jagged ingot
pulsar rock
#

I'm still low key confused as to why local vars and whatnot use : to invoke their methods, and . seems to be used for static things

jagged ingot
#

It's a combination of two things: The Lua engine being used and Lua code itself.

pulsar rock
#

Is this just a Lua thing?

#

It's super confusing, ngl

jagged ingot
#

Believe it or not, the Lua engine used by PZ isn't actually Lua. It's a reverse-engineered copy.

pulsar rock
#

Kahlua, right?

jagged ingot
#

Kahlua2.

pulsar rock
#

It's ridiculously weird to do it like that, coming from other languages

#

But ah well

jagged ingot
#

So, calling new is different from Java objects and Lua objects. You have to use .new(..) with Java and :new(..) for PZ's Lua objects.

#

: is calling to an instanced object. . is calling to a property.

pulsar rock
#

I see, yeah, that just feels wrong

#

Ah well

jagged ingot
#

Anything you know that has to involve calling . or :new(..) needs to use : for methods that aren't static.

#

I agree, however this is how that works.

pulsar rock
#

Thanks for the info

jagged ingot
#

The problem with Java objects is that you don't get to know what is or isn't static by default.

jagged ingot
pulsar rock
#

Alrighty

#

Nearly done with the Skill Limiter mod

#

Just gotta fix 1 more error ๐Ÿ™

jagged ingot
#

I'm working on a mod that involves modding the core of the game to add support for manipulating music and shaders.

pulsar rock
#

Oh?

jagged ingot
#

Yeah. I'm able to manipulate the GLSL shaders with uniform variables. I also push PCM data from music of my own to them causing some cool effects.

#

Also some stuff with moodles visually affecting the screen.

pulsar rock
#

A bit like that one old mod that did overlays?

#

Depending on mood / health / etc

jagged ingot
#

That mod uses images via Lua drawn as UI textures.

pulsar rock
#

Same general goal, though?

jagged ingot
#

I'm actually modding and sending info the frag shaders.

pulsar rock
#

Just nicer

jagged ingot
#

It's GPU driven.

#

It's so much more than that overlay mod.

pulsar rock
#

Nice!

#

Okay, I feel like this shouldn't be causing issues; But apparently it is.

#

__add not defined for operands

#
            for trait_perk, level in pairs(mapTable) do
                if trait_perk:getName() == perk:getName() then
                    trait_perk_level = trait_perk_level + level
                end
            end
#

The trait_perk_level + level is throwing that error

#

I print the level and it looks like an integer type

#

Like

#

It prints 3

#

Unless that's a string as integer?

#

Or am I missing some weird arithmetic / integer wackyness in Lua?

#

You have a clue? @jagged ingot

#
local trait_perk_level = 0
#

This is where that var is created

jagged ingot
#

Hmm

#

try tonumber(var)

pulsar rock
#

Let's see..

jagged ingot
#

I'm curious if it's a string, or one of the values is nil.

#

If it prints a numeric character, it can still be a string.

#

If you're more curious about type identities in Lua, try using type(var), which puts out a string of the type name itself.

pulsar rock
#

The odd thing is that it was refusing to be concatenated to another string

#

Ah, Lua has a type()?

#

Nice

jagged ingot
#

Oh wait

#
print(type("Hello world"))  --> string
    print(type(10.4*3))         --> number
    print(type(print))          --> function
    print(type(type))           --> function
    print(type(true))           --> boolean
    print(type(nil))            --> nil
    print(type(type(X)))        --> string

btw

#

So Max, you use .. to concat.

dapper vector
jagged ingot
#

It's like PHP.

pulsar rock
jagged ingot
#

Ok cool just making sure.

pulsar rock
#

(Thanks though)

#

But yeah

#

tonumber didn't do it

atomic kiln
#

So this typescript thing, you all seem to be raving about it. Should I be focusing on that over the traditional way?

pulsar rock
#

Time to print a type()

jagged ingot
#

Whenever you see an error like that, assume first a variable is invalid at this point in the code. Work from the spot that errors going backwards.

pulsar rock
#

I miss debugging in other languages, ngl

#

I might just switch over to TS for future mods

jagged ingot
pulsar rock
jagged ingot
#

It's ultimately an option and yours to make. Not negative either way.

jagged ingot
pulsar rock
#

That's honestly really nice

#

And you do a great job at it

#

Very clear stuff ๐Ÿ‘Œ

jagged ingot
#

BTW the typings alone in that TypeScript environment can act as an additional JavaDocs.

#

Take a search tool to it when you have questions. It exposes all public functions that the game does for Lua users.

pulsar rock
#

I'm using IntelliJ atm

jagged ingot
pulsar rock
#

It's doing a nice job in general of showcasing that stuff

#

Just apparently not for the static things

atomic kiln
#

So just due to it being easily searchable it'll be easier to learn?

jagged ingot
atomic kiln
#

I humbly request details

#

You're free to rant

pulsar rock
#

Could do a quick thread?

#

Though the information seems universally useful for anyone interested in modding

#

ยฏ_(ใƒ„)_/ยฏ

jagged ingot
#

Sure.

#

It'll show you errors in many more ways than you can with most Lua writing software. You will see what you're working with and not assume it is a number or a string, object, etc. You have instant access to TypeScript tools like interfaces and abstract classes.

#

You can see what objects contain.

atomic kiln
#

And here I was just planning to write my lua in notepad

jagged ingot
#

Visual Studio Code is free.

#

There's also rich text editors like Sublime Text and Notepad++.

pulsar rock
#

I genuinely do not understand people that proclaim writing code in generic text editors is somehow a better experience than IDEs

atomic kiln
#

Don't expect me to know about that. I'm a spaghetti coder, pure and simple.

#

And yeah, ++ was what I meant

jagged ingot
pulsar rock
#

Right?

#

I'm not missing something?

jagged ingot
#

I genuinely hate people who punch down.

pulsar rock
#

It just feels like people trying to prove something or gatekeep IDEs as something bad

#

Like, holy crap

#

We made IDEs and other tools to make programming more enjoyable and productive :')

jagged ingot
atomic kiln
#

I've just never had a need to learn IDEs because the caveman method works well enough

pulsar rock
#

Oh

#

More power to you if you personally enjoy / are okay with using regular text editors

jagged ingot
pulsar rock
#

We're just talking about the kind of people that feel the need to hate on IDEs / people that use IDEs / people that don't want to use regular text editors

#

On a side note

#

I found the issue

jagged ingot
#

It's for people who try to act as if IDEs are a sin against their God.

pulsar rock
#

The number is apparently Userdata

#

That's Java data, right?

#

Now, how do I convert that hmm

jagged ingot
atomic kiln
#

You're free to despise my uncultured existence

jagged ingot
#

I can make it easy for you to get it.

pulsar rock
#

From a hashmap, from a trait's XP map

#

I have the userdata in a variable

#

Just gotta convert it

jagged ingot
#

Show me the line.

pulsar rock
#
        local mapTable = transformIntoKahluaTable(profession_xp_boost_map)
        for prof_perk, level in pairs(mapTable) do
            if prof_perk:getName() == perk:getName() then
                print("SkillLimiter - Types of level & trait_perk_level below:")
                print(type(level))
                print(type(trait_perk_level))
                trait_perk_level = trait_perk_level + level
atomic kiln
#

I tried out IntelliJ for a bit and was totally lost on how to set up the environment
TypeScript any simpler?#

jagged ingot
pulsar rock
#

(Jetbrains IDE's are fabulous once you get used to them, though)

jagged ingot
#

They have fernflower, which makes me giddy everytime remember that.

#

So trait_perk_level

pulsar rock
#

Nay

#

That's a var I make myself

#

Initialised as 0

#

"level" is the issue

jagged ingot
#

Ah ok

#

If you use `, you can highlight your text better.

pulsar rock
#

I'm aware

jagged ingot
#

Hahah sorry again.

pulsar rock
#

Just figured 0 wasn't necessary :P

jagged ingot
#

Typed a lot of md lately so brain is in that place.

pulsar rock
#

I feel ya

#

I do a fair bit of Discord server management stuff, with a good amount of markdown text blocks to spice things up ๐Ÿ™

#

But yeah

#

level

#

From userdata to a generic number / integer

jagged ingot
#

I don't know where this comes from: ```lua
local mapTable = transformIntoKahluaTable(profession_xp_boost_map)

#

Looking for the Java API call.

pulsar rock
#

Someone tossed me a code snippet & source file to check out

#

The method they referred me to used that

jagged ingot
#
function dump(o)
   if type(o) == 'table' then
      local s = '{ '
      for k,v in pairs(o) do
         if type(k) ~= 'number' then k = '"'..k..'"' end
         s = s .. '['..k..'] = ' .. dump(v) .. ','
      end
      return s .. '} '
   else
      return tostring(o)
   end
end
#

Dumps a table and prints it.

#

Could investigate the table

pulsar rock
#

\lua\client\OptionScreens\CharacterCreationProfession.lua

jagged ingot
#

I have that file open now.

pulsar rock
#

Taken from there

jagged ingot
#

Ah ok

pulsar rock
#

Oh

#

Found it

#

level:intValue()

#

Apparently this works

jagged ingot
#

Epic.

pulsar rock
#

Let's see if the mod works now

atomic kiln
#

This IDE confuses me. I just wanna bash rocks together and make code.
Do I need to install the JS/TS Nightly?

jagged ingot
#

Wait what?

pulsar rock
#

Say, does Lua have something akin to default values for parameters?

jagged ingot
#

Visual Studio Code is a self-updating text editor.

jagged ingot
pulsar rock
#

Ah, hm

jagged ingot
#

It'll be nil by default.

pulsar rock
#

Oh

#

So you can leave an argument open and it'll be nil?

jagged ingot
#

What are you trying to write?

#

What's the statement?

pulsar rock
#

Just wanted to add a bonus parameter in my function

#

But I got it, I think

jagged ingot
#

You can write tuples btw

pulsar rock
#

Can you check for nil through if var then?

#

Like, nil is evaluated as false?

jagged ingot
#

I don't think implicit nil checks as booleans works in Lua but I think it might.

#

write it in the debug console in-game if open.

pulsar rock
#

Let's see if the mod works now

jagged ingot
#

I know explicit literal checks don't work in Lua.

#

AKA null !== undefined in JS.

quasi geode
#

nil is false

#

esentially

#
if nil then
   -- never triggers
end
jagged ingot
#

Good to know. Thanks. Been writing == nil.

#

I think a small project I might work on next is a self-documentation tool so I can write documentation for things like the Java API for PZ and have it insert into say those typings or decompiled Java code.

#

Another idea is to write a simple UI program that templates and has GUI to build custom ISUI Lua classes.

pulsar rock
#

@jagged ingot Mod is alive ๐Ÿ™

#

Now, anyone know how to upload a mod to the Workshop? hmm

jagged ingot
#

Yes. Check out ModTemplate in ../Zomboid/Workshop/.

pulsar rock
#

Will do

jagged ingot
#

You toss your mod into the ../mods/ folder in that.

#

Launch steam-enabled PZ, go to workshop tab, and follow what it says.

#

BTW you should copy the ModTemplate folder and customize it ofc.

jaunty marten
# jagged ingot ```lua function dump(o) if type(o) == 'table' then local s = '{ ' ...

more clear

local strrepeat, pairs, type, format, tostring, print = string.rep, pairs, type, string.format, tostring, print

local function toPlain(tbl, indent, out)
    local isend = not out
    out = out or "{\n"

    indent = indent or 1
    for k, v in pairs(tbl) do
        local tabs = strrepeat("     ", indent)
        formatting = tabs .. tostring(k) .."  =  "
        if type(v) == "table" then
            out = out .. formatting .."{\n"
            out = out .. toPlain(v, indent + 1, "")
            out = out .. tabs .."},\n"
        else
            out = out .. formatting .. (type(v) == "string" and format("%q", v) or tostring(v)) ..",\n"    
        end
    end
    if isend then out = out .."}\n" end

    return out
end

function PrintTable(t)
    print(toPlain(t))
end
mellow karma
wet dune
#

@willow estuary How would I just have a single outfit for every zombie?

bitter hedge
#

anyone know where i can find the file to make a custom spawnpoint for single player

median lagoon
#

Hello im starting into moding. What i shuld know or have as begginer?

atomic kiln
#

So when TS for PZ says to install NPM in main folder, does it mean the VSCode folder? Or my project folder?

jagged ingot
#

So in the project's folder, run it.

#

It sets up all the dependencies and plugins in the environment that run when compiling the code.

#

It's a NodeJs environment and npm is the "Node Package Manager".

jagged ingot
midnight mica
#

anyone have any idea why setContainerCapacity does not seem to work server side?
it works whenever i use it when the vehicle is created, but once its created i can't change the container size anymore, seems weird

static oyster
#

anyone knows the line of code that tells if the zombie can see the player or not ?

thin hornet
#

Ill try to make a tutorial how it can be extended and used

#

but basically i might be using this for all my future mods so I ll keep it up to date too but also minimalistic

drifting ore
#

how do i override

#

a modded item?

drifting ore
#

If i dont use item tweaker

prisma wren
#

hey can someone help me figure out how to make a VHS + book mod

#

im a complete beginner in JS

#

and iโ€™ve never done any modding

jagged ingot
#

JavaScript?

prisma wren
#

yeah

jagged ingot
#

PZ uses Lua. I bet you already know this.

#

Are you familiar with Lua's syntax?

prisma wren
#

forgot

#

a bit

frosty falcon
#

break it down to smaller tasks and work on those

jagged ingot
#

I'm sure that the mod would be simple enough to use Lua by itself, however if you know anything about TypeScript and feel more familiar with JavaScript, you have the option to use TypeScript.

I think the majority of your mod would be item scripts.

jagged ingot
frosty falcon
#

lots of small victories > one large project challenge for newer ppl imo

jagged ingot
#

Isn't there a guide somewhere that's generally used for types of mods for items for PZ?

#

I remember some website that had a lot of tutorials.

frosty falcon
#

so depending on what you're doing with the book for example, you could finish that part first make sure it's all working and try the next bit

#

I say this because you can lose motivation if you get stuck on a big project, that said yours seems fairly straightforwad, good to begin with

prisma wren
#

i know that part from developing stuff

frosty falcon
#

decide what you're gonna do first, try it, come back if you get stuck

prisma wren
#

alright iโ€™ll do that

frosty falcon
#

sounds good, lots of helpful people in here :)

jagged ingot
#

If you have any issues with Lua and can't find answers after looking it up on Google, it isn't a sin to ask here.

frosty falcon
#

I mainly learned from picking apart other peoples basic mods when I started

#

didn't quite find any solid tutorials if I'm honest

jagged ingot
#

I learn from breaking and reverse engineering hahaha

frosty falcon
#

learning you can use java too was super handy

#

the public classes

jagged ingot
#

Yeah. 95+% of my modding in PZ is Java.

#

Oh, and Kotlin.

frosty falcon
#

I haven't actually checked whats exactly exposed to kahlua, but seems a good majority or all of the public java classes are availabl

jagged ingot
#

The latest JavaDocs rendering is 41.65 though. With 42 on the horizon, this could be problematic.

frosty falcon
#

ye I mean this stuff

#

I think its just a selected set of exposed classes

jagged ingot
frosty falcon
#

ye its fine

jagged ingot
#

Those items are recursively exposed.

#

The typings I'm referring to only shows what Kahlua2 exposes through PZ.

#

JavaDocs like the ones I know shows more than what's exposed. This could be confusing to someone who tries to invoke unexposed content.

frosty falcon
#

thats what I'm trying to understand, which parts of the javadoc is unexposed

#

not exposed

jagged ingot
#

I can see this being confusing for people who don't understand.

frosty falcon
#

is it simply all public java classes

#

that I can view in the decompiled code

jagged ingot
#

My experience helps me know what is and isn't.

frosty falcon
#

or did this javadoc come from a generated subset of classes

#

only answer I suppose is to try

jagged ingot
#

This one specifically comes from third-party. It means that the code from the game was ran through a JavaDocs tool.

frosty falcon
#

yea dw

jagged ingot
#

Same with the official one from 2015.

frosty falcon
#

was just confusing myself a lil

jagged ingot
#

Items that are type are exposed but not directly.

frosty falcon
#

oh this is quite nice and organised

jagged ingot
#

From what I can see, the typings were generated where classes in the zombie package are recursively unzipped and compiled so I can still see some classes here that might show things that aren't accessible. It is based on that codeblock you see in LuaManager.

#

It'll be closer to what you'd expect to see exposed.

#

Even then you'll see where that call ends up.

frosty falcon
#

gotcha

jagged ingot
#

Seeing the actual types for parameters, return types, and static fields helps though.

#

JavaDocs has that too.

frosty falcon
#

yea haven't used much of java so far but theres a lot of useful things in there

#

often you don't need a lot of it tbh

#

unless you're going real deep with your mods

jagged ingot
#

๐Ÿ™‚

frosty falcon
#

its pretty nice being able to make an entire bicycle mod without even referring to javadocs

jagged ingot
cosmic condor
#

none of my mods is java lol

frosty falcon
#

I'm curious why its different to the decompiled code, what exactly is the typings you have

jagged ingot
#

The comment on the bottom is for the next one below it.

frosty falcon
#

ohh ok I misread it

jagged ingot
#

It's TypeScript so method signatures differ from say Java where multiple methods with non-erasure parameters can be a thing.

#

They have to be combined to follow the TS syntax.

frosty falcon
#

oh you're using it for typescript

#

that makes sense now

jagged ingot
#

It's actual typescript.

frosty falcon
#

yeye

jagged ingot
#

That GitHub project is actually a TypeScript environment to mod PZ using it.

frosty falcon
#

I thought you were telling me you used it instead of java, but without the context of typescript xd

#

was like, wat the

#

but it makes sense, this is just directly matching the java... can't think of the right words rn ugh

#

binding them

#

now the question is

#

will this project be maintained

#

but in the dev world, I guess that's always the question

jagged ingot
frosty falcon
#

could be

jagged ingot
#

Well I know the author.

frosty falcon
#

curious if someone else would take the mantle