#mod_development

1 messages · Page 236 of 1

echo lark
#

or is it ZombRand(1, 101)?

bronze yoke
#

1, 101

drifting ore
#

Guys, explain to me what a clothing GUID is, do I have to create new xml files for clothes, can I just refer to an already created file in the items parameters? What is the threat to me?

violet shell
#

I would do ZombRand(99)+1 if you want a result between 1 to 100.

#

I understand, maybe syntax is not the right word. What I meant was I'm unsure if my for loops are written correctly and do what it's meant to do. I'm also unsure if my inventory checks.

echo lark
violet shell
#

dunno, I usually do as I said, but I'm a dabbler 😄

bronze yoke
#

i'd argue doing an addition probably makes it ever so slightly slower

bright fog
thick karma
thick karma
bronze yoke
thick karma
#

I was thinking he wanted 1-101

#

Wait he did

#

lol I got confused reading how he changed it.

#

Originally we were discussing 1, 101

#

1 - 100 => (1, 101) => (100) + 1...

(0, 101) something else entirely.

violet shell
thick karma
thick karma
violet shell
#

I was so unsure of my code that I was asking if the for loops and the inventory checks were theorically ok. And then the server I'm running started so I had to switch to admin mod 🙂 I'll run it later tonight and paste the stack trace 🙂

thick karma
# violet shell I was so unsure of my code that I was asking if the for loops and the inventory ...

Well it's one thing to ask what a for loop should look like or how to decorate a specific function, but generally speaking if you just want to know whether an entire file has errors, that is the purpose of compiling them (i.e., this is something we all learn by launching the game with them loaded).

If you're stumped by an error message, definitely ask for clarification, but if you just want to know whether a file will throw a syntax error somewhere, you should just try running it and follow the error messages to fixing it. Asking humans to syntax test for you by reading is honestly inefficient... Computers read faster than people do.

#

Also, learning to follow the error to the solution is a vital skill in this process, so I'm reluctant to tell you where an error is before you've even seen the message it's going to produce.

violet shell
#

Ok, I am grateful, you're right, to improve myself I must see the issues and confront, and then solve them 🙂 (eventually with some help 😉 )

thick karma
#

In VS Code or any other worthwhile editor

#

Once you get stuck or get the errors sorted, I'll do my best to help with stuff the computer can't show you very easily.

violet shell
#

I use Notepad++

thick karma
#

I don't know it well but I'm sure it has something for Lua

ornate sand
#

Does anyone have any idea what Bob_Reload_Rifle_Rack.X is in the anims_X folder?
I noticed that every other type of rack animation is assigned. Bolt action for pretty much every long gun, dbshotgun_rack for double barrel shotguns etc.
I was wondering could it be the unassigned lever action rack animation? Since the game does have a lever action rifle in it, but it simply isn't in the script or lua files yet.

#

I also don't have the software to view .x animations so I can't just open it up and see what it is

marsh sonnet
#

Has anyone ever looked into SQL Support for zomboid servers?

drifting ore
# verbal yew https://www.guidgenerator.com/online-guid-generator.aspx

Thanks a lot for the diagram, it brings more clarity to all of this. But I'm also interested in the technical part. Why, in principle, is there a unique GUID and xml file for each piece of clothing? Let's say that the model I need already exists in the game. In this case, can I create, for example, three different items whose clothingItems refer to the same file? Or will it just break the game?

verbal yew
#

if u want full model from game into zombie like item, without any changes, just copy it from vanilla fileGuidTable.xml

#

without xml into clothes

#

like i do for vanillas items (i use it on my zombies)

#

or if you want create new item, model full based on vanila, just doit for item, like:
ClothingItem = Shoes_ArmyBoots, for example into scripts

drifting ore
#

Oh, I think I got more clarity on how it works. And thanks a lot for the advice that I can copy the file from vanilla. Just one small question: if I do this, will I need to replace the GUID there if I plan to keep the original item in the game and add another one?

verbal yew
drifting ore
#

Thank you very much, you really helped me a lot! 🙏Good luck developing your mods

verbal yew
#

ClothingItem = Shoes_ArmyBootsMYMOD. into scripts param

#

for example

#

Shoes_ArmyBootsMYMOD.xml be same as vanillas Shoes_ArmyBoots.xml, but another GUIDs

drifting ore
#

Can I ask one more question. should the GUID be the same in the fileGuidTable file and in the clothingItems file for the same piece of clothing? It's just that when I read the steam guide, they used different ones, but I had doubts that I should use the same one

verbal yew
drifting ore
#

Thank you spiffo ❤️

verbal yew
true plinth
#

Hello all,
i have a strange issue : i created a very simple recipe, the most simple as possible, but i cannot see this recipe in my game.
Nothing in the log.
the recipe is :

module Base
{
    recipe create simple object
    {
        RippedSheets,

        Result:Bowl,
        Time:150.0,
        Category:Cooking,
        NeedToBeLearn:false,
        Override:true
    }
}

I put this simple recipe as usual in the correct path of the mod :
WorkshopMod/Contents/mods/IsaRepair/media/scripts/IsaRepair_recipes.txt

and i know that the mod was loaded, because i have some lua code correctly loaded.

But i cannot see the recipe in the game, really strange unhappy

#

ok i understood : despite the fact that my "in dev mod" was in my personal "Workshop" folder, the game persist in using the global mod directory 🤦‍♂️

thick karma
#

If you wanna play live version of a mod while mid-update, gotta move item out of Workshop folder.

vestal gyro
#

I feel like that happened to every modder here atleast once

echo lark
#

is it possible to put a mod requirement for a script file? like "If X mod is activated then load the scritpts file"

echo lark
mellow frigate
#
local modInfoTK = getModInfoByID("TheyKnew")
if not modInfoTK or not isModActive(modInfoTK) then
    return--handle : compat not required
end
--condition at start of a file to handle compatibility with "TheyKnew" mod
echo lark
mellow frigate
echo lark
# mellow frigate no it is for lua scripts 🙂

oh, im trying to put a condition in my recipe script file. basically made my own version of a packing mod, and wanted to add in modded items without having to do a seperate module. so was trying to put a check in the recipe scripts somehow to check if a mod is active

mellow frigate
verbal yew
#

variation to work with mod

#

But you will have to create more recipes... most likely... In order to give out some, hide some

winged stirrup
#

I made a new weapon and I want to make it function as a wrench. How should I modify the Lua file?

echo lark
violet shell
#

@thick karma Thanks mate ! I managed to debug my file, but I still have issues I can't fix.

#

Here is the first one :

mellow frigate
#

yes my mistake

#

I do not understand: ```lua
item = itemInBag:getDeviceData():setIsTwoWay(false)

#

what is itemInBag ?

violet shell
#

it's in the for loop

#
for _,itemInBag ... do
mellow frigate
#

it is not set in its current context. so it is nil which is your error

violet shell
#

my first issue is that my testIfWalkieTalkie () function is getting me an error (first stack trace in my previous message)

mellow frigate
#

second loop, not first

violet shell
#

ok so I should add a local itemInBag = nil ?

mellow frigate
#

no you should set it or not use it in the second loop

#

after a copy paste re-read your code.

#

check after the comment ```lua
-- check bags equipped in hands

violet shell
#
function InjectionsRequests.fixInventory(player, items)
    local itemToRemove = items:get(0)
    -- check backpacks/fanny packs
    local locationList = {"Back", "FannyPackFront", "FannyPackBack"}
        for _,location in pairs(locationList) do
            local bag = player:getWornItem(location)
            if bag and instanceof(bag, "InventoryContainer") then
                local container = bag:getInventory()
                container:DoRemoveItem(itemToRemove)
            -- code for removing the items (example: container:Remove(item))
            end
        end   

    -- check bags equipped in hands
    local itemA = player:getPrimaryHandItem()
    local itemB = player:getSecondaryHandItem()
    local itemList = {itemA, itemB}
        for _,item in pairs(itemList) do
            if item and instanceof(item, "InventoryContainer") then
                local container = item:getInventory()
                container:DoRemoveItem(itemToRemove)
                -- code for removing items
            end
        end
    player:getInventory():DoRemoveItem(itemToRemove)
end
#

This code is working (from another of my mods)

#

(btw fixed the "end" problem 😉 )

violet shell
pulsar rock
#

Hey hi, is there a way to reliably profile mod impact?

neat herald
#

I was wondering what the ordinal numbers correspond with. I understand it is specifying a resource but what resource is it calling? Is there a chart I am missing

verbal yew
neat herald
#

Going to have to redo all my recipes but such is life 🤣

#

Would anyone happen to know where I can find the file that contains function Recipe.OnGive.Cooking
Ours have borked 😅

neon bronze
#

recipecode.lua in server

neat herald
red tiger
#

I'm thinking about resuming work on my ZedScript support extension in vscode again..

#

I was at a point where the logic parser for errors and warnings were being implemented.

#

AFAIK, I'm the only one who has built syntax-highlighting and some documentation / Intellisense support for ZedScript.

zenith igloo
#

is there a limit of how many times update is called per second (for OnPlayerUpdate or OnTick etc if there is any)

#

is it the direct fps or limited to 60 for stability ?

#

for example wanted to increase sickness value per tick, is there a way to calculate it to be called 60 times per second for all to balance it for all players? or is it not needed?

thick karma
#

Then it'll be not only the same rate across players on a server, but same rate across game speeds.

zenith igloo
#

I need to use OnPlayerUpdate since it will be called under conditions so it wont be heavy to have effect much I believe

#

I mean it needs to be called on tick

#

just dont want it to create problems because someone is playing with 120 fps since it would double the amount for example endurance recovery

bronze yoke
#

it's tied directly to framerate

thick karma
bronze yoke
#

use a delta to modify it by the framerate

zenith igloo
zenith igloo
thick karma
#

But again, even if you modify to work on frame rate, you'll at least need a sandbox option for rate of sickness change to make it work right for different game speeds

bronze yoke
#

there's provided by the GameTime object (getGameTime()), there's a few different ones for different needs

zenith igloo
#

Im not mainly working on lua but work on C# so kinda had no clue on lua kek

bronze yoke
#

getMultipliedSecondsSinceLastUpdate() is probably the most general use one

zenith igloo
#

just wanted to make sure there wouldnt be difference for players since Im increasing values within update method that number of calls changes within fps

thick karma
#

@❓: I'm saying OnTick behavior modified to happen the same number of times per second may still happen too fast or too slow if people are playing 15 minute days as opposed to realtime.

zenith igloo
thick karma
#

If we're talking about how fast someone gets sick it seems that you would want to adjust the rate such that playing on 15 minute days doesn't make you sick 96 times faster than playing in realtime.

bronze yoke
#

it'd make you sick at exactly the same rate in real time

thick karma
#

Right but in game time it would not make sense

bronze yoke
#

whether or not you want it to scale with day length is a per-mechanic choice and deltas are provided for both needs

zenith igloo
#

I dont really care about the gametime tbh just want it to be equal amount of calls for all players

thick karma
#

Fair I was just saying based on his simple goal of adjusting illness level 60 times per second for everyone

zenith igloo
#

but what albion sent should end up in the same road so

thick karma
#

It would feel strange getting sick at the same rate if your days should be moving much much faster

zenith igloo
#

sickness was just an example

thick karma
#

But it's something to consider

zenith igloo
#

I mean I think I got what you are saying but Im not planning to add it on sickness value but currently on endurance value

bronze yoke
#

you wouldn't need a sandbox option either way, you can just multiply by ('base' day length / current day length)

zenith igloo
#

If I do I will keep it in my mind tho

#

thanks both of you guys ❤️

thick karma
#

