#mod_development

1 messages ยท Page 523 of 1

thin hornet
#

You need to decompile

fathom hare
#

hey

#

is the WordZed radio preset editor from Azakaela still valid today?

drifting ore
#

Ok no mb, that work

#

But now I don't find createRunConfigurations

thin hornet
#

Top right you open gradle menu

#

after you saved the change it should be there

drifting ore
#

Hey I just saw that thx

#

Never used intellij before

thin hornet
#

well you seem to have it easy as of now

#

You dont have to use intellij after than as it take quite a lot of ram

#

but if you do its very powerfull

drifting ore
#

For small project I prefer vs code

thin hornet
#

Yeah thats what im using too atm

#

i moved the decompiled code at the root of my vs project to search into it.

drifting ore
#

That what I plan to do

#

I like jetbrains for pycharm and dataspell

thin hornet
#

i also copied all pz lua code at the root. so i have some sort of lua autocomplete and parameter suggestion

thin hornet
#

great

#

hehe

drifting ore
#

I can't find setupWorkspace after running createRunConfigurations

#

Ok mb, I get it

#

Everything is in a build folder, right?

thin hornet
#

yeah

drifting ore
#

Ok, thx ! I get what I wanted

next glacier
#

ok mod was sorking

#

but

harsh prairie
#

Is there a special way to format the description page for spawn locations? I am just using paragraphs but that makes the text go blank

next glacier
#

math.floor((filth / 2)+0.5)
filth = bloodAmount + dirtAmount

#

so it should be like
11+12 = 23/2 = 11.5+.5 = 12

#

wait

#

thats wrong xD

#

12/100
1/10
1/1 water

#

ah so i have to divide by 20

#

right right

#

sorry, explaining it to myself helped

small topaz
small topaz
#

@harsh prairie if it just about making paragraphs and therefore making new lines in the description, my first try would be just adding a \n to the text or, if that doesn't work, you can try using <br>. have you tried those?

#

not sure if that solves the issue though...

harsh prairie
#

I have not. Those are the kinds of things I have no idea about! I'll give them a try

thin hornet
#

Might try <LINE> too

#

with a space before and after

harsh prairie
#

@thin hornet <LINE> did the trick, thank you!

thin hornet
#

its confusing sometime its \n or <br> but yeah glad it worked

harsh prairie
#

I did try the \n and <br> in the same way you said to use <LINE> and they did not work that way, but since line works I am just going to write that one down and use it.

small topaz
#

i usually try everything until it works! XD i guess it might be related to the question whether your text is given in "..." or without quotation marks but not sure

thin hornet
#

i hope they fix the power outage soon or ima have to go loot a generator somewhere

small topaz
thin hornet
#

irl i dont have electricity. in the middle of coding it went out

next glacier
#

F

thin hornet
#

yeah Rip

small topaz
#

XD XD i guessed you meant something with the power shut off in game! XD XD XD

thin hornet
#

xD

next glacier
#

btw how many colors are the game textures?

#

I think I can make some textures

#

i think, but probably cant actually xD

#

Ah I think I see part of the problem with getting the code to work

#

it errors if I dont restart the game

#

quitting to menu doesnt work

weary crypt
#

Would it be possible to make the large fuel can from FuelAPI wearable as a backpack without breaking it's ability to carry fuel?

next glacier
#

12+34 = 46 / 20 = 2.3

#

2.3 rounded off is 2

#

2 water

#

hurray

#

also fixed the 0/0 water

#

by doing an elseif math.floor((filth/20)+0.5) < 1

#

was wondering why it didnt work at first because i set it to <0 facepalm

#

then i digged in for the actual numbers and when i say 0.0000123***

#

got it

next glacier
#

since weapons arent containers but you can wear them on back

#

but idk the code for that sorry

weary crypt
#

I'll try the seemingly obvious route of just adding the attribute to equip it on the back and see what happens

willow estuary
weary crypt
#

Damn, that's a shame.

#

Would there be a way to convert the item between a container and a drainable while storing it's fuel state?

#

Or would it just be needlessly complicated

willow estuary
small topaz
#

or creating a new clothing item which just looks like the gas can equipped on back and then doing some tricky interface tweaks so that the player believes they are equpping the gas can on their back

next glacier
#

like a dummy item

willow estuary
#

Yeah, that's doable, but, yeah, there's no way I could simply explain how to do it?

small topaz
next glacier
#

like me :/

weary crypt
willow estuary
#

I dunno, TBH I just go for the low effort easy wins where I can just cut and paste code snippets of mine and such that can help someone out?
I'm not any good at teaching or explaining stuff, I just know how to cut and paste. ๐Ÿ˜

next glacier
#

isnt it possible to just add a tag something like isWearable or something

weary crypt
#

That's fair, I don't mind doing some research I'm just not particularly sure where to start.

next glacier
#

or a cheaty way make it a clothes

weary crypt
small topaz
willow estuary
# next glacier isnt it possible to just add a tag something like isWearable or something

No. I don't like saying things aren't possible in that people take it as a challenge, or that I'm trying to stifle creativity.
But I'm saying this to save people's time, in that it is currently impossible. Clothing, Containers (as in backpacks/bags), and AlarmClockClothing are the only categories of items that can be worn like clothing. Only those two types of items. No radios. No drainables. No food. No weapons. Just clothing and containers. That's it. It's hardcoded in the Java AFAIK. It's something I've repeatedly tried myself. It don't work.

Any type of item would probably work for attaching like weapons. But you would have to attach them to a clothing item that has a hotbar slot.

weary crypt
willow estuary
#

Any type of item would probably work for attaching like weapons. But you would have to attach them to a clothing item that has a hotbar slot.

next glacier
#

Jerrycans mod doesnt work?

weary crypt
#

As Blair said, it's defined as a drainable not a container or clothing item

next glacier
#

Yeah

#

Probably why it cant be worn even if it has canbequipped back

small topaz
#

i guess you also have to tell the game how to position such and item correctly when attached. even if the game would come with some default way to attach arbitrary items, it will probably look quite glitchy depending on the actual 3d design of the item in question.

weary crypt
#

I'm trying to think of a mod that has an example of something that changes states and returns to it's original condition to look for an example of how to store that information. Maybe a firearm mod that lets you fold/unfold a stock since it keeps it's condition between iterations despite being a different item.

weary crypt
willow estuary
weary crypt
#

I'll take a look at that, thank you. ๐Ÿ‘

next glacier
#

yeah that sounds like dummyitem to me

#

I have a dumb and stupid idea i dont recommend

#

like adding a dummy backpack that looks like gascan

#

that spawns when you click a contextmenu that you can label as "wear"

#

and puts the gascan inside

#

but thats stewpid xD

small topaz
next glacier
#

because i can think of some issues

#

like how to limit what specific items get inside

#

or if you can hide the tab in inventory

next glacier
#

Is there a limit to the number of colors you can use in the game?

#

for making textures?

#

either its very limited or, we arent that good at making them

small topaz
#

to give clothing items the option of different colors, you just have to set a single option in their xml file as true and make their texture white. the rest should then work automatically

next glacier
#

i assume they arent completely white but maybe 10-20% grey

#

but i mean the item icons

#

btw.

#

because i saw some heels in general chat

small topaz
#

ya... at least a very light color. but you should introduce some "shadows" or "contours" to their texture to make them look decent.

next glacier
#

yeah built-in ambient occlusian

#

because game doesnt have it

weary crypt
#

Is there somewhere I can see a list of all vanilla item definitions?

small topaz
weary crypt
hidden compass
#

Is there a sample to add a display to an existing inventory Tooltip (Mouseover on each item)?

I've found InventoryItem:setTooltip(String), but I think this may interfere with other mods. I'm looking for samples with other methods. I would also like to specify a different color for the label and value if possible. (Label: yellow, value: white)

Best regards ๐Ÿ™‚

next glacier
#

here

#

idk if this has it

#

but contains everything in game

weary crypt
#

Thanks. ๐Ÿ‘

solemn marsh
#

if i add a mod do i need to start a new save

next glacier
next glacier
#

unless you are willing to go to unloaded chunks

solemn marsh
#

what if i have it so loot spawns again after a long time

next glacier
#

unless you have lootrespawn

#

but lootrespawn works on unloaded chunks iirc

modest yarrow
hidden compass
#

@next glacier
Thanks for reply.
InventoryItem#setTooltip(String) is just add only label, and the display was one color like attached image.
If possible, I would like to display the label in yellow and the value in white, just like the existing Tooltip.

Also, I have overridden the ISToolTipInv.render function, but if other mods override the same function, it should conflict.
So I'm looking for other method to add tooltip line.

MYMOD.original_render = ISToolTipInv.render
function ISToolTipInv:render()
    if not CONDITION then
        MYMOD.original_render(self);
    end
    self.item:setTooltip("label: value");
end
small topaz
#

this will minimize conflicts with other mods. otherwise, if you change the tooltips of vanilla items and there is another mod changing the tooltips of the same items, there is no way to avoid conflicts.

modest yarrow
hidden compass
# modest yarrow Take a look at the mod: "Effons Have I foud this book"

Yes, I already check that mod. but I cannot hook that event. Something wrong?

MYMOD.myfunc = function (item, self)
    getSpecificPlayer(0):Say("[DEBUG] called")
end
Events.OnBeforeFirstInventoryTooltipDisplay.Add(MYMOD.myfunc)
Exception thrown java.lang.RuntimeException: attempted index: Add of non-table: null at KahluaThread.tableget line:1689..
thin hornet
modest yarrow
#

ACtually I think it's a custom event from the mod

thin hornet
#

hehe

#

pepe you want to add to existing item tooltip or is it for your own items?

modest yarrow
dark finch
hidden compass
thin hornet
#

Its doable but quite a little challenge

thin hornet
# hidden compass I want to add just one line to existing tooltip.

take a look at this code here that might give you some idea how its done in my api. Unfortunatly it's not yet released.
https://github.com/Konijima/PZ-Community-API/blob/dev/Contents/mods/CommunityAPI/media/lua/client/ItemTooltipAPI/Overrides/ISToolTipInv.lua

GitHub

Community API is a team effort to centralize & give mod creators optimized tools for creating quality mods. - PZ-Community-API/ISToolTipInv.lua at dev ยท Konijima/PZ-Community-API

hidden compass
thin hornet
#

around line 200

#

My api remake the whole java class into lua.

#

Its to create dynamic custom tooltip the same way vanilla are made

small topaz
# hidden compass I want to add just one line to existing tooltip.

in that case... question is, where does the vanilla tooltip takes the text from. instead of manipulating the tooltip method, it might be easier to find the variable containg the text for it and append. for example, if the text is stored in the variable desc, you can try sth like desc = desc.."my new text". this will simply append your new text to the existing tooltip...

thin hornet
#

item:doTooltip() create the content of the tooltip

#

its not easy to do cause its java sided

hidden compass
hidden compass
thin hornet
#

yeah doTooltip does a lot of stuff internally

lusty nebula
#

I have a question...I have created a small script that auto-equip on the character the clothes and that auto-place the items belonging to the character automatically in the backpack but the game seems to add by default a belt even if you spawn with the character fully naked ( So doubling the belt I've already put in the inventory via the script ) any way to get rid of the default belt?

thin hornet
#

it create the layout

thin hornet
lusty nebula
#

yep but I would like to find a way, if feasible, to let it not spawn at all

#

even if you don't put it anywhere it spawns by defaul it seems

thin hornet
#

there must be a script adding the belt and the keyring

#

find that and youll be able to see what is doable

#

if overwrittable etc

lusty nebula
#

I'm using it but it seems to spawn independently from the script...maybe is hardcoded by default...

willow estuary
lusty nebula
#

ahhh...didn't thought about it...checking...thanks mate! ๐Ÿ˜‰

willow estuary
#

KeyRings are spawned in the player's inventory in the Java however.

lusty nebula
#

I've already removed the keyring from spawing but it's the belt that instead continues to spawn...

lusty nebula
#

Doesn't seems to work at least speaking of removing the default belt ( Your script correctly adds it ). I've tried also using
-- delete the player's starting inventory and clothing
pl:clearWornItems();
pl:getInventory():clear();
but it spawns the same

lusty nebula
#

( Thanks somehow for the help mate, much appreciated )

thin hornet
small topaz
small topaz
thin hornet
#

yeah isnt it strike two?

small topaz
#

anyway, manipulating start clothes and inventory works fine for me using the event OnNewGame

thin hornet
#
local function onTick()
  Events.OnTick.Remove(onTick);
  -- check if survived zero day
  -- check if  player:getModData().myModPlayerStarted is not set
  -- remove stuff
  -- set modData().myModPlayerStarted = true;
  -- 
end
Events.OnTick.Add(onTick);
#

just an idea

lusty nebula
#

Let's say that the character spawns with a certain number of clothes + the belt ( and the scripts let them auto equip ) then depending on character and profession ( I'm working on a professions mod ) loads also certain items in the character backpack. Everything works fine with no errors but one belt seems to be added by the game by default whatever you write in the script. Do a simple test...Spawn on Apocalypse fully nakes somehow the character will have a belt equipped...

