#mod_development

1 messages · Page 235 of 1

untold orbit
#
                    if (var1.accessLevel == 1 && var4.networkAI.doCheckAccessLevel() && (var3.booleanVariables & (!SystemDisabler.getAllowDebugConnections() && !SystemDisabler.getOverrideServerConnectDebugCheck() ? '\uf000' : '쀀')) != 0 && ServerOptions.instance.AntiCheatProtectionType12.getValue() && PacketValidator.checkUser(var1)) {
                        PacketValidator.doKickUser(var1, var3.getClass().getSimpleName(), "Type12", (String)null);
                    }
...\src\main\java\zombie\network\GameServer.java:2113: error: unclosed character literal
                    if (var1.accessLevel == 1 && var4.networkAI.doCheckAccessLevel() && (var3.booleanVariables & (!SystemDisabler.getAllowDebugConnections() && !SystemDisabler.getOverrideServerConnectDebugCheck() ? '\uf000' : '쀀')) != 0 && ServerOptions.instance.AntiCheatProtectionType12.getValue() && PacketValidator.checkUser(var1)) {
                                                                                                                                                                                                                                                                     ^
#

Pointing ^ at '\uf000' : '쀀'

#

Also get a "not a statement" error

#

Additionally:

        if (PlayerToAddressMap.containsKey(var0)) {
            sendObjectChange(var0, "reanimatedID", (Object[])("ID", (double)var1.OnlineID));
        }
error: ')' expected
            sendObjectChange(var0, "reanimatedID", (Object[])("ID", (double)var1.OnlineID));
error: ';' expected
            sendObjectChange(var0, "reanimatedID", (Object[])("ID", (double)var1.OnlineID));
bronze yoke
#

you can't

#

require searches from lua/shared/ lua/client/ lua/server/, you can't require a file outside of those directories

violet shell
#

ok thanks

#

I'm trying to avoid the problem by using a global table

#

@bronze yoke ok here is my problem : it seems that global table declared in spawnpoints.lua from /maps/mymap/ does not pass to global variables/tables after because when I want to call it back in a regular lua function in /lua/shared/myfile.lua it says the table is nil.

#

my spawnpoints.lua file in /maps/myap/ which is loaded on game start/server load (=> debug print is in coop-console.txt only)

#

my lua file in lua/shared/ which call a function on player death, but I get an error on death : the spawnRandomX & spawnRandomY tables are not defined 😦

tiny wolf
#

Sorry i come from nowhere but is it possible to teleport your player to your random position with a OnCreateCharacter event ? So you do not need to use the spawnpoint.LUA system

tiny wolf
#

Maybe it will be a better solution for Asilar situation 😉

#

Ok so do someone know after how many rooms into a building game decide to do not care about Z population mask and overwrite a « full population » into a building ?

uneven vessel
#

@verbal yew i find that zombies will become and unbecome sprinters

#

does it roll every time the think checks

untold orbit
#

How do I reset the chat text once I did RGB:0,255,0 for example

#

I tried doing <TEXT> but it ruins the chat, if I don't add it then the color will be the same everywhere

thick karma
#

0, 255, 0 would just get bounded to 0, 1, 0 afaik.

slow hound
#

This is where I've gotten with the Nutrition UI itself and the data within.
the calorie average is tracked from the previous day total vs current calories but updates live

also when you have consumed too many calories too fast the arrow indicator next to weight will let you know you are gaining a lot of weight from too many calories in a short time span (not quite the same as the normal weight indicator)```
(sorry for bloom on screenshot) any suggestions that you can think would improve to be better? or better logic usage?
#

you are right about rgb 1

untold orbit
thick karma
#

Yes because it's bounding it to 0,1,0 which is also green in RGB 1

untold orbit
#

So how do I reset it?

thick karma
#

But the 255 is unnecessary and also a bad habit because Java side of the game gets mad about trying to save floats > 1 in some contexts

thick karma
#

White

#

Idr the revert-to-last command

#

Gotta try to search for the guide I mentioned but I don't have the link

untold orbit
#

1,1,1 just makes it white

thick karma
#

Well that is to my knowledge default

#

I guess it depends where you're colorizing text

#

@untold orbit

#

<PUSHRGB:R,G,B> and <POPRGB>

untold orbit
#

PUSHRGB:0,1,0 afodsajgoisdgoisdag <POPRGB> works but it makes everything be the text color before that

#

like /all is no longer orange but blue now

#

a <RESET> would be great lol

thick karma
#

Mmm not sure what you're even colorizing so I'm not sure how the tags are conflicting for you

untold orbit
#

In-game chat

thick karma
#

So if you call <POPRGB> to restore prior color it miscolors everything after that prior color would ordinarily be replaced by the next color?

#

Because does not sound how I would expect it to be intended to work...

untold orbit
#

Well if I remember correctly /all is supposed to be orange no?

thick karma
#

Idr tbh I barely use chat

#

I play with friends and we use voice

#

I use those tags primarily for coloring tooltips

#

Sorry 😦

#

Gotta AB test that I guess

untold orbit
#

That's all right, it works good enough until I figure out another way to do it

thick karma
#

Right on

#

Good luck!

untold orbit
#

but the rgb is float then? so how do I translate for example 252, 152, 3 to float?

thick karma
#

Divide each by 255

#

252/255

#

152/255

#

3/255

#

Idk what you're going for but that sounds orangish

#

An okay orange in RGB-1 is 1.0,0.6,0

#

Comes up a lot for me

untold orbit
#

thx!

thick karma
#

Can adjust from there if you're particular

#

Good luck!

slow hound
#

you trying to change a specific type of chat?

#

like yelling only or general chat only?

#

can do something like local chatType = getType()
chatType.yell etc

i'm still newish but have been messing around with things like this

#

you can find everything you need in the Chatbase file though

untold orbit
#

nah I am sending processGeneralMessage with PUSHRGB:0,1,0 and then trying to reset problem is whenever I push all chats become that color and when I do poprgb all chats get the color that was previously

slow hound
#

ahh

frank elbow
#

Are you making sure you have spaces before and after the command? The rich text parser is a bit finicky about that

untold orbit
#

I don't maybe thats why

frank elbow
#

Usually that just leads to text being "eaten", rather than colors being off, but worth a shot

untold orbit
#

Yeah it didn't help

frank elbow
#

It's worth backing up here; what's the goal?

#

Beyond just "coloring a message", I mean—one message? part of one?

#

& what's the code you're currently using to do so?

untold orbit
#

Sending a welcome message, its done through lua but I guess I could look into doing it via java instead now that I started modding that part of the game

frank elbow
#

That should be entirely possible through Lua

untold orbit
#

Well it is possible, and I am using processGeneralMessage and it all works, but the color issue persist

untold orbit
#

Well I send a server command with the username, get that on the client then just

processGeneralMessage(" <PUSHRGB:0,1,0> " .. args[1] .. " connected <POPRGB> ")

It works but the issue with the colors persist

thick karma
#

@turbid gale Do you mind if I share how to fix that bug here for any lurkers who are learning?

frank elbow
#

To my knowledge, anyway. Those would be replaced with &lt; and &gt;, so I'm a bit confused

untold orbit
#

What does < and > do? And it does work tho

frank elbow
#

Those are character replacements that ultimately would show as < and > in chat. I'd like to see a screenshot to make sure it's the color expected from that

untold orbit
#

Ignore the white boxes (added in Paint)

frank elbow
#

Weird. This is with only that mod active?

untold orbit
#

Well no but none of the other mods interact with chat afaik

verbal yew
turbid gale
#

Yeah go ahead

frank elbow
turbid gale
#

I don't consider anything proprietary. Looking at other mods is the best way to learn.

untold orbit
#

Maybe this is the reason lol

local _ChatMessage = __classmetatables[ChatMessage.class].__index

function _ChatMessage:getTextWithPrefix()
    local text = self:getText() 

    if string.find(text, " connected") then
        return text
    end

    if string.find(text, " disconnected") then
        return text
    end

    return self:getAuthor() .. ": " .. text

end
frank elbow
#

Ah yeah that'd do it—the replacement occurs in the Java-side implementation of that

#

Generally the "prefix" includes a color as well, so that's likely the source of the bug too

#

i.e., you don't include messages' colors, so they're using the leftover one

untold orbit
#

Would I be able to fix this code or do I have to work with Java?

frank elbow
#

You can fix it by rewriting the color in that function

thick karma
#

@dense cliff Alrighty permission granted:

local IrisBugFixesVFE = {}

IrisBugFixesVFE.needed = getActivatedMods():contains("VFExpansion1")

if IrisBugFixesVFE.needed then
    require("VFE_WeaponScriptOverwrite")
else
    return IrisBugFixesVFE
end

IrisBugFixesVFE.ReloadWeaponAction = {}

IrisBugFixesVFE.ReloadWeaponAction.setReloadSpeed = ISReloadWeaponAction.setReloadSpeed

function ISReloadWeaponAction.setReloadSpeed(player, rack)
    local primary = player:getPrimaryHandItem()

    local worthy = primary and primary.getAmmoType and primary.getRecoilpad and primary.getSling

    if not worthy then return end --> ADDED CHECK FOR EXISTENCE OF NECESSARY FUNCTIONALITY
    
    IrisBugFixesVFE.ReloadWeaponAction.setReloadSpeed(player, rack)
end

return IrisBugFixesVFE

(Fixes a bug in VFE where primary hand item is not a gun.)

verbal yew
#

guys, which information from food item transfered in new item when its be "ReplaceOnCooked"?
ModData transfered?

untold orbit
frank elbow
uneven vessel
verbal yew
uneven vessel
#

they are definitely changing

#

I have 98 fast shambler 2 sprinter

#

and they sometimes begin sprinting

#

sometimes stop

untold orbit
thick karma
#

@dense cliff DMing you a folder, then will explain

dense cliff
#

Ok, thank you

uneven vessel
#

and I've had catastrophic scenarios in which the number of sprinters keep increasing, but that could've been bad luck

frank elbow
uneven vessel
#

I was watching my players as a dm and a horde of normals slowly turned 1 by 1 until there was 7 sprinters

verbal yew
frank elbow
uneven vessel
#

oh it happening? sure next timei see it

#

oh my fucking god

#

i just got jumped by 6 sprinters

#

as soon as i said that

verbal yew
untold orbit
#

aa so technically I could just deal with all the coloring in function _ChatMessage:getTextWithPrefix() by using getChatID()

uneven vessel
#

maybe it is interacting with my other mod screamerz by braven

#

?

frank elbow
verbal yew
untold orbit
#

Not if I want different colors for all chats 😜

uneven vessel
#

makes sprinters scream

verbal yew
#

perhaps

frank elbow
frank elbow
jade yew
#

Helloooo. So. I am brand new to modding. Not just PZ but in general. But I love PZ and I'm just starting out in the modding. I've installed blender, visual studio and some lua plugins. And I've found some guides. Any resources I can use to help me?

uneven vessel
frank elbow
#

The pins have a link to the modding wiki, which has some resources. Unsure how up-to-date it all is, though. Checking out the code of existing mods is good to learn, with the caveat that it's worth taking care to not pick up bad habits

jade yew
uneven vessel
#

yup

#

what do you wanna do?

jade yew
#

I want to try making an actual food truck. There's an ice cream truck mod and taco truck mod. But I'd like to make a mod where you can actually stand in the side window with an oven, etc. For RP servers.

#

There's no mods for it. So I want to learn how to make it myself. xD

uneven vessel
#

Hmmmmmmmmmmmmm

#

There's a mod that lets you be on vehicles already

jade yew
#

I might be able to use the taco truck mod since it has the side window and stuff.

uneven vessel
#

probably something here you can use

jade yew
#

Thanks :D

manic magnet
#

There is a semi truck mod that when in the back seats gives you access to a microwave and mini fridge. You could look through there for adding something like access to ovens and fridges in the rear seats of vehicles.

jade yew
uneven vessel
#

The Ki5 humvee has a trunk that can be accessed from the inside

#

and you can put items in it

#

and people outside can retrieve them

#

so it should be possible

jade yew
#

Oh yeah, their land rover mods and stuff

#

That'd be good to look into

#

Thankies

manic magnet
jade yew
manic magnet
#

Yeah. No worries. It takes me forever to do most stuff as well. 🤣

#

Mostly because I will redo everything like 10 times before I am happy with it. lol

echo lark
#

is it possible to write a function that does somethign only when a specific item is equipped? i know theres the event OnEquipPrimary, but i dont want the function to check or be called every time a item is equipped in the primary, only when a specific weapon is

manic magnet
echo lark
manic magnet
#

Then just add your function to the event.

echo lark
violet shell
#

spawnpoints.lua is loaded serverside right ?

manic magnet
manic magnet
#

I know you can point to a file in spawnpoints for a local file and a serverfile (variable name might be wrong here, I can't check at the moment) for server side files that define spawns.

echo lark
manic magnet
violet shell
#

Ok, First time messing around with gloabal ModData

#

Can you tell me if I'm going the right direction or not ?

echo lark
#

thanks for the help!!

tawdry solar
#

can i make a gun fire super fast ?

manic magnet
violet shell
#

The idea is to inject new spawnpoints coordinates on death of a player, so they cannot respawn at the same place

#

I'm trying to get around the 1 time loading spawnpoints.lua at server start/game start

manic magnet
#

I see... I haven't ever attempted to put anything like that in spawnpoints.lua... It could work?

violet shell
#

but the problem is that if the player dies, and respawn in the same cell, the posX and posY would be the same (because spawnpoints.lua is loaded only on startup)

#

@thick karma I cannot call spawnpoints.lua from media/lua/ lua files because spawnpoints.lua is stored in media/maps/mymap/ so I cannot use the require() function to call it later. Also, all global variables are reset on death, so Braven pointed me at global ModData to get around that.

thick karma
#

Not all global variables reset on death... I'm not sure what you're referencing but that is definitely not true clientside of global variables generally.

violet shell
#

I tried to globalize spawnRandomX & spawnRandomY but it didn'twork at all

thick karma
#

That's not because they reset though.

violet shell
#

I declared spawnRandomX & spawnRandomY as global tables in spawnpoints.lua

thick karma
#

It sounds like SpawnPoints ran again when you died and cleared those tables by redeclaring them as {}

violet shell
#

but when I called them in my regular lua function (in lua/shared/myfile.lua) it said it was null

thick karma
#

I'm guessing you called something serverside from client

#

And it doesn't exist clientside

violet shell
#

ok, so I should use Global ModData and use the send/request functions ?

#

or there is another way to transmit serverside tables to client ?

thick karma
thick karma
violet shell
#

Sure, what I want to do is that when a player choose my random spawn location, they spawn in a totally random point. To do so, my idea was to randomize the coordinates with ZombRand. To make it simple at first, I chose 11 cells in wilderness and only randomized posX & posY values in spawnpoints.lua

#

but the issue is that SpawnPoints() which is in spawnpoints.lua is only called once (when server starts). So I had the idea to call for a resetSpawnpoints() function with Events.OnPlayerDeath.Add().

#

At first I wanted to call back the SpawnPoints() with a require(), but I cannot use that because require() is limited to /media/lua/ folders, and spawnpoints.lua is stored in /media/maps/. So I tried to get around that using global tables, but didn't work either, and was digging towards the global modData 🙂

#

@thick karma is it clearer ? files at which step do you want ?

thick karma
#

That's clearer. I am looking at the files. It seems that client pulls regions from server using MapSpawnSelect:getSpawnRegions()

#

That calls SpawnRegionMgr.getSpawnRegions() , and if you're a multiplayer client you end up calling getServerSpawnRegions() which appears to be an exposed global function

#

Meaning to get this working (if it's even possible) you'd need to get server to update its regions and then tell client to redo the process of pulling correct server data.

#

Also I think direct access of SpawnPoints is a no go

#

It seems to get redefined by many maps and called at file load time

#

And you can't call it right without reinitializing all the spawn points of all spawn point files as far as I can tell

violet shell
#

@thick karma ok, so do you see a way to go or it's almost impossible ?

#

what I don't understand is how the client knows the spawnlocations after a character dies. Where those data are stored. If I can find out this, I maybe can find a way to modify it right ?

thick karma
tawdry solar
#

which one of those 2 in the model files change the position of the model ingame?

thick karma
#
function MapSpawnSelect:fillList()
    self.listbox:clear()
    local regions = self:getSpawnRegions()
    if not regions then return end
    for _,v in ipairs(regions) do
        local info = getMapInfo(v.name)
        if info then
            local item = {};
            item.name = info.title or "NO TITLE";
            item.region = v;
            item.dir = v.name;
            item.desc = info.description or "NO DESCRIPTION";
            item.worldimage = info.thumb;
            self.listbox:addItem(item.name, item);
        else
            local item = {}
            item.name = v.name;
            item.region = v;
            item.dir = "";
            item.desc = "";
            item.worldimage = nil;
            self.listbox:addItem(item.name, item);
        end
    end
    self.listbox:sort()

    self:hideOrShowSaveName()
end
tawdry solar
#

but i dont know how to get it the right way

slow hound
scarlet fulcrum
#

hello 😄 not entirely a modding question but probably not fitting for #mod_support either - does anyone have any recommendations for good monitoring suites that work well with PZ to check for performance bottlenecks on dedicated servers? I'm presuming there's no APM stuff built-in by default since I can't find any on google

tawdry solar
#

mine is the correct size

#

its just not hte correct direction

slow hound
#

that's for rotation

#

not size

tawdry solar
#

yeah i never said that

slow hound
#

so rotation is good but the actual location offset is not good you say?

tawdry solar
#

yeah

#

i changed it to be an actual size and position of an actual model ingame

#

transforms actually helped

#

huh

slow hound
#

YW

tawdry solar
#

thanks

slow hound
#

i think it's about applying them and good to go hehe

#

Going to take my Zomboid plunger and go find some more toilets

tawdry solar
#

how can i find list of weapon anims ?

red tiger
#

Good evening.

uneven vessel
#

Does anyone know how profession framework handles foraging bonuses?

#
    name = "Internal Forces",
    icon = "profession_InternalForces",
    cost = 0,
    xp = {
        [Perks.Doctor] = 1,
        [Perks.Aiming] = 1,
        [Perks.Reloading] = 1,
        [Perks.Nimble] = 1,
        [Perks.Lightfoot] = 1,
        [Perks.Fitness] = 1,
        [Perks.Woodwork] = 1,
        [Perks.Maintenance] = 1,
    },
    traits = {
        'Brave',
    },
})```
#

I got this so far but I wanna give them better foraging like everyone else

verbal yew
#

i think proffession framework not support somethink like that

uneven vessel
#

ah well i don't need it that bad

#

:3

verbal yew
#

and for Brave should be create workaround like in SOTO
Because Brave is selectable trait. Its mean when i take your profession - i can throw away brave and get free point trait from brave cost

uneven vessel
#

yes i noticed

#

but my players are all good boys

#

they would never

verbal yew
#

like in soto has Brave2 with same ui icon, text, etc, but cant be selected, only getting from proffession
and event onCreatePlayer - where check if player has Brave2 - remove Brave2, add Brave.

#

ah, okay, understood

uneven vessel
#

soto?

#

oh

#

maybe i will do that then

uneven vessel
#

Does anyone know why this gun's textures invert when the gun becomes bloody?

thick karma
#

And it calls that when it's built presumably to populate its list right.

red tiger
#

Good morning. (06:15 AM)

violet shell
versed ibex
#

how is there not any type of "ring mod" that adds rare drop chance rings that have effects like inventory reduction, strength boost, etc ?

severe crane
versed ibex
#

i mean theres literally a spaceship mod but i feel ya

severe crane
#

also @versed ibex are you good at map modding?

versed ibex
#

no sir

thick karma
#

That's Lua

red tiger
#

Hahaha.

#

I'm working on type-discovery reference chains and scope-referencing from global context with Lua code right now.

#

I'm doing this in TypeScript using the luaparse npm library.

#

Started doing this last night. I'm already 1000+ lines in.

#

But basically using lua-language-server annotative-typings syntax, I'm working backwards variable assignments and assigning their types using discovery through luaparse AST objects.

#

=)

