#mod_development
1 messages Β· Page 530 of 1
yeah but there is like 2 sort of table, key table and index table and mixed (which become like a key table in reality)
this is why we have pairs() for looping key table and #table to loop indexes table
#keyTable wouldnt work
your updated post up there should be good now lets just see what happen with that mixed procedural thingy
Honestly just want to know if the apple drops often and the procedural item
Cuz if you get apple & the procList item, then mixed works
I haven't been able to find the java stuff yet
otherwise I'd have looked at it already
π
I think you have to find a rar file or something and export it
But I never bothered
from my understanding, if rolls is found it will completly ignore your procedural stuff
Hmm. So you're saying, we would have to edit it in postMerge?
By taking the entirety of inventoryMale, make a procList out of it
Add it into proclist, clear inventorymale and add procedural=true, add our proclist and inventorymale that we jsut made?
yeah
or just set rolls to nil
it will go to procedural automatically
private static void ParseSuburbsDistributions() {
KahluaTableImpl var0 = (KahluaTableImpl)LuaManager.env.rawget("SuburbsDistributions");
Iterator var1 = var0.delegate.entrySet().iterator();
while(true) {
label57:
while(var1.hasNext()) {
Entry var2 = (Entry)var1.next();
String var3 = var2.getKey().toString();
KahluaTableImpl var4 = (KahluaTableImpl)var2.getValue();
if (var4.delegate.containsKey("rolls")) {
ItemPickerJava.ItemPickerContainer var12 = ExtractContainersFromLua(var4);
containers.put(var3, var12);
} else {
ItemPickerJava.ItemPickerRoom var5 = new ItemPickerJava.ItemPickerRoom();
rooms.put(var3, var5);
Iterator var6 = var4.delegate.entrySet().iterator();
while(true) {
while(true) {
if (!var6.hasNext()) {
continue label57;
}
Entry var7 = (Entry)var6.next();
String var8 = var7.getKey().toString();
if (var7.getValue() instanceof Double) {
var5.fillRand = ((Double)var7.getValue()).intValue();
} else if ("isShop".equals(var8)) {
var5.isShop = (Boolean)var7.getValue();
} else {
KahluaTableImpl var9 = null;
try {
var9 = (KahluaTableImpl)var7.getValue();
} catch (Exception var11) {
var11.printStackTrace();
}
if (var9.delegate.containsKey("procedural") || !var8.isEmpty() && var9.delegate.containsKey("rolls") && var9.delegate.containsKey("items")) {
ItemPickerJava.ItemPickerContainer var10 = ExtractContainersFromLua(var9);
var5.Containers.put(var8, var10);
} else {
DebugLog.log("ERROR: SuburbsDistributions[\"" + var3 + "\"] is broken");
}
}
}
}
}
}
return;
}
}
well its an iterator, its analyze each entry and goes deeper
on the highest level its analyzing if it find rolls it handle it as a regular distribution table.
if not then it try to analyze deeper and find for the isShop or procedural field
local function ProceduralZombieLoot()
-- get inventoryMale/female
local maleInv = Distributions.all.inventorymale
local femInv = Distributions.all.inventoryfemale
-- extract roll&items into a Procedural gen
ProceduralDistributions.list.inventorymale = {
rolls=maleInv.rolls,
items=maleInv.items
}
ProceduralDistributions.list.inventorfemale = {
rolls=maleInv.rolls,
items=maleInv.items
}
table.insert(maleInv.ProcList, {name="inventorymale", min=1,max=1,weightChance=100})
table.insert(maleInv.ProcList, {name="inventoryfemale", min=1,max=1,weightChance=100})
maleInv.rolls = nil
femInv.rolls = nil
-- done?
end
Events.OnPostMerge.Add(ProceduralZombieLoot)
Some bullshit liek that lol
forgot the nil
The ProcList should already exist from merging the tables
so just have to add the procedurally generated inventorymale
by the way you can also just access those inner table like this local maleInv = Distributions.all.inventorymale
hmm that looks better
oh damn i just realize that all.inventorymale is where the zombie loot is defined xD
Yeah its the random shit zombies have on them, except for their outfit loot
right
Honestly making a utility mod with just that postmerge thing might be useful haha
Allowing people to add ProcLists to zombies
& mods that edit the default list would still work with it
now for the event stuff
there is really not much happening there xD
they all triggered one after the other
So that mean you can do anything to them before they get picked up by the next line which start parsing them
yeah i was expecting something else, but i see why now
The default suburbsdist does nothing on pre
the mixup of java and lua is confusing sometime
it does all the work in merge
Then it calls post
which the defauilt thing does nothing in, again
It used to remove Razors lol
probably as a test
local function postDistributionMerge()
--RemoveItemFromDistribution(SuburbsDistributions, "Razor")
--DeepPrintDistributionTable(SuburbsDistributions,"")
end
Razors matter
It removed all razors lmao
pretty cool
I assume that's what it would usually be used for
However, we could hook to OnmMerge instead of PostMerge
It just feels safer to hook on PostMerge
Because then you know 100% it's already mer ged lol
yeah but changing the inventory for a procedural list even if done in the postmerge seems like a plan for breaking stuff if ever someone attempt to do something to that table
i wonder why its not already a proc list tho
probably cause proc list was initiated to not repeat the same stuff everywhere, but maleinventory is not repeated anywhere else.
Yeah
But I doubt a mod will be changing the list after it's been parsed?
Can you even do it after the parse?
nah its parsed only once
Which would mean postMerge is the last place to change it
So it probably can't break it unless other mods utilise postmerge and do something strange
But in worst case, you can tell people to put your mod later in load order
Or do mods have a variable for prefered load order?
Like, if you set a high number it will be more likely ot load later
oh the only case that would happen is if someone got an idea like your of doing something similar
for example if someone this change maleinventory before you by idk, reusing your code, then it would break cause the field wouldnt exist anymore
The whole making the zomb inventories into ProcLoots is niche to begin with!
In fact, you can parse the entire table and make everything that is rolls+items into Proctables
It's not that difficult
But since it was just 2 tables I didn't even bother doing loops for it
For example, people copy ItemTweaker into their mod. Everytime it overwrite the globals
They just copy the thing wholesale?
so if you were to have an edited ItemTweaker in yours but someone else add the unedited ItemTweaker again after yours then your edited version is not there anymore
Guess ppl gotta start renaming everything with their initials or modname
So best way to not get that problem when including something like ItemTweaker into your own mod, is to make it local and or change the global names
Can't you simply make it so your mod requires itemTweaker?
And just use it by require
that would be the proper way of using "API" mods
but people prefer not have dependencies most of the time
its a bit messy
often due to lack of knowledge
Also gives credit to the author of the API in a direct way
yeah but sometime you may want to have your own edited version if you need more feature from it.
Can't you use some form of extensions in lua?
If the API is stored in an object, you could add your own functions to it
if its global, but if you mess with it it can also break other mod that require it
I just noticed my Role has changed to "builder" lol
I like to make my APIs local and export it, and then any other script that want to use it need to require it into a local variable, this prevent modification to the original object kindof
That's a good way of doing it I suppose
I guess to use things like classes in lua you need to make a function .new() that creates the empty object and populated it with functions etc?
yeah using ISBaseObject is a good thing for making classes that need to be instanciated
Well, hopefully the asura guy will find some use in our rambling lmao
Oh yeah im glad now i feel like I know more about how the distribution works than like 2 hour ago
Hopefully that'll make it easier to mod things π
Probably writing a Guide would be a good thing if any exist
I think the insight that if rolls exist and isn't nil, then procedural is completely ignored even if procedural=true
is pretty valuable
in fact, does it ever check procedural?
oh it does
var9.delegate.containsKey("procedural") || !var8.isEmpty()
var9 contains procedural, or not not var8 ?
lol
oh okay
I see
var8 is the ProcList in this instance
I'm pretty certain
However, its using or instead of and
which seems weird
makes it seem like you can completely ommit procedural as long as you have the list...?
mhm
I think java conditionals shorthand
like it the first is true it probably not read the restart of the condition or im not too sure
so procedural true would make it so the or is whatever
Well yes,
if proc is true rest is ignored
well, what i'm curious of is that
it doesn't seem like it actually checks that procedural is true
it simply puts the var8 and var10 into the var5.container
var9 seems to be the table with keys
and var10 is the containers from var9
so maybe keyvaluepairs?
or maybe whatever is inside each key from var9
look at line 251
I don't have the whole file lmao, just what you posted π
that method also doesn't check if the bool is true lol
but it does save the variable
so maybe its used later
its prioritize procedural
so even if rolls + procedural is set
it will be procedural first
It does check the procedural
// line 678
if (var0.procedural) {
rollProceduralItem(var0.proceduralItems, var1, var5, var3, var4);
} else {
if (var0.junk != null) {
doRollItem(var0.junk, var1, var5, var3, var2, true, var4);
}
doRollItem(var0, var1, var5, var3, var2, false, var4);
}
It only checks if .procedural is true at line 678 from what i've seen so far
line 1039 checks it too
ah, here it gets the list of procedural items
// line 1039
if (var5 != null && var5.procedural) {
ArrayList var6 = var5.proceduralItems;
for(int var7 = 0; var7 < var6.size(); ++var7) {
ItemPickerJava.ProceduralItem var8 = (ItemPickerJava.ProceduralItem)var6.get(var7);
if (var2.equals(var8.name)) {
ItemPickerJava.ItemPickerContainer var9 = (ItemPickerJava.ItemPickerContainer)ProceduralDistributions.get(var2);
if (var9.junk != null && var3) {
return var9.junk;
}
if (!var3) {
return var9;
}
}
}
}
so there are 2 places in the code that uses .procedural inside a conditional
no matter what those other function do
the moment its parsed if it has procedural = true everything else will be ignored
hmm
the other functions you talk about are only using the "already parsed" data
So do you think, if we add procedural=true to something, we should also do the postmerge thing for that thing?
Since it seems it might completely ignore the normal items then?
if you add procedural and procList to maleinventory, its will simply ignore the original items and rolls yeah
so using post merge to move the original rolls items into a procList is still valid.
but unsetting the rolls after is useless
That's good to know then
btw, do you need the require for distributions?
not really, all vanilla script are loaded before mods
@thin hornet @blazing radish I think this should work, but i haven't tested it.
-- ExampleDistributions.lua
require('Items/Distributions')
require('Items/ProceduralDistributions')
local ExampleTable = {
all = {
inventoryfemale = {
items = {"Watermelon", 100,}
procedural = true,
ProcList = {
{name="ExampleProc", min=1, max=2, weightChance=5}
}
},
inventorymale = {
items = {"Apple", 100,}
procedural = true,
ProcList = {
{name="ExampleProc", min=1, max=2, weightChance=5}
}
}
}
}
ProceduralDistributions.list.ExampleProc = {
rolls = 1,
items = {
"Screwdriver", 1,
}
}
table.insert(Distributions, ExampleTable);
-- Example to add default loot into it's own ProcTable to keep it, should work with other mods modifying the default loot.
local function fixEntry(entryMain, entryName)
local entry = entryMain and Distributions[entryMain] or Distributions
entry = entryName and entry[entryName]
-- return if invalid entry
if not entry or not entry.rolls or not entry.items then
-- will this print somewhere?
print("invalid entry, entryMain:", entryMain, " entryName:", entryName)
return
end
ProceduralDistributions.list[entryName] = {
rolls=entry.rolls,
items=entry.items
}
entry.procedural = true -- sets to true just in case.
entry.ProcList = entry.ProcList or {} -- makes sure ProcList exists
table.insert(entry.ProcList, {name=entryName, min=1, max=1, weightChance=100})
end
local function PostProceduralFix()
fixEntry("all", "inventorymale") -- Distribution.all.inventorymale
fixEntry("all", "inventoryfemale") -- Distribution.all.inventoryfemale
fixEntry(nil, "SomeBag") -- should print invalid entry.
end
Events.OnPostMerge.Add(PostProceduralFix)
add a local to entry = Distributions[entryMain][entryName]
Good catch
Btw, when a table contains a single item, does the weight matter?
I figured the chance of an item appearing would be weight/totalweight
Not too sure how the weightChance work honestly
I think weightChance is different from weight
weightChance is probably a straiht up 0-100%
but just weight is usually competing against other weights
its seems so, and can even be omitted
Using weight efficiently is probably best done using a binary tree
First split would be half items
Or half maxweight
half items would be more efficeint
The primitive competing weight is just placing it in an array, then using a for loop that removes the weight of the item each iteration and stops when your random number is less than weight of the item you're on right now
naturally binarytree will be faster if you have a lot of items
but for small amounts, the array version should work just fine
so weightChance is the weight for the entry in the procList array
so if you had only one proc entry you dont even need to set the weightChance
What if you have minimum 1 and maximum 2?
Would it always be 2 if it's only one item, or will it be an actual chance
Guess we'd see if I bothered to test the thing I wrote earlier
Since I set screwdriver to min 1 max 2 with weightchance 5
hmm, also one thing that might chance how I wrote the fix function
If you have a proc table with rolls higher than 1
If you proc that table, does it add 1 item per roll?
Or should you reverse it, and say 1,rolls on the proctable isntead and put the proctable rolls to 1
local function fixEntry(entryMain, entryName)
local entry = Distributions[entryMain] and Distributions[entryMain][entryName]
if not entry or not entry.rolls or not entry.items then return; end
ProceduralDistributions.list[entryName] = {
rolls=entry.rolls,
items=entry.items
}
entry.procedural = true;
entry.ProcList = entry.ProcList or {}; -- probably good to define this in case its not set
table.insert(entry.ProcList, {name=entryName, min=1, max=1, weightChance=100})
end
Yah it might contains some bugs as I'm not very used to lua
I figured it would be paired with something that already set it to procedural, but you're absolutely correct that it's good to make sure
I assumed you wouldn't try to do something you know won't work π
xD
But if you wanted to go through every single entry, say procedurally
then yes those checks are needed
Yo ugonna have to check is entry exists too then
cuz it could be nil
shouldn't it has or nil on entry too?
I think lua conditional assignment is weird af
what do you mean, which line
Tho, C conditional assignment is also pretty sorcery
something like a = (true) ? b : c
if i recall
local entry = Distributions[entryMain] and Distributions[entryMain][entryName]
--- if the first condition is not nil the other one will be the result
and if the other is nil too then it will result to nil too
isn't that the or nil is usually for?
or does it keep the nil from the first assignment
if the first condition is not met it wont go to the other one, therefore its should be nil or false
if the first condition is met then it will assign the second condition as the result which in turn could be nil if that key doesnt exist
If we were to add parenthesis then it would simple return true or false
I did consider making a check for Main being nil i nthe function, in order to ignore that and just go on entryname
Incase there is an container that isn't classified under sometyhing
but I think everything is under something
inside distributions
The thing that the function doesn't do, is if theres something that is 3 deep
My first thought was making a list that you could go through in order to dig down, but I figured it's not needed for the example
Didn't need to make something universally applicable
nothing is 3 deep?
I didn't check, so I don't know
From what I saw, it's either RoomName.ContainerType
or All.containertype
Yeah so there is a case for making the Main disregarded
If I wanted to expose the fix function that should definitely be included, but I'm not really a modder π
I haven't really made anything yet
I tried makign a few things, but it was quite the hassle
Can I add a custom recipe to a vanilla magazine ?
you could override the vanilla magazine i supose oh its an item you could use ItemTweaker
local entry = entryMain and Distributions[entryMain]
entry = entry and entry[entryName] or Distributions[entryName]
if not entry then return end
That should do it right?
if entryMain is nil it should become Distributions[entryName]
-- Example to add default loot into it's own ProcTable to keep it, should work with other mods modifying the default loot.
local function fixEntry(entryMain, entryName)
local entry;
if Distributions[entryMain] and Distributions[entryMain][entryName] then
entry = Distributions[entryMain][entryName];
else
entry = Distributions[entryMain];
end
if not entry or not entry.rolls or not entry.items then return; end
ProceduralDistributions.list[entryName] = {
rolls=entry.rolls,
items=entry.items
}
entry.procedural = true -- sets to true just in case.
entry.ProcList = entry.ProcList or {} -- makes sure ProcList exists
table.insert(entry.ProcList, {name=entryName, min=1, max=1, weightChance=100})
end
local function PostProceduralFix()
fixEntry("all", "inventorymale") -- Distribution.all.inventorymale
fixEntry("Toolbox") -- Distribution.all.inventoryfemale
end
Events.OnPostMerge.Add(PostProceduralFix)
If entryMain doesn't exist, it should try also try entryName, is entryMain exists it will try [entryMain][EntryName]
All it doesn't have is the rolls and items for return check
if not entry or not entry.rolls or not entry.items then return end
``` should have same effect
If any of them are nil, it should return
isnt that what we did?
I hadn't added it
Just being ultra fancy with the lua conditional assignments
local function fixEntry(entryMain, entryName)
local entry = entryMain and Distributions[entryMain]
entry = entry and entry[entryName] or Distributions[entryName]
if not entry or not entry.rolls or not entry.items then return end
ProceduralDistributions.list[entryName] = {
rolls=entry.rolls,
items=entry.items
}
entry.procedural = true -- sets to true just in case.
entry.ProcList = entry.ProcList or {} -- makes sure ProcList exists
table.insert(entry.ProcList, {name=entryName, min=1, max=1, weightChance=100})
end
though, does return need a ;?
when it's oneline if
i use ; all the time as an habit to make it clearer
Yeah it was my habit too lol
actually I think the entry = entry and entry[name] or dist[name]can be shortened
to entry = entry[name] or dist[name]
Just worried it might go "lol no ur accessing a nil table"
for readability
local entry;
if Distributions[entryMain] and Distributions[entryMain][entryName] then
entry = Distributions[entryMain][entryName];
else
entry = Distributions[entryMain];
end
if not entry or not entry.rolls or not entry.items then return; end
is ok too π
No!
xD
π
what happens if you try to index nil into a table?
lol
does it treat it like an actual key?
yeah i think so
I'm a big fan of limiting if statements if possible
since they are a performance thief
function calls are worst
depends on the language since compilers like to paste it into the function I think
i mean for pz lua
I know you should be storing shit locally
its interpreted by the java script engine
because if you call java functions that is the worst
but calling lua functions I don't think is that bad?
Readability and reusability is quite important though as someone who works with the code, so even if lua functions were pain I'd still use them lol
I am fully onboard with not going through the java lua interface as much as possible
local entry = entryMain and Distributions[entryMain] or Distributions
entry = entryName and entry[entryName]
-- return if invalid entry
if not entry or not entry.rolls or not entry.items then
-- will this print somewhere?
print("invalid entry, entryMain:", entryMain, " entryName:", entryName)
return
end
I think this should cover all the bases, and looks even shlichker
entry becomes Distribution[entryMain] if entryMain exists, otherwise it's Distributions,
entry becomes entry[entryName] if entryName exists, otherwise it's nil
But idk if it will screw itself by the assignment of entryName before and entry[entryName] ?
does the conditional assignment evaluate to the end before assignment?
It should, but you never know lol
xD
install lua on your computer for quick testing, or you can also just use online lua console
is there a print for errors btw?
Because I haven't personally been able to see prints outside of ingame
a print for error?
yeah, like when lua errors etc with F11 you see it
But I don't see normal print anywhere in F11 menu
Maybe you can throw an error somehow for debugging
in the in game console
and C:\Users\Konijima\Zomboid\console.txt
all print should be there
hmm maybe would have to check that console.txt for failures of loading
yeah that would be there
actually no , it is not a cuck
because I expect nil if the entryName is nil
π
my brain
what I need to check is
a = {}
a.test = "yaboi"
b = a
a = "test" and a.test
b = nil and b.test
print(a)
print(b)
Yeah so it does work
good haha
it does fully evaluate the conditional assignment
before any assignment
and it should work same with a string instead of true right?
Since boolean in lua is always true unless the value is nil
nil or false
yeah anything not false or nil would evaluate as true unless specifically asking for a true a == true
I really should test this thing, but i am honestly too lazy. my burst of attention is soon done
a = {};a.test = "yaboi";b = a;a = "test" and a.test;b = nil and b.test;print(a);print(b);
I mean the whole system haha
wouldnt surprise me if there are some sleeper bugs in there that won't show up until you use it
-- file: ExampleProceduralFix.lua
-- probably contains bugs
require('Items/Distributions')
require('Items/ProceduralDistributions')
-- function fixEntry: Fixes a container to use ProcList while retaining the base loot by adding it as a new procList entry.
-- entryMain: first level in Distributions, such as 'roomName' or 'all'. Some items (like schoolbag) does not have one, leave it as nil for those.
-- entryName: name of the container we want to fix into ProcList, such as inventorymale for male zombie corpses.
local function fixEntry(entryMain, entryName)
local entry = entryMain and Distributions[entryMain] or Distributions
entry = entryName and entry[entryName]
-- return if invalid entry
if not entry or not entry.rolls or not entry.items then
print("invalid entry, entryMain:", entryMain, " entryName:", entryName)
return
end
-- create a distributionName that is sure not to conflict with anything, probably could be ommitted
local distName = "GeneratedFix_" .. entryName -- lua string concatenation is weird.
ProceduralDistributions.list[distName] = {
rolls=entry.rolls,
items=entry.items
}
entry.procedural = true -- sets to true just in case.
entry.ProcList = entry.ProcList or {} -- makes sure ProcList exists
table.insert(entry.ProcList, {name=distName, min=1, max=1, weightChance=100})
end
-- Example usage of fixEntry
local function PostProceduralFix()
fixEntry("all", "inventorymale") -- Distribution.all.inventorymale
fixEntry("all", "inventoryfemale") -- Distribution.all.inventoryfemale
fixEntry(nil, "SomeBag") -- should print invalid entry. but some containers with no mainEntry exist.
end
Events.OnPostMerge.Add(PostProceduralFix)
if I could be arsed I'd make a global object that you can add entries to a list, which is then read by the OnPostMerge
good idea to prefix the automated fix
also
if not entry or not entry.rolls or not entry.items then
print("invalid entry, entryMain:", entryMain, " entryName:", entryName)
return
end
could be
if not entry or not entry.rolls or not entry.items then
error("invalid entry, entryMain:" .. entryMain .. " entryName:" .. entryName)
end
if you want it to throw the error
yeah
I only really wanted to log it as an error but continue with the rest
Guess it's possible to throw the error at the end of the function if a boolean is set to true
or just use a pcall
local function test(param1)
error("ERROR!!" .. param1);
end;
if pcall(test, "param1") then
print("did not throw error");
end;
i think error in pcall still write to the console.txt id have to test i forgot
Basically yeah https://www.lua.org/pil/8.4.html

just wow
I'l be honest with ya, I didn't understand a thing, this is too advanced for my very beginner knowledge on this
I didn't realized it was that hard
Well, not sure if that's the best method of doing it. But atleast it's probably more efficient to let java do the work isntead of lua.
I see
well, tbh I'm very grateful of your help
seriously
that dive into tbaels lua and java was incredibly mindblowing
I realize I need to learn a lot to do somehting good in the future
I never tried the code, so I'm not sure it works in practice π do tell me if you try it
how to put description on an item? pls help.
anyone know what role this code?
No matter how much I test, I don't know.
It seems to be a health-related figure.
Give it up.π
Tooltip = "My description"
thanks
does my description like this: (lorem ipsum) or (lorem_ipsum)?
I don't get it
does the spacing need an underscore or not
"My description" is a string, so space don't matter
a text entry, like Tooltip_tissue_tooltip
IΒΏm not even sure on hwat code I need to test, is this one? #mod_development message
or the earlier one where you did the ping?
I copiednboth just in case but I wasn't sure
Yeah that part should make the base loot of the inventorymale & female into a Procedural table and add it
The other thing you need to do is add your own procedural table like in the one above
health-related and randomness related too, it rolls for values between (including) min and max, with plant health applying a modifier that can't go over the autorized values
oh thanks to answer!!! ummm What formula is applied do you know?
Anyone know if there are any mods that add a very low chance of surviving a bite or immunity? I want something that doesn't totally change the dynamic of the game but does give you a reason to continue trying to survive after a bite.
I see, I'll try later and I'lll let you know how it went, thank you mate
@blazing radish this is the file I had at the end when I was investigating and talking about it
but I never tried anyof it
ex)
plant week = 1~2
plant healthy = 3~5
is it right? ummm What formula is applied do you know?
first part is creating tables, second part is adding those tables
right?
Yah the file has example on both
amazing, thank you so much
line 0 to 28 could be a file in itself, and 29 to the end could be another file
But I think it doesn't matter, they can be in same file lol
I had to split it in two when I was pasting code into discord because I don't have nitro lmao, and adding the comments take a lot of characters x)
lmao
I've read the whole rabbit hole, felt like this meme
"I want to add 1 item to every zombie" at starting point
"here is how you create your own proc tables and add them to the game without overriding anything" at the end
Lmao, as I said there might be another method that doesn't use distributions, or adds it to outfits or something
what I don't understand is why using OnZombieDead duplicates the desired item according to the player number
and it's even bugged, because it's only "visual", you take the item and instantly dissapears from your inventory
annoying as hell
hmm
Well, the game has some kind of peer to peer
And the scripts run on all players I believe as well
well, if this doesn't work I'll be returning to OnZombieDead regardless, it seems to be the safest method to do what I want
a weak plant may not even produce anything, if that's the case I think the game kills the plant when it is supposed to be ready for harvest, so it should be min to max (1-3) and with health bonus up to (2 to 5)
oh thx!!!!!!!!π―π€£
is it possible to add or remove kills from a player?
Is there a way to reduce the weight of an item attached to a belt/holster/back by a particular amount or is it always reduced by a fixed value?
Ah, oh well. Thank you.
is there a car damage event that can be used?
What about editing the item itself? not sure if you can edit weight etc directly through lua though
You should be able to since as admin you can edit weight
Actually, Eggon's Holster tweaker does it by Attachment type. He admittedly did it with a hack-like method, but hey that kinda like what we all do xD
I'll take a look at that, thank you.
I looked at their code and its more of they ended up making their own system.
To call me a novice when it comes to lua would be generous already so if that's the case it's probably over my head.
to act pretty much identical to vanilla, since yeah the default 30% weight reduction that holsters give is defined somewhere in some convoluted way where its just too tough to track down.
ZombRand(10) is from 0 to 9 right ?
yes
Also, can I set a display name for an inventory item with lua. After looking, I don't think it's possible.
Do you mean for an individual item? If so, you can. See the code that renames bags
I'd send it myself but I can't at the moment, but searching through the files for "rename" or smth should help
do you guys know where are the water dispenser files?
I searching all media files and didnt find anything
maybe it have another name but I don't even find the texture
you won't find textures that way because they are all inside .pack files
and tile properties go inside .tiles
Should be possible
Not on my pc so cant elaborate atm :\
The code that rename bag ? Where is it ?
In the same large file where the context menu is populated, I believe
I'm at my computer now so I can find it, one moment
So you can rename a bag from the contexte menu ? I didn't knew that
Yep, that's the way I found out how to rename when I was trying to do the same thing
If you found it I take it but otherwise I should be able to get there by myself
Ok, thx
Thanks! So its there any water dispenser's file I could use as a reference?
can i use Item properties like BoredomChange on recipes? trying to make a recipe that reduces boredom when crafted
try
If anyone needs a thumbnail for their mod done message me, i'll do it for free i'm very bored.
You can add an OnCreate function that does what you want
what is the catch for letting people shoot / swing from cars? does it HAVE to have a window?
as a component slot?
i want to shoot from a vehicle that has no doors / windows/
i'd love to shoot 360 but i heard that was removed.
Well I noticed accuracy is super reduced atleast if you're trying to shoot anywhere except the cone of your window
lmao
but he wont aim.
Using the ctrl key instead of right click?
or "aiming" stance
they do the same thing.
would the lua file that would contain the code for the OnCreate function go into lua/server or lua/client folder?
vanilla recipe functions go in the server folder, so you should stick to that
Probably because there are no animations for that, even though devs added mod support for showing players in vehicles, that's not a vanilla thing
he wont shoot either.
and there ARE aiming/shooting in car anims π
can windows that do not exist be set to open?
Just found after 1 hour that my issue was table.append instead of table.insert xD
a video f the mower in action. adult language warning
i so need to get this working lol.
blap blap from the back.
any tips on how to go about changing player boredom value after calling player:getStats():getBoredom(); ?
player:setStats():setBoredom();
Javadoc Project Zomboid Modding API declaration: package: zombie.characters, class: Stats
holy shit thats amazing tysm
would using player:setStats():setBoredom(); change the boredom value to a set number or would it subtract or add the value?
set number.
so just get current bordeom and add/subtract as needed and set it to that.
How can I make an item use a battery like the flashlight ?
I understood that you need the trainable type and use UseDelta but what does it represent? How much energy is consumed? And above all, when does the object consume battery and can I cut the consumption?
Like if the object is in a drawer, is it consumes energy? What if the item is in an inventory of a player who is deco?
what do the float and float1 refer to in setBoredomβ(float float1) ?
float mean a value with decimal points
like 0.1, 1.2, 10.55
is there any difference between the float and float1?
float is the type, float1 is the variable name
here an example of values
self:addSliderOption(stats,"Hunger", 0, 1);
self:addSliderOption(stats,"Thirst", 0, 1);
self:addSliderOption(stats,"Fatigue", 0, 1);
self:addSliderOption(stats,"Endurance", 0, 1);
local op = self:addSliderOption(stats,"Fitness", 0, 2); -- -1 to 1, use applymod due to slider
op.applyMod = 1;
self:addSliderOption(stats,"Drunkenness", 0, 100, 1);
self:addSliderOption(stats,"Anger", 0, 1);
--self:addSliderOption(stats,"Boredom", 0, 1);
self:addSliderOption(stats,"Fear", 0, 1);
self:addSliderOption(stats,"Pain", 0, 100, 1);
self:addSliderOption(stats,"Panic", 0, 100, 1);
self:addSliderOption(stats,"Morale", 0, 1);
self:addSliderOption(stats,"Stress", 0, 1);
self:addSliderOption(stats,"StressFromCigarettes", 0, stats:getMaxStressFromCigarettes());
self:addSliderOption(player,"TimeSinceLastSmoke", 0, 10);
self:addSliderOption(body,"BoredomLevel", 0, 100, 1);
self:addSliderOption(body,"UnhappynessLevel", 0, 100, 1);
self:addSliderOption(stats,"Sanity", 0, 1);
self:addSliderOption(body,"Wetness", 0, 100, 1);
self:addSliderOption(body,"Temperature", 20, 40, 0.1);
op = self:addSliderOption(body,"ColdDamageStage", 0, 1);
op.title = "ColdDamageStage (hypo 4)";
self:addSliderOption(body,"OverallBodyHealth", 0, 100, 1);
op = self:addSliderOption(body,"ColdStrength", 0, 100, 1);
op.title = "CatchAColdStrength";
self:addSliderOption(stats,"Sickness", 0, 1);
self:addSliderOption(body,"InfectionLevel", 0, 100, 1);
self:addSliderOption(body,"FakeInfectionLevel", 0, 100, 1);
self:addSliderOption(body,"FoodSicknessLevel", 0, 100, 1);
this give you the minimum and maximum values for each thing
sum stuff are in body some other in stats
local player = getPlayer();
local stats = player:getStats();
local body = player:getBodyDamage();
nice
i still have about 4 other things to add in
plus figure a solution for night vision
this is what i have so far, i'm trying to get the setBoredom to use getBoredom - .25 but i'm not sure how i'd format it
function Recipe.OnCreate.Carving(items, result, player)
local currentBoredom = player:getStats():getBoredom();
local currentUnhappiness = player:getBodyDamage():getUnhappynessLevel();
player:setStats():setBoredom(float float1);
end
end
I saw someone posting a nightvision mod just like a couple day ago
its just jury rigged lighting
it isnt close nor is anywhere near a substitute
boredom and unhappiness is both from getBodyDamage()
they also both a value between 0 to 100
have a look into client\DebugUIs\DebugMenu\General\ISStatsAndBody.lua
If i recall the Eris nightvision mod did a UI overlay
Beta of my pager mod, need to fix 2-3 bugs and I upload it
thats pretty cool man
Thanks, it's for RP. So no more need for discord. You send a message with the radio frequency to your friend when you need to talk to him
For exemple
it taps into some stuff that was first introduced in the weather update years ago
It takes into account the range of the radio too
the version of eris nightvision goggle i have here only use an image overlay overlayBrightness.png
i havent tested really but it substract a powerlevel from 1
1 sec
i am wondering just how much of this originally was just a test to begin with
hell, its been around since 2017
i am up to my eyes in stuff that needs to be completed right now and would love to just strike it
for the meantime i guess brita and myself are just gonna sit and smoke
that screenshot come from a mod or was that from the vanilla game debug ?
`function Recipe.OnCreate.Carving(items, result, player)
local currentUnhappiness = player:getBodyDamage():getUnhappynessLevel();
local boredomChange = player:getBodyDamage():getBoredom() - .05;
player:setBodyDamage():setBoredom(float boredomChange);
end
end`
aside form the line about Unhappiness, does anyone see anything super super inherently wrong with this?
@slate wasp
function Recipe.OnCreate.Carving(items, result, player)
local body = player:getBodyDamage();
local currentUnhappiness = body:getUnhappynessLevel();
local currentBoredom = body:getBoredomLevel();
body:setBoredomLevel(currentBoredom - .05);
end
vanilla debug
the actual NVG stuff eris uses has roots to vanilla but to what extent i dont know
once again, thank you so so much
also you dont have to add your recipe OnCreate directly into the Recipe.OnCreate table you can just use your own global function with prefix to make sure it never overwrite with other mod like MyMod_Recipe_OnCreate_Carving
@thin hornet should the _'s be .'s in MyMod_Recipe_OnCreate_Carving?
Recipe.OnCreate.SomeThing
Recipe is a table containing table OnCreate
OnCreate is a table containing OnCreate Functions.
This is vanilla so if an other mod would add a Carving to it, it could conflict
So basically you can just name your function how you want with a prefix to make sure its unique.
Then in the recipe script .txt you just link that function there
recipe DoSomething {
OnCreate:MyMod_Recipe_OnCreate_Carving,
}
Its just a tip to prevent conflict
ohh so only vanilla tables use periods in spacing?
Well Recipe.OnCreate.DoSomething is the same as
Recipe = {
OnCreate = {
DoSomething = function()
end
}
}
You dont Require to add your own function to that vanilla object
you can but you dont have to
--- myRecipe.txt
recipe DoSomething {
OnCreate:MyMod_Recipe_OnCreate_Carving,
}
--- myrecipecode.lua
function MyMod_Recipe_OnCreate_Carvin(items, result, player)
end
this would work perfectly and chance of conflict are near zero since the naming is very unique
ohh i understand now
ok, so. I've got some code, right?
local GetVehicles = getWorld():getCell():getVehicles();
local GetVehicle = GetVehicles:get(i);
GetVehicle:setScriptName(85crownvic_rosewoodpolice);
GetVehicle:scriptReloaded();```
Right?
so far, it works. Buuuut
there's like a 1/10 chance it'll error out with
[04-03-22 17:29:08.627] ERROR: General , 1646436548626> 940,993,293> java.lang.NullPointerException: Cannot invoke "zombie.vehicles.VehicleDoor.load(java.nio.ByteBuffer, int)" because the return value of "zombie.vehicles.VehiclePart.getDoor()" is null.
how would I fix this? I can see potentially resetting the vehicle if this happens, but how on earth would I check if the door is null?
@hearty herald I found a solution for the duplicaiton issue
not exactly me, was Dislaik the genuis behind
function zombieDeath(zombie)
local inv = zombie:getInventory();
if not inv:contains("Base.Axe") then
inv:AddItem("Base.Axe", 1);
end
end
Events.OnZombieDead.Add(zombieDeath);
I was too afraid to mess with tables and stuff that I don't understand and we were talking about this issue before
Hello, does anyone know how to add several result items to a recipe?
use OnCreate
Seen, think i have it working.
do you guys know how to create a RNG Lua code.
like Example
you have a Lottery Ticket you open it
and there's a big change you get a paper(as a junk prize) and a low chance to get a gun(as a jackpot price).
i try Zombrand but i dont know how to use it.
zombRand(Maxnumber)
is this correct?
ZombRand is a random number generator-- you need to somehow compare to the number to get a truthy value
I would probably do it like:
local LOTTERY_WIN_CHANCE = 5;
function OpenLotteryTicket(items, result, player)
local ticket = ZombRand(0, 100);
local toGet = "";
if ticket < LOTTERY_WIN_CHANCE
toGet = "TicketShard";
else
toGet = "Katana";
end
player:getInventory():AddItem(toGet);
end
There may be more elegant ways to express the conditional, I just didn't like the repetition of player:getInventory():AddItem
I just realized you didn't necessarily want to give the paper when not giving the jackpot, but you get the idea
big thanks to you.
Anyone know if there are good resources for pluralization of item names?
What does BodyLocation variable do in a clothing mod?
what kind of restrictions on clothing you'll get
for example, if you use a fullsuit (coveralls in game), it won't let you use a jacket, pants and more clothes
if you use eyes, then it won't be compatible with other eyes items or full masks
I hope is understandable enough π
Got it haha thanks for the explanation!
NP mate! I think you can check those restrictions in a game file, I'll look for them (found those by mistake while doing research for my mod)
found it!
it's on main PZ folder/media/lua/shared/NPCs/BodyLocations.lua
Alright bro thanks! π
np mate, good luck with your work
player:getXp():AddXP(Perks.Woodwork, 3);
else
player:getXp():AddXP(Perks.Woodwork, 1);```
this should mean that if the players Carp skill Level is LESS THAN or EQUAL to 3, then to give 3 Carp XP, but if higher Level than 3, to give 1 Carp XP when the function is called right? just want to make sure i'm not going crazy. for some reason it's giving me 1xp regardless.
Have you debugged the call to player:getPerkLevel(Perks.Woodwork) just to make sure it's returning the value you expect?
otherwise there'd have to be something else going on in the code, I expect
Yo! Do you guys have any idea which file i'd have to change to set a certain weapon spawning chance to 0 and alter the durability of others ? I mean dont plan on creating a mod but its its the only way i guess i dont mind.
A mod would be the way to go if you want to have a controlled way to apply the change, and is absolutely necessary if you want the change for anyone but yourself.
Finally figured out counting items via the ItemContainer, and also multi-word searching:
Just need to nail handling for hyphenated items and I should be good to move onto searching other areas
Then build the timed action support for walking around looking and this mod will be done!
Couldn't you like
Instead of looking for hyphenated words
Just look for whatever word is between the hyphens
So like, "pork-steak" would just show as "pork" and "steak"
Forgot the term in search algorithms for that
The search list is already almost 2100 entries across vanilla, so I would rather not add that complexity if I can simply incorporate everything in the pattern
But yes, failing that an approach breaking down the inputs would suffice
hello i'm super new into modding here so for example i want someone to enter his age in this line
io.write("enter your age here: ")
user_input = io.read()
print(user_input)
but it doesn't work
Are you looking in player's bag too ? I have a function to find all inventories of bags that the player carries, if you want it
nvm i think there's something wrong with my interpreter
You can't use 'io.write()' I'm almost sure
but i can at replit lua interpreter
on my local interpreter i can't
the web version had 5.1.5 lua
my local interpreter version is 5.4.2
So I got Eris NVGs to work with Brita's Armor Pack:
io.write asks to enter something in the console right ? It's impossible in game, you must use a UI
No problems so far. I think I am starting to understand the lua. π
hence why i'm new into this stuff
i'm learning the basics
does the game use specific lua version?
The latest, presumably. Although this game's been in development for 10 years at this point so who knows. π€ͺ
If you want, I made a UI library to just that.
In 30 line of code (I can give you an exemple), you can do that to ask a name for exemple.
The rectangle is a box where you can add text and then you press enter to call a function
thanks for that
but again i'm still new to this i'm learning the basic first.
after that i want to try make a trading mod because i'm inspired by a mod called dingo trading but still need a lot of improvement imo
overall your ui might helps a lot
Ok, try something simple first you right
Exemple of an UI to ask a name:
local ui
-- Function when enter is press
local function onEnter(elem, text, args)
getPlayer():Say(text);
ui:close();
end
-- UI creation
local function onCreateUI()
ui = NewUI(); -- Init
ui:addText('', "Enter name:", _, "Center");
ui:nextLine();
ui:addEntry("e1", "", false); -- Add entry
ui["e1"]:setEnterFunc(onEnter);
ui:saveLayout();
ui:close();
end
Events.OnCreateUI.Add(onCreateUI)
OHH your the only cure creator mod!
your mod is awesome man! it got into my list of must have mod
Thx ^^
Has anyone ever made a custom object that uses batteries?
I'm trying to figure out how to make my pager consume power
Maybe one of the nightvision goggle mods use batteries?
Maybe indeed, I will check that
try look into better flashlight mod
I already did but all items are derivatives of the vanilla flashlight. So energy consumed is managed by the game, not by the mod
Nop, nothing
Well, maybe a workaround would be to "install battery" action with removes a battery from the game and adds a power variable to the item?
Using moddata maybe
tried this on my web interpreter but it output this
lua: [string "<eval>"]:21: attempt to index global 'Events' (a nil value)
stack traceback:
[string "<eval>"]:21: in main chunk
You need to use it in game, not just with lua
Make a mod and add lua file to it
ahh i see
i'll dive there after i finish learning lua basic
What the KnockBackOnNoDeath parameter affects/does?
what does the power level do?
Just be careful that no items will disappear when used or dropped ( Or rather the main problem NV got in the past ) π
I have ideas to work around the problem with modData, but I thought there was an easy way to do it
hey someone know how to increase the limit of safehouse? i would like to have 2 safe house plz
how do you recommend i go about doing that?
Well, you could just print the result
local perkLvl = player:getPerkLevel(Perks.Woodwork)
print("Perks.Woodwork returns: " .. perkLvl)
if perkLvl <= 3 then
-- something
else
-- something else
end
I'm using your function for cross-verifying the item against the actual contents of inventories-- but first I'm matching the input against known items so I don't kick off searching for items that don't exist
Is the search that intensive that you need the item verification?
Just considering things like renamed items
I don't understand what you mean
What the name implies, some items knock zombies back with each hit, like baseball bats, others don't, like knives
I don't know really anything about renamed items, so I'll have to cross that bridge later
On boot I cache the items that exist:
function cacheItems()
print("Startup, getting cache of items available for searching");
local allItems = getAllItems();
local function addTo(set, key)
set[key] = true;
end
ITEMSEARCH_PERSISTENT_DATA.itemCache = allItems;
ITEMSEARCH_PERSISTENT_DATA.displayNameSet = {};
ITEMSEARCH_PERSISTENT_DATA.itemsByDisplayName = {};
local javaItemsSize = allItems:size();
for x = 0, javaItemsSize -1 do
local item = allItems:get(x);
local module = item:getModuleName();
local name = item:getName();
local type = item:getType();
local displayName = item:getDisplayName();
if not setContains(ITEMSEARCH_PERSISTENT_DATA.displayNameSet) then
addTo(ITEMSEARCH_PERSISTENT_DATA.displayNameSet, displayName);
ITEMSEARCH_PERSISTENT_DATA.itemsByDisplayName[displayName] = { item };
else
table.insert(ITEMSEARCH_PERSISTENT_DATA.itemsByDisplayName[displayName], item)
print("We now have more than one item by the display name of " .. displayName);
for i, v in ipairs(ITEMSEARCH_PERSISTENT_DATA.itemsByDisplayName[displayName]) do
print(displayName .. "[" .. i .. "]" .. " Module: " .. v:getModuleName());
end
end
end
print("Done starting up, should have cached display item info for " .. javaItemsSize .. " items provided by getAllItems()");
end
There's also the use-case argument, what if you have to search for itemType by their class name, which could be different from display name
For sure. My dialog is simple right now but I have a thought for options related to the search: Search by type, as well as specifying how far/long you want the char to look
ofc you could fix the whole display name / class name by passing it through a hashtable
During a search attempt, before actually checking the player's inventory, their loot, etc., I try to cross-verify that such an item exists in some module:
if exactMatch then
local matches = ITEMSEARCH_PERSISTENT_DATA.itemsByDisplayName[searchText];
print("Exact match from persistent data on display name: ", ITEMSEARCH_PERSISTENT_DATA.itemsByDisplayName[searchText]);
for i, match in ipairs(matches) do
print(match:getDisplayName() .. ": " .. tostring(match:getType()) .. " - " .. match:getModuleName() .. "." .. match:getName());
-- TODO: If we truly have multiple items, this will always take the last match found, making this non-deterministic
displayName = match:getDisplayName();
end
end
if displayName == nil then
local searchPattern = self:createSearchPattern(searchText);
print("Generated search pattern is: " .. searchPattern);
displayName = findBestMatch(searchPattern);
if displayName ~= nil then
print("Best match found via pattern was: " .. displayName);
else
print("No match found via pattern");
end
end
if displayName == nil then
print("No match found, out of options :(");
return;
else
print("The match we found was: " .. displayName);
end
Just don't know personalyl how often display name is different
Are you thinking I should be able to use straight object comparisons between items?
Well, you can index a hashtable by their displayName to get the classname
But that would require setting up a hashtable with every single displayname linked to the associated classname lol
Which classname? I've seen module, type, name, display name...
Just what I'm calling it the items are referred by a certain name in the code
I think if you want to be specific you have to use the module as well?
Like Base.Screwdriver isntead of Screwdriver
Yes, that is technically considered the "full type"
I pieced that together when I started using ItemContainer:getItemCount overloads
how would i integrate getZombieKills() into a function? like how boredom is player:getStats():getBoredomLevel, what would be getZombieKillsβ equivalent to player:getStats?
However people are used to the display names, so I wouldn't want it to be confusing in regards to like - "Why do I have to use this weird name instead of the name I always see in my inventory?"
Yeah display name is best
But that does run into the issues of people renaming items, perhaps thinking they can find it easier
Do you have a ref on item renames? I'd like to see how it works
Uh, I think you can right click items an rename from there
I know you can do it on cooked food and bags
oh shi-
Didn't realize it was vanilla
Can you tell I've only played this game a bit? π
Yah it exists in vanilla
My friend renamed food he cooked and gave it to me in MP
Luckily it was not the food with the bleach in it LOL
π
Did you know, if you add bleach into food you don't even see it has bleach in it
super trolly
Doesn't even contain negative mood
You sure? I thought it gives the icon a poison symbol
It doesn't on food
Apparently bags, food, and map can be renamed
At least I know it does when you add poo to food when using the defecation mod
Bleach is literally hidden in vanilla cooking
Damn I wish the same could be said for the poo stew I made my group.
Yep, my friend said "I left food for friend2 in the oven"
turns out it was the food he tested adding bleach to
π

Never trust your friends with food once they learn of this forbidden knowledge btw
Well, it's good that it's just bags food and maps I guess
I don't think most people really use the rename thing
most useful for organisation with bags I guess
and there's always the classic "release without the feature, wait for complaints"
I can see a compromise
If your item validation system says it doesn't exist, you can give them a prompt that says "this is not a default item, search anyway?"
Or something along those lines
Guys, what language PZ mods uses?
Lua
https://steamcommunity.com/sharedfiles/filedetails/?id=2702976412
is the modpack we're using
Yet for somereason player zmobies are naked, kinda takes you out of it when your friends in a horde in their undie and bday suit
Anyone know what would cause this?
guy how to make an item that is placeable like the oven or ham radios
and guys how make the item that cannot be pick or place by a regular player and only the admin can.
need help with lua basic
the_answer = tonumber(io.read())
if the_answer >= 1 then
print("you'right congrats!")
elseif the_answer <= 0 then
print("you're wrong!")
end```
if i type any alphabet at the console i got this error
```lua: [string "<eval>"]:4: attempt to compare number with nil
stack traceback
[string "<eval>"]:4: in main chunk```
how can i make the answer is wrong without traceback error
to change Pain and Panic levels is it just panicChange and painChange or do i have to go lua diving for these?
Hey guys, in my ever-changing list of mods, I had one mod that allowed me to reclaim sheets from sheet rope. I've been trying to find which mod it is again, but I haven't had any luck. Wondering if anyone would know off-hand.
I've seen some tailoring mods that have it so you can do it with twine, but none that just allow you to reclaim when you click right on the sheet rope.
would it be possible to make a 'craftable item' accessible only for a specific Faction in MP?
add an item that an admin would give them that is part of the recipe
Great idea! Thanks!
no worries dude, its the system i use.
Hey Senjay, the way to figure out problems like this is to figure out the specifications of the function you're calling. However, from context I can tell you that a function like tonumber probably returns nil when given something that isn't numeric. Just add another condition to detect if the_answer is nil and bypass comparing it to the numbers
For convenience I would probably reorder the conditions:
if the_answer = nil or the_answer <= 0 then
print("You're wrong!");
else
print("You're right, congrats!");
end
Or separate out the nil check to print something different for non-numeric input
Is there an easy fix for item to big on the ground ?
You can use the scale field for the item.
model Marshmallows_GroundRotten
{
mesh = WorldItems/Marshmallows,
texture = WorldItems/MarshmallowsBurnt,
scale = 0.4,
}
- you can also reszie/modify models, at least
fbxmodels, in realtime in game by changing them in blender etc, and saving/moving them to the pz model directory as well.
Wait, I need a model here
I don't want to do a model, I suck at it. Just keep the icon like that but smaller
You know what ? I will do a model, but just a 3d rectangle
Is there something special to know about the model or every fbx is ok ?
Do you actually need a model? since a lot of items just use a sprite
how to disable the pick up item option on ham radio. and also disable the disassemble option as well?
I made that in an item.txt in script but still a sprite. Did I miss something ?:
module PagerMod
{
imports
{
Base
}
item Pager
{
Type = Normal,
Weight = 0.1,
DisplayName = Pager,
DisplayCategory = Item,
Icon = Pager,
Tooltip = Tooltip_Pager,
}
model Pager
{
mesh = WorldItems/Pager,
texture = WorldItems/PagerTexture,
scale = 1,
}
}
Wouldn't scale = 1 make it full size? You'd want less than 1, greater than 0, to scale it down yeah?
thank you this is what i needed
i've been experimenting lua basic overall
Take a look at the vanilla code which builds the context menu items. I assume you'd essentially want to prevent them being added through the normal flow for those items upon checking your conditions.
For the moment I try to get a model, after I change the scale
If I find an error from the game itself, where do I report it ?
I got an error when placing a makshift radio
idk, but my best advice as i can think of is asking Beard on #old_techsupport channel
You need to have the item script reference the model script like so with WorldStaticModel
item Aluminum
{
DisplayCategory = Material,
Weight = 0.1,
Type = Normal,
DisplayName = Aluminum,
Icon = Aluminum,
MetalValue = 5,
WorldStaticModel = Aluminum,
}
Still a spite, I must be missing something
So we have this new anti-cheat system.
It prevent player from teleporting "illegaly".
But the server command to teleport send a packet to the client and the client use this to change the player position:
player:setX(x);
player:setY(y);
player:setZ(z);
player:setLx(player:getX());
player:setLy(player:getY());
player:setLz(player:getZ());
But I need to allow players to teleport without admin rights.
And using this with my mod kicks the player.
Yeah
But I do not seem to find a serversided way of doing it
I tried setting the player position from the server using a clientCommand event.
It doesn't teleport the client
example:
--- client
sendClientCommand("Test", "teleport", pos);
--- server
local function onClientCommand(module, command, playerObj, args)
if module == "Test" and command == "teleport" then
playerObj:setX(args.x);
playerObj:setY(args.y);
playerObj:setZ(args.z);
playerObj:setLx(playerObj:getX());
playerObj:setLy(playerObj:getY());
playerObj:setLz(playerObj:getZ());
end
end
Events.OnClientCommand.Add(onClientCommand);
sendClientCommand is when the client send a command
i sent an example
thats what im doing, just to show that i set the player position from the server but that doesnt work on that player client.
Seem like position have to be changed client side
tested in 41.66?
it only kick non admin by the way
can you post your example?
well i dont know, for me it kick players and thats what i do
waiting for 41.67 to disable teleport anti-cheat
setting player position from server does nothing.
setting player position from client kicks the player.
thats what i get
So i would think there is a way to transmit a player new position from a server only method.
changing it on server then transmitting it or something but havent found anything yet
maybe cause it doesnt move a long distance
im trying to teleport across the map
I was wondering is there anyway to spawn in items that canβt be crafted from the game menu ? Iβve been wanting to try to find a way to place down those big military tents in other parts of the map because I figure it would make a cool looking starting base . Maybe if I use admin mode ? Or a mod maybe ?
if there was a getGameServer() we could just use the public static function to sendTeleport from the server directly
Wooooo
proper slicktops time
https://gyazo.com/273a3bff25cd98b9f047e7d9871e96f9
https://gyazo.com/008b29cdd219cb5ae33ba3bd07f0e39a
uhh... how do i fix this? its either not loading models or models are in wierd place
Any mods for fixing layer height on graves with snow when they're empty.
How do I make a mod that replaces a recipe from the base game/another mod?
there is a weird bug in PZ where your model doesn't appear correctly if the models under a custom module instead base
if you do it directly on base it'll work, unless I missed some other error
heya guys
Hey All, having an issue with transferring items on the a multiplayer server... I'm transferring items to containers and bags just fine when all of the sudden the container/bags stops receiving items. Weight Limit is not the issue, and the server is modded, but the thing is I'm the only one experiencing this issue. My ping was a steady 50 ms.
Anyone can help me to get mods to work when i try to host a game with one of my friends? I have them active in the main menu and in the server setting but when i go to launch/start the server it does not appear like they are not active or something
Anyone know what these two items parameters does/affect?
UseDelta = <<- Present in items like pills/pills containers for example
KnockBackOnNoDeath = <<- Present in items like weapons/hand weapons for example
do you have the swat pack mod?
anyone see anything wront with this .,txt for my trailer?
@willow estuary you around?
Ok got the UseDelta..In case it could be of help for others: https://theindiestone.com/forums/index.php?/topic/378-drainable-item-usedelta-chart-make-shift-chart/
The use delta is the amount of uses that Drainable items have. The formula is 1 divided by delta number = Number of uses. Thank you 7Roses . I will make a complete and better chart at some point.Unless someone else wants to use a calculator or their head to make it for us. 1=1 .1 = 9 .2 = 5 .3 = ...
Ok KnockBackOnNoDeath is a boolean so it has the TRUE/FALSE values...Remains to understand for what... π
if they don't de, then push them back?
I think I've got it...It should be so...True: If with the weapon of choise you don't kill the zed after have scored a hit and he get close there is the chance that the character will attempt to knock down the zed ( without hitting him directly with the weapon )
FALSE: The character will always hit the zed with the weapon of choice until the zed is not dead without attempting to knock him down/push him
( at least this is the impression I have so far after making some tests with TRUE/FALSE activated )
Is there an event for when the player gets close enough to a container? corpse, box, etc etc?
custom recipe gives carpentry xp even when there's nothing in the recipe file telling it to? gives .25xp each time it's crafted
```recipe Carve Wooden Block
{
Log,
keep dj_ChiselBad/dj_ChiselGood,
Result:dj_WoodBlock,
OnCreate:djCarving_Recipe_OnCreate_Carving,
Time:250.0,
Category:Carpentry,
}```
local body = player:getBodyDamage();
local stats = player:getStats();
local currentUnhappiness = body:getUnhappynessLevel();
local currentBoredom = body:getBoredomLevel();
local currentStress = stats:getStress();
body:setBoredomLevel(currentBoredom - 40);
body:setUnhappynessLevel(currentUnhappiness - 40);
stats:setStress(currentStress - .15);
end```
Thanks love 
Here others you can check
https://pzwiki.net/wiki/Modding:Lua_Event
OnRefreshInventoryWindowContainers looks interesting
@gilded hawk Just make some tests first to check that they work because some may be obsolete with 41.66 π
I patched PLLoot Fantasy too. The HECU and ARES masks now have working NV again. π
Am I wrong, or shouldn't all public methods of classes under zombie.scripting.objects be available to call from Lua?
Trying to call getType, and Recipe.class appears to have a public getType(), but then... Exception thrown java.lang.RuntimeException: Object tried to call nil in cacheRecipes at KahluaUtil.fail line:82.
@zealous wing Mighty! Can't wait that you'll release it! ( I hope soon LOOL π )
Last piece about the UseDelta that can be of interest for modders learning like me. Here is a table reporting the number of uses.
https://www.dropbox.com/s/l41uwujbpce2j7a/DeltaUse Chart.xls
( Or rather the number of times the item of interest can be used before ending. Sample: a bottle of pills with UseDelta set to 0.05 will have 20 uses or rather, said in brief, it will simulate 20 pills contained in the pill's container )
figured out the issue with item transferring. There was a server setting... "item limit" or "container limit" and they changed it and now its no longer happening! π
you fixed the night vision script?
It's been fixed. It's just that neither Brita nor Paw Low ever re-enabled its functionality for their NVGs.
So I did it myself.
it doesnt. the only getType defined in that file is under the Recipe.Result class, which is fetched by calling the getResult method on the recipe
Aha, missed that it was declared under the nested class. Thanks for straightening me out.
That's the spirit!
Hey Folks.. Is there any other way to make zeds to bite through my vehicle? I'm making a convertible vehicle without any roof and side windows, And I tried removing every window parts except the Windshield on the script and still, they can't hurt me through it. They only keep bumping my vehicle's door forever. Is there any alternatives of doing it?
hello man i tested this code yesterday received an error
took me about 10 minute to figure out that this line is causing it
if the_answer = nil or the_answer <= 0 then
it should be
if the_answer == nil or the_answer <= 0 then
hey guys how to locate the code for the deletion of items in the ground.
probably needs windows to work. add window parts, but don't add the script that actually spawns the items. then add the windows to the no-display category so they don't appear in the mechanics interface. now the game thinks the car has open windows while the player will never know that it has windows at all.
Yee yee ass NVGs:
Yee yee ass mod release:
https://steamcommunity.com/sharedfiles/filedetails/?id=2774195675
congrats for the release π
though i don't use brita anymore because of how immersion breaking the mod is unless someone made balancing patch
Thanks.
Halve the spawn rates in the settings and it'd be close to the vanilla normal spawn rate.
Or come to the understanding that the state of Kentucky circa 1993 had more guns than people.
yeah i agree to the state of kentucky but not just half the spawn rate
i preferably made -50% weapon spawn -80% ammo spawn -50% weapon mods
and make it so that the police station is not bloated with U.S army whole arsenal
we shouldn't discuss more about this stuff here
hello how to add collision on an item. pls help
https://discordapp.com/channels/136501320340209664/232196827577974784/949927369387409438 @faint jewel have you tried this for your trailer?
Oh right.. I'm a little new to this.. How do I put them on "no-display"? And what do you mean by the script the don't spawn items? Is that the vehicle items distribution?
no, vehicle parts have scripts attached
{
category = nodisplay,
lua
{
create = Vehicles.Create.Window,
init = Vehicles.Init.Window,
}
}```
add this in your vehicle config after the normal windows template
create = and init = need to be overwritten, because that's what will add the actual window item to the part. don't know right now how to clear the script
in worst case, need to write a custom script that doesn't do anything and add it there instead
Alrighty.. soo do I put the script that does nothing on the client's folder or server?
Sup gamers, does the AddItem call take arguments for item condition?
or is there any other way to spawn an item with custom condinition?
do this: part Window* { category = nodisplay, lua { create = Vehicles.Init.Window, init = Vehicles.Init.Window, } }
turns out the .init script is empty and not doing anything
so you might as well use it for create =
in full your vehicle config should look like this: template = Window/part/WindowFrontLeft, template = Window/part/WindowFrontRight, part Window* { category = nodisplay, lua { create = Vehicles.Init.Window, init = Vehicles.Init.Window, } }
yes
alrighty
i just noticed your vehicle has a windshield
so you might want to use part WindowFront* instead
and then do the same for the backseats
yep.. also do I have to include the rearleft/right windows for the zeds to hurt the other passengers?
yes
hmm alright.
If it's lua, can't you simply write ?
create = function() return end,
every seat needs a window
don't know if it works like that in vehicle config
yes. create = , will not work
or leave it out entirely
havent tried nil
if you leave it out, it will inherit script from base window part, which we don't want in this case
Ah, but the file is a lua file right?
pretty sure using an anonymous function would work just fine if so
Oh neat its working. Thanks for the help!
Just has to hace the correct input
Just be wary incase the window.init function in the future has some functionality I guess π
kek, future you will thank you π
i mean, it's not that hard to make a custom empty function and call that instead
i just can't be arsed to explain right now π
i'm 110% lua idiot, but even i can do that
understandable, have a nice day
Okay soo... The zeds can only bite through front passengers.. Except the rear passengers.. did I do it wrong for the backseats?
can someone make batman armour
i saw the new batman and i wanna be batman in project zomboid
MOD IDEA: "HIVE MIND"
When 1 zed saw you, all the zeds in the whole map knows your location and will hunt you
In the patch note of the build 41.67, they say "Fixed GlobalModData.save() not being called on the server.". Does that mean that now global ModData is save beteween restart of server ?
yes
Nice, I just released a mod that uses global modData and I needed to save the table with Json.lua. Any idea of ββthe official release? To update my mod in advance and upload it later
Can't you get the games version by some function from lua?
GetCore() should have a function for that. That's usually what you call for this kind of thing
I suppose there's also the mod version thingy you could use
getCore():getVersionNumber() returns a string
So you could check for versionNumber, split it in parts and just do a number check on the last bit to see if it's over a certain theshold?
If it's over the threshold you could just unhook whatever event you used to save moddata with json
Though i guess your mod will still work when moddata save is fixed so you donm't actually have to change anything π
shift + del, easiest update ever
I'm glad I didn't even look into fixing that when I saw the changelist
does anyone know how is the aim outline is rendered around the zombies?
Cause I would like mod it of instead it being an outline, it becomes an overlay on top of the zombie
Hiya, probably a simple one. but I'm trying to make my own backpack show. it'll use the big hiking bag as its base so I've tried to copy/paste that as a starting point. my character is wearing the bag correctly, as the back weapon goes to the side, but I cannot see anything. Is there something I'm missing?
as far as I can tell. everything is referencing eachother, the item actually works, as i can put stuff in the bag etc, its jsut not visible in the world
Also, I'm looking for a good modeller who is also a fan of Tom Clancy The Division for a mod project (ping me or pm me if interested)
Thanks, it will be used for the NVGs I commissioned from shark like last year lol
hey guys how to add a collision on an item. can any of you guys know?
Hello, I have a question ( that will be easy for all of you I think ) I would like to know how to set XP to the player's perks ? I've seen the AddXP function but not the setXP for the perks
I have/... here's the script feel free to try it out.
I don't see the part with initialising window and create
template = Window/part/WindowFrontLeft,
template = Window/part/WindowFrontRight,
part Wind*
{
category = nodisplay,
itemType= Base.nil,
table install
{
recipes = Impossible,
}
table uninstall
{
recipes = Impossible,
}
}
part Wind*
{
category = nodisplay,
itemType= Base.nil,
table install
{
recipes = Impossible,
}
table uninstall
{
recipes = Impossible,
}
lua
{
create = Vehicle.InitWindow, -- this one shouldn't do anything, you can use InitWindow or make an empty function...
init = Vehicles.Init.Window,
}
}
And does it work being called Wind* isntead of Window* ?
gets the windsheild too.
got it sorted. I was missing the fileGuidTable file
Are there any good resources for adding UI.
I need text insert box and display boxes
tell me please, is it possible to make a mod only for the server part? Is it possible for one team? For example, when you enter say nick text in the console, a message is written to the game in / all? Based on the principle of discord integration (it works very poorly for me)
P.S I am writing my GUI in C# for a server and I wanted to implement a bot to manage it, etc.
Conspiracy theory: Brita is an Ai who was programmed to make armor and weapon mods
How else would there be that many weapons in Britas weapon pack
is the "HoursForWorldItemRemoval" in the sandbox settings broken. i tried to type a Base item in the description and set the deletion time to 1hour ingame and check the whitelist so that the items that on the whitelist dissapear. but it didn't work.
Hello
Is there any documentation for creating custom challenges? I know it involves lua but I cant find anything on it except for old form posts with no replies.
Basically I want to create a custom challenge map that adds items to the players inventory on character creation and gives them a scrape on their shin. Kinda like CDDA but I cant find where the documentation for these functions are or a formatting tutorial for setting up a challenge map.
You can use my library to make something simple (I recommended), otherwise my guide to make custom UI:
https://steamcommunity.com/sharedfiles/filedetails/?id=2760035814
https://github.com/MrBounty/PZ-Mod---Doc/blob/main/Make an custom UI.md
Tell me if you try my library pls, I need feedbacks
Sure thing. I'll try it out for sure, I will post any feedback on steam workshop
This looks like exactly what I was looking for!
How do I make my mod delete a recipe from the vanilla recipes?
Guys, I will update the question, is it possible to create a mod that users will not need to install?
#mod_development message
You can make a mod only on the server but players still need to dl it
What are tou planning to do exactly ?
I understand, sorry ... thanks. So my implementation of the discord bot apparently disappears, to create a custom chat command (((
I wanted to make my GUI with the discord bot inside work on the principle of discord integration, but also accept administration commands to ban, kick, etc.
I wanted to do this through voting in the discord.
A UI in the game ? To make vote on a discord ?
omg this is amazing, just what I needed 
No, I thought the vote was right in the discord through reactions
This is my GUI now, it remains to solve the discord issue
And how I see the voting method. then I thought to count the votes from the number of total votes and decide on the percentage of the ban or not
No idea about the discord thing, never did that
Well, I need to implement a system so that, roughly speaking, I can write command name text to the console and it will be sent in the same way as discord integration. So I'm looking for a method
Roughly speaking, I am re-inventing discord integration, but for myself, because I want to add commands to the admins, etc., I did it, it remains to do somehow custom console commands and their processing. how to start
In java DiscordBot.this.sender.sendMessageFromDiscord(message.getAuthor().getName(), removeSmilesAndImages); works like this,So I'm trying to figure out how to use this method through the console command to transfer a nickname and text
@thin hornet Are you one creator of the computer mod ?
Ok, if i want to use your mod to make one, basically make your mod a require. Can I ?
I have an idea for a website to exchange objects accessible from the computer
Ohhh I want to make Amazon for the pc mod!
Technically yes
Its a global object so its should be accessible
But i have yet to update it to make it more extensible
That would be nice. The idea is to use my new pager mod, you post an ad on the site and receive a message on the pager when someone accepts your offer with a channel for the radio to chat or meet, something like that
When building out a distribution list, is there a way to limit the item generation spawn to a specific building on the map? Or even a specific floor on the building?
@crimson spindle depends on the map design
Simple UI library maybe that's a good mod oh no what's this it's telling me to rate and favourite! But it is not one of my favourite mods. It looks like I will not be downloading it if lying is part of the deal D:
What about for the vanilla map?
Yes, that is vanilla map has that built out pretty well
so how do you do it? lets say you want to limit the spawns to just the hospital buildings?
@crimson spindle check the tutorials on the wiki
Hey y'all just wondering if there was an NPC survivor mod I just got the game but without npc survivors it feels pretty empty. Maybe I haven't played enough though. Just wondering
@tardy beacon this channel is about making mods.. you're better off posting that in mod support probably.. that said, NPCs aren't a thing yet, but the game devs are working on it.. just wait and see
Ohhh my bad
So I have Soul Filcher's Awesome Time, and I'm trying to figure out how to level up masonry? Do I just build a crapton of concrete floors?
yay home now.
Nice welcome home! I just sat down after work with some pizza and tryin' to fix up server π
If I want to completely overwrite another mod's distribution file...would adding zzz in the front of my file name cause it load after?
ModDistro.lua <<-- original mod file.
zzzModDistro.lua <<-- my file.
Search results from surrounding containers:
i can NOT get it to let me shoot out of this wagon.
any ideas?
template = Window/part/WindowFrontLeft,
template = Window/part/WindowFrontRight,
part Window*
{
category = nodisplay,
lua
{
create = Vehicles.Init.Window,
init = Vehicles.Init.Window,
}
}
this does not work lol
Here is the beta for a map mod I am making. Its a survival challenge based off the backrooms. I've been running into some technical difficulties so I may or may not finish it.
getting an error telling me that my function doesn't exist? "no such function" any ideas?
```recipe Solve Puzzle Cube
{
Cube,
Result:Cube,
RemoveResultItem:true,
Time:100.0,
AnimNode:Disassemble,
Prop1:CubePuzzle,
OnCreate:djCube_Recipe_OnCreate_SolveCube,
}
}```
local SolveCube_Chance = 1;
local ticket = ZombRand(0, 4);
local toGet = "";
if ticket = SolveCube_Chance
toGet = "Cube";
else
toGet = "Katana";
end
player:getInventory():AddItem(toGet);
end
end```
Anyone know how to resolve my model showing upside down when drinking but is fine when being placed in game?
Is the function in a different file? If so, have you used require('otherFile') ?
That's the only thing I can think of, I have 0 experience with recipes
nah itβs all in the one file, iβm sure iβll figure it out. thanks anyway!
Tried placing the function above the place where it's referenced?
That's a habit from languages like C, where it doesn't know the functions exist unless it's defined before in the file lol
So you would make an empty function definition with just the type and that at the top or in a header file, then in a different place write the whole function
Yeah It's a habit of mine to put functions above their use place
I mean that kind of "hierarchy" is common in every scripting language
For obvious reasons
Like even Batch and COBOL use that standard
Hey all. I'm trying to find a mod that adds kill count to the RADIO_SAVE.txt so I can use it in my streams
I can already get the DaysSinceStart from there... lets me get average kills per day and such
From what I gather the kill count is probably in the vehicles.db where all the character info is stored? But I have no idea how to access that...
ugh
when you say βaboveβ itβs use place, what exactly do you mean? the line that defines the function is on line 1 in my .lua file, and what i posted earlier was the only code in that file. just a little confused
? what happened?
Yeah, if the function is on line 1, the thing that uses the function would be on line, say 10. But maybe there's something else going on with the linking of the recipe files?
I have an item I want to only be able to spawn in the file cabinets/desk of medical clinics/hospitals... patient files, test results, etc. things like that... but I don't want it spawning where the medical supplies go. How do I go about doing that? As far as I can see in the Procedural Distributions there isn't a MedicalOffice table or something similar.
Like I know there is OfficeCounter, OfficeDesk, and OfficeDrawers in the procedural distribution list.. however im not sure how to restrict it to just certain locations like the hospital or clinic so they don't spawn in like a law office for example.
Well in Distributions.lua there is a sub directory for areas/rooms
dentiststorage = { -- Area
isShop = true,
metal_shelves = { -- Container
procedural = true,
procList = {
{name="MedicalStorageDrugs", min=0, max=6, weightChance=100},
{name="MedicalStorageTools", min=0, max=4, weightChance=80},
{name="MedicalStorageOutfit", min=0, max=2, weightChance=40},
}
}
},
hmmm so then in that example... what i need to do then is define my own proceduralDistro... lets say MedicalOffice.... then add it to that?
There is also this:
changeroom = {
locker = {
procedural = true,
procList = {
{name="FactoryLockers", min=0, max=99, forceForRooms="batteryfactory;brewery;dogfoodfactory;factory;fryshipping;metalshop;radiofactory;warehouse;wirefactory;whiskeybottling"},
{name="HospitalLockers", min=0, max=99, forceForRooms="hospitalroom"},
}
},
forceForRooms
And as yo ucan see you can have several rooms for it
lol
hmmmm
So what I think is going on here is
where is the rooms coming from
There are room types like Changing Room, Bathroom etc
And those ahve their own list
Because they are universal across many buildings
But if they are inside a say hospital
They have roomtype
like "hospitalroom"
that makes sense
So what you wanted was like hospital office right?
yeah
Theres an area called office, and hers an example of the police stuff in it
desk = {
procedural = true,
procList = {
{name="OfficeDesk", min=0, max=99, weightChance=100},
{name="PoliceDesk", min=0, max=99, forceForRooms="policestorage"},
}
},
So it has normal officedest stuff
But in "policestorage" it also has whatever policeDesk proclist has
So Area type is probably part of the map, which defines which desk proclist/itemlist will be used
is there anywhere wher eyou can see all the roomtypes or areatypes?
Not sure, I just look through Distributions
or you just have to comb through the distro list.. gotcha
so in those cases can you define your own and append it to the existing distro table?
I think what you want to do is