So player gains endurance 60 times per second?

zenith igloo
#

issue was that different fps amounts would give different results

thick karma
zenith igloo
#

since there is no FixedUpdate() so equal to pz terms no event that is called 60 times per second for all

bronze yoke
#

yeah, pz doesn't really seem to get the idea of a tick rate 😅

thick karma
#

Anyhoo I think it's clear now lol

violet shell
thick karma
#

I will take a look when I boot up PC. On phone atm.

#

@violet shell

verbal yew
#
local last_event = 0;
local function OnTick()
  local now = getTimeInMillis(); 
  if now - last_event > N*1000 then -- where N - realtime sec
    -- DO STUFF HERE
  last_event = now
  end
end

Events.OnTick.Add(OnTick)
bronze yoke
#

the problem with this approach is it doesn't account for long frame times

#

if i use this to do something 60 times a second, and my game lags and i only have 30 frames that second, it will only happen 30 times

#

this approach only stops it from going too fast, it doesn't prevent going too slow

zenith igloo
#

Im not really sure what would be the difference if I dont match everyones call amount tbh but at least I have solutions now if it becomes an issue kek

#

thanks for responding

red tiger
#

Good afternoon.

zenith igloo
#

good night :3

bronze yoke
#

if you wanted a framerate safe interval i'd do it more like this```lua
local intervalMs = 1000 / 60 -- 60 times a second
local last_event

local function OnTick()
last_event = last_event or getTimeInMillis() -- regrettably cannot be initialised outside of the loop because the first tick could be a very long time after lua load
local numTicks = (getTimeInMillis() - last_event) % intervalMs

-- either this:
for i = 1, numTicks do
    -- do stuff here
    last_event = last_event + intervalMs
end

-- or, if your code can just have its effects multiplied safely, this is more performant:
if numTicks < 1 then return end
-- do stuff here, multiply whatever it does by numTicks

last_event = last_event + intervalMs * numTicks

end

Events.OnTick.Add(OnTick)

zenith igloo
#

damn Im not really used to see multiple people trying to help this quick love yall ❤️

torn igloo
#

Any idea why player:getInventory() doesn't work on OnClientCommand? It basically empty.

bronze yoke
#

player inventories aren't synchronised, you can only access them on the client they belong to

bright fog
#

That's actually fairly important to know

#

So like if you want to access the inventory of another player you got to do some weird stuff?

thick karma
# violet shell I'm still getting an error with my first function.

attempted index: getName of non-table: null is the primary descriptive text needed to understand why your error is happening on line # 10 of Asilar_RadioOneWayOnBelt_bis.lua. It is trying to call getName on a variable that is not a table, and is in fact not even initialized to have a value. In this case, the variable is item. When you say item:getName(), this is an attempt to access getName of item (meaning in this case a function available to the item), but item is nonexistent and not even a table that could be used this way, so the compiler says you're trying to access getName of non-table: null.

I'm gonna take a shot in the dark and guess that this happens when you unequip a primary hand item, because I suspect this would trigger OnEquipPrimary with nil as the provided inventoryItem. If this is the problem, you simply need to check that item exists before you try using it:

local function onEquipRadioToggle(player, item)
    print("Entering onEquipRadioToggle")
    if not item then return end -- Bingo Bongo.
    -- Check if radio is being equipped
    if testIfWalkieTalkie(item) == true then 
        -- etc. etc. etc.
end 
#

@violet shell Make sense?

#

@violet shell Here's a bonus thought:

local RadioOneWay = {}

RadioOneWay.walkieTalkies = {
    ["Base.WalkieTalkie1"] = true,
    ["Base.WalkieTalkie2"] = true,
    ["Base.WalkieTalkie3"] = true,
    ["Base.WalkieTalkie4"] = true,
    ["Base.WalkieTalkie5"] = true
}

local function testIfWalkieTalkie(item)
    print("Entering testIfWalkieTalkie")
    
    if RadioOneWay.walkieTalkies[item:getName()] then
        print("Item is a WalkieTalkie")
        return true
    else
        print ("Item isnot a WalkieTalkie")
        return false
    end
end
#

(I would honestly move all of your functions into a module, and then return it by doing return RadioOneWay at the end of your entire file.)

#

The code above reduces the amount of work your conditional needs to do, and also has the added benefit of letting modders add their own walkie talkies if they ever want to easily implement compatibility with your mod.

#

And the check will take the same amount of time for 100 walkie variants as it does for 5.

earnest minnow
#

any vehicle modders able to tell me if a higher steeringClamp value means better or worse steering angle?

#

did you ever find the answer to this?

faint jewel
#

no?

faint jewel
#

tried to make a mower turn in a very tight circle. it didn;'t work

earnest minnow
frank elbow
#

It looks like Poltergeist answered a few messages after the one you replied to

red tiger
faint jewel
#

/me runs away.

violet shell
# thick karma <@275035810074722305> Here's a bonus thought: ```lua local RadioOneWay = {} Ra...

It makes a lot of sense, and thank you to explain me the way you did to understand better the traces. I was on that understanding, but didn't know why I got that error. Because it's said that Events.OnPrimaryEquip has (character, item) as arguments. So I don't understand the error. But if I understand what you say, it's because the the function is called 2 times : one time for the unequipped item and then item is nil, and then for the equipped item in which case I will get my item, right ?

thick karma
gilded hawk
#

Guys, am I blind or there is no "On Cell loaded" event?

bronze yoke
#

the game doesn't load in cells

gilded hawk
#

Uh, so if I want to run event only when a cell is loaded, I have to use LoadGridsquare take note of the cell, and then wait for the a new LoadGridsquare in a different cell?

bronze yoke
#

pretty much

#

what are you trying to do?

gilded hawk
# bronze yoke what are you trying to do?

I'm yet again, trying to implement my destroyed/bombed cities mod, and I want it to happen automatically by having the mod check the count of buildings and zombies in a cell and if the Number of both is high enough, then the mod will assume it's a city, and generate a lot of explosions on it.

bronze yoke
#

you won't really be able to do that, there isn't usually even one entire cell loaded

gilded hawk
bronze yoke
#

oh yes, that might work

gilded hawk
#

😄

#

Now my "only" issue is hoping that that variable is exposed 👀

violet shell
# thick karma The code above reduces the amount of work your conditional needs to do, and also...
local RadioOneWay.walkieTalkies = {
    ["Base.WalkieTalkie1"] = true,
    ["Base.WalkieTalkie2"] = true,
    ["Base.WalkieTalkie3"] = true,
    ["Base.WalkieTalkie4"] = true,
    ["Base.WalkieTalkie5"] = true
} [...]
if RadioOneWay.walkieTalkies[item:getName()] then
        print("Item is a WalkieTalkie")
        return true

Can you explain me how this works ? when you call RadioOneWay.walkieTalkies[item:getName()], you asks to compare item:getName() with each entry of RadioOneWay.walkieTalkies {} ?

gilded hawk
# bronze yoke oh yes, that might work

Ugh, apparently, I can't access this variable 😦

getWorld():getMetaGrid().Buildings -- retuns `nil`
// from: IsoMetaGrid
public final ArrayList<BuildingDef> Buildings = new ArrayList();

If I'm not mistaken, there should be a way to manually expose fields, right?

bronze yoke
thick karma
bronze yoke
#

i don't remember how you do it manually, it's usually done with some weird string manipulation

thick karma
thick karma
thick karma
thick karma
thick karma
#

Sorry for my limitless ability to typo; it cannot be contained.

hardy skiff
#

I'm in the process of completely rewriting the distribution method for Brita's Weapons Pack for use on my own private server. Which will have a separate table to determine firearm's spawning rate. Feel free to let me know what your opinions are on this! If it goes well, I may get in touch with Brita to try to integrate it into the main mod...

#
    id = "FN_57", -- base id of the firearm
    type_category = "pistol", -- general categories of the firearm
    type_action = "semi", -- type of action of the firearm
    type_region = "EUR", -- The region where the weapon originated - and usually the area where it was primarily used.
    rarity = 2, -- Adjustment factors affecting their rarity after being affected by sandbox options. 
    
    -- 1 = Firearms that are commonly used by individuals, LEO, or MIL. These are usually popular sellers in gun stores, or standard issue weapons for military/police forces.
    -- 2 = These types of firearms are more niche for individual gun owners, or are special purpose weapons for LEO/MIL, not generally issued.
    -- 3 = Exotic firearms, rarely seen by the public. Such firearms are either expensive customized items or having very particularly unique uses.
    -- 4 = At this point, the weapons are either ancient antiques or some prototypes, which developer decided that supposed to be extremly hard to find.

    isMIL = true, -- If firearm is used by military forces
    isLEO = true, -- If firearm is used by law enforcement agencies
    isCIV = true, -- If firearm can be obtained by general public, which is not an NFA item (a machinegun, short-barreled rifle, short-barreled shotgun, or destructive device).
}```
thick karma
#

Sorry in what context? @bright fog

#

... in a function means all the variables that get passed after named ones...

gilded hawk
stone gale
#

Whoever you were, thank you for the tags.FifiHuggif

gilded hawk
#

Oh yeah I found my old baby code, not the most polished code, but damn it works 😄

-- Remember, this only work with "public" fields, not "private" or "protected"
local function getClassFieldValueByName(classInstance, fieldName)
  local cacheKey = tostring(classInstance) .. fieldName

  if fieldCache[cacheKey] then
    return getClassFieldVal(classInstance, fieldCache[cacheKey])
  end

  local fieldsCount = getNumClassFields(classInstance)
  for i = 0, fieldsCount - 1 do
    local field = getClassField(classInstance, i)

    if tostring(field):sub(-#fieldName) == fieldName then
      fieldCache[cacheKey] = field

      return getClassFieldVal(classInstance, field)
    end
  end
end
local metaGrid = getWorld():getMetaGrid()
  local buildings = getClassFieldValueByName(metaGrid, 'Buildings')
  MxDebug:print('LoadGridsquare - metaGrid.Buildings', buildings)
  -- Prints correct value: [zombie.iso.BuildingDef@5e011ce2, zombie.iso.BuildingDef@1fa51c80, zombie.iso.BuildingDef@74153c4b, zombie.iso.BuildingDef@655ec585, zombie.iso...
#

Uh, that's interesting, the game already has loaded "6653" buildings 🤔

violet shell
thick karma
#

Yep

#

Exactly

violet shell
#

nice 🙂

thick karma
#

You can also write functions in basic variable format (or assignment format or whatever you want to call it):

Module.functionName = function(item)

end```
violet shell
#

With this method, do I still need to add a check in the main function :
if not item then return end -- Bingo Bongo.?

violet shell
thick karma
#

You only need that check in the main function because if you guarantee item exists right away then every function you call from there should have an item to handle

violet shell
#

ok

drifting ore
#

how can i update a mod to new game version if i lost the mod files

violet shell
#

subscribe to the mod, get the files in your steam folder, copy/paste them ?

drifting ore
#

i dont need access to the original ones?

violet shell
#

Did you ever uploaded the mod on steam workshop ?

violet shell
thick karma
#

returning the module has to be the absolute last thing that happens in the file

violet shell
#

ok

thick karma
violet shell
#

So I have to create another file with only the calls ?

thick karma
#

(Unless the function needs to be added after file load for some reason)

violet shell
#

What I don't get, is when the code is ran by the server if the Call (Events.OnEquipPrimary.Add) is inside the module

gilded hawk
#

Does anyone know where the value of currentPopulation and desiredPopulation are coming from when looking into java\popman\MPDebugInfo.java? I can't seem to find reference to this anywhere else 😦

thick karma
#

Eh?