#

Provided this solution works effectively, this will literally save me like over a thousand hours at least of manual type assignments for the Lua API documentation I have planned.

#

Thought it would be fun to share this silliness here.

flat panther
#

How do you make a muzzleflash effect work on custom guns?

violet shell
red tiger
violet shell
#

lol 🙂

#

If you want to work on that, I'll be very grateful too 😄

red tiger
#

hahah

#

Yeah I look for those in general. That's what I mean't.

#

I realized recently that some people define commissions as also free work which I didn't think was a thing.

thick karma
#

"I have an idea. Anyone want to do all the work of making it reality in exchange for hearing it? This is a commission so I want credit for the idea and a link back to my profile page. Also, it'll only be allowed on my server. I want you to add code that will break the mod on any server but mine. Thanks."

red tiger
#

lol

#

I'm serious.

thick karma
#

Lighting Bags of Poo -- A mod commissioned by DoucherMcGee

red tiger
#

I'd imagine publicly releasing the method(s) on how to do this might make some people grumpy. =)

#

PZ modding silliness.

bronze yoke
#

it's pretty straight forward really, i know some servers already do it

red tiger
#

I did it back in 2015/2016 with a server I worked for.

thick karma
#

Process is so simple, any server could do it.

#

🙃

#

😏

thick karma
#

