#mod_development
1 messages ยท Page 72 of 1
I was going to just make it a looped action - people tended to want control over the two types of reading
I would say it's streamlined well enough that it feels subjectively easier to me than modding e.g. NMS
i have an A level in computer science but i fucking suck at programming (they also literally only taught us python in college level...)
Hello World in PZ was a smidge faster than in NMS for me
But then again I modded NMS in C# and did not have to do that.
nms?
I made a mod that propagated plants and animals more so you could find forest planets and such
Also I finished converting the XP boosting calculations
Huge modding scene in NMS
Because NMS is not competitive, no one (smart) cares if you mod online
pretty straight forward except for the whole while() while() thing
I think most of it was to get the right perk (not sure)
So people frequently play online with a ton of mods
ive been eyeing up nms for a while but its never gotten to the top of my "to play" list
ahh yeah igy
also TIL if you eat more than 300 proteins you don't get a boost to strength XP
fronteir are too money focused to allow modding support for elite dangerous
This mean you figured out a way to get real values and things, or did you have to compromise somewhere?
I got several hundred hours out of playing and modding NMS so I don't hate the game, but I did leave the game because I am disappointed by how the devs approach updates to that game.
I would say it's a game experience worth exploring
I can't post the function here cause it's 100 character too long but I pulled out all the math they use to convert the raw XP (usually down)
They have kept it at $60 when off-sale for SO long it's crazy
I can now decide to cap it at 0.25 while still taking in proteins, traits, etc
There's a few quirks in here that I didn't know about tho
But in fairness it does give you quadrillions of planets to explore @pseudo ermine
---perks boostMap based on career and starting traits
local xpBoostID = pXP:getPerkBoost(perk)
local xpBoostMultiplier = 1
if xpBoostID == 0 and (not isSkillExcludedFrom.SpeedReduction(perk)) then
xpBoostMultiplier = 0.25
elseif xpBoostID == 1 and perk==Perks.Sprinting then
xpBoostMultiplier = 1.25
elseif xpBoostID == 1 then
xpBoostMultiplier = 1
elseif xpBoostID == 2 and (not isSkillExcludedFrom.SpeedIncrease(perk)) then
xpBoostMultiplier = 1.33
elseif xpBoostID == 3 and (not isSkillExcludedFrom.SpeedIncrease(perk)) then
xpBoostMultiplier = 1.66
end
Exciting, though still sounds like a potential issue with mods that modify the XP rate based on original skill level?
Haha since it's procgen the game is damn near endless if you just like exploring
yeah and elite gives you 400 billion star systems lol
the amount put into said planets is what i care about xd
Last I checked you couldn't land in Elite
speed increase excluded perks are strength and fitness
Not anywhere interesting
this is why they can start at 3 but not recieve the boosts
Because they weren't done
well elites more of a sim of an accurate milky way
Only dust balls
like the star locations are accurate from 2014 starmaps then they used an algorithm to fill in the gaps
sprinting get's it's own caveat if you start with sprinting 1 though
In NMS you can literally take off a planet, fly through atmosphere into space, jump through a black hole to another solar system, fly down to a planet in that system, and land in a lush tropical rainforest.
with horizons non atmospheric landings were added, and they are some places like thargoid and guardian surface bases
local isSkillExcludedFrom = {}
---@param perk PerkFactory.Perk
function isSkillExcludedFrom.SpeedReduction(perk) return (perk == Perks.Sprinting or perk == Perks.Fitness or perk == Perks.Strength) end
---@param perk PerkFactory.Perk
function isSkillExcludedFrom.SpeedIncrease(perk) return (perk == Perks.Fitness or perk == Perks.Strength) end
with oddyssey there are surfaces with atmosphere, boots on the ground
What a strange thing to work differently in vanilla.
My worries with all the work you've now done is that it seems possible that it works.. Uh.. Worse is the wrong word, but it's less compatible with mods that change xp rates based on character creation skill levels.
but its still sparce
In NMS you can get inside of your mech, boost off the ground, and (with mods that enable more boost and flight energy for mechs), literally fly to another planet (or more realistically a planet's moon) in your mech.
10 votes and 13 comments so far on Reddit
but look at my FPS when on said surface base
I don't see how so
This would just flatten/cap the XP as if they didn't start with any added skills
Yeah that's why I chose NMS over Elite, I wanted a fuller experience of playing on the ground (in high FPS)
I usually play with a mod that changes the rates, so instead of: 0.25 > 1 > 1.33 > 1.66 it'd be 1 > 1.25 > 1.5 > 1.75 > 2 for example
Which mod is that?
Lemme find it.
fair, i just love the semi-accuracy of elite
and ive experienced its emptyness ive travelled to saggitarius A*
https://steamcommunity.com/sharedfiles/filedetails/?id=2827283808&searchtext=skill+xp+rate
I believe we used this.
That should have no impact
๐ฉ
https://www.youtube.com/watch?v=eImXhhBRa-4&t=683s @pseudo ermine
This video will show you how to build a No Man's Sky mod using the No Man's Sky Mod Builder.
This video uses scripts written for No Man's Sky Frontiers 3.67.
Mods are created using NMS Mod Builder 2.1.2 and MBIN Compiler 3.68.
Check out No Man's Sky Mod Builder today!
Links to the download pages you ...
Keep in mind the colors are heavily modded
it claims to be doing that - but I 'm pretty sure it's just rewarding more XP after the fact
nice xd
ive considered getting into modding but id probably just get rly stressed out
But yeah I need that lush planet experience or space sims not appealing to me
because i get extremely stressed with programming
I mean, it goes both ways. It can subtract xp ๐
If you do, just remember to be patient and mentally prepared to fail a lot before you succeed.
vents.AddXP.Add(function (gamechar, perk, xpAmount)
local perkLevel = gamechar:getPerkLevel(perk)
local boostLevel = gamechar:getXp():getPerkBoost(perk)
local mult = UxptMultiplierMath.skill(perk) * UxptMultiplierMath.actualBoost(perk, boostLevel) * UxptMultiplierMath.extra(perk, perkLevel)
local extraXP = xpAmount * (mult - 1)
if extraXP > 0 then
gamechar:getXp():AddXP(perk, extraXP, false, false, false)
end
end)
Also, following a good tutorial can save you a lot of energy and Q&A, and there are a couple pretty good ones available on YouTube.
fair
Huh, yeah. You're right.
id probably start with blade and sorcery
because modding in weapons seems incredibly user friendly with that
I imagine most people wouldn't bother decorating the original function
Hell yeah I have never played it
there's an addXP hook
from what ive seen its like importing a model and then defining edges and weights and grab points etc
which you can bypass in addXP
There are many weapon mods in PZ too so I imagine it is far from impossible, but that's not my expertise
so the journals don't interact with his mod at all
Anyone knows of a mod that adds more craftable melee weapons? (Not drops, just craftable)
hmm...
:>>>
I could add something here to account for his added/detracted XP
I'd have to test it more
just nice devs
anyway its stopped raining i gtg, british weather has given me 30 seconds to do bike maintinence while dry
o7
I think you're right that he only lets you get bonus XP.
I'm trying to think out what impact it could have
And yeah, that'd mean you're adding his XP on top of existing XP, though. So.. If you're making the XP values equal 0.25 mult, then his level 0+ multipliers would just be even more XP, no?
What I'd be targeting is lowering the boostmap calc to always be 0
which nets 0.25, yes
but then his added XP would be thrown on top
I think that would be fine(?)
is hook is ran after mystuff
I'm worried that you'll read his AddXP and record it separately ๐
@sour island @drifting stump helped me with the lock thing it now points to the floor by default
oh nice
I'd have to test it out honestly
UI.inventoryPane.inventory = UI.backpacks[#UI.backpacks].inventory
it could be that his mod would be netting alot more XP to the player but almost nothing in the journal lol
which is kind of good(?)
Potentially? 
well he calls addXP so that would be recorded too actually
I think it should be fine
My head is trying to figure out how I would want to do this exact same thing.
I have the pre-modifier XP recorded in my diary, same as you have with your new hook.
Now I just need to decide what drawbacks I'm willing to have.
Very tempted to simply use AddXP and let the modifiers do their magic when I'm reading the diary, but with a penalty like 20% per trait's difference. (Unless the trait is in some exception list, like Under/Overweight)
---perks boostMap based on career and starting traits
local xpBoostID = 0--pXP:getPerkBoost(perk)
local xpBoostMultiplier = 1
if xpBoostID == 0 and (not isSkillExcludedFrom.SpeedReduction(perk)) then xpBoostMultiplier = 0.25
--elseif xpBoostID == 1 and perk==Perks.Sprinting then xpBoostMultiplier = 1.25
--elseif xpBoostID == 1 then xpBoostMultiplier = 1
--elseif xpBoostID == 2 and (not isSkillExcludedFrom.SpeedIncrease(perk)) then xpBoostMultiplier = 1.33
--elseif xpBoostID == 3 and (not isSkillExcludedFrom.SpeedIncrease(perk)) then xpBoostMultiplier = 1.66
end
this is what I'm doing -- basically as with the vanilla -- sprinting/fitness/strength still get x1, everything gets x0.25
what's weird is sprinting is excluded from reductions but not increases
so I think fast learners can learn how to sprint faster but slow learners are fine lmao

probably an oversight, the XP code seems very old compared to other stuff
it also confirms that the isoGameCharacter is an isoPlayer before checking nutrition
so this code is probably as old as isoSurvivor
- the fact they don't identify skills based on combat parent for pacifist
if player:HasTrait("Pacifist") and (perk:getParent()==Perks.Combat or perk==Perks.Aiming) then traitMultiplier = 0.75 end
if (IsoGameCharacter.this.Traits.Pacifist.isSet()) {
if (var6.getType() != PerkFactory.Perks.SmallBlade && var6.getType() != PerkFactory.Perks.LongBlade && var6.getType() != PerkFactory.Perks.SmallBlunt && var6.getType() != PerkFactory.Perks.Spear && var6.getType() != PerkFactory.Perks.Maintenance && var6.getType() != PerkFactory.Perks.Blunt && var6.getType() != PerkFactory.Perks.Axe) {
if (var6.getType() == PerkFactory.Perks.Aiming) {
var9 *= 0.75F;
}
} else {
var9 *= 0.75F;
}
}
I don't remember the parents ever not being in game though
I've only been here in Build 41, so I ain't got a clue ๐
I was here before cars but everything is a blur
Only started modding at the start of covid
Love this game, and I'm glad the modding community seems to be growing again
U ancient god tier wizard
^Truth.
nah, I'm still learning
Well that's the one sure thing when doing any type of programming ๐
Can the uploader check if the poster is the default image and automatically set it to unlisted?
those settings mods make me want to bash my head in
why why did brita and arsenal think it was a good idea
it's an open barn door at this point - but Arsenal should have made the template version unlisted
afaik unlisted mods can still be downloaded
they can and anyone can see them they just need the link
doesnt show up in searches
I believe the game should have no issues grabbing updates either
Someone told me there isn't an issue writing into Lua/ so I wonder what issue I'm having and if it's the same modOptions has
My settings can be changed locally to work - but modOptions can't for some reason
Perhaps it'd be enough to just default to the mod being unlisted when uploading in Zomboid? Then opening the overlay to your mod afterward. You'll see the yellow banner at the top saying "HEYO UNLISTED BRUV"
Clarification: Keep the drop-down options or what we have now, just make the default selection not-public.
Perhaps with a disclaimer next to it - 'Unlisted can still be accessed for testing/downloads.'
I'll have to actually move that up the priority then - maybe it was fixed and I have been using an old/broken method
That might work. Only argument I've seen for keeping mods public is to add them to Collections for easier mod download? (E.g. a user can subscribe to a collection, then join the server later, instead of sitting on a semi-cryptic screen in Zomboid)
It's unclear if you can add an unlisted mod to a collection for me rn.
When you try to give yourself a lantern via item menu without reading:

server.lua
local car = addVehicleDebug(args.type, args.dir, nil, sq)
local carid = car:getID()
sendServerCommand("KYRPT", "getTrailer", {trailer = carid});
client.lua
local Commands = {};
Commands.KYRPT = {};
Commands.KYRPT.getTrailer = function(player, args)
print("it Fired")
local car = args.trailer;
end
local onServerCommand = function(module, command, args)
if Commands[module] and Commands[module][command] then
Commands[module][command](args)
end
end
Events.OnServerCommand.Add(onServerCommand)
why it error?
ERROR: General , 1672201348457> 58,528,300> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: attempted index: trailer of non-table: null at KahluaThread.tableget line:1689.
when if i do a print after setting vcarid it says 3
Your function expects two arguments and you're passing one
Commands.KYRPT.getTrailer, I mean. It expects player and args, so if you pass only one then args will be nil
oh son of a.
thank you.
forest through the trees and all.
sendServerCommand("KYRPT", "getTrailer", {player = player, trailer = carid});
hmmm same thing still.
Have you modified the code for onServerCommand?
Regardless of what you send via sendServerCommand, if you don't call the function with the correct number of arguments some of them will be nil
if Commands[module] and Commands[module][command] then
Commands[module][command](args)
end
end
that part?
it's an array. being passed as one
Mhm, so it's one value (confusing use of "value" here, I realize. I mean to say it's a single variable, not to imply that it isn't a reference type)
Unless you unpack it or otherwise get the player key out of it, it's going to be passed as one argument
I'd have to see it to answer that
Hey all, I've made a few custom zombies and I wanted to add loot to them. I've been looking at the code in TheyKnew and the UndeadSurvivor mod and I cannot for love nor money get it to work for my mod.
I don't fully understand how the code works so I may be missing something and was wondering if someone could explain what I'm doing wrong?
This is the code in question:
`function CheckDrops(zombie)
if not zombie:getOutfitName() then return false end
local outfit = tostring(zombie:getOutfitName());
local inv = zombie:getInventory();
if outfit == "Stalker" then
if 50 >= ZombRand(1, 100) then
inv:AddItems("Base.Maggots", 1);
end
if 30 >= ZombRand(1, 100) then
inv:AddItems("Base.Maggots", 1);
end
end`
I have created a file in the same location of my mod and tried the following:
`function CheckDrops(zombie)
if not zombie:getOutfitName() then return false end
local outfit = tostring(zombie:getOutfitName());
local inv = zombie:getInventory();
if outfit == "*My Zombie Outfit Name*" then
if 100 >= ZombRand(1, 100) then
inv:AddItems("Base.Hat_SantaHat", 1);
end
if 1 >= ZombRand(1, 100) then
inv:AddItems("Base.Hat_SantaHats", 1);
end
end`
I have my name of my outfit (which I know is working and spawning correctly) in place of My Zombie Outfit Name but no matter how many of that zombie I kill I never get a Santa hat (which I chose as a test item but have tried others). Can anyone identify what I am doing wrong?
What calls CheckDrops?
I have no idea, that's what I'm stuck with, this code if from a mod I was told to look at to figure out how to add loot to zombies, there are a few bits I don't understand at all as I've never used it
You may want to search through the mod you're comparing with to see what calls it, since the function won't run unless it's called
OnZombieDeath I think so
You're missing the line
Events.OnZombieDead.Add(CheckDrops);
```from the Undead Survivor example
Oh sorry, yeah the code is at the bottom Events.OnZombieDead.Add(CheckDrops);
This line hooks into the "OnZombieDead" event (which fires each time a zombie dies, naturally), and then adds the function named "CheckDrops".
Is that also in your code?
Events.OnZombieDead.Add(CheckDrops); is at the bottom of the file yeah, after the rest of the code
Okay, good. Did you place your lua file in media/lua/server/?
yeah
If you run the game with the -debug launch parameter and open a world with the mod enabled, could you press F11, scroll to your lua file in the lower-right corner view, click it, and then double click the line in your code that starts with if not zombie:getOufitName()? (It should change colour)
This sets a breakpoint, so the next time that code is fired, it'll open this view and we can debug from there. Go kill something to trigger it ๐
the zombie in OnZombieDead is not the body but the zombie before it dies btw
loot doesn't transfer unless it's a dead player
Does that mean Undead Survivor fails to put stuff in zeds' pockets? 
it may have set the zombies as undead players artificially with the boolean or probably yes and they add the loot elsewhere
zombies are very particular with loading/unloading it's kind of a pain but I had the same issue when adding loot for mine
I see nothing that indicates UndeadSurvivor does anything extra than what BigZombie is doing above, when I look through the UndeadSurvivor code. I wouldn't be too surprised if the UndeadSurvivor code had this bug.
This sounds like something far too complex for me, I guess my custom zombies will have to do without loot lol
I'm sure that it adds extra loot as I've seen zombies with fish and so on
You could just kill a few Headhunter type zombies and see if they drop M14 magazines.
hmmmm
I lied
---@param zombie IsoObject | IsoGameCharacter | IsoZombie
---@param player IsoObject | IsoGameCharacter | IsoPlayer
function eHelicopter_zombieAI.onDead_gottaGoFast(zombie, player, bodyPart, weapon)
if ZombRand(100) <= 25 then
zombie:getInventory():AddItems("Base.AlienPowerCells", ZombRand(1,4))
end
if ZombRand(1000) <= 1 then
zombie:getInventory():AddItem("Base.AlienBlaster")
end
end
---
Events.OnZombieDead.Add(eHelicopter_zombieAI.onDead)
I guess it does work
In that case, I'm not sure why it isn't working for BigZed ๐ฆ
Naw, they did both types of if statement, just in case.
the other is a 1/100 tho
Well, I mean, if 100 >= ZombRand(1, 100) is a 100% ๐
ZombRand produces numbers from a (inclusive) to b (exclusive) right? 100 is surely always larger than 99.
Also, my diary now gives XP, woo.
congrats
I should test my zombies...
I got pulled from my journal to fix something related to my shops
._.
I really wish I understood code better, I've managed to get by with most things but now I'm lost lol
How do you add the distribution for the outfit?
I'll confirm if mine spawn items
The outfit is done in the clothing.xml
And the distribution table?
I haven't added it to the distributions, the clothes are specific to a custom zombie
nevermind
They do the whole if outfit == "this outfit" thing for that ๐
Have you tried printing the outfit string
Zombies have specific loot based on outfit
Yeah my loot doesnt work
I copied the outfit from where it's defined in clothing which is what the Undead Survivor mod
Either my loot never worked or something was changed recently
If the stalker mod has maggots appear they probably do it in another way and never removed that one
None of them have any cells/guns
ah yeah distributions have a outfit section
it's probably handled in there
add prints everywhere inside that lua code to see what happens.
a start
b if success
???
I am lost at this point. All I know is I've been watching a streamer and the undead survivors tend to have extra loot when he kills them. I can't figure out how it's done
is he using the stalker mod?
there currently isn't a way to track the deadbody from the onDeadZombie event -- if you want more loot you'll have to add it to the loot distribution for that outfit
I don;t understand coding well enough to understand how to do that. Until now I've gotten by on trial and error lol
have you ever messed with distributions?
Yes but I use what I understand to be an old method. Because I learned mapping I make a room definition and create the following
SuburbsDistributions.petshop = { counter = { rolls = 2, items = { "Dogfood", 100, "DogChew", 70, } }, }
So I know that the room I set as petshop will spawn that loot in the counters.
As far as I'm aware this is a really old method but it's all I've ever needed.
I have also been given code to add items I've created to categories such as
`BZM.tab_addMagProcedural_Plushies = function(x,count)
ProceduralDistributions = ProceduralDistributions or {};
ProceduralDistributions.list = ProceduralDistributions.list or {};
ProceduralDistributions.list[x] = ProceduralDistributions.list[x] or {};
ProceduralDistributions.list[x].items = ProceduralDistributions.list[x].items or {};
table.insert(ProceduralDistributions.list[x].items,"BZMClothing.SpiffoDredd");
table.insert(ProceduralDistributions.list[x].items, count);
table.insert(ProceduralDistributions.list[x].items,"BZMClothing.SpiffoBatman");
table.insert(ProceduralDistributions.list[x].items, count);
end
BZM.tab_addMagProcedural_Plushies("GigamartToys",0.1)`
But again for me this was copy and paste, I never learned how it worked, just was told that it worked and when I've tested it in debug it shows in the possible loot
require "Items/Distributions"
Distributions.all.Outfit_AmbulanceDriver = {
rolls = 1,
items = {
"FirstAidKit", 2,
"Gloves_Surgical", 10,
"HandTorch", 8,
"Hat_SurgicalMask_Blue", 10,
},
junk = { rolls = 1, items = {} }
}
Outfits are listed under the all{}
this should inject this table inside safely
(FYI @brazen grove : You can use three backticks
```lua
like this
```
to create nice code blocks with lua formatting.)
ah cheers, I'm an old man, Discord is fairly new to me lol
What file did this come from? I'll go have a look, see if I can get something to work
require "Items/Distributions"
No worries, it's arcane knowledge sometimes ๐
cheers, I'll go have a look now ๐
Thanks, I';; make sure I do that and see how it goes ๐
The snippet I gave you is all you should need
Btw super weird helis has special zombies - if you wanted to see some tricks
Cheers, I''ll have a look anyway as my brain isn't very "normal", I'm a visual learner lol
Good thing we ran into eachother as I had no clue about my own zombie loot issue
Well I'm glad it helped haha. One thing I've learned about modding, you can have issues and no-one will tell you, you can also have perfectly working code and get a comment about how you broke their game and it's not even your mod lol
If you hate spam and have multiple outfits with the same loot:
require "Items/Distributions"
local alienOutfits = {"AlienTourist", "AlienRedneck", "AlienSanta", "AlienBeefo"}
for _,outfitID in pairs(alienOutfits) do
SuburbsDistributions.all["Outfit_"..outfitID] = {
rolls = 1,
items = {
"AlienPowerCells", 25,
"AlienPowerCells", 25,
"AlienPowerCells", 25,
"AlienPowerCells", 25,
"AlienBlaster", 1,
},
junk = { rolls = 1, items = {} }
}
end
Anyway I can check if someone is inside a building
but, he can too
SuburbsDistributions or [1]
Or to check if someone is typing
Note to self don't hit 'respawn all dead' when they're all sprinters
I just tried ```require "Items/Distributions"
Distributions.all.Monmouth_UnknownHost = {
rolls = 2,
items = {
"HockeyMask", 100,
"Hat_SantaHatGreen", 100,
"SpiffoTail", 100,
},
junk = { rolls = 1, items = {} }
}```
and no luck >.<
that's my bad Distributions should be SuburbsDistributions
also, I haven't gotten one to drop yet
lol
this is why I hate messing with distributions though
what's the caveat to junk vs items?
I recall something like junk ignores loot %
yeah idk, this is odd

SuburbsDistributions.all.Monmouth_UnknownHost = {
rolls = 2,
items = {
"HockeyMask", 99,
"Hat_SantaHatGreen", 50,
"SpiffoTail", 1,
},
junk = { rolls = 1, items = {} }
}```
No luck either :/
scratch that
if container:getType() == "inventorymale" or container:getType() == "inventoryfemale" then
local containerType = container:getType()
if container:getParent() ~= nil and instanceof(container:getParent(), "IsoDeadBody") then
containerType = container:getParent():getOutfitName()
end
if containerType ~= nil then
local containerDist = SuburbsDistributions["all"]["Outfit_" .. containerType]
if containerDist == nil then
containerDist = SuburbsDistributions["all"][container:getType()]
end
LootZedTool.SpawnItemChecker.containerType = containerType
LootZedTool.rollItem_CalcChances(containerDist, container, true, player, nil)
end
return
end
Yeah, I'm not sure why it's not spawning stuff
Do you also delete all the zombies around you when testing?
I know that that impacts loot spawn
Yeah I do, delete them all then only spawn in the custom one in batches
I'm going to move the items into junk
wait... that snippet is only in the lootzedtool
I don't see Outfit_ used anywhere else
it's in java java
var9 = (ItemPickerJava.ItemPickerContainer)((ItemPickerJava.ItemPickerRoom)rooms.get("all")).Containers.get("Outfit_" + var4);
๐ค very weird, not sure what about the % chance would warrant not being able to find anything
I just tried the Undead Survivor mod, spawned a bunch of nomads and they all have loads of extra loot on them ๐ฎ
and it's all the stuff in the OnDeathDistributions.lua >.<
I don't get how it works lol
weird
It definitely works on that mod, I cannot for love nor money figure out how though
let me rerun my original method
I've tested it over and over and it works, I just can't replicate it lol
heh
undead survivor has this
if getActivatedMods():contains("ExpandedHelicopterEvents") then
if 50 >= ZombRand(1, 100) then
inv:AddItems("EHE.ProteinBar", 1);
end
end
Yeah but I don't have ExandedHelicopterEvents installed and it works for me
I think that's just to add the protein bar into the loot pool if the mod is installed right?
Yeah, just thought it was funny
but yeah I can't seem to replicate the ...wait
god I'm dumb
?
"EHE.ProteinBar"
I transitioned all the items over to EHE/SWH a while back
Are your items Base?
I tried it with and without
@sour island have u ever made a guide ?
my issue was that I had Base.
@brazen grove go back to checkDrops and paste your entire file
oh wait, this means my distro issue was also from the fact I used Base
I deleted mine as it wasn't working but I can type it up again
guide for?
I have no idea what that is :/
modding
What are you programming with?
Notepadd++
No, I've never written a guide
So what they say about you on the streams is true
lmk when you have the draft - we can try to figure it out
What do they say?
Can't say with children around
What do you stream @brazen grove ?
(also I'm joking) but you should probably look into using something like VSC or intelliJ
I believe his a mapper
if you plan to dabble more with Lua
Nice save
Yeah I made a map, then I added things to that map, then Peach showed me how to 3D model so I've been learning that. I just try and learn as much as possible lol
Nice
Wow and now you will learn how to code?! You awsome man
but I am interested in what people have been saying...
It's mostly from unkH and how much he loves you
I only started mapping a year ago, 3d modelling I learned in a day with Peach but code... I'm a visual learner, code baffles me
also: https://github.com/Konijima/PZ-Libraries -- if you want something with some responsiveness
OHHHHH!!!! If it's UkH then it will be about how I troll him endlessly
Poor man still doesn't know what I've sent him for xmas
Nice
Funnily enough it's him that's caused me to try and figure this out as I'm making him as a zombie lol
Nice
Like his character a zed? In game?
Yeah, he's all made and ready to go, done his tattoo sleeve etc, just need to make the right items spawn on him now
function CheckDrops(zombie)
if not zombie:getOutfitName() then return false end
local outfit = tostring(zombie:getOutfitName());
local inv = zombie:getInventory();
if outfit == "*My Zombie Outfit Name*" then
if 100 >= ZombRand(1, 100) then
inv:AddItems("Base.Hat_SantaHat", 1);
end
if 1 >= ZombRand(1, 100) then
inv:AddItems("Base.Hat_SantaHats", 1);
end
end
is SantaHat vanilla? the green one?
How would I check if im inside a building?
I think so, I just looked up something uncommon to find to test it
it is vanilla, just thinking of possible issues
btw you have a typo in 'Hat_SantaHats'
and AddItem() can be used with out the second argument if you just want 1 anyway
I'll change the items once it works, I just wanted to get it working. Just going to test it again now
and you have the events call on the bottom under this?
function CheckDrops(zombie)
if not zombie:getOutfitName() then return false end
local outfit = tostring(zombie:getOutfitName())
local inv = zombie:getInventory()
print("Outfit: "..outfit)
if outfit == "Monmouth_UnknownHost" then
if 100 >= ZombRand(1, 100) then
inv:AddItem("Base.Hat_SantaHat")
end
if 1 >= ZombRand(1, 100) then
inv:AddItem("Base.Hat_SantaHat")
--inv:AddItems("Base.Hat_SantaHat", 2)
end
end
end
Events.OnZombieDead.Add(CheckDrops)
Try that, the print will tell you what the outfitID is just in case it's not what you think it is
you could something like
getPlayer():getSquare():getBuilding()
if not zombie:getOutfitName() then return false end
local outfit = tostring(zombie:getOutfitName());
local inv = zombie:getInventory();
if outfit == "Monmouth_UnknownHost" then
if 100 >= ZombRand(1, 100) then
inv:AddItems("Base.Hat_SantaHat", 1);
end
if 1 >= ZombRand(1, 100) then
inv:AddItems("Base.Hat_SantaHats", 1);
end
if 50 >= ZombRand(1, 100) then
inv:AddItems("Base.Hat_SantaHats", 1);
end
end
Events.OnZombieDead.Add(CheckDrops)```
I used that code and it still didn't work :/
try adding the print
think I said that an hour ago
yeah, my bad
my code was scuffed for a different reason - so I assumed undead was too
which taught me how to add loot to body distros so that's a plus
chances are the outfitID is something else
isn't isInARoom() a thing?
check javadocs
I've tried the code you posted and still no santa hat, where do I need to look now?
what prints do you get
so that should work for checking if someone is in a room
or will only check for actual rooms
I don't know where I'm looking for them
don't get me wrong i am still learning... a lot. also an art person learning code ๐
If you run the game with -debug in launch options you'll see an outputwindow
otherwise they're in the console.txt - in /users/BZM/Zomboid/
Also, if this is a mod that's already published - you need to unsubscribe from it
Otherwise the game will be using that version
Oh I know that, I never sub to it, just run off the workshop one
That's the console log but I'm not sure what I'm looking for
when you want to know about java you have 3 options, find someone who already does what you want or check what they do in-game or decompile the code and read
After you killed a zombie it would print out 'Outfit: n'
assuming that's what the print says
fair enough ๐ ty
It wasn't showing in the debug box, just the damage I did to the zombie etc
SEVERE: Error found in LUA file: C:/Users/bigzo/Zomboid/Workshop/Monmouth County/Contents/mods/Monmouth County/media/lua/server/Monmouth_OnDeathDistribution.lua
ERROR: General , 1672247557439> ExceptionLogger.logException> Exception thrown se.krka.kahlua.vm.KahluaException: Monmouth_OnDeathDistribution.lua:19: 'end' expected (to close 'function' at line 3) near `<eof>` at LexState.lexerror line:278.
ERROR: General , 1672247557439> DebugLogStream.printException> Stack trace:
se.krka.kahlua.vm.KahluaException: Monmouth_OnDeathDistribution.lua:19: 'end' expected (to close 'function' at line 3) near `<eof>`
you dropped this
end
I'm so confused, I copied the one I've quoted so is it saying I need to remove the end before events. etc
I changed mine, as I copied yours from before
it was missing an end at the end
should be three ends
OK I've added that and will try again >.<
I don't suppose notepad++ has any sort of syntax highlighting?
it has some but sometimes it confuses me more than it helps.
it doesn't have a warning/error for missing an end or )/}?
any errors in console?
How would I be able to check if someone is visible?
I can't find any stack trace's but I don't know what I'm looking for
Wait
do you have undead survivors also installed?
your function is global
you might be overwriting yourself
local function CheckDrops(zombie)
if not zombie:getOutfitName() then return false end
local outfit = tostring(zombie:getOutfitName())
local inv = zombie:getInventory()
print("Outfit: "..outfit)
if outfit == "Monmouth_UnknownHost" then
if 100 >= ZombRand(1, 100) then
inv:AddItem("Base.Hat_SantaHat")
end
if 1 >= ZombRand(1, 100) then
inv:AddItem("Base.Hat_SantaHat")
--inv:AddItems("Base.Hat_SantaHat", 2)
end
end
end
Events.OnZombieDead.Add(CheckDrops)
simply add a local before function
OK I'll try that in a sec, I have it installed but not active
then that wasn't the issue, weird it's not showing up in the loaded files
Still not working. I'll try changing it to local
Unless there's another CheckDrops somewhere it shouldn't matter
Well....
added that local and all of a sudden, santa hats :/
I guess I have something using checkdrops already? lol
If the file is working it will appear here, if you are in debug mode
most likely you have another version of it somewhere?
intelliJ also lets you search all files within a project
not to keep hyping it up
Downloading this now ๐
๐
https://github.com/Konijima/PZ-Libraries on how to set up the libraries - has a slew of other features
auto-completion for Lua functions - class lookup etc
I appreciate all the help man, I'm going to go add the items I want to spawn on and my xmas present just got delivered so I have an RC car to play with lol
a bomb that makes zombies dance
idk man that sounds like fortnite but it'll be funny to watch hordes of zombies dance to california while half of the hoard mauls you down
I was just about to say are you a Fortnite player lol
Make en dance like thriller
quick quick i need a script to grab all players with a moddata on them! ggoogogogogogogo
also, we need a "helpful snippets" sub channel.
Im new to this, is there a list of all the functions/commands you can use? All the mods I'm studying, they have commands that will pull the the temperature, or the players health etc. How do you know what commands do all this or it's documented somewhere?
there's a java doc online but I personally use https://github.com/Konijima/PZ-Libraries
ah cool thanks
Let's you use a lookup
you do need to know some of the classes - in this case the descript and nutrition are under isogamecharacter
interesting, i see
I remember asking about that some time ago, but the staff flatly refused
weeak
honestly, I can't understand why, imagine you need a snippet to get all players, you just go to search bar and you will find all snippet related with that
I'mma try and get one added to the... OTHER modding discord lol.
IKR!
that's what i am looking for.
what's the other server with blackjack and snippets?
dm'd
I think the snippets were all on the pinned comments
but it became unwieldy
this was before #threads tho
Does anyone know why a part of a vehicle can cause warnings? I get this error only with the trunk of a vehicle that creates, and with no other part.
https://media.discordapp.net/attachments/1053916410503512074/1057459571754537060/Untitled.png
I tried looking in the .class files, but I don't have decompilers to open those files.
hahah restart the game.
you messed up while editing it.
it got mad.
that means reboot.
If a function is added into Events.X.Add() is it a reference or a copy?
Can I change X later?
reference
yep, the issue was on my end
Hi guys, can someone tell me what's wrong with this code?
TraitFactory.addTrait("sanctuarytrait", getText("UI_trait_Sanctuary"), 20, getText("UI_trait_Sanctuarydesc"), false);
end
Events.OnGameBoot.Add(SanctTraits);```
For some reason, with only this, the server get the "CFileWriterThread" error and dont startup
Hi all . I have a Pb on a pz mod in development. I spawn a unique bag type object at world creation. There should only be one. This bag has an unlimited capacity and a weight close to zero. The player can thus place it where he wishes. it will serve as a "base" or "shop" . I can then add items (weapons etc) in this bag according to the actions of the players. It all works very well. My problem now. The bag object is saved in a variable named TBAG when it is created. This variable is erased each time the game is restarted or the player dies and recreates a new character.
How to store, save the bag object in lua and find it when we launch the game again (continue game)? Please can you send me some sample code or point me in the right direction...
so hey, about that chunka code i was hunting...
quick quick i need a script to grab all players with a moddata on them! ggoogogogogogogo
you are all slow and i had to write this... monstrosity to appease myself.
there are villagers at my door with pitchforks.
you must write your own util functions from scratch to earn the veteran badge
there's 12 in all
bruuuuuuuuh i have like 28 tiny little shits.
i even wrote a tiny little shit to HELP ANOTHER TINY LITTLE SHIT.
-- Maffs Halp
function math.sign(v)
return (v >= 0 and 1) or -1
end
function math.round(v, bracket)
bracket = bracket or 1
return math.floor(v/bracket + math.sign(v) * 0.5) * bracket
end```
see?
and that's just to be able to round numbers!
why can't you just add 0.5 to floor?
i wanted to be able to say math.round(v,.0005); and it round it to the ten thousandths.
MWAHAHAHAHAHAHAHA
now the REAL question.,... does car:getID() STAY as car id?
declaration: package: zombie.vehicles, class: BaseVehicle
i basically need a way to track a VERY specific vehicle without the joy of moddata.
with moddata i could just staple the job id on and be done.
but NOOOOOO vehicles can't DO moddata
Is there a list anywhere of all the anim nodes for recipes?
anyways i 'm adding my snipplets to the other discord
Is there any way to do x number of or are we forced to use one of in recipes?
Lead00Buck/Improvised00Buck=9,
Was hoping that would work, but I don't think it will.
hey @sour island you down for a cleanup pass on something?
just a driveby comment to point out that moddata does work on vehicles
since in lua tables are passed by reference
local function insertValueInSleepTable(value, table)
table.insert(table, 1, value)
if #table > 100 then
table.remove(table)
end
end
local modData = player:getModData().DynamicTraitsWorld.SleepSystem;
insertValueInSleepTable(5, modData.Last100PreferredHour)```
will something like this work?
modData looks like this
```lua
player:getModData().DynamicTraitsWorld = player:getModData().DynamicTraitsWorld or {};
local modData = player:getModData().DynamicTraitsWorld
modData.SleepSystem = modData.SleepSystem or {};
modData.SleepSystem.Last100PreferredHour = modData.SleepSystem.Last100PreferredHour or {};
like It'll remove element from moddata table, right?
don't use .remove()
- why?
- what to use instead?
- I tried looking for a snarky thing online, but it reindexes every index - you might as well run table.insert() for every entry
- depends on the table but you can just
nilkeyed entries
if your keys are numeric then you'll have to figure that one out - it's one of the 12 util functions every modder writes
i really dont need keys here
I just need to store 100 numbers
in order in which I write them
unless Im misunderstanding usage of keys
if your keys are not in numeric order then the order is not accurate
which as far as I understand are pretty much good to find stuff in your table by, well, specific key
one of the weird things about Lua
this lua bullshit is getting on my nerves, why couldn't they just make non-keyed tables work fine
If u dont use .remove
U use= nil instead?

you can use nil as is if the key isn't numeric
I have a safe(r) table remove
I can clean it up
what is the condition for removing them?
literally jsut oldest one
so first?
so I suggest you stick the newest in first
if you nil the last entry the entry is cleanly removed
if you nil something with entries after it the entry stay there as a nil
what I was going to give you literally slides the entries over -- and it's less intensive than remove
local function insertValueInSleepTable(value, table)
table.insert(table, 1, value)
if #table > 100 then
table[101] = nil;
end
end
local modData = player:getModData().DynamicTraitsWorld.SleepSystem;
insertValueInSleepTable(5, modData.Last100PreferredHour)```
?
yes, that works
he is, i just took imporant lines
Got it
thx for help
There's no way to get intellisense/code completion into an IDE for this right? There's no SDK or anything?
best shit ever
---needs to be numerically ordered list
local function softRemove(tbl)
local tblLen = #tbl
--clear entries that are too far
for i=1, tblLen do
if CONDITION then
tbl[i] = nil
end
end
--prepare new index for table
local newIndex = 0
--iterate through and overwrite nil entries
for i=1, tblLen do
if tbl[i]~=nil then
newIndex = newIndex+1
tbl[newIndex]=tbl[i]
end
end
--cut off end of list based on newIndex
for i=newIndex+1, tblLen do
tbl[i]=nil
end
end
Thank christ, I thought I was going to have to do this blind
This is what I use for EHE targeting lists
I don't know if there's something already in vanilla that does this
I wish discord would have "personal pins" functionality where you can pin things for yourself
but apparently it's less costly than table.remove()
Removing entry from table is smort way
#musicmaniacpins
fuck
there, personal pin achieved

then just ctrl+f for it

Hey, so I'm really new to this, and I want to create a trait that causes you to take damage when you're outside during the day time
I've got my trait available to select in-game but I can't figure out how to actually code the functionality
This is what I would like to happen, a very basic thing I just wrote
if player isOutside and CurrentTime >=09:00 then getMinDamage
Totally sure none of that is in the correct format, but that's the gist of it, any pointers - even to guides would be appreciated
Once I get that working I'll look into getting the moodle added but I just wanted the basic functionality first
is that pseudocode of what you have or is that general gist of what you figured what you need so far?
A general gist, but I need the time to be between 09:00 and 20:00, so greater that 9, but less that 20:00
local function vampireTrait()
local player = getPlayer();
local timeOfDay = getGameTime():getTimeOfDay();
if timeOfDay > 9 and timeOfDay < 22 and player:isOutside() then
-- take damage here, havent looked much into it but you should look in bodydamage in javadoc
end
end
Events.EveryTenMinutes.Add(vampireTrait)
probably here
ctrl+f for damage, alternatively look through list up here see what probably can be used to deal damage
or wait for someone to help with that. Havent done much bodydamage myself so idk
if you want trait to work every minute use EveryOneMinute
Ok all that is amazing, thank you ๐
generally i'd recommend everyminute for what you trying to do
or Health, ctrl+f for one of those 2
lele there's literally AddDamage
public void AddDamage(int int1,
float float1)
Is there a mod that adds more stuff to build?
Unsure if this was just for the sake of example, but something worth noting is that your local table parameter will shadow the global table which contains insert (i.e., table.insert)
uh?
So you should either rename the parameter or keep a reference to insert (or the global table)
arent passed args local?
They are, I'm saying the second arg will shadow the table in the global scope
Not dumb, I'm just not explaining well ๐
shadowing is when you use the same name for a local variable that a global variable has, thereby blocking your access to the global
The table variable that contains insert, remove, etc. is in the global scope. By naming a parameter table, you are shadowing it, which anonymous explained above
I do cuz i wanna use global .insert
Mhm
Gotcha
cheers
local function insertValueInSleepTable(value, tableToInsertInto)
table.insert(tableToInsertInto, 1, value)
if #tableToInsertInto > 100 then
tableToInsertInto[101] = nil;
end
end```
so dis good, right?
Yup, looks good. I wonder why you aren't just returning early to block inserts above 100 rather than undoing them, though
Ohh, gotcha
thx
Anyone knows why @sour island's Shops & Traders mod won't show anything when I hover "Shops"?
p. sure inserting at 1 means the code has to go and redo all the keys in the table, I would probably just implement a ring buffer for something like that

redoing keys == reshuffling table or extra processing time?
< my brainscan btw
cuz honestly as long as it doesnt reshuffle im fine with milisecond of extra processing time
since you're capping it at 100 it probably doesn't add too much time, but of course it has to reshuffle
Since it's 100 elements to move at most it's not that big of a deal (ninja'd), but I agree w Anonymous that it could be improved
It's not shuffled, it's moving each element by 1
ah
which is shuffling, lol
ye then its fine, its small table
I guess we mean different things
Ya, understood as random shuffle
shifting != shuffling
Technically it is a shuffle, but everyone uses shuffle to imply randomness
Denotation vs connotation
ah
shifting is a subset of shuffling
either way, as long as you're not doing this every tick, its probably fine
ya
inserting at 1 is also costly?
would the thing I gave him be better than inserting at 1?
also I think I got a working reverse engineer XP calculation
costly as in O(n), once every 10 minutes with n = 100 doesn't matter
I mean from my moddata names it's quite understandable what kind of mod im making, but either way I came up with cool way to dynamically ear/lose More/Less sleep traits. Every sleep that player takes I mark midpoint, then I count last 100 midpoints averages which is this player preferred sleep schedule (aka when they are used to sleep), then if they sleep withing +-6h of that midpoint it counts for them upkeeping their schedule, if they sleep outside of it, it counts against it. So that way you can shift your schedule and for example sleep between 13-23h marks and stil keep the earned trait cuz your body adjusted to it
pretty cool stuff I think
neat
Anyone have any idea why my mod textures aren't reloading ingame? I'm in debug and all that but swapping out the texture PNGs doesn't go "live" until I restart the game. Needless to say this is really tossing a wrench in my workflow.
Is there some option I need to enable (or disable)? Some setting in the mod itself?
Prob PZ limitation
I haven't had luck getting it to be consistent ingame either. Just restart all the time.
It can reload lua files from debug menu like 80% of the time so hoping for textures idk man xd
Blech. I wish there was a way to edit textures on-model without needing to boot the game every time...
Change pixel > reboot game > needs to be a diff pixel > reboot game
Turns a small retexture into a whole day's work
Yea, I messed with textures on one item for 3 hours last night.
But tbf I had a rare bug caused by an image that was too large. Make sure your image sizes are correct.
They should be, they're drawn directly on the OG textures.
Good. I tried to put an icon in that was like 3x larger than it should have been and it caused my item to not have the "grab" context action
took forever to find the cause
At least knowing that everyone else is suffering and it isn't just me helps a little
Same
It's especially frustrating because the textures aren't consistently UV mapped, so one pixel somewhere will get stretched out like crazy to wrap around an arm or something
Doing something as simple as "draw a straight line across the skirt hem" is nigh impossible
That's rough
c'est la vie
@agile vigil https://pastebin.com/tgDJb7Hg reverse engineered XP calcs - seems to work
Now I can decide what gets stored
function doStashSpawn()
local sx = math.floor(getPlayer():getX())
local sy = math.floor(getPlayer():getY())
local sz = getPlayer():getZ()
local cs = getPlayer():getCurrentSquare()
local cell = getCell():getGridSquare(sx+(ZombRand(-15,15)), sy+(ZombRand(-15,15)), sz);
local stash = IsoThumpable.new(cell, cs, "location_community_cemetary_01_43", false,
ISDoubleTileFurniture:new("Crate", "location_community_cemetary_01_43", "location_community_cemetary_01_43"));
stash:setIsContainer(true);
stash:getContainer():setType("Crate");
local maxSpawnItem = SandboxVars.SES.scMaxSpawn
local rollSpawn = ZombRand(1, maxSpawnItem)
for i = 1, rollSpawn do
local spawnables = getScriptManager():getAllItems()
local itemPicked = spawnables:get(ZombRand(1, #spawnables))
stash:getContainer():AddItems(itemPicked:getFullType(), 1);
cell:AddTileObject(stash);
if isClient() then stash:transmitCompleteItemToServer(); end
end
getPlayerLoot(0):refreshBackpacks()
getPlayerInventory(0):refreshBackpacks()
end
local function StashAndCorpseSpawn()
local StashSpawnChance = SandboxVars.SES.scChanceStash
local CorpseSpawnChance = SandboxVars.SES.scChanceCorpse
if ZombRand(1, 1000) <= StashSpawnChance then doStashSpawn() end
if ZombRand(1, 1000) <= CorpseSpawnChance then doCorpseSpawn() end
end
Events.OnPlayerMove.Add(StashAndCorpseSpawn)
will this work?
Do you recall if your build finished with a bunch of warnings?
Yea, I did that first thing
and guide is for 2022 so i was just like "fuck it i'll just reinstall"
But I got failed/skipped annotations, and "WARN: Unable to find mod.info file"
I couldn't find the exact SDK
just make sure you follow all steps and try again thats all i can say
I got 17.0.5 but they used 17.0.3 openjdk
i use other jdk as well
Hm, are you sure you just didn't notice the warnings?
at which step
A few of them - particularly the annotate step and the mod.info warning is in setupworkspace
huh?
I guess that particular warning shows in all of them
C
did u not get this?
Yea, I did ultimately.
well i minimized my shit so i jsut waited until i got that
Aight it's probably fine.
maybe i did get warnings idk
First time using tools like this so I just don't know what's normal.


is ... is it working?
yes
had to do some magic with hours
how can I send like a snippet which you can expand
seen ppl do it in discord
maybe this?
nice
whole system ^
spent last 10 min making it properly calculate average betweem 21pm and 4am cuz it was giving like 12am as an answer

cuz well yaknow (21+4)/2 is 12.5
thought i accounted for that in find midpoint
but was missing that last bit
if midPoint <= 6 then midPoint = midPoint + 24 end
now just need to add passive negative ticking to SleepHeathiness if players are awake for more than 20h and all done
pretty cool, huh
gotta do few more tetsts see if it does everything correctly
is there a way to check modData from debug mode?
like the table
i know that when it throws error you can go dig around in last called variables, including tables
but without that
fully works, both when you sleep thorough midnight (so your starting hour is higher than your end hour) and through the day, when starting hour is lower than end hour
well this was fun
code would look so much cleaner if i didnt have those loggers in but I kinda want to leave them in if I need them again
like in 29 lines i have 10 ofthem being commented out as loggers 
gimme that code a second
^
except there was + 24 missing in 1 place
I cleaned it up a bit actually
lemme send fresh one
ah, local currentPreferredTargetHour = calculateAverage(modData.Last100PreferredHour); should be in the body of main function
actually it'd be less demanding to keep it in both ifs
than to do calculations every 10 min
then i only count it when player is sleeping or after they finished sleeping
local function sleepSystem()
local player = getPlayer();
local modData = player:getModData().DynamicTraitsWorld.SleepSystem;
local timeOfDay = getGameTime():getTimeOfDay();
local currentPreferredTargetHour = calculateAverage(modData.Last100PreferredHour);
local lowerBoundary = calculateTime(currentPreferredTargetHour, -6);
local upperBoundary = calculateTime(currentPreferredTargetHour, 6);
--print("DTW Logger: Time of Day: "..timeOfDay);
--print("DTW Logger: Boundaries L:"..lowerBoundary.." and U:"..upperBoundary);
if player:isAsleep() then
if modData.CurrentlySleeping == false then
modData.WentToSleepAt = timeOfDay;
modData.CurrentlySleeping = true;
end
local SleepHealthiness = ((timeOfDay > lowerBoundary or timeOfDay < upperBoundary) and 200) or -200
modData.SleepHealthinessBar = math.min(SleepHealthiness, modData.SleepHealthinessBar + 1 / 6);
print("DTW Logger: Between boundaries of "..lowerBoundary.." and "..upperBoundary);
print("DTW Logger: SleepHealthinessBar ".. modData.SleepHealthinessBar);
end
if not player:isAsleep() and modData.CurrentlySleeping == true then
local time = ((modData.WentToSleepAt > timeOfDay and 24) or 0) + timeOfDay
print("DTW Logger: old currentPreferredTargetHour: "..currentPreferredTargetHour)
print("DTW Logger: findMidpoint("..modData.WentToSleepAt..", "..time..")="..findMidpoint(modData.WentToSleepAt, time));
insertValueInSleepTable(findMidpoint(modData.WentToSleepAt, timeOfDay), modData.Last100PreferredHour);
print("DTW Logger: new currentPreferredTargetHour: "..calculateAverage(modData.Last100PreferredHour));
modData.CurrentlySleeping = false;
end
end
does this help
I can redo it on the newer one
na, no need, but thanks ๐
I use those myself sometimes
but on much smaller statements where it's easier to understand without having to think about it for X seconds
I am new to modding. I am trying to run a basic Lua in the following directory:
C:\Users\ghoul\Zomboid\mods\mymod\media\lua
I've enabled the mod but when I play the game nothing happens.
What could be the issue I am having?
Below is the code in my lua file:
local function EveryTenMinutes()
-- Java: we get the first player
local player = getSpecificPlayer(0);
-- Java: let the player speak
player:Say("I like turtles.");
end
Events.EveryTenMinutes.Add(EveryTenMinutes)
for example
local rainProtection = (primaryItem and primaryItem:isProtectFromRainWhileEquipped()) or (secondaryItem and secondaryItem:isProtectFromRainWhileEquipped());
local rainGain = rainIntensity * (rainProtection and 0.5 or 1);
btw there's an issue
currentPreferredTargetHour is cut off from it's define
purple means global
also it's not just about combining ifs, makes it easier to change later/maintain with out having to jump around
ye but then i have to figure out later what was in those ifs
its much easier to read 2 ifs
to me at least
a bit more inconvenient, I agree
I can see that - that's also why I include extra ()s
helps me keep track of OOP at a glance
also this is not correct
local SleepHealthiness = ((timeOfDay > lowerBoundary or timeOfDay < upperBoundary) and 200) or -200
did I get it backwards?
oh wait no i missed next line
yea no I definitely prefer upper combination to be unfolded
local time = ((modData.WentToSleepAt > timeOfDay and 24) or 0) + timeOfDay this one is short and simple
local X = ((true) and 200) or -200
it takes some getting used to for sure
That code looks right to me. Under media/lua you usually have client, server and shared folders - try creating say client and moving your turtles lua file into it?
anyway 4 am, gn all ๐
nope
Thanks I will try it
local timeInBoundaries = timeOfDay > lowerBoundary or timeOfDay < upperBoundary
local SleepHealthiness = (timeInBoundaries and 200) or -200
modData.SleepHealthinessBar = math.min(SleepHealthiness, modData.SleepHealthinessBar + 1 / 6);
```might be easier to read
cuz my time can be between 0 and 30
eh, im not sure i can even explain it honestly
it works

if u wanna toy with it and see for yourself, can send the thing with all the extra functions it calls

really don't wanna deal with people up in arms over it behaving differently lol
One of must-have mods getting update? Sign me in, chief
might add a sandbox to allow for career XP to be transcribed
also need to still write out the TV tracking
I have the framework laid out
that's just same as setting free trait points to 100
oh, not the starting skills, never
ah
I mean the bonus you get to XP earned

right now when you transcribe you get the XP you've earned recorded as if it were flat
oh
but like any starting points over 0 nets a % bonus
I translated the XP bonus math into Lua - so I can now decide what gets transcribed lol
alrighty, same for me actually
Also to hype this up
and to keep me on it too
Need to work on the license stuff so it's on the up and up
anyone knows what table the zombie distro is
For dead bodies?
zombie bistro?
Can the ContextMenu files have new entries added "a la carte," or does the whole file need to be overwritten?
Anyone got a mod that can give u skills etc. Shooting, carpentry, farming
You can add your own callback to the OnFillInventoryObjectContextMenu or OnFillWorldObjectContextMenu events, and add your option(s) to the context. This is how it works in RV Interior to add the "Exit" option when right-clicking in the world inside a vehicle interior:
local function onPlayerSelectExit(player)
sendClientCommand(player, "RVInterior","clientStartExitInterior", {})
end
local function addExitOption(playerId, context)
local player = getSpecificPlayer(playerId)
if RVInterior.playerInsideInterior(player) then
context:addOption(getText("UI_exitrvinterior"), player, onPlayerSelectExit)
end
end
Events.OnFillWorldObjectContextMenu.Add(addExitOption)
Thanks!
anyone made a function that spawns a tile server side?
like theres no client?
i thought you already have that function
if isClient() then skizotsTile:transmitCompleteItemToServer(); end
and my server has 48 of the signs stacked on each other.
object:transmitCompleteItemToServer() you mena THIS
which i have. and does shit.
If you can create an object you could make a command
Client -> server, then transmit back
and THAT is what i am asking for lol.
That is if there isn't a vanilla function already like the one Glytcher mentioned
I'm not at my PC atm but commands are kind of tedious
Have you made one before?
the one i am USING is client side and i cannot for the life of me get the dumb server to spawn one. so that it stays put.
are fishing nets visible in mp?
local grid = getCell():getGridSquare(x, y, z);
local net = IsoObject.new(grid, sprite, "FishingNet");
grid:AddTileObject(net)
net:transmitCompleteItemToServer();
``` this is how the do it.
Is your sign an isoObject?
it's a tile in the tilesheet lol.
local sname = tileSpawn.Tile
local object = IsoObject.new(sq,sname)
sq:AddSpecialObject(object);
object:getSprite():setName(sname);
local signData = object:getModData();
signData.loc = tileSpawn.loc;
object:transmitCompleteItemToServer()
object:transmitModData()
``` my current spawning method.
i THINK that is what i had at first. but hey i'll give it at hrow.
What's the difference between a "tile object" and a "special object"? I can see that IsoGridSquare has methods to AddSpecialObject and AddTileObject, and that the IsoGenerator calls tile.AddSpecialObject...
(I'm also trying to spawn an IsoObject and have it actually save/persist, and likewise having no luck)
lol
anyone knows what table the zombie distro is
yeah that didn't work either :/
ClothingSelectionDefinitions?
imean if they die and the stuff with em
@faint jewel there's another method IsoGridSquare.transmitAddObjectToSquare(object, number), but that appears to just be calling AddTileObject followed by either transmitCompleteItemToServer or transmitCompleteItemToClients, depending on whether it's client- or server-side.
For what it's worth.
i might have just accomplished it!
What worked?
well I had to fix some old code.
so now... WE TEST!
nvm.
no sign at all now.
le sigh
stupid variable
okay so it spawns... but it does NOT stay.
but it's gotta be spawning something or there wouldn't be all those damned mod datas.
How would I make an object that gives combat skill experience when hit with a weapon?
I'm trying to make a training dummy
wtf does getCell():setDrag(cursor,0) do?
That ought to be cool
I believe thats when u drag icons
I sure hope so, I just can't find any info anywhere on that sort of thing
Right now I'm just looking through the code of other mods that add world objects to see if I can piece something together
I'd guess a start would be to make an object which is an IsoThumpable, which I believe will generate the event OnWeaponHitThumpable when it's hit by a weapon.
Looks like there are 3 parameters passed to the event callback: the IsoGameCharacter who hit the thumpable (could be a zombie or a player or...), the HandWeapon which was used to hit it, and the IsoThumpable itself.
I would probably use the HandWeapon, so that I can make it give experience to whatever skill that weapon is tied to
Does VSCode have libraries for PZ? I know IntelliJ has some but I'd prefer to not have to download another IDE
You'd want to check the 3rd parameter first, to see if it was your training dummy object (because every thumpable in the world will generate that same event when it's hit)
anyone know of a mod that spawns tiles that aren't MAP based.
i just wanna drop a tile and have the server acknowledge it
I got my Metal Drum spawning and persisting, if that's of interest. My problem turned out to be not that it wasn't persisting, but that I was creating it incorrectly, so I was getting a pile of invalid objects but my code to check whether the square had a metal drum already wasn't finding one.
I ended up doing this:
local object = ISMetalDrum:new(nil, "crafted_01_29")
object:create(square:getX(), square:getY(), square:getZ(), false, "crafted_01_29")
square:transmitAddObjectToSquare(object.javaObject, -1)
That's somewhat specific to metal drums, but the trick that might be useful is fishing out the javaObject from the returned Lua object to pass to square:transmitAddObjectToSquare
huh?
Well, that's an IsoObject (or an IsoThumpable actually) rather than a tile, so I don't know how relevant it is for you.
ISMetalDrum is an object defined by PZ in lua/server/MetalDrum/BuildingObjects/ISMetalDrum.lua
well shit.
What's the item name of the mall sign?
well i created my own.
and there's two variations
tileSpawn.Tile = that's what feeds in the name.
So I guess that you'd create the object directly using something like IsoThumpable.new(getCell(), square, "your_sprite_name")?
How are you creating it in Lua at the moment?
local sname = tileSpawn.Tile
--this spawns the tile, and pdes not work.
local grid = getCell():getGridSquare(x, y, z);
local sign = IsoObject.new(grid, tileSpawn.Tile, tileSpawn.Tile);
grid:AddTileObject(sign)
sign:transmitCompleteItemToServer();
-- this transmits the mod data. and works.
local signData = sign:getModData();
signData.loc = tileSpawn.loc;
sign:transmitModData()
local object = ISMetalDrum:new(nil, sname)
object:create(x, y, z, false, sname)
sq:transmitAddObjectToSquare(object.javaObject, -1)
--local object = IsoObject.new(sq,sname)
--sq:AddTileObject(object);
--object:getSprite():setName(sname);
--tileSpawn.spawned = true;
--table.remove(JobBoardTileSpawns.toSpawn, i);
``` throwing all the code i can find at it XD
So the ISMetalDrum javaObject is just created by something like the IsoObject.new call you already have (it's created IsoThumpable.new).
local cell = getWorld():getCell();
self.sq = cell:getGridSquare(x, y, z);
self.javaObject = IsoThumpable.new(cell, self.sq, sprite, north, self);
that's it?
It does a bunch of other stuff too, setting maxhealth and break sounds and waterMax and things. I don't know how much of the other stuff is relevant though.
i just need to make a collideable object that the server remembers.
Does the drum in your code above get remembered, but the sign doesn't?
local sq = getCell():getGridSquare(x, y, z);
local sign = IsoThumpable.new(getCell(), sq, sname, false, ISSimpleFurniture:new("Job Board", sname, sname));
sign:setIsContainer(false);
sign:setCanPassThrough(false);
sign:setIsDismantable(false);
sq:AddTileObject(sign);
if isClient() then
sign:transmitCompleteItemToServer();
end
triggerEvent("OnObjectAdded", sign)
``` this aint work either.
Okay, dumb question I know, but how do I code a thumpable?
@vast pilot
not sure what you want, but literally the message above
that didn't work though polty.
So- For my drug mod, I am looking to add some additional traits that represent the really harsh, irreversible side effects of drug abuse. Anyone have any solid traits ideas?
it spawns them locally but NOT on the server.
Is that bc of the isClient() condition?
Could you run the code to create the sign on the server side instead?
I am sure you'll find somebody to fix it ๐
Hey guys,I've been working on getting my mod to work on multiplayer and since there are very little resources on that topic I have a few questions. isClient() / isServer() What these methods do is clear, however when I call isClient() in a file that is located in shared it returns false althought...
This seems to be related to the issue
"However you must be aware that if you modify the moddata of an object client side, it is not modified server side. IS added methods to sync client/server object like sendObjectChange or transmitModData but these methods are not universally supported by every class.
So whenever you modify moddata on client side and rely on it on server side you will have to send a client command and modify it on the server."
I don't know much about the custom-item-definition-and-sprites side of things, as I've mostly been doing code, sorry. If you wanted to spawn the training dummy from code, then something like Skizot's snippet would be a start... you call IsoThumpable.new with the cell, square, sprite name, "north" parameter (?) and a Lua object which wraps the IsoThumpable Java object. But you'd probably want to make a custom piece of furniture that a player can craft and place in the world, and I don't know how to hook that up.
So much of Zomboid's code is hard-coded if statements checking if something is this specific object type, or that specific object type... it's a really brittle and hard-to-extend architecture.
Oh, blah, sorry
That latter part is easy. You'd just need to make a script file that creates a new item with the Movable type, and have that tied to the tile you want it to represent
That was meant to be @vast pilot
Then youd just need to make a script for the recipe of that item, which is also simple
If you want to do a simple test, try this
local sign = IsoThumpable.new(sq:getCell(), sq, "KYRO_Tiles_03", false, {})
I've seen callbacks in a recipe when something is crafted, but wouldn't you want it to invoke something when the object is placed?
While you are here, idk if you saw this
lol
yes i saw it and no it is no what i need.
ty though โค๏ธ
which part of code doesn't work though
add a bunch of prints and minimise the number of outside factors
here's the thing it works. technically.
but iot doesn't save the sign if you leave the chunk.
when you come back to it its says no Sign, Making one!
can you share the code that prints that
function checkTileSpawns(sq)
local x, y, z = sq:getX(), sq:getY(), sq:getZ();
if #JobBoardTileSpawns.toSpawn > 0 then
for i = #JobBoardTileSpawns.toSpawn, 1, - 1 do
local tileSpawn = JobBoardTileSpawns.toSpawn[i];
if x == tileSpawn.x and y == tileSpawn.y and z == tileSpawn.z then
local SignExists = checkForSign(sq, tileSpawn.Tile)
if SignExists then
print("there's a sign here, move along!");
else
print("no Sign, Making one!");
local sname = tileSpawn.Tile
local sq = getCell():getGridSquare(x, y, z);
local sign = IsoThumpable.new(getCell(), sq, sname, false, ISSimpleFurniture:new("Job Board", sname, sname));
sign:setIsContainer(false);
sign:setCanPassThrough(false);
sign:setIsDismantable(false);
sq:AddTileObject(sign);
if isClient() then
sign:transmitCompleteItemToServer();
end
triggerEvent("OnObjectAdded", sign)
-- this transmits the mod data. and works.
local signData = sign:getModData();
signData.loc = tileSpawn.loc;
sign:transmitModData()
end
end
end
else
Events.LoadGridsquare.Remove(checkTileSpawns);
end
end
enjoy!
Does the square that's supposed to have the sign end up with no extra objects on it when you return to the area, or if you check it with F2 is it accumulating a bunch of borked objects?
we have to go deeper, what is checkForSign??????
what he said, I was thinking about that
also when you spawn something you should remove it from JobBoardTileSpawns.toSpawn somewhere?
gotta go, hope you find the answer
hey also- Anyone here know the people that made the mods -> iMedicine (Nyamops) or Zombie Virus Vaccine (Demonius) ?
Haven't seen anything from either of them in a long time... :( Both Russian, Nyamops seemed to have disappeared last spring, and Demonius the summer of 2021. Just didnt know if anyone had heard anything
function checkForSign(square, signsprite)
for i=1,square:getObjects():size() do
local obj = square:getObjects():get(i-1)
if obj:getSprite() and obj:getSprite():getName() then
local spriteName = obj:getSprite():getName()
if spriteName == signsprite then
print("there's a sign!");
return true;
end
end
end
return false;
end
I suppose following this- What would be a proper procedure to the usage of assets in those mods if they become completely depreciated, or otherwise? I would ideally reach out to the creators, but it doesnt seem like either of them have much- if any, real way to contact them
Just give credit - if it's just models and stuff, unless their pages say specifically not to use them. If it's code you should try to make it required unless it's very unwieldy to do so, credit is fine - again unless their pages say doing so is not ok.
how is it possible to use setSprite to change a sprite of an existing object when using a recipe
How slow is CheckModsNeedUpdate generally?
It hasn't picked up a pending update yet for the past ~30 minutes 
Nyamops
Dunno zombie virus
does anyone know of a mod that makes noise when a bandage gets dirty
Can we have a thread for us pleb's mod ideas? Just in case we have a good idea that someone else might be able to pull off
I've seen people's stall out and close their game - are you not able to continue without updating?
@sour island Love your mods. Could you possibly make a simple mod that increases being drunk duration?
Got a method in my Discord bot that runs the command every 10 minutes and then checks for updates
Which is working fine, except for the fact that the command isn't actually finding mod updates