thick karma
#

Nothing changes

#

Just need to change the Add call to reflect new full function name

#

Add(Module.functionName)

#

It'll work exactly the same way

violet shell
#

ok thanks 🙂 I'm a little lost about those modules and how it works exactly, but I trust you. Made the changes, gonna try this now, I'll come back with Stack Traces 😄

#

I have a side question about walkies & VOIP. What is the 16000 range unit ? tiles ? Because on my server, we got some weird bugs with walkies, when we can't hear each other even if we are inside the range (at least we thought we were). Is there some known issues about that or have I a mod interfere ?

thick karma
thick karma
violet shell
echo lark
#

is there no way to hide hair and beard without using the 0 mask?

violet shell
#

The error is in this loop. itemInBag is buggy.

        -- check in bags
        local locationList = {"Back", "FannyPackFront", "FannyPackBack"}
            for _,location in pairs(locationList) do
                local bag = player:getWornItem(location)
                if bag and instanceof(bag, "InventoryContainer") then
                    local container = bag:getInventory()
                    for _,itemInBag in pairs(container) do
                        if RadioOneWay.testIfWalkieTalkie(itemInBag) == true then
                            print("Radio in backpacks, IsTwoWay = "..item:getDeviceData():getIsTwoWay())
                            print("Toggle TwoWay to False")
                            -- Toggle code
                            item = itemInBag:getDeviceData():setIsTwoWay(false)
                            print("Result IsTwoWay = "..item:getDeviceData():getIsTwoWay())
                        end
                    end
                end
            end
#

it's the for loop that doesn't work

#

is it just :

local itemInBag = bag:getInventory()
for _, itemInBag do
-- the stuff to do
end
``` ?
#

I don't understand how to cicle through all the items in "bag" to check if it's a walkietalkie.

dawn acorn
#

Does anyone have the api for gun events?

#

Ala. magazine attachment, attachment attachment

winged stirrup
#

I made a mod item, but what should I do if I want to make it function like a wrench?

coarse sinew
drifting ore
#

How i can run my custom mods? I used to put the mods in the mod carpet but It doesnt work anymore

bright fog
bright fog
winged stirrup
# coarse sinew Base.Wrench is hardcoded for use on vehicle mechanics. Looking over the ISVehicl...

I added a weapon to the file but it doesn't work. if part:getId() == "Engine" and not VehicleUtils.RequiredKeyNotFound(part, self.chr) then
if part:getCondition() > 10 and self.chr:getPerkLevel(Perks.Mechanics) >= part:getVehicle():getScript():getEngineRepairLevel() and (self.chr:getInventory():contains("Wrench") or self.chr:getInventory():contains("KW_MagicWand")) then
option = self.context:addOption(getText("IGUI_TakeEngineParts"), playerObj, ISVehicleMechanics.onTakeEngineParts, part);
self:doMenuTooltip(part, option, "takeengineparts");
else
option = self.context:addOption(getText("IGUI_TakeEngineParts"), nil, nil);
self:doMenuTooltip(part, option, "takeengineparts");
option.notAvailable = true;
end
if part:getCondition() < 100 and self.chr:getInventory():getNumberOfItem("EngineParts", false, true) > 0 and self.chr:getPerkLevel(Perks.Mechanics) >= part:getVehicle():getScript():getEngineRepairLevel() and (self.chr:getInventory():contains("Wrench") or self.chr:getInventory():contains("KW_MagicWand")) then
local option = self.context:addOption(getText("IGUI_RepairEngine"), playerObj, ISVehicleMechanics.onRepairEngine, part);
self:doMenuTooltip(part, option, "repairengine");
else
local option = self.context:addOption(getText("IGUI_RepairEngine"), playerObj, ISVehicleMechanics.onRepairEngine, part);
self:doMenuTooltip(part, option, "repairengine");
option.notAvailable = true;
end
end

coarse sinew
#

Have you changed all the functions that check for Wrench ?

#

Also you can put the code in a code block like this, using ```:

local test = "";
winged stirrup
#

I just added it to the script settings and ISVehicleMechanics.lua file.

#

Where can I find and change the wrench check function?

coarse sinew
#

Oh wow, looking further, it's not that easy, you also have to modify the script of each car to accept your wrench as a fixer. And that's not even considering modded cars.

bright fog
#

<@&671452400221159444>

lost slate
bright fog
thick karma
thick karma
# violet shell The error is in this loop. itemInBag is buggy. ```lua -- check in bags ...

You use pairs with tables; for a Java-based item container, there are other ways to search for what you need. There are many recursive search functions for grabbing stuff from an item container built into the game, so you don't need to write the recursion from scratch, just visit Zomboid Javadoc and figure out which one works.

I think this might return what you're looking for, given the type of the item:

getAllTypeRecurse(String string, ArrayList arrayList)

However there might be a better option that lets you use a search function instead of matching type, which would require fewer loops through inventory to check for the right item.

#

@violet shell you might want
public ArrayList getAllEvalRecurse(LuaClosure luaClosure)... The lua closure may be referring to a Lua function that can be used to pick items. That would be useful here.

bright fog
#

Or some shit like that

thick karma
#

That's what I was thinkin

#

@violet shell What we're saying is the function (the "Lua closure") probably needs to be of the form

function isDesired(item)

   (-- pseudocode)
   if item:getType() contains "WalkieTalkie" then
      return true
   end

   return false
end
bright fog
#

yeah

#

That's probably something like that

#

You most likely find examples of it in the base game code

bronze yoke
#

it's a bug caused by an admittedly pretty vital last minute security change

violet shell
#

OK thanks a lot 🙂

sour island
coarse sinew
#

Actually that could be added to the Install and Uninstall tests

violet shell
#

@thick karma @bright fog Thanks for your help, I gonna dig with that 🙂

bright fog
#

Np

violet shell
#

I found this in vanilla code :

containers = ISInventoryPaneContextMenu.getContainers(playerObj)
    -- Test with each source as selectedItem
    for i=1,containers:size() do
        local container = containers:get(i-1)
        for j=1,container:getItems():size() do
            local item = container:getItems():get(j-1)
            if item ~= bag then
                local valid = RecipeManager.IsRecipeValid(recipe, playerObj, item, containers)
                if not valid then
                    print('  valid='..tostring(valid)..' with selectedItem='..item:getFullType())
                    for k=1,#itemText do
                        print(itemText[k])
                    end
                end
            end
        end
    end

Maybe it can help ?

bright fog
#

I don't know what you're trying to do exactly so uh idk

violet shell
#

That bug in my code is really driving me mad

#

I'm trying to check for specific item in all the inventory of the player (inventory, worn bags, equipped bags in hand)

echo lark
echo lark
violet shell
#

I have the same code working in 1 mod and don't in another

#
    -- This one is from my Biocoded injection mod and is working 
    -- check backpacks/fanny packs
    local locationList = {"Back", "FannyPackFront", "FannyPackBack"}
        for _,location in pairs(locationList) do
            local bag = player:getWornItem(location)
            if bag and instanceof(bag, "InventoryContainer") then
                local container = bag:getInventory()
                container:DoRemoveItem(itemToRemove)
            -- code for removing the items (example: container:Remove(item))
            end
        end  
    
    -- this one is from RadioOneWay mod and is not working
    -- check backpacks/fanny packs
    local locationList = {"Back", "FannyPackFront", "FannyPackBack"}
        for _,location in pairs(locationList) do
            local bag = player:getWornItem(location)
            if bag and instanceof(bag, "InventoryContainer") then
                local container = bag:getInventory()
                for _,itemInBag in pairs(container) do
                    if RadioOneWay.testIfWalkieTalkie(itemInBag) == true then
                        print("Radio in backpacks, IsTwoWay = "..item:getDeviceData():getIsTwoWay())
                        print("Toggle TwoWay to False")
                        -- Toggle code
                        item = itemInBag:getDeviceData():setIsTwoWay(false)
                        print("Result IsTwoWay = "..item:getDeviceData():getIsTwoWay())
                    end
                end
            end
        end
echo lark
#

is it getFirstTypeRecurse that checks the player and their bags

#

i cant remember

violet shell
#

in the first code, bag is ok, in the second code, bag is bugged and I get an error

#

I tried with bag:getInventory() it's buggy, now I'm trying with bag:getItems():get(x) but it's buggy too

#

here is the last trace :

LOG  : General     , 1714657462416> 0> [Asilar_RadioOneWayOnBelt]     Entering testIfWalkieTalkie
LOG  : General     , 1714657462416> 0> [Asilar_RadioOneWayOnBelt]     Item is not a WalkieTalkie
LOG  : General     , 1714657462416> 0> [Asilar_RadioOneWayOnBelt]     Entering Back loop
LOG  : General     , 1714657462420> 0> -----------------------------------------
STACK TRACE
-----------------------------------------
function: onEquipRadioToggle -- file: Asilar_RadioOneWayOnBelt_bis.lua line # 52 | MOD: Asilar's OneWay Radio on Belt
Callframe at: setPrimaryHandItem
function: perform -- file: ISEquipWeaponAction.lua line # 146 | Vanilla