Is there a way to ping a distant location to determine whether a player is even allowed to stand there before they arrive?

brittle dock
#

If you're able to get the tile info of the ISOGridSquare you're wanting to ping, you could check isSolid(), isSolidTrans() and HasStairs()?

#

How are you wanting to select the tile to "ping"? Might not be terribly difficult if you just want to check a certain number of tiles ahead of where your character is facing?

coarse sinew
#

If that tile is not loaded, I don't think you can check

red tiger
#

I'd imagine that you can load the area with the tile then check

thick karma
#

I'm thinking of any workarounds for the random spawn goal but without knowing whether the landing location is safe, you would have to God mode people and move them until it were, which seems undesirable

brittle dock
#

Ah, random spawn mod or something?

thick karma
#

Asilar is trying to solve that

#

And I was just openly brainstorming

#

You could randomly TP people after they are first created, but it wouldn't be totally safe to pick random coords

#

Thinking about how to limit it to safe coords

brittle dock
#

I was about to pseudocode something, but let me grab some coffee and expand on this idea

red tiger
#

I vein my coffee directly as IV fluid.

#

I am a perpetual earthquake.

red tiger
#

Coding / working on my tool until I drop from being tired.

verbal yew
#

getBaseHunger() - it's what?

#

HungerChange ?


It's HungerChange/100

flat panther
brittle dock
flat panther
#

we just don't have it in all of the guns that we made yet

dawn shuttle
#

Anyone knows if adding a file using getModFileWriter will cause the server checksum to have issues?

#

The file is an .ini file in case the checksum ignores certain file types

gleaming sorrel
#

I recently made a new mod but it's not showing up in the modlist

It seems others are having the same issue but I'm not sure how to fix it

bronze yoke
#

prefer getFileWriter

#

that writes to Zomboid/Lua/

thick karma
brittle dock
thick karma
#

Haha... From the feedback, most people think it's just too much better than Cat's Eyes and many other 4-5 point traits.

#

Zomboid is a game where the darkness kills you from time to time and Darkvision nearly eliminates the threat of darkness itself.

#

Now, the zeds who are angrier at night, not so much.

brittle dock
#

No idea why that just triggered these specific neurons to fire, but I really need to try "Fear the Rain" or whatever it's called. It's been out for AGES and I've never tried it, but I imagine it could be terrifying

thick karma
#

That does sound fun

brittle dock
#

If you're not familiar, it makes zombies programmed to avoid rain, so they try to break down windows and doors to get inside during storms

thick karma
#

Oh lmao that's classic

#

I figured they just got more aggressive during rain

neat herald
#

Having an issue with a test recipe file not working. I can't seem to find errors in the logs when the server is loading the file either.
Is there a tool to check recipe files for errors or is there a file location where I can check for error logs?

neat herald
brittle dock
#

Should be a red icon in the bottom right (by default) when you pause the game

neat herald
#

Issue is that the server starts but the file causes a black screen and we cannot enter the server to access the game

#

Therefore error mag can't even checked

#

Can't seem to find anything in the server logs about the file either

brittle dock
#

All of the server mods are updated, and you're joining with the same versions?

neat herald
#

Yes

#

This is a test server we are working and we know the issue is the file.

gleaming sorrel
#

I really need to know how to fix my mod
I uploaded it to the workshop
Yet it doesn't appear in the Zomboid modlist

Others have the same problem but I'm not sure what's causing it

neat herald
#

Does anyone know of a tool to check recipe files for errors or is there a file location where I can check for recipe error logs?

thick karma
#

From Zomboid/Workshop down

gleaming sorrel
thick karma
#

If so, I'm thinking directories must be wrong

gleaming sorrel
thick karma
#

If you zip me I'll check your directories.

gleaming sorrel
bright fog
#

Or if you have a github repository tbf

brittle dock
gleaming sorrel
gleaming sorrel
thick karma
#

I'm guessing you tested it locally in Zomboid/mods, it worked, you transferred it to Workshop and uploaded?

thick karma
#

That would strongly suggest a directory issue but I'm checkin

#

Okay I think your mod.info may be part of your problem.

#

Idk what icon is for tbh, maybe it works or maybe it's an issue, but you are definitely pointing to poster.png while using a file saved as poster.jpg... need to switch to png for sure.

Also, you have an empty pack= line, and I don't like the sound of that. I'm guessing you need to delete or use it.

#

So delete or use pack, fix poster.jpg, and maybe delete icon line are first 3 things I'd try.

#

Also I'd delete the blank line

#

I don't know but I wouldn't bet on blank lines in mod.info

gleaming sorrel
#

I'll try it thank you

thick karma
#

Good luck... folders actually do seem right. I assume Left 4 Dead Re-Texture is inside Workshop directly?

gleaming sorrel
#

Yes

thick karma
#

Yeah everything but that mod.info looks p normal

#

Empty texturepacks folder could be deleted I imagine

#

Since that's a vanilla game folder I don't think it's cause issues as a leftover

#

But I also don't think it'd stop you from loading mod...

gleaming sorrel
#

I have empty pack folders as a way to add moodles in the future when I figure out how to do so consistently

It has never caused any problems in the past to my knowledge keeping the texturepack folder empty

#

Though I never have a empty pack line to go along with it

bronze yoke
#

if it works locally i'd be surprised if it was causing problems on the workshop

#

it's not like the game reads mod.infos from the workshop differently

gleaming sorrel
#

but it works now

thick karma
#

Glad you got it sorted!

visual birch
#

hello pple, i want to create a mod for disabled pvp only in same faction, actually we have an option in game, but its a single option / player for disable it. Anyone for help me?

slow hound
#

for

zombie.characters.BodyDamage.Metabolics

How would I call this for a player to Obtain the
getMet() value of the player?

I feel like i'm having a stupid moment

#

i'm essentially tryin to get the float value of the current action state

bright fog
#

Good question

slow hound
#

😦

bright fog
#

Trying to look at the doc and not sure how

slow hound
#

I tried getMetabolicTarget and nil also

bright fog
#

Sounds like it's unused tbf

slow hound
#

I may end up manually defining the current action state float values using the floats I see in the
Metabolics class, but I would really like this to be dynamic

bright fog
#

What do you need this for exactly ?

slow hound
#
function NutritionUtility.calculateCalorieBurnRate(weight, activityLevel, playerTemp)
    local baseBMR = 0.016 * (weight / 80)
    local temperatureFactor = 1 + (playerTemp - 37) * 0.01
    return baseBMR * activityLevel * temperatureFactor
end
#

calories per second tracker

#

everythign works except getting this float value dynamically

#

activitylevel is the float

thick karma
bright fog
#
local bodyDamage = getPlayer():getBodyDamage()
local thermo = bodyDamage:getThermoregulator()
local met = thermo:getMetabolicTarget()
slow hound
#

hmm

bright fog
#

tho it's target

#

so eh

#

But outputs a float

#

So idk man

slow hound
#
function PlayerClimateDebug:initVariables()
    local thermos = self.player:getBodyDamage():getThermoregulator();
    local stats = self.player:getStats();
    local body = self.player:getBodyDamage();
    local nutrition = self.player:getNutrition();
    local climate = getClimateManager();

    self.vars = {};
    self:registerVariable("title_main","MAIN",false);
    self:registerVariable("getMetabolicTarget", "MetabolicTarget:", true, thermos, 0, nil, nil);

has to be i guess

#

is this only in debug though? i can still use this out of debug?

#

it's the only place i see

#

appreciate it by the way. i am right on the edge of just manually defining them since it's based on the player state anyways so the specific number isn't as important as just tracking the value depending on the state itself

echo lark
#

hey guys, is there a way to apply tags using doparam to item, but not overwrite the items previous tags?, trying to make guns of 93 magazines/guns work with The Workshop disasemble recipes by adding the tags that the recipes call for to dissasemble, but dont want to overwrite the existing tags on the mags/guns

bronze yoke
#

it's actually perfectly safe to do it with doparam, it won't override

violet shell
violet shell
#

I'll dig that.

bronze yoke
# echo lark oh, lol thanks XD

