#mod_development

1 messages Β· Page 26 of 1

weak sierra
#

it did not clear up upon restarting the game, though

worldly olive
#

Oh, maybe somebody knows. I have managed to play a lot of animations by using the playEmote, but there are two animations that for some reason I can't, they run so weird (I think is the surrender one the default?). Any guide / information of what all the fields means in the .xml inside the animsets?

weak sierra
#

i am unaware of a guide but there are mods that make use of that system that u might poke at

worldly olive
#

Yeah I tried True Actions, Real Ladders, and others, and some are TimedActions (which I don't use for this) and others uses some variables that to be honest tried to replicate but I'm sure I'm failing in the .xml

weak sierra
#

how about Authentic Animations

#

and

#

PA Public Testing does a thing where it parses the animation wheel and turns them into chat commands

#

there's also a mod that does animations as hotkeys i think

worldly olive
#

Authentic Animations, will take a look at that one to see how it does it

#

But still I can't understand how I can play some animations but not all of them

weak sierra
#

i don't know enough to give you more insight, sorry x3

#

i'd poke around the same set of mods

#

to learn

#

so that's all i have! x3

#

might have more luck with insight into it in #modeling ?

#

oh also Vanilla Firearms Expanded and Brita's both have custom animations for gun reloading and holding and such

worldly olive
#

Thanks! will check at Authentic Animations, tootally forgot about that one

weak sierra
#
{
    imports
    {
        UndeadSurvivor,
    }
    
    recipe ReconditionHeadhunterRifle
    {
        UndeadSurvivor.HeadhunterRifle=1,
        ScrapMetal=120,
        MetalPipe=1,
        SmallSheetMetal=3,
        MetalBar=1,
        Screws=16,
        BlowTorch=8.5,
        keep [Recipe.GetItemTypes.WeldingMask],
        keep [Recipe.GetItemTypes.Screwdriver],
        keep [Recipe.GetItemTypes.Hammer],
        keep [Recipe.GetItemTypes.Saw],
        keep [Recipe.GetItemTypes.SharpKnife],

        SkillRequired:MetalWelding=9;Aiming=6;Maintenance=5,
        Sound:BlowTorch,
        NeedToBeLearn:true,
        Result:UndeadSurvivor.HeadhunterRifle,
        Time:350.0,
        Category:Firearm,
        OnGiveXP:MetalWeldingAndMaintenance10,
        OnCreate:ReconditionGun,
        RemoveResultItem:true,
        AllowDestroyedItem:true,
    }
    
    recipe ReconditionDeadlyHeadhunterRifle
    {
        UndeadSurvivor.DeadlyHeadhunterRifle=1,
        ScrapMetal=120,
        MetalPipe=1,
        SmallSheetMetal=3,
        MetalBar=1,
        Screws=16,
        BlowTorch=8.5,
        keep [Recipe.GetItemTypes.WeldingMask],
        keep [Recipe.GetItemTypes.Screwdriver],
        keep [Recipe.GetItemTypes.Hammer],
        keep [Recipe.GetItemTypes.Saw],
        keep [Recipe.GetItemTypes.SharpKnife],

        SkillRequired:MetalWelding=9;Aiming=6;Maintenance=5,
        Sound:BlowTorch,
        NeedToBeLearn:true,
        Result:UndeadSurvivor.DeadlyHeadhunterRifle,
        Time:350.0,
        Category:Firearm,
        OnGiveXP:MetalWeldingAndMaintenance10,
        OnCreate:ReconditionGun,
        RemoveResultItem:true,
        AllowDestroyedItem:true,
    }
}```
#

anyone see anything wrong in this script?

#

it causes the game to go into a GetItem loop

#
ERROR: General     , 1663629861880> DebugLogStream.printException> Stack trace:
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at se.krka.kahlua.integration.expose.caller.MethodCaller.call(MethodCaller.java:62)
    at se.krka.kahlua.integration.expose.LuaJavaInvoker.call(LuaJavaInvoker.java:198)
    at se.krka.kahlua.integration.expose.MultiLuaJavaInvoker.call(MultiLuaJavaInvoker.java:60)
    at se.krka.kahlua.vm.KahluaThread.callJava(KahluaThread.java:182)
    at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:1007)
    at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:163)
    at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1980)
    at se.krka.kahlua.vm.KahluaThread.pcallBoolean(KahluaThread.java:1924)
    at se.krka.kahlua.integration.LuaCaller.protectedCallBoolean(LuaCaller.java:104)
    at zombie.ui.UIElement.onMouseUp(UIElement.java:1228)
    at zombie.ui.UIElement.onMouseUp(UIElement.java:1183)
    at zombie.ui.UIElement.onMouseUp(UIElement.java:1183)
    at zombie.ui.UIManager.update(UIManager.java:809)
    at zombie.GameWindow.logic(GameWindow.java:261)
    at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
    at zombie.GameWindow.frameStep(GameWindow.java:764)
    at zombie.GameWindow.run_ez(GameWindow.java:680)
    at zombie.GameWindow.mainThread(GameWindow.java:494)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.StackOverflowError
    at zombie.scripting.ScriptManager.getModule(ScriptManager.java:209)
    at zombie.scripting.ScriptManager.getModule(ScriptManager.java:202)
    at zombie.scripting.objects.ScriptModule.getItem(ScriptModule.java:479)```
#

the last line repeats indefinitely, the one about line 479

#

maybe i need to not import

#

i haven't done much importing besides base, maybe it is a mistake

#

i've heard people say something like "importing base makes your stuff accessible"

#

which makes it sound more like "export"

#

lol

#

so perhaps it works the inverse from what i intuit

#

that'd lead it to be a loop, so.. let's see

#

well that did fix it

#

reads the source to see if she can determine if import means what she thinks it means

#

well, doesn't matter, but in getItem there's nothing making sure that you don't end up in an infinite loop

#

so

#

it goes through the imports there rather than preprocessing them

#

meaning it will go on a loop if you import something that imports you

#

would be nice if code would detect that and prevent it, but i grant it could only do so for a depth of 1 without it being a performance concern

#

anyway mystery solved there..

#

still dunno what the other error is

#

oh and import just means "look through this when trying to get a thing" from the context im seeing here, which makes sense - i imagine that using full names avoids the necessity

#

so it was redundant for me anyway

tardy basin
#

Hi, idk if this is the right channel but you guys might have the tools to do this so

With the total estimate of zombies on the map being ~52000 in the normal multiplier, I would like to count all the beds in Knox county to see how realistic that population is (aswell as get an estimate on what the realistic population multiplier would be)

Counting by hand would be aboslutely barbaric so I was wondering if anyone had any tools to do this faster

Thanks

weak sierra
#

the anti-cheat is obtuse in its numbering so i can't be sure if this is really a mistake but..

#
   public static boolean checkType8(UdpConnection var0, IPositional var1, IPositional var2, String var3) {
      float var4 = IsoUtils.DistanceTo(var2.getX(), var2.getY(), var1.getX(), var1.getY());
      boolean var5 = (double)var4 <= 10.0D * ServerOptions.instance.AntiCheatProtectionType3ThresholdMultiplier.getValue();
      if (!var5 && ServerOptions.instance.AntiCheatProtectionType3.getValue() && doKickUser(var0, var3, "UI_ValidationFailed_Type3")) {
         LoggerManager.getLogger("kick").write(String.format("Kick: player=\"%s\" type=\"%s\" issuer=\"%s\" value=\"%f\"", var0.username, "UI_ValidationFailed_Type3", var3, var4));
      }

      return var5;
   }```
#

check type 8 uses the type 3 setting

#

i.. assume this is not intended

tardy basin
#

stressed ok thanks

shadow geyser
radiant venture
grim rose
#

hello i am having problem

#

in short

#

i drop my model on ground

#

my model doesn't render on ground

#

i equip my model

#

and it works

#

any idea how to fix while hearing this kind of issue

ancient grail
ancient grail
grim rose
#

yea, i tried using it but zomboid rejects to read model

tardy basin
ancient grail
ancient grail
tardy basin
#

I ended up just counting all the houses in the main towns and then multiplying by 2.5 because thats around the average amount of beds in a house

#

and then for louisville I added +20% for good measure

ancient grail
ancient grail
tardy basin
shadow geyser
ancient grail
tight dust
#

Is this where discussions about mods making hair and skin retexture?

shadow geyser
#

modelling might be better

tight dust
#

Ok.

shell sequoia
#

Is Brita weapon pack broken or am I doing something wrong?

#

I used to have an older brita weapon back from what I remember but ever since the latest one needs a Arsenal(26) I cant fire a gun

worldly olive
zealous cosmos
tardy basin
#

yeah I'm counting it off the ingame louisville, however

#

theres only enough beds for ~8000 people

zealous cosmos
tardy basin
#

yeah

zealous cosmos
weak sierra
weak sierra
#

i did say that on here someplace, guess ya missed that

#

im surprised there was no safeguard in place to prevent an import loop, i didn't realize it worked in a way where one could happen, but when i read the code it was pretty obvious

#

since i was using full names it was unnecessary anyway xD

#

i actually almost always use full names

#

avoids potential fuckery

#

i should probably start doing it for Base too, be consistent, lol

#

the problem i could not solve yesterday, which was more mysterious, was this one:

#

same code works, then runs again with diff index and throws an error about a symbol near an "=" that doesn't exist - but works anyway.

ancient grail
weak sierra
#

also have to keep in mind that nothing is stopping zeds from migrating in from elsewhere - presumably you make enough of a disturbance driving around and maybe firing a gun, chopping a tree, etc.. that it could echo for miles and they do migrate.

#

so im not sure if the population is too relevant to begin with

#

if we assume they wander off en masse when the exclusion zone is mostly dead then it explains the lower amount, and if we assume they wander back in when humans outside are less available and you become a better target

#

if it's about number-of-beds then yeah there's no way they are going to go for accuracy there

#

it'd be an impractical amount of detail and effort to make by hand

#

they'd have to either spend a lot of money paying people to drastically expand the map and entirely redo the spacing if we want realism or rely on generated map stuff to achieve it which would yield relatively low-quality copy-paste reseults

#

lots of liberties were taken with the map and i imagine that is one of them

#

could relatively easily iterate the whole map looking for beds if you really wanted to, though

#

go over the whole grid and check each tile for a bed and if you find one, increment counter - just make sure to only count one part of multi-tile beds

#

since it'd be a one-time non-gameplay thing you could do it without being particularly picky about speed/efficiency

drifting ore
#

Can anyone guide me on Noir's shops and how to modify them? Mainly the NPC shops, thank you!

timid saffron
#

Does anyone know of a way to change who the player is controlling? IE I would like to add an npc and switch the player to control that npc

weak sierra
#

you could programmatically re-bind the keys to custom functionality

#

not sure about if you'd wanna change the view or if that's plausible

vast nacelle
#

Is there a Lua Event for when a player receives an injury? I didn't see one on the Lua Events wiki page.

weak sierra
#

could do checks and use OnPlayerUpdate

#

not sure if there's something more apt

#

might hook a function instead of an event tho

#

keep that in mind

vast nacelle
#

Alright. Thanks.

safe sinew
weak sierra
#

look into the code and find out?

safe sinew
#

I'm trying to dissect the mod right now to sus it out

plush wagon
#

Omg remember me the stupid person who can kind of make noodles?

topaz pasture
#

I wish more mods had that turret

#

Fuck me, that'd be great on a Humvee

hearty dew
#

What determines which version of a mod is loaded when you have both the steam version and a version in ~/Zomboid/Workshop?

#

~/Zomboid/Workshop had been preferred over the steam version until now. I activated Mod Manager: Server, and I'm wondering if that's affected which version is loaded. If I deactive both Mod Manager: Server and Mod Manager, it will use my dev version, but if I activate Mod Manager (not the server version) it starts preferring steam over dev. Curious if anyone wrestled with this same issue?

shadow geyser
#

yeah usually have to just avoid having both. I am always playing on my latest version and not the steam version just because its a pain to deal with, and bugs caused by that are really annoying to realize and debug

lime hedge
lime hedge
#

you can also set to sync with 3 or even 10 folder, had to setup a local dedicated server for a test, before deploying to main server, so yeah at least need to sync between ~client steam workshop dir, and local dedicated workshop dir.

#

also a question, could we apply auto reloadfile ontick? if there's checksum difference on certain file, it would apply it right away without us even reloading it manually ?, i'm thinking about hot module reloading.

halcyon dagger
#

can we create custom radio channels? like with custom text and so on? has this been done? πŸ™‚

calm acorn
weak sierra
hearty dew
#

And prior to today, it seemed to always load the dev versions of my mods

#

I downloaded a few more mods from steam workshop last night, and now it has become inconsistent blobshrug

deft falcon
#

How to check what foraging zone the player is in

#

nevermind

#

just digged thru game files lol

summer rune
#

hello i am wondering if LuaEvents are all available on both client and server side. For example I see many mods that listen for the OnPlayerDeath Event on the client side and once that event gets triggered, they call the server side with a sendClientCommand call. All that just to do something on the server in case of an death. Cant the server use the OnPlayerDeath Event directly or is there a difference?

#

what am i missing?

lime hedge
#

i dunno about the host one...

weak sierra
#

if i unsub to just my own mod then the dev version of it will load, it has nothing to do with whether anything else is a workshop or local copy

boreal crow
#

Can I add an extra context to an items menu via lua, and where should I look to get started

hearty dew
#

There are some lua events to add entries to inventory items context menus

boreal crow
#

Gracias :)

#

Would you know where I should look if I wish to add the context to a vehicle door for example, if the player has a welding mask and a propane torch

#

I will look at documentation now though, thanks

hearty dew
#
function fillMenu(player, context, items)
    context:addOption("Do my thing", items, doMyThing, player)
end
function doMyThing(items, player)
    print("hi")
end
Events.OnFillInventoryObjectContextMenu.Add(fillMenu)

@boreal crow something like that

boreal crow
#

OK, that's a great starting point - I'll take a peak at some documentation and go from there, thank you once again!

hearty dew
#

If not that event, probably is a similar one for context menu when clicking on vehicles

boreal crow
#

I'm thinking of inventory vehicle doors, that have been removed - so your example is perfect actually freddy_fox

deft falcon
#

my mian issue was the event one, i just assigned a function that prints "hi" when its ran but it just didnt work

#

its just one where you right click anywhere and it shows up, like walk to and sit on ground

hearty dew
#

So you want an entry in the context menu that appears when you click in the game world?

#

on the ground, etc

deft falcon
#

yes

hearty dew
#

Events.OnFillWorldObjectContextMenu looks like it is for that

deft falcon
#
Events.OnFillIWorldObjectContextMenu.Add(fillMenu)
function fillMenu(player, context)
    context:addOption("Do my thing", doMyThing, player)
end
function doMyThing(player)
    print("hi")
end```
#

would this work?

shadow geyser
hearty dew
#
Events.OnFillIWorldObjectContextMenu.Add(fillMenu)
function fillMenu(player, context, worldObjects)
    context:addOption("Do my thing", worldObjects, doMyThing, player)
end
function doMyThing(worldObjects, player)
    print("hi")
end```
boreal crow
#

Where is a good place to start on overriding a specific zomboid lua function?
e.g.: media\lua\server\Vehicles\Vehicles.lua has function Commands.takeEngineParts(player, args) and I'd like to override exclusively that, and leave everything else as-is

deft falcon
#

ill reply in a bit if it works

summer rune
deft falcon
#

also does the first param have to be "" or can it be

getText("ContextMenu_(thing)")
```?
hearty dew
#

getText returns a localized string

shadow geyser
hearty dew
deft falcon
#

broken letters and logs confirm its that line

hearty dew
deft falcon
#

wait it says OnFill i world

#

imma fix that

#

dunno why its there

boreal crow
#

patch it I guess, I just want to change the amount of parts given to the player

willow estuary
deft falcon
#

wait so is it filli or fill

#

cant tell whether its a typo or not

shadow geyser
#

you need to define the function first

#

before you can add it. it doesn't work like a pointer

deft falcon
#

ok i moved the line to the bottom should work i think

#

imm atry again

#

dunno if filli or fill is correct tho lol

shadow geyser
#

fill is correct

#

filli isn't a word, and you can compare it with vanilla code as well in future

deft falcon
#

yea it broke again

deft falcon
shadow geyser
#

obviously a typo

deft falcon
#

lol

shadow geyser
#

what on earth is with your fonts

deft falcon
#

idk it broke or osmething

willow estuary
deft falcon
#

yea so tyrir made the typo

#

bro idk with this game

#

wakeful is referred to as "needslesssleep"

#

i trust typos at tihs point

hearty dew
shadow geyser
#

needs less sleep

deft falcon
#

ok good news it didnt break

willow estuary
deft falcon
#

yea ik its case sensitive im just too lazy to write it on discord

#

with cases

#

and sleepyhead is NeedsMoreSleep i think

#

ok thanks @hearty dew it works

#

dunno why it didnt work before but oh well

#

now imma just add checks and it should be good

#

yea yea it works

#

works as planned

#

ty yall

vast veldt
#

Nevermind, I rebooted the game and it started working as expected... weird.

calm acorn
hearty dew
#

I see images referenced in lua to files in media/ui that don't exist. Are they compressed in the .pack files in media/texturepacks or somewhere else? Is there info on how to decompress these packs, if that's where they are?

#

Looks like a proprietary format. The Indie Stone has a tool on their forums, TileZed, to manipulate the .pack files

elfin stump
#

is there anything like zombie:getOutfitName but for containers? To get the container name like "BathroomCabinet" that would usually be used in distribution tables?

elfin stump
#

I found OnFillContainer and it gives me the info I need at the time I need πŸ™‚

summer rune
#

I am at https://projectzomboid.com/modding/ and honestly i am a software engineer, however i do not understand this weird documentation. I looked through a mod which uses the class NonPvpZone in Lua. Where and how can i find the class in this documentation? Where can I search? Where do I have to navigate?

shadow geyser
#

it also has a search bar making things alot easier

summer rune
#

oh god, thank u. @shadow geyser u are amazing πŸ˜„

shadow geyser
summer rune
#

I have another question. If there is a zombie or several zombies that I want to remove. Can I just call the remove command on the zombie on the server side and the server syncs that automatically with all the clients? is the server authorative? or do i have to remove the zombies in my mod also at client side?

empty cove
#

heya, i would like to ask if is it possible to cast inventoryitem to specific item type instance? I managed to grab radio data through getScriptManager:FindItem(fullType) but I can't grab those radio item's current channel

drifting ore
#

Hello everyone. I'm very new to discord. I heard on Reddit that could get some help for modding PZ.

#

Am currently looking a bit into the script file items_weapons.txt and there's a lot of properties under each items.

#

and all items does not have the same amount of properties.

#

how can I know which properties are required ?

#

and where are they used ?

shadow geyser
lime hedge
#

i get little confused with this __(operator), not defined things... do i have to define all of it

#

for every single __add, __mul, __sub, __lq lt le, etc

summer rune
fading creek
summer rune
#

very much appreciated, thank you

fading creek
#

cant guarantee im right though, only briefly checked for it

summer rune
#

it is a starting point for me πŸ™‚ so helped either way

lime hedge
#

@summer rune

fading creek
#

^ah yeah thats probably more helpful

#

i was just digging to find that too lmao

lime hedge
#

just ALT+SHIFT+F in your IDE, you shall be fine, load only the media folder, to check for vanilla stuff, so its not bloated with 3rd party stuff,

summer rune
#

thank you very much. with media folder u mean C:\Program Files (x86)\Steam\steamapps\common\ProjectZomboid\media correct?

summer rune
#

alright, this will get me started πŸ™‚ thanks

lime hedge
mellow oyster
#

Does anyone know how moodle framework functions, i can't seem to get it to work.

empty cove
#

is there a way to invoke java reflect method? I'm stuck at this part and have no idea how to progress from here.

#

or you can only invoke it in debug mode?

drifting ore
#

My JavaDecompiler doesn't show me the content of .class file

#

but It works with .jar file is it normal ?

drifting ore
#

weird

gilded hawk
flat cipher
#

that's IntelliJ IDEA

lime hedge
drifting ore
#

@lime hedge you are not a student ?

flat cipher
#

you can get the Community edition for free, it’s very good

lime hedge
lime hedge
summer rune
#

jetbrains IDEs are good , but when it comes to cloud and container stuff, they are not that great.

alpine scroll
#

@thin hornet Not sure if this is the correct place or anything, but im following the guide on github (https://github.com/Konijima/PZ-Libraries ) and its getting stuck on "Decompiling class zombie/characters/action/ActionTransition". Is that intentional?

GitHub

Complete tutorial to decompile and use Intellisense for Project Zomboid modder. - GitHub - Konijima/PZ-Libraries: Complete tutorial to decompile and use Intellisense for Project Zomboid modder.

lime hedge
summer rune
summer rune
lime hedge
lime hedge
lime hedge
#

so i don't really have a problem with that

summer rune
#

i have to use windows for my work env tho πŸ™‚

lime hedge
summer rune
#

true, with my arch setup script always something to change and fix

lime hedge
#

a win win solution lol.. the sad part i can't use my beloved i3WM conf.

summer rune
#

qtile is my favorite

lime hedge
#

have to stick with windows UI haha

lime hedge
#

gonna check on it

summer rune
#

for sure

lime hedge
#

@summer rune is it lighter than i3wm?

summer rune
#

depends on what u mean. performance wise. no. easier to configure? yeah]

lime hedge
#

i saw the comparison page, the video got that wrong xD

summer rune
#

and minimal feature set

#

i mean it is python

lime hedge
summer rune
#

exactly

#

everything has its prs and cons

calm acorn
#

python is reason enough for me to not use something

lime hedge
#

for terminal I use tilix just for the quake mode.. also its fast enough.

summer rune
lime hedge
summer rune
#

golang is my favorite lang. πŸ™‚ i introduced that everywhere i worked.

lime hedge
#

eventho it's python.. it just slow by nature, that's why there's Julia

summer rune
#

it is a mixed bag between c++, python and c#

#

and python and lua for scripting, chefskiss

lime hedge
#

golang is great, it just.. has its own use case.

shadow geyser
lime hedge
#

I'm sticking to node due to the ecosystem and the demand, hopefully deno will be a better iteration of node

summer rune
#

javascript is okay, i dont like the prototype stuff.

#

but i gotta be honest, java is the worst πŸ˜„

lime hedge
#

even all of it will be transpiled to "prototype".. all of the syntatic sugar..

#

I mean, all over the net are filled with JS, I can make mods, altering behavior etc by monkey patch it for just any web based stuff lol.

summer rune
#

understandable. i am using a ton of js and ts as well. still dont enjoy it.

#

possibilities are great. language is meh

lime hedge
#

its a weird language without TS, even with TS.. it just unrepairable lol

#

corrupting your mindset

#

once you dive in too deep with js, there's no easy way to get out. it may be good for your pocket and understanding, but not for your mental health.

#

lol

#

also the npm module are potentially bigger than cyberpunk2077*5 installation

calm acorn
summer rune
#

thanks, appreciated πŸ™‚

spark comet
#

im brand new to pz modding but have a lot of experience in lua, what would i have to learn to implement new animations such as weapon swings? i wanna make a mod that changes weapon attack animations based on proficiency level with that weapon

alpine scroll
halcyon dagger
#

How can I extract the textures for using it in like mapmap?

hearty dew
#

Is there a way to specify dependencies between workshop items in the workshop.txt file? Or do you have to do that via the steam UI?

alpine scroll
#

I think something is wrong

hearty dew
#

What are some options for saving character-specific data (and specific to a game world too)? For example, if the user has enabled/disabled a feature of the mod for a particular character

calm acorn
worldly olive
#

Is there any way to check that if the food that was eaten contained "X" ingredient? like I made a salad and in the On_Eat I can see if it contains for example berries?
Or if I add an On_Eat to a berry that On_Eat automatically triggers when the salad is eaten because it contained that berry?

hearty dew
#

I don't know, but I happened across a function, I think it was called getExtraItems(), on the InventoryItem object. I assumed it was for that purpose, but I didn't verify, just a hunch. Might be a starting place if nobody else comes along with an answer

drifting ore
#
module Base
{

    item Diary
    {
        Type = Normal,
        DisplayName = Diary,
        DisplayCategory = Literature,
        Weight = 0.5,
        Icon = Book,
        WorldStaticModel = Book,
    }

}
drifting ore
#

Mod is loaded.

hearty dew
#

Nothing stands out as wrong. Do you perhaps have the same mod installed in a different location, ~/Zomboid/Workshop perhaps, that is loading instead of that one you are modifying?

drifting ore
hearty dew
#

You might try looking through console.txt to make sure that file is loaded when loading into a world with the mod activated

drifting ore
#

Ah ok ty

hearty dew
#

Actually, scripts files might not be logged in console.txt when they are read. Lua files certainly are

#

Oh, there ya go

drifting ore
#

Yeah

#

That's strange because it still doesn't show up on the debug item list

worldly olive
coral briar
#

public void addDirt​(BloodBodyPartType bloodBodyPartType, java.lang.Integer integer, boolean boolean1)

#

Any idea what the boolean does?

robust shoal
#

Do recipes for crafting only give 1 item max? Where do I find a breakdown of how recipes are formatted?

#

I understand I can look at current recipes for this, but I need to know if I can specify multiple results

#

Otherwise, how can I fill a container with items, as it's own item? I would like to specify a crate full of items, and then result that in my recipe, if possible.

#

Does it require a perfect distribution entry in the dist table?

#

Also, how do I specify the amount of space within a new container item?

weak sierra
#

there's a guide someplace

sour nova
#

When I'm modding, do I have to relaunch the game to reload lua, or can I use a developer console command to reload

drifting ore
#

Is there anyway I could pay someone to create a mod with a single profession?

#

Like 5-10$

#

Usd

drifting ore
drifting ore
# robust shoal message me

I wanted something like a radio guy that is on when your in your car I just can’t think of a good name for it

fading creek
#

does anyone happen to know how to get the container of a vehicles glovebox? i can get the part itself but i cant figure out how to get its inventory to add stuff to it

#

im assuming im taking the wrong approach by getting the part but im not sure how else i'd do it

shadow geyser
shadow geyser
drifting ore
#

Is there a way to see what music plays when?

ancient grail
#

anyone has a servermsg script

vast nacelle
#

Lua event question. I'm trying creating to create a function that places a static group of zombies in a location when an area is generated but I for the life of me can't figure out what Lua event I should be using to call it. The function works when attached to something like EveryTenMinutes and I happen to be in the area of the designated location.

Which Lua event fires off when/after a cell is generating its zombie population? I had hoped OnPostMapLoad would fit the bill but it seems to only go off when you load into the game (and also seems to be too "early" to spawn zombies).

drifting ore
#

Once you get your first mod, what's the best way to test in PZ ? πŸ™‚

#

can I just drop it in the steamapps/workshop/contents ?

shadow geyser
# drifting ore can I just drop it in the steamapps/workshop/contents ?

Not in that folder. use the workshop folder in your home folder ie "C:\Users\user\Zomboid\Workshop" just dev with my mod inside the workshop folder. makes it so much easier too when doing explorative stuff to try to learn things. my IDE just has the mod open in that folder. no point in making changes then moving files around, when you can just modify them in place

vast nacelle
#

@tame mulch That looks like one I can use. Thanks.

drifting ore
#

Is there a function to find a specific steam account ?

#

If I remember well, there is something like player.getSteamID()

drifting ore
#

is there any way to start Pz in a minimal mode, so that it takes less time to startup ?

#

like I just need a crowbar and a zombie ?

shadow geyser
#

you could try the debug scenarios? i haven't used them in a long time, but I think they don't load the whole map

#

might be faster

violet fractal
weak sierra
#

doing UI things is a fancy thing for a first mod, grats

violet fractal
drifting ore
#

Hey guys, I have a question

#

I wanted to stop some items from spawning in the world altogether, so I am editing the proceduralgeneration.lua life

#

is this correct ?

#

So with 0 rolls, or 0 on the actual items there wouldnt be any spawns right ?

low yarrow
boreal crow
#

Can I use item tags within recipes, and how do I put a recipe that keeps two items, so like keep WeldingMask&Blowtorch

shadow geyser
#

just have 2 lines, one which is keep weldingmask and one which is keep blowtorch

#

and yes you can use item tags, but you need to write the getitemtypes function yourself. just take a look at the existing ones and base it on them

boreal crow
#

Thank you, I will try to find some examples

#

@shadow geyser for example, I found this in the games scripts:
keep [Recipe.GetItemTypes.WeldingMask]
Would I still need to define this myself, for the welding mask - or would it just use the predefined game code?

weak sierra
#

if predefined exists, use that

#

only create your own if it doesn't

boreal crow
#

OK thank you!

boreal crow
#

I am having issues, I am using Intellij and I set the modules up and all of that - but there seems to be at least one missing lua file - VehicleCommands

#

but it's not in the zdoc-lua.jar file

shrewd otter
#

are there any mods that rework PVP? like get rid of stun lock ect

prisma cipher
#

hey, so I want to create custom events for my server. My current goal is to create a scenario where everyone starts in a church and every 24 in game hours a large horde appears with increasing difficulty. Is something like this possible with mods? Where should I start?

shadow geyser
#

possible, but probably alot of work. there might be similiar mods that do parts of those already though, so you might be able to scrap together code and just duct tape it all together

prisma cipher
#

any good sources for getting started in Lua?

summer rune
#

Does anyone know why this way of creating a safezone does not work? SafeHouse.addSafeHouse(10927,8989,10843,8939, "BlockedNonClaimable", true)

#

there is no exception

prisma cipher
#

in my personal experience, the coordinates in game compared to the one from the PZ online map are slightly off.

summer rune
#

i walked to the positions ingame

#

and i used the admin panel safezone tool to test the creation. it worked from the ingame panel.

#

but i think i am using the lua function not correctly

#

wait, so is this not 2 cords? addSafeHouse​(int x, int y, int w, int h, java.lang.String player, boolean remote)

#

seems like width and length?

zinc prairie
#

Any tutorials on how to mod in custom occupations?

#

I wanna try to start modding just need some pointers

livid geode
#

Can anyone help me with item removing code for mods
This line doesn't really work--

#

When I use AddItem it works-- but Remove doesn't work
What do I type in to make it removing specific item from the inventory

hearty dew
#

The uses of that function that accepts a string in the vanilla lua code don't have a module name:

self.character:getInventory():Remove("CampfireKit");```
Might try that.
Aside from that, might have a dig into the java decompiled code to figure out exactly what's happening, if nobody else has some insight they can share.
#

Might also try using an actual object rather than a string, if an object is available. Then you don't have to worry about getting the type id string right

#

There are a couple different methods other than the one that accepts a string as you are using

livid geode
summer rune
#

how can i find out if a statement is only workign on the client or server side?

weak sierra
#

you could print to the log and see which log it ends up in if you test on a dedicated server

#

:P

summer rune
#
local function setSafehouseData(_title, _owner, _x, _y, _w, _h)
    local playerObj = getSpecificPlayer(0);
    local safeObj = SafeHouse.addSafeHouse(_x, _y, _w, _h, _owner, false);
    safeObj:setTitle(_title);
    safeObj:setOwner(_owner);
    safeObj:updateSafehouse(playerObj);
    safeObj:syncSafehouse();
end

this code is running inside the vanilla lua code on the client side within the admin panel.

can i make it work on the server side?

magic nymph
#

Does anyone know how to modify the attribute of an item that has already spawned?

#

I'm not even sure if it's possible; it could be in the saved game file. The only thing I've found in the workshop is someone who added a custom recipe where you use the old item to craft a new item, which then has the changed attribute.

wooden lodge
#

Is there a way someone could assist me with making a magazine that gives you Level 5 Aiming, Level 5 Reloading and Level 5 Short Blade when reading?
I'd really appreciate it, as it's for a miliatry RP setup. Thank you so much. Please DM me!

twin wagon
#

I exported a weapon model as .fbx from blender but it's invisible in game :hmm:, any thoughts?

quasi kernel
#

Read up a bit, seems to be the case. Use a converter.

willow estuary
#

You can use .fbx models in PZ, and considering all the problems people have with the .x format you probably should.
Having said that, there are all sorts of ways a model can not appear in game that have nothing to do with the format, and can instead be due to errors with the model/item scripts, issues with the model itself, being subscribed to your mod while also trying to work on it on your home computer, etc.

quasi kernel
#

Oh huh, my bad then.

#

Very much noted, will point people to this if a similar question comes up.

boreal crow
#

No matter what I do, my zdoc is generating incorrectly with Capsid - anyone got any experience?

drifting ore
#

Are there any mods on the workshop that allow safehouses in any area? (aka non residential etc) for multiplayer or co-op?

boreal crow
#

you can toggle that in settings

#

AdminsSafehouse: When set to true, only admins will be able to take safehouses for themselves.
DisableSafehouseWhenPlayerConnected: This will make it so that when the player who owns the safehouse is playing the game, other players can enter their base and take things. When set to False safehouse will be locked out at all times.
PlayerSafehouse: This is the setting which determines whether or not safehouse will be a part of the game at all. When set to false, noone can claim a safehouse.
SafeHouseRemovalTime: After the player has not visited their safehouse within this amount of time it will automatically be removed from their possession. The amount is in real-life hours.
SafeHouseAllowFire: Toggles whether or not fire can damage an active safehouse. True means that fire can destroy houses.
SafehouseAllowLoot: Allows players that aren’t apart of a safehouse to loot things out of the containers within the safehouse.
SafeHouseAllowRespawn: Allows players the ability to respawn within their safehouse. Players can toggle this option on and off within the Safehouse menu.
SafeHouseAllowTresspass: Allows other players that aren’t apart of a safehouse to enter uninvited. When set to false, other players won’t be able to enter within 2 blocks of another player’s safehouse.
SafehouseDaySurvivedToClaim: You can set a certain amount of in-game days that players must have survived before they are able to claim a safehouse for themselves.

drifting ore
#

ahhh okay tyvm

hearty dew
#

For some of the functions, instead of rewriting your own which are basically duplicates from ISHealthPanel, you may want to consider reusing and decorating them instead. That would allow your mod to integrate with other mods that improve the health panel

#

For example, ISHealthPanel.doBodyPartContextMenu

#

Some other mods add additional items to it, which are not displayed in the context menu in the ISMiniHealth panel

hearty dew
small topaz
#

I have a problem that the game does not display certain symbols of written text correctly in various interface menus. For example, the string "CαΊ§n cΓ³ Dao CαΊ‘o" is only displayed as "Cn c Dao Co". So all special characters not part of the latin alphabet disappear. Any ideas how this could be fixed?

hearty dew
#

Just a guess, but perhaps the strings are utf8 encoded while java expects utf16

small topaz
#

funny enough but utf16 .luas lead to total crash

twin wagon
#

you can use FBX export straight from blender. it's pretty sick.

hearty dew
#

Maybe pz expects lua files to be utf8. I'm unsure. I haven't looked into how lua handled file encoding at all, so I'd have to research it.

That said, I think the proper way to handle this is to put your localized strings into the proper place so you can retrieve them via getText(), which should handle all the tricky localization and encoding for you

small topaz
hearty dew
#

What that amounts to is putting your strings into media/lua/shared/Translate in the appropriate directory and file. Each string will have an identifier. Then in your lua you use getText("IGUI_MYMOD_SomeString") instead of using the string literal.

For EN strings, that'd be media/lua/shared/Translate/EN/UI_EN.txt and it's contents would be

IGUI_EN = {
    IGUI_MYMOD_SomeString = "Razor Needed",
}

For VI strings, that'd be media/lua/shared/Translate/VI/UI_VI.txt and it's contents would be

IGUI_VI = {
    IGUI_MYMOD_SomeString = "CαΊ§n cΓ³ Dao CαΊ‘o",
}
small topaz
#

oh thanks! I try that!

hearty dew
#

I'm not 100% sure the correct language tag is VI for vietnamese, but hopefully pz uses BCP 47 language tags, which uses vi for vietnamese, and my assumption is correct πŸ˜…

small topaz
#

it should be VI

#

But doesn't work for me either. using getText("IGUI_MYMOD_SomeString") simply prints "IGUI_MYMOD_SomeString" while in game on the respective position. it does not access the data from the UI_VI.txt file

#

ah... now it works! should be UI_VI = { } and UI_MYMOD instead!

hearty dew
#

getText("IGUI_MYMOD_SomeString") simply prints "IGUI_MYMOD_SomeString"
getText() will simply print the string you give it when it can't find a localized version. It's not associating what you put into UI_VI.txt with that identifier for some reason

small topaz
#

many thanks for help!!

#

maybe there is a difference whether the ui stuff is displayed while actually in game or in one of the menus before you start but not sure here... anyway everything seems to work now

hearty dew
#

Yea, I think that's true

hearty dew
#

Although, it looks like you intentionally didn't include that from ISHealthPanel, so nm :)

zinc prairie
#

How do I access the files of mods I've subscribed too? (win10)

#

Trying to learn from thm

hearty dew
#

They are downloaded to your steam folder, Steam/steamapps/workshop/content/10860

zinc prairie
#

Thank you!!!

hearty dew
#

I think, by default, steam is located at C:/Program Files/Steam

#

but that's configurable

zinc prairie
#

Ah okay! Thank you! It's appreciated!

vivid imp
#

Hello, I'm following the same pattern as the base game to create a VHS casette, but the name is not translated, do you know what could be happening here?

#
RecMedia["e5206ac2-3aee-11ed-a261-0242ac120002"] = {
    itemDisplayName = "RM_78f211f6-3aef-11ed-a261-0242ac120002",
    title = "RM_dd446b86-3aef-11ed-a261-0242ac120002",
    subtitle = "RM_09ce9064-3af0-11ed-a261-0242ac120002",
    author = nil,
    extra = nil,
    spawning = 0,
    category = "Retail-VHS",
    lines = {...}

This is part of what I have for recorded_media.lua

#

and in Translate/EN/Recorded_Media_EN.txt this:
RM_78f211f6-3aef-11ed-a261-0242ac120002 = "VHS: Letal Homemade Weapons"

vivid imp
#

no

#

what is that?

signal ibex
#
vivid imp
#

no

signal ibex
#

I think you need to use wordzed to make texts

vivid imp
#

I mean, it works fine. Is just the title, as you can see in the screenshot

lime hedge
shadow geyser
# small topaz I have a problem that the game does not display certain symbols of written text ...

the specific translation files, need to have the correct encoding. https://github.com/TheIndieStone/ProjectZomboidTranslations/issues/155

GitHub

I'm trying to update russian translation to the latest PZ version but I run into a problem which I can't solve (I remember same issue was here year ago). So what issue is. Currently...

small topaz
violet fractal
hollow current
#

Hello! Quick question. I am new to modding. I am trying to find where to put a custom item's icon file. Couldn't find it in any guide.

#

I currently have it in \texture\icon_file.png

#

but doesn't seem to be the correct location for it

#

I followed this guide but seems to be outdated

drifting ore
#

Do you guys have just one PZmod for every IntellijIDEA project ? Is it viable to work on multiples mods under the same Project ? how do you setup your source controls ?

#

Is some of you are modding together and share their progress with github, or something else ?

hollow current
glad ridge
# vivid imp

is there a reason you don't just use itemDisplayName = VHS: How to make a Potato Launcher ?

grim rose
#

@violet fractal was it hard to get UI on screen?

#

i would like to know if it was hard because i do plan on making one UI mod myself

lime hedge
#

adjust as you wish

grim rose
#

i see, i will keep it on my mind

violet fractal
lime hedge
summer rune
#

I would like to change values in the GlobalModData Table manually by hand. Can i connect with a sql db viewer, or open a text file? where is it located and how can i manipulate it?

narrow turret
lime hedge
#

what's the different between distribution and proceduraldistribution?.. haven't mess with that yet, so I need a little lead.

livid geode
#

How do I add another line to an already existing vanilla .lua file with my mod? For example I wish to add another option to the HealthPanelUI -->

#

When I edit the main file I can add it-- but how do I do that without editing the main file but only by using my mod files?

livid geode
#

--edit: nvm I figured that our.. All I have to do is copy the whole file and then edit it. It will overwrite the old one when loading the mod πŸ˜„

vivid imp
glad ridge
vivid imp
#

And the translations?

glad ridge
#

you don't need one, as the display name is what will appear as the in game name

#

as far as i know how that works

shadow geyser
shadow geyser
shadow geyser
ancient grail
shadow geyser
#

you just grab the lua object, they aren't local variables, so you should be able to do

cheatPartChangeSubMenu:addOption(asdfjkahsdbgflk) 

from another file.

ancient grail
#

thats good to know thanks alot man

shadow geyser
#

and if it is a local variable, you should still be able to grab it from the UI manager I think. which is more complicated, but still a much preferred method than overwriting a vanilla file.

ancient grail
#

i have modifyed the debug ui before .i just placed the zombie population button on the front. and i did the copy the file thing. i know you cant delete lua file u just empty it out but the thing is its the same name as the debug ui

so how do i go about undoing what i did

shadow geyser
#

yeah, I don't know of a clean way to work around that weird steam issue. the last time it happened to me, I was just forced to make the change and hoped people would try to unsubscribe and resubscribe. But now that I think about it, it might be useful tov add some info popup to unsubscribe and subscribe, to try to help people fix the issue

pale phoenix
#

I'm looking for someone to help me out with a mod I want to create. I have some coding experience but I've never made a mod before. I also haven't used said coding experience in probably 10 years. If anyone is willing to point me in the right direction I would greatly appreciate it.

astral dune
#

Is it possible to attach persistent metadata to a vehicle? Or would I have to store that seperately?

boreal crow
#

As Capsid is no longer supported, what is best practice for mod making now? I love IDE Features, and I'm wondering how hard would it be and practical would it be to just copy and jar the media/lua and media/scripts to use

#

I'm not so much bothered about java as I don't intend on modding it too far out of the scope

astral dune
#

Capsid still works, doesn't it?

boreal crow
#

It's not extracting the full lua library, and it's no longer supported

astral dune
#

what is missing?

boreal crow
#

VehicleCommands.lua is one of htem

#

I am not sure what else could be missing

#

I even tried remaking the project, and re-importing it twice

astral dune
#

hmm, even when it was supported it doesn't look like that file was generated

boreal crow
#

That's very strange then

#

I wonder why it's ignored

astral dune
#

bug, possibly

boreal crow
#

could I just repackage the .jar?

astral dune
#

the lua files in the folder you posted should work fine, right? I don't think you need it to be a jar to use it as a library

tame mulch
lime hedge
#

Is it feasible to iterate through all the container in the world, then iterate through the items to update certain one?

#

every server time tick

astral dune
#

god I hope not

boreal crow
#

Every tick? That would be bad

#

Why would you need to do that, what's the purpose? Maybe someone can direct you

willow estuary
boreal crow
#

There's an example of searching in the vicinity I believe I read when looking at lua

#

the code for finding clothes to scrap

#

why isnt my recipe working
mod isnt turned on
Oops

#

I have never programmed lua before, what is the intention of this:
MyModName_RecipeCodes = MyModName_RecipeCodes or {};
Is it saying class MyModName_RecipeCodes should be equal to MyModName_RecipeCodes if exists, else create new array?

magic nymph
#

Is it saying class MyModName_RecipeCodes should be equal to MyModName_RecipeCodes if exists, else create new array?
Yes, but an object, not an array.

quasi geode
#

*table, not a object

magic nymph
#

true

boreal crow
#

Oh thank you

scarlet trellis
#

Hello I have a question. If Im starting to get lag from a stupid amount of mods, can I safely look passed the map mods?

#

They shouldnt be affecting performance if the player isnt close enough to load them in right?

#

apologies if Im misunderstanding how that works but Im not sure which types of mods to look at first

boreal crow
#

I would say as long as it's exclusively a map mod, the only thing you should get is extra load time - so I'd say you are right, but I also do not know

#

VenomousTweaks/scripts/recipes.txt Content: ```js
module Base
{
recipe Take Honey
{
TreeBranch,
keep Ketchup,

    Result:Honey,
    Time:10.0,
    Category:Survivalist,
    OnGiveXP:Recipe.OnGiveXP.WoodWork5,
}

}```

I am having issues with my recipe, so I made a very basic one that makes honey from a Tree Branch and Ketchup lol - but it doesn't seem to work still - am I missing something

unique goblet
#

is there a way to change colour of item name text?

boreal crow
#
module MSGTweaks
{
    imports {
        Base
    }
    recipe Take Honey
    {
        TreeBranch,
        keep Ketchup,

        Result:Honey,
        Time:10.0,
        Category:Survivalist,
        OnGiveXP:Recipe.OnGiveXP.WoodWork5,
    }

}```
weak sierra
#

so if you don't have enough RAM they can make lag, otherwise generally yes, though if a map mod has a ton of content in an unusually dense place, etc., it could potentially impact performance

weak sierra
boreal crow
#

It was just a test, lol

#
module MSGTweaks
{
    imports {
        Base
    }
    recipe Weld into Metal Plates
    {
        BlowTorch=1,
        keep [Recipe.GetItemTypes.WeldingMask],
        [MSGTweaks_RecipeCodes.GetItemTypes.CarScrapDoor],

        SkillRequired:MetalWelding=1,
        Sound:BlowTorch,
        NeedToBeLearn:false,
        Result:Base.SmallMetalSheet=1,
        Time:100.0,
        Category:Welding,
        OnCreate:MSGTweaks_RecipeCodes.OnCreate.DismantleCarPart
        OnGiveXP:MSGTweaks_RecipeCodes.OnGiveXP.CarPartScrapper15,
    }
}```
weak sierra
#

very strange xD

boreal crow
#

that's what I am actually trying to do

weak sierra
#

yeah that's less weird

boreal crow
#

Haha :p

untold badger
#

hey any clue why im getting this when hosting a server?

livid geode
#

Can anyone show me how to make a ContextMenu option when other player on MP is right clicked that gives player an infection when clicked.. please
I spent 2 weeks now trying out tons of methods and none of them works-- best I could do is give myself an infection with player:getBodyDamage.. but idk how to do that to the other player 😦

hollow steppe
#

hello all, I am attempting to override a recipe in a local mod I am creating. However it does not seem to want to override it and I can't seem to change the name of it if I just try to create a new item with a modified recipe. Does anyone have any ideas?
recipe Make Gears
{
HCCopperingot,
Charcoal,
Lighter/Matches/PercedWood/HCMagnesiumstriker/HCBowdrill,
HCGearmold,
keep Tongs,
keep HCWorkgloves,
keep HCSmelter2/HCFurnace2/HCBlastfurnace2,
CanBeDoneFromFloor:true,
Result:HCGearcopper=10,
NeedToBeLearn:true,
Time:100,
Category:Smithing,
OnGiveXP:HCWelding_OnGiveXP,
Override:true,
}

livid geode
limpid leaf
#

what function use to warp survival npc to my character

lime hedge
#

any example regarding adding combobox in sandbox options? what type other than bool,double,integer?

vital needle
#

Hi all, I am trying to get into PZ modding, with the most minimal amount of experience in blender and none at all in all the other important areas. My goal for now is to just replace the player model with a different model I made in blender, but I am overwhelmed with the amount of information and don't even know where to start. Can anybody point me in the right direction and show me a good source to learn about modeling? There are plenty of videos about modeling clothing or weapons, but I am not sure if that is going to help me with my goal.

undone elbow
#

Is it possible to connect as client in debug mode?

limpid cape
vital needle
limpid cape
# vital needle Yes I have seen that, thanks. There are lots of resources, but none about specif...

In that case i would also check out the indie stone forums. There does happen to be an entire section on 3d modeling
https://theindiestone.com/forums/index.php?/topic/37647-the-one-stop-shop-for-3d-modeling-from-blender-to-zomboid/

vital needle
limpid cape
#

not sure if it would be exactly what you're looking for but it does seem to go in depth in an easy to understand format. And no problem. I've been researching a ton myself to get more into the modding scene. I'm a bit slow on taking that plunge down the rabbit hole lol

astral dune
#

I need to know when a player has accessed the mechanics menu on a vehicle. Is there a better way to do this other than overwriting ISVehicleMenu.lua?

vast veldt
#

Hi, I've been writing a mod that I've mostly got operational single player for testing and laying down the basic operation. I'm now ready to start moving to testing in a dedicated server environment. My LUA is loading and I can get print commands etc to execute, but I'm looking to try and find the right event to hook into to call when the server has finished booting. In SP I use the event "OnGameStart" which kicks everything off. This doesn't seem to be running on my server though, so was wondering, which event from https://pzwiki.net/wiki/Modding:Lua_Event can be used to hook into the server's startup cycle?

vast veldt
#

I receive a "Object tried to call nil" exception trying to use the same code which works for SP for OnGameStart

vast veldt
#

If I call my commands in a file called Z.lua which loads at the end of the loading process things seem to work...

undone elbow
#

@vast veldt All lua files in "client" folder are ignored by the server.

vast veldt
#

They are in either /server or /shared

undone elbow
#

Should work. OnGameStart, OnGameBoot, etc

vast veldt
#

It works provided I don't use the "ongamestart" event - if I call my initializer directly within Z.lua and then use EveryTenMinutes to hook the main program loop, it works, but onGameStart doesn't seem to fire on the dedicated server.

undone elbow
vast veldt
#

I'll check it out now, ty

#

if isServer() then
-- Bind Initialization
Events.OnGameStart.Add(PGMG.Main.initialize);
end

The line above will not run, it gives a nil value exception. The same command:

PGMG.Main.initialize();

Will run provided it is in Z.lua. initialize() calls other classes which are not loaded at the point of LUA execution, although should be by OnGameStart()

undone elbow
#

Also you should have only one copy of the mod. Unsubscribe your mod that you published recently. Unsubscribe while the game is closed OR remove files manually while the game is running.

vast veldt
#

Ty. I'm confident I have only one copy, I have not published the mod to workshop yet, I am testing solely on my local client (where OnGameLoad works as I might otherwise expect), or my dedicated server, where I have specified it in the Mods= directive. The mod loads and works pretty much as expected when boot procedure is set in Z.lua

undone elbow
#

I meant isolate local copy if you are testing dedicated server.)

#

I can check the mod if you send it in zip.

vast veldt
#

Sure, one sec, I'll DM you.

livid geode
#

https://theindiestone.com/forums/index.php?/topic/43951-how-to-make-interactable-action-with-other-players-in-the-world/&tab=comments#comment-330245
Does anyone have an answer for this?
@willow estuary sorry for ping, but Ive seen you answer some real complicated modding posts and I assume you might have the solution to this..

hidden estuary
#

its been a few months of my death, has there been any framework for adding new crops to the game? or any current-patch example of it?
preferrably a non-spaghetti option

calm depot
#

I believe SoulFilcher's farming time adds new crops

#

the code part isn't all that challenging, being good at graphic art and making sprites is πŸ™‚

#

in fact, if you can do the sprites, I'll do the code for you.

hidden estuary
#

I believe that one is broken

#

unless there's been an update to it, I think the mod page itself says that its broken

#

SoulFlicher even made a Let Us Farm Lettuce to serve as an example of a new crop mod, and I tried using that, did not work

#

I mean, it "works", crops just never grow, ever

#

so farmtime, at least last time I had a go at it, did not work

robust shoal
#

Looking for a tutor to help me through my first mod, I am proficient in modding, and have created mods for other games, however I am finding some issues in appropriating my knowledge here, and someone who could hel me would be appreciated. Private message me if youd be willing to show me the ropes. I have done thr tutorials available, but I will need a more knowledgeable person to help me through constructing the mod I am hoping to work on.

hidden estuary
#

heavily depends on what you're going for, friend

#

I wish it didnt

robust shoal
#

I'm looking to make a teleport function basically

hidden estuary
#

like a console command?

robust shoal
#

I'd like to create a map teleport functon, either in context menu or otherwise, which will allow players to jump from a home base (safehouse) to a pre-decided spawn point with their current character. This is used to simulate the Tarkov loading into raid feature.

#

I understand the anticheat will not like this, and it will be unnecessary to make it work with the anticheat, I understand the setting will need to be turned off for this mod to work, similar to how TrueActions - Lying requires it

calm depot
#

not at all, if the server executes the teleport, it won't trigger anticheat at all

robust shoal
#

thats awesome

calm depot
#

what you essentially want is a server command that clients can send to trigger the teleport

calm depot
hearty dew
#

How do the loot 'rolls' work conceptually? How do they relate to the chance?

calm depot
#

it's basically a ratio

#

if you want to examine the end result, run the game in Debug mode and turn on LootZed

#

you can then inspect any container and see exactly what the spawn chances are as a %age

hidden estuary
#

then there must've been an update since I last tried, I can try again

#

tho its been a few months and it finally dawned on me that maybe adding crops to a trait mod is going a next mile that I shouldn't be going with

somber axle
#

How does multiplayer work for modding? I've made a mod that makes changes to ISBuildMenu and buildutil. The changes to buildutil work fine in multiplayer but build menu not so much. Obviously fine in single player, any ideas?

hearty dew
#
function SomeOtherModFancyFunction()
  print("You can't overwrite me");
end
SomeOtherModFancyFunction();```
Is there any clever way to overwrite a function like that defined and used within the same file?

Only thing I could think of is trying to load my file in my mod prior to SomeOtherMod's file and messing with the _G metatable.
calm depot
#

yes, you'd need to create a function for __newindex on _G

#

when key == SomeOtherModFancyFunction - rawset to your code instead

#

that's some pretty vicious interference though; I'd suggest contacting the mod author as the first port of call

zealous wing
#

Question: Is there a way to change the context menu text for reading a map to something else other than "Read Map?"
E.g., "Read Tattered Map, "Read Note," etc.

frank gyro
#

any good mods that add like, push bars to cars or military modded vehicles? downloaded the '86 oshkosh p19A mod from KI5 and its a huge military truck. but it just does NOT go through zombies like youd expect...

hollow current
#

Hello! I am working on a mod to add a new mechanic item. I finished the item addition part, but I am not sure how I am able to edit its context menu in-game or how it can be used when you're on a vehicle properties menu. I know it is tied to Lua scripting. Would anyone be able to point me in the right direction for a tutorial regarding that?

#

p.s.: I'm not totally new to scripting in general, just to Lua

hollow current
#

okay so, i did some reverse engineering and was able to figure out the context menu part, however, I am not sure how I can make it so that it appears only when right clicking the battery. As of now, it appears when right clicking any vehicle part

hearty dew
#

@hollow current Is there an item / context menu option that does something similar to what you are trying to do? If so, I'd use that as a starting point by trying to see how it functions in the vanilla lua sourcd

hollow current
#

Battery charger. I already tried searching for its source code and how it detects clicking on the battery exclusively. No luck finding it so far

hearty dew
#

How ISVehicleMechanics.lua handles inflating tires (search for onInflateTire in that file) might be a starting place. It sounds somewhat similar

hollow current
#

I'll look for that, thanks!

hearty dew
#

I'm not familiar with the battery charger. Is there a string in the UI you can use to search for?

#

e.g. in the context menu

hollow current
#

That's the problem. I can't even find it. No even via in game item spawner when I'm launched in debug mode lol, even though I'd normally find it via my playthroughs (not a modded item)

hearty dew
#

ISInventoryPaneContextMenu.createMenu checks if there is a car battery charger and adds an option if there is one

    if carBatteryCharger then
        context:addOption(getText("ContextMenu_CarBatteryCharger_Place"), playerObj, ISInventoryPaneContextMenu.onPlaceCarBatteryCharger, carBatteryCharger)

ISWorldObjectContextMenu.createMenu does something similar with a battery charger:

    if carBatteryCharger and ISWorldObjectContextMenu.handleCarBatteryCharger(test, context, worldobjects, playerObj, playerInv) then
        return true
    end```
#

What you probably will need to do is decorate one or both of those methods to add another entry into whichever context menu is appropriate for what item/object your mod adds

hollow current
#

I will try to put that into action, thank youu

hearty dew
#

So something like:

local function onOptionActivation(theFancyObject, player)
    -- do important, amazing stuff with theFancyObject
end

local original_ISWorldObjectContextMenu_createMenu = ISWorldObjectContextMenu.createMenu
ISWorldObjectContextMenu.createMenu = function(player, worldobjects, x, y, test)
    original_ISWorldObjectContextMenu_createMenu(player, worldobjects, x, y, test)

    -- get theFancyObject from worldobjects or player inventory perhaps
    context:addOption("My option name", theFancyObject, onOptionActivation, player)
end```
hollow current
#

I really appreciate the time, thankss

shadow geyser
shadow geyser
hollow current
#

That makes sense

hollow current
# hearty dew So something like: ```lua local function onOptionActivation(theFancyObject, play...

So, I've tried implementing this, mixed parts of it with the source code of another mod that slightly does a similar function of what I am trying to do. I'd love if someone explained what trueself is supposed to be, as well as what I am doing wrong in the code

--hook the menu to install our button
local old_ISVehicleMechanics_doPartContextMenu = ISVehicleMechanics.doPartContextMenu
function ISVehicleMechanics:doPartContextMenu(part, x,y)
    if UIManager.getSpeedControls():getCurrentGameSpeed() == 0 then return; end
    
    local playerObj = getSpecificPlayer(self.playerNum);
    local option;
    local trueself = self.parent;
    if not trueself.context then trueself.context = ISContextMenu.get(trueself.playerNum, x + self:getX() + trueself:getAbsoluteX(), y + self:getY() + trueself:getAbsoluteY()) end--in cases doPart never created the menu, we do it

    -- Call the old version of this function to handle all other parts and actions
    old_ISVehicleMechanics_doPartContextMenu(self, part, x, y);

    if part:getId() == "Battery" then
        local JumpstartOption = context:addOption(getText("ContextMenu_BatteryJumpstarter"), trueself, ISVehicleMechanics.onBatteryJumpstart, playerObj)
    end
end```
hollow current
#

there is also this code, which works perfectly fine except that its not exclusive to the battery only, but to every vehicle part

require "BatteryJumpstarter"

--hook the menu to install our button
local genuine_ISVehicleMechanics_onListRightMouseUp = ISVehicleMechanics.onListRightMouseUp
function ISVehicleMechanics:onListRightMouseUp(x, y)
    genuine_ISVehicleMechanics_onListRightMouseUp(self, x, y);
    
    local trueself = self.parent;--PZ mixes ISVehicleMechanics uses between parent and children, onListRightMouseUp is called on children. but children are not initialized.
    if BatteryJumpstarter.OPTIONS.Verbose then print ("BatteryJumpstarter ISVehicleMechanics:onListRightMouseUp. playernum= "..trueself.playerNum); end
    if not trueself.context then trueself.context = ISContextMenu.get(trueself.playerNum, x + self:getX() + trueself:getAbsoluteX(), y + self:getY() + trueself:getAbsoluteY()) end--in cases doPart never created the menu, we do it
    local JumpstartOption = trueself.context:addOption(getText("ContextMenu_BatteryJumpstarter"), trueself, ISVehicleMechanics.onBatteryJumpstart, trueself.chr, trueself.vehicle)
end

I am sure this is because the function doesn't even have a part parameter to use, but would it be efficient to use this script with a little bit of tweaking?

hollow current
willow estuary
# hollow current That's weird. It doesn't appear on my side

Looks like something is breaking your item picker. Maybe it's another mod? I wouldn't suggest working on mods with other mods activated.
Test them with other mods activated, sure, but generally don't work on them w/other mods unless it's a patch for that other mod or something.

hollow current
#

It's only the mod I am working with that is activated. I'll try joining the world with no mods at all and see if that fixes it

#

yea it was my own mod breaking it. Was breaking vehicle spawner as well for some reason

#

okay figured out both issues. Thanks for the help so much guys!

#

quick question, what to use to check if a vehicle part is missing and check current battery charge while it is installed in the vehicle (not in inventory)? Is there a way to check all the functions you can use with part:function()?

hollow current
#
if part:getId() == "Battery" and part:getUsedDelta() == 1 then``` doesn't work because the ``getUsedDelta()`` is supposed to be for inventory items
undone elbow
hollow current
#

oki another question, hopefully the last today. So, I added a drainable item. I have the following code:

function ISVehicleMechanics:doPartContextMenu(part, x,y)
    if UIManager.getSpeedControls():getCurrentGameSpeed() == 0 then return; end
    
    local playerObj = getSpecificPlayer(self.playerNum);
    local option;

    -- Call the old version of this function to handle all other parts and actions
    old_ISVehicleMechanics_doPartContextMenu(self, part, x, y);

    -- Conditions to jumpstart the Battery:
    -- 1. Battery exists
    -- 2. Player has Jumpstarter
    -- 3. Jumpstarter is not empty
    -- 4. Battery charge is 0%

    if self.chr:getInventory():contains("Jumpstarter") then --If player has a Jumpstarter
        if part:getId() == "Battery" then --If player right clicks on battery
            if part:getInventoryItem():getUsedDelta() == 0 then --if battery charge is 0
               JumpstartOption = self.context:addOption(getText("ContextMenu_BatteryJumpstarter"), playerObj, ISVehicleMechanics.onBatteryJumpstart, part);
            else --This part sets battery charge to 0. For testing purposes only.
                RechargeOption = self.context:addOption("Set charge to 0", playerObj, ISVehicleMechanics.ZeroCondition, part);
            end
        end
    end
end

function ISVehicleMechanics.onBatteryJumpstart(playerObj, part)
    --math.randomseed(os.time())
    local chance = ZombRand(1,100) --Generate a random number between 1 and 100
    if chance <= 75 then
        part:getInventoryItem():setUsedDelta(0.05);
    end
end

The way it should work is that it checks if player has a "Jumpstarter" in his inventory, and if so, and the If conditions are met, it uses up this jumpstarter to set the battery UsedDelta to 0.05, but it also should decrease the UsedDelta of the jumpstarter. How do I store that item in a variable and then manipulate its UsedDelta?

hollow current
#

after a bit of searching, I gathered that I need to loop through inventory items. I stored the player's inventory in a variable, then tried to loop through it, but doesn't seem to work. What's wrong?

function ISVehicleMechanics.onBatteryJumpstart(playerObj, part)
    local chance = ZombRand(1,100) --Generate a random number between 1 and 100
    local invent = playerObj:getInventory()
    if chance <= 75 then
        part:getInventoryItem():setUsedDelta(0.05);
        for i=0, invent:size()-1 do
            local item = invent:get(i)
            if item:getType() == "Jumpstarter" then
                item:Use()
            end
        end
    end
end
shadow geyser
hollow current
#
function ISVehicleMechanics.onBatteryJumpstart(playerObj, part)
    local chance = ZombRand(1,100) --Generate a random number between 1 and 100
    local invent = playerObj:getInventory()
    local item = invent.getItemFromType("Jumpstarter")
    if chance <= 75 then
        part:getInventoryItem():setUsedDelta(0.05);
        item.Use()
    end
end```
shadow geyser
#

you need to use :

hollow current
#

oh excuse me, still not used to lua haha

shadow geyser
#

I think Use() also needs to be with a colon as well, but I might be mistaken

hollow current
#

i think it successfully got the item and stored in the variable since it thrown an error at the use part

#

gonna add a semicolon and see if that fixes it

#

hmm nope, still throwing an error at item.Use();

#

... because it should be item:use i think

#

item:Use() without semicolon does work. It fixed it, thanks!
Although a problem is that if the player has a stack of jumpstarters, it only stores in the variable the first one

shadow geyser
#

isn't that correct, its not like if you have 10 jumpstarters, you are using all ten to jumpstart the battery

hollow current
#

What i mean is, assuming i have two, and one of them is fully depleted, would it be possible to have the script ignore it and move on the second?

shadow geyser
#

oh I see, then just use getItemsFromType which will return an array of all of them, then just loop through to use one which has sufficient uses left

hollow current
#

Lovely, thank you so much for time. It means a lot!

maiden hound
#

Does anyone know how to mamually install a mod? (i.e. a zip file containing a mod)

radiant venture
#

does anyone know where the code responsible for in game time is?

#

or the code responsible for item spawning?

hearty dew
#

There is an example mod there that should serve as a guide to how the directories should be structured

maiden hound
#

Thanks man

ancient grail
#

hi .
is it posible to have a function act on items placed on ground? timebased
similar to despawn but instead of despawning it it does something else

undone elbow
#

How to check if the player sees a square?

hollow current
#

Would anyone have an idea of how to show a textbox?

#

This line is included in a mod that uses a textbox but seems outdated.

    local modal = ISTextBox:new(0, 0, 280, 180, getText("Change item name"), weapon:getName(), nil, ISInventoryRenameWeapon.onRenameWeaponClick, player, getSpecificPlayer(player), weapon);
hearty dew
#

What kind of textbox? Like a tooltip? Or a modal dialog that the user has to dismiss?

hollow current
#

a window with a textbox where the player has the ability to write in, then can press the "ok" button

#

i think i figured it out though, gimme a min

#

nope, didn't

#

Okay I just did, thanks!

shadow geyser
hollow current
#

btw, we allowed to publish own mods here, or is the channel dedicated for modding questions only?

violet fractal
#

Hello, has anyone has made an UI children button? I don't know what wrong I've done but I keep getting an error when I call the addchild() function

function ISMiniHealth:createChildren()
    self.bottomPanel = ISPanel:new(5, 5, 20, 20)
    self:addChild(self.bottomPanel)
end
#

Seeing other codes around they just call the addChild() with just the children element as an argument and that's it. But I doesn't want to let me to it in my code for some reason I still don't know...

shadow geyser
violet fractal
#

I took the piece of code from vanilla ISMiniMap.lua and it does nothing else before calling the addChild() function

function ISMiniMapOuter:createChildren()
    local btnWid = 31
    local btnHgt = self.bottomHeight - 1

    self.bottomPanel = ISPanel:new(self.borderSize, self.inner:getBottom() + 1, self.inner.width, btnHgt)
    self:addChild(self.bottomPanel)
    self.bottomPanel:setVisible(false)

end
shadow geyser
#

try setting self.bottomPanel.enable = true

violet fractal
#

I even tryed to add self.bottomPanel.anchorBottom = false since the error stack trace on ISUIElement.lua stops there but still same issue

hearty dew
#

Might be some layout validation or child element validation that is occurring in java. I don't have the java code decompiled, but might be worth doing to see why setAnchorBottom is throwing that exception

#

or maybe it is a type mismatch, actually

#

Oh, hrm, it just looks like a boolean

#
    self.bottomPanel = ISPanel:new(5, 5, 20, 20)
    self.bottomPanel:initialise()
    self.bottomPanel:setAnchorRight(false)
    self.bottomPanel:setAnchorLeft(true)
    self.bottomPanel:setAnchorBottom(false)
    self.bottomPanel:setAnchorTop(false)

    self:addChild(self.bottomPanel)
#

Does that work, explicitly setting all the anchors in a consistent manner?

violet fractal
#

Funny, now the stack trace stops at line 649 at ISUIElement.lua

#

I will try to fiddle with those

shadow geyser
#

try taking a look at the UI api mod on workshop

hearty dew
#

Possibly could be something in parent that those values are validated against. Looking into those java methods could shed more light onto what exactly is happening. I don't have the java decompiled, otherwise I would

shadow geyser
#

it has code for creating buttons really easily, so you can check how those functions are creating buttons, and it should inform you whats wrong

#

actually, is it only the button that is not working? do you have any other UI working?

violet fractal
#

This is the only time I try to add child element

shadow geyser
#

ok can you send what the current code you have is, then the error you get when you run it

winged lotus
#

Good evening all, I have a quick question, is there a way/event I could use in shared lua code to edit an item (i.e. condition/name of a weapon) at the specific moment it is loaded in the container?

shadow geyser
#

OnfillContainer

violet fractal
#

I changed where ISMiniHealth:createChildren() is called

#

It was called inside ISMiniHealth:new(), I moved it outside right after ISMiniHealth:initialize() and ISMiniHealth:instantiate() are called

#

Yeah it definitely fixed my issue. My function was called at the wrong place.

#

Well sorry, that was a kinda dumb mistake, thank for taking your time

winged lotus
weak sierra
#

i know there's a way to loop get all items

#

but i can't find it atm, been a bit

#

anyone point me at that?

#

hm

#

so i need to loop through all recipe-teaching magazines/books

#

i am unable to find a way to just get all items and then loop through that and filter

#

anyone?

dark finch
#

Why is it so hard to commission a mod? Is modding that hard? excuse me if i sound ignorant cuz i am but I literally just want a vending machine that only excepts gold jewelry. and if i could put my own items in it and set the price that would be great.

meager lion
#

Its time consuming and usually done as a labor of love, just combing over the JavaDocs to be come familiar with the API takes time

winged lotus
#

Yeah it's usually hard and quite time consuming, and sometimes even for nothing. For example, I just spent the last 4 hours on a piece of enhancement code for an existing mod without any conclusive result. I mean, it's very nice when everything works out but it can also kind of feel like a job and it requires quite the motivation to persevere until a stable mod is achieved.

undone elbow
#

Quick question. I'v added an item on the server to a player's inventory and changed UsedDelta. How to transmit changes to the client?

winged lotus
#

(And not even speaking of maintenance here πŸ˜…)

dark finch
#

Damn where do u even begin learning mod creation for this game? Id love to learn cuz i got plenty of great ideas

winged lotus
ebon wing
#

like onkeen said its usually a labor of love and feels like a job. Modders are naturally in the coding field usually in the same language so its like they can come home and make magic happen after work in their spare time otherwise your living life and learning the language in the gaps

jaunty gate
#

What's the best way to detect if a player is say within 5 squares of a body of water (natural water, not rain barrel or whatever)?

shadow geyser
shadow geyser
weak sierra
weak sierra
#

i started by making my own versions of others' mods with permission

#

e.g., adding features and such

#

w/o needing permission, you could also try making plugins that modify and require existing mods

#

after a few of those you may feel confident enough to make your own stuff

#

or you can just jump into it MD_Shrug

#

i just did that because it was what i wanted to do at the time

#

i concur with robot's advice re: your own first few mods that aren't based on or plugins to others' tho

lime hedge
#

@shadow geyser do the server code will run even when there's no player?, tried to iterate every SH then the floor, for checking containers and the items in it.

#

Also, I made a syntatic recipes, to execute some moddata manipulation to the item(ingredients) with RemoveResulItem, tried every ways, when performing to all items, it doesn't loop thru item with the sam type, or either the loop wont stop at all.

shadow geyser
meager lion
#

@jaunty gate Personally if I was to go about checking for water around a players position it would be a double For loop (One inside the other), with a max of 5 iterations of both Checking if each tile is water, then breaking the loop as soon as it finds a confirmation, if no matches are found the 25 tiles checked, then when the player moves in a X/Y direction check the 5 tiles in said direction until a match was found.

weak sierra
#

it probably still means nothing is loaded

#

but

#

code still runs

#

e.g., plant watering updates happen, my update checking mod runs, and so on

lime hedge
lime hedge
lime hedge
#

wanted to iterate thru all of certain type of items in the world, and update moddata in it. i'm sure this should be done in server, since client only load what it sees.

lime hedge
#

@weak sierra @shadow geyser thanks anyway, there's another question, is there any different between require() and require "xx" ??, I saw in intelliJ, require("xx") are only accepting function param, let's say I wanted to require file client/Timed/A.lua (A.lua doesn't return anything, only global func inside of it) from another mod, what's the right way to require it? "client/Timed/A" or just "Timed/A", I'm not sure tho

lime hedge
weak sierra
#

hehehe

#

yeah

#

no

#

you can't do a damn thing without things loaded

#

you could from java

#

the only way to do that would be to move a "character" through the world to load things like a cursor

#

afaik

#

it's best to run code on the client and throttle it by how long it's been since the code ran to kinda "simulate" having it run serverside instead

#

if the code itself has to execute from server then use a command sent from the client to the server

#

but getting complete lists of X in cell and such is an impossibility as it all depends on the reality bubble of a player

#

really wish they'd add functions to force a square, chunk, or cell to load completely

#

that way things like this could be done without pain

#

you could iterate through whatever spatial unit is required and do whatever

hearty dew
#

And in that scenario, you'd want require("Timed/A")

lime hedge
#

alot

weak sierra
#

good to know

lime hedge
# weak sierra it's best to run code on the client and throttle it by how long it's been since ...

Ah I see... do you have any example for throttling/debouncing?, now I'm relying on throttling/debouncing guard on every10mins tick, i dunno if that's the right approach, would love to know if there's some kind of object/chunk onload to trigger function execution, so I dont have to rely on 10 min tick to check something, knowing the code will only run if the chunk is loaded, I assume this way -> if the player go far from that cells before the next event tick.. the code will not reach that object.

#

or probably I should try to derive from SGlobalObject to test on something, probably its possible to make it global like a plants

weak sierra
#

there's an on load for squares

#

LoadGridsquare and ReuseGridsquare

#

i have some code i wrote for vehicle-related stuff

lime hedge
weak sierra
#

i loop thru all vehicles loaded in the area on OnPlayerMove

#

but only run that if it's been N real minutes/seconds since the last

#

or if the cell changes

#

and then do proxy check on each

#

in one of my mods

lime hedge
#

except this only for container/items check

#

in every loaded square with container in it

weak sierra
#

u might take a peek at Time Decreases Loot

#

and their proximity container code

#

cuz it's probably what ur trying to do..?

lime hedge
meager lion
#

Does anyone by chance know what file contains how Carry weight is calculated?

weak sierra
#

no but if you find it please lmk

#

i wouldn't mind adjusting that

meager lion
#

IsoPlayer:setMaxWeightBase(value);
is the best ive found, problem is that it doesnt adjust with player health etc.

#

and id rather avoid repeat checks

lime hedge
# weak sierra cuz it's probably what ur trying to do..?

well it's more like transforming the said item to another one after a period, probably like fresh to become rotten, I haven't seen the fresh/rotten code yet, since this is only a patch that i'm working on, I try not to do a total overhaul/override to the core concept of the transformation, so for now have to rely on timestamp moddata before it supposed to change, also this is some kind of playground for me to learn Lua as well

#

the code has flaw, where it only do daily tick, whereas if player fails to be on certain cell on that tick, it wont transform at all..

weak sierra
#

im pretty sure that that's what the base game does, has a timestamp and then calculates what should be done when the item updates

#

but i dont know for sure either

#

cuz stuff rots in ur inventory when ur offline

#

and that's stored in players.db in multiplayer

#

in a binary blob

#

so it isn't being updated while ur offline

#

therefore timestamp probably

lime hedge
lime hedge
meager lion
#

Closest hint ive found so far

#

sadly thats player weight lol

weak sierra
#

looks like it's based on a nutrition object

#

ah

#

yeah that's not relevant then

lime hedge
meager lion
#

You sir, are my hero lol

lime hedge
#

idunno ifthat what ure lookin for

meager lion
#

Thats EXCATLY it

lime hedge
#

yea there's this.BodyDamage.ReduceGeneralHealth(var2); since you're talkin abt health

meager lion
#

where are you accessing that btw?

lime hedge
#

@meager lion btw it's 12k lines long.. :S

meager lion
#

not surprised since it stores and handles all the stats of a player

lime hedge
weak sierra
#

there's also setMaxWeightBase in there

meager lion
#

Everything on the JavaDocs for IsoPlayer is in that lol

lime hedge
weak sierra
#

yeah but not always the other way around

#

sometimes stuff is in there but not exposed

meager lion
#

True

#

I was more interested in the formulas then anything since that was shrouded in mystery for me lol

lime hedge
#

tbh I can't scroll the code easily....

#

lol

weak sierra
#

the snippet of code we were seeing was fall damage

#

the setting of max weight is just.. thing = thing

lime hedge
#

I wonder if it's because a decompiled source, do devs really wrote 12k lines long? :S

meager lion
#

Sadly some files end up that way

weak sierra
#

that has an impact but it's usually not ludicrously longer

#

bytecode only has so many interpretations

lime hedge
#

I just blatantly press ctrl+b (go to declaration/usages) all the time to scroll it..

lime hedge
weak sierra
#

the names of locals are lost at compile time

#

thus the generic names for some things and not others

#

when u decompile

#

non-local things could be referenced by external code

#

thus they are in the output

#

the symbols

#

unless u have a debug build ofc

#

in which case it's all there

lime hedge
weak sierra
#

that'd be nice :p

#

if there's an equivalent in java

#

ofc they could also just add a java modding hook

#

i'd kill for that πŸ˜‚

#

lua is painful

#

and the exposed api is limited

lime hedge
weak sierra
#

no point, i mod for my server

lime hedge
weak sierra
#

and ppl won't be installing a modding hook into their game files by hand

#

so

#

useless to me

lime hedge
#

no typesafe either.. i came from typescript.. so yeah.. make me pretty confused

lime hedge
#

so it need hooks

weak sierra
#

there's a thing called pipewrench that lets u mod PZ in typescript

#

it has limitations

#

but

#

sounds nice ig? i dont know typescript and i've already learned lua tho

lime hedge
lime hedge
#

yesterday alr ask Konijima, he's not sure either, so probably I should just wait for the next version of pzpw before using it,

weak sierra
#

i have a decade or so of experience in C#

#

typescript sounds preferable to js

#

but it's js-based, not C#-based

meager lion
#
if (this.Traits.Strong.isSet()) {
         this.maxWeightDelta = 1.5F;
      }

      if (this.Traits.Weak.isSet()) {
         this.maxWeightDelta = 0.75F;
      }

      if (this.Traits.Feeble.isSet()) {
         this.maxWeightDelta = 0.9F;
      }

      if (this.Traits.Stout.isSet()) {
         this.maxWeightDelta = 1.25F;
      }```
#

Rather weird this is done it seems

#
this.getParentChar().setMaxWeight((int)((float)this.getParentChar().getMaxWeight() * ((IsoPlayer)this.getParentChar()).getMaxWeightDelta()));```
lime hedge
lime hedge
meager lion
#

you can set the Delta to adjust the multiplier, i would assume this is just a quick and easy tweak for strength

lime hedge
#

getMaxWeight() << is this max character weight, or main inv weight?

#

i see

meager lion
#

Heres where it gets kinda interesting 1 sec

#

heres the whole snippet for everyon

#
this.getParentChar().setMaxWeight((int)((float)this.getParentChar().getMaxWeightBase() * this.getParentChar().getWeightMod()) - var1);
         if (this.getParentChar().getMaxWeight() < 0) {
            this.getParentChar().setMaxWeight(0);
         }

         if (this.getParentChar().getMoodles().getMoodleLevel(MoodleType.FoodEaten) > 0) {
            this.getParentChar().setMaxWeight(this.getParentChar().getMaxWeight() + 2);
         }

         if (this.getParentChar() instanceof IsoPlayer) {
            this.getParentChar().setMaxWeight((int)((float)this.getParentChar().getMaxWeight() * ((IsoPlayer)this.getParentChar()).getMaxWeightDelta()));
         }```
#

var1 is all moodlets

#
if (this.getParentChar().getMoodles().getMoodleLevel(MoodleType.Bleeding) == 4) {
            ++var1;
         }```
#

Hungry, Thirst, Sick, Bleeding, Injured 2,3 & 4

#

Line 1791 of BodyDamage.java

#

is the strength modifier

lime hedge
#

ah yeahhh interesting tho, can you edit it with triple '''java

#

so ppl can see the syntax highlight, the chain method make it pretty mess to read

meager lion
#

mb lol

lime hedge
lime hedge
meager lion
#
public float getWeightMod() {
      int var1 = this.getPerkLevel(PerkFactory.Perks.Strength);
      if (var1 == 1) {
         return 0.9F;
      } else if (var1 == 2) {
         return 1.07F;
      } else if (var1 == 3) {
         return 1.24F;
      } else if (var1 == 4) {
         return 1.41F;
      } else if (var1 == 5) {
         return 1.58F;
      } else if (var1 == 6) {
         return 1.75F;
      } else if (var1 == 7) {
         return 1.92F;
      } else if (var1 == 8) {
         return 2.09F;
      } else if (var1 == 9) {
         return 2.26F;
      } else {
         return var1 == 10 ? 2.5F : 0.8F;
      }
   }```
#

Somewhat yes

#
setMaxWeightDelta​(float float1)
setMaxWeight​(int int1)
setMaxWeightBase​(int int1)```
#

off of IsoPlayer

hearty dew
#
if (this.getParentChar().getMoodles().getMoodleLevel(MoodleType.FoodEaten) > 0) {
            this.getParentChar().setMaxWeight(this.getParentChar().getMaxWeight() + 2);
         }```
Never understood this. IRL I lift less if I'm overstuffed with food, but it's temporary strength buff in pz πŸ˜‚
meager lion
#

I wonder if Overstuffed isnt classified as a Positive Food eaten moodle?

hollow current
#

few questions
1- How do I make it so that a context menu option that I added is reddened out (can't be pressed)
2- How do I add a tooltip to the context menu option so that it appears as some kind of a description when mouse is hovered over it
3- How do I get the "generator" object that is placed in the world, so that I can add an option to its context menu when its right clicked?

hearty dew
#

#3, might look in ISWorldObjectsContextMenu.lua (I think that's the filename). If not, can try grepping around for the term 'generator'

lime hedge
#
ISFarmingMenu.canPlow = function(seedAvailable, typeOfSeed, option)
    local tooltip = ISToolTip:new();
    tooltip:initialise();
    tooltip:setVisible(false);
    option.toolTip = tooltip;
    tooltip:setName(getText("Farming_" .. typeOfSeed));
    local result = true;
    tooltip.description = getText("Farming_Tooltip_MinWater") .. farming_vegetableconf.props[typeOfSeed].waterLvl .. "";
    if farming_vegetableconf.props[typeOfSeed].waterLvlMax then
        tooltip.description = tooltip.description .. " <LINE> " .. getText("Farming_Tooltip_MaxWater") ..  farming_vegetableconf.props[typeOfSeed].waterLvlMax;
    end
    tooltip.description = tooltip.description .. " <LINE> " .. getText("Farming_Tooltip_TimeOfGrow") .. math.floor((farming_vegetableconf.props[typeOfSeed].timeToGrow * 7) / 24) .. " " .. getText("IGUI_Gametime_days");
    local waterPlus = "";
    if farming_vegetableconf.props[typeOfSeed].waterLvlMax then
        waterPlus = "-" .. farming_vegetableconf.props[typeOfSeed].waterLvlMax;
    end
    tooltip.description = tooltip.description .. " <LINE> " .. getText("Farming_Tooltip_AverageWater") .. farming_vegetableconf.props[typeOfSeed].waterLvl .. waterPlus;
    local rgb = "";
    if seedAvailable < farming_vegetableconf.props[typeOfSeed].seedsRequired then
        result = false;
        rgb = "<RGB:1,0,0>";
    end
    tooltip.description = tooltip.description .. " <LINE> " .. rgb .. getText("Farming_Tooltip_RequiredSeeds") .. seedAvailable .. "/" .. farming_vegetableconf.props[typeOfSeed].seedsRequired;
    tooltip:setTexture(farming_vegetableconf.props[typeOfSeed].texture);
    if not result then
        option.onSelect = nil;
        option.notAvailable = true;
    end
    tooltip:setWidth(170);
end
hearty dew
#

#2, not sure about context menus specifically, but other ui elements have a tooltip key used for that purpose. If you have an example of a tooltip in a context menu in-game, you could take that string and try searching for it in the lua code. I don't know of any off the top of my head to search for

lime hedge
#

local MENU = context:addOption("Sow Seed", player, OnClick, args...), something like that

then your tooltips function like above .canplow which take option as the third args, so xxx:canPlow(arg1, arg2, MENU)

hollow current
#

Thanks so much for the help!

frank swan
#

hey guys, I ended up adding black wood to my home hosted server and it doesn't seem to come up as an option to spawn in, town is there and everything just no option to spawn in, anyone know how to fix this? or do I have to manually add the location?

meager lion
#

I would assume you need to add in custom spawn locations

#

use either
servertest_spawnpoints.lua or
servertest_spawnregions.lua

frank swan
#

@meager lion that's what I assumed, I had the conclusion that maybe not because it works fine on the steam hosted servers.

#

thanks man

meager lion
#

np, gl

frank swan
#

@meager lion any clue how to check downloaded mods?

#

this is all I'm seeing

meager lion
#

its done through servertest.ini

frank swan
#

yeah, I'm just trying to find the main download of the mods

meager lion
#

As for if they download that im not sure on, ive got a dedicated for my projects

frank swan
#

just wondering is all

shadow geyser
shadow geyser
# lime hedge <@370376376269930497> <@534578288899653654> thanks anyway, there's another quest...

use require "path\to\filename" when you just want to ensure another file has been loaded first. use require("path\to\filename") when that file name also is returning an object, typically a lua table. the require function with the brackets is a nice way to access tables without having to put them into the global space, as you can store all the functions from that file inside their own table and return the table in that file. as an example:
library.lua:


mylib = {}
function mylib.foo ()
    functionstuff
end

function mylib.bar()
    functionstuff
end
return mylib

so in another lua file

mylib = require("path\to\library")

the mylib object now contains those functions. you can do this to store constants, or even just data for your mod. its a really good way to keep the global table clean

lime hedge
lime hedge
# shadow geyser use ``require "path\to\filename"`` when you just want to ensure another file has...

Ah... I see, for now I only want to ensure another file has been loaded first, somehow the original function in the mod that I patch still get called instead of the overridden func, probably because the code lies in the Client (original), meanwhile I override in the Client (patch) as well, then need to call those function in the Server, I guess I have to move it out to Shared so server can call the new function instead of the original one.

shadow geyser
hollow current
#
local BatteryJumpstarter = {}
local generator = nil;

Events.OnFillWorldObjectContextMenu.Add(function(player, context, worldobjects)
    local objects = player:getSquare():getObjects()
    for i = 0, objects:size() - 1 do
        local object = objects:get(i)
        if instanceof(object, 'IsoGenerator') then
            generator = object
        end
    end
    if generator then
        local playerObj = getSpecificPlayer(player)
        local playerInv = playerObj:getInventory()
        local option = context:addOption("test", worldobjects, BatteryJumpstarter.onJumpstarterRecharge, generator, player)
    end
end)

function BatteryJumpstarter.onJumpstarterRecharge(worldobjects, generator, player)
    print("test")
end

return BatteryJumpstarter```
#

Any idea why I get an error thrown at local objects = player:getSquare():getObjects()?

#

code is supposed to check the objects in the square that the player right clicks, and if it has a generator, it adds a context menu option

#

okay i figured it out, it should've been local objects = playerObj:getSquare():getObjects()

#

but now the option appears only when I stand on the generator. I guess this code checks the square where the player is standing, not where he presses

#

any idea how to get around it?

hollow current
#

How do I make it check for the click square instead of the playerobj square?

lime hedge
#

@hollow current probably ISSelectCursor:onSquareSelected

hollow current
#

throws an error

hollow current
#

@lime hedge I think the ISSelectCursor needs to be defined first? i am not sure

lime hedge
lime hedge
shadow geyser
winter bolt
#

what the dog doin

hearty dew
shadow geyser
#

might be correct, but in either case, ever where I see it being used, when actually catching the returned objects, I always see people using the bracketed version, and the keyword version when just making another lua file load first

hearty dew
#
stat ::= varlist β€˜=’ explist
    varlist ::= var {β€˜,’ var}
    explist ::= exp {β€˜,’ exp}

stat ::= functioncall

    exp ::=  nil | false | true | Numeral | LiteralString | β€˜...’ | functiondef | 
         prefixexp | tableconstructor | exp binop exp | unop exp 

    prefixexp ::= var | functioncall | β€˜(’ exp β€˜)’

    functioncall ::=  prefixexp args

    args ::=  β€˜(’ [explist] β€˜)’ | tableconstructor | LiteralString```

Looks valid as an assignment statement either way with the grammar from the 5.4 lua documentation
#

Functions the same way too. Just tested it in pz.

local JSON = require "lib/JSON"```
hollow current
#

By the way, I also looked at the vanilla source code

#

IsWorldObjectContextMenu.lua

#

it has something to define the generator, like:

ISWorldObjectContextMenu.fetch = function(v, player, doSquare)
    local playerObj = getSpecificPlayer(player)
    local playerInv = playerObj:getInventory()

    local props = v:getSprite() and v:getSprite():getProperties() or nil

    if v:getSquare() then
        local worldItems = v:getSquare():getWorldObjects();
        if worldItems and not worldItems:isEmpty() then
            worldItem = worldItems:get(0);
        end
    end
    if v:getSquare() then
        building = v:getSquare():getBuilding();
    end
    if v:hasWater() then
        -- Don't choose a puddle if a sink is available.
        if not storeWater or isPuddleOrRiver(storeWater) then
            storeWater = v;
        end
    end
    c = c + 1;
    if instanceof(v, "IsoGenerator") then
        generator = v;
    end
end```
#

i've tried to implement it in my code as well, but no luck so far. It doesn't throw any errors, but the option doesn't show up at all

small topaz
#

I am currently working on a mod which adds new food items which can possibly be poisonous. Want to arrange things so that the player can detect that they are poisonous according to the same rules as in the vanilla game (i.e. depending on the player's cooking skill). What I have found out so far is that there is a java method called setPoisonDetectionLevel(int) which is somehow related to the visibility of poison in a food item.

Does anyone knows how this setPoisonDetectionLevel command exactly works? I did some play-testing with it but have not been able to see things clearly atm...

hearty dew
small topaz
# hearty dew .

Thanks for the suggestion. If no one has any experience with said java command, I'll probably should have a look at it.... 😐

hollow current
#

um im still facing issues. Can't solve it so far.

require 'ISUI/ISWorldObjectContextMenu'

ISWorldObjectContextMenu.fetchSquares = {}

local BatteryJumpstarter = {}
local generator = nil;

Events.OnPreFillWorldObjectContextMenu.Add(function(player, context, worldobjects)
    --Detect if the generator exists, somehow?
end)

Events.OnFillWorldObjectContextMenu.Add(function(player, context, worldobjects)
    local playerObj = getSpecificPlayer(player)
    --local objects = playerObj:getSquare():getObjects()
    --for i = 0, objects:size() - 1 do
        --local object = objects:get(i)
        --if instanceof(object, 'IsoGenerator') then
            --generator = object
        --end
    --end
    if generator then
        if generator:isActivated() then
            local playerInv = playerObj:getInventory();
            local option = context:addOption("Recharge Jumpstarter", worldobjects, BatteryJumpstarter.onJumpstarterRecharge, generator, player);
        end
    end
end)```

This is what I have
hearty dew
# small topaz Thanks for the suggestion. If no one has any experience with said java command, ...
        poisonChance            = 0,                                            --percent chance the item is poisoned
        poisonPowerMin          = 0,                                            --minimum amount of poison to apply
        poisonPowerMax          = 0,                                            --maximum amount of poison to apply
        poisonDetectionLevel    = 0,                                            --level required to detect the poison

That's from forageDefinitions.lua. Just a hunch, but I'm guessing that the value provided to the setPoisonDetectionLevel() method sets the cooking skill level at which a player can see whether an item is poisoned?

small topaz
# hearty dew ```lua poisonChance = 0, ...

Many thanks! I searched the whole zomboid folder via a certain commands for the string "PoisonDetectionLevel" but this hasn't been shown to me in the result! Very helpful!!

ah no... I think I searched for "getPoisonDetection" and therefore missed that result.... XD