ERROR: General     , 1714657462422> 0> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: Object tried to call nil in onEquipRadioToggle at KahluaUtil.fail line:82.```
echo lark
#

ive never used it before, but i think someone suggested it to me once, and i found by searching it that it checks everything

#

but it will grab the first type it sees regardless of where it is on you i think

#

so i think if im not wrong, you dont need to do the check for the specific bags, just use getFirstTypeRecurse

#

yeah here, thats where ive seen it before

#

i gotta step out for a bit, good luck!

violet shell
#

But with this I only get the first one. I want to check all the items because if there are multiple identical items I want to apply my code on each of it

bright fog
#

There's other get in inventory methods

violet shell
#

ok, but Type of item is it's type=xxx in the item script right ?

#

item myitem {
type = typeofitem --example = radio
}

bright fog
violet shell
#

what I want to check is "myitem"

#

I don't want to check the type =

#

so I guess it's name

bronze yoke
#

type usually refers to the internal name of the item script, not the Type field in the script

bright fog
#

This is how I find recharges in Susceptible Overhaul

#

It's the same thing for getAllRecurse

#

But it outputs an array of item

violet shell
# bronze yoke type usually refers to the internal name of the item script, not the Type field ...

so in ```item WalkieTalkie1
{
DisplayCategory = Communications,
Type = Radio,
Icon = WalkieTalkieBudget,
Weight = 1.0,

    DisplayName        = Toys-R-Mine Walkie Talkie,
    
    UseDelta        = 0.007, 
    UseWhileEquipped    = FALSE,
    DisappearOnUse        = FALSE,
    TwoWay            = TRUE,
    TransmitRange        = 750,
    MicRange        = 5,
    BaseVolumeRange        = 8,
    IsPortable        = TRUE,
    IsTelevision        = FALSE,
    MinChannel        = 75000,
    MaxChannel        = 150000,
    UsesBattery        = TRUE,
    IsHighTier        = FALSE,
    WorldObjectSprite    = appliances_com_01_16,
    Tooltip = Tooltip_item_Radio,
    StaticModel = WalkieTalkieToy,
    AttachmentType = Walkie,
}```

type is "WalkieTalkie1" ?

violet shell
bright fog
#

Sure

bronze yoke
#

the only exception to this that i know of is on the Item object (not InventoryItem) that is called name and Type = Radio is the type, everywhere else type is WalkieTalkie1

bright fog
violet shell
#

ok thanks

#

so, I can replace the whole @small topaz code with loops and so by player:getInventory():getAllTypeRecurse(typeofwalkie) in a loop where typeofwalkie is cycled throught a table with all the walkies names ?

violet shell
#

ok thank you very much. Gonna try it now

bright fog
violet shell
#

Can I have just a table with item types in a module ?
Like RadioOneWay.listOfWalkies = {string1, string2, string3} ?

bronze yoke
#

sure

violet shell
#

Like that :

RadioOneWay.listOfWalkies = {
    "Base.WalkieTalkie1",
    "Base.WalkieTalkie2",
    "Base.WalkieTalkie3",
    "Base.WalkieTalkie4",
    "Base.WalkieTalkie5",
    "Base.WalkieTalkieMakeShift"
}
#

also, I know I cannot declare functions local inside a local module, but do I need to declare variable local in a function in a local module ?

bronze yoke
#

yeah

bright fog
violet shell
#

ok.

#

this should do the job ?

for _,typeOfWalkie in pairs(RadioOneWay.listOfWalkies) do
        print("Entering for loop to test each WalkieTalkie Type")
        local walkiesInInventory = player:getInventory():getAllTypeRecurse(typeOfWalkie)
        for i=0,walkiesInInventory():getSize() do
            walkiesInInventory:get(i) = walkiesInInventory:get(i):getDeviceData():setIsTwoWay(false)
        end
thick karma
#

But if you use the new way, looping by counting index up from 1 to #RadioOneWay.listOfWalkies would be faster.

violet shell
#

but you're array has "= true" so I was not sure it would work

thick karma
#

Yes exactly, in the original array the keys are the value you need in the loop you're doing

#

The loop format for key-value pairs is for key, value in pairs(table)

violet shell
#

in my last for loop, for i=0, ... how I ask for the loop to go until all items of the getAllTypeRecurse has?

thick karma
#

You're throwing away the key and calling it _ in your new one

violet shell
#

getSize() is not the right one

thick karma
#

But you could've just used the key

thick karma
#

0, result:size() - 1

#

Would be the required for bounds

#

Given the result of calling that

bronze yoke
violet shell
#

why "-1" ?

bronze yoke
#

walkiesInInventory:get(i) = walkiesInInventory:get(i):getDeviceData():setIsTwoWay(false) doesn't assign anything

#

just do walkiesInInventory:get(i):getDeviceData():setIsTwoWay(false)

thick karma
# violet shell why "-1" ?

Because loop proceeds until index is greater than the second value, and the last available value in an array that begins at 0 and has size elements is size - 1.

#

E.g., 0, 1, 2, 3, 4 would be 5 elements

violet shell
#

ok thanks 🙂

thick karma
#

Size would be 5

#

Last valid index would be 4

violet shell
#
for typeOfWalkie in pairs(RadioOneWay.walkieTalkies) do
            print("Entering for loop to test each WalkieTalkie Type")
            local walkiesInInventory = player:getInventory():getAllTypeRecurse(typeOfWalkie)
            for i=0,walkiesInInventory():size()-1 do
                walkiesInInventory:get(i):getDeviceData():setIsTwoWay(false)
            end
        end
``` ?
thick karma
#

In normal Lua tables the indexing goes from 1 to size instead of 0 to size - 1, btw. Just so you know.

violet shell
#

assuming RadioOneWay.walkieTalkies is the array you gave me yesterday

thick karma
#

Yes

#

Exactly

#

Did you try getAllEvalRecurse? I feel like that would be a lot faster if your goal is to perform an action on every walkie in your inventory

#

Your current method would require you to recursively search inv 5+ times instead of once

#

(not faster to understand and write but faster when the code fires)

violet shell
#

I didn't understand what you told me with getAllEvalRecurse, so I tried my own way, with the help of Sir Doggy, MCSlappy & albion. But if you can explain me a little more, I'll change the code without any problem 🙂

thick karma
#

I mean whatever works, works. I would have to be on PC to write out an example, and I haven't actually used it so I could be wrong about how it works. Was just curious how far you got in trying it.

edgy cosmos
violet shell
#

Line 56 is : for i=0,walkiesInInventory():size()-1 do
and line 55 : local walkiesInInventory = player:getInventory():getAllTypeRecurse(typeOfWalkie)

bronze yoke
#

it'd just be something like```lua
-- assuming walkieTalkies is a lookup table like burryaga has suggested:

RadioOneWay.predicateWalkie = function(item)
return RadioOneWay.walkieTalkies[item:getFullType()]
end

local walkiesInInventory = player:getInventory():getAllEvalRecurse(RadioOneWay.predicateWalkie)

bronze yoke
#

the extra ()s there attempts to call walkiesInInventory as a function

violet shell
#

so it should be for i=0,walkiesInInventory:size()-1 do ?

mellow frigate
thick karma
#

They're both objectively correct

verbal yew
#

how use item in recipe like its should be pot with full water?

bronze yoke
#

personally i'd prefer typeOfWalkie, _ to make the discarding of the value explicit

thick karma
bronze yoke
#

i don't think end of line semicolons are justifiable but using them to break up multiple statements on a single line is good practice

#

though it's often better practice to not try to minimise lines at the expense of readability in the first place

thick karma
#

Same reason I wouldn't put placeholder empty variables for find and gsub calls...

bronze yoke
#

well you've got me there

#

i wouldn't either but pairs feels like a special case to me

thick karma
#

Sometimes functions return stuff you don't need and I just don't catch it

violet shell
bronze yoke
#

i wonder if there's a performance difference

thick karma
#

The name of the function in albion's example would go there

thick karma
#

The "predicate" function

#

Just for the definition, link probably has nothing to do with Lua

thick karma
bronze yoke
#

oh i meant with using _ to discard

thick karma
#

Ohhhhhhhhh

#

No clue there

bronze yoke
#

to my knowledge _ is just a convention and does actually assign the value to a variable _

#

so potentially there is some kind of overhead induced by that assignment

#

but it's almost definitely next to nothing

thick karma
#

Yeah I would expect it to do so, but I have no clue whether overhead of assignment is more time consuming than overhead of throwing away if any such overhead exists

violet shell
#

Ok, so now the code isn't buggy anymore (thanks to you all), but I still ave issues

#

I tried to equip walkie, but seems it never finds a walkie

#

should I delete the Base. before the WalkieTalkie in your array ?

#

as McSlappy suggested ?

#

RadioOneWay.walkieTalkies = {
["Base.WalkieTalkie1"] = true,
["Base.WalkieTalkie2"] = true,
["Base.WalkieTalkie3"] = true,
["Base.WalkieTalkie4"] = true,
["Base.WalkieTalkie5"] = true,
["Base.WalkieTalkieMakeShift"] = true
}

bronze yoke
#

it looks like it should be Radio.WalkieTalkie...

#

they're one of the few vanilla things not in the base module

violet shell
#

ok 🙂

#

you're right, radio stuff is in its own module Radio {}

#

new issues : first trace is equipping a machete, second trace is equipping a walkietalkie5 (military)

#

line 58 is : print("Selected Item is a WalkieTalkie, IsTwoWay = "..item:getDeviceData():getIsTwoWay())

#

in the second case, code doesn't recognize the walkietalkie as being one 😦

thick karma
#

(Printing stack trace snippet as raw text helps people on phones help you.)

violet shell
#

LOG : General , 1714664007158> 228?594?500> [Asilar_RadioOneWayOnBelt] Entering onEquipRadioToggle
LOG : General , 1714664007159> 228?594?500> [Asilar_RadioOneWayOnBelt] Entering testIfWalkieTalkie
LOG : General , 1714664007160> 228?594?501> [Asilar_RadioOneWayOnBelt] Item is not a WalkieTalkie
LOG : General , 1714664007160> 228?594?502> [Asilar_RadioOneWayOnBelt] Equipped Item is not a WalkieTalkie
LOG : General , 1714664007160> 228?594?502> [Asilar_RadioOneWayOnBelt] Entering for loop to test each WalkieTalkie Type
LOG : General , 1714664007167> 228?594?509> [Asilar_RadioOneWayOnBelt] Entering for loop to test each WalkieTalkie Type
LOG : General , 1714664007168> 228?594?510> [Asilar_RadioOneWayOnBelt] Entering for loop to test each WalkieTalkie Type
LOG : General , 1714664007169> 228?594?511> [Asilar_RadioOneWayOnBelt] Entering for loop to test each WalkieTalkie Type
LOG : General , 1714664007170> 228?594?511> [Asilar_RadioOneWayOnBelt] Entering for loop to test each WalkieTalkie Type
LOG : General , 1714664007170> 228?594?512> [Asilar_RadioOneWayOnBelt] Entering the for loop to check every WalkieTalkie found
LOG : General , 1714664007174> 228?594?516> -----------------------------------------
STACK TRACE

function: onEquipRadioToggle -- file: Asilar_RadioOneWayOnBelt_bis.lua line # 58 | MOD: Asilar's OneWay Radio on Belt
Callframe at: setPrimaryHandItem
function: perform -- file: ISEquipWeaponAction.lua line # 146 | Vanilla

ERROR: General , 1714664007176> 228?594?518> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: Object tried to call nil in onEquipRadioToggle at KahluaUtil.fail line:82.
ERROR: General , 1714664007177> 228?594?518> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: Object tried to call nil in onEquipRadioToggle

#

first trace

#

it seems that local walkiesInInventory = player:getInventory():getAllTypeRecurse(typeOfWalkie) doesn't return only the walkies ?

violet shell
#

maybe we're in the corner case @bronze yoke mentionned earlier about Type for Radio objects

violet shell
thick karma
#

Oh I see

#

Idk might need to see current state of onEquipRadioToggle

violet shell
uneven vessel
#

I set this thing's range to 7

#

but is still targeting from miles away

#

This is range 7 on the js2000 for comparison

thick karma
#

With your latest edits

violet shell
#

ok sure 🙂

uneven vessel
#

What else can affect weapon range?

violet shell
#
function RadioOneWay.onEquipRadioToggle(player, item)
    if not item then return end
    print("Entering onEquipRadioToggle")
    -- Check if radio is being equipped
    if RadioOneWay.testIfWalkieTalkie(item) == true then
        -- Toggle code
        print("Equipped Item is a WalkieTalkie, IsTwoWay = "..item:getDeviceData():getIsTwoWay())
        print("Toggle TwoWay to True")
        item:getDeviceData():setIsTwoWay(true)
        print("Result IsTwoWay = "..item:getDeviceData():getIsTwoWay())
    -- if it's not a radio then we set radios in inventory to OneWay only
    else
        print("Equipped Item is not a WalkieTalkie")
        for typeOfWalkie in pairs(RadioOneWay.walkieTalkies) do
            print("Entering for loop to test each WalkieTalkie Type")
            local walkiesInInventory = player:getInventory():getAllTypeRecurse(typeOfWalkie)
            for i=0,walkiesInInventory:size()-1 do
                print("Entering the for loop to check every WalkieTalkie found")
                print("Selected Item is a WalkieTalkie, IsTwoWay = "..item:getDeviceData():getIsTwoWay())
                print("Toggle TwoWay to False")
                walkiesInInventory:get(i):getDeviceData():setIsTwoWay(false)
                print("Result IsTwoWay = "..item:getDeviceData():getIsTwoWay())
            end
        end
    end
end
#
RadioOneWay.walkieTalkies = {
    ["Radio.WalkieTalkie1"] = true,
    ["Radio.WalkieTalkie2"] = true,
    ["Radio.WalkieTalkie3"] = true,
    ["Radio.WalkieTalkie4"] = true,
    ["Radio.WalkieTalkie5"] = true,
    ["Radio.WalkieTalkieMakeShift"] = true
}