however it is slightly better practice to instead do```lua
local tags = item:getTags()
if not tags:contains("MyTag") then
tags:add("MyTag")
end

#

if you do it with DoParam it can add the same tag twice, which doesn't really do much, but it can cause the very slightest amount of slowdown

echo lark
thick karma
#

You would need to artificially determine safe ranges

violet shell
#

Yeah, that's what I did in the first place, manually selected 11 cells, and randomized coords inside those cells

thick karma
#

Maybe you could create some kind of weighted-odds table that players could edit to add random locations within known territories.

violet shell
#

but I was wondering, if we can "scan" a tile as you asked before, maybe we could scan for an area of tiles and say : spawn is possible only if XX% of the tiles around are grass tiles ?

slow hound
#

would you be able to get the final built spawnpoints.lua values directly right after the event is triggered post-merge and pre determine the available worldx and worldy positions?

#

just shooting random things out there but seems possible maybe

thick karma
#

I guess they could be teleported to a bad spot and then very quickly moved nearby... That might be okay but hard to say.

#

It might immediately kill them

#

Pairing with something like Udderly Safe Login might be necessary

worldly wing
thick karma
#

Missing comma on Item

worldly wing
#

ain't no way

#

lol

#

i hate programming

#

thanks

thick karma
#

"You don't have a clip for that sound!" lied the game.

gleaming sorrel
#

Does anybody know how I would add a video to the steam workshop page of my mod

I find it works much better for showcasing

worldly wing
steady lagoon
#

Hey folks, is there a way to check if a mod is installed through lua?

nova socket
steady lagoon
#

I apologise, I mean if there's a way to check, through LUA, if a mod is installed

nova socket
#

oh that

#

yeah thats easy

steady lagoon
#

essentially I don't want to run a line of code if a mod is not installed

#

therefore I need a flag for it, but is there a getter for this?

nova socket
steady lagoon
#

I see, where do I find the ID string of a mod?

nova socket
#

mod.info of specified mod

steady lagoon
#

thank you very much

#

just for reference, what is the relevant class for "getActivatedMods"?

#

GlobalObject?

nova socket
#

ye

#

https://projectzomboid.com/modding/zombie/Lua/LuaManager.GlobalObject.html#getActivatedMods()

steady lagoon
#

thank you very much

nova socket
#

everytime i come back to modding zomboid its always a goddamn pleasure, you start to appreciate the amount of exposure to things when you get into modding other games just to realize you cannot utilize 90% of what's there.

bright fog
#

@gleaming sorrel lovely :)

uneven ore
#

How do I make Variables Persist after Quiting the Game?

dawn shuttle
# uneven ore How do I make Variables Persist after Quiting the Game?

Best way would be to use mod data. Any Iso objects, grid square, inv item, etc, can call getModData()

From there you can create a custom entry to store your information and will be available next time you load the game. You'll also need to call transmitModData to save your changes

#

Tip: make your entry key unique as other mods can store data

uneven ore
dawn shuttle
#

Do you call transmitModData?

uneven ore
dawn shuttle
#

Read my response in full then 😉

uneven ore
dawn shuttle
#

No arguments needed

uneven ore
dawn shuttle
#

getModData returns a KahluaTable. Which allows you to add/update new keys. Since getModData passes by reference and not value, any changes to that KahluaTable will be applied to the mod data. transmitModData will then save this change in memory.

`player = getPlayer();

playermoddata = player:getModData()

-- on world load
playermoddata["myCustomModKey"] = 42