#

Checking the script mate,thanks ๐Ÿ˜‰

small topaz
lusty nebula
#

Got to try...

solemn marsh
#

are there any mods that make the player and zombies more detailed

lusty nebula
#

Checked my script run on Events.OnCreatePlayer...

small topaz
# lusty nebula Got to try...

but the basic trick will in any case be as Konijima suggested: you just need to find an event or a vanilla function which is called after the vanilla game adds the belt. there are probably a lot of options for that. if OnNewGame doesn't work, use the ticks as Konijima or OnPlayerUpdate or any vanilla function which is called immediately after the game starts

thin hornet
#

with the OnTick it would work in MP so thats a good way. Well actually OnTick is good for stuff that require networking to be ready. Since its not ready with OnGameStart

lusty nebula
#

bazz89/Konijima can I send you the script via pm so you can give a check ( I'm not a super expert of scripts )

willow estuary
#

You could just comment out the lines that spawn and apply the belt in SpawnItems.lua if nothing else.

small topaz
willow estuary
lusty nebula
#

I am ashamed to do so my script for you experts will be laughable... ๐Ÿ˜„

cursive moon
#

Should I use More traits or dynamic traits?

lusty nebula
#

OK this one is in the folder " Client"

#

This one ( works for the pilot part of the one above ) instead is in " Shared " Folder ( EDIT: Scripts removed )

#

Ignore the part about prison spawns and comments to it I'm still modifying it it's just a draft ( Permission to use it requested to the author, be clear )

#

Note that some items are not vanilla and have dependencies on mods

#

I've used to scripts otherwise all professions use the same items set in the backpack ( Section at the bottom RMMM_MilitarySpawn.GiveScrewdriver = function(keyName) etc,etc,etc

#

The one in Shared is what you get in the pilot backpack, the client one for the other ones

#

My main issues were:
1-I'm not able to assign different backpack loadouts in one single script ( so to have diversity amongst characters ) because I dunno how to do it
2- The belt thing ( but it's just a minor issue )

#

When you'll stop laughing looking at my scripts mess say me something LOOOL ๐Ÿ˜„

#

Am I been able to create the void? LOOL ๐Ÿ˜„ ( Anyone still around?)

small topaz
#

ya... still here.

#

๐Ÿ˜‰

lusty nebula
#

ok np mate just joking ๐Ÿ˜„

small topaz
#

just looking for the command to remove stuff from the inventory.

#

but using Konijima's idea with the OnTick event, i can unequip the belt when game starts

lusty nebula
#

Basically everything works fine ( at least here ) but that damned additional belt continues to spawn in the inventory when you spawn the character ( Nothing major if not possible to be solved I'll live with it )

#

Don't get crazy about mate, if your solution of adding the Konijma suggestion works, please send me the file corrected ( and where to place them ) and it will be more than eough ๐Ÿ˜‰

#

it

willow estuary
lusty nebula
#

You have been already more than kind in listen to me and trying to help

#

where I have to place it?

willow estuary
#

Really anywhere that's gonna go off after the belt spawning? Like I said, you can also just comment out the lines in SpawnItems.lua that spawn the belt and that just eliminates all the business with despawning the Belt.

lusty nebula
#

( If you can write me the part already modified should be great so to avoid mistakes )

small topaz
#

here is Konijima's idea with the OnTick event. unequips all clothing on start including the belt. i just didn't found the code for removing inventory stuff yet.

lusty nebula
#

Ok so I need only to copy it anywhere in the script? ( No idea what instace of your itemm and your items script type means LOOL )

small topaz
#

oh... didn't saw Blair Algol's comment ๐Ÿ˜‰

#

i'll try to integrate this

lusty nebula
#

ok I'll wait. ( and thanks mate you're a legend! ๐Ÿ˜‰ )

hidden compass
#

Sorry for the question that has nothing to do with modding.
What kind of text formatting should I use to display images in the description of a Steam mod?

lusty nebula
#

..but please modify directly the files I've initially posted above so I will not make errors, thanks

#

so that I have only to copy/paste ( Otherwise sure that I'll do something wrong ๐Ÿ˜„ )

#

(Not to say that when I'll release the mod, thanks to you will be provided in the mod description ) ๐Ÿ˜‰

#

@hidden compass If you go to your profile and you update the description for ie you'll get a window of help with the formatting that works on Steam IIRC

small topaz
#

ahhh... project zomboid wiki!!!! script type of "belt" seems to be "Base.Belt2" instead of "Base.Belt"???

lusty nebula
#

yep it's Base.Belt2

#

The other is outdated I think

#

Should be located in C:\Program Files (x86)\Steam\steamapps\common\ProjectZomboid\media\scripts IIRC ( The belt2 I mean )

hidden compass
lusty nebula
hidden compass
lusty nebula
#

should be something like [img] [/img]

#

BBcode basicallly

hidden compass
small topaz
#

finally, this did it for me. really strange that you cannot use OnNewGame for removing the belt. used Konijima's OnTick idea

lusty nebula
#

Great man!

small topaz
#

@lusty nebula you can probably just add this function to your lua and it might work...

lusty nebula
#

I was getting crazy with that belt ๐Ÿ˜„

small topaz
lusty nebula
#

at the end is ok or better at the beginning?

small topaz
#

so... this completely removes the belt from the inventory

lusty nebula
#

even the equipped one?

small topaz
#

ahh... and rename the function "RemoveBelt" everywhere, for example to RMM_MilitarySpawn.RemoveBelt or so

small topaz
lusty nebula
#

Mate I don't know how to thanks you, really, many many many thanks for your help and time!

small topaz
small topaz
#

and play-test yourself to see whether everything works with your code

lusty nebula
#

to rename the function what I have to rename?

small topaz
#

just rename every occurence of "RemoveBelt" to "RMM_MilitarySpawn.RemoveBelt" or so

#

strictly speaking not necessary but better to minimize chance of double naming with other mods

lusty nebula
#

Ok perfect I owe you a box of beer and if you'll pass from Italy you'll surely get it.Thanks mate!

#

๐Ÿ˜‰

small topaz
#

ok... but as I said, test it yourself

lusty nebula
#

will do mate but for now many many thanks!

modest yarrow
#

Is there a way to tell an item it cannot stack in the inventory ?

drifting ore
lusty nebula
#

Note:I'm now removing the scripts I've posted at the begining just in case some genius will arriive around

#

(put a lot of time in them with my limited skills )

#

Again thanks mate see you around in the Apocalypse! Salute! ๐Ÿ˜‰

small topaz
#

ok ๐Ÿ˜‰

#

oh... maybe it is safer if put a condition "if item then ... end" around the getPlayer():getInventory():Remove(item) command...

fiery pecan
#

sorry I'm a day late here, had to do stuff last night. So, I'm back, and doing tests right now

lusty nebula
#

will do ( You are already starting to speak aramaic for me LOOOL ๐Ÿ˜„ )

#

Have a good evening Sir, bye! ๐Ÿ˜‰

small topaz
modest yarrow
#

That each item has its own "row"

lusty nebula
#

@small topaz Just a very quick jump...Works like a charm ๐Ÿ˜‰ You're super!

small topaz
#

glad to hear but thank @thin hornet and @willow estuary . they had the idea with the ontick event and the correct code for removing items

lusty nebula
#

Thanks you all guys!!!!!! You're great gents!!! ๐Ÿ˜‰

modest yarrow
drifting stump
#

should be able to use it any item

modest yarrow
#

yep:
item Visa { DisplayCategory = AliceInZomboidland, Weight = 0, Type = Normal, DisplayName = Visa, Icon = CreditCard, CanStack = FALSE, }

drifting stump
#

you used this in the item script right

#

are you trying with the same items

#

because theyve already been created so they kept their properties

modest yarrow
#

I respawned new ones

#

I restarted PZ

#

or do I need to do a new world ?

drifting stump
#

no shouldnt need

modest yarrow
#

this is how I spawn it
`function InventoryUtils.GiveVisaToPlayer(player, duration)
local inventory = player:getInventory()
---@type AliasItem
local item = inventory:AddItem(sharedConstants.VisaFullName)

item:getModData().visa_duration = duration

return item

end
`

#

Btw, how do you format code ? I use the backtick character but doesn't look good compare to some posts

drifting stump
#

3x

modest yarrow
#

thx

#

so CanStack doesn't work ๐Ÿ˜ฆ

drifting stump
#

not sure what to tell you i got it from the item script properties dump i did and checked if vanilla items use it and yes some did

modest yarrow
#

also when I print item:
local item = inventory:AddItem(sharedConstants.VisaFullName)
it returns ComboItem type.
Is that normal ? shouldn't it be InventoryItem ?

drifting ore
#

And a comboItem is an inventoryItem

fiery pecan
#

so, after some thought, I feel reloading the outfit is the wrong approach. Although the following does nothing, for some reason:

local GetZedList = getWorld():getCell():getZombieList();
if(GetZedList ~= nil) then
  for i=0, GetZedList:size()-1 do
    local GetZed = GetZedList:get(i);
    if((GetZedOutfitName == "AmbulanceDriver")) then
      GetZed:clearWornItems();
    end
  end
end

Sorry for the multiple edits

leaden dew
#

Hello! Is it possible to unite skillbook effect for two skills? Trying to make an skill book like 2-in-1, so...

I'm not sure that SkillTrained variable can handle two values.
I'm not sure that XPSystem supporting this too...

I also found these perks:
PerkFactory.Perks Firearm
PerkFactory.Perks Aiming
PerkFactory.Perks Reloading

What exactly Firearm perk mean and do?)

zealous pebble
#

Is lua hard to learn. I have some coding experience

cold burrow
# zealous pebble Is lua hard to learn. I have some coding experience

As a guy who have some coding experience, i would say that lua is specific as any other language. But nothing special at all.
Main problem for me is lack of documentation and simple examples. You will have to dig through vanilla or mods code (which not always easy to read) to get some knowledge, or constantly ask here for help.

gritty edge
#

Hey! I'm very new to coding on zomboid and know some lua. Do you know how to set a specific skill to change its multiplier from other skills?

fiery pecan
#

then wait for people to answer?

gritty edge
#

^

fading frost
#

could someone help me turn the tarot cards mod into a standard deck of cards mod with 3d models please?
i already changed the lua script, but i don't know how to add the model for the individual cards. i'm hoping to have two: one with a black pattern and one with a light-grey pattern. i'm already working on the model itself in blender, but beyond that, i can't texture, and i have no idea how to add the models into the mod. i also wanted to make the fully-collected deck use the deck of cards mesh, but obviously with the texture changed to match the new cards)

#

the tarot cards also only spawn in bookshops, but i'd like it to spawn in every container and location types as well

#

oh i think the mod's by @abstract raptor (would i be wrong?)

sonic helm
#

Yeah, its her's iirc.

abstract raptor
#

Hi

errant gale
#

does anyone know how to modify the attackspeed of a game character? Is it linked to the xml files?

glass gorge
#

is it possible to implement custom hotkeys

errant gale
#

yes

#

there's a lua event called OnCustomUIKeyPressed

sinful idol
#

The animation manager has a method for setting the animation speed, but I haven't been able to make it work :( I think it's not exposed to Lua. Maybe one can use reflection to call it? I'm not sure.

#

If you found a way lmk!

gilded hawk
#

For the fellow new modders like me, if you want to give the player a backpack/container with items you can use the code from the Builder mode new game


local bag =  playerObj:getInventory():FindAndReturn("Base.Bag_Schoolbag");
       if not bag then
           bag = playerObj:getInventory():AddItem("Base.Bag_Schoolbag");
           playerObj:getInventory():AddItem("Base.WaterBottleFull");
           bag:getItemContainer():AddItem("Base.BaseballBat");
           bag:getItemContainer():AddItem("Base.Hammer");
           playerObj:getInventory():AddItem("Base.Crisps");
           playerObj:setClothingItem_Back(bag);
       end
       bag:getItemContainer():AddItem("Base.Saw");
       playerObj:getInventory():AddItem("Base.Crisps2");
       playerObj:getInventory():AddItem("Base.Crisps3");
dusk saddle
#

Been trying to figure out what sort of bug might be causing the can opener to not work properly with my mod, can't open cans (which upon searching through this server means it's most likely a mod bug - as others have had this issue, though didn't see any answers for it other than that). Would anybody here happen to know if there might be anything that could be breaking it? The mod mainly just adds new foods, some plushies, and a hat with the most advanced part being the recipe lua file

willow estuary
#

If you haven't already, test your mod w/o any other mods enabled to confirm that it's another mod and not an error with your mod.
Then test your mods with one other mod, or a few other mods enabled until you find the mod responsible.

nimble spoke
willow estuary
#

It's usually some "Better so-and-so-items" mod that borks can openers.

#

..ironically enough.

dusk saddle
#

Oh yeah it's certainly from my mod, as I don't have any others enabled and vanilla works just fine

willow estuary
#

Okay, sorry, combination of misreading your post + this can opener being broken by mods thing is something I've seen a million times now ๐Ÿ˜„

dusk saddle
#

Haha no worries, just trying to figure out if maybe I accidentally overwrote the can opener script but I'm not seeing anything out of the ordinary

gilded hawk
#

How can I programmatically add upgrades and a magazine to a spawned gun using getItemContainer():AddItem("Base.HuntingRifle"); ?

#

(And upgrades too)

dusk saddle
willow estuary
# dusk saddle Would do you happen to mean? Like the `CannedFood=` tag?

Nah, it was very common practice for people to overwrite entire item scripts with their mods that would increase item durability or change some item weights and the like?
Like, literally having a file called items.txt that was a copy of the vanilla items.txt with a few changes in it.
Which means that when there was a change with PZ build updates to the vanilla files, such as when the item tag system was added, all the "better item" mods that overwrote vanilla item files weren't compatible with how PZ was changed to use item tags,

In the context of PZ item tags are the Tags = CanOpener, part, the PZ code uses that to know that TinOpener items can open cans.


    item TinOpener
    {
        DisplayCategory = Cooking,
        Weight    =    0.6,
        Type    =    Normal,
        DisplayName    =    Can Opener,
        Icon    =    CanOpener,
        MetalValue = 3,
        StaticModel = CanOpener,
        Tags = CanOpener,
        WorldStaticModel = CanOpenerGround,
    }
#

I think that business, with overwriting entire vanilla files for a few modifications, might have been partially to blame to people using itemzed w/o knowing how to use it properly, before it was broken by b41 updates.

#

CannedFood = TRUE, is an item parameter and not an item tag FYI. Technical distinction.

dusk saddle
#

Ah I see, thanks for the clarification.
Hmm, well I can't say I've copied the whole item scripts thing, now I'm really dumb and beginner at Zomboid modding so I'm sure there's some mistake somewhere though I've named my file PompsItems-food_items alongside the other text files having PompsItems before them. Perhaps the best way to do this would be to drag out each text file to find out which one would be causing it and then further take that one apart

#

Aha! It's coming from my recipe lua thing, silly me forgot the module base part

gilded hawk
dusk saddle
#

Very rad, all the best with yer' mod

gilded hawk
#

In order, add the gun, the attachments, add the attachments to the gun, add the magazines, fill the magazines, make a magazine appear in the gun


        local rifle = player:getInventory():AddItem("Base.AssaultRifle2"); -- It's the M14
        local scope = player:getInventory():AddItem("Base.x2Scope");
        local recoil_pad = player:getInventory():AddItem("Base.RecoilPad");
        local laser = player:getInventory():AddItem("Base.Laser");
        rifle:attachWeaponPart(scope)
        rifle:attachWeaponPart(recoil_pad)
        rifle:attachWeaponPart(laser)

        local magazines = {
            player:getInventory():AddItem("Base.M14Clip"),
            player:getInventory():AddItem("Base.M14Clip"),
            player:getInventory():AddItem("Base.M14Clip"),
        }

        for _, magazine in pairs(magazines) do
            -- Fill all the magazines
            magazine:setCurrentAmmoCount(magazine:getMaxAmmo())
        end
        -- Use the first magazine of the 3 as a reference for the max ammo
        rifle:setCurrentAmmoCount(magazines[1]:getCurrentAmmoCount())
        -- Magically make a clip appear in the gun
        rifle:setContainsClip(true)
#

I just don't understand why laser and stuff is still in my backpack tho Thinkedit Isn't it supposed to disappear from the backpack?

willow estuary
gilded hawk
#

Apparently it's not automatically removed after attachweaponpart is called

#

I just noticed it in here


function ISUpgradeWeapon:perform()
    self.weapon:setJobDelta(0.0);
    self.part:setJobDelta(0.0);
    self.weapon:attachWeaponPart(self.part)
    self.character:getInventory():Remove(self.part);
    self.character:setSecondaryHandItem(nil);
    -- needed to remove from queue / start next.
    ISBaseTimedAction.perform(self);
end
willow estuary
gilded hawk
#

Oh

#

Sorry, I misred

willow estuary
#

๐Ÿ‘

gilded hawk
#

So, If I understan correctly InventoryItemFactory.CreateItem creates the item in memory but does not put it anywhere, right?

willow estuary
#

AFAIK yep.

gilded hawk
#

Okay thank you so much

gilded hawk
#

Alright, spawn gun, magazines and attachments directly on the gun v2

        local rifle = player:getInventory():AddItem("Base.AssaultRifle2"); -- It's the M14
        local scope = InventoryItemFactory.CreateItem("Base.x2Scope");
        local recoil_pad = InventoryItemFactory.CreateItem("Base.RecoilPad");
        local laser = InventoryItemFactory.CreateItem("Base.Laser");
        rifle:attachWeaponPart(scope)
        rifle:attachWeaponPart(recoil_pad)
        rifle:attachWeaponPart(laser)
        player:getInventory():Remove(self.part);

        local magazines = {
            player:getInventory():AddItem("Base.M14Clip"),
            player:getInventory():AddItem("Base.M14Clip"),
            player:getInventory():AddItem("Base.M14Clip"),
        }

        for _, magazine in pairs(magazines) do
            -- Fill all the magazines
            magazine:setCurrentAmmoCount(magazine:getMaxAmmo())
        end
        -- Use the first magazine of the 3 as a reference for the max ammo
        rifle:setCurrentAmmoCount(magazines[1]:getCurrentAmmoCount())
        -- Magically make a clip appear in the gun
    rifle:setContainsClip(true)
fiery pecan
#

welp. I suck with lua... Still having issues getting my zed outfit changes to save on the server, and I believe I found the cause (just don't know how to fix it) "sendObjectChange can only be called on the server"

sinful idol
fiery pecan
#

I tried that?

wide burrow
#

Anyone know a cheat menu for my private server

sinful idol
# fiery pecan I tried that?

I just looked at the decompiled source. The only reason it should error out like that is if it's called in the client

#

Maybe you're somehow triggering it client side still?

fiery pecan
# sinful idol I just looked at the decompiled source. The only reason it should error out like...

odd. Basically: I'm using a local server hosted from the steam menu for testing. Here's my code?


--Get Zombies
local GetZedList = getWorld():getCell():getZombieList();
if(GetZedList ~= nil) then
  for i=0, GetZedList:size()-1 do
  --Get Zombie
  GetZed = GetZedList:get(i);
    if((GetZedOutfitName == "AmbulanceDriver")) then
GetZed:dressInPersistentOutfit("EMSMeade");
GetZed:reloadOutfit();
GetZed:sendObjectChange('GetZedOutfit');

#

Pardon the mess, not proficient with Discord's lua thing

sinful idol
#

Maybe you can check if you're client side and run it only if it's in the server? I forgot how but you can check through Lua if you're running in client or server

#

Actually I believe it's just a global isServer() you can call iirc

fiery pecan
#

ah

#

totally not trying that now, lol

odd notch
#

kind of a tooling question but does anyone think its possible to run two servers on the same .db's?

#

or at least how to tell the game which database to use?

wide burrow
#

I downloaded cheat menu rebirth whats the bind to open the menu

sinful idol
odd notch
#

but we use,, sqlite

#

i figure this would alleviate our impending 32 slot restriction if i can do a backend solution

#

where i have the population for 2 servers but not the database infrastructure :(

#

i guess the better question is, is there any way to use a cloud database instead of the local cachedir /db/ .db junk

round zenith
#

function CarCraftingMH_OnCreate(items, result, player)
addVehicle("SmallCar02")

local vehicle = player:getVehicle()

if not vehicle then
vehicle = player:getUseableVehicle()
end
if not vehicle then
vehicle = player:getNearVehicle()
end
sendClientCommand(player, "vehicle", "getKey", { vehicle = vehicle:getId() })
end
anyone got any ideas why this code would work on singleplayer and not multiplayer? Does addVehicle just not work in MP?

gilded hawk
willow estuary
#

FYI you probably could also accidentally (or intentionally) create a "carnado" spawning in a bus in the wrong circumstances.

sinful idol
# odd notch i guess the better question is, is there any way to use a *cloud* database inste...

i'm still unsure what you're trying to do, but you might be able to use something like litestream which allows you to replicate sqllite servers. I've been using it for production for some time now and it's pretty nifty.

https://litestream.io/

Again not sure if it would solve what you're trying to do but that should at least provide sqlite replication

Litestream is an open-source, real-time streaming replication tool that lets you safely run SQLite applications on a single node.

round zenith
#

Ya I am aware of the carnado possibility. With regards to the admin aspect I don't think there is really a way around that from a working perspective. If I block it then it just doesnt work

odd notch
#

like a symlink-esque way to replicate two servers sqlite files

leaden dew
#

Is there any way to add distributions for special car with special texture spawned? Currently i'm stuck after AND operator... Don't know how to check spawned car's texture

if getActivatedMods():contains("MOD_ID") and ?????? then 
table.insert(VehicleDistributions.TYPE["CONTAINER"].items, "ITEM"); ... etc. etc.
end
sinful idol
odd notch
#

i am a child

#

ignore me this is far too complex of a tooling thing and the more i talk about it the more i can see the slack logo

wide burrow
#

Anyone know the name of the aiming mod that goes with britas weapons for a multi-player server

odd notch
modest yarrow
#

Do you know if there is a way to spawn Decoration in Debug ?

gilded hawk
#

I need some help, my newly spawned survivor has a holster, and I'm trying to make it have the pistol in the holster, but for some reason it's not happening, does anyone have suggestions? I'm using Profession framework

OnNewGame = function (player, square, profession)
        local fak = player:getInventory():AddItem("Base.Bag_Schoolbag");
        fak:getItemContainer():AddItem("Base.AlcoholBandage");
        fak:getItemContainer():AddItem("Base.AlcoholBandage");
        fak:getItemContainer():AddItem("Base.AlcoholBandage");
        fak:getItemContainer():AddItem("Base.AlcoholBandage");
        fak:getItemContainer():AddItem("Base.AlcoholBandage");
        fak:getItemContainer():AddItem("Base.Tweezers");
        fak:getItemContainer():AddItem("Base.SutureNeedle");

        local weapon = player:getInventory():AddItem("Base.Pistol"); -- It's the M9
        local scope = InventoryItemFactory.CreateItem("Base.IronSight");
        local laser = InventoryItemFactory.CreateItem("Base.Laser");
        weapon:attachWeaponPart(scope)
        weapon:attachWeaponPart(laser)

        local magazines = {
            player:getInventory():AddItem("Base.9mmClip"),
            player:getInventory():AddItem("Base.9mmClip"),
            player:getInventory():AddItem("Base.9mmClip"),
        }

        for _, magazine in pairs(magazines) do
            magazine:setCurrentAmmoCount(magazine:getMaxAmmo())
        end

        weapon:setCurrentAmmoCount(magazines[1]:getCurrentAmmoCount())
        weapon:setContainsClip(true)

        player:getInventory():AddItem("Base.Bullets9mmBox");

        -- Attach pistol in the holster
        player:setAttachedItem("Holster Right", weapon);
    end
modest yarrow
#

have you tried "HolsterRight" ?

#

without the space

gilded hawk
#

I did not cause I assumed it always has spaces since for the rifle on the back I had to use "Big Weapon On Back"

#

Yeah does not work even with HolsterRight

willow estuary
leaden dew
wide burrow
#

Anyone know the name of the aiming mod that goes with britas weapons for a multi-player server

willow estuary
willow estuary
round zenith
#

Thanks Blair I will try that though I am going MIA for 2 weeks so I'll disable it for 2 weeks and test when I'm back. If someone else tests it and it work for other clients to be able to see the car spawned by a client let me know!!!

gilded hawk
#

i made it fucking woooooooorking, It has to be forced in the slot

        -- Attach pistol in the holster
        player:setAttachedItem("Holster Right", weapon);
        -- Force the weapon to be in the holster slot
        weapon:setAttachedSlot(2);
leaden dew
# willow estuary From `VehicleDistributions.lua` ```lua -- Specific cars like police, fire, r...

Still canโ€™t figure out how to address right skin to spawn items only in acceptable vehicles with correct skinโ€ฆ

Modโ€™s distribution table just adds one normal and unite trunks in one classโ€ฆ there is no special normal for the skin.

Proper skins are 2nd and 10th VEHICLE.txtโ€ฆ

Or am I able to add new normals (guessing yes), but how can I address proper skin?

next glacier
#

I made the mistake just quitting to main menu and back

#

when i restarted the game, there were no errors

#

btw

#

what kind of 3d models are used by the game

#

its looks like its all text

#

time = numPages * o.minutesPerPage / f

#

what is f

#

oh wait nvm

#

local f = 1 / getGameTime():getMinutesPerDay() / 2

#

any good examples so i can learn mod options integration?

#

ahh i see

#

looks easy nuff

dusk saddle
#

I have returned, being the complete numbskull I am with scripting as I have very little know how on it, I notice my recipe lua file conflicts with the base game one, adding a module base to the top seems to just prevent the oncreate recipes from working, while getting rid of it prevents default recipes such as opening cans.
As a reference to some of the recipes: box of frozen mozzarella sticks can be opened to give you both the sticks and the empty packaging (litter, essentially).
If anybody has any ideas to resolve this, I'd be delighted to hear them

leaden notch
next glacier
#

note to self dont subscribe to your own mod xD

#

messes things up

zealous pebble
#

what is lua similar to

#

code wise

#

not going to lie at first glance it looks like a slightly more complex python

leaden notch
#

luau

#

built off lua, but a quite different language

little vessel
uncut jasper
#

hi, i have a problem in recipe code, for "result.", i want put "Nothing" in result but no work now, before it's working and to day no work, why???
WARN : Recipe , 1644598141027> 149?001?622> RecipeManager.resolveItemModuleDotType> ERROR: can't find recipe result "Nothing" in recipe "Verifier l'outils"

#
recipe Creer une cle de maison a partir de l'outils empreinte
{
TraitRequired:nimblefingers;nimblefingers2,
SkillRequired:MetalWelding=2,

keep PrintTool,

BlankHouseKey,

RemoveResultItem:true,

Result:Nothing,
OnCanPerform:CanFindKeyCuttingMachinePrintCopy,
OnCreate:matchHouseKeytoPrintTool,

Tooltip:Requires a Powered Key Duplication Machine.,

Prop1:Source=1,
Category:Welding,

Sound:Metalwork1,
Time:800,
}```
lusty nebula
#

QUESTION: If I have to get the keyring I use local keyRing =
...but if I have to get a bag instead of the keyring ( the ALICE green backpack in my case ) do I have to use ( sample ):
local bag =
or do I have to indicate the precise item name ( sample )
local Bag_ALICEpack =
or simply item generically (sample)
local item =

?

small topaz
# lusty nebula QUESTION: If I have to get the keyring I use local keyRing = ...but if I have to...

not exactly sure what you mean but the phrase "local keyRing = ..." just defines a new variable which happens to have the name keyRing. It doesn't contain anything related to the actual key ring by itself. To properly relate it to the key ring, the question is what you have on the right hand side of the "=" sign. For example, setting local keyRing = "Base.KeyRing" will give your variable keyRing the value "Base.KeyRing" (that is the script id of the actual in game key ring).

thin hornet
#

Variable name on the left side can be what ever

small topaz
next glacier
#

im getting an error on line 7

lusty nebula
#

This is the code I'm using. It works but it adds a building key to the character inventory ( plus the keyring ). I want instead that it gives only the backpack ( no key or keyring ) but keeping the ability to add any item I want intoo the backpack ( or rather the part after -- add a basic key to the player's keyring )

small topaz
next glacier
#

wondering if i should use joke.item

lusty nebula
next glacier
#

now I get why they used "o"

thin hornet
# lusty nebula

if you are just adding item your dont need to store the reference into a variable
you store only if your are going to modify it or use later in the code

next glacier
#

very short

thin hornet
#

its the same object in the end

next glacier
#

at least your example using "this" helped me understand a bit

#

thanks for that

thin hornet
next glacier
#

yea heard from other guy here

#

It got me confused a bit

small topaz
#

not related to the things currently discussed here but is there a command which returns the current game tick?

next glacier
#

i thought it was a keyword

#

then guy said lua doesnt have "this" but "self" instead

thin hornet
#

but you could make yourself one with OnTick and getting millisecond and substracting last tick ms

next glacier
#

maybe you can get something from getGameTime()

#

but idk if gametime is presented as ticks

radiant hound
#

Hey guys, just wondering, I see a sound effect in the game called firealarm, but the game does not have fire alarms implemented, correct?

I want to mod fire alarms in but first checking that it isn't a thing already

next glacier
#

there is an animtimer.ticks

#

if i use joke.
can I just do a local joke.item = item

#

or equivalent

small topaz
thin hornet
#

There is maybe a way then

next glacier
#

now that I've made one mod here. I feel like I want to make a minecraft mod

thin hornet
#

shared/getTick.lua

local currentTick = 0;

local function getTick()
  return currentTick;
end

local function updateTick(tick)
  currentTick = tick;
end
Events.OnTick.Add(updateTick);

return getTick;
local getTick = require("getTick");
local tick = getTick();
small topaz
radiant hound
#

do you know what the int variable called "area" in the RoomDef class represents?

next glacier
#

๐Ÿ˜น no wonder it wasnt working

#

even though I havent forgotten lua is case sensitive

#

my brain does not process casing as much as it should

narrow laurel
#

Is it possible to lower the infection chance of a bite to something like 85% on a dedicated server?

next glacier
#

to make a mod? or just for the server.

#

I dont know enough yet, but if its in sandbox_vars

#

then you can check there

narrow laurel
#

I can't find a setting for that so I assume I need a mod?

lusty nebula
#

Quote from bazz89: " not exactly sure what you mean but the phrase "local keyRing = ..."
just defines a new variable which happens to have the name keyRing. "

Ok so if I've understood it correctly I could change the new variable name to any ( ..and it will be exactly the same as the keyRing above, only the variable name will change ), correct?
Sample: " local backpack = "

next glacier
narrow laurel
#

yes

next glacier
#

its not there?

narrow laurel
#

No, I don't see a bit where I could change it.

lusty nebula
#

Thanks both to bazz89 and konijima, with your indications got rid of my issue!Thanks guys! Salute!

next glacier
#

anyone know

#

if you can change ui rendering fps

lusty nebula
#

it's in the options

#

(video options)

next glacier
#

changing it via a mod

#

I want it to be like for example 60

#

its limited to 30fps

#

anyone know where the arguments in game options are stored

lusty nebula
#

IIRC there should be a file containg all those settings

small topaz
crimson spindle
#

How do I get a player's first aid skill level? This is what I'm trying to do:

    local breakthrough = ZombRand(0,100);
    local firstAidSkil = --What do I put here?
    if breakthrough <= 1 * firstAidSkill then
        player:getInventory():AddItem("HTFAC.HTFACBreakthrough");
    end
end```
lusty nebula
#

@next glacier The file is in C:\Users\YOURPC\Zomboid\Lua

#

but I dunno if the Ui refresh rate is hardcoded or not

next glacier
#

the files here

#

are the options you saved.

#

not where the code for the options are, sorry forgot to be clear

#

i found it

lusty nebula
#

location?

next glacier
#

E:\SteamLibrary\steamapps\common\ProjectZomboid\media\lua\client\OptionScreens\MainOptions.lua

lusty nebula
#

Good ( Always better to know where is ๐Ÿ˜‰ )

next glacier
#

yeah maybe my "mod" will receive popularity

#

"more ui fps options"

little vessel
lusty nebula
#

@next glacier looking at the comments in the various mod discussions you should create a mod to stop users to make always the same questions and to let them read the mod descriptions first LOOOL ๐Ÿ˜„

crimson spindle
#

thank you!

next glacier
#

like my mod

#

"Reading is a Joke"

little vessel
# crimson spindle thank you!

No problem. If you don't want to use playerObj cause you are not using the variable anywhere else then just
getSpecificPlayer(player):getPerkLevel(Perks.Doctor);

Vanilla files tell me that

-- all the perks are: Agility, Cooking, Melee, Crafting, Fitness, Strength, Blunt, Axe, Sprinting, Lightfoot, Nimble, Sneak, Woodwork, Aiming, Reloading, Farming, Survivalist, Fishing, Trapping, Passiv, Firearm, PlantScavenging, Doctor, Electricity, Blacksmith, MetalWelding, Melting, Mechanics, Spear, Maintenance, SmallBlade, LongBlade, SmallBlunt, Combat,
thin hornet
#

Meh... having a major issue now xD
When in character creation the networking is not yet ready..... No way to communicate to the server yet

#

would be great to have a way to request the server even before the player has fully spawned

#

Just need to fetch some server custom info

lusty nebula
#

Removed

little vessel
# lusty nebula Removed

Perks is what the game files call skills, traits are a different beast.
Unless I just missed something and you are referring to something else...

lusty nebula
#

You're correct, sorry I was looking at the wrong part of my notes ( I'm working on my script so I got confused )

#

Somehow there are others hidden in the code ( and this time perks ). Some time ago I've found one named Injuried and it worked as perk IIRC

#

other ones I recall were " Insane " and "Kind-hearted"

crimson spindle
#

so expanding on the previous problem... i noticed this is happening now:

#

this is the recipe and subsequent code:

{
    Category:Health,
    keep HTFAC.HTFACMicroscope,
    HTFAC.HTFACTestTubeBlood=5,
    SheetPaper2,
    Pen/BluePen/RedPen/Pencil,
        
    NeedToBeLearn:true,
    CanBeDoneFromFloor:true,
    SkillRequired:Doctor=1,
    Time:250.0,
        
    Result:HTFAC.HTFACReportMicroscopic,
    OnCreate:HTFACBreakthroughChance,
}```
breakthrough code:
```function HTFACBreakthroughChance(items, result, player)
    --local playerObj = getSpecificPlayer(player);
    local breakthrough = ZombRand(0,100);
    local playerFirstAidSkill = player:getPerkLevel(Perks.Doctor);
    
    if breakthrough <= 2 + playerFirstAidSkill then
        playerObj:getInventory():AddItem("HTFAC.HTFACBreakthrough");
    end
end```
#

the way it works is there is a guaranteed item from the recipe, and then a chance of an additional item. But when I perform it using that context menu (the microscope object is a placed item), it doesn't go to the player inventory

verbal ivy
#

Hi, anyone know why changing the zombie stat in server side is not working? Let's say I have "zombie:applyDamageFromVehicle()", it work absolutely fine in SP, but in MP the code has ran at the server side but it doesn't do anything. It's not because the code only ran at client side, I had the line "if isClient() then return end" to make sure it runs at server side, and I have print output in the server log to confirm it did run at server side. But it just didn't do anything. Any idea why does it happen?

radiant hound
#

anybody knows where in the code is the check for the player to die to a generator indoors?

potent flicker
#

So I have a question about "Trunk Capacity Mods", despawning items, and the memory issues that causes it.

As far as I've understood the reason things despawn from vehicle/trailer trunks is due to how the storage space associated with a vehicle, whether it is spread over several separate containers or not, has a limited amount of memory it is saved to, and as such when the vehicle's information is reshuffled in the memory (normal computer things), whether RAM or drive, the reassignment of "stored item information" causes it to drop the information that is overflowing.

#

And that, the dropped "overflow", is what causes items to despawn.

#

Other types of containers are coded differently and do not suffer from the same issues. To my understanding this includes like bags/backpacks/etc.

#

Here's a more technical question: due to how carried containers store their information in a different manner it appears that they act like a "memory address book" where they point to a different part of the memory as to what they contain. If I'm right in that, couldn't one get around the "items despawning" issue by putting everything into bags before you toss them into the back of your trailer?

willow estuary
#

Well, I believe part of that phenomenon is that it was common practice for people to use trunk space mods to hoard stuff in 1500 weight unit capacity vehicle trunks and the like.
But it was never common practice for people to use ridiculous backpack space mods?

potent flicker
#

Asking because KI-5 has some vehicles, or more specifically some trailers, in their collection like the M1082 and M1095 (and their covered versions) from the '86 Oshkosh P19A mod, the IS-Container from the Containers! mod, and the super-trailers from his '82 Oshkosh M911 mod.

#

Oh, it's not about using ridiculous backpack-space mods

#

Imagine something like crates that you can pick up and store even when filled.

#

But with 0 weight reduction

#

Something like a hypothetical "Cargo Crates for Vehicle Storage", or some such.

#

I'm asking because I'm considering a "No Permanent Base"-run as a test before doing something like it on a coop-server.

#

Where people can't sleep elsewhere but vehicles

#

and you can't create bases that are meant to be permanent staging points, instead having to range out from a vehicle convoy-camp and temporary defensive positions and such.

willow estuary
#

What I'm saying is that it may be that backpack/etc containers would despawn stuff the same as trunk space mods, but that people just don't know that because people don't use backpack space mods the way that trunk space mods were used?

I don't have any strong opinions, or have done any deep data dives on the subject, I just know "you make containers with a large enough capacity and put enough item data in it stuff goes despawn"?

potent flicker
#

Oh, yeah, I understand but that's not what I'm getting at:

#

What happens if you, instead of filling the trunk/trailer with everything loose

#

you stuff it all into bags/carry-crates before putting it in the vehicle/trailer?

willow estuary
#

I'd be surprised if that worked.

#

But the world surprises almost every day so ๐Ÿคท

potent flicker
#

It all depends on how things are coded, right?

#

Since mem-storage is basically "Here, this is how much memory this particular entity has and this is the amount dedicated for keeping items in it"

#

Now, is each entity, containers included, always stored in their entirety inside of what they are in turned stored in?

#

Or is it that bags/containers, when stored in other containers, are made into something equivalent to a single item with a very high weight value?

willow estuary
#

One thing I do know is that the item type itself, and how much data is attached to that item affects the despawn effect, so you can't even say "X amount of weight units or Z number of items is the practical limit". Food type items have more data than Literature type items.

ORGM Machinegun belts were notorious for despawning stuff in trunk space circumstances because they have 200 pieces of mod data to track every round of ammuntion in them for example.

potent flicker
#

I mean, the weight is more of a vehicle limit than a memory limit, right? The suspension and tires not being able to handle the load, etc.

willow estuary
#

You might be able despawn the contents of vanilla vehicles by filling them with cigarettes, for example.

potent flicker
#

But that's because it's a massive stack of single items, no?

#

If you were able to convert things into larger pieces for storage, like "Box of Cigarettes"/"Roll of Bandages", etc, with recipes to convert them into their smaller pieces

#

much like ammo and ammo-boxes

#

But what you said about the ORGM Machinegun belts makes me think that it's the more straight-forward

#

"Everything in Bag A is also stored in the memory of Crate B as well as the memory of Trailer C if you put A in B and B in C."

willow estuary
#

I'll be honest in that I've spent a fair amount of effort talking to people more knowledgeable than me on the subject, trying to get concrete answers, so I could say "Don't give your trunks X amount of capacity and you won't have to deal with the trunk space despawn curse", to put an end to all the confusion etc over the issue.

And everyone basically said "It's not possible to give concrete answers on account of all the variables in play, just don't mess with modified trunk spaces if you don't want to deal with the despawn issue"?

#

So, personally, I'm satisfied to say "It's just not a good idea, experiment at your own risk"

potent flicker
#

Fair enough.

#

That does leave me to wonder if the larger containers/trunks/trailers in some of KI-5's vehicle mods suffer from the same issue

#

In that you really don't want to fill them, even unaltered, as you automatically run into despawn-issues.

#

But I can see how food items require more memory space, especially the perishable kind.

#

And even more so things the player has cooked themselves

#

Each item being unique in nutrition, hunger, happiness, thirst, etc, and it all being variable with your cooking skill.

willow estuary
#

I'm sure under the right circumstances, such as multiple vehicles in close proximity (ie the same chunk) that are stuffed full of stuff, it has happened? People report issues constantly, and the huge volume of reports + poor descriptions means it could be an ongoing issue with those vehicles that people just aren't aware of?

Personally, I would not use those vehicles for my own server on account of those concerns. My own cargo container mod has a weight limit of 250 for example.

There was memory optimization for saving game data that I understand made the despawn issue less pronounced, but that doesn't mean that it doesn't still happen, just that the limits are different that previously.

Funny aside, when b41 was first released, it was literally a daily post in tech support by someone who had all their stuff despawn due to trunk space mods. It became a punchline. Eventually they fell out of common practice because of people getting constantly burnt by it, and also the memory optimization would have helped make it less common.

#
  • Also, full disclosure, I'm not "objective" on the matter in that I've just seen it repeatedly be a gigantic fucking headache for people in the past, so I'm definitely biased on the subject?
#

So definitely take my opinions with a grain of salt/I'm just another idiot on the internet/yadda yadda yadda.

potent flicker
#

Oh, I'm "well aware" since I already looked through this channel for answers and your grievances with people stuffing towns in trunks came up often enough ๐Ÿ˜›

But it's totally fine! I'm studying computer science, like getting into the guts of game code to figure it, like suggesting or making (read attempt) mods/strategy optimization based on what I learn, have gotten really freaking sucked in by PZ, and was writing this partly to make the challenge I mentioned work properly partly to deal with my massive hoarder-issues and partly to because I like exploratory stuff like this. No offense taken, the salt was considered and subsequently discarded, and I've enjoyed this a lot!

dark finch
#

Players on my server are saying cars give infinite engine parts and still act broken when repaired, why is that?

potent flicker
#

Definitely learned something and where to take my explorations.

willow estuary
#

Ahahahaah ๐Ÿ˜„

#

Yeah, the best answer I have is "The largest vehicle trunk capacity in vanilla is 100 units and that's what the game is designed for"?

potent flicker
#

Might be that removing the engine parts permanently sets the engine condition to 0 but doesn't remove the ability to yoink further engine parts from it?

dark finch
#

Y is that

#

Very weird problem

potent flicker
#

Depends on if it is a vanilla function, a mod-altered vanilla function, or a completely mod-added function.

willow estuary
#

Assuming that you're using mods, then a mod is most likely to blame there.

potent flicker
#

In the first it might be a coding oversight or mod-overwrite error. Like Algol I suspect the latter.

#

Actually, it's either a coding oversight or a mod-conflict/-overwrite thing.

#

The difference is just in how likely Option A is over Option B

potent flicker
#

I mean, removing engine-parts and repairing engines isn't a car scrap-unique thing, no?

dark finch
#

Iono if it would effect it

potent flicker
#

I'd love to take a look but I've yet to work out where/how to find the specific scripting/lua code in PZ mods.

#

I started playing the game literally 3 days ago xD

#

Well, playing modded, that is.

#

... I'mma test it in single-player, one moment.

willow estuary
#

Well, to be honest, a lot of "improvement mods" that are intended to fix what the modmakers see as problems with vanilla are made with the best of intentions, but also rudimentary grasp of good PZ modding practices? IME a lot of them have serious problems under the hood (such as the "better item mod apocalypse" when item tags were introduced), so my first suspicion is that it's some sort of vehicle mod that's intended to "improve/expand vehicle mechanics", and a scrap cars mod sounds like one of those?

potent flicker
#

Just tested it

#

SP does not have that issue with either vanilla or modded cars

#

Well, the modded cars I had laying around.

#

And yes, I have Scrap Cars enabled

dark finch
#

Thnx for the help, ima take a look at my vehicle mods

dusk saddle
# little vessel Your recipe files cannot be named the same as vanilla. Name it something else. N...

Not a fan of pinging others, so just going to turn this one off. Are you sure that's the case, I'm not seeing any changes from renaming anything, it's only if I remove the recipe lua file or get rid of the various bits at the beginning such as Recipe.OnCreate = {} like in the default one, which also results in the recipes not working as intended. My stuff should be named differently, as I deleted every oncreate recipe from the lua file and it still didn't work, only once I took the lua file out would I be able to open cans again. There aren't any traces of can or tin in my recipe lua, here's an example of one of the recipes:

    --Moxx Sticks Box
function Recipe.OnCreate.OpenMoxxBox(items, result, player)
    player:getInventory():AddItem("MoxxBoxDestroyed");
end
willow estuary
#
  1. Make sure your recipe function file doesn't have the same name as the vanilla recipe file so it doesn't overwrite it.
  2. Have require "recipecode" at the beginning of your recipe file
  3. Change all that Recipe.OnCreate = {} etc stuff to Recipe.OnCreate = Recipe.OnCreate or {} and such as appropriate for the statement and the like with your file, as you're wiping vanilla recipe functions with how you define them.
next glacier
#

@thin hornet is it possible to edit MainOptions.lua

dusk saddle
#

Ah, I suppose that makes sense. Thank you for all the help you've been providing to me, Algol!

willow estuary
#

๐Ÿ‘

next glacier
#

btw what are other commands in lua

#

original code has addCombo

#

how to I go around overriding that

thin hornet
next glacier
#

i haff code

#
--MoreFPSOptions
local UIRenderFPS = MainOptions.self:addCombo(splitpoint, y, comboWidth, 20, getText("UI_optionscreen_UIRenderFPS"), {"144", "120", "60", "30", "25", "20", "15", "10"}, 2)
map["defaultTooltip"] = getText("UI_optionscreen_UIRenderFPS_tt")
UIRenderFPS:setToolTipMap(map)
local gameOption_toUI = gameOption.toUI
function gameOption:toUI(self)
    local box = self.control
    local fps = getCore():getOptionUIRenderFPS()
    if fps == 144 then box.selected = 1
    elseif fps == 120 then box.selected = 2
    elseif fps == 60 then box.selected = 3
    elseif fps == 35 then box.selected = 4
    elseif fps == 25 then box.selected = 5
    elseif fps == 20 then box.selected = 6
    elseif fps == 15 then box.selected = 7
    elseif fps == 10 then box.selected = 8
    end
end

local gameOption_apply = gameOption.apply
function gameOption.apply(self)
    local box = self.control
    if box.options[box.selected] then
        local fpsTable = {144, 120, 60, 30, 25, 20, 15, 10}
        getCore():setOptionUIRenderFPS(fpsTable[box.selected])
    end
end
self.gameOptions:add(gameOption)```
willow estuary
#

I'll post the answer in #mod_support as that's the channel that was added for mod-user-issues, and this channel is intended for mod-creation-issues.

willow estuary
#

๐Ÿ‘

next glacier
#

i only know right now add, set, get

#

yeah this is completely the wrong way

#

it can me done if i modify original MainOptions.lua

#

but not as a mod

#

or so i think

#

my mod <3

obsidian rapids
#

Hello guys i'm trying to see if i can make a new skill, i was wondering where i could find the skill related script so i can take them as an example anyone has an idea ?

fathom hare
#

Hey guys, would it be hard for someone with a little bit knowledge to create a simple custom mod for MP which reduces the weight of military and tactical walkie talkies? I assume it should be items_radio.txt file which somehow overrides the original on a dedicated server.

obsidian rapids
fathom hare
#

Or is there maybe somewhere a guide on how to override vanilla items?

fiery pecan
#

welp... Update on my zombies issue:
The issue isn't saving the zombie. It's dynamically updating the changes for the client. Anybody know how I would "refresh/reload" a zombie????

sour nova
#
function has_value (tab, val)
    if(tab ~= nil) and (val ~= nil) then
        for index, value in ipairs (tab) do
            if value == val then
                return true
            end
        end
    end
    return false
end

function setContains(set, key)
    if set ~= nil then
        return set[key] ~= nil
    end
end

How come when I use setContains instead of has_value my code breaks. I thought these should be identical

#

i see it as soon as i posted i think

#

if set not nil should work

#

or what i have in parens >_>

dreamy grotto
#

not exactly a modding question, but it's about the game's code. is their a way to look at loot tables for every item? I was wondering if machetes could spawn in any area that spawns good tools

#

such as sheds behind houses, etc.

drifting ore
#

There is a thing in the debugger to know what takes time to calculate? I try to optimize my mod because some say it makes them lose FPS

fiery pecan
sour nova
#
dreamy grotto
#

do the different names for loot tables each refer to one container, or could one loot table be found in multiple containers?

daring palm
#

@undone heron@sour islandsry for tagging you guys, but did you somehow manage to set WalkSpeed? I'm trying to do the same but to no avail

fiery pecan
#

fecking scams!

#

get the feck outta here!!!

subtle pawn
#

Chipping in a idea, sprinkler mod because watering plants get's annoying

daring palm
#

Someone told me that "More Traits" mod had something

#

I'm taking a look on it right now

modest yarrow
#

Is there a way to create a recipe with no Result ? but just use the OnCreate function ?

round zenith
#

@subtle pawn already a mod for that

daring palm
#

@undone heron Well ... the solution in the mod is to change the player's coordinates by using setX, setY functions, but it seems bad to me.

subtle pawn
round zenith
#

@subtle pawn its called irrigation on the workshop

fiery pecan
harsh prairie
#

I've downloaded some mods but they aren't showing up in the mods folder or anywhere else. Tried restarting the game a few times but that didn't help.

undone heron
#

You could check to see if movement modifiers work. Last I check they didn't in 41. So like boots and sneakers are also broken

daring palm
#

I've managed to successfully increase running speed a little bit by changing the runSpeedModifier within clothing items

#

but there's a cap even if you set to 1000.0

undone crag
daring palm
#

since there's no direct way to tweak the speed multiplier, I'm trying any indirect way

#

no success so far

harsh prairie
#

the problem seemed to fix itself! phew.

drifting ore
#

ClearChildren() is the java function and clearChildren() the lua one

#
--************************************************************************--
--** ISUIElement:clearChildren
--**
--************************************************************************--
function ISUIElement:clearChildren()
    if self.javaObject == nil then
        return;
    end
    self.children = {}
    self.javaObject:ClearChildren();
end
weary matrix
#

check the following line and you'll see the javadoc is correct:

self.javaObject:ClearChildren();```
crimson spindle
#

Is it possible to make a recipe which spawns no item?

nimble spoke
#

Or something like that

drifting ore
#

But hey, seam logic now

harsh prairie
#

How do you make a spawn point occupation specific?

nimble spoke
drifting ore
harsh prairie
nimble spoke
harsh prairie
#

ah, didn't try that. thanks!

#

@nimble spoke that worked for other mods, but still not Pillow's. I am going to try verifying the game files.

#

It is now fixed. phew!

next glacier
#

how do you make it so that your mod still works without modoptions

crimson spindle
#

how do i get a recipe to use just some of the pen instead of the whole pen? is this because its a condition and not drainable?

next glacier
#

???

#

are you not correct

#

if i use ==
different error

#

yea nope

#

still box2 of non-table: null

#

ah

#

just need a require

#

to preload other file

#

making it so if game does not have modoptions installed

#

my mod still works

faint jewel
#

test?

ionic galleon
#

Hi, I want to ask if anyone knows how to spawn an isoobject and make it impassable

#

I've tried setting the sprite properties

#

With walln...

#

And to no avail. The object spawns but it is still passable

next glacier
#

Do we have a UV map of textures in this game?

frank rivet
deft peak
#

so i think my question got skipped over here last time, but are we allowed to suggest mod ideas and ask about mods here?

#

or

#

is this purely for the technical side of them, creation etc

willow estuary
#

If you have questions about using mods/using specific mods #mod_support

deft peak
#

Ah ok thanks Blair ๐Ÿ‘

eager trail
#

1992 encyclopedia

wary holly
#

I got this idea but I don't know how to mod. So basically if you have a pillow in your inventory then the sleeping quality of anything goes up

crimson spindle
#

Can you make a recipe which accepts only fresh food ingredients?

crimson spindle
#

Final question, what's a really good mod I can reference for configuring the loot distribution tables?

next glacier
#

changing the function for sleeping quality
and adding a condition:

#

scan your inventory for a pillow
then sleep quality up

#

else sleep quality = vanilla value

thin hornet
#

Anyone know if we can disable splitscreen in MP?

require("JoyPad/ISJoyPadListBox");

function ISJoypadListBox:invoke()
    local joypadData = self.joypadData
    local item = self.items[self.selected].item
    if item.cmd == "takeover" then
        self:cmdTakeOver(item.playerNum)
    elseif item.cmd == "addnew" then
        --self:cmdAddNew()
    elseif item.cmd == "addsaved" then
        --self:cmdAddSaved(item.player)
    elseif item.cmd == "cancel" then
        self:cmdCancel()
    end
end
next glacier
#

how do you play

#

without splitscreen

#

(if on same pc)?

thin hornet
#

You dont on my server

next glacier
#

so you know where everyone is. interesting

next glacier
#

maybe run it on an event

gilded hawk
#

How can I ensure that my mod works in MP without any friend to help me test if it actually works?

#

Ah, that's very straight forward

#

Thanks

#

I was wondering, is it possible to force a profession to be Female or Male only? Thinkedit
I was thinking about using professions to make premade character from movies or other stuff

frank elbow
#

I think someone was trying to do that not too long ago

#

@hidden estuary did you ever figure that out?

small topaz
gilded hawk
hidden estuary
#

figure what out

#

oh yeah no, I couldn't get it to work

#

I tried to hide the gender option in the character creation menu

#

and that code works, the problem is that if I try to make the game check for a trait, the trait doesnt apply to a player yet cause the player doesnt exist yet

gilded hawk
#

Interesting, If I make it working, I will probably ask @quasi geode to add the code to Profession Framework since I use it for all my professions

hidden estuary
#

I didn't try with a profession

#

here

#

do
    local CharacterCreationHeader_create = CharacterCreationHeader.create
    function CharacterCreationHeader:create()
        if getPlayer():HasTrait("valkyrieWoman") then
            CharacterCreationHeader_create(self);
            self.genderCombo:setVisible(false);
            MainScreen.instance.avatar:setFemale(true);
            MainScreen.instance.desc:setFemale(true);
        end
    end
end```
#

so, the trait didn't work, didn't try with a profession, maybe if the game checks for a profession it would work, but I didn't try that

small topaz
hidden estuary
#

I dont know how to do that xD

#

my knowledge on lua is very scarce, specially in regards of this game

#

still learning the ropes

small topaz
# hidden estuary I dont know how to do that xD

hmm... ok... you should learn lua programming then. ๐Ÿ˜‰ here is the basic idea: in the lua files controlling the occupation&trait screens, you should identify which functions are triggered when the player selects or deselects traits. then make a new variable called for example "TraitHasBeenChoosen" and set it true when the player chooses your trait in question and false otherwise. in the character creation screen, you can then use sth like "if TraiTHasBeenChoosen == true then hide the gender option". but you need to learn lua for this. the whole strategy I outlined should definitely work but requires some coding work.

small topaz
#

might be better to append the command "self.genderCombo.setVisible(false)" to the function "disableBtn" instead.

#

moreover, you could try to modify initClothing function to make it so that each character has your desired gender. but there might be other functions to modify to realize this. that's just my first idea.

frank elbow
small topaz
drifting stump
drifting stump
frank elbow
#

As in, a module-level return? Yeah, true

drifting stump
#

yes

small topaz
drifting stump
#

let me write an example for future reference

next glacier
#

yguys know

#

why this doesnt get loaded

drifting stump
#
-------- exampleFile.lua --------
local variable = "example"

return variable
---------------------------------
------- exampleImport.lua -------
local variable = require("exampleFile")

print(variable) -- will print "example"
---------------------------------
frank elbow
#

Something to note with the example @drifting stump just sent: it must be a table in order to ensure the values are by-reference and not by-value. Meaning, if you return just a number or a string for example, then you won't be able to update it

#

I figured the example would be a table when I typed that lol

drifting stump
#

ill leave it like that because its a simple example of exporting a variable

frank elbow
#

That require should read require('exampleFile')

next glacier
#

what? whats special about setting a local variable = require("file")

drifting stump
#

its assigning the variable returned from the other file

frank elbow
#

It loads the file if it hasn't been loaded (note that this means multiple requires to the same file = only a single load!), then returns the value returned by the module

next glacier
#

so far ive only used require("file")

frank elbow
#

That also returns the value(s) returned by the module, you're just not using them

#

I highly recommend reading through Programming in Lua (or some other resource, if official docs aren't your cup of tea)

next glacier
#

so far ive been just reading chunks and bits in between

frank elbow
#

You can get by by learning as you go, but when I learned Lua I read the entire thing to be thorough. It's up to you how well you want to know it; for the most part, knowing the intricacies of metatables is just interesting but not too commonly used

small topaz
# frank elbow I don't disagree with using a variable to track the state (although, I wish ther...

btw I also guess there is a way to access the trait without making an extra variable. the game also remembers the traits (otherwise I couldn't assign them properly to the player when game starts). there is probably a way to access the trait in a more clean way. in case you couldn't get it from the IsoPlayer, there is also an object called Main.instance.desc in the character creation which stores a lot of stuff for the player build, for example the profession. might be worth a try to check this (although I am not sure if it stores the trait).

frank elbow
small topaz
#

ah ok. but as i said before, there are probably also problems because they seem to disable the whole create() method. would try to fix it first.

gilded hawk
#

Sorry for not replying to the gender/profession/trait things but im at work, but I'm fairly confident that it's possible to look for the selected profession and gender by looking into the clothes options for the professions

small topaz
drifting stump
#

did some improving of the example

small topaz
#

but Main.instance.desc:isFemale() contains just the info about the current gender. to make it so that a certain character always has a predefined gender, you need some different coding.

pearl monolith
#

Is anyone there who knows how to make clothing/armor mods ? i could use a hand

frank elbow
#

You can (and should!) check the source of existing mods by downloading them and looking through their mod folder. Further explanation on the meaning of this: download a clothing mod, check out its source to learn how it works

#

I'm unsure about specific resources for clothing mods, but I imagine they're out there. You should also check the pins & the modding section of the wiki (which is also in the pins)

daring palm
#

hey guys. How do I pop vehicle's tire? I'm making a mod that randomly pops the tire whenever the player steps over a specific ground item.

#

Tried to set damage on it, but it didn't work. Condition goes to 0 but it does not pop

gilded hawk
daring palm
#

boom

gilded hawk
#

Can they boom in pz?

daring palm
#

sure. when you keep running over zombies, one tire eventually pop

#

there's even a specific sound

#

!!!

gilded hawk
#

๐Ÿ˜ฎ

#

Damn 90 hours in and I didn't even know it could happend

small topaz
#

this code will make all the characters in the customisation screen female!

gilded hawk
#

oooooh

#

You _pog

#

I just need to use desc:getProfession() to enforce the profession check then

small topaz
#

it doesn't hide the option to select gender yet. moreover, it probably won't work if player choose the "Unlock all clothing" option in sandbox.

gilded hawk
#

I can probably figure something out tho

#

Thanks a fuckton man

#

I'm sending you a hug pepe_hug

small topaz
#

might be that there are better ways to do this but could be a point to start with. here is the code again, so you can copy:

#

and I guess this code should be put to lua/client

gilded hawk
#

Do I need to require CharacterCreationMain Thinkedit ?

small topaz
leaden dew
#

Is there any way to get distribution tables after world (map?) started and save them to file?

Trying to figure out whatโ€™s wrong with suburbsโ€ฆ

small topaz
gilded hawk
#

Okay thanks loveyou

#

I can work on it in 1-2 hour and I will let you know cheer

small topaz
#

you're welcome! but don't forget to test it a lot (also using the "randomize" character button) to check whether it really works in every case.

quasi geode
tranquil reef
#
if (item:getType() == "Bleach") then
    bleachItem = item
end```
#

How can I extend this to be multiple objects, like soap, cleaning liquid, etc

#

can I just do an "or" symbol within the if statement lol? I'm not really sure what the symbol is for that in lua though

frank elbow
#

The symbol is or, but for any amount greater than 2 (really, any amount greater than 1 is fine for this pattern, but if it's only two comparisons it's more typing for marginal benefit) you'll want to use table keys instead

#

That is:

local validItems = {
    ['Bleach'] = true,
    ['SomethingElse'] = true,
    -- and so on
}

if validItems[item:getType()] then
    -- do stuff
end
#

If you're trying to assign them to different variables, you'll have to either do multiple comparisons or have a second table which you use instead of those variables. I believe tables are slightly less performant than variables, though (may be untrue, I'm not familiar with kahlua's implementation), so your call if that's a loss that's acceptable

tranquil reef
#

Alright, thank you

frank elbow
#

Oh, I meant to also say: I'm unsure what the standard is, but I'd assume it's safer to use getFullType (which would return 'Base.Bleach') rather than getType

#

In case someone's mod defines Bleach in another module, for example

tranquil reef
#

So pretty much all I'd have to do would be to change getType to getFullType?

frank elbow
#

Yes, and expect Base.Bleach instead of Bleach for the string

daring palm
#

Omar. Why does the game use Strings for comparison instead of Numeric values?

frank elbow
#

What do you mean? Like the example above?

daring palm
#

in general. I see all sorts of things being Stringed compared when they could use numbers instead

frank elbow
#

I'd assume in some cases it's for ease of modding; it's much simpler to compare item IDs as above than it would be to keep track of integer IDs (which would also be limited, but with Lua's number range that wouldn't be much of an issue)

daring palm
#

it could enumerate ItemTypeName and then use the enumerated values for much faster comparisons

frank elbow
#

I can't really give an absolute answer, though. You'd have to ask the devs

frank elbow
daring palm
#

I think I saw some usage of enumerated values

#

don't remember where

#

if item == ITEM.KETTLE then ...

frank elbow
#

I'd assume that was a string "enumeration", or just a table of strings

daring palm
#

ops item:itemID()

#

Omar. one final question if you dont mind

#

How do I safely delete an item?

frank elbow
#

๐Ÿคท๐Ÿพโ€โ™‚๏ธ I'm not really much of a modder, I'm only useful for Lua knowledge

daring palm
#

oh I see

frank elbow
#

I imagine the documentation lists a method for item deletion if it exists

daring palm
#

I'm trying to pop a vehicle's tire. The only way I figured out so far is "deleting" the wheel

#

basically I get the part and then

#

part:setInventoryItem(nil)

#

vehicle:transmitPartItem(part)

#

but I'm not sure if that is the safest way to remove a tire

#

It does work, but I suspect the part goes to the limbo ...

frank elbow
#

Couldn't tell you; the only deletion code I can think of is the trash can's "delete all", which uses ItemContainer's clear method (and there might be a debug deletion too? unsure). I imagine if you determine where the existing tire popping happens in the code you can mimic it in Lua

daring palm
#

Yeah. I tried to pinpoint the popping logic in the code but I didn't find anything.

#

the setInventoryItem to nil was the closest I could get

frank elbow
#

When does tire popping usually occur? When the tire condition is low?

daring palm
#

I suspected so. My initial idea was to set the condition to 0 and then wait for the game to update

#

Didn't work either. I kept running with the car with a 0 condition tire and nothing happened

frank elbow
#

I believe I've found the relevant code

daring palm
#

there is a method named "damage"

frank elbow
#

From server/vehicles/Vehicles.lua, line 619

-- lower the tire condition depending on your speed/current steering
-- also handle tire explosing because of condition/lack of air here
function Vehicles.Update.Tire(vehicle, part, elapsedMinutes)
    if vehicle:isEngineRunning() and vehicle:getCurrentSpeedKmHour() > 10 and part:getInventoryItem() then
        local chance = Vehicles.LowerCondition(vehicle, part, elapsedMinutes);
        
        -- randomly losing air
        if part:getContainerContentAmount() > 0 and ZombRandFloat(0, 100) < (chance / 2) then
            part:setContainerContentAmount(part:getContainerContentAmount() - 1, false, true);
        end
        
        -- chance of tire explosing
        -- because of it not containing enough air
        if part:getContainerContentAmount() < 5 then
            local contentMod = (part:getInventoryItem():getMaxCapacity() - part:getContainerContentAmount())  / 350;
            if part:getContainerContentAmount() == 0 or ZombRandFloat(0, 100) < contentMod then
                vehicle:getSquare():AddWorldInventoryItem(part:getInventoryItem(), 0,0,0);
                VehicleUtils.RemoveTire(part, false);
            end
        end
    
        -- then because of condition
        if part:getCondition() < 15 then
            local condMod = (100 - part:getCondition())  / 350;
            if part:getCondition() == 0 or ZombRandFloat(0, 100) < condMod then VehicleUtils.RemoveTire(part, true); end
        end
    end
end
#

So VehicleUtils.RemoveTire may be what you need

daring palm
#

thanks, Omar. I'll check it out right now

vocal drift
#

Hi! Sorry to bother you, I'm playing with a few friends in a private server with some mods and I'm the only one having this bug, it happens whenever I open the build menu or interact with it (changing tabs, adding materials, adding stuff to favorites, closing the menu, etc.), this is the stack trace (in different messages because of Discord's character limit):

#
function: populateRecipesList -- file: ISCraftingUI.lua line # 1067
function: refresh -- file: ISCraftingUI.lua line # 65
function: addItemInEvolvedRecipe -- file: ISCraftingUI.lua line # 1520
function: onAddRandomIngredient -- file: ISCraftingUI.lua line # 435
function: onMouseUp -- file: ISButton.lua line # 56

ERROR: General     , 1644853851778> 3.100.985.711> ExceptionLogger.logException> Exception thrown java.lang.reflect.InvocationTargetException at GeneratedMethodAccessor312.invoke.
ERROR: General     , 1644853851778> 3.100.985.711> DebugLogStream.printException> Stack trace:
java.lang.reflect.InvocationTargetException
    at jdk.internal.reflect.GeneratedMethodAccessor312.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.LuaJavaInvoker.call(LuaJavaInvoker.java:188)
    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.UIManager.update(UIManager.java:808)
    at zombie.GameWindow.logic(GameWindow.java:253)
    at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
#
    at zombie.GameWindow.run_ez(GameWindow.java:661)
    at zombie.GameWindow.mainThread(GameWindow.java:475)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 1
    at java.base/jdk.internal.util.Preconditions.outOfBounds(Unknown Source)
    at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Unknown Source)
    at java.base/jdk.internal.util.Preconditions.checkIndex(Unknown Source)
    at java.base/java.util.Objects.checkIndex(Unknown Source)
    at java.base/java.util.ArrayList.get(Unknown Source)
    at zombie.inventory.RecipeManager$RMRecipeSource.getAvailableItems(RecipeManager.java:723)
    at zombie.inventory.RecipeManager$RMRecipe.getAvailableItems(RecipeManager.java:618)
    at zombie.inventory.RecipeManager.getAvailableItems(RecipeManager.java:1025)
    at zombie.inventory.RecipeManager.getAvailableItemsNeeded(RecipeManager.java:1002)
    at zombie.inventory.RecipeManager.HasAllRequiredItems(RecipeManager.java:441)
    at zombie.inventory.RecipeManager.IsRecipeValid(RecipeManager.java:333)
    ... 21 more
#

I'm afraid I don't know Lua, the only different recipes we have are those of the Engineer class (me)

daring palm
#

@frank elbow it worked! thank you so much. I hope God gives you all the candy you want

frank elbow
vocal drift
#

Alright, thank you!

next glacier
#

exactly?

#

or do you have more mods than server

#

looks like an invalid recipe

gilded hawk
#

Can someone explain me this error?

function: CharacterCreationMain.lua -- file: CharacterCreationMain.lua line # 1

ERROR: General     , 1644857542267> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: attempted index: initClothing of non-table: null at KahluaThread.tableget line:1689.
ERROR: General     , 1644857542268> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: attempted index: initClothing of non-table: null
    at se.krka.kahlua.vm.KahluaThread.tableget(KahluaThread.java:1689)
    at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:492)
    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.pcall(KahluaThread.java:1782)
    at se.krka.kahlua.integration.LuaCaller.pcall(LuaCaller.java:76)
    at se.krka.kahlua.integration.LuaCaller.protectedCall(LuaCaller.java:117)
    at zombie.Lua.LuaManager.RunLuaInternal(LuaManager.java:550)
    at zombie.Lua.LuaManager.RunLua(LuaManager.java:496)
    at zombie.Lua.LuaManager.RunLua(LuaManager.java:482)
    at zombie.Lua.LuaManager.LoadDirBase(LuaManager.java:329)
    at zombie.Lua.LuaManager.LoadDirBase(LuaManager.java:256)
    at zombie.Lua.LuaManager.LoadDirBase(LuaManager.java:375)
    at zombie.GameWindow.init(GameWindow.java:1170)
    at zombie.GameWindow.mainThreadInit(GameWindow.java:556)
    at zombie.GameWindow.mainThread(GameWindow.java:469)
    at java.base/java.lang.Thread.run(Unknown Source)
LOG  : General     , 1644857542269> -----------------------------------------
#

this is my code pz-BeatrixKiddo\Contents\mods\BeatrixKiddo\media\lua\client\OptionScreens\CharacterCreationMain.lua

local old_CharacterCreationMain_initClothing = CharacterCreationMain.initClothing
function CharacterCreationMain:initClothing()
    local result = old_CharacterCreationMain_initClothing(self)
    -- code
    return result
end
small topaz
small topaz
gilded hawk
#

It should not give me that error tho Thinkedit

#

Because even when I use your code I get the error

small topaz
gilded hawk
# gilded hawk Because even when I use your code I get the error
attempted index: initClothing of non-table: null

LOG  : General     , 1644857820550> -----------------------------------------
STACK TRACE
-----------------------------------------
function: CharacterCreationMain.lua -- file: CharacterCreationMain.lua line # 2

ERROR: General     , 1644857820551> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: attempted index: initClothing of non-table: null at KahluaThread.tableget line:1689.
ERROR: General     , 1644857820551> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: attempted index: initClothing of non-table: null
    at se.krka.kahlua.vm.KahluaThread.tableget(KahluaThread.java:1689)
    at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:492)
    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.pcall(KahluaThread.java:1782)
    at se.krka.kahlua.integration.LuaCaller.pcall(LuaCaller.java:76)
    at se.krka.kahlua.integration.LuaCaller.protectedCall(LuaCaller.java:117)
    at zombie.Lua.LuaManager.RunLuaInternal(LuaManager.java:550)
    at zombie.Lua.LuaManager.RunLua(LuaManager.java:496)
    at zombie.Lua.LuaManager.RunLua(LuaManager.java:482)
    at zombie.Lua.LuaManager.LoadDirBase(LuaManager.java:329)
    at zombie.Lua.LuaManager.LoadDirBase(LuaManager.java:256)
    at zombie.Lua.LuaManager.LoadDirBase(LuaManager.java:375)
    at zombie.GameWindow.init(GameWindow.java:1170)
    at zombie.GameWindow.mainThreadInit(GameWindow.java:556)
    at zombie.GameWindow.mainThread(GameWindow.java:469)
    at java.base/java.lang.Thread.run(Unknown Source)
#

The only other piece of code that could be touching it is ProfessionFramework Thinkedit

willow estuary
#

Are you overwriting the entire CharacterCreationMain.lua with your code in a file with the same name?

small topaz
#

hmm... seems also to be the case that your modded file has the name CharacterCreationMain. Does it overwrite every function from that file?

#

oh... see @willow estuary ๐Ÿ˜‰

gilded hawk
#

Oh

#

That's something

#

Yes, has same name and path

willow estuary
#
  1. Rename your file to something other than that
  2. Have the first line in your file be require "OptionScreens/CharacterCreationMain"
gilded hawk
#

Okay thanks Blair

#

I think I will use the require thank you

small topaz
#

also, don't define the function CharacterCreationMain:initClothing twice in your mod

gilded hawk
#

I did not expect it to overwrite the entire file, it's not something I'm used to

small topaz
gilded hawk
#

This function is autogenerate by my PD2 vscode extension and I just do the old_namehere hook that's why I was confused when you mentioned that the return could be the problem. I never had return issues with lua

local old_CharacterCreationMain_initClothing = CharacterCreationMain.initClothing
function CharacterCreationMain:initClothing()
    local result = old_CharacterCreationMain_initClothing(self)
    -- code
    return result
end
#

Okay changing the name made it work ๐ŸŽ‰ tada_vuetify

small topaz
gilded hawk
#

It will be just nil iirc

#

So, I noticed a thing

local vanilla_initClothing = CharacterCreationMain.initClothing
function CharacterCreationMain:initClothing(...) 
    local desc = MainScreen.instance.desc
    if desc:getProfession() == "BeatrixKiddo" then
        desc:setFemale(true) -- set gender always to female
        CharacterCreationHeader.instance.avatarPanel:setSurvivorDesc(desc)
        MainScreen.instance.charCreationHeader.genderCombo.disabled = true
        MainScreen.instance.charCreationHeader.genderCombo.selected = 1
    end
    vanilla_initClothing(self, ...)
end

This code works, and MainScreen.instance.charCreationHeader.genderCombo.disabled = true disables, the button. But the combo value has to be forced to 1
Weird, but it does work

small topaz
#

good question! maybe it deletes all data related to gender combo when you disable it in your way and sets everything to nil which may cause conflicts. but just a speculation.

#

as an alternative way to disable the gender combo in the init function, you could try to append the command self.genderCombo:setVisible(false) to the function disableBtn (also in CharacterCreationMain). This won't delete anything afaik but just "hide" the option.

gilded hawk
#

That's a good idea

hybrid wolf
#

I have an idea for a mod, just to throw it out here; nightmare/psychosis... in the middle of the night where you might have a nightmare you end up going through a minigame that zombies are entering your house, you're not physically effected and you don't die, but if you do die in the nightmare you wake up with nightmare moodle, if you survive the small horde you dont get the moodle (or you get a bonus). The psychosis would be a random godmode zombie would spawn nearby or inside your safehouse, that isn't real, can't hurt you but you can't tell until you've been virtually "bitten".

hybrid wolf
#

I dont even know if it's possible. But if anyone is looking for ideas, that one is up for grabs

#

lol

gilded hawk
#

The problem is that you can always GTFO and run out of window, and that can invalidate the entire minigame

hybrid wolf
#

run too far and you wake up with nightmare moodle I guess

gilded hawk
#

But in that case you will realize that it was just a nightmare Thinkedit and the minigame is nil

#

Plus cant work in MP

hybrid wolf
#

or like a real nightmare, you look like you're running but you're going at snails pace

#

oh it wouldn't fool anyone because you'd have known you put the mod on, but then thats where the psychosis portion would be also be in there

#

lol, in MP see a friend just swinging away at nothin.

#

but also the psychosis could randomly add door banging sounds, window breaks, or window smear sounds. and zombie growls behind you

gilded hawk
#

I tried to set spawn using ProfessionFramework but, for some reason they are not working, any suggestions?


ProfessionFramework.addProfession('BeatrixKiddo', {
    name = 'Beatrix "The Bride" Kiddo',
    icon = "profession_BeatrixKiddoOperative",
    cost = 0,
    xp = {
        
    },
    clothing = {
        -- not working with the current version of the Profession Framework on steam. as date 02-JAN-2022
    },
    traits = {

    },
    inventory = {

    },
    spawn = {
        ["Muldraugh, KY"] = {
            { worldX = 35, worldY = 32, posX = 225, posY = 113 }, -- chapel
            { worldX = 35, worldY = 33, posX = 286, posY = 271 }, -- church
        },
        ["Riverside, KY"] = {
            { worldX = 21, worldY = 17, posX = 279, posY = 272 }, -- church
        },
        ["Rosewood, KY"] = {
            { worldX = 27, worldY = 38, posX = 24, posY = 140 }, -- church
        },
        ["West Point, KY"] = {
            { worldX = 39, worldY = 23, posX = 263, posY = 97 }, -- church
        }
    }
})
faint jewel
#

so i made gasoline drinkable, why do i just die instead of peeing fire?

gilded hawk
modest yarrow
#

Is that normal in Solo that Client ticks before Server ?

small topaz
# gilded hawk

in case you don't find a solution with the profession framework, you could also set up the spawn points manually. isn't much work. i think you just need a map folder, a folder for each city, a file spawnpoints.lua defining the actual spawn points and a map.info file (which is in fact just a txt).

#

best thing then is to look at other mods defining new spawn points and check how they realize it.

gilded hawk
#

I'm dumb

#

it's spawns not spawn

#

engiUpset ๐Ÿ”ซ

#

God I miss having linting

quasi geode
#

ah snap...not your fault there, the documentation and examples are apparently wrong (totally my fault)

gilded hawk
#

Eh, shit happens mate

#

Also you forgot the [Text Here] for the example in github

quasi geode
#

ya i noticed that too lol

#

about to fix those lol

gilded hawk
#

Nice ๐Ÿ‘

#

Good thing I cloned your repo on my machine otherwise i would still be stuck lol

#

This Kill Bill mod is taking way more time then expected lol

#

How can I spawn dead zombies in front of my survivor Thinkedit ?

tacit bobcat
#

is there a mod, which can queue up cassettes ?

zealous pebble
#

I couldn't find resources on adding new professions. I haven't tried to look for how to make new weapons

modest yarrow
#

Quick python script that can be useful for some people.
You need to have **Python **installed.
This will generate "ProjectZomboidAutogeneratedWorkspace.code-workspace" file (at the same location of the python file).
This file can be open with Visual studio Code and it will list:

  • all the mods you have in the workshop
  • lua, luaexamples and scripts folders inside Zomboid installation path

Like that you can quickly browse Vanilla and mods code, do quick search in one place ๐Ÿ˜‰

generate_workspace.py

import os
import glob
import json


## Config
steamapps = "D:/Games/Steam/steamapps/"
workspace_name = "ProjectZomboidAutogeneratedWorkspace"

## Setup
export_paths = {
    "folders" : []
}
def add_path(path):
    p = {
        "path" : os.path.normpath(path) 
    }
    export_paths['folders'].append(p)

def sort_alpha(path):
    return os.path.basename(path).lower()


add_path("### ZOMBOID ###")
## Add Zomboid Install Paths
zomboid_root = os.path.join(steamapps, "common/ProjectZomboid/")
zomboid_folders = ["media/lua", "media/luaexamples", "media/scripts"]
for p in zomboid_folders:
    add_path(os.path.join(zomboid_root,p))

## Add Mods Paths
add_path("### Mods ### ")
workshop_root = os.path.join(steamapps, "workshop/content/108600/")
mods_paths = [p for p in glob.glob(workshop_root + "/*/mods/*")]
mods_paths.sort(key=sort_alpha)

for p in mods_paths:
    add_path(p)


## Serialize to json
file = os.path.join(os.path.dirname(__file__), f'{workspace_name}.code-workspace')
with open(file, 'w') as outfile:
    serialize = json.dumps(export_paths, indent=4, sort_keys=True)
    outfile.write(serialize)
zealous pebble
#

Can I use python I kinda get python

modest yarrow
#

It's just a utility script . I'm used to writing python. PZ is only lua and java

zealous pebble
#

Oh I don't really get the python usage then. Idk nvm. Still trying to learn about the basics of modding. I don't know where the info on making new professions are

zealous pebble
faint jewel
#

that would be easy.

#

well easy enough.

gilded hawk
#

I was wondering why does the Schizofrenia mod have this check on most of the player edits?

if player:HasTrait("schizophrenia") and player:isLocalPlayer() and player:getPlayerNum() == 0 then

I don't understand why does it need the player num and isLocalPlayer

thin hornet
gilded hawk
#

Oh, interesting

#

I did not even know we could splitscreen

thin hornet
#

if you have a controller plugged in and press A you can run two character

#

even in an dedicated server

gilded hawk
#

๐Ÿ˜ฎ

#

Impressive

#

Thanks

thin hornet
#

getPlayer() will always return the first local player, getSpecificPlayer(number) will give you the local players from its playerNum

gilded hawk
#

Okay good thank you

thin hornet
#

this is why we use getSpecificPlayer() with context menu cause player 2 in splitscreen can open a context menu for himself

gilded hawk
#

Oh, this is very interesting thanks

#

I will look into it

thin hornet
#

so after looking into the server source there is no event for when the game actually save serverside.

#

what i wanted is to save server custom data at the same time the server save itself. So automatically when running the quit command or the save command.

lusty nebula
#

Sorry, maybe a stupid question but what is difference between client, server or shared or the lua folder?
I mean...Let's say I have a lua file named XXX. I've made some trials and independently in which folder I put it, somehow it works...so what's the difference between the folders mentioned above? What affect putting the file in folder or another?

gilded hawk
#

How can I check if a server has sleep enabled?

nimble spoke
gilded hawk
#
if not isClient() or getServerOptions():getBoolean("SleepAllowed") then
end

Nevermind, I foudn the boolean

lusty nebula
#

Thanks mate! ๐Ÿ˜‰

#

Ok, so last thing....If I run my mod only in SP any folder is the same ( Whatever folder I chose the game will somehow read all the files independently to their folder location ) but if instead I want it working in MP too better to use the shared file correct? ( So both the client and the server could use them )

gilded hawk
#

How can I get how many days has a character survived? I see there is pl:getHoursSurvived() but If I understand correctly this does not work if you char dies, right?

lusty nebula
#

If you set it so every time you character will die it will spawn the character starting again from day 0
if pl:getHoursSurvived() == 0

velvet sonnet
#

hearse mod happycat

gilded hawk
#

Oh, good nice

gilded hawk
#

Or is there a day survived function?

lusty nebula
#

try I have not done tests on the used value

gilded hawk
#

I am, I will give info asap

lusty nebula
#

If instead you want the clothes and the inventory cleared at any new spawn use:
pl:clearWornItems();
pl:getInventory():clear();

#

Sample:
-- if it's a fresh spawn
if pl:getHoursSurvived() == 0 and MXRP_PrisonSpawn.IsPrisonSpawn() then
MXRP_PrisonSpawn.CharacterCreate();
end
end

MXRP_PrisonSpawn.CharacterCreate = function()
local pl = getPlayer();
-- delete the player's starting inventory and clothing
pl:clearWornItems();
pl:getInventory():clear();

#

( The second part is useful if want that the character will always spawn equipped with a certain inventory and a certain set of worn clothes )

next glacier
#

how do I make my mod work server side

lusty nebula
next glacier
#

thanks

lusty nebula
#

๐Ÿ˜‰

next glacier
#

but

#

i think currently my code does not edit

#

sandbox vars

lusty nebula
#

try goggle search you should find what you need ๐Ÿ˜‰

next glacier
#

what is the equivalent of

#

isClient()

#

to server

lusty nebula
#

Sorry can't help I play only SP

next glacier
#

woops

#

okay thanks