#mod_development

1 messages ยท Page 37 of 1

thick karma
#

I finally got the command right for closing my gd inventory when I move my thumbstick

#

New mod incoming!

#

Omfg

#

I can't believe it finally worked

#

COmmand seems so obvious but I tried so many variations that failed me

bronze yoke
#

hell yeah

thick karma
#

Ahhhh so excited for this one

marble lynx
#

count me in

thick karma
#

So something that annoyed t.f. out of me immediately as a controller player

#

(1) there are 2-3 windows that open automatically on joining server that tmk cannot be accessed or closed via controller, and take up screen space. They are Server Info, Chat, and Debug (if you're in Debug mode)

#

(2) When you want to close things quickly, spamming Circle (standard Back) won't save you, because Inventory closes on Y, not Circle.

#

I have now fixed both of these problems.

#

When player aims, those windows you do not need during a fight will all instantly close. Chat, Server Info, Debug, AND Inventory.

#

Omg what should I call it? (People hate my names. ๐Ÿ˜ญ) I was gonna call it Catlike Reflexes. Also should I tie it to a trait so it's optional like I did for Trash Talker?

marble lynx
#

Maybe something simple and direct like No More Annoying Popups (Controller)

#

Btw there's no toggle UI keybind for controller?

bronze yoke
#

yeah i prefer to keep them direct, for easy understanding but also because it means i don't actually have to come up with a name

thick karma
thick karma
# marble lynx Btw there's no toggle UI keybind for controller?

When I use it through Steam, it only hides the controller UI (buttons that overlay the rest of the UI), nothing else, and it's not a toggle, it's a hold press. Also, pressing V on the keyboard does the same thing while a gamepad is connected (hides gamepad UI), but toggles instead of only activating on hold. So having a gamepad connected fundamentally takes over and ruins the HUD-hiding mechanism. Cinema mode does not exist for at least some gamepad players (e.g., me) without my mod.

#

Controller support in this game is honestly very mediocre and I am trying to take little steps to remedy that.

viral vale
#

I'll create a little server to make it easier to collaborate with whoever is interested, i'll DM a link ๐Ÿ™‚

marble lynx
marble lynx
thick karma
#

It has a somewhat unique effect that defies concise description. Hide Chat, Server Info, Debug, and Inventory on Aim is a stupid sounding name to me.

#

I would prefer to simply sum that up with colorful jargon but IDK, I don't want misleading jargon.

marble lynx
thick karma
#

Getting warmer for me, was considering something similar

#

I am considering something that could double as a trait name

#

I feel some people on the server will be used to not closing inventory on aim and perhaps for one reason or another hate that

#

So I would like the trait name to be concise and also descriptive and in the same adjectival tone as other traits

marble lynx
#

Could use mod options for that and leave it disabled by default

thick karma
#

Mmm that is a possibility

#

I gotta learn Mod Options crap I'm lookin it up

fast galleon
#

Some mods adds their keys to default key meny

marble lynx
#

Or make it an option in the context menu/right click like how Tidy Up Meister does it

thick karma
#

Mod Options tutorial for devs says this: "NB: This is for the client side only! It's ok for single player, but in multiplayer every player can change it. Be careful, if your options affect gameplay."

#

So I actually don't think I can use this for custom player options...

#

They will need to just live with the shortcuts.

#

Hopefully they can. I picked buttons that are unused intentionally

#

C'est la vie.

thick karma
#

yeah no worries, I don't need custom button configs in my mod

marble lynx
#

Which is a good thing because every player can enable it or disable it if they want

thick karma
#

Just more work xD

thick karma
marble lynx
#

Not for everyone, it's local

#

Iirc

thick karma
#

Ohhhhhhhh

#

I misunderstood his warning

#

So he's saying if your options actually change fundamentally important things for the server

#

You should watch out because anyone can toggle stuff

marble lynx
#

His warning is more for stuff like tweaking the percentages/frequencies of something occuring or spawning i think, yeah

thick karma
#

I get it now.

marble lynx
#

eg

thick karma
#

Maybe, though I fear people would be as mad at that as they will Catlike Reflexes

#

Sigh how to balance ambiguity vs being succinct and not having an awkward name for a trait

hearty dew
thick karma
#

Oh I figured it out thanks @hearty dew

#

That statement was actually me expressing how long it took to find the correct command which in retrospect feels obvious

hearty dew
#

Ah, okay ๐Ÿ™‚

thick karma
#

Yeaaaaah got Mod Options working on my new mod, juicy.

#

So just to be clear, if I use Mod Options to let people enable or disable a mod, that's a local disabling and enabling, right? Won't affect other players at all?

#

(assuming the thing being enabled is a local player thing)

#

(such as what happens when local player presses a key)

hearty dew
#

Yea, each player has their own mod options (just like they have standard pz options), so you could write the mod to handle those mod options specific to the client

thick karma
#

Yyyyeeaaaaas

#

victory

#

So excite

#

Now to finalize a name for this...

marble lynx
#

Grats ๐Ÿ™‚

thick karma
#

Hmmmm how about Clear for Combat? Anyone hate it? Like it?

marble lynx
#

It's not very descriptive

thick karma
#

yeah I dunno haha

#

How to be descriptive in <= 3 words

#

I do not want a 7 word title for the sake of description... that's what descriptions are for...

marble lynx
#

Could be 4 words ๐Ÿคฃ

thick karma
#

But I would love a more accurate title <= 3 words if possible

#

What 4 words?

#

It closes many things when I aim

marble lynx
#

Something like the one I suggested earlier

thick karma
#

What 4 words would accurately describe what closes

#

And when it happens?

#

I responded to that

thick karma
marble lynx
#

Cause when I read "Clear for Combat" i would not know what the mod does

#

yup

thick karma
#

For sure, but this begs the questions, "Which windows?"

marble lynx
#

Combat Closes Windows? If you wanna leave out the stances part

thick karma
#

Does not currently close all your windows

#

Title would suggest it does

#

Problems with everything ๐Ÿ˜ฆ

marble lynx
#

Well it doesn't need to be that specific, they can check the mod page for that

thick karma
#

Haha exactly why I generally don't bother with trying to be that specifically descriptive in the title

#

But reaction to last creative title was pretty negative, so I don't want to make people stretch too much to "get it" either.

marble lynx
#

Yes but Clear for Combat tells a person nothing haha

thick karma
#

True enough. But the fact that it's tagged as a UI mod might give context that gives a good hint.

marble lynx
#

People rarely look at tags tho

thick karma
#

"Clear how? Oh, UI mod. Clear something about UI?" click

#

I know I am expecting too much

#

Ugh I need a concise, descriptive name I don't hate

thick karma
#

I feel like I just want to call it Aiming Closes Everything and actually do that @marble lynx. Think I need to add a range of other UI elements to the stuff I close.

marble lynx
#

Sounds good to me

#

Altho I have no idea how much work it would be to reopen the relevant windows on a controller after the fighting

thick karma
#

Generally they'd be reopened one at a time, except for the ones that don't have controller shortcuts at all, which can be collectively reopened using a keyboard shortcut

#

Bettee than dying because they're blocking your view if you ask me

#

I will feel lucky to reopen my windows when I escape death due to rapid closing of them, personally

marble lynx
#

Yeah yeah, go for it then ๐Ÿ™‚ ๐Ÿ‘

summer rune
#

we are hosting a server with gportal. and we have scheduled automatic restarts activated. but i guess this just kills the PZ dedicated server process and restarts it.

because we have the problem, that after each restart the player state and the world state is set back for about 5- 10 minutes.

what can we do to save the world before the restart?
is there a mod for that? can i write a mod to save the world? is there even a lua function provided for that use case?

hearty dew
#

You could send the quit command to the stdin of the server process to make it shutdown normally

pine fiber
summer rune
marble lynx
#

quit saves the world prior to shutting down

hearty dew
#

I'm not sure. I would hope so, but I've not tested nor looked at that code. That's not what I was referring to, however

summer rune
hearty dew
#

If you run the server in the terminal, you can type quit to shutdown the server normally. I was suggesting sending that input to the server process in your automated reboot script prior to killing it and restarting the server

summer rune
hearty dew
#

On linux, you could start the server with a fifo file as the stdin, then you should be able to write quit to the fifo for the server process to get that input

#

idk how you'd do that on windows

marble lynx
#

Maybe try contacting gportal's cust support about the issue?

ancient grail
#

anyone has an idea which lua file controls players shadow? and if is possible to remove the shodow of just the character u are using ...

summer rune
hearty dew
summer rune
#

okay thanks all. I will try those things. i will keep u posted.

ancient grail
pine fiber
#

If it's not working, u could try to set restarts just after a SaveWorldEveryMinutes. And maybe modify this :

BackupsPeriod=0

ancient grail
#

i could provide you the details on how i was able to do this if u want.
and it involves moving the rcon files to the system32 folder

pine fiber
#

but with gportal, could we use a rcon connection ?

summer rune
hearty dew
#

That's the server console output from Core.quit()

#

This is from the quit command

ancient grail
#

yes we can we also use gportal the limit here is that your pc needs to be on every restart

i wanted to make a mod but would require alot of research so i ended up doing this as a quick patch but never had the impulse to do the mod

summer rune
hearty dew
#

maybe there's a save method on Core. Let me check that

ancient grail
#

just use sendcommandtoserver

#

/save

summer rune
#

ohhhh

#

yeah that might work. right?

ancient grail
#

not sure if it requires client admin tho

hearty dew
#

You'd need an admin client to issue those, perhaps

ancient grail
#

servermsg doesnt work. but you can try

summer rune
#

cant the server send a sendcommandtoserver

ancient grail
#

ah then your screwed

summer rune
#

hm

ancient grail
hearty dew
#

Don't see anything on Core

hearty dew
#

I'll try sending save and quit from the server itself

hearty dew
ancient grail
#

you might want to look at the script where it does the /save

ancient grail
hearty dew
#

If my assumption is correct, that probably be difficult to mod

ancient grail
#

is there a shadow texture file? i dont think there is ... hmmmmm

hearty dew
#

SendCommandToServer() when called on the server-side causes and exception bc it expects to be called from the client-side

summer rune
hearty dew
#

GameClient.connection is null

#

@summer rune On GlobalObject, there is save(boolean) and saveGame()

#

At least it saves the GlobalModData heh

summer rune
#

i have access to these files by FTP. maybe some ideas here?

hearty dew
#

@summer rune ```java
if ((n3 = ServerOptions.instance.SaveWorldEveryMinutes.getValue()) > 0 && (l = System.currentTimeMillis()) > this.LastSaved + (long)(n3 * 60 * 1000)) {
this.bQueuedSaveAll = true;
this.LastSaved = l;
}
if (this.bQueuedSaveAll) {

`ServerOptions` is exposed to lua. You might be able to set that to 1 to trigger a save to occur. Downside of this approach is if the game saved within the last minute, it won't work
summer rune
hearty dew
#

It's called in the server's main loop

summer rune
#

oh that is fantastic. okay. thanks. i will go this way then.

#

i will set the option to 15min every minute. however if it is 5 minutes before restart i will set the option to 1min

#

i already have a loop where i check restarts to warn players in the global chat of an incoming restarting

#

that is awesome. thank you so much

hearty dew
#

This works. It saved immediately when I set it to 1

#
ServerOptions.instance:getOptionByName("SaveWorldEveryMinutes"):setValue(1))
summer rune
#

very much appreciated!

wanton dirge
#

Thanks for trying to help me with this one last night guys (fell asleep right after posting this, was after an hour or so of trying to debug it that I realized the game was telling me exactly what I needed to know...)

It's Events.OnKeyPressed danny

#

Morning brain fixes what tired brain couldn't.

visual abyss
#

Is it possible to wrap descriptions for items in tooltip? I have few fairly long descriptions and they would make the tooltip ridiculously wide. I like adding descriptions.

ancient grail
#

u just have to find it. as i forgot what its called but ill help u search now

visual abyss
#

Okay, I'll look as well. Appreciate it.

pine fiber
#

Is there a way to restart the items distribution on the map directly in-game without restarting a new game?

thick karma
#

Ugh I have been trying to find a way for an hour... can someone help me out with changing the focus of your keyboard input back to completely unfocused?

#

But preferably irrespective of what it's currently focused on?

fast galleon
#

Update something about ItempickerJava.Parse() from that post

warm pawn
#

Great!

blissful salmon
#

I'm looking for a "clean" way to disable my custom recipes if a sandbox option is set. What I do at the moment is to "use" getProp1() as string for my category which I want do disable. Is there a way to create a customfield?

viral vale
#

Haha, thank you very much ๐Ÿ˜›

thick karma
#

Or maybe turn off cursor in Debug Console anybody? I have found a way to escape focus...

pine fiber
#

Is there a way to modify the weightChance=40 parameter of a Distributions list ?

sour island
#

If it's a part of the list you can just redefine it.

blissful salmon
#

As far as I know, the category is already used for specify a tab. But I don't want them to appear in in a separated tab if possible.

sour island
#

Idk if this would be helpful but I have a sort of similar mod to give players speech. "Conditional Speech". It uses text filters to change phrases on the fly. If you wanted the zombies to say randomized keywords or something.

sour island
#

I recall there being a tag like that- but you could also set a new isValid function on the recipe object to always return false

#

This would make it never appear in context but may still appear in the crafting menu

jaunty marten
#

not by sandbox options but u can create sub-mod in ur mod exactly to disable/enable certain recipes

#

but anyway u can try to check source of crafting menu ui and mb there will some key that can "disable" (hide) any recipe

blissful salmon
visual abyss
#

Looks like trying to make completely new weapon part types (i.e. barrel) isn't possible? I've been trying to figure out a workaround but it appears that the weapon part types are hardcoded.

blissful salmon
jaunty marten
#

I'm not at pc rn but as I remember mod hierarchy
Mod/
..Content/
....Mod1/media..
....Mod2/media..

sour island
#

Oh you're trying to make a specific tab for recipes? Hmmm

jaunty marten
#

it will single mod but in mods list will a few mods

#

so u can disable any that u want separately

blissful salmon
# sour island Oh you're trying to make a specific tab for recipes? Hmmm

No, sorry if my text was confusing. My recipes appear on the normal tabs which already existing. If I set a Sandbox option I want for to disable some of my recipes with a specific "flag/group" or whater i set on the recipes. the primary goal is to make my mod in a way that i can later ad new recipes without having to change the lua code.

sour island
#

You don't need a sub-mod -- you can't just check for active mod IDs or in this case sandbox options and do what you need.

steep copper
#

Hi, do you know how to get username from an isoPlayer Object ?
local playerObj = getPlayer(); print(playerObj.getUsername());
It throw error

sour island
#

Use : not .

sour island
jaunty marten
sour island
#

I don't think recipes have their own tag system like items do - so you may need to adjust a list of recipe names

#

If the module encompasses too much

blissful salmon
#

for my items I used for example:
Tags = SoulMod_UnfinishedWoodItem,
TotalWorkUnits = 10,
and later I can call it with
local itemModData = item:getModData()
o.TotalWorkUnits = itemModData.TotalWorkUnits or 200

thick karma
#

Anyone know how to send a mouse click signal to an arbitrary X, Y? Is that possible from the Lua?

blissful salmon
ancient grail
#

let me know if it works pls ty

blissful salmon
#

Thank you guys for the ideas. I thinks Chuck's idea is the one that fits best for my needs. If someone still have an idea for a customfield just let me know ๐Ÿ™‚

sour island
#

You can add an ontest on the fly, just a fyi

sour island
ancient grail
sour island
#

It is, calling function/method that is exposed is always:afaik. Variables are ..

thick karma
thorn bane
#

Is it possible to get what gets said in a certain radio channel?

sour island
#

Try calling debug windows' close buttons' click then

thick karma
#

Now, I have a working "solution" for breaking said focus, but my janky solution leaves the cursor flashing animation active, and I don't like that.

sour island
#

Should handle what you need

blissful salmon
#

I'm not familiar with the ontest/oncreatefunction function etc. so far. for my items I just added it to the contextmenu if some tests were true... do you have a link to a sample or provide one if possible. Or I can check if I find one in the base lua code...

thick karma
#

I am having trouble finding where that close button click gets handled unfortunately

visual abyss
sour island
#

It would be inherited from general UI

novel quartz
#

I have a mod question; If i have a mod like bushcraft, do my friends need it to play in my world?

#

okay

#

ty

blissful salmon
sour island
visual abyss
#

so it would return a bool

#

oncreate just does stuff that you'd want if the craft was successful

blissful salmon
sour island
visual abyss
#

for example, i'm adding a craft called Dissect Corpse

#

I wanted to make parts random

#
    recipe Dissect Corpse
    {
        CorpseMale/CorpseFemale,

        Time:               100.0,
        Category:           Salvage,
        CanBeDoneFromFloor: true,
        OnCreate:           ZomboidExtract.Recipes.OnCreate.DissectCorpse,
        Result:             ZEZombieParts,
        RemoveResultItem:   true,
    }

It would call OnCreate.DissectCorpse which is:

function ZomboidExtract.Recipes.OnCreate.DissectCorpse(items, result, player)
     local lootTable = {}
     lootTable["none"] = 70
     lootTable["ZomboidExtract.ZEZombieBrain"] = 10
     lootTable["ZomboidExtract.ZEZombieHeart"] = 10
     lootTable["ZomboidExtract.ZEZombieLung"] = 10
     lootTable["ZomboidExtract.ZEZombieKidney"] = 10
     lootTable["ZomboidExtract.ZEZombieLiver"] = 10
     lootTable["ZomboidExtract.ZEZombieBone"] = 10
     lootTable["ZomboidExtract.ZEZombieFlesh"] = 10

    local item = RollWeightTable(lootTable)
    if item ~= "none" then
        player:getInventory():AddItem(item)
    end
end

You might notice that the result would be ZEZombieParts but it's immediately removed as it is just a fodder to show in the crafting ui. where the OnCreate would actually add random parts.

sour island
#

Option 1: you include an unique OnTest for all your recipes to check for sandbox options as you see fit.

Option 2: you parse through recipes onGameBoot and add an always false OnTest to recipes you choose.

#

I think option 1 might be easier to implement but it would mean if you needed different things to occur in onTest you'd need to make another function for those cases.

#

Which if you want to avoid maintenance overhead is not ideal

blissful salmon
thick karma
sour island
#

Afaik it's one function per Lua parameter

thick karma
#

UIManager:getDebugConsole() <- this is the debug console

blissful salmon
#

but I think this is also a good solution.

thick karma
#

UIManager:getDebugConsole().close:click() <- nada

#

UIManager:getDebugConsole().close() <- nada

#

UIManager:getDebugConsole():close() <- nada

sour island
thick karma
#

UIManager:getDebugConsole():close():click() <- nada

sour island
#

Find the Lua pseudo-objects

thick karma
#

UIManager:getDebugConsole() is the pseudo-object

#

This is accessible in Lua

#

but I don't have access to a close function through that object

#

I can make it invisible

#

I can set capture and such

sour island
#

It's pulling on the Lua object

#

If you check ISPanel.lua you should be able to find how to grab the close button or related functions

thick karma
sour island
#

But that is it the debug console is an ISPanel

thick karma
#

How would I get the ISPanel version of the debug object that has access to close?

sour island
#

Most UI has an instance set for clients

thick karma
#

I only have a UIDebugConsole object

#

I can get an instance of debug console, it just doesn't come back as an ISPanel

sour island
#

What is it's type then?

thick karma
#

Afaik, it's coming back as a UIDebugConsole because those functions appear to be visible

#

But UIDebugConsole doesn't have unfocus() or close() or anything

sour island
#

That sounds like the java half of stuff

thick karma
#

I hear what you're saying, but I am searching all the text of all the Lua files in media/lua and I'm seeing no other way to pull the debug console

#

Aside from using getDebugConsole

#

I have it all indexed

#

So I can literally search every line of every file

sour island
#

If you can find the debug console Lua file it is probably a subtype of ISPanel

#

You would have to do something like ISDebugPanel.instance

#

I'm not sure what the type is though

thick karma
#

There really isn't a "Debug Console" Lua file...

#

Those are all the files containing "DebugConsole"

#

This "getDebugConsole" function does not come from a DebugConsole Lua

#

In fact it doesn't even show up in Lua at all

#

It just appears to be exposed

#

Via UIManager

ancient grail
novel quartz
#

Okay so I dont have the game yet so i dont know how joining worlds works

sour island
#

Where is ISDebugSubPanelBase housed?

novel quartz
#

is it simular to minecraft in the way that someone makes their wolrd multiplayer and they join that way?

thick karma
thick karma
novel quartz
sour island
#

DebugUIs/DebugMenu/Base/ should have the UI files needed

#

SubPanel is one tier too deep

#

You want whatever is the parent of it - but I am looking through one of my projects for the correct names

#

So I can't find what it is called

thick karma
sour island
#

ISGeneralDebug ?

thick karma
sour island
#

I think generalDebug is still one of the subtabs

#

Wish the Lua was online, but can't help much more

fast galleon
thick karma
#

Yes thank you @fast galleon

#

Not adequate

#

Trying to lose the focus

#

Not just hide it

jade chasm
#

does anyone have a quick lua script for making a weapon two handed? i'm not sure what needs to be done other than changing the folder names. new to modding and just trying to make my sword two handed

#

^any resources on modding melee weapons appreciated. most guides focus on firearms

shadow geyser
#

RequiresEquippedBothHands = TRUE, if it needs to be held in 2 hands

fast galleon
#

UIDebugConsole is in java

jade chasm
#

lmao thank you

fast galleon
sour island
#

He's on controller

thick karma
#

My joypad focus is coming free just fine

sour island
#

Have you tried removing it from UI manager?

ancient grail
thick karma
#

I mean then I would have to reinitialize it entirely because removing it is not its natural behavior

#

Also could cause other issues

sour island
#

Most UI gets removed on closure - from what I've seen

thick karma
#

If it expects that debugger to exist

sour island
#

If you don't figure it out, ping me in like 7 hours

thick karma
ancient grail
#

what is the lua file that limits a players view . like behind him? is there a way to be able to see everything 360ยฐ
i saw a mod that dors this but says obsolete

sour island
#

I should upload the Lua as a hidden repo

thick karma
#

Oof I give up for now @sour island lol been trying so long.

#

Ttyl

sour island
#

No worries, wish I could be more help. I'll give it a shot once I'm home.

visual abyss
#

is there a way to override a recipe that has more than 1 recipes (i.e. disinfect bandage, it has like 4 different recipes)

#

I can only seem to override the first available recipe instead of all (trying to make them all required to be learned)

sour island
#

Using the scripts format probably not I would guess

#

You could parse through all recipes in Lua though

visual abyss
#

would you happen to know how?

#

I've been wanting to do that but couldn't really find any snippets to help do that

sour island
#

getScriptManager() returns the object that controls alot of that stuff

visual abyss
#

it'd be nice instead of having to manually fix all of the recipes haha (i'm basically doing a total reconversion of the game)

sour island
#

Recipes being able to share exact names actually always bothered me

visual abyss
#

I'm not sure if I understand but are you actually able to modify the script manager (i.e. remove or adjust recipe)?

#

always felt like the base code isnt mutable

noble shale
#

I'm making a mod that adds a recipe and modifies a right-click menu for an item. When I make the mod, am I saving a new recipes.txt (and others), or am I making a modified recipes.txt and publishing that?

calm acorn
#

typically add your mod id to the front of the file name so mymodid_recipes.txt

noble shale
#

Awesome, I was hoping I could make a new file lol. Not new to design but I'm new to actually implementing it myself, ty!

#

Sorry, one more question, is XP gain handled in XpUpdate.txt?

sour island
#

You can do this with any script: vehicles, items, 3D models, just depends on how much of it is exposed.

visual abyss
#

i'm able to retrieve all recipes

#

but i'm trying to figure how to write/apply actual changes

#

I'm only 3 days old learning to mod PZ

sour island
#

The get all recipes method/function returns an array (Java)

visual abyss
#

right

noble shale
sour island
#

You cant parse through using normal Lua as it's not a Lua table -- the devs have exposed the methods for an array though

#

I have something like this in a few projects hold on

#

I don't have an example using getAllRecipes but this one is for item scripts

#
EHE_Recipe.addCanOpenBoxesTagToTypesThatCan()
    if ran then return else ran = true end
    ---Adds "CanOpenBoxes" tag to scripts for type
    local allItems = ScriptManager.instance:getAllItems()
    local debugText = "EHE: Added Tag 'CanOpenBoxes' to: "

    for i=0, allItems:size()-1 do
        ---@type Item
        local itemScript = allItems:get(i)
        local itemFullName = itemScript:getFullName()
        local tags = itemScript:getTags()
        local addCanOpenBoxesTag = EHE_Recipe.typesThatCanOpenBoxes[itemFullName]
        local tagString = ""

        if tags:contains("EHESignalFlare") then
            eheFlares.addFlareType(itemFullName, "EHESignalFlare")
        elseif tags:contains("EHEFlare") then
            eheFlares.addFlareType(itemFullName, "EHEFlare")
        end

        for ii=0, tags:size()-1 do
            ---@type string
            local tag = tags:get(ii)

            if EHE_Recipe.additionalTagChecks[tag] then
                addCanOpenBoxesTag = true
            end
            tagString = tagString..tag..";"
        end

        if addCanOpenBoxesTag then
            debugText = debugText..itemFullName..", "
            itemScript:DoParam("Tags = "..tagString..";CanOpenBoxes")
        end
    end
    print(debugText)
end

Events.OnGameBoot.Add(EHE_Recipe.addCanOpenBoxesTagToTypesThatCan)
noble shale
#

If I'm adding a new listing to recipecode.lua, do I need to include this at the top? Or could I just include the function I want to add?

Recipe.GetItemTypes = {}
Recipe.OnCanPerform = {}
Recipe.OnCreate = {}
Recipe.OnGiveXP = {}
Recipe.OnTest = {}```
sour island
#

You shouldn't include that at the top actually

#

It would set them all to empty

#

You should instead use require "filepath after client/server/shared" before your code.

noble shale
#

I will keep working at it and I'll add this in, thank you!

sour island
#

Looks more complicated than it is

noble shale
#

I'm new to coding haha

sour island
#

Just check recipecode.lua's path

#

And copy it After the client/ server/ or shared/

#

And leave off the .lua

#

If I recall recipecode is in shared?

#

So it would just be require "recipecode" at the top of your file -- your file also has to be in the same directory (client/shared/server).

Require calls for the first file to be found before running anything after it.

noble shale
#

There's one in client and one in server

sour island
#

In vanilla?

noble shale
#

Yes!

sour island
#

Are they identical?

noble shale
#

Sry I lied

#

Just server

#

I misread the search I did

sour island
#

Ok, so your mod's file has to be in server/ too

#

And you can just put the require at the top -- it will have anything globally defined accessible

visual abyss
noble shale
#

require "\media\lua\server\recipes.lua after server"

Like that?

sour island
#

Anything with local infront will have to be copied

noble shale
#

errr

#

recipecode

sour island
#

No

safe silo
#

Does anyone know how to add heat sources to an object like how a antique oven works? Want to make a heater, but cant figure out how.

plucky junco
#

hi, a quick question, is possible to send the "quit" msg to the console using a mod?

sour island
#

require "recipecode"

#

That's it

sour island
#

Check the "recipe.class"

calm acorn
# visual abyss ``` recipe Dissect Corpse { CorpseMale/CorpseFemale, Ti...

Use a cumulative sum distribution function to get loot with the appropriate weights

--Cumulative Distribution Function
--Author: Xyberviri#5609
--License: GNU GPL v3
local function GetRandomLoot(loottable)
    local totalweights = 0 --Precompute this value for optimization
    for Pick, Chance in pairs(loottable) do
        totalweights = totalweights + Chance
    end

  local rand = ZombRand(1,totalweights) 
  local weight = 0
  for Pick, Chance in pairs(loottable) do
      weight = weight + (Chance * 10)
      if weight >= rand then
        return Pick
      end
  end
end

Then you can call it like this:

--Example:
local PartTable = {
    ["none"]                          = 70,
    ["ZomboidExtract.ZEZombieBrain"]  = 10,
    ["ZomboidExtract.ZEZombieHeart"]  = 10,
    ["ZomboidExtract.ZEZombieLung"]   = 10,
    ["ZomboidExtract.ZEZombieKidney"] = 10,
    ["ZomboidExtract.ZEZombieLiver"]  = 10,
    ["ZomboidExtract.ZEZombieBone"]   = 10,
    ["ZomboidExtract.ZEZombieFlesh"]  = 10,
  }
  
local item = GetRandomLoot(PartTable)
if item ~= "none" then
    player:getInventory():AddItem(item)
end

If you precompute your table weights then you an optimize the function like so:

--Cumulative Distribution Function (Optimized)
--Author: Xyberviri#5609
--License: GNU GPL v3
--Legal: https://tldrlegal.com/license/gnu-general-public-license-v3-(gpl-3) 
local function GetRandomLoot(loottable,totalweights)
  local rand = ZombRand(1,totalweights) 
  local weight = 0
  for Pick, Chance in pairs(loottable) do
      weight = weight + (Chance * 10)
      if weight >= rand then
        return Pick
      end
  end
end

--Example (Optimized):  
local item = GetRandomLoot(PartTable,140)

See: https://gist.github.com/xyberviri/0a4aaa0866a20bd3bf6ddd30d2663411

Gist

GitHub Gist: instantly share code, notes, and snippets.

sour island
visual abyss
safe silo
#

Oh okay.. Just found AddHeatSource and expected to just use that

outer juniper
#

Does anyone know where vehicle driving mechanics are coded? I want to make something that adds momentum to vehicles based on their weight, but I can't find where that info is or if I'm in over my head.

calm acorn
#

Thanks Chuck, should be pretty solid Zoids i have used that across multiple game engines and that formula is from a statistics and probably course i took a long time ago

safe silo
#

Is there a way to get the IsoCell? It looks like it's the specific tile in game but I would expect a X, Y, Z input for it but doesn't look like it.

calm acorn
#

getCell()

blissful salmon
#

@sour island Just for info... I solved my recipe problem by using a separate module name and a OnTest function which checks the sandbox option.

--recipe definition
module SoulMod_WoodCraft
{
  imports {
      Base
  }
  
  recipe SoulModCreateUnfinishedBat
  {
    Log=1,
    keep [Recipe.GetItemTypes.Saw],
    
    Result:SoulMod.UnfinishedBat,
    Sound:Sawing,
    Time:200.0,
    Category:Survivalist,
    SkillRequired:Woodwork=1,
    OnTest:SoulMod.CheckWoodCraftEnabled,
  }
}

-- OnTest function
function SoulMod.CheckWoodCraftEnabled(sourceItem, result)
  if SandboxVars.SoulMod.CraftItemsOverTime and true then
    return true
  end
    return false
end

-- hide from recipe tab by modulename
local recipes = getAllRecipes()

local function DisableWoodcraftRecipes()
    if recipes then
      for i = recipes:size() - 1, 0, -1  do 
          local recipe = recipes:get(i)
          if recipe:getModule():getName() == "SoulMod_WoodCraft" then
                recipe:setIsHidden(true)
            end
        end
    end
end

this seems to work so far...

calm acorn
#

thats the one the player is active in i think

#

if you are looking for a grid square i use sq = getCell():getGridSquare(x, y, z)

sour island
safe silo
sour island
#

Not home at the moment - if I have some time I'll poke around

visual abyss
#

@sour island so I was able to get local java exposed recipe and modified it. Now to figure how to actually apply the changes. ๐Ÿค”

#

cant seem to find a doparam version for recipe

calm acorn
#

@sour island I have added you to my credits for CarWanna https://steamcommunity.com/sharedfiles/filedetails/?id=2801264901 and disclosed that I reused some of your tooltip code from the skill recovery journal mod on my steam page along with a Credits.txt file distributed with the mod.

The exact file CWTitleVehicleUITooltip.lua in my mod has the gnu gpl v3 banner with notice of what was changed and link to the original source. were both use the same license and I think i have done everything to cover the requirements but if i missed something please let me know.

sour island
sour island
gilded hawk
#

So, I'm planning to make a mod that allows players in a faction to share symbols and markers on the map instantly.

Would this be useful to anyone?
Seems useful to me but in my server with my friends I'm the only guy using the map and markers ๐Ÿ˜•

visual abyss
# sour island I don't think it has a general doParam. But modifying the object should change t...

Unless i'm doing it completely wrong:

function ZomboidExtract_OverwriteBaseRecipes()
    local recipes = getScriptManager():getAllRecipes()

    if recipes then
        print("----------------------OVERWRITE BEGIN")
        for i = 0, recipes:size() - 1 do
            local recipe = recipes:get(i)
            print(recipe:getName())
            if recipe.setIsHidden ~= nil then
                recipe:setIsHidden(true)
            end
            -- break
        end
        print("----------------------OVERWRITE END")
    end
end
sour island
#

Should work but this would hide all recipes

sour island
gilded hawk
#

Well, I guess it's time to code

sour island
#

I wanted to add map markers or such for EHE but when they first released it was a bit hard to decipher it

sour island
#

Bonus points if I can draw a large circle of about 50ish squares

#

Expanded Heli Events

visual abyss
gilded hawk
#

oh, I remembered that I need to try that mod at some point

#

Too bad that i'm spending more time coding than playing ๐Ÿฅด

noble shale
#

First mod makes the game crash in menu, wholesome

visual abyss
thorn bane
#

I know this is a general lua question but I can't figure this out.

How do I get the length from this line?
getPlayer():getInventory():getItemsFromFullType("Radio.RadioMakeShift")

gilded hawk
#

@sour island I think you know this, do we have a vanilla way to print LUA tables in the console.txt?

calm acorn
#

length of the string? string.len( string ) == # ?

thorn bane
calm acorn
#

#array

gilded hawk
thorn bane
thorn bane
# calm acorn #array

Typing print(#getPlayer():getInventory():getItemsFromFullType("Radio.RadioMakeShift")) throws me an error when I type it into the command console

gilded hawk
# thorn bane It isn't, wish it was that easy

Odd, it clearly is a ArrayList

public ArrayList<InventoryItem> getItemsFromFullType(String var1) {
      return var1 != null && var1.contains(".") ? this.getAllType(var1) : new ArrayList();
   }

Try

print(getPlayer():getInventory():getItemsFromFullType("Radio.RadioMakeShift"):size()-1)
thorn bane
#

Oh, I see what I did wrong

#

You typed "Size()" and not "size()"

#

Aren't typos a wonderful thing :v

calm acorn
#

death by casing

gilded hawk
calm acorn
#

i renamed some files thinking i was being organized, ended up costing me a week until i figured out file load order was a thing ๐Ÿ˜›

thorn bane
#

lmaooo

calm acorn
#

@ancient grail I pushed my final update for CarWanna; Added the ability for players to turn vehicles back into pinkslips, vehicles save part condition, installed inventory items, vanilla cars even keep the same color https://puu.sh/JoMGl/c07e9b4ede.mp4

noble shale
#

My game locks up every time I try to load my mod and I can't figure out why. psyduck

calm acorn
#

%userprofile%\zomboid\console.txt

#

should be the last thing in the list

scarlet zinc
#

Is there a way to force inventory to exist a limit number of a certain item, and stop something to not unequip it by players in normal means?

calm acorn
#

like you can equip it in more than one slot?

noble shale
#

"RecipeManager.resolveItemModuleDotType> WARNING: module "Base" may have forgot to import module Base"

But I have it?? I think?

imports {
            Base
    }

    recipe Scrap Log
    {```
scarlet zinc
#

Was trying to make a orifice mouth mod

ancient grail
calm acorn
#

Or just use Base and dont bother with the import

ancient grail
#

his trying to make vanila vehicles all have upgrades and i mentioned the paint thing aswell .

calm acorn
#

There is a set HSV command on the server which sends the updated colors to the clients you just need to make sure you get the vehicle by ID for it to work

noble shale
bronze yoke
#

painting vehicles works fine (i assume, i've never tested it) but i don't think painting parts is possible at all

calm acorn
#

vehicles parts all use the same color

bronze yoke
#

that's what glytch3r was asking me about painting before, i think

calm acorn
#

yeah you cant really have individual parts be different colors, also that only works with vanilla and fillabusters cars because they dont have a full skin that covers the model, what the pz peeps did was make it so that the transparent part of the texture uses that HSV setting.

visual abyss
#

anyone got an example of ArrayList.removeIf() in lua

#

I can't seem to get it to work

thick karma
#

Anyone happen to know where exactly the game draws your perk level-up info off the top of your head?

noble shale
thorn bane
#

Anyone know how to add a new tab to the Chat?

thorn bane
#

losing my mind over how to add a tab

hearty dew
#

There is ProjectZomboid/media/lua/client/Chat/ISChat.lua, and there is a bunch of the chat code in java too, so hopefully enough is exposed in lua to add custom tabs. ISChat:createTab might be promising

pine fiber
thorn bane
#

@hearty dew I'm basing my code from ISChat, but I can't seem to figure out ISChatcreateTab

thorn bane
#
--                                  Global Radio             /gradio                    Global Radio         
ISChat.allChatStreams[8] = {name = "globalradio", command = "/gradio ", shortCommand = "/gr", tabID = 3};
ISChat.defaultTabStream[3] = ISChat.allChatStreams[8];
#

Edit: Mistyped 3 on the first line

#

I'm having a look at ISChat.onTabAdded, but I haven't a clue on how to actually implement it

hearty dew
#

Looks like a portion of the tab setup is done in zombie.chat.ChatManager. Might have to look through that.

#

It raises the OnTabAdded event

thorn bane
#

Oooh, inneresting

#

I'll have a quick peep

thorn bane
thorn bane
#

@bronze yoke Came up empty handed. Maybe I didn't implement it correctly

#

Nope, still no luck ๐Ÿ˜”

tired creek
#

I donโ€™t know anything about modding (or if this already exists) but I had an idea for if thereโ€™s a task the lets say requires 4 metal working and 5 mechanics if you have 2 players near each other 1 with the 4 metal working another with the 5 mechanics they can both work on it together. Definitely useful on higher pop servers/groups

quartz birch
#

would anyone like to help me get started with my first mod?

thorn bane
quartz birch
#

I wanna make a media player basically

thorn bane
thorn bane
quartz birch
#

like an in game ui screen that you can watch or listen to content on

thorn bane
#

I don't think the game even supports getting any information from the web

quartz birch
#

dang ๐Ÿ˜ฆ

#

there goes my idea then

thorn bane
thorn bane
#

PROGRESS

#

PROGESSSSSSS

#

Right, so I have nailed it down to this big chunk of code;

ISChat.onTabAdded = function(tabTitle, tabID)
    local chat = ISChat.instance;
    local newTab = chat:createTab();
    newTab.parent = chat;
    newTab.tabTitle = tabTitle;
    newTab.tabID = tabID;
    newTab.streamID = 1;
    newTab.chatStreams = {}
    for _, stream in ipairs(ISChat.allChatStreams) do
        if stream.tabID == tabID + 1 then --tabID is zero-based index but stream.tabID is one-based index.
            table.insert(newTab.chatStreams, stream)
        end
    end
    newTab.lastChatCommand = newTab.chatStreams[newTab.streamID].command;
    newTab:setUIName("chat text panel with title '" .. tabTitle .. "'");
    local pos = chat:calcTabPos();
    local size = chat:calcTabSize();
    newTab:setY(pos.y);
    newTab:setHeight(size.height);
    newTab:setWidth(size.width);
    if chat.tabCnt == 0 then
        chat:addChild(newTab);
        chat.chatText = newTab;
        chat.chatText:setVisible(true);
    end
    if chat.tabCnt == 1 then
        chat.panel:setVisible(true);
        chat.chatText:setY(pos.y);
        chat.chatText:setHeight(size.height);
        chat.chatText:setWidth(size.width);
        chat:removeChild(chat.chatText);
        chat.panel:addView(chat.chatText.tabTitle, chat.chatText);
    end
    if chat.tabCnt >= 1 then
        chat.panel:addView(tabTitle, newTab);
        chat.minimumWidth = chat.panel:getWidthOfAllTabs() + 2 * chat.inset;
    end
    table.insert(chat.tabs, newTab);
    chat.tabCnt = chat.tabCnt + 1;
end

However, I'm struggling to make this tab different than the "General" tab that's already in the game. Any ideas?

sour island
gilded hawk
limber summit
#

Back with more info for my engi evolvedRecipe mod...I will make this more complicated eventually in terms of breaking down these items into more chemical-ly components, but initially the items i have listed for:

increasing either firepower/range and explosionpower/range are:

  • gasoline
  • gunpowder
  • bleach
  • distilled alcohol

increasing extraDamage:

  • nails
  • screws
  • glass
  • scrap metal

Anything missing?

vast nacelle
#

Am I correct in assuming the AimingMod property of guns is added to the character's aiming skill before being multiplied by the AimingPerkHitChanceModifier property?
So a gun held by a character with level 5 Aiming with
Hitchance = 40
AimingMod = 0.8
AimingPerkHitChanceModifier = 10
Would end up having an actual hitchance of (40 + (10 * (5+0.8)) = 98)?

#

Or does Aiming mod instead deal with how quickly your character acquires targets? (Red outline to green)

visual abyss
#

I'm under the impression that green outline means guaranteed hit

glacial flicker
#

Any modder out there willing to help a newbie out? I have a couple of ideas but lack knowledge on how to apply them

safe silo
#

If I wanted to just create a world item with no actual type, like just a MISC item what would I put under Type?

I want a base template for an item that has no actual function if it makes sense

    item ElectricHeater
    {
        Type                    =   Radio,
        Weight                    =    2.4,
        Icon                    =    ElectricHeater,
        DisplayName             =   Electric Heater,
        WorldStaticModel        =   ElectricHeaterModel,
        ConditionMax            =   100,
        UseDelta                =   0.009, 
        UseWhileEquipped        =   FALSE,
        DisappearOnUse            =   FALSE,
        TwoWay                    =   FALSE,
        TransmitRange            =   0,
        MicRange                =   0,
        BaseVolumeRange            =   15,
        IsPortable                =   TRUE,
        IsTelevision            =   FALSE,
        MinChannel                =   100,
        MaxChannel                =   200,
        UsesBattery                =   TRUE,
        IsHighTier                =   FALSE,
        Tooltip                 =   Tooltip_item_Boombox,
        AcceptMediaType         =   0,
        UseWorldItem             =     TRUE,
    }
#

Currently type is Radio, but I want it to be like "none" or "misc"

visual abyss
#

Normal

#

Afaik Type is "hardcoded"

#

to like 6 specific types

safe silo
#

So I can set it to "Normal"?

visual abyss
#

yeah

#

Normal

safe silo
#

Alright. What about the template for different DisplayName, Icon etc?

visual abyss
#

what do you mean?

safe silo
#

So all the variables inside my example has stuff like MicRange, TwoWay which is used when Type = Radio.

What are the default variables with using Type = Normal?

jade chasm
#

is there a table somewhere with all the loot distribution tags?

safe silo
#

Like would this be sufficient?

    item ElectricHeater
    {
        Type                    =   Normal,
        Weight                    =    2.4,
        Icon                    =    ElectricHeater,
        DisplayName             =   Electric Heater,
        WorldStaticModel        =   ElectricHeaterModel,
    }
visual abyss
#

oh minimal

#

uhh yeah that would suffice

#

in fact

safe silo
#

sweet, thanks!

visual abyss
#

you can omit icon and world static model

#

but world static model is the only thing that allows it to show up in the world (not carried/container)

#

This is the most minimal i got

#

prob could omit weight

safe silo
#

Oh damn lol, ty!

visual abyss
#

i dont have worldstaticmodel cause it'll never be used in the world

safe silo
#

How would I print stuff to the console if I'm in debug mode from my LUA?

Is it just print("hello world")?

visual abyss
#

yes

safe silo
#

What does item:getType() == "" actually do?

Is it the name of the item it looks for?

So if I have an item named "Lorem"

Will item:getType == "Lorem" be TRUE?

bronze yoke
#

yeah

safe silo
#

So getType is the same as getName? Or is getType safe for if players would be able to change the name

visual abyss
#

I think its the one where

#

you define it

#

item itemNameType { }

#

getType would return itemnameType

#

while getname returns displayname

#

this is just off top of my head

safe silo
#

Ohhhhh sweet! thanks

visual abyss
#

though

#

cause looking at the source

#
            if item:getType() == "IronIngot" then
    item IronIngot
    {
        DisplayCategory = Material,
        Weight = 5,
        Type = Drainable,
        DisplayName    = Workable Iron,
        Icon = MetalBits,
        UseDelta = 0.01,
        ConsolidateOption = ContextMenu_Merge,
        UseWhileEquipped = FALSE,
    }
ancient grail
glacial flicker
#

Can you isolate vehicle mechanics and add them to a tile?

#

I want to have garbage containers have 2 seats to hide in it

safe silo
#

How easy would it be to make a context menu that only takes batteries and show how much battery is left? Is there a menu i can copy from in-game?

bronze yoke
calm acorn
#

otherwise it just shows the icon

calm acorn
safe silo
#

Is it possible to have normal world item and add a function to it so it can open a menu with battery in it?

small topaz
#

When making a new recipe via scripts and requiring that the player needs 5 items to realize the recipe, does anyone knows whether it is possible to allow the player to use 5 items from different categories?

What I want to do is this: The player should be able to craft a new item using 5 berries as ingredient. The game comes with different types of berries: Base.BerryBlue, Base.BerryGeneric1, Base.BerryGeneric2, ... and so on. Now I want to arrange things so that players can use any combination of those berries as long they have 5 berries in their inventory. For example 5 Base.BerryBlue should work but also 2 Base.BerryBlue + 3 Base.BerryGeneric1.

I already tried constructions like

Base.BerryBlue/Base.BerryGeneric1/Base.BerryGeneric2 = 5

or

[Recipe.GetItemTypes.Berry] = 5

in the recipe.txt script but both ideas didn't work for me (with this, players can only craft the item when having 5 berries of the same type in their inventory, 5 Base.BerryBlue, 5 Base.BerryGeneric1, but not possible to mix berries up).

Any ideas how I could solve the problem?

ancient grail
#

ahhh so
Type() prints what kind of variable it is

getType() prints the name

getFullType() prints the module

isVanilla() prints true or false

so we can have something like

if (item:getType == "Apple" and item:isVanilla == false)
then doPoisonDamage()
end

idk just made it up
so that any other apple is poison for example
idk haha

ancient grail
ancient grail
thorn bane
#

Asking back here, would anyone know how to create a new chat tab for the MP Chat Window?

I've managed to duplicate the General tab using onTabAdded, but I can't figure out how to make it entirely unique FROM general.

ancient grail
#

u want the recipe to consume 5berries?
then just use
Base.Berries=5,

small topaz
ancient grail
thorn bane
#

Derive?

small topaz
#

as I wrote 5 Base.BerryBlue should work but also 3 Base.BerryBlue + 2 Base.BerryGeneric1 as well...

thorn bane
ancient grail
#

look for lua inherit or derive
i havent played with it but i think this is what you need

ancient grail
thorn bane
#

Hmmm, I don't think that'd be the answer, but I'll take a peep none-the-less

sour island
ancient grail
#

you might need to repeat the lines over and over again like 5x

sample


bery1/bery2/bery3/bry3/berri4/verby5

bery1/bery2/bery3/bry3/berri4/verby5

bery1/bery2/bery3/bry3/berri4/verby5

bery1/bery2/bery3/bry3/berri4/verby5
sour island
#

also: if that doesn't work:

   public Boolean onMouseUp(double var1, double var3) {
      if (!this.isVisible()) {
         return Boolean.FALSE;
      } else {
         super.onMouseUp(var1, var3);
         this.moving = false;
         this.setCapture(false);
         return Boolean.TRUE;
      }
   }
ancient grail
sour island
#

this should be called after you click on the x - being the window is not visible -- I have no idea what Boolean.FALSE is doing tho

#

database panel?

ancient grail
ancient grail
thorn bane
ancient grail
#

where you can log users add remove users see ban ids etc

sour island
#

you mean the admin panel?

#

isn't that just a standard UI window?

#

the command console isn't standard UI - which is what I was mistaken about

ancient grail
#

this one @sour island

sour island
#

and you want that to be closed?

ancient grail
#

no. to do function commands to do what the buttons do without clicking it

#

like adding users automatically

sour island
#

lua/client/ISUI/AdminPanel/ISWhitelistViewer.lua

ancient grail
#

without a client admin

a lua function that auto does this sendcommandtoserver doesnt work since it reqiore admin

ancient grail
thorn bane
#

@sour island Sorry to put you on the spot, but you wouldn't know how to add a tab in the chat UI, do you?

sour island
#

Not personally no

thorn bane
#

Damb ๐Ÿ˜”

sour island
#

you'd have to look through the UI code

thorn bane
#

I have, I've had no luck

#

I can get another chat tab, but it's a duplicate of the General tab

ancient grail
#

can we see the code you did that created the other general tab u mentioned? and may i ask what your goal is

thorn bane
#

I can't get this one to be unique

#

Sure, one sec

#

Big wall of code incoming, its just the same function in ISChat.lua

#
ISChat.onTabAdded = function(tabTitle, tabID)
    local chat = ISChat.instance;
    local newTab = chat:createTab();
    newTab.parent = chat;
    newTab.tabTitle = tabTitle;
    newTab.tabID = tabID;
    newTab.streamID = 1;
    newTab.chatStreams = {}
    for _, stream in ipairs(ISChat.allChatStreams) do
        if stream.tabID == tabID + 1 then --tabID is zero-based index but stream.tabID is one-based index.
            table.insert(newTab.chatStreams, stream)
        end
    end
    newTab.lastChatCommand = newTab.chatStreams[newTab.streamID].command;
    newTab:setUIName("chat text panel with title '" .. tabTitle .. "'");
    local pos = chat:calcTabPos();
    local size = chat:calcTabSize();
    newTab:setY(pos.y);
    newTab:setHeight(size.height);
    newTab:setWidth(size.width);
    if chat.tabCnt == 0 then
        chat:addChild(newTab);
        chat.chatText = newTab;
        chat.chatText:setVisible(true);
    end
    if chat.tabCnt == 1 then
        chat.panel:setVisible(true);
        chat.chatText:setY(pos.y);
        chat.chatText:setHeight(size.height);
        chat.chatText:setWidth(size.width);
        chat:removeChild(chat.chatText);
        chat.panel:addView(chat.chatText.tabTitle, chat.chatText);
    end
    if chat.tabCnt >= 1 then
        chat.panel:addView(tabTitle, newTab);
        chat.minimumWidth = chat.panel:getWidthOfAllTabs() + 2 * chat.inset;
    end
    table.insert(chat.tabs, newTab);
    chat.tabCnt = chat.tabCnt + 1;
end

Events.OnTabAdded.Add(ISChat.onTabAdded);
ancient grail
#

whats the purpose whos suppose to be allowed to use it?

#

is this an overwrite of the vanilla lua?

#

im currently on mobile cant check stuff

thorn bane
#

I have another command, /radio, that kind of acts like /all, but only works if the player has a radio.

I've set it the command to work in a unique tabID, which I can't seem to create

thorn bane
#

Nothing's changed

ancient grail
#

?

thorn bane
#

Nope

#

That's different

thick karma
#

I did not know how to send click commands to that exit button and if it's THIS easy omfg thank god

thorn bane
#

Changing anything in the code block btw doesn't do anything, and just breaks the chat UI entirely

#

I'm not the smartest when it comes to Lua

ancient grail
#

ZombiePopulationWindow.OnOpenPanel(); 
ISCheatPanelUI.OnOpenPanel()
ISItemsListViewer.OnOpenPanel()
ISDebugMenu.OnOpenPanel();
ISGeneralDebug.OnOpenPanel()
ISPlayerStatsUI.OnOpenPanel()
BrushToolManager.openPanel(playerObj)
BrushToolManager.openPanel()
ISGameStatisticPanel.OnOpenPanel() 
ISAnimDebugMonitor.OnOpenPanel()
ZombiePopulationWindow.OnOpenPanel()
DailyValuesDebug.OnOpenPanel()
PlayerClimateDebug.OnOpenPanel()
WeatherFXDebug.OnOpenPanel()
ISAdminWeather.OnOpenPanel()
ForecasterDebug.OnOpenPanel()```

this is what i know you can do tho. i mean opening panels like button presses
thick karma
#

@sour island ๐Ÿ˜ญ it works the same as setVisible, which is unfortunately not a good thing

ancient grail
#

ouch

thick karma
#

Do you know how to send a mouse-click signal to center of the screen?

#

Or corner or something?

#

To a nonspecific location?

#

I think that might fix this because the only way I can currently make debug console input caret stop flashing is to either (A) click off the window, or (B) enter a broken console command

#

Obviously B is an unacceptable solution

ancient grail
thick karma
#

I do not want users to have to figure out A

ancient grail
#

for example

thorn bane
ancient grail
thick karma
ancient grail
#

wait sorry just read the script and this is the one that inserts all the avilable chats

#

this wont work i think @thorn bane

thorn bane
#

Yeaah

ancient grail
thorn bane
#

Like I said, clueless ;v;

sour island
ancient grail
#

@thorn bane perhaps you nbeed to add a line here

#

--

require "ISUI/ISCollapsableWindow"
require "ISUI/ISRichTextPanel"
require "ISUI/ISButton"
require "ISUI/ISTabPanel"

ISChat = ISCollapsableWindow:derive("ISChat");
ISChat.maxLine = 50;
ISChat.focused = false;
ISChat.allChatStreams = {}
ISChat.allChatStreams[1] = {name = "say", command = "/say ", shortCommand = "/s ", tabID = 1};
ISChat.allChatStreams[2] = {name = "yell", command = "/yell ", shortCommand = "/y ", tabID = 1};
ISChat.allChatStreams[3] = {name = "whisper", command = "/whisper ", shortCommand = "/w ", tabID = 1};
ISChat.allChatStreams[4] = {name = "faction", command = "/faction ", shortCommand = "/f ", tabID = 1};
ISChat.allChatStreams[5] = {name = "safehouse", command = "/safehouse ", shortCommand = "/sh ", tabID = 1};
ISChat.allChatStreams[6] = {name = "general", command = "/all ", tabID = 1};
ISChat.allChatStreams[7] = {name = "admin", command = "/admin ", shortCommand = "/a ", tabID = 2};
ISChat.defaultTabStream = {}
ISChat.defaultTabStream[1] = ISChat.allChatStreams[1];
ISChat.defaultTabStream[2] = ISChat.allChatStreams[7];
-- default min and max opaque values
ISChat.minControlOpaque = 0.5; -- a value
ISChat.minGeneralOpaque = 0.0; -- a value, not percentage

#

and as mentioned you need to derive i really believe

thorn bane
#

I'll give it a crack, one second

#

Still throws an error, chat doesn't display

#

Give me a moment

small topaz
#

but I think I give up the plan of allowing the player to mix different berries and go another way...

ancient grail
#

its ugly but if you look at atm mods they do this to everysingle accessory than you can sell for cash

#

its cuz theres no tag for it

thick karma
#

Anyone know how the game handles clicking on the Debug Console's input field? I am trying to directly access it. I think it's a child of the UIDebugConsole instance you get from UIManager:getDebugConsole() because it ceases to exist if I ClearChildren on that object.

#

I'm not sure how to get the children of the debug console... I seem to only be able to remove them

small topaz
thorn bane
#

Still no luck with the Chat Tab

#

:(

ancient grail
# thorn bane Still no luck with the Chat Tab

i think this is a hard to do mod dude.. you will really have to learn lua and pz api and all that .. or perhaps look for reference.. i wish i have the solutions for u but im afraid im still very weak
hHa

but if i find a lead il just DM u abt it. im going to research abt chat commands anyways might come across something related to your needs

thorn bane
#

Sure, cheers

#

Theres only one other mod I see do chat tabs but its so complicated that I haven't been able to analyze it

thick karma
#

No one has any bright ideas for triggering a mouse click event do they?

visual abyss
#

can weapon not have more than 1 compatible clips/mags?

thick karma
#

Does PerkFactory bug out on high XP growth settings? I'm confused by the feedback it's giving me

#
    character:Say("Add XP: " .. perk:getName() .. ". Level " .. tostring(level))
    character:Say("Current XP: " .. tostring(perk:getXpForLevel(level)) .. ". XP to Next Level: " .. tostring(perk:getTotalXpForLevel(level)))
    character:Say("Current XP: " .. tostring(perk:getXpForLevel(level + 1)) .. ". XP to Next Level: " .. tostring(perk:getTotalXpForLevel(level + 1)))
    character:Say("Current XP: " .. tostring(perk:getXpForLevel(10)) .. ". XP to Next Level: " .. tostring(perk:getTotalXpForLevel(10)))
#

Seems like numbers come out wonky from AddXP but not LevelPerk

#

In fact I think maybe Level in AddXP is giving me the XP I am getting, and Perk is giving me some odd garbage disconnected from the actual state of my perks

thick karma
#

Also, when I call setHoursSurvived, I notice that it works in the Debug console but doesn't work when called from any of my files... any way to make it work?

vast nacelle
# thick karma ``` character:Say("Add XP: " .. perk:getName() .. ". Level " .. tostring(lev...

I'm not sure what the issue here is. Those print statements are showing exactly what I'd expect.
You asked for how much XP it takes to get to level 2 Sprinting from level 1, which is 150. Then you ask how much XP you would have in total after having acquired level 2, so the XP needed for Level 1 + Level 2, which is 225.
Then you ask for the same for level 100, which doesn't exist. There isn't a level 100 Sprinting, so the xp needed for getting from a theoretical level 99 to level 100 is just a -1, i.e. invalid. As for total XP, it just gives you the total of all the xp needed for all the valid levels, which is 32775.

thick karma
#

That variable was passed to me by the Event triggers

#

Under the name "level"

#

Beside the word "perk"

#

So you can hopefully see how I did not expect to be getting level 100 as output

#

Or any of the consequences of that

#

I guess I expected the parameter names that match in AddXP and LevelPerk to match in real terms, but they clearly don't completely. When I call LevelPerk's level variable, it gives me my level in that perk.

#

Hence I assumed broken

#

or at least wondered I should say

vast nacelle
#

Yeah, AddXP takes in the skill being added to and the amount of XP that is to be given. If it is calling that amount 'level' somewhere, that's a bad variable name.

ancient grail
vast nacelle
#

I'd say that's on TIS for betraying expectations with a bad variable name.

thick karma
#

that's what confused me so much

#

Thanks for clarifying

thick karma
ancient grail
thick karma
#

How do you mean?

#

I ran it in the client, shared, and server folders to no avail

ancient grail
thick karma
#

Nah more like they're in a hurry and things get overlooked and mistakes get made in the name of deadlines

#

They are actually pretty unusually supportive of modding

ancient grail
ancient grail
#

which is helpful

#

i bet live streaming a talk about basic to advance modding will attract alot of attention esp if its comming from popular mod authors
i wish theres such event

thick karma
#

Haha unfortunately I think a lot is subjective and that lot would be small... watching random Zomboid modding live is not on many people's agendas.

#

I mean only so many people post here a day and I don't think most of us would want to sit around watching each other mod... too busy on our own

glacial flicker
#

is this where we drop ideas for mods because I don't know how to mod?=

#

Separate Aiming into categories (Revolver/pistol, shotgun, rifle, semi-automatic, etc) so people can't farm Aiming with a shotty and 10 boxes of shells

#

also another idea, hiding in dumpsters

wintry stag
marble lynx
#

they can smell you too, you haven't been showering for a month

#

๐Ÿ‘ƒ

bronze yoke
#

mod where zombies can smell you based on your body dirt

marble lynx
#

i will await the release ๐Ÿคฃ

vast nacelle
#

But I do wish for a breakdown of the Aiming skill.

marble lynx
bronze yoke
#

my girlfriend was discussing the potential mechanics of a random tripping mod earlier

marble lynx
#

yeah i think that aiming thing is cool and does make sense as well

marble lynx
#

sounds like hell

bronze yoke
#

maybe for april fools...

vast nacelle
bronze yoke
#

yeah player tripping

fast galleon
#

is the isosquare:getCanSee(int) reliable? Seems to work on SP so far.

fast galleon
#

ah this again

#

print("distance: ",player:DistTo(x + 0.5, y + 0.5))
print("distance sq",player:DistToSquared(x + 0.5, y + 0.5))
distance: 4
distance sq: 9

ruby urchin
#

I prefer use vectors

#

local distance = Vector2f.new(x1, y1):distance(x2, y2);

fast galleon
ruby urchin
jaunty marten
# fast galleon Thank you, forgot about that one. What makes it better?

if u don't need accuracy like u just check distance between objects then better to use :DistToSquared
if u want to draw it somewhere like hud and u need accuracy there then first one
cos in :DistTo and :distance uses math.sqrt and to calc sqrt machine need more resources than :DistToSquared

fast galleon
ancient grail
#

just wanted to share my bat file that auto creates folderstructure for modding

@echo off
MKDIR media\lua\client\ISUI
MKDIR media\lua\server\Items
MKDIR media\texturepacks
MKDIR media\lua\shared\Translate\EN
MKDIR media\scripts
MKDIR media\sound
MKDIR media\textures\Worlditems
MKDIR media\models_X\Worlditems
MKDIR media\clothing
MKDIR media\ui\vehicles
exit
gaunt meteor
#

does anyone know where player damage is handled? its not lua is it?

#

if two players hit eachother where does the game define that? O_o

pine fiber
hearty dew
#

.

#

I'd check in ProjectZomboid/zombie/characters/BodyDamage/BodyDamage.class

hearty dew
#
----------  Static Fields  -----------
Field Type            Field Name      Field Value
static UIDebugConsole instance      = zombie.ui.UIDebugConsole@52d7542f
static Object         outputLock    = DebugConsole Output Lock
static ByteBuffer     outputBB      = java.nio.HeapByteBuffer[pos=0 lim=8192 cap=8192]
static boolean        outputChanged = false
static CharsetDecoder outputDecoder = sun.nio.cs.UTF_8$Decoder@3fb6f218
static char[]         outputChars   = [C@19dcd79f
static CharBuffer     outputCharBuf =

----------  Instance Fields  -----------
Field Type        Field Name              Field Value
IsoGameCharacter  ParentChar            = nil
ScrollBar         ScrollBarV            = zombie.ui.ScrollBar@6524e8c2
UITextBox2        OutputLog             = zombie.ui.UITextBox2@4ef418dc
UITextBox2        CommandLine           = zombie.ui.UIDebugConsole$CommandEntry@723ad6fc
UITextBox2        autosuggest           = zombie.ui.UITextBox2@1aa482b8
String            ConsoleVersion        = v1.1.0
int               inputlength           = 47
ArrayList<String> Previous              = [LUtils.inspectJava(UIManager:getDebugConsole()), print(tostring(LUtils.g ...
ArrayList<Method> globalLuaMethods      = [public static void zombie.Lua.LuaManager$GlobalObject.triggerEvent(java. ...
int               PreviousIndex         = 17
Method            prevSuggestion        = public static void zombie.Lua.LuaManager$GlobalObject.disconnect()
String[]          AvailableCommands     = [Ljava.lang.String;@127177f3
String[]          AvailableCommandsHelp = [Ljava.lang.String;@2c7e9647
boolean           bDebounceUp           = false
boolean           bDebounceDown         = false
----------  Instance Methods  ----------
Return Type Method Name         Parameters
void        render              ()
void        addOutput           (byte[], int, int)
void        ProcessCommand      ()
void        onOtherKey          (int)
void        InitSuggestionEngine()
int         levenshteinDistance (CharSequence, CharSequence)
void        handleOutput        ()
Method      SuggestionEngine    (String, ArrayList)
Method      SuggestionEngine    (String)
void        SpoolText           (String)
void        UpdateViewPos       ()
void        historyPrev         ()
void        historyNext         ()
void        ClearConsole        ()
void        setSuggestWidth     (int)
void        update              ()

That's what shows up in the reflection APIs for the UIManager:getDebugConsole() object. Plus a bunch of methods on the super classes

visual abyss
#

Being little lazy before I start researching - how does one determine if the player enters a certain spot and trigger an event (for example, teleport to another place)

thorn bane
#

Once again asking back here, but does anyone know how to make another tab in the Chat UI?

hearty dew
thorn bane
ancient grail
# pine fiber I also take the opportunity to share this addon for VSC which also allows to gen...

i also plan to someday create a tool using autohotkey
that allows modders to visually see what they are doing
like for example if they are to create an item then first thing they would pick is the category
then after that a checkbox of paramaters they want to use
when they check it they will input the data for it and theres a default data incade they are not sure yet.

they will just pick a script.txt file and it will append the stuff
there
this will reduce human error and also speed things up for advance modders and will guide newbie modders
its just that i havent mastered all the items yet so im not quite sure if i can do this yet

it would be faster if i use a spreadsheet first to map out everything..
wana colab on doing this? idk how to do it using vc.i only know very few languages and barely master any

ancient grail
pine fiber
visual abyss
#

first time messing with clickedSquare and the likes and I can't figure out why I'm having error on last print line

local function testFillContext(player, context, worldobjects, test)
    if test then return; end

    local square = clickedSquare;

    print("iso square ("..square:getX()..","..square:getY()..")");
    if instanceof(square, "IsoGridSquare") then
        local objs = square:getObjects();
        for i = 0, objs:size() - 1 do
            print("obj: "..objs:get(i));
        end
    end
end

Events.OnFillWorldObjectContextMenu.Add(testFillContext);
#

am i missing something?

#

I'm still learning how to read the ingame debugger but here's the screenshot

hearty dew
#

The debugger is a bit wonky sometimes, and it isn't easy to already read the error messages. Best way for me is to open Zomboid/console.txt in a terminal, and tail it so any new lines appended show up in the terminal. Then you'll easily see the exceptions caused by the errors.

#

For example, your error isn't there until after you step over the line. And you have to click the Errors button at the top to see the error. And I think it appends the error at the top or something, or it doesn't scroll to the most recent error, making it a bit of a nuisance imo

visual abyss
#

yeah i just found out haha

#

but now i'm just struggling cause

#

there's only 1 obj in the list

#

and its nil

#

is that intended?

hearty dew
#

Hmm, it shouldn't be. Hopefully the java side isn't inserting nulls into arrays, at least

#

What's the error message?

visual abyss
#

well i'm not erroring right now but sec

#
local function testFillContext(player, context, worldobjects, test)
    if test then return; end

    local square = clickedSquare;

    print("iso square ("..square:getX()..","..square:getY()..")");
    if instanceof(square, "IsoGridSquare") then
        local objs = square:getObjects();
        print("objs size: "..objs:size());
        for i = 0, objs:size() - 1 do
            local obj = objs:get(i);
            if instanceof(obj, "IsoObject") then
                local idk = obj:getName();
                print(idk);
            end
        end
    end
end

Events.OnFillWorldObjectContextMenu.Add(testFillContext);
#

it would print idk (aka nil)

#

it being nil is the reason it errored out

#

if it helps, i'm in my custom map

#

not vanilla map

#

slightly different code than above

#

was trying to trigger the error

#
local function testFillContext(player, context, worldobjects, test)
    if test then return; end

    local square = clickedSquare;

    print("iso square ("..square:getX()..","..square:getY()..")");
    if instanceof(square, "IsoGridSquare") then
        local objs = square:getObjects();
        print("objs size: "..objs:size());
        for i = 0, objs:size() - 1 do
            local obj = objs:get(i);
            if instanceof(obj, "IsoObject") then
                -- local idk = obj:getName();
                -- print(idk);
                print("obj ("..i.."): "..obj:getName());
            end
        end
    end
end

Events.OnFillWorldObjectContextMenu.Add(testFillContext);
hearty dew
visual abyss
#

is it possible to print just obj?

hearty dew
#

if you call tostring on it, it will just print out the java type and the lua address of the object

#

I have a function to print out java objects though, prints out fields and methods, if you'd find that useful

visual abyss
#

that would be great.

#

i could have used that the last few days haha

hearty dew
#

Adding some color to it atm. If you're using an ansi terminal and want it printed in color, I can upload the colorized version later

#

Hmm, apparantely windows terminals don't support ansi colors until windows 10 (with the Threshold 2 Update in Nov 2015). So would need another terminal like mintty (that comes with cygwin) prior to that

ruby urchin
visual abyss
#

no

#

object

#

trying to make a teleport pad so to speak

#

accessing it via context menu

#

er adding the ability to use it with timed action in context menu

#

so i'm just trying to learn how to use the context stuff

#

and well the obj stuff is holding me up

visual abyss
#

let me try this in the vanilla map

ruby urchin
#

You can try this one

---Gets all IsoMovingObject from IsoGridSquare.
---@param p1 IsoGridSquare | table
---@return table
getObjectFromSquare = function(p1)
    local t = {};

    if type(p1) == "table" then

        for k, v in pairs(p1) do
            local objects = v:getMovingObjects();

            for i = 0, objects:size() - 1 do
                local object = objects:get(i);

                table.insert(t, object);
            end
        end
    else
        local objects = p1:getMovingObjects();

        for i = 0, objects:size() - 1 do
            local object = objects:get(i);

            table.insert(t, object);
        end
    end

    return t;
end

local squareObjects = getObjectFromSquare(square);

visual abyss
#

see if it isn't throwing an error

#

oh thanks

#

i'll try that

ruby urchin
#

just change getMovingObjets for getObjects

visual abyss
#

whats the difference between those 2

ruby urchin
#

IIRC getMovingObjects get Players, NPC and things like that, and getObjects Items ground, sprites, etc, basically static things

small stag
#

What's a good starting place for mod creation? e.g. language to research, and repos to browse, tutorials for the PZ api if there are any.

thin dirge
#

the pinned messages

small stag
#

is everything written in LUA, or are there alternatives?

visual abyss
#

yes

#

there is a typescript to lua transpiler

small stag
#

nice, thank you

visual abyss
#

bruh i'm just gonna take a break from this lmao

#

i legitimately have no idea why i keep getting a nil obj

#

it seems every squre has at least one object

sour island
#

I add context menus to objects on the map based on their mod data

#

Should have enough info here to get what you need

#

I'm not sure if worldObjects is already a table of the same objects as squares' objects -- but that's how I found it in vanilla ... So ๐Ÿคท

visual abyss
thick karma
#

Ay is there a limit on how many OnTick things can get done or something? I tried borrowing OnTick capabilities from my other mod and even though the code looks right to me, my new OnTick function is never firing.

#

I've tried firing it from shared and client and I'm getting nada...

#
local function zeroSurvivedTime(ticks)
    
    -- oddTickB = not oddTickB

    -- if oddTickB then return end

    for playerIndex = 0, getNumActivePlayers() - 1 do

        if player then 

            player:Say("Tick... tock...")

        end
    end
end

Events.OnTick.Add(zeroSurvivedTime)```
sour island
#

If player?

thick karma
#

Makes sure player object exists to prevent exceptions when player is dead and such

#

Works in all my mods, shouldn't be the issue

sour island
#

It's just I don't see where it's defined

thick karma
#

Oh shit

#

Thank you

#

Wow

#

I was just so tired last night lmao

sour island
#

Happens

thick karma
#

And today I overlooked that because so elementary

#

Thanks man

#

Was losing my mind

#

lol I really owe you a coffee if you have a donation link ๐Ÿ˜›

sour island
#

I do, but it's no worries

astral dune
#

This is why I use intellij and am very suspicious of purple colored variables, lol

glacial flicker
#

Quick question. Is there a way to change how the water tiles work depending on the season? I'd like for them to freeze during the winter and letting zombies and players walk on them

blissful salmon
#

Is there a way to detect if a new zombie was created? In the event list I only found OnZombieUpdate or OnZombieDead.

gaunt meteor
#

heyyo im super tired, can anyone tell me the true name for tailoring e.g. is it Perks.Tailoring? sry for dumb question im just way too tired and also firstaid is named Perks.Doctor for e.g.

magic nymph
gaunt meteor
magic nymph
#

np

ancient grail
# thorn bane Still no luck with the Chat Tab

This video explains OOP and inheritance in Lua and how it can be used to create classes.

Socials:
Discord server: https://discord.gg/mUaVASvG4z
Twitter: https://bit.ly/TwitterWMG
Instagram: https://bit.ly/InstaWMG
Our Games: https://bit.ly/ItchWMG

Text Editors: Atom: https://bit.ly/2WRikj8

โ–ถ Play video
magic nymph
#

I have a question regarding car key spawn. I'm looking at BaseVehicle.addKeyToWorld and I noticed that it has a keyIsOnDoor property that that has a chance to be set to true..

My question is: has anyone figured out how to get a key from door? It's not the ignition since there's a separate roll in that same method to place the key in ignition. I can post the relevant code if needed.

#

I'm pretty sure I've never once encountered a car with a key in the door, nor has an option to remove key (or similar) showed up in the context menu when right clicking on a car.

#

If someone has a clue, please @ me. Gotta go now, thanks in advance.

high citrus
#

hi, is there a way to display messages that will be visibile only by the client? I would like to display a local count down to the player

#

it needs to be well visible but it doesn't have to be huge

ancient grail
#

@magic nymph check out xyberviri's carwanna mod

ancient grail
high citrus
#

the login and then the client checking the remaining time trough EveryOneMinute

#

I would like to check the time trough the actual real world clock (since the time is expressed in real world seconds) but apparently I can't call any of the GameTime methods that returns the actual time

#

calling addLineChatElement on the player seems to produce text that is not visible by other players

hearty dew
#

Have to set ZoidUtils.ANSITerminal = true (and use an ANSI terminal) for the colorization

glacial flicker
#

Any way to change the water tiles properties so in winter they freeze?

#

or maybe a mod that does something similar

#

so I can check the ins and out

elfin stump
#

Is there an event that runs the first time a character is created for a specific username? Or, even better, is there a way to check how many characters that user has created at any given time?

stray yacht
#

Hey gang, I've got a new mod running flawlessly from my local workshop area but when I upload and run it from the steam mods folder, the debug log tells me it "NeedsUpdate" and failed to download. I've checked my own usual suspects for this but I'm stumped. Any ideas for things I should look at?

ancient grail
ancient grail
stray yacht
safe silo
#

I'm trying to place a world item that's drainable. Whenever I try to place it I get this error

attempted index: transferIfNeeded of non-table: null

LOG  : General     , 1666121110924> -----------------------------------------
STACK TRACE
-----------------------------------------
function: create -- file: ISPlace3DItemCursor.lua line # 29 | Vanilla
function: tryBuild -- file: ISBuildingObject.lua line # 202 | Vanilla
function: DoTileBuilding -- file: ISBuildingObject.lua line # 177 | Vanilla
gilded hawk
#

I'm wondering how can I make a class, instantiate it, and keep it as a singleton in zomboid?

I noticed that classes and initiation is quite non-standard in pz (from my past experience with lua) ๐Ÿค”

gilded hawk
hearty dew
#

Depends on your implementation of classes in lua, I suppose

#

But, maybe if you have some type,```lua
MyType = {}
function MyType:new()
end

you could have your singleton like so
```lua
MyType.instance = MyType:new()
function someOtherFunction()
  local foo = MyType.instance
end
gilded hawk
#

Alright, I'll give it a shoot, thank you tyrir

hearty dew
#

There's a lot of back and forth between java and lua for chat tabs. If the java side had exposed to lua the ChatTab and ChatManager classes, it'd be relatively straight forward to add a custom tab, but unfortunately those aren't exposed. So only way I see how to do it is to patch a number of lua functions in order to implement the behavior that ChatTab normally provides (or avoid the calls to the non-existent ChatTab).
focusOnTab
ISChat.addLineInChat
ISChat.onCommandEntered
probably a few more I haven't caught yet.

Something like this creates the tab on the lua side, but without those above functions patched, there will be errors due to the missing ChatTab backing the lua-side tab.

local myTabID = ZombRand(1000,2000)
table.insert(ISChat.allChatStreams, {name = "my custom chat", command = "/something ", shortCommand = "/smfn ", tabID = myTabID})
ISChat.onTabAdded("my tab title", myTabID - 1)
thorn bane
#

I will definitely look into this, thank you!

#

Thought that was the middle finger for a second lmfaooo

#

whats with tabID being random?

#

That's the only part I dont understand

hearty dew
#

for fun

thorn bane
#

Ah

hearty dew
#

to avoid selecting same id as other mods

thorn bane
#

Gotcha gotcha

blissful salmon
#

I'm still looking for a way to detect if a new zombie was created. I already tested a workaround by save all zombieId's I get from my current cell but this seems not right for me. Like I wrote some time ago I only found OnZombieUpdate or OnZombieDead but nothing like OnZombieCreated...

bronze yoke
#

there is no straight forward way of doing this

blissful salmon
#

ok. do you have a better workaround than mine? I realy not sure if my approach is a good one.

bronze yoke
#

i found a method that seems to perform fairly well, but i haven't tested it to an extent i'm comfortable with

thick karma
blissful salmon
bronze yoke
#

these are there for modders, the game doesn't call them

thick karma
#

Oh.... I saw Steps.lua calling createZombie and figured maybe it was used. Also saw createHorde get called somewhere

blissful salmon
#

Do I always get an OnZombieUpdate Event when a new zombie is spawnt?

thick karma
#

Oof

bronze yoke
#

the lua might use them in some situations, but primarily zombies are created from java

thick karma
blissful salmon
#

I can for example use the getModData on each zombie and set myzombiemoddate[mymod] = {}

bronze yoke
blissful salmon
#

I'll go with this and see how it performs...

thick karma
bronze yoke
#

i've got some code that seems to perform far far better than that, but i haven't tested that it definitely gets all zombies

blissful salmon
#

can you share your approach?

bronze yoke
#

i'll send it here in a bit

blissful salmon
#

ok thx

#

can you @ mention me when you do it so I don't miss it?

thick karma
#
local function OnZombieUpdate(zombie)

    if (zombie:getHoursSurvived() > 0) then return end
    
    -- Do stuff

end

Events.OnZombieUpdate.Add(OnZombieUpdate)

@blissful salmon This miiight work if the other method fails you. Not sure. Would be somewhat inefficient because zombies do a lot of thinking, but that comparison is pretty fast in the scheme of game logic.

#

May have to replace 0 with a sufficiently small float to catch the zombie's moment of creation

bronze yoke
#

you'd need to have some kind of check like that with my method too, my method just doesn't get called nearly as often as OnZombieUpdate

blissful salmon
thick karma
#

Good luck!

bronze yoke
#

further testing shows that my method doesn't really work LOL

rancid tendon
#

question

#

if i create and reference the same sandbox setting across 3 different mods, assuming they're set up exactly the same on each mod, will they merge and all reference the same single entry or will there be 3 separate entries?

#

i have a mod that consists of 3 sub-mods, and i want to introduce a sandbox setting that acts as a global modifier for all items of a type from each mod using just 1 sandbox setting var

bronze yoke
#

there might be some unforeseen weirdness, but i think they would just merge

blissful salmon
elfin stump
hearty dew
#

@elfin stump

summer rune
#

in the SandboxVars.lua there is a setting WorldItemRemovalList Description: A comma-separated list of item types that will be removed after HoursForWorldItemRemoval hours.
My question is, (1) if it will remove items that are "placed" on purpose on the ground. (2) and if it will remove spawned items by the game. Like items spawned on a desk in a room.

elfin stump
rancid tendon
#

i've had hats set to remove and people on servers will place their hats somewhere to display them and then they disappear anyway

#

dunno about the other part, though

summer rune
#

damn so no server clean up of dropped items. well

rancid tendon
#

also query:

        clip
        {
            file = media/yourMusic/TCBoombox/War - Magic Mountain (1970).ogg,
            distanceMax = 75 * SandboxVars.MFTEOTW.GlobalVolume,
        }```
#

does this look right?

#

i'm really inexperienced with this kinda stuff so i'm checking-- will that sandbox setting modify the variable properly?

bronze yoke
#

is this in a script file? i don't think you can do that

rancid tendon
#

aughhh yeah it is in a script file

#

i was kinda wondering about that

#

is there any way to modify that value using a sandbox var then?

blissful salmon
#

for testing purpose I manually create a zombie and set the walktype.
zombie:setWalkType("sprint1")
this seems to work as long I don't exit and restart the game. Isn't this value saved with the zombie? I used this since some days but today I noticed that they loose their running state. Do I need to do something in addition?

ancient grail
ancient grail
astral dune
#

where you can read/write to is sandboxed a bit. You have to get a filewriter/reader, which is either to the lua folder or to a particular mod's folder, not just anywhere in the file system that you'd like

blissful salmon
#

Maybe my question was not clear enougth. The zombie is still there but refuses to run. He is just walking.

ancient grail
#

yeh i wanted to make an array of items written on sandbox where the admins can just modify it and use the ; as delimiter the concat it

to return individual input we use ipars i guess

a good reference probably would be the item despawn. list

rancid tendon
#

does anyone know how to modify values in script files using sandbox settings?

#

if that's possible?

ancient grail
#

its just dbg on solo. its probably cuz theres bo chat panel.
which is why making a mod compatible for both is hard

.

glacial flicker
#

Heyo, to get the times for a bot, do we use the getYear, getMonth, getDay or was that changed?

blissful salmon
thick karma
safe silo
#

Can I have an item being just drainable?

Normally it'd be attached to DisplayCategory = LightSource or smth else but if I want a static item that takes batteries can I leave it as just Type = Drainable?

rancid tendon
#

again: does anyone know whether or not it's possible to modify script file values such as an item's weight using sandbox setting values?

visual abyss
#

alrighty girls and boys i'm back at it with the dumb context menu

#
local function testContext(player, context, worldObjects, test)
    if test then return; end

    local square = clickedSquare;
    print("square ("..square:getX()..","..square:getY()..")");

    local size = 0
    for _ in pairs(worldObjects) do size = size + 1; end
    print("worldObjects size: "..size);

    for k,v in pairs(worldObjects) do
        print("key: "..k);
        -- v is apparently IsoObject
        -- yet if i do v:getName(), it returns nil...
        print("------");
    end
end

Events.OnFillWorldObjectContextMenu.Add(testContext);
#

It seems that there's always at minimum 2 world objects on the square

#

I know square isn't being used past the print

vast nacelle
#

Where are you getting clickedSquare from? Is it a global variable set somewhere else?

visual abyss
#

yes

#

vanilla global

blissful salmon
visual abyss
#

:getName() will error

#

but yeah v is isoobject

#

as per your request with type(v)

#

but I used someone's library to actually print out the java class it uses

ruby urchin
visual abyss
#

well basically what I am trying to achieve: I wanted to place an object of some sort in the world that will act as a teleporter if the player used the context menu (i.e. rmb -> teleport)

#

I have an object placed in the worlded

#

unless i'm doing it the wrong way with the object stuff, idk how one would make it such a thing

blissful salmon
#

does everything return nil? also getObjectName()?
and can you still try it with the for i== loop? I'm not an expert in case of java and lua. but i think i had a case where pairs for me didnt work.

visual abyss
#

as per getObjectName:

blissful salmon
#

hmm... strange...

#

i checkt the java of the isoobject class... getName returns the string name which is null per default.
I don't know if there are cases in whitch the name is not set... so it returns null/nil.

#

is it the same for the second object so when you write:

  print(v:getName())

visual abyss
#

nope. it skips that

#

like i said, it just returns a nil for some godforsaken reason

blissful salmon
#

what happens when you check the objects on the square?
square:getObjects()

safe silo
#

recipes that require specific levels how would that work?

#

ie. Creating X item requires Carpentry 4

elfin stump
#

You can look in the zomboid folder at media/scripts/recipes.txt and search for "SkillRequired" to find examples of how it is done

safe silo
#

Thank you Phil โค๏ธ

elfin stump
#

np!

pine fiber
#

How can I insert the data in a table to obtain a table like that :
data = { a = 1, b = 2, c = 3 } with table.insert() ?
I tried table.insert(table, a, 1) and some other things, but nothing works...

hearty dew
#

data[a] = 1

#

table.insert works with arrays

pine fiber
#

ty @hearty dew

hearty dew
#

Could use table.insert to create a { 1 = a, 2 = b, 3 = c } table. Then afterwards, from it create a new table with the key/values reversed, if you're keen on use table.insert :)

#
Padd_Utils = Padd_Utils or {}
Padd_Utils.createIndex = function(t)
    local index = {}
    for name, value in pairs(t) do
        index[value] = name
    end
    return index
end
pine fiber
#

If I want to create a list of objects with their number of occurrence (which increments) what do you advise me? like
table = { apple = 2, berries = 18 ... }

hearty dew
#
local food_counts = {
  apples = 0,
  berries = 0,
}

food_counts.apples = food_counts.apples + 1

Would that work?

#

If you don't know them ahead of time,```lua
local food_counts = {}

local fruit = "apples"
if not food_counts[fruit] then
food_counts[fruit] = 0
end
food_counts[fruit = food_counts[fruit] + 1

#

Or could do something fancy with __index in its metatable to avoid the conditional, I suppose

pine fiber
#

It works like a charm ! ty like ever @hearty dew

#

If it could help someone โคต๏ธ

glacial flicker
#

Can anyone link a mod that affects the map tiles in real time?

#

Or anyone knows what functions triggers when something burns? Like grass turns into burnt grass

thorn bane
trail lotus
#

hey guys. I tried redefining and creating a whole new playstyle in pz a couple months ago, development slowed down and people vocally showed quite a bit of support and were quite sad development slowed. with that being said there motivation has made me wanna pick back up the pace get back into trying to develop this server, I'm mainly looking for skilled developers that have a interest in the playstyle we are trying to create, and have a good idea at what we are going for.. I have a large community of people ready to voice their opinion and I want nothing more then to build it the way I promised and how they ultimately wanted it. with that being said if you are interested in supporting or taking a role in the development please dm me and ill get with you. it can be small artwork to massive server changing mods I'd love to pay you for your time and contribution! I want to remodel how the dev team will work this time and create a work area people can be assigned to and work on projects as well as help each other. I think this will allow me to better compensate people for their time and work.

bronze yoke
#

what is this playstyle though?

trail lotus
# bronze yoke what is this playstyle though?

city life rp, it would greatly resemble a gta5rp server but more realistic and not so chaotic obviously. this playstyle contains no zombies meaning all interaction is player orientated.

bronze yoke
#

i'll have a look!

trail lotus
#

just dm and i can get you a disc invite i dont wanna get in trouble posting it here ๐Ÿ™‚

oak oasis
#

@weak sierra i have something I want to ask you personally pls check dm

ancient grail
ancient grail
ancient grail