player:transmitModData()`

uneven ore
uneven ore
gleaming sorrel
echo lark
#

anyone know why an item wouldnt should up in a recipe even though it has the require tag the recipe calls for?

#

in TW theres this recipe

#

which is this function

#

and i used lua to apply tags to the items, and i see the tags in the craft helper, but they still dont show up/cant disasemble them

bright fog
gleaming sorrel
#

It's like a true Left 4 Dead realism mode

dawn shuttle
# uneven ore Is the Entry key the '42' or inside the [ ] ?

If that is not clear, then I would suggest to read up a bit first on how Lua table works. It will save you A LOT of headaches 🙂

Here's a nice little StackOverflow on the matter: https://stackoverflow.com/questions/7933703/inserting-key-pairs-into-lua-table

And here's a good lua tutorial, here's the page for tables https://www.tutorialspoint.com/lua/lua_tables.htm

uneven ore
#

alright

echo lark
urban plaza
#

is Konijima still active? I noticed he hasn't posted in the discord since June of last year and his github hasn't had activity since the same time.

also his twitter apparently was suspended: https://twitter.com/KonijimaMods

X
#

wait no he committed once on feb 26th to a private repo

thick karma
#

Define active

urban plaza
#

yeah hence the question

#

"alive"

#

"modding"

thick karma
#

Maybe

urban plaza
#

"having left or taken vacation"

thick karma
#

Hard to know

urban plaza
#

"gainfully employed"

thick karma
#

I haven't heard of him explicitly quitting or being involved in specific PZ work

#

Just seemed to stop showing up as many do

#

His last posts don't exactly say f you guys

urban plaza
#

yeah. I figured I'd ask given the twitter account suspension

thick karma
#

No idea about that

urban plaza
echo lark
#

hmm so ive been poking around and asking here about applying tags to weapons and found a method that seemed to work, except it wasnt able to be used in the recipes that call those tags. i can see the items have the tag in the craft helper, but cant be used in the recipes

#

function vcApplyTagsGun()
local items = getAllItems();

for i = 0, items:size() - 1 do
  local item = items:get(i)

  if item:getTypeString() == "Weapon" and item:isRanged() then
    local tags = item:getTags()
    if not tags:contains("Gun") then
      tags:add("Gun")
    end
  end
end

end

Events.OnInitGlobalModData.Add(vcApplyTagsGun)

thats the code i used

#

anybody know whats wrong?

autumn summit
gleaming sorrel
slow hound
#

edit the workshop page and there is a place to add videos

gleaming sorrel
slow hound
#

you post to youtube and share the link

#

just post it and quick add and make it public. if you don't care about views or SEO you can get it uploaded in 2 minutes max

#

other option is embedding gifs to the page itself

#

sharex 60fps gif keeps quality and file size isn't horrible

#

--Okay, going to ask once more before i manually declare each value by action state....

does anyone know how to read the getMet method float value from the Metabolic class of a player? is this possible? i know

function NutritionUtility.getActivityLevel()
    local bodyDamage = getPlayer():getBodyDamage()
    local thermoregulator = bodyDamage:getThermoregulator()
    local metabolicTarget = thermoregulator:getMetabolicTarget()
    local activityLevel = metabolicTarget:getMet()
    return activityLevel
end

this returns nil.

#

I'm trying to detect the float value that should be passed from the getMet method of the Metabolic class. the float value should represent the multiplier for metabolic rates based on character action state. in theory i guess since it's not working

gleaming sorrel
slow hound
#

Nevermind. i'm thinking that this java class is just a list of predefined floats that are already declared so even though i can probably get it using something like Metabolics.Running10kmh:getMet, it' seems like extra work for no reason when i'm going to have to still get the list of actionstatenames anyways. man what a pain.

bright fog
bright fog
#

Check my mod page for an example

#

You can make great looking stuff thay way

verbal yew
#

result:setCustomName(true); result:setCustomWeight(true);
This is a required staff when you change the weight and name of an item through recipes.
What does this even do?
I just didn't notice much difference without these two attributes...

gusty night
#

how much it gonna take for a halo flood zed retexture 🙏 🙏 🙏 🙏

#

i would legit pay for a good halo flood zed retexture lowkey

#

depression

bright fog
#

@median prairie on the other hand did the Occult zombies mod and I did the Bloater model for my mod TLOU infected so we know a bit more on modeling custom bodies for zombies

#

(There's probably others out there who know a bunch on the subject too)

#

I personally don't take commissions however but idk for Nerm and Mystery

red tiger
#

Good morning. (3:45 AM)

bright fog
#

Oof

#

11 am for me

red tiger
#

I woke up around this time yesterday and then proceeded to put in 15 hours of coding.

gusty night
red tiger
#

I am writing code that analyzes Lua code, linking references and assignments and discovering types, applying them.

bright fog
gusty night
gusty night
red tiger
bright fog
#

Of course give me a sec

gusty night
# red tiger

just looking at that burnt a hole through my brain and i barely understand any of it in the first place

red tiger
#

Oh. This is my realm. I work heavily in abstract, fundamental stuff in code.

gusty night
#

yeah even going near any amount of coding just hits me with the 25+ days straight worth of trying to code trauma 🔥

red tiger
#

Good thing I haven't posted the GitHub link to the file responsible for generating that data.

#

lol

#

The code is recursive too.

bronze yoke
#

so your items don't have the tag yet when the game checks for them

#

in your case you can just remove your code from the event and call it during the file load, your function doesn't do anything that needs to be delayed to work

echo lark
bronze yoke
#

yeah!

echo lark
peak nymph
echo lark
#

so as someone who has never added sandbox settings to any code ive written, how easy is it?, im about to start looking into it to add the option to skip adding the tags from my code if the item is in the sandbox setting. this is the code i have:
function vcApplyTagsGun()
local items = getAllItems();

for i = 0, items:size() - 1 do
  local item = items:get(i)

  if item:getTypeString() == "Weapon" and item:isRanged() then
    local tags = item:getTags()
    if not tags:contains("Gun") then
     tags:add("Gun")
    end
  end
end

end

vcApplyTagsGun()

function vcApplyTagsGunMag()
local items = getAllItems();

for i = 0, items:size() - 1 do
  local item = items:get(i)

  if item:getDisplayCategory() == "Ammo" and item:getAmmoType() then
    local tags = item:getTags()
    if not tags:contains("GunMag") then
     tags:add("GunMag")
    end
  end
end

end

vcApplyTagsGunMag()

would it be easy to add that to this code?

verbal yew
#

nil same as false?

bright fog
verbal yew
#

thanks

bright fog
#

Acts the same at least but if you do variable == false it's not the same as variable == nil but if you do not variable then it's the same as both

frank elbow
#

Also not the same when it comes to resolution of Java calls

verbal yew
#

need to rest from coding...

brittle dock
bright fog
#

or non existant

#

Like

tbl = {}
tbl.variable <-- nil
verbal yew
#

local b = nil
if b ~= nil then

its bad stuff? xD

bronze yoke
#

nil evaluates to false but nil is not false

#

nil is nil

bright fog
frank elbow
bronze yoke
frank elbow
#

Also, for future reference, you can format code on discord by enclosing it in two sets of three grave accents. So:
```lua
code
```

Becomes

code
bronze yoke
#

i think i got around this by caching the source during the GetItemTypes function and editing it upon OnInitGlobalModData?

echo lark
bronze yoke
#

ah, no, i just grabbed the recipe source directly

indigo rune
#

Someone plz make a mod that adds graph paper for planning out floorplans

brittle dock
brittle dock
bronze yoke
#
local addSandboxItems = function()
    if SandboxVars.MyMod.MyVar then
        -- the get(x) is the source in the order it appears in the recipe
        local source = ScriptManager.instance:getRecipe("Recipe Name"):getSource():get(0):getItems()
        source:add("farming.Potato")
    end
end

Events.OnInitGlobalModData.Add(addSandboxItems)
bronze yoke
indigo rune
#

Is it a seperate discord ?

brittle dock
#

There's a requests channel near the bottom of the list 🍻

frank elbow
#

There's also a thread here for mod ideas

#

Not to dissuade you from joining that, just saying. The one here is likely much less active

indigo rune
#

thanks 🙂

modern ruin
#

Hello, I've recently started modding Zomboid and I'm currently developing a mod that includes guns but I'm having an issue where there's no muzzle flash upon shooting the custom gun. Could anyone help with that?

brittle dock
#

I figure both are good resources depending on how much you want the idea realized; if it's a cool idea that you'd like to maybe see implemented one day, a modder with free time might see it here, or it might spark a conversation. If you actively want this created, hard to beat the direct nature of commissioning.

bright fog
#

yup

#

As usual with mod ideas, don't expect anything to be done unless you pay for it

#

If a modder ever does it, great for you but there's a very high chance no one will work on it unless the idea is revolutionary and not too hardly done

brittle dock
#

That being said, I'm currently working on an idea that was sparked by a conversation in last month's Thursdoid.

#

But it'll be my interpretation of the idea

bright fog
#

Recently got an idea for a mod myself with the last dev blog bcs I felt it was a miss that they went with the crafting recipe for storing items within boxes

#

You could simply have boxes where the player actually puts items per items in it

#

And the texture of the box could even update to show how many items are in it

pine patio
#

We already have boxes that do that... They are just tiles, but still

frank elbow
#

Based on the bit in the blog about save file space efficiency I imagine that was an intentional decision

bright fog
#

And I don't want tiles

#

I want transportable items/placeable visually in 3D

#

And that's definitely doable

#

But like no one has done that for some reasons

#

Like have a simple counter of items within a box

#

And then you can change the texture based on the number of items in it or even easier just don't change the texture at all

pine patio
#

So... basically a box shaped backpack?

bright fog
#

Have you never used the mods that add boxes/piles of items ?

pine patio
#

Only hanabi drinks. Let's you turn 12 cans of soda into a single box

bright fog
#

Well that's exactly this but instead of being limited to putting 12 cans in a box

#

You could put as many as you want

bronze yoke
#

you mean a container?

bright fog
#

Put 1 by 1

brittle dock
coarse sinew
bright fog
bright fog
#

Have an item = multiple items

bronze yoke
#

you need to store all the information about the items if you want them to stay individual

pine patio
#

I'm not an expert in modding, but the grappling stuff means that shopping carts are now a possibility?

bronze yoke
#

there's already a couple shopping cart mods

frank elbow
#

Depending on how they implement the boxes I imagine there could be a “best of both worlds” of storing only the relevant information about individual items. I have a feeling it'll only be for items where that wouldn't be a concern, though

bronze yoke
#

the grappling stuff is for two animated characters to interact, you can already have one animated character interact with an object fine

frank elbow
#

I assume the “water rations” from the blog are exclusively unopened, for example (gonna need to rewatch to see whether there's evidence to the contrary)

echo lark
echo lark
bronze yoke
#

yeah, just :remove("farming.Potato") will search for farming.Potato in that list and remove it if it's there

echo lark
echo lark
bright fog
bright fog
#

Did you make variable animations ?

#

Sry variable textures I meant

#

/models

echo lark
# bright fog Did you make variable animations ?

nope, so far all thel models are like a big rubbermaid packing bin. except for a few that i made quickly. but basically i was doign the x10 boxes one model, the x20 boxes a diferent model. then all the x50/x100 are going to be the basic rubbermaid packing bin

#

but that would be a neat idea

bright fog
#

Yeah exactly so you see cans getting added on the texture / model

echo lark
#

i literally just finnished the mod like a week ago, and am using it on the server i admin for. was tweaking bugs as players found them, then i was eventually gonna add more features

echo lark
bright fog
#

Since you're going for a hundred items yeah and I wouldn't make a model for every quantity in that case

#

But you can keep it simplier like a row of items is updated everytime

echo lark
#

yeah true

bright fog
#

My idea wasn't to go up to a hundreds tho as you rarely get that many identical cans

echo lark
bright fog
#

Yeah

#

Sounds good

echo lark
#

thats also why the x50/x100 are just gonna be generic models. cuz realisticly you wouldnt be able to fit that many into any box, but hoarders gona hoard and cause lag so

bright fog
#

Yea

#

Which is why I see the way TIS does it currently as a complete miss

half remnant
#

Hey guys, a quick question regarding ProfessionFactory Class.

Is there a way to delete specific occupations with one of the methods of that class?

I saw in the documentation that it has only addProfession & getProfession but no delete method.

half pelican
#

Hi everyone, want to rework the mod a bit. How to get the weight of an item? Is there something like item:getWeight()?

violet shell
#

Hi there 🙂

#

Me again with my questions and issues 😄

#

I'm looking a spot to inject some code when a player equip an item from belt to hand. Anyone would have an idea where I should look at ?

#

I guess it's either this function ISHotbar:activateSlot(slotIndex) or this function ISHotbar:equipItem(item)Dunno which one would be better to override, probably the first one ?

#

Maybe this one :

function ISHotbar:activateSlot(slotIndex)
    local item = self.attachedItems[slotIndex]
    if not item then return end
    if item:getAttachedSlot() ~= slotIndex then
        error "item:getAttachedSlot() ~= slotIndex"
    end
    if item:canBeActivated() then
        item:setActivated(not item:isActivated())
        return
    end
        -- Entering my code that change item attributes here
    self:equipItem(item)
end

#

Also, to change items attributes, does it need to be server side or client side ?

red tiger
#

Holy shit.. I'm accurately generating the same Lua code through the parser data I'm analyzing.

#

There we go.

#

Going hard in the TypeScript rn :D

#
/**
 * Renders a Lua function declaration as a string.
 * 
 * @param func The function to render.
 * @param options Passed options on indenting the code.
 * @returns The function rendered as a string.
 */
function functionDeclarationToString(func: ast.FunctionDeclaration, options: RenderOptions = { indent: 0 }): string {
    const i = ' '.repeat(options.indent * 4);
    const options2 = indent(options);

    /* (If exists, generate the name of the function) */
    let name = '';
    if (func.identifier) {
        switch (func.identifier!.type) {
            case 'Identifier': {
                name = func.identifier.name;
                break;
            }
            case 'MemberExpression': {
                name = memberExpressionToString(func.identifier);
                break;
            }
        }
    }

    /* (Build the function's declaration) */
    let s = `${i}${func.isLocal ? 'local ' : ''}function ${name && name.length ? `${name} ` : ''}(${parametersToString(func.parameters)})\n`;
    s += `${bodyToString(func.body, options2)}\n`;
    s += `${i}end`;

    return s;
}
#

Working with the language itself in code is so much fun.

flat panther
#

And while we're at it, is there a way to change the firing speed? My friend tried to make it faster than the highest vanilla value today and it actually broke the gun completely (it's for a minigun basically)

tranquil kindle
#

So you would need to use real full auto or other similar mods that speed up animations, which firerate is tied to

#

About muzzle flash, is it actually stated in Model script?

tranquil kindle
half pelican
#

How can I rewrite the function
function AcceptItemFunction.Vest(container, item)
return (item:getDisplayCategory() == "Ammo")
so that a check is performed on the weight of the item, which must be less than or equal to 1?
I unfortunately don't know anything yet about these arguments that are or should be accepted here.

flat panther
tranquil kindle
#

Where model is stated

#

If you dont have it, you can add it in txt file or in game while in debug mode with attachment editor

mellow frigate
half pelican
#

oh I get it
it seems to be
function AcceptItemFunction.Vest(container, item)
return (item:getWeight() <= 1.01)

thick karma
#

@drifting ore Anyone know off the top which functions are responsible for adding vanilla traits and occupations? Noname wants to remove some of the vanilla ones. I told her that to my knowledge the only way would be to decorate the functions that add them.

#

I'm not on PC so cannot search yet.

bright fog
#

Removing a trait can actually be done fairly easily, as you just have to a trait with the same name with profession set to true, tho some traits are already added that way as they can be activated by professions so you'd have to remove traits from being used by these professions too

#

In MainCreationMethods.lua @drifting ore

#

So I believe the idea is to just copy this entire line and just replace false to true

#

As you can see, some are already true and that's because they can be used by professions or added hidden and enabled by a profession, I'm not too sure how that works this part ngl

#

You just do that OnGameBoot and should remove the trait

verbal yew
#

TraitFactory.setMutualExclusive("copywhatyouneed3", "copywhatyouneed4");
vestal gyro
#

Also if the functions are called at the same time make sure the lua file comes last in the loading order(for example naming it zRemoveTrait would work)

bright fog
#

But still good practice to require the files I feel like

#

I believe they are always loaded first from what I understood

vestal gyro
bright fog
#

Really you guys should stop using god damn file names to handle your load orders I swear 😂

#

Just require the files you need loaded first

vestal gyro
#

Never

drifting ore
bright fog
# vestal gyro Never

That's terrible practice to use file names because everyone will put their file names with Z + gl having well ordered files with such naming

bright fog
uneven vessel
#

how to change a gun's rate of fire? What stat?

bright fog
#

If you want to remove the trait from being inside the trait list you set it to true

bright fog
drifting ore
vestal gyro
bright fog
#

You don't expect something and it happens

vestal gyro
#

Fair

bright fog
vestal gyro
#

On another note is anyone familiar with the T-shirt UV texture map?

bright fog
vestal gyro
#

Actually nvm I'll ask in #modeling when I get back to my computer and can show an example

bright fog
#

Sadly I think you might have to overwrite this function to remove vanilla occupations

drifting ore
bronze yoke
#

i'd hook ProfessionFactory.addProfession to drop the call if the id matches the vanilla professions

bright fog
#

Not having to overwrite is usually better

bronze yoke
#

it'd throw some errors because they use the profession object after creating it

#

but i'm not sure if they'd be harmful errors

bright fog
#

probably not

#

But who knows lol

bronze yoke
#

otherwise i'd just overwrite the function, people will tell you not to overwrite for compatibility reasons but it's not like removing every profession in the game is going to be very compatible

drifting ore
bronze yoke
#

i meant something like this:

local old_addProfession = ProfessionFactory.addProfession
ProfessionFactory.addProfession = function(name, ...)
    if name == "fireofficer" then return end
    return old_addProfession(name, ...)
end
#

this would make addProfession just ignore calls to create fireofficer

drifting ore
#

Ok

thick karma
bright fog
#

Yeah I did that to remove the Susceptible trait in my overhaul mod

#

Also fun fact, it doesn't actually remove the trait

#

It is still here and can be given via debug/admin menu

thick karma
#

Just flags it as needing a job

#

But you don't assign it to any job

#

Voila

#

Sneaky

bright fog
#

Yeah, issue is with traits that already assign to jobs

bronze yoke
#

i'm curious if you could just do ProfessionFactory.ProfessionMap:remove("fireofficer")

thick karma
#

Old Glytch3r recently solved removing all vanilla professions so I know it can be done. I do not know if it was entirely bug free but I saw screenshots

bronze yoke
#

profession framework has an option to disable all vanilla stuff

#

i think it just overwrites the functions though

thick karma
#

Oh cool didn't know

#

Yeah that's essentially what he did

#

Rebuilt menu with custom jobs

bronze yoke
#

seems overkill, i'd just overwrite the function that creates them 😭

thick karma
#

Haha yeah if that's bug free it's 100% the way to go

#

Even if it throws bugs for missing functions I would probably fake those to remove all bugs

bronze yoke
#

hehe i thought about doing that 😅

mellow frigate
#

Has anyone here advices on how to start the game faster ? I'm currently bored of spending so much time restarting it and it breaks my motivation

thick karma
#

Just make a table of trash functions

#

With the right names

#

Bing bang bong

thick karma
#

Buy 256 gb of RAM

mellow frigate
thick karma
#

😭

thick karma
bronze yoke
#

return a table with a __call that does nothing and a __index that returns itself

thick karma
#

Chat GPT eat your heart out

thick karma
#

Gotta be worth 7 or 8 brains.

mellow frigate
# thick karma Hire albion

/ChatAlbion make Project Zomboid mod in lua with NPCs that works in Multiplayer and corrects desynchronization.

bronze yoke
#

i saw the game has a mechanism for auto-starting a scenario on game launch, but making a debug scenario might not be worth the time and i have no idea if that's actually any faster

frank elbow
#

For some things maybe you can avoid the issue altogether by throwing in some debug code that allows you to test without restarting. I've been doing that for UI stuff, setting it up in a way that reloading the files allows me to test on the fly

#

Of course, that doesn't work for something that applies on start, or something like finding the source of an accidental infinite loop that freezes the game (not that I'm speaking from experience, or anything. definitely didn't spend an hour this weekend tracking down such a bug)

thick karma
bronze yoke
#

there's a good reason my mods are barely tested at all in multiplayer

thick karma
#

Although this might create a loophole society of people who downvote everything with their noses because they have nothing left to lose...

#

I don't know I haven't given this a lot of thought.

bronze yoke
#

i write for multiplayer first but i don't usually even test multiplayer until the mod is done unless there's something i'm really unsure about

echo lark
#

is it possible for a recipe to have a % chance to fail based on a perk lvl somehow? maybe with an oncreate? i was trying a few things with oncreate and cant seem to get it to work.
basically i have a bunch of recipes to craft gun magazines, but have the recipe have a chance to fail and return some of the source items if it fails

thick karma
bronze yoke
#

have the recipe result removed by default (it's a recipe property) and implement it entirely with oncreate

#

roll, if success give them the magazine, if failure give them some items back

echo lark
thick karma
#

Actually this one

#

And use the type of the item you wanna spawn

#

The function should know the result item because you know what recipe calls that function and you know the recipe's result

#

But idk about doing it automatically

steep vortex
#

Hiya, are there any simple examples of adding items to the possible inventory of a zombie?

thick karma
#

AddItem is the thing I just posted before this

bronze yoke
#

it's fine to add items to a zombie's inventory on this event

steep vortex
#

Thanks.

thick karma
#

Oh cool so it'll sync for you?

#

Nice to know

steep vortex
#

Should this be in server, client or shared?

thick karma
#

I would think client or shared should work because it's a player combining their own items into other items and that sounds like clientside stuff to me in this version of PZ, but I have no experience with recipe OnCreate functions.

#

Hopefully if I'm wrong my saying that will provoke albion into correcting me.

#

😏

bronze yoke
#

you're mixing two questions together

#

i think OnZombieDead stuff should be in server

#

the OnCreate stuff is separate and generally has to be in the server folder because that's where the Recipe table is (even though it is only ever called on the client)

thick karma
#

Can't your OnCreate be any global function? Or does it have to be in that table?

bronze yoke
#

it can be any global function

thick karma
#

Do many people add theirs to that table for consistency or something? Or is there some benefit to putting mod recipe functions in the vanilla recipe function table as opposed to your own module?

#

Genuinely curious

bronze yoke
#

consistency

#

probably a lot of people think they have to, a lot of people make up weird magical rules about how lua works

thick karma
#

I see... fair enough. Maybe shared would be a safe bet if it's in your own module so that if server ever needs to see recipe functions in the future you're already in the habit?

#

Or some reason not to do that?

bronze yoke
#

i think future proofing is sort of pointless but there isn't any reason not to do that

thick karma
#

Fair

bronze yoke
#

you only need your function to exist in the client environment and be accessible through _G, there isn't really any other limitations and i can't think of reasons why one way or another would be better/worse practice

thick karma
#

Roger that. Clarification appreciated as always.

bronze yoke
#

it might be seen as overkill to create your own tables if you're only creating a couple functions, but if you're doing a whole crafting mod and would have loads then i'd say to create your own to avoid name clashes in the recipe table

frosty hinge
#

Is there anyone who could make a player model for commission? im trying to get a mod of my fursona.

frosty hinge
#

ty

thick karma
#

You will have better luck there

#

There's a request channel

#

And many who mod on commission

gleaming sorrel
#

I'm attempting to improve my textures to be closer to the actual Left 4 Dead textures. I think I got it fairly close on this one but I'm not completely sure

echo lark
# thick karma Oh apparently it's included in the params https://pzwiki.net/wiki/Scripts_guide/...

yeah i just couldnt figure out how to get it to spawn on a % chance, i think it just kept coming up nill or something, im gonna start from scratch and research a bit on it later. my recipe removes the result item by default, then i was trying to write code so that (for an example) metalwelding lvls 1-2 was a 25% chance of success, and if it succeeds it would add the result item to the inventory. i duno where i was going wrong

thick karma
violet shell
gilded hawk
#

I have some code running on onMouseDownOutside, is there a way to stop the click to go through the elements outside of it? Like, I can run code when onMouseDownOutside is fired, but I haven't found a way to intercept it 😦

red tiger
#

Good evening. My current project is getting whacko-mode.

red tiger
gilded hawk
red tiger
#

So I wrote TypeScript that writes Lua back from luaparse which parses the Lua.

#

I'm doing some rewriting for recursion ATM however I have now a built reference chain global mapping of all Lua code that I can use to discover types strongly and annotate them back as lua classes or my JSON format for PZ-Rosetta.

#

Oh, and I wrote a web app for human documentation too.

#

I'm about to have waaay too much fun messing with the PZ Lua codebase. =D

echo lark
echo lark
#

so the recipes removeresult:true. and the function is supposed to find the result item in the recipe that called the function then spawn it on a % chance based on metalworking lvl

red tiger
#

This is what the result somewhat will look:

#

Figured you'd enjoy that knowing it's in TypeScript. =)

gilded hawk
#

I will give it a proper look tomorrow! I'm curring wrapping up my mod and then bed time

red tiger
#

Yeah I was gonna say it's late for you.

#

Coffee time.

gilded hawk
#

Eh! it works

red tiger
#

I. Like.

#

Imagine making actual UI tho.

#

Hahahahaha

#

<3

gilded hawk
#

Oh yeah, it's awful in PZ 😅

red tiger
#

Wanna work on that HTML renderer with me?

gilded hawk
#

But, I can't help it 🤣

red tiger
#

I have to write out the CSS logic from scratch but worth.

gilded hawk
#

I would love to, but i already work 9-5 on React/Next.js/Tailwind/CSS/HTMX stuff. and i'm trying to at least code something different in my free time 😅

violet shell
#

and if you don't get it, give me your file and numbers, and I'll try to unstuck you

red tiger
#
<radialmenu>
    <option>Fire Weapon</option>
    <!-- etc. -->
</radialmenu>
#

Imagine this for PZ.

#

🤤

#

I was literally working on this when I put the pause on it.

gilded hawk
red tiger
#

Again I have to build the HTML / CSS engine but it's worth it.

gilded hawk
red tiger
#

All we'd need are primitive rules.

red tiger
#

@gilded hawk It's so funny that I happen to have this project sitting around.

#

xD

#

It's very possible to make a solution like this, even without JSX.

#

Just write a simple xml parser.

echo lark
# violet shell <@162657084867870723> Check this

hmm unfortunetly i dont think that helps me much. and ive erased all the code i had to start fresh. i might stop trying for tonight and start fresh another time, or look for mods that do similar things to see what i was doing wrong

#

but i dont realy know any mods that have recipes who have a % chance to fail

#

i think the part im realy struggling on is getting the OnCreate to identify the fulltype of the result item that called the function. cuz i wana use the same oncreate for like 30-40 recipes. so i cant specify which item to spawn, i have to find a way for the code to identify and spawn (or identify and remove i tried both ways) wtv the result item is from the recipe that called the function. i think i just kept getting a null error

harsh hawk
#

y'know what'd be a fun mod? A mod that lets you go to space in pz

#

a bit silly but itd be fun

#

i wanna make a rocket and go live on the moon or smth

red tiger
#

Just make PZ in Factorio.

azure rivet
#

Hi, I want to work with an animation but I require the character to always look behind an object. As an example, if the object is facing north, the player interacts with it, it will self-reposition itself to the south of the object and look at it, and if the object is facing west, the player is looking at it from the east.
Can tell me what can help me understand this?

echo lark
#

is there a specific way to remove a result item from an on craft? like player:getInventory():Remove(result) or something? my recipe has a 25% chance to fail and if it fails i want it to remove the result item, and add random ammounts of the items it took to craft.

#

this is my full code:

function Recipe.OnCreate.vcMagazineSuccessChance(result)
  -- Get the character's metalworking level.
  local metalworkingLevel = player:getPerkLevel(Perks.MetalWelding)

  --- chance to remove the result item based on metalworking level.
  local chanceToRemove = 0
  if metalworkingLevel <= 2 then
    chanceToRemove = 75 -- 25% chance
  elseif metalworkingLevel <= 4 then
    chanceToRemove = 50  -- 50% chance
  elseif metalworkingLevel <= 6 then
    chanceToRemove = 25 -- 75% chance
  end

  -- result removed based on chancetoremove
  if ZombRand(1, 100) < chanceToRemove then
    player:getInventory():Remove(result)
    -- since magazine craft failed give random chance for items
    player:getInventory():AddItems("TW.MetalParts", ZombRand(0, 3))
    player:getInventory():AddItems("SmallSheetMetal", ZombRand(0, 3))
    player:getInventory():AddItems("TW.Spring", ZombRand(0, 3))
    player:getInventory():AddItems("ScrapMetal", ZombRand(5, 20))
    player:getInventory():AddItems("Screws", ZombRand(2, 8))
  end
end
verbal yew
#

RemoveResultItem:true,

#

in function OnCreate - chance

#

where you get another result

#

like if succesful - player:getInventory():AddItems("Module.YourItem", count)
if not: your scrap stuff

echo lark
icy escarp
#

Hi modders, Wiki editor here. I'm looking for the code that handles what weapons spawn stuck in zombies. e.g. katanas not spawning in zombies till after 60 days. There's not much info on this that i can find. Does anybody know which file it would be in?

verbal yew
verbal yew
#

maybe for start you should take getType() from result, idk

verbal yew
verbal yew
echo lark
slow hound
#

oh nevermind it has days until spawn in there also

haughty stream
#

I want more variation in the player models,
I have six models that I want to implement;
Tallskinny, Tallaverage, Tallfat
and
Shortskinny, Shortaverage, Shortfat

Is this possible with the current engine? And is it something that's simple enough that I could do before B42?

I'm new to PZ mod development, and have only done a few simple items

haughty stream
red tiger
#

Am up again coding until I drop.

#

:D

#

2 AM vibes.

bright fog
#

I'm not too sure how that would be done unless you can modify the armature of the character

half remnant
#

Hey guys, a quick question regarding ProfessionFactory Class.

Is there a way to delete specific occupations with one of the methods of that class?

I saw in the documentation that it has only addProfession & getProfession but no delete method.

violet shell
#

Hi there 🙂

#

A quick question : what getInventory() returns ? A table ?

thick karma
#

An ItemContainer iirc.

#

Just search for getInventory

#

Check return type

bright fog
echo lark
#

does anyone know how to remove or add a result without neededing its ID, from an OnCreate. im trying to make it so the recipe has a chance to fail. ive tried various things and got various tips from people but still am getting errors and its not working. this is my code

function Recipe.OnCreate.vcMagazineSuccessChance(items, result, player)
  -- Get the character's metalworking level.
  local metalworkingLevel = player:getPerkLevel(Perks.MetalWelding)

  --- chance to remove the result item based on metalworking level.
  local chanceToRemove = 0
  if metalworkingLevel <= 2 then
    chanceToRemove = 75 -- 25% chance
  elseif metalworkingLevel <= 4 then
    chanceToRemove = 50  -- 50% chance
  elseif metalworkingLevel <= 6 then
    chanceToRemove = 25 -- 75% chance
  end

  -- result removed based on chancetoremove
  if ZombRand(1, 100) > chanceToRemove then
    player:getInventory():AddItem(result, 1);
    -- since magazine craft failed give random chance for items
    player:getInventory():AddItems("TW.MetalParts", ZombRand(0, 3));
    player:getInventory():AddItems("SmallSheetMetal", ZombRand(0, 3));
    player:getInventory():AddItems("TW.Spring", ZombRand(0, 3));
    player:getInventory():AddItems("ScrapMetal", ZombRand(5, 20));
    player:getInventory():AddItems("Screws", ZombRand(2, 8));
  end
end
#

ive also tried player:getInventory():Remove(result, 1);

verbal yew
#

DoRemoveItem

echo lark
# verbal yew DoRemoveItem

ok ill try, honestly if i cant figure this out today im just gonna say fuck it and make an oncreate for each recipe instead XD

echo lark
# verbal yew DoRemoveItem

nope, didnt work. the error always points to the same line, the line that adds or removes the result item.

flat panther
echo lark
# verbal yew True, true

hmm do you think instead of removing the result item if it fails i could set RemoveResultItem to true if it fails? im not sure if you can do that with lua on an OnCreate, kind of new to this stuff

tranquil kindle
#

Rotation is also important (not only what direction it points, but info from blender)

tranquil kindle
# flat panther

First thing first id suggest making a duplicate (for reference), change scale to 0.01 on all axis and then in edit mode make its size back to original (muzzle flash and distance in attachment editor is tied to scale and rotation for some reason. Here im sending an example of model which i made to work with muzzle flash and other attachments (if it were not for 90 rotation on X, attachments will most likely be misplaced when you have gun with attachment and put it on ground, if you skip visible attachments, you can probably skip it, but i highly suggest doing so)

#

In your case i do belive muzzle flash is visible, but its Huge and far away from screen as with 1x1x1 scale your muzzle flash size and distance from origin point to barrel is 100 times higher

boreal oriole
#

Hello people I want to send client command to the server when player disconnects from server. Are there any lua events that handles when player disconnects. Using OnDisconnected event doesn't seem to do it for me when I do it like this ```
local function onPlayerDisconnect()
local player = getPlayer()
sendClientCommand(player,moduleName,command, player:getOnlineID())
end
end