function RadioOneWay.testIfWalkieTalkie(item)
    print("Entering testIfWalkieTalkie")
    
    if RadioOneWay.walkieTalkies[item:getName()] then
        print("Item is a WalkieTalkie")
        return true
    else
        print ("Item is not a WalkieTalkie")
        return false
    end
end
#

maybe I should write :

function RadioOneWay.testIfWalkieTalkie(item)
  if RadioOneWay.walkieTalkies[item:getType()] then...
``` ?
#

seems that it enters the for loop even if there's no walkietalkie :

for typeOfWalkie in pairs(RadioOneWay.walkieTalkies) do
            print("Entering for loop to test each WalkieTalkie Type")
            local walkiesInInventory = player:getInventory():getAllTypeRecurse(typeOfWalkie)
            for i=0,walkiesInInventory:size()-1 do
                print("Entering the for loop to check every WalkieTalkie found")
                print("Selected Item is a WalkieTalkie, IsTwoWay = "..item:getDeviceData():getIsTwoWay())
                print("Toggle TwoWay to False")
                walkiesInInventory:get(i):getDeviceData():setIsTwoWay(false)
                print("Result IsTwoWay = "..item:getDeviceData():getIsTwoWay())
            end
        end
uneven vessel
#

for some reason no matter what value I change this shotgun's fire-rate is always the same and the range too

violet shell
#

here it the new stack trace :

LOG  : General     , 1714665024415> 229?611?381> [Asilar_RadioOneWayOnBelt]     Entering testIfWalkieTalkie
LOG  : General     , 1714665024415> 229?611?382> [Asilar_RadioOneWayOnBelt]     Item is not a WalkieTalkie
LOG  : General     , 1714665024416> 229?611?382> [Asilar_RadioOneWayOnBelt]     Equipped Item is not a WalkieTalkie
LOG  : General     , 1714665024416> 229?611?382> [Asilar_RadioOneWayOnBelt]     Entering for loop to test each WalkieTalkie Type
LOG  : General     , 1714665024416> 229?611?383> [Asilar_RadioOneWayOnBelt]     Entering for loop to test each WalkieTalkie Type
LOG  : General     , 1714665024417> 229?611?383> [Asilar_RadioOneWayOnBelt]     Entering for loop to test each WalkieTalkie Type
LOG  : General     , 1714665024417> 229?611?383> [Asilar_RadioOneWayOnBelt]     Entering for loop to test each WalkieTalkie Type
LOG  : General     , 1714665024417> 229?611?383> [Asilar_RadioOneWayOnBelt]     Entering for loop to test each WalkieTalkie Type
LOG  : General     , 1714665024418> 229?611?384> [Asilar_RadioOneWayOnBelt]     Entering the for loop to check every WalkieTalkie found
ERROR: General     , 1714665024418> 229?611?385> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: __concat not defined for operands: Selected Item is a WalkieTalkie, IsTwoWay =  and true at KahluaUtil.fail line:82.
ERROR: General     , 1714665024419> 229?611?385> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: __concat not defined for operands: Selected Item is a WalkieTalkie, IsTwoWay =  and true```
#

Stack trace:
java.lang.RuntimeException: __concat not defined for operands: Selected Item is a WalkieTalkie, IsTwoWay = and true

#

ok, so I added a new variable twoWayState and assign "True" or "False" with a if/else check. And I call it in my print prompts instead of item:...

torn igloo
#

Why does SetMaxDamage or SetMinDamage etc not work for melee weapons on MP? It simply reset back to default.

torn igloo
#

I will check that out. Thanks.

echo lark
#

this one

#

if you have it installed thats probably why its happening. took me a bit to figure that one out XD. giving it a tag stops that from happening though

violet shell
#

@thick karma Ok, fixed last errors. Now I have a functionnal module. Last problem : the function you wrote to test if the item equipped is a walkietalkie doesn't work as intended.

function RadioOneWay.testIfWalkieTalkie(item)
    print("Entering testIfWalkieTalkie")
    
    if RadioOneWay.walkieTalkies[item:getType()] then
        print("Item is a WalkieTalkie")
        return true
    else
        print ("Item is not a WalkieTalkie")
        return false
    end
end
``` always return false.
#

and ```lua
RadioOneWay.walkieTalkies = {
["Radio.WalkieTalkie1"] = true,
["Radio.WalkieTalkie2"] = true,
["Radio.WalkieTalkie3"] = true,
["Radio.WalkieTalkie4"] = true,
["Radio.WalkieTalkie5"] = true,
["Radio.WalkieTalkieMakeShift"] = true
}

bronze yoke
#

it should be getFullType()

violet shell
#

ok thanks 🙂 trying that !

bronze yoke
#

getType() would return e.g. WalkieTalkie1, getFullType is Radio.WalkieTalkie1

violet shell
#

damn, I just think about something ! If I have a mod installed that override walkietalkies, then the FullType would change right ?

#

or it's still Radio.blabla ?

bronze yoke
#

it'd still be Radio

violet shell
#

ok (I have visible talkies installed and running)

violet shell
#

<@&671452400221159444> did I made a mistake in my last message ? It got erased or i'm going mad ?

thick karma
granite glade
#

Is there anywhere I can reference the titles of loot tables?

#

or, more accurately, distribution tables?

thick karma
#

ProceduralDistribution[s].lua

#

I can't remember if there is an s, but I think not.

#

Search ProjectZomboid/media/lua for it

granite glade
#

Thanks!

violet shell
thick karma
#

Nah just kidding it sounds like maybe a bot flagged your code

violet shell
#

I tagged the 4 of you (albion, burryaga, Sir Doggy & McSlappy), so maybe it was too much ?

bright fog
#

perhaps

violet shell
bright fog
#

