#mod_development
1 messages ยท Page 37 of 1
New mod incoming!
Omfg
I can't believe it finally worked
COmmand seems so obvious but I tried so many variations that failed me
hell yeah
Ahhhh so excited for this one
count me in
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?
Maybe something simple and direct like No More Annoying Popups (Controller)
Btw there's no toggle UI keybind for controller?
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
Actually allows keyboarders to also close inventory on aiming
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.
Awesome ๐ฎ
I'll create a little server to make it easier to collaborate with whoever is interested, i'll DM a link ๐
Hmm, Hide UI Windows During Combat (Controller) then? ๐
that sounds good ๐
Ah I see, no wonder you had to take measures
Doesn't really hide entire UI, doesn't only apply to controller.
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.
Okay, Combat Stance Closes Windows
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
Could use mod options for that and leave it disabled by default
Some mods adds their keys to default key meny
Or make it an option in the context menu/right click like how Tidy Up Meister does it
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.
Yeah that's how it works
yeah no worries, I don't need custom button configs in my mod
Which is a good thing because every player can enable it or disable it if they want
Just more work xD
Right but it disables or enables for everyone
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
His warning is more for stuff like tweaking the percentages/frequencies of something occuring or spawning i think, yeah
I get it now.
'Combat Focus'?
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
Server-client commands? I have some functions in my library that simplify them to one api call, if it'd be any help
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
Ah, okay ๐
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)
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
Grats ๐
Hmmmm how about Clear for Combat? Anyone hate it? Like it?
It's not very descriptive
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...
Could be 4 words ๐คฃ
But I would love a more accurate title <= 3 words if possible
What 4 words?
It closes many things when I aim
Something like the one I suggested earlier
What 4 words would accurately describe what closes
And when it happens?
I responded to that
this, right?
For sure, but this begs the questions, "Which windows?"
Combat Closes Windows? If you wanna leave out the stances part
Does not currently close all your windows
Title would suggest it does
Problems with everything ๐ฆ
Well it doesn't need to be that specific, they can check the mod page for that
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.
Yes but Clear for Combat tells a person nothing haha
True enough. But the fact that it's tagged as a UI mod might give context that gives a good hint.
People rarely look at tags tho
"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
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.
That would be nice too ๐
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
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
Yeah yeah, go for it then ๐ ๐
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?
You could send the quit command to the stdin of the server process to make it shutdown normally
There is some parameters in servertest.ini config file you could maybe use :
BackupsOnStart=true
BackupsPeriod=20
SaveWorldEveryMinutes=15
does it save the game world? core.quit()
quit saves the world prior to shutting down
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
we have this:
SaveWorldEveryMinutes=15
BackupsCount=5
BackupsOnStart=true
BackupsOnVersionChange=true
BackupsPeriod=0
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
i have no access to the terminal nor the reboot script sadly
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
Maybe try contacting gportal's cust support about the issue?
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 ...
i will if i have no possibility to fix it myself. but since they are a popular host, i thought maybe someone else hat this problem and found a solution
You might try a mod that calls Core.quit() to see if that works. That might do what you want
okay thanks all. I will try those things. i will keep u posted.
what i did was i have a scheduled task on windows that sends save nd server msg 5 mins before restart.its thru rcon
If it's not working, u could try to set restarts just after a SaveWorldEveryMinutes. And maybe modify this :
BackupsPeriod=0
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
smart idea ๐
but with gportal, could we use a rcon connection ?
that is a interesting and smart solution, however i have no windows server or pc running 24/7. but thanks a lot anyway ๐
yes
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
damn, so no save as it looks like. hmm
maybe there's a save method on Core. Let me check that
not sure if it requires client admin tho
You'd need an admin client to issue those, perhaps
servermsg doesnt work. but you can try
cant the server send a sendcommandtoserver
ah then your screwed
hm
frustrated abt this too. but yeah it cant . or porbably can but not just all
Don't see anything on Core
anyone?
I'll try sending save and quit from the server itself
No, idea, but I'd suspect that in the rendering code java-side
you might want to look at the script where it does the /save
so it might not be moddable?
If my assumption is correct, that probably be difficult to mod
is there a shadow texture file? i dont think there is ... hmmmmm
SendCommandToServer() when called on the server-side causes and exception bc it expects to be called from the client-side
thanks for trying. thanks a lot ๐ฅ
GameClient.connection is null
@summer rune On GlobalObject, there is save(boolean) and saveGame()
At least it saves the GlobalModData heh
i have access to these files by FTP. maybe some ideas here?
@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
sorry, to ask this of you. but can u find out how often this snippet is called from java? so if i change the serveroption to 1min will it be called in the next 2 minutes, even if it was 15min before?
It's called in the server's main loop
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
This works. It saved immediately when I set it to 1
ServerOptions.instance:getOptionByName("SaveWorldEveryMinutes"):setValue(1))
very much appreciated!
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 
Morning brain fixes what tired brain couldn't.
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.
i think theres a mod utilitity for this
u just have to find it. as i forgot what its called but ill help u search now
Okay, I'll look as well. Appreciate it.
Is there a way to restart the items distribution on the map directly in-game without restarting a new game?
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?
I heard of Itempicker initSandboxLootSettings but I haven't seen what it does yet. Also it was said not to use on running game.
Update something about ItempickerJava.Parse() from that post
Great!
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?
Haha, thank you very much ๐
Or maybe turn off cursor in Debug Console anybody? I have found a way to escape focus...
Is there a way to modify the weightChance=40 parameter of a Distributions list ?
If it's a part of the list you can just redefine it.
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.
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.
I'm not sure if the OBSOLETE tag exists for recipes but I can imagine setting this to true on the recipe object should hide it?
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
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
Thx for the quick answer. I think setIsHidden(boolean hide) should do the hiding thing. I just looking for a way to group some items together. Which is not the category where it appears.
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.
just iterate table of items
What excatly do you mean with a sub-mod?
I'm not at pc rn but as I remember mod hierarchy
Mod/
..Content/
....Mod1/media..
....Mod2/media..
Oh you're trying to make a specific tab for recipes? Hmmm
it will single mod but in mods list will a few mods
so u can disable any that u want separately
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.
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.
Hi, do you know how to get username from an isoPlayer Object ?
local playerObj = getPlayer(); print(playerObj.getUsername());
It throw error
Use : not .
If your recipes have an unique module you can use that
why he need to check mod ids?
disabled sub-mod even won't load scripts for recipes
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
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
Anyone know how to send a mouse click signal to an arbitrary X, Y? Is that possible from the Lua?
Ah yes... This should to the trick... I can split them up like that.
via lua no
u have to put that on the oncreatefunction
it will still show that you are able to do the recipe tho.so you should give back the stuff of ever its turned off. not sure if its posible to put it ontest function but might worth a shot to try this
let me know if it works pls ty
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 ๐
You can add an ontest on the fly, just a fyi
No but it sounds like you want something specific that may be still achievable. What is your actual need?
ithink its
print(getPlayer():getUsername())
im not pc right now so i cant check
It is, calling function/method that is exposed is always:afaik. Variables are ..
When I close the Debug menu using UIManager:getDebugConsole():setVisible(false), it doesn't stop focusing on that box. I want to be able to break focus when I hide the Debug like that.
Is it possible to get what gets said in a certain radio channel?
Try calling debug windows' close buttons' click then
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.
Should handle what you need
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...
I am having trouble finding where that close button click gets handled unfortunately
Look in recipes.txt then search the lua source files for that function
It would be inherited from general UI
I have a mod question; If i have a mod like bushcraft, do my friends need it to play in my world?
okay
ty
ah thanks... I remember now that I already saw them. Do I use the ontest to return if it's doable?
Check where debug UI is initiated - it is probably an ISPanel (I'm not at my PC atm) but ISPanel are generated with a new() and are given buttons, topbars, etc. It should be stored as a variable.
So if you know how to call on the debug window you should be able to do something like debugWindow.close:click()
i havent messed with it but if i recall, it checks if its valid to create or not. a function that can check for more specific conditions that scripts cant give
so it would return a bool
oncreate just does stuff that you'd want if the craft was successful
I'll test it... So far I think all the inputs helps me...
OnTest is a string equal to the name of a lua function. If you use getScriptManager you can parse through all recipes and check their names, modules, etc what ever you want. You can even set a new OnTest.
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.
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
was about to ask if I can pass a parameter or if I have to do multiple functions.
Unfortunately debug window does not have a close function that works afaik in Lua.
Afaik it's one function per Lua parameter
UIManager:getDebugConsole() <- this is the debug console
but I think this is also a good solution.
UIManager:getDebugConsole().close:click() <- nada
UIManager:getDebugConsole().close() <- nada
UIManager:getDebugConsole():close() <- nada
That's Java exposure stuff - the UI is entirely Lua
UIManager:getDebugConsole():close():click() <- nada
Find the Lua pseudo-objects
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
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
I did this. The close function for ISPanel does not apply to this object.
But that is it the debug console is an ISPanel
How would I get the ISPanel version of the debug object that has access to close?
Most UI has an instance set for clients
I only have a UIDebugConsole object
I can get an instance of debug console, it just doesn't come back as an ISPanel
What is it's type then?
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
That sounds like the java half of stuff
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
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
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
sorry the question doesn't make sense..
if u have a mod then your friend will play? i think this is subjective
Okay so I dont have the game yet so i dont know how joining worlds works
Where is ISDebugSubPanelBase housed?
is it simular to minecraft in the way that someone makes their wolrd multiplayer and they join that way?
ISDebugPanel is nil in the console
There is actually a file for this
dm it might be easier to explain to me lol
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
This was a dead end, close function doesn't do what is needed
ISGeneralDebug ?
Nah
I think generalDebug is still one of the subtabs
Wish the Lua was online, but can't help much more
Did you try
:setVisible(false)
Yes thank you @fast galleon
Not adequate
Trying to lose the focus
Not just hide it
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
TwoHandWeapon = TRUE,
RequiresEquippedBothHands = TRUE, if it needs to be held in 2 hands
UIDebugConsole is in java
lmao thank you
btw not sure what you mean focus, but I added that to every ten minutes and after it's gone I can use keyboard again
He's on controller
The keyboard focus is actually what gets trapped @fast galleon @sour island . If you use that hide function while inside of the Lua Debug Console, you will not be able to press any keyboard buttons until you click once on something else or the background
My joypad focus is coming free just fine
Have you tried removing it from UI manager?
resolved
I mean then I would have to reinitialize it entirely because removing it is not its natural behavior
Also could cause other issues
Most UI gets removed on closure - from what I've seen
If it expects that debugger to exist
If you don't figure it out, ping me in like 7 hours
Cool thanks
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
I should upload the Lua as a hidden repo
No worries, wish I could be more help. I'll give it a shot once I'm home.
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)
Using the scripts format probably not I would guess
You could parse through all recipes in Lua though
would you happen to know how?
I've been wanting to do that but couldn't really find any snippets to help do that
getScriptManager() returns the object that controls alot of that stuff
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)
Recipes being able to share exact names actually always bothered me
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
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?
make sure you do not use the same names as files that already exist in the same file path because you will overwrite vanilla/other mod files
typically add your mod id to the front of the file name so mymodid_recipes.txt
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?
The scriptManager is what parses the scripts on run. You can use some exposed methods (Java functions) to change them as you need.
You can do this with any script: vehicles, items, 3D models, just depends on how much of it is exposed.
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
The get all recipes method/function returns an array (Java)
right
nvm I think got this
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)
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 = {}```
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.
Looks more complicated than it is
I'm new to coding haha
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.
There's one in client and one in server
In vanilla?
Yes!
Are they identical?
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
trying to understand how it is being saved. doParam()?
require "\media\lua\server\recipes.lua after server"
Like that?
Anything with local infront will have to be copied
No
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.
hi, a quick question, is possible to send the "quit" msg to the console using a mod?
DoParam() is setting the parameter for the item script object -- but recipe objects have their own methods.
Check the "recipe.class"
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
Alot of base mechanics are very hard typed -- as in you can probably add another type of oven but not really a generic heater. It might still be possible but you'll have to basically write the foundation yourself.
Nice weighting ๐
i already implemented my own weight function but thank you. I'll check if it's better than mine.
Oh okay.. Just found AddHeatSource and expected to just use that
declaration: package: zombie.iso, class: IsoHeatSource
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.
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
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.
getCell()
@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...
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)
Oh, I wasn't aware there was an object for it - might be much easier to do.
I know this might be a lot to ask but would you be up for helping me a bit with it? I'd gladly pay you.
Not home at the moment - if I have some time I'll poke around
Thank you!
@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
@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.
I don't think it has a general doParam. But modifying the object should change the recipe.
Thanks for the heads up ๐
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 ๐
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
Should work but this would hide all recipes
If you know of a way to add markers from a given set if coords, I could use that
I think that sounds awesome.
Well, I guess it's time to code
I wanted to add map markers or such for EHE but when they first released it was a bit hard to decipher it
EHE? ๐ค
Bonus points if I can draw a large circle of about 50ish squares
Expanded Heli Events
This is just to see if it works but it doesn't seem to work. - don't worry, i have it running on gamestart hook
oh, I remembered that I need to try that mod at some point
Too bad that i'm spending more time coding than playing ๐ฅด
First mod makes the game crash in menu, wholesome
turns out that having the crafting ui open when loading is old. refreshing window works. however it crashes when i open it ๐ค
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")
@sour island I think you know this, do we have a vanilla way to print LUA tables in the console.txt?
length of the string? string.len( string ) == # ?
Length of the array, my bad
#array
:Size() if it's a java array list
It isn't, wish it was that easy
Typing print(#getPlayer():getInventory():getItemsFromFullType("Radio.RadioMakeShift")) throws me an error when I type it into the command console
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)
Oh, I see what I did wrong
You typed "Size()" and not "size()"
Aren't typos a wonderful thing :v
death by casing

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 ๐
lmaooo
ouch
@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
My game locks up every time I try to load my mod and I can't figure out why. 
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?
like you can equip it in more than one slot?
"RecipeManager.resolveItemModuleDotType> WARNING: module "Base" may have forgot to import module Base"
But I have it?? I think?
imports {
Base
}
recipe Scrap Log
{```
More like, to have only one of the same item at the same time, not through weight limitation, and stop player form throwing it away.
Was trying to make a orifice mouth mod
hells yeah! great work sempai
on this i would avoid using the module "base" because "Base" is a vanilla one, you should probably change that to something like :
module MyModId {
imports
{
Base
}
}
Or just use Base and dont bother with the import
sorry to tag u but @bronze yoke have a look at this.
his trying to make vanila vehicles all have upgrades and i mentioned the paint thing aswell .
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
You're a life saver, thank you so so much
painting vehicles works fine (i assume, i've never tested it) but i don't think painting parts is possible at all
vehicles parts all use the same color
that's what glytch3r was asking me about painting before, i think
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.
anyone got an example of ArrayList.removeIf() in lua
I can't seem to get it to work
Anyone happen to know where exactly the game draws your perk level-up info off the top of your head?
First time ever working with code, and my first Zomboid mod! Or at least part of it. Lol. I'm used to working with Halo so this was really fun.
Anyone know how to add a new tab to the Chat?
congrats
losing my mind over how to add a tab
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
ISChat.allChatStreams[7] = {name = "admin", command = "/admin ", shortCommand = "/a ", tabID = 2};
Look around there
@hearty dew I'm basing my code from ISChat, but I can't seem to figure out ISChatcreateTab
I've already got my own one sorted, but it doesn't appear
-- 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
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
I don't see this even in the documentation :/
Give me a sec
@bronze yoke Came up empty handed. Maybe I didn't implement it correctly
Nope, still no luck ๐
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
would anyone like to help me get started with my first mod?
What's your idea?
I wanna make a media player basically
Tasks are usually client-side, so it'd be difficult to pull off
Media player as innnnnn?
like an in game ui screen that you can watch or listen to content on
I don't think the game even supports getting any information from the web
Still need help with this btw ;v;
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?
If you search my messages I probably pasted it
Yep I found it ๐
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?
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)
I'm under the impression that green outline means guaranteed hit
Any modder out there willing to help a newbie out? I have a couple of ideas but lack knowledge on how to apply them
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"
So I can set it to "Normal"?
Alright. What about the template for different DisplayName, Icon etc?
what do you mean?
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?
is there a table somewhere with all the loot distribution tags?
Like would this be sufficient?
item ElectricHeater
{
Type = Normal,
Weight = 2.4,
Icon = ElectricHeater,
DisplayName = Electric Heater,
WorldStaticModel = ElectricHeaterModel,
}
sweet, thanks!
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
Oh damn lol, ty!
i dont have worldstaticmodel cause it'll never be used in the world
How would I print stuff to the console if I'm in debug mode from my LUA?
Is it just print("hello world")?
yes
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?
yeah
So getType is the same as getName? Or is getType safe for if players would be able to change the name
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
Ohhhhh sweet! thanks
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,
}
amm what about the item's module?
what if we have Test.Apple
Stuff.Apple
and then the vanilla
Base.Apple
what if we have similar names just diffrent module . can we use ```if getType()==Base.Apple?
Can you isolate vehicle mechanics and add them to a tile?
I want to have garbage containers have 2 seats to hide in it
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?
getFullType() includes the module
worldstaticmodel is for 3d models
otherwise it just shows the icon
you can use item:isVanilla() to see if its a vanilla item, the modid item:getModID() == "pz-vanilla" also
Is it possible to have normal world item and add a function to it so it can open a menu with battery in it?
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?
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
yes. from any category actually
what isnit that you want to do
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.
u want the recipe to consume 5berries?
then just use
Base.Berries=5,
as I described it. more precisely, I want the player be able to make fruit jams from foraged berries.
im not sure cuz im a n00b but i think you might want to take a look at derive
Derive?
hmmm... but this will the player only allow to use 5 berries with the script ID "Base.Berries", wouldn't it? I want the player to be able to use and mix different types of berries for the recipe.
as I wrote 5 Base.BerryBlue should work but also 3 Base.BerryBlue + 2 Base.BerryGeneric1 as well...
Sorry for the ping, but what's Derive?
look for lua inherit or derive
i havent played with it but i think this is what you need
do you have a list of all the beries?
Hmmm, I don't think that'd be the answer, but I'll take a peep none-the-less
I think I misunderstood which window was the debug console - if you meant the window titled command console - have you tried -- lua UIManager:getDebugConsole():ButtonClicked("close")
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
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;
}
}
wow if this works the can you also do this for the database panel and make em functions?
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?
cuz derive is like using a class and sorta cloning it to be able to get what it has withiut redoing the entire lua
and you get to add more functions
if im not mistaken. i just watched a video abt this yesterday... hehe
yeah the admin panel has database
I wouldn't have a clue. If you could send the video that'd be fantastic
where you can log users add remove users see ban ids etc
Creating OOP, Classes and Objects in Lua
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
and you want that to be closed?
no. to do function commands to do what the buttons do without clicking it
like adding users automatically
lua/client/ISUI/AdminPanel/ISWhitelistViewer.lua
without a client admin
a lua function that auto does this sendcommandtoserver doesnt work since it reqiore admin
yep there are 3 files
@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?
Not personally no
Damb ๐
you'd have to look through the UI code
I have, I've had no luck
I can get another chat tab, but it's a duplicate of the General tab
can we see the code you did that created the other general tab u mentioned? and may i ask what your goal is
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);
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
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
It is an exact copy and paste, yes
Nothing's changed
Between the debug console, window, and menu, idk htf anyone keeps it all straight ๐ But I am trying this command now and if it works I need to send you a coffee
I did not know how to send click commands to that exit button and if it's THIS easy omfg thank god
goodluck
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
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
@sour island ๐ญ it works the same as setVisible, which is unfortunately not a good thing
ouch
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
try changing it into your own code
ISChat2.onTabAdded = function(tabTitle , tabID)
I do not want users to have to figure out A
for example
Would I change all of the ISChat's or just that one?
change all. you dont want the game to be calling 2 global functions that does the same thing
I don't understand what this means
wait sorry just read the script and this is the one that inserts all the avilable chats
this wont work i think @thorn bane
Yeaah
sorry tagged the wrong person
Like I said, clueless ;v;
What if you call mouseup?
@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
I'll give it a crack, one second
Still throws an error, chat doesn't display
Give me a moment
yes. one option would be to make the recipe for each combination of berries. but the pz wiki says there are 8 types of berries (in fact, I think there are even more and wiki is a bit outdated). so this would result in at least 8^5=32768 combinations...
but I think I give up the plan of allowing the player to mix different berries and go another way...
what? no its just berry lines x5
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
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
ah ok... I misunderstood then. I'll give it a try then. thanks!
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
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
No one has any bright ideas for triggering a mouse click event do they?
can weapon not have more than 1 compatible clips/mags?
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
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?
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.
But the problem is I got the level 100 from a variable called level that comes in when you AddXP. I assumed level corresponded to perk level as it does with LevelPerk, but that apparently is not the case.
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
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.
no if u level it up theres no exp gain
meaning if u use skillrecoveryjournal the lvl u gained from that wont count hence wont be written
He's talking about the lua event 'AddXP' which does actually call the amount of XP being added 'level'.
I'd say that's on TIS for betraying expectations with a bad variable name.
Yes I have that
that's what confused me so much
Thanks for clarifying
Still lost on this fwiw
I'm referring to the AddXP function in which there is a Level variable used to apparently represent XP gain
try sending it from client to server?
ye i eventually got it.. i mean name scheme right? who needs it? devs: ah lets not make sense to prevent modders from doing great mods ๐
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
like OnClientCommand i think
like a server file has listener and client file has arg to send to server
yeah i was jk
they put notes on the lua files so that counts as something right. and they dont just delete the parts they change they comment it out
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
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
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
Zombies can hear/see you, so that's kinda dumb. The Aiming idea doesn't sounds that bad but it would create conflicts with other gun mods.
mod where zombies can smell you based on your body dirt
i will await the release ๐คฃ
There are potentially some weapon properties such a mod could use to cue off of when reclassifying, such as weaponReloadType. If not, support patches.
The bigger issue is that there is far too much involving the Aiming skill on the Java side of the code for any such mod to really work without getting into janky workarounds.
But I do wish for a breakdown of the Aiming skill.
mod where having too many things/bodies on the ground will trip the player more often
my girlfriend was discussing the potential mechanics of a random tripping mod earlier
yeah i think that aiming thing is cool and does make sense as well
great minds think alike
sounds like hell
maybe for april fools...
Do you mean player tripping? Cause we've already got the zombie tripping one. If so, hold up there, Satan.
yeah player tripping
is the isosquare:getCanSee(int) reliable? Seems to work on SP so far.
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
Thank you, forgot about that one. What makes it better?
Nothing special, just the pythagorean theorem math.sqrt((x2-x1)^2 + (y2-y1)^2)
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
I don't care much about accuracy, I just want to know if the player can see a moveable and how close he is. So now I check square:getCanSee and call the isoutils distancemanhatten directly.
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
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
I also take the opportunity to share this addon for VSC which also allows to generate a complete tree structure (folders + files + possible variables). Really useful!
https://marketplace.visualstudio.com/items?itemName=Huuums.vscode-fast-folder-structure
The code that calculates what to do when zombies hit a player is for sure in java. Players hitting one another is probably around the same code
.
I'd check in ProjectZomboid/zombie/characters/BodyDamage/BodyDamage.class
Almost all of the debug console is in java afaik
---------- 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
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)
Once again asking back here, but does anyone know how to make another tab in the Chat UI?
I might look at it today. There was something I wanted to do by adding an extra chat tab or window
if you find out how to, please let me know. I've been struggling for the past day ;v;
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
you check the logger for teleport
I don't think I have the skills to help you with that either, but good idea!
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
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
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?
Hmm, it shouldn't be. Hopefully the java side isn't inserting nulls into arrays, at least
What's the error message?
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);
yea, it seems some of those objects you are inspecting return nil from getName()
is it possible to print just obj?
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
too big to paste ๐ฎ
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
Are you trying get IsoPlayer or something like that?
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
freaking love this
let me try this in the vanilla map
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);
just change getMovingObjets for getObjects
whats the difference between those 2
IIRC getMovingObjects get Players, NPC and things like that, and getObjects Items ground, sprites, etc, basically static things
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.
the pinned messages
is everything written in LUA, or are there alternatives?
nice, thank you
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
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 ๐คท
i'll take a look at it later. my brain needs a break.
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)```
If player?
Makes sure player object exists to prevent exceptions when player is dead and such
Works in all my mods, shouldn't be the issue
It's just I don't see where it's defined
Happens
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 ๐
I do, but it's no worries
This is why I use intellij and am very suspicious of purple colored variables, lol
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
Is there a way to detect if a new zombie was created? In the event list I only found OnZombieUpdate or OnZombieDead.
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.
It should be Tailoring from what I'm looking at
tyvm ๐
np
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
- [Music] - Daniel Docherty https://www.danieldocher...
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.
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
@magic nymph check out xyberviri's carwanna mod
what is the event that creates the countdown?
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
@visual abyss
Have to set ZoidUtils.ANSITerminal = true (and use an ANSI terminal) for the colorization
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
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?
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?
u can nake a mod that writes to a file after you click the button on the character creation
then just show how many times on on the stats panel i guess . goodluck
you can get real world time
try to look at konijimas world clock mod
thanks
havent encountered this
You might have a look at AquaStar Yacht Club to see how they handled moving on water
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
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) ๐ค
a java class?
A Lua class
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
Alright, I'll give it a shoot, thank you tyrir
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)
๐
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
for fun
Ah
to avoid selecting same id as other mods
Gotcha gotcha
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...
there is no straight forward way of doing this
ok. do you have a better workaround than mine? I realy not sure if my approach is a good one.
i found a method that seems to perform fairly well, but i haven't tested it to an extent i'm comfortable with
There are several functions you might try decorating in the GlobalObject. Specifically, createHorde variations and createZombie look promising.
Thx for the answer. But how can I decorate this functions and how exactly can this help me? I think I don't understand your idea correctly.
these are there for modders, the game doesn't call them
Oh.... I saw Steps.lua calling createZombie and figured maybe it was used. Also saw createHorde get called somewhere
Do I always get an OnZombieUpdate Event when a new zombie is spawnt?
Oof
the lua might use them in some situations, but primarily zombies are created from java
If you do, you could try checking zombie:getHoursSurvived() to make sure it's still 0
I can for example use the getModData on each zombie and set myzombiemoddate[mymod] = {}
yeah, this event is called every frame (or something like that) per zombie
I'll go with this and see how it performs...
(Presumably this would only be true once or very briefly.)
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
can you share your approach?
i'll send it here in a bit
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
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
Thx. This is very similar to my check of the moddata. But may be a bit more perfomant.
Good luck!
further testing shows that my method doesn't really work LOL
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
there might be some unforeseen weirdness, but i think they would just merge
unlucky ๐ฆ
Do we have any way to do file i/o? I thought that was disabled in the PZ lua but maybe there is another method?
@elfin stump
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.
Awesome thanks
placing an item is the same as dropping it functionally, except that you get more control over where it appears. a dropped item is no different than a placed item for the purposes of that field
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
damn so no server clean up of dropped items. well
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?
is this in a script file? i don't think you can do that
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?
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?
check out the statistics on the admin panel . it shows how many zeds there are
there is . readfile and write file
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
And what do I look for or do with this value? Is it also in the debug menu? I test most of the things in solo mode. But I never figured out how to get the Admin panel in Solo mode.
Maybe my question was not clear enougth. The zombie is still there but refuses to run. He is just walking.
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
u cant
does anyone know how to modify values in script files using sandbox settings?
if that's possible?
its just dbg on solo. its probably cuz theres bo chat panel.
which is why making a mod compatible for both is hard
.
Heyo, to get the times for a bot, do we use the getYear, getMonth, getDay or was that changed?
But do you have a clue how I can figure out why the zombie is just walking after a stop and start of the game? The amount of zeds shouldn't be that important for that. Or am I missing something?
Sounds like that particular state is not recovered from any saved info about zombies. Perhaps a different function is responsible for loading an existing zombie's details when it is spawned. Could even be that the zombie is making decisions based on its Lua states but saves and loads from a separate set of Java states that you're not accessibg
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?
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?
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
Where are you getting clickedSquare from? Is it a global variable set somewhere else?
can you print the type?
type(v)
or did you try to iterate with a for i loop?
worldObjects:get(i):getName()
: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
What you waiting get exactly?
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
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.
as per getObjectName:
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())
what happens when you check the objects on the square?
square:getObjects()
recipes that require specific levels how would that work?
ie. Creating X item requires Carpentry 4
when you create the recipe include the line "SkillRequired:Carpentry=4," I think
You can look in the zomboid folder at media/scripts/recipes.txt and search for "SkillRequired" to find examples of how it is done
Thank you Phil โค๏ธ
np!
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...
ty @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
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 ... }
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
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
By the way Tyrir, I tried this, and my miniscule brain hasn't got it sorted out. I'll probably rewrite the code tomorrow, it's all spaghetti atm.
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.
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.
https://www.kentuckyroleplay.com/ that is my website ๐
We are a hyper realistic roleplay community in developement on Project zomboid!
i'll have a look!
just dm and i can get you a disc invite i dont wanna get in trouble posting it here ๐
@weak sierra i have something I want to ask you personally pls check dm
try moving objects instead
you might want to write it on a file then read it to get the data back.. else you will lose the population youve counted i guess..
u might want to do this modular
first create a function that counts(btw u can use onload chunks perhaps)
then make the write script should be client to server
then the read. tho im not sure who u would want to gove this data too
sorry havent found anything that looks like this. tho u might want to try looking at itemtweaker and somehow apply it to whaat ur trying to build
goodluck