Events.OnDisconnect.Add(onPlayerDisconnect)```

bronze yoke
#

the problem is that when OnDisconnect fires, the player has already disconnected, so they can't send any commands

boreal oriole
#

Ah I see that's the problem

#

Okay thank you I'll try to find a workaround the problem

edgy cosmos
#

Hi hello, I'm trying to set up a clothing mod and I've gotten the clothing.txt made, the xml's, etc, but they don't show up ingame in the assigned slot or at all.

#

idk if there's some file I'm missing somewhere, I've just based it off of the authz structure.

thick karma
edgy cosmos
#

... ah, i forgot the guidtable

edgy cosmos
echo lark
# thick karma What error? The stack trace and the associated chunk of code would help people h...

well at this point ive tried like a douzen diferent ways but usualy its something like
java.lang.RuntimeException: Object tried to call nil in vcMagazineSuccessChance
on line 17 which is the line that im trying to remove or add the source "player:getInventory():GetResult():DoRemoveItem()" (thats just the last one i tried, ive tried various methods, usualy all come back as object tried to call nill)

echo lark
#

im gonna try to see if i can recipe:SetRemoveResultItem(True) and if the chancetoremove fails

#

hmm thats not gonna work, OnCreate happens after the recipes completed i think

thick karma
violet shell
#

@McSlappy, did you try the "OnTest" on your recipe ?

#
    {
    BloodSample,
    OnCreate:onCreateBloodAnalysis,
    OnTest:LabRecipes_IsNearMicroscope,
    Result:BloodAnalysisNotes,
    SkillRequired:Doctor=2,
    RemoveResultItem:true,
    Time:10,
    Category:Health,
    OnGiveXP:Asilar_BloodTest_OnGiveXP3,
    }```