[url=https://theindiestone.com/forums/index.php/topic/2530-mod-permissions/?p=36478][img] https://i.imgur.com/l9ciVMC.png[/img][/url]

thick karma
#

I have had code flagged and been auto-timed out before when trying to post my ini and tell Discord using ```ini

bright fog
#

The link to the image

#

Use the one I sent

violet shell
bright fog
#

I have no idea how Steam retrieves the image ngl so hard to say

violet shell
#

also, to clarify why I'm on Ask for Permittion : I have no issue about people using my code, but I would like to be aware of. Thanks a lot.

bright fog
#

Join the modding Discord if you haven't yet, we have a bunch of link ressources like these

#

Fair

violet shell
#

I didn't want to seem harsh as this mod would not has been working without you all, but I just prefer to know if it's used elswhere.

bright fog
#

give me a sec

bright fog
vestal gyro
#

Also since we are not getting any major updates on all the new stuff coming to B42 it seems like they are in the polishing phase

urban plaza
#

anyone know why the class

// Compiled from "VehiclesDB2.java"
class zombie.vehicles.VehiclesDB2$SQLStore {
  /* redacted */
  private java.lang.String searchPathForSqliteLib(java.lang.String);
  /* redacted */
}

Defines the searchPathForSqliteLib function?

The relevant decompiled file would be
zombie/vehicles/VehiclesDB2.java
And the relevant class file is
zombie/vehicles/VehiclesDB2$SQLStore.class

It seems like a complete embed/reuse of the same code from:

// Compiled from "PZSQLUtils.java"
class zombie.utils.PZSQLUtils {
  /* [redacted] */
  private static java.lang.String searchPathForSqliteLib(java.lang.String);
  /* [redacted] */
}

Except the vehiclesDB2 version lacks the static qualifier. Decompiled code appears to be exactly the same.
Is it like a bytecode optimization by the java compiler used with Zomboid, to mixin the static method from the PZSQLUtils code?

mellow frigate
#

Vehicles version not being used in the decompiled code I have at hand, I have no better guess than yours.

gilded hawk
#

Is there a mod that allows you to count the distance between two points on the map?

somber swan
#

Me slowly learning Lua so I can try my hand at mod making every time I encounter some weird quirk that I've never seen in any other programming or scripting language I've worked with

somber swan
gilded hawk
#

I haven't found a way to do this in debug 😦

somber swan
#

Next time I'm in there if I think of it I'll look, p sure I found it before.

#

It's not like, literally just "Click tile, it's this far away" but it does let you ultimately get the distance between two points

somber swan
#

Anyone have a recommended IDE for Lua?

#

very new to it

#

(stg if one of you says Vim)

frank elbow
#

Vi

#

VS Code is good

somber swan
somber swan
loud niche
#

Hello, I am creating a mod for servers, since some mods do not work correctly and I am getting to work today. I already have my first tests. But I would like to show a message to a player when he connects to the server. I've used getPlayer():say(), but I've been searching all afternoon to see if there is a method, or another function, to display a notice to the player above their head, for informational purposes. I hope you can help me. Thank you

somber swan
grizzled fulcrum
#

Ya keywords in Lua like python more than C

#

It definitely messes with you coming from any other lang

somber swan
#

That would explain the popularity.

#

I never learned Python but if Lua is like Python I get why Lua is popular

grizzled fulcrum
#

It's decently lightweight and easy to integrate with most lang

gilded hawk
#

Does anyone know how to get the type of building from java\iso\BuildingDef.java or java\iso\areas\IsoBuilding.java I can't seem to figure out how to differentiate between, industrial, residential, and police/firestation buildings.

I know that IsoBuilding -> isResidential uses this.containsRoom("bedroom") to check if a building is residential, but it's not enough

grizzled fulcrum
#

are U doing java mod?

#

I am not at home so I can't investigate rn

gilded hawk
#

I'm doing lua mod, but I still need to look into the Java for it

#

It's a module of my destroyed building and cities mod. And for now it can read the complete list of building in PZ, and using some math stuff that I barelly understand myself it makes clusters, and with these clusters I can make an educated guess checking if it's a city or not. And for now it's quite good.

But I noticed how this code tends to confuse the "mobile home parks" for actual cities/town, which is kinda annoying but I can figure something out

red tiger
#

Hey @gilded hawk

gilded hawk
#

Hey Jab

red tiger
#

Might want to continue my planned Java client mod.

#

Works with UI, shaders and things.

gilded hawk
#

That sounds interesting, I should give it a look once i'm done with this project

#

ooooh yeah I fixed it

gilded hawk
#

I see this as a great success, it's bed time then

red tiger
grizzled fulcrum
#

You just showed me klogg and it saves my brain trying to read log files 😄

winged stirrup
#

Hi, I'm making mod tools for the first time with the help of Chatgpt because I didn't learn how to code, and I set up the items with scrap. I want to make it a mod tool that can function as all the tools used for car maintenance. Can you tell me which files to modify and which files to add?

sly geode
#

Hello guys, i wanna create custom faction flags.

verbal yew
#

Home Canned-Meat in process

jaunty marten
red tiger
#

Mx was interested in it too.

jaunty marten
jaunty marten
red tiger
#

It's possible but how much impact would it have in a period of time when compared to a tool that scans the lua codebase and discovers types & allows me to human-document code?

jaunty marten
#

you*

red tiger
#

I just left for a time.

jaunty marten
#

ah, fine then

red tiger
#

I came back after my brain surgery and am recovering.

jaunty marten
#

brain surgery? what a shit

red tiger
#

Having a very good recovery so far.

#

I blame it on Lua.

#

PZ modding put a rock in my brain lol

jaunty marten
jaunty marten
red tiger
#

I am making progress on my documentation tool btw

red tiger
#

@jaunty marten

#

=)

worldly wing
#

any advice on why my modded distributions file isn't working? The mod ID and item name are correct, but the item is not showing up in the containers it should be. It looks like the spawning rolls are happening correctly, but whenever it's the Silly Drink's turn to be spawned nothing gets added to the container.

bright fog
#

You need to insert in the table your values with table.insert()

worldly wing
#

isn't that only for proceduraldistributions? this is the curated distributions file

#

but I will try that and report back 👍

worldly wing
#

yeah makes perfect sense

#

I'm completely new to Lua lol so figuring out as I go

#

thanks for the advice :)

bright fog
#

Check out other mods that add items to loot distributions if you need

#

Yeah np

worldly wing
#

ah yeah I should have done that lol

jaunty marten
red tiger
#

Thanks.

#

I'm working on a reference dictionary and reference <-> assignment mapping for spreading types around the code.

jaunty marten
#

coooool

red tiger
#

It digs through all code, not just surface.

jaunty marten
#

oh, even better then

worldly wing
#

but I'm still getting the same issue where the item is not actually appearing in the containers whenever it rolls.

#

The chance is set to 100%, so ideally it should be showing up in just about every pop vending machine, but they're all coming up empty, like the silly drink is being rolled but just not appearing.

#

Kind of at a loss, I feel like the issue is likely with the item naming scheme but everything seems right to me

#

worth noting the item itself works fine when I spawn it in with debug, it's just not appearing in containers

#

here's the item code

coarse sinew
worldly wing
coarse sinew
#

Yup

worldly wing
#

thanks a bunch gonna try that now

#

it worked perfectly 👍 gonna fix everything else tomorrow since I need to go to bed it's 5am here tired thanks again for the help

bronze yoke
bright fog
#

classic

#

If only VSCode would highlight such mistake in .txt files lol

bronze yoke
#

jab's plugin might

dreamy tusk
#

Hi

#

How can I make a mod that replaces some ingame sfx?

bright fog
#

If it's FMOD handled SFX, requires manual installation from players

dreamy tusk
#

I want to change the hit sound of the frying pan

bright fog
#

You got to find the frying pan sound

#

If it's in a .bank file, you're fucked

dreamy tusk
#

oh

bright fog
#

Check in the script file with the frying pan melee weapon

dreamy tusk
#

and how do I make it a mod? so I can upload it on workshop

bright fog
bronze yoke
#

almost all sounds are in the bank files, what matters is if it's triggered through a sound script

bright fog
#

But first thing I would suggest is find a mod that modifies an item stats/information and look how they do it

gaunt meteor
#

i am gonna go insane

#

literally doing nothing wrong with my icons smad

winged stirrup
#

I'm trying to make it so that the newly created mod item can be used in place of all the tools for vehicle maintenance, but I don't know what's wrong, but it keeps saying that a wrench is needed to remove the engine. Please help. The code is like this.

thick karma
thick karma
# winged stirrup

Looks like you're trying to run code that is intended to happen within a function independent of any function, and outside of that context part will be nil so none of your code will happen

winged stirrup
#

@thick karmaSo how can we make the newly created item function as a full vehicle maintenance tool?

thick karma
#

Also I would drop personally drop IS from the custom module name because I don't work for Indie Stone. I am guessing you don't, either. I would rewrite top line as

local VehicleMechanicsOverride = {}

and refactor appropriately.

Honestly, MagicMechanicsWand or just MagicWand might be even better options, depending on the purpose of the mod.

thick karma
winged stirrup
#

I will try my best to search first. Thank you.

thick karma
#

If you can find the function that checks whether you have the right tools I can tell you how to decorate it

#

It'll presumably check whether you have a wrench somehow

thick karma
#

And whenever you detect those functions are checking whether player has a wrench, you return true if they have a wrench or your tool

#

Alternatively perhaps there's a way I don't know about to flag an item as a version of another

winged stirrup
#

I'm looking at the ISVehicleMechanics file right now. I really want to find it.

thick karma
#

I see part of your issue... You're trying to decorate a vanilla function called isToolAvailable right?

#

Can you share that function

winged stirrup
#

I haven't learned coding, so I'm just making questions in chat gpt, so I can't figure out what the problem is.

thick karma
#

For what it's worth, learning to program a bit will help you learn to use ChatGPT more effectively to fill in the gaps

winged stirrup
#

My friend who was in charge of coding didn't work hard, so I'm trying to make it myself, but it's difficult.

thick karma
#

I would recommend studying some fundamentals the old fashioned way - studying something a human wrote to help another human

winged stirrup
#

I think I should take this opportunity to learn.

thick karma
#

The first thing you probably need to do is find the function named isToolAvailable if that exists

#

The original from vanilla files

#

They're in the ProjectZomboid game directory

winged stirrup
#

I'm looking into it now, but it seems difficult because I don't have any knowledge. I think it's right to study more and then come back and ask questions.

thick karma
#

That's how we find functions or other data in Lua and script files to begin reading and understanding them

#

For Java stuff, you need to decompile the game, but hopefully that won't be required here

winged stirrup
#

I searched for isToolAvailable using the explorer, but nothing came up.

thick karma
#

That is an important first step or this won't work

#

Google or ask ChatGPT how to index a folder to allow searching the file text of selected filetypes

#

If you don't know how

#

It's a common need

#

@winged stirrup I'm guessing you are working on indexing. If you index ProjectZomboid/media and it still doesn't work, let me know. Should be somewhere in your Steam apps

winged stirrup
#

When I searched on chatgpt, it said to do it with Python, so I installed it, but it was too difficult... Can I study more later and post the question again?

thick karma
#

Google "indexing a folder on Windows" and you'll get much better advice.

#

Python is not required here at all.

thick karma
#

Here's a simple one.

#

This covers Windows 11 with screenshots. Almost the same process: https://www.elevenforum.com/t/add-or-remove-search-index-locations-in-windows-11.2966/

latent yoke
#

just want to ask if theres a mod that makes a buildable ramp that has a switch to put it up and down hehe

thick karma
#

Okay I looked for you on my PC, and just to save you trouble, isToolAvailable does not exist. Maybe your friend was working on creating such a function. Determining whether you have the tool in ISVehicleMechanics is done by calling self.chr:getInventory():contains("Wrench")

#

@winged stirrup Which means as I said earlier you might want to decorate contains itself.

winged stirrup
#

Will it work if I edit all the places containing self.chr:getInventory():contains("Wrench")?

thick karma
#

Alternatively, you could decorate every single function that checks for whether you have a wrench to fire alternative behavior based on presence of your tool

#

That'll be a bit more complex, but it'll have the benefit of correctly showing your tool name.

winged stirrup
#

Is there a chance that it will work if I edit everything where self.chr:getInventory():contains is so that it can work in all tools?

thick karma
#

If you decorate contains you could lie to the game so that whenever Lua checks whether you have a wrench, it says yes if you at least have your magic wand.

thick karma
#

You would need to decorate all the actual functions that reference a wrench to do handle display names properly.

winged stirrup
#

It's a harder task than I thought. I guess I'll have to get my friend to do the work half-heartedly.

thick karma
# winged stirrup It's a harder task than I thought. I guess I'll have to get my friend to do the ...

I recommend patience if you have someone who is willing to try to solve it. The job is a bit of a headache, and, as you may have learned today, there are often extremely time-consuming periods of analysis, study, and planning before any code is written to begin solving a complex problem. I can say at a glance that optimally handling this situation in every imaginable context might be a headache. I just browsed around the file to find references to "Wrench" and found many.

#

Most of not all of them may have to be explicitly modded to make the mod's item tell players when it's being used in any relevant menu.

#

As well as to make the item usable on the first place, of course.

#

Also, just in case you're actively trying to get him to solve this faster, I would caution that hurrying or expressing impatience with people will often only slow them down. Patience, gratitude, and encouragement are going to be much better bets if your goal is to see the job done as quickly as possible.

winged stirrup
#

I'll try to solve it slowly. Thank you for letting me know a lot

violet shell
#

I have a question about 1 server option :
RedistributeHours = 12.0, -- The number of hours that must pass before zombies migrate to empty parts of the same cell. Minimum = 0.0 Maximum = 8760.0 Default = 12.0
Does anyone can explain me how it works ? On our server we would like that zombies migrate less because with our server options the countryside/wilderness seems a little to much populated, we would like to reduce the migration of the Zeds to have a bigger difference between urban & wilderness zones. (And yes, I am already in Urban settting).
Maybe there's a mod that allows to tweak the migration system ?

thick karma
violet shell
#

ok, is there a way to have better control on how they migrate ? Like a mod that has been made already ? Or some other options I should investigate/consider ?

thick karma
#

I tried to find a mod just now and couldn't

violet shell
#

yeah same 🙂

worldly wing
drifting ore
#

dont suppose i could get some help, im developing a mod with a friend and we keep having the same issue with our weapons that they are invisable

#

i made each weapon myself in blender (two of them are literally just reskins but also increasing the metalness value to make them shiny)

#

i cant figure out for the life of me whats wrong

#

oop posted in the wrong channel, my bad

thick karma
#

It's just that no one who has the ability to help and the time to do so has seen your question yet.

#

Mod support is for getting other people's existing mods to work

#

This is where questions about making your own mod belong

#

I can't tell you about properly exporting new weapons but I would recommend you share your script files for the items.

drifting ore
#

ok cool, i thought it belonged in mod support

#

ok will do

thick karma
#

So people can review them for mistakes

drifting ore
#

give me a moment

thick karma
#

Maybe post a model that is showing as invisible in #modeling and ask there if everyone thinks the model seems ready for PZ

drifting ore
#

if your talking about tri count and all of that ive made sure thats not an issue

#

everything is well below the limit

#

and all on one UV map too

#

i posted some screenshots, the two golden ones are just reskins that have also have had their "metalness" value increased so they are shiny

thick karma
#

I'm not talking about anything specific because I don't make weapons. I'm just speaking from a perspective of strategic problem solving. If other guns from other mods and vanilla itself are perfectly visible and only yours are not, that suggests you have a mistake in your scripts or a mistake in your model or other relevant mod files.

drifting ore
#

im sure that its not a coding error and is intead a blender issue as the person im making the mod with is very adept at modding while im fairly fresh in terms of blender

#

ahh ok

#

got it

thick karma
#

And posting them will give people a chance to review what you made to confirm end result is exactly as it should be.

#

I have no way of knowing exactly where you went wrong

drifting ore
#

got it! thank you very much

thick karma
#

Just helping you get help faster

drifting ore
#

im trying to find those mod files for you but finding them on mac is a pain lol

karmic fog
#

Is there any dev tool that helps with finding the correct values for rotation and offset for static items?
I want to make a sheath and attach it to the thigh bone. Do I really have to simply put in random numbers into the model script and hope they're close, then adjust them by trial and error, having to reload the game each time?

gilded hawk
#

Is there a debug option/menu to set how much erosion does a building have?

gilded hawk
#

I need to replicate how PZ applies the "overlay_grime_X_X" and "d_wallcracks_X_X" to building walls 👀

mellow frigate
gilded hawk
#

Do you mean an actual mod, or the preset?

mellow frigate
red tiger
#

Hey @gilded hawk

#

Check out the HTML UI project?

gilded hawk
# mellow frigate I mixed: 10 years later mod

I am looking at the old version, and and it does not seem to help, all the sprites are hard coded 😦 So, I does not help me understrand how the game places it's sprites

I will look at the new version too 🤷‍♂️

red tiger
#

Ah yes. Sublime, my beloved.

gilded hawk
gilded hawk
red tiger
#

All in good time.

red tiger
#

xD

#

I'm making progress btw on my lua wizard code.

gilded hawk
red tiger
#

I'm already discovering basic relationships between calls and assignments and spreading types.

#

I'm applying logical relational stuff with how Lua executes code to discover and provide types for variables.

#

If I do properly implement this the way I'm doing right now, I can even apply types to inner-function variables, including if clauses and even evaluations for those code blocks.

#

I'm also compiling type information for the Java API.

gilded hawk
#

Damn 😮

#

That's cool!

red tiger
#

That's how PipeWrench works.

#

(And how Umbrella's Java API, "Candle" works)

#

I can take that code and apply it to this project as well.

#

=)

gilded hawk
#

Very very nice!

#

In the meantime, I'm here trying to figure out what kind of black magic is happening here

   public void init() {
      for(int var1 = 0; var1 < 100; ++var1) {
         this.spawnChance[var1] = var1 <= 50 ? 100 : 0;
      }

      String var7 = "d_wallcracks_1_";
      int[] var2 = new int[]{2, 2, 2, 1, 1, 1, 0, 0, 0};

      int var3;
      for(var3 = 0; var3 < 3; ++var3) {
         this.objsRef.add(new ArrayList());
         this.topRef.add(new ArrayList());
         this.botRef.add(new ArrayList());
      }

      for(var3 = 0; var3 < var2.length; ++var3) {
         for(int var4 = 0; var4 <= 7; ++var4) {
            int var5 = var4 * 9 + var3;
            ErosionObjOverlaySprites var6 = new ErosionObjOverlaySprites(1, "WallCracks");
            var6.setSprite(0, var7 + var5, 0);
            this.objs.add(new ErosionObjOverlay(var6, 60, true));
            ((ArrayList)this.objsRef.get(var2[var3])).add(this.objs.size() - 1);
            if (var4 == 0) {
               ((ArrayList)this.botRef.get(var2[var3])).add(this.objs.size() - 1);
            } else if (var4 == 1) {
               ((ArrayList)this.topRef.get(var2[var3])).add(this.objs.size() - 1);
            }
         }
      }

   }

Like, i'm just trying to understand how the game picks a d_wallcracks_1_X depending on the direction of the sprite 🤷‍♂️

red tiger
#

Classic decompiled code from fernflower.

#

int-arrays being put into arraylists.

#

lol

#

It looks like sprite IDs are being mapped to strings as arraylists?

#

Clean up this code. The generics are making it look crazier than it is.

#

That will help.

bronze yoke
#

i'll be honest, when i saw your question i took a quick look at the erosion code to see if i could help and went NOPE

gilded hawk
#

Absolutely reletable

red tiger
#

@gilded hawk class and method pls

gilded hawk
#

Used in java\erosion\ErosionRegions.java

red tiger
#

@bronze yoke We good now. I renamed all the vars in 4 classes for em.

#

Also reversed / reapplied generics.

#

Sprites works in int spriteID, int season, and int evolution?

gilded hawk
#

We are still in the dark, but a bit more readable

gilded hawk
#

Im suspecting the game has a funny way of setting wall vines, and wall cracks

Looks like, each sprite is not just a single direction, but multiple?

#

insert big question mark here

undone tapir
#

I used ClearAllDistributionItems on SuburbsDistributions, Distributions, ProceduralDistributions and VehicleDistrbutions, but now I would like loot to generate. I set day length to 15 minutes and loot respawn to 1 hour to try and generate loot in unvisited chunks but it doesn't appear to be generating loot. Is there a way to re-populate the distributions I cleared with the default vanilla distribution information?

rich reef
#

Hello all. I was wondering if anyone knew how to get the total size X/Y of a property, possibly using getBuilding or something similiar?

rich reef
#

For reference, I am trying to make the Claim Safehouse context popup check for the size of the property before giving the option to claim. If that helps anyone decipher my issue

coarse sinew
rich reef
#

Thank you very much!

rich reef
#

@coarse sinew Thanks again for your help! I thought I'd share a simple function to help people figure out the first floor square footage of a building. Need to figure out how to determine how many levels a home has now.

function CheckSafehouseSize(worldobjects, square, player)    
        
        -- Check if player is in a building

        if not getPlayer():getSquare():getBuilding()
            then
                return
            end

        -- Get building definition

        local buildingDef = getPlayer():getSquare():getBuilding():getDef();
        
        if buildingDef == nil
            then 
                return
            end
        
        if buildingDef
            then
                local buildingHeight = buildingDef:getH();
                local buildingWidth = buildingDef:getW();

                print ("Safehouse Coordinates: ", buildingDef:getX(), " ", buildingDef:getY())
                print ("Running Safehouse Size Check...")
                print ("Safehouse Size is: ", buildingWidth, " Wide -- ", buildingHeight, " Tall")    
                print ("Safehouse Sq Footage: ", (buildingHeight * buildingWidth * 9))    

            end        
end
karmic fog
#

I made a new weapon, a knife to be exact, and it works in all ways intended - just it doesn't render when placed on the ground.
It renders in hand, but not on the ground.
Is that a common mistake among programmers? I have double checked everything from the code, cross-referenced with other mods and it still doesn't work.

model SWCM_Wolf_Knife
{
mesh = weapons/1handed/SWCM_Wolf_Knife,

attachment world 
{
offset: x y z
rotation: x y z
}
}```
ornate sand
half remnant
#

Good morning guys! 🍻

Is there a way to spawn a specific VHS tape via code without using admin perms ingame?

I can spawn generic 'VHS_Retail' or 'VHS_Home' but they aren't actual usable tapes. And I can't find a naming convention for specific tapes as it were before 41.66.

urban plaza
#

anyone know which version of Kahlua PZ uses?

https://github.com/krka/kahlua2 as implied by se.krka.kahlua2 hasn't been updated in 11 years.

https://github.com/yanmingsohu/kahlua2 has been updated as of 7 months ago and uses the same directory structure as the above (as it's a fork, so you can use git to manage both)

https://github.com/ProjectSky/PZ-kahlua seems to try to archive a version of kahlua used in PZ but completely messes with the structure of everything and was last updated 7 years ago.

Anyway I'm having a wonderful time of it trying to get any of the three to build.

urban plaza
#

The versioning substitution rule as set forth in line 90 of kahlua's build.xml appears to not have been respected:

<?xml version="1.0" encoding="UTF-8"?>
<project name="Kahlua" basedir="." default="all">
  <!-- stuff -->
  <target name="compile-core" depends="setup">
    <!-- stuff -->
    <replace dir="${build.dir}/core-src-replaced" replacefilterfile="version.properties">
    <!-- stuff -->
  </target>
  <!-- stuff -->
</project>

where version.properties is:

lua.version=5.1
kahlua.major=2
kahlua.minor=1
kahlua.fix=0

(see https://ant.apache.org/manual/Tasks/replace.html)
should have replaced the version information in se.krka.kahlua.Version but that contains:
Kahlua kahlua.major.kahlua.minor.kahlua.fix for Lua lua.version as its VERSION
Which implies it never was replaced, either due to mistakes in the build configuration or in the things done to incorporate kahlua into pz's code since.

I guess I could decompile pz's library code and compare it with the different publicly available versions of kahlua that are available. If there were to be any major differences.

The whole impetus to this was to be able to run a repl for the underlying lua implementation without running the game.

Honestly though I could just save myself a headache and load the exact version of kahlua shipped with zomboid by compiling something to load the same compiled .class es for it from the zomboid game folder zomboid does. Or bite the bullet and test everything from inside the game. But the lua global namespace is extremely populated in-game so I was trying to avoid it.

karmic fog
drifting ore
#

Hi all, i was wondering if anyone could take a quick look at my scripts for some custom weapons ive added?

#

they show up in the crafting menu but when equiped the model is invisable

#

meaning im killing zombies with nothing

bronze yoke
drifting ore
bronze yoke
drifting ore
#

or would it be easier to send you the link to the mod instead?

ornate sand
urban plaza
drifting ore
#

Most of the work went into making the models

ornate sand
#

WeaponSprite=SawBat
So your texture has to be named SawBat too.
At least that's how I got my tools & blades to render in properly

drifting ore
#

Yep. It’s named SawBat

#

I’ve double checked the names and they are all correct

#

Let me grab the link for the mod. That will be easier

ornate sand
#

Weird. That's how I got my stuff to work.
But for my firearms mod I had to have the texture line for the new stuff too.
Like so:
model Glock17
{
mesh = weapons/firearm/Glock17,
texture = weapons/firearm/Glock17,
attachment muzzle
{
offset = 0.0000 0.1386 00.264,
rotate = -90.0000 0.000 -180.0000,
}
}

drifting ore
#

Ooh ok

#

Thanks!

drifting ore
#

unfortunatly that didnt work, is it possible someone can take a look at the entire mod and see where im going wrong?

tardy cedar
#

Hey I'm new to making mods, but I got this idea to make a tinnitus trait joke mod where a tinnitus sound loops all the time. If someone could help me, or link a good video I'd be thankful

thick karma
neon bronze
#

doesnt isLooped = true play the sound indefinitely?

thick karma
#

Oh maybe so

#

Never wanted to make a sound go on indefinitely

neon bronze
#

a good aproach would be to make a new trait that gives like +5 points and then check with OnCreatePlayer Event if player has that trait

#

i think it gets fired everytime a player loads in right?

thick karma
#

Pinged into a thread

tardy cedar
#

thanks!

thick karma
neon bronze
#

cant give 0 points or else it will be hidden

#

maybe in b42 they'll allow it to have stuff cost 0 points

thick karma
#

Honestly, upon further reflection, I'm surprised nobody has ever made a free traits mod for the character selection screen

bronze yoke
#

it's just the work needed to utility gap

thick karma
#

Fair

#

Out of curiosity what happens when you try creating a trait with 0 cost? Does the game store it as existing, or throw an error?

#

Or refuse to add it?

thick karma
#

Guessing that

#

My bad

#

By hidden, you mean it can't be selected at creation, right?

bronze yoke
#

i don't think i recall it being hidden but i don't remember clearly

#

i feel like it just showed up in positive traits or something

marble loom
#

Hey
for some reason im playing with some mods and i cant seem to open close doors or interact with some stuff

thick karma
#

Hmmm I'll try it later for giggles

marble loom
#

and i cant equip weapons and such

#

but some friends that joined the server CAN play properly

#

what do i do?

thick karma
marble loom
neon bronze
thick karma
#

Are you sure that's not hidden because it's profession-locked?

#

Because that definitely hides traits if you don't have the right profession.

#

@neon bronze

neon bronze
#

Am i stupid?

thick karma
#

Haha not trying to say that

#

Just asking

neon bronze
#

But i seemed to recall thats how it worked

thick karma
#

Trying to reconcile what you're saying with what albion is saying

neon bronze
#

I remember someone saying that if you set a trait to 0 it would act as hidden but it could also be profession bound

thick karma
#

If they saw a trait from vanilla that was both profession locked and free, it would be a reasonable mistake to think it was because it was free, if indeed that is a mistake (albion has a pretty solid track record when it comes to being right about these things)

neon bronze
#

Lisan Al Ghaib that she is, she probably is in the right on this one

bronze yoke
#

i only have a vague recollection of this messing with it once a long time ago

echo lark
#

do the GUID for clothing have to be hexadecimal? or does that not matter?

neon bronze
#

There is guid generator online for that

bronze yoke
#

technically no but it is conventional

echo lark
# neon bronze There is guid generator online for that

yeah i know, i was just naming my stuff by replacing the first part of the GUID. like Helm-Full01-4071-ad87-9abaa761dca9. but then read someone that it had to be hexadecimal, but i thought i say mods that used similar naming to what i was doing but couldnt find it again. so was just making sure

echo lark
bronze yoke
#

it's just to avoid conflicts

#

there are technically no limitations whatsoever on what you put in the guid field, it doesn't have to be a guid or anything

#

it just needs to be unique and guids are very good at that

echo lark
#

ah ok, so ill stick to my method then, thanks!

wary panther
#

I'm having a hard time understanding this games item distribution. I'm just looking to add a new item to some existing containers, no custom roomdefs or custom containers. Would that be handled by Distributions.lua or ProceduralDistributions.lua, or both?

Would I have to create my own ProcDist entry to overwrite one of the vanilla ones, or can I insert items directly to vanilla ProcDist entries?

#

I made a pair of pants and I want to add them to vanilla dressers and inventorymale, but I just cannot wrap my head around the item distribution system.

#

I tried seeing how AuthenticZ handles it, because I have it installed, and the mod is far too dense for me to make heads or tails of whats going on lol

verbal yew
#

math.ceil from 5.25 its 6?

wary panther
verbal yew
#

thanks

modern veldt
#

Guys is there any way to modify IsoPlayer in Lua? Or any other way to save some player state. I am trying to make a mp mod and I need to track some state of players and save it permanently

bronze yoke
#

if you need to store data persistently you can add to the player's moddata table, which you can retrieve with player:getModData()

modern veldt
#

I saw that before here just now but I wasn't sure it is saved persistently or temporarily, thank you. I will try that.

ornate sand
bright fog
bronze yoke
#

isoplayers aren't recycled

bright fog
#

👌

bronze yoke
#

to my knowledge isozombie and isogridsquare are the only classes with that property (and grid squares are saved, loaded, and reset properly)

wary panther
#

I think that's what confused me at first, since in Distributions.lua the inventorymale entry doesn't use a procLIst, but every other container I wanted to use did. Inserting into inventorymale doesn't seem to make them wear the pants, however. The last thing I'm stumped on 😆

#

Can't seem to find where the game handles zed clothing

ornate sand
wary panther
#

Still trying to dissect how AuthenticZ handles it, completely lost in the sauce right now but I'm apparently making slow progress lol

ornate sand
#

Getting new clothing items to 100% is a lot more complex than any other item, I found out the hard way.
But it's doable. I'm considering making another mod just so I could fit some special forces zombies with all the new stuff I've made / am making

#

One mod to study for it is Brita's Armor pack. They got zombies in full custom outfits working, and it's just clothing items, not guns

wary panther
#

I will definitely check that out

urban plaza
bronze yoke
#

no, it's saved as part of the player object in players.db

#

global mod data is an entirely separate system from object mod data, they just share a name and the general purpose of 'table that saves'

wary panther
bronze yoke
#

an object's mod data is saved with the object, which is usually the save data, but players are saved to the database instead (and zombies don't usually save their moddata at all)

ornate sand
urban plaza
bronze yoke
#

yeah, that's just the raw save binary for the character object afaik

urban plaza
#

yeah in zombie.savefile.PlayerDB's update and add methods seem to insert the binary data for the character object in that column. Neat!

correction: zombie.savefile.PlayerDB 's private SQLPlayerStore subclasses methods, to be specific

urban plaza
torn igloo
#

What is the smallest decimal you can put in sandbox double?

modern veldt
urban plaza
#

I would defer to @bronze yoke's expertise here, so her stated player:getModData() use. Unless you're asking how to use that, mechanically

modern veldt
#

Okey, I got it thanks, I managed to use that but if there is better option, I am willing to use that

bronze yoke
#

global mod data is ideal for data that is not tied to a specific object, for things that are tied to objects (such as players) their object moddata from getModData() is preferable

copper hemlock
#

Hey, I'm very new to modding and I'm attempting to create my very first mod, I cannot find any information online on how to create a mod which adds a new meta event which would function exactly like the ones already included and randomly trigger with the other events. Can anyone give me any advice and/or direct me to a website/tutorial which explains how to accomplish this?

drifting ore
#

hey, are there any modders that take commissions? i was planning on buying 2 custom mods.

uneven ore
drifting ore
uneven ore
urban plaza
#

do the developers still use the forums? or if I had a specific bug report that related to the code would I want to use a different avenue

bronze yoke
#

forums are the way to go

thick karma
urban plaza
#

I'll post first :3 it's not game breaking

urban plaza
thick karma
#

Righto

vestal gyro
#

this is so weird

vestal gyro
#

when I put my poncho on everything was fine but when I clicked on the hood down the item deletes itself from my inventory

vestal gyro
bright fog
#

impossible to say what's causing this here

#

Most likely an incompatibility with another mod

urban plaza
#

@thick karma it's pending moderator approval

#

may I dm?

#

not for approval just to discuss it

muted garnet
#

Say me pls if anyone knows how to get all car's and the capacity of their seats? (does this need to be written separately for each car or is there a general meaning for the character?)

bright fog
muted garnet
bright fog
#

Looking at it I see a few methods that could be useful to you

#

getMaxPassengers()

muted garnet
#

hmm thanks, I'll check it out

bright fog
#

getBestSeat(IsoGameCharacter chr)

#

getPartById(String id)

#

getPartByIndex(int index)

bright fog
#

idk what it outputs tho

#

you'll have to test that

crisp fossil
#

is it possible to override a sandbox option of another mod? I tried doing the same name but it just shows both names

bright fog
bright fog
#

But perhaps there are other means of chansing a mod's sandbox options

#

Haven't looked into it tho

crisp fossil
bright fog
#

Already tried it myself

#

It ends up duplicating your sandbox options

true nova
crisp fossil
true nova
#

i mean you can change the sandbox option values outside of the sandbox.txt . the sandbox options are just variables set to a specific container type, i've only done a mod that checks the value but i would think just setting it equal to what you want would do it and then make sure you load the mod after the one you're modifying so it overwrites it. if that fails you can always find what the variable affects in the mod and just directly change that

crisp fossil
true nova
hidden compass
rich reef
#

I want to say Thank You again for everyone's help and guidance. I was able to complete a mod for my server that lets me check the rough square footage of a building and also account for how many stories the building is tall. Hours and hours of coding, and finally got it pretty dang solid. So, thank you again!

#

Fun Fact: The Louisville Grand Ohio Mall is ~207495 Square Feet in size!

ornate sand
# rich reef

Not to be a stickler but are you saying that one square is one square foot? 😁

rich reef
rich reef
# ornate sand Just checking! 😄

I checked a whole bunch of buildings, and its pretty accurate, in a rough sense to get basic square footage. Doesn't account for crazy shaped buildings, but will give a minimum for those. Using the function to enable various levels of residential safehouse claims based on the size of the building. Working awesome so far.

brittle dock
flat panther
#

Does anyone know how to make a silencer that changes the firing sound of a gun?

#

I'm also having a problem with making this separate backpack as an equippable item and it's been unusually persistent, no matter what we tried
At least two bag items have worked fine before, but this one just doesn't want to show up in-game, only a bunch of floating polygons are visible instead; the ground model works perfectly, however

echo lark
rain shard
#

Is there a method that would allow me to disable certain vanilla recipes?

flat panther
undone tapir
#

I am using a mod to disable traits from another mod for a multiplayer server.

It works when the character is made for the first time.

When that character dies and they make a new character, the disabled traits show back up.

Is there a better Event to trigger the trait disabling than Events.OnGameBoot?

Have also tried Events.OnCreatePlayer but the disabled traits still show up.

flat panther
bright fog
bronze yoke
#

check how this other mod adds its trait

#

ongameboot would be sufficient to disable a vanilla trait because that's the only time vanilla creates them

#

if that's not working for a modded trait that mod is doing something weird that we can only guess about

undone tapir
undone tapir
bright fog
undone tapir
#

yes, after the character dies and they click "new game"

#

it triggers fine the first time, it only doesnt trigger after they die and click new game

bright fog
#

Remove it for everyone ? Then that's not how you do it

outer arch
#

Hey guys, i am new to modding and i wanted to try to mod this great game. I have watched some guides and think i can do it. but i am looking for the function that returns an empty bowl after eating from it... my plan is to return it as a "Dirty bowl". can someone point me in the right direction?

undone tapir
#
KnoxTraits = KnoxTraits or {}

function KnoxTraits.initTraitTweaks()
    local traitsToDisable = {}
    table.insert(traitsToDisable, "leadfoot")
    table.insert(traitsToDisable, "bouncer")
    table.insert(traitsToDisable, "scrounger")
    table.insert(traitsToDisable, "antique")
    table.insert(traitsToDisable, "restfulsleeper")
    table.insert(traitsToDisable, "batteringram")
    table.insert(traitsToDisable, "graverobber")
    table.insert(traitsToDisable, "actionhero")
    table.insert(traitsToDisable, "secondwind")
    table.insert(traitsToDisable, "gunspecialist")
    table.insert(traitsToDisable, "Cowardly")
    table.insert(traitsToDisable, "Conspicuous")
    table.insert(traitsToDisable, "Pacifist")
    table.insert(traitsToDisable, "fearful")
    table.insert(traitsToDisable, "mundane")
    table.insert(traitsToDisable, "incomprehensive")
    table.insert(traitsToDisable, "indefatigable")
    table.insert(traitsToDisable, "ingenuitive")
    table.insert(traitsToDisable, "glassbody")
    table.insert(traitsToDisable, "Hunter")
    table.insert(traitsToDisable, "progun")    
    table.insert(traitsToDisable, "noxpshooter")
    table.insert(traitsToDisable, "terminator")
    
    for k, v in pairs(traitsToDisable) do
        local traitToDisable = TraitFactory.getTrait(v)
        
        if (traitToDisable) then
            traitToDisable:setRemoveInMP(true)
        end
    end
    
    TraitFactory.setMutualExclusive("terminator", "gunspecialist");
end

Events.OnGameBoot.Add(KnoxTraits.initTraitTweaks)

is how the mod is currently handling it

bright fog
bronze yoke
#

setRemoveInMP is a valid way to do it for a server-specific mod though

#

changing to that other method won't fix the issue

bronze yoke
#

the problem is that the changes are being undone, which likely means the mod is recreating the traits at some point other than ongameboot

bright fog
#

Which is... problematic lol

drifting ore
#

I’m trying to fix my weapons mod by looking at other mods. What does “attachment world” mean in a models .txt file?

icy escarp
#

Is there any way to extract the data out of newtiledefinitions.tiles or does anyone know how i can view the file without errors or if its possible? Without using tilezed manually

coarse sinew
icy escarp
undone tapir
#

the only file in more traits that i can find that references traitfactory is \lua\shared\NPCs\MoreTraitsMainCreationMethods.lua and it's also using Events.OnGameBoot.Add

i did a discord search and read this about loard order: "on the server, client is skipped vanilla shared -> modded shared -> vanilla server -> modded server"

i moved the trait remover.lua from client to /shared/ and then later /shared/npcs/ but it still looks like either more trait's ongameboot is happening after my removal or removal isnt happening at all

is there a way to name the file or something to make sure the traitremover.lua is processed after more traits? (its already after more traits in the load order)

bronze yoke
#

add require "NPCs/MoreTraitsMainCreationMethods.lua" to the start of your file

undone tapir
#

ty let me try that

bronze yoke
drifting ore
#

I need motivation to finish this mod. I burned out a few weeks ago.

mellow frigate
#

someone can tell me what is the expected minimum level of B42 please ?

verbal yew
undone tapir
#

ill try that one next ty. the require didn't work unfortunately

thick karma
mellow frigate
bronze yoke
#

well the lowest value guaranteed to be available in any given cell is still zero

thick karma
#

I imagine 0 to -31 would be the lowest possible range of floors based on this

bronze yoke
#

yeah

thick karma
#

Which is gonna be sick

#

Haha

bronze yoke
#

i just wonder how that'll play out with building and stuff

#

i'm sure in most places you wouldn't actually run into it but a varying height limit will feel super weird