#

With this recipe, I call for OnTest before, to check if the recipe is ok or not. It asks for a boolean.

#

So you could do : OnTest:chancesOfSuccess

#

and then have function chancesOfSuccess () -- your test method return true or false end

#

the big advantage is that you pass at least players and items to your functions (OnCreate/OnTest)

echo lark
bronze yoke
#

ontest is called for every single potential ingredient available to the player when the recipe is considered (either they opened the crafting menu, or they right clicked on an item that can be used in the recipe)

#

it's not suitable for recipe logic, it's not part of crafting the recipe, it's only useful for discerning what items can or can't be used in that recipe

echo lark
#

yeah thats what i thought it did

violet shell
#

@thick karma Available for some code review 😄 Just syntax and so. Not sure I used some functions properly in my last lua file.

echo lark
#

im just gonna have to write an OnCreate for each recipe, and RemoveResultItem=True the recipes, then do the zomband and spawn the item. just wanted to avoid having to write 55 OnCreates (thought it was 30ish, but nope its 55) if i could just use one for all of them

violet shell
#

why you don't have 1 function with tests in this function

#

can you give me a sample of 3 or 4 of your recipes so I can get it ?

echo lark
#

but i cant get the OnCreate to identify the result item from the recipe that calls the function, everythign just returns nill object

#

so i have to specify AddItem:("gunmagazineid") instad of something like GetSource and removing it

violet shell
echo lark
#

this is 3 of the recipes (right now im only tseting the code ont he first one so its the only one that has a RemoveResultItem)

    recipe Craft HK91 Magazine
    {
        keep [Recipe.GetItemTypes.Hammer],
        keep [Recipe.GetItemTypes.Screwdriver],
        keep [Recipe.GetItemTypes.WeldingMask],
        BlowTorch=2,
        ScrapMetal=20,
        SmallSheetMetal=4,
        TW.Spring=2,
        TW.MetalParts=4,
        Screws=8,

        Result:Base.HK91Mag,
        RemoveResultItem: False,
        SkillRequired:Reloading=1,
        Category:Firearm,
        OnCreate: Recipe.OnCreate.vcMagazineSuccessChance,
        OnGiveXP:Recipe.OnGiveXP.MetalWelding10,
        NeedToBeLearn:false,
        Sound:Hammering,
        Time:300.0,
    }

    recipe Craft FN FAL Magazine
    {
        keep [Recipe.GetItemTypes.Hammer],
        keep [Recipe.GetItemTypes.Screwdriver],
        keep [Recipe.GetItemTypes.WeldingMask],
        BlowTorch=2,
        ScrapMetal=20,
        SmallSheetMetal=4,
        TW.Spring=2,
        TW.MetalParts=4,
        Screws=8,

        Result:FALMag,
        SkillRequired:MetalWelding=2;Reloading=1,
        Category:Firearm,
        OnGiveXP:Recipe.OnGiveXP.MetalWelding10,
        NeedToBeLearn:true,
        Sound:Hammering,
        Time:300.0,
    }

    recipe Craft Browning BAR .308 Magazine
    {
        keep [Recipe.GetItemTypes.Hammer],
        keep [Recipe.GetItemTypes.Screwdriver],
        keep [Recipe.GetItemTypes.WeldingMask],
        BlowTorch=2,
        ScrapMetal=10,
        SmallSheetMetal=2,
        TW.Spring=2,
        TW.MetalParts=2,
        Screws=4,

        Result:308BARMag,
        SkillRequired:MetalWelding=2;Reloading=1,
        Category:Firearm,
        OnGiveXP:Recipe.OnGiveXP.MetalWelding10,
        NeedToBeLearn:true,
        Sound:Hammering,
        Time:300.0,
    }
#

and this is the oncreate (recipe:SetRemoveResultItem(True) is just the latest method ive tried, but ive tried many other methods, all return nill object)

function Recipe.OnCreate.vcMagazineSuccessChance(items, result, player)
    -- Get the character's metalworking level.
    local metalworkingLevel = player:getPerkLevel(Perks.MetalWelding)
  
    --- chance to remove the result item based on metalworking level.
    local chanceToRemove = 0
    if metalworkingLevel <= 2 then
      chanceToRemove = 75 -- 25% chance
    elseif metalworkingLevel <= 4 then
      chanceToRemove = 50  -- 50% chance
    elseif metalworkingLevel <= 6 then
      chanceToRemove = 25 -- 75% chance
    end
  
    print("checking for result item")
    if result then
      local resultType = result.type  -- Get the item type from the result object
      local resultCount = result.count  -- Get the item count from the result object
      print("Result item:", resultType, resultCount)
    else
      print("Result item is nil")
    end
  
    -- ... rest of your code ...
  
    -- result removed based on chancetoremove
    if ZombRand(1, 100) < chanceToRemove then
      recipe:SetRemoveResultItem(True)
      -- since magazine craft failed give random chance for items
      player:getInventory():AddItems("TW.MetalParts", ZombRand(0, 3));
      player:getInventory():AddItems("SmallSheetMetal", ZombRand(0, 3));
      player:getInventory():AddItems("TW.Spring", ZombRand(0, 3));
      player:getInventory():AddItems("ScrapMetal", ZombRand(5, 20));
      player:getInventory():AddItems("Screws", ZombRand(2, 8));
    end
  end
#

i couldnt even get those prints to print anything, was just the last thing i tried with the removeresultitem

#

but since that method doesnt work, i would have to write an OnCreate for each recipe, to add the specific gun magazine from the craft and use RemoveResultItem:True, but i didnt want to have to write 55 of them so i was trying to write one that just grabed the result item when the oncreate was called

violet shell
#

I may have a workaround

#

but I don't know if it is worth

#

you could have the unique chancesOfSuccess function to check every item needed for the recipe, and to select the result accordingly, assuming every recipe have a slithly different cost

violet shell
#

@thick karma @bronze yoke [sorry I made a mistake and erased the original message & file] If you have some spare time, would you mind to check if this code is correctly written/syntaxed ?

vestal gyro
#

Just test it in game, it will tell you on which line it breaks

#

Atleast in debug mode

echo lark
violet shell
#

Anyone have an idea how is stored Wolrdmap data ? I would like to check if I can store the map data in player's modData.

polar gyro
#

anyone know how to inject in this one correctly?

    type = "Bag",
    name = "Back",
    animset = "back",
    replacement = {
        BigWeapon = "Big Weapon On Back with Bag",
        BigBlade = "Big Blade On Back with Bag",
        Racket = "Racket Back with Bag",
        Shovel = "Shovel Back with Bag",
        Guitar = "null",
        GuitarAcoustic = "null",
        Pan = "Pan On Back with Bag";
        Rifle = "Rifle On Back with Bag",
        Saucepan = "Saucepan Back with Bag",
    }
}
table.insert(ISHotbarAttachDefinition.replacements, BackReplacement);```
#

Well, chatgpt give this advice and that's working:

local index = #ISHotbarAttachDefinition.replacements
ISHotbarAttachDefinition.replacements[index].replacement.LongBlade = "LongBlade On Back with Bag"```
steep vortex
#

Hi. Bit of an odd one. So I've got this code (it continues to add a whole bunch of extra items).

require "Items/ItemPicker"
require "Items/ProceduralDistributions"

table.insert(SuburbsDistributions["all"]["inventoryfemale"].items, "BusinessCards.AfterLife");
table.insert(SuburbsDistributions["all"]["inventoryfemale"].items, 0.5);
table.insert(SuburbsDistributions["all"]["inventorymale"].items, "BusinessCards.AfterLife");
table.insert(SuburbsDistributions["all"]["inventorymale"].items, 0.5);
...```

It seems to work just fine; the loot can be found on zombies, but I'm getting this error
```STACK TRACE
-----------------------------------------
function: BusinessCardsDistributionZombies.lua -- file: BusinessCardsDistributionZombies.lua line # 5 | MOD: Business Cards.
[30-04-24 18:18:34.705] ERROR: General     , 1714497514705> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: attempted index: list of non-table: null at KahluaThread.tableget line:1689..
[30-04-24 18:18:34.705] ERROR: General     , 1714497514705> DebugLogStream.printException> Stack trace:.
[30-04-24 18:18:34.707] LOG  : General     , 1714497514707> -----------------------------------------
STACK TRACE```

Any idea what the error is and if it's an issue?
bronze yoke
#

are you sure this is the right file? the error doesn't line up with anything in your code

steep vortex
#

🤦‍♀️

#

Thank you.
So I tried doing this wrongly using a file that added the items to the inventory in server/NPCs and had forgotten to delete that after

echo lark
#

well shit, i got it to work

#
function Recipe.OnCreate.vcMagazineSuccessChance(items, result, player)

    local metalworkingLevel = player:getPerkLevel(Perks.MetalWelding)
  
    --- chance to remove the result item based on metalworking level.
    local chanceToRemove = 0
    if metalworkingLevel <= 2 then
      chanceToRemove = 75 -- 25% chance
    elseif metalworkingLevel <= 4 then
      chanceToRemove = 50 -- 50% chance
    elseif metalworkingLevel <= 6 then
      chanceToRemove = 25 -- 75% chance
    end
  
    -- Check chance to remove and handle successful crafting
    if ZombRand(0, 101) >= chanceToRemove then
      if result then
        local resultType = result:getFullType()
        player:getInventory():AddItem(resultType, 1)
        return -- Exit the function after successful crafting
      end -- Close the 'if result' block here
    else
      player:getInventory():AddItems("TW.MetalParts", ZombRand(0, 3));
      player:getInventory():AddItems("SmallSheetMetal", ZombRand(0, 3));
      player:getInventory():AddItems("TW.Spring", ZombRand(0, 3));
      player:getInventory():AddItems("ScrapMetal", ZombRand(5, 20));
      player:getInventory():AddItems("Screws", ZombRand(2, 8));
    end
  
  end
#

using a chart, checking the type with getFullType, then comparing that to the chart, and spawning the item i got it to work without the chart.

#

so ill just need a chart with all my gun mags

thick karma
#

I think what you're saying is getting a little lost in translation here.

Syntax is mandatory punctuation and formatting of the relationship between the fundamental data managed by a program. If you have syntax errors, your debug mode errors will tell you about them, and your file won't load at all.

If you're unsure whether a file loaded, you can also add a global variable to the end of it, something like ThisIsJustForTesting = 1, and then print that variable using print(ThisIsJustForTesting) in the debug console to see whether it's 1 or nil.

#

@violet shell

thick karma
#

Have you tested the code? That is generally the determining factor in whether something is written or "syntaxed" correctly.

echo lark
#

if i want a 1-100 do i do ZombRand(0, 101) or do i do ZombRand(1, 100)