#mod_development

1 messages · Page 193 of 1

buoyant fjord
#

they can be busted down though right?

#

damn, idk how to detect then

ebon lion
#

I've a question, in regards to an idea for a mod that might be relatively simple, or might be impossible, depending on how accessible a certain aspect of the game is without touching the actual code.
Does anyone know if the .lua-s handle in any way the incoming and outgoing messages and/or VOIP in the radio system? I feel like it could reasonably be content that's hardcoded and unmoddable, but it would be really neat if there was a way to play around with it.
Can anyone point me in the right direction on whether the moddable envoiriment handles sending and receiving radio transmissions, and if yes, where to begin looking?

EDIT: (For added context, while I don't want to wall of text the channel with the full reasoning, I'd like to try and create a version of Radios that allow you to listen to multiple (fixed, probably only 2) frequencies at the same time, and on top of that, allows you to rebroadcast what you receive on one frequency to another. Think of someone running a radio station on an RP server, and having a separate frequency where people can 'call in', and the host can go: "Caller, you're on the air". Or, alternatively, players could set up their own mobile carrier for lower powered walkie talkies, where anyone with two walkies can talk to people across the map, because powerful radios in key places upcycle the talking frequency to the listening frequency and rebroadcast it for greater distance.)

vapid quest
#

i made this

#
    print("option is working")
end

local function CustomContextMenuOption(player, context, items)
    context:addOption("Custom Option", player, contextMenuDoOnClick)
end

Events.OnFillWorldObjectContextMenu.Add(CustomContextMenuOption)```
true nova
# vapid quest i made this

and that adds to the context menu Custom Option? and prints option is working? thats great its a good start

vapid quest
#

yes, you can try it if you want

true nova
#

thanks man just made my life a bit easier

vapid quest
true nova
#

i wouldn't have a problem figuring things out if the devs just added some comments in their code! or if there was some documentation of how things work anywhere angry

weak sierra
#

VOIP is also very broken atm at long distances

#

and a bunch of other threads on here since

#

i tried to even javamod it back server-side, seems it'd require client mods too or else we missed the mark

#

TIS says it was a security measure but it didn't make a lot of sense to me

#

side effect of preventing people from getting others' location via lua cheats

#

but most cheats are java or external so meh

#

also changed getOnlinePlayers breaking a bunch of mods that needed it

ebon lion
weak sierra
#

now that said, VOIP already has frequencies

#

on the radios

#

if they worked, that is

#

so you could already have that sort of system

ebon lion
#

Hm... Alright, then I'll have a more in-depth look over the files later, see what's accessible. Thanks again.
If you happen to know which file handles incoming and/or outgoing messages, I would appreciate it, as on the first check, the system seemed pretty byzantine

vagrant valley
#

Hello

#

I have an issue with my lua script

#

Specifically an OnCreate script

#

I checked everything and fixed problems but items still wouldnt spawn in my inventory

#

I even took code from another mod and it doesnt work for some strange reason

true nova
#

post the lua

covert carbon
vagrant valley
#
 player:getInventory():AddItem("Base.GoldScrap", zombrand(3));   
 player:getInventory():AddItem("Base.CopperScrap", zombrand(5));   
 player:getInventory():AddItem("Base.SilverScrap", zombrand(3));   
 player:getInventory():AddItem("Base.PalladiumScrap", zombrand(2);
    player:getInventory():addItem("Base.PlatinumScrap", zombrand(2)); 
   player:getInventory():AddItem("Base.MetalSlag", zombrand(2));
end```
#

Wow that looks terrible

#

There we go

#

The formatting isnt like that but that should be enough

ebon lion
bronze yoke
#

also zombrand should be ZombRand

vagrant valley
#

Alright

#

Let me see

#

Still doesnt work

#

There's something about getScriptItem() in the logs

#

@bronze yoke @ebon lion

uneven raptor
#

where can i find the project zomboid installed mods list

#

in my local game files

true nova
vagrant valley
#
Category:Electrical, AllowOnlyOne: false, Base.Electronics Scrap,
Time: 60,
OnCreate:ScrapElectronicRummage_OnCreate,
OnGiveXP: Recipe.OnGiveXP.ScrapElectronicRummage, Result:Base.ElectronicScrap, }```
#

Wait

#

That's another versio

#
    Category:Electrical,
    AllowOnlyOne:false,
    Base.ElectronicsScrap,
    Time:60,
    OnCreate:Recipe.OnCreate.ScrapElectronicRummage,
    OnGiveXP:Recipe.OnGiveXP.ScrapElectronicRummage,
    Result:Base.ElectronicScrap,
    }
#

there we go

true nova
true nova
vagrant valley
#

It does work with base but i guess that's redudant

true nova
#

i dont really see anything wrong though

#

is your module named base?

vagrant valley
#

Yes

#

Do i need a different module for it to work?

true nova
#

and your custom items in your lua is contained in it?

vagrant valley
#

Yes

#

It's the item scripts in a separate file

true nova
#

i would name it something else, it shouldn't affect anything but it is best practice. i doubt that would fix it but if you rename it then it would be "yourmodulename"."itemname" when called in the lua. also is your lua file placed in the proper folders?

vagrant valley
#

Its in lua/server yes

true nova
#

and you're using this on a server?

#

something like this should go in shared or client

bronze yoke
#

recipe code should be in server

vagrant valley
#

The recipe code is in server

bronze yoke
#

the recipe tables will not exist before server runs

vagrant valley
#

even for the vanilla game recipes

#

So do i have to put it in shared?

#

every mod seems to put it in server

bronze yoke
#

no, keep it in server, it will break in shared

true nova
#

ah well im wrong lol

vagrant valley
#

Right

#

The mystery continues

#

I think i should get the full error messages

true nova
#

yeah id check your log and if it is a lua problem it will give you the line

#

thats weird though when deciding what file to put things in i couldnt find much on exactly where to put it so i put recipes in shared and the 2 mods i have worked fine in server... i should change that shouldnt i?

vagrant valley
#

Oh my god

#

i missed goddamn closing bracket

#

'holy shit

#

Also my keyboard is kinda broken right now

#

so dont mind the spelling

true nova
#

atleast you fixed it! despite my questionable help! gj

vagrant valley
#

I think it's still broken

#

For some reason it still wont work despite fixing that issue

covert carbon
#

pulling all nighter to finish mod

true nova
vagrant valley
#

Nevermind

covert carbon
vagrant valley
#

there was another error

#

but the game didnt read the updated script unless i restart completely

#

se.krka.kahlua.vm.KahluaException: recipecode.lua:32: function arguments expected near `:` at LexState.lexerror line:278.

#

I guess i used the wrong function

#

Here's the code

#
    player:getXp:AddXP(Perks.MetalWelding, 0.1);
    player:getXp:AddXP(Perks.Electrical, 0.2);
end```
covert carbon
#

have you defined "player" ?

bronze yoke
#

getXp() not getXp

vagrant valley
#

does it enclose the addxp

#

or is it just getXp():

true nova
#

just getXp()

vagrant valley
#

Alright

#

It's not spitting anymore lua issues

#

But it still doesnt work

#

It's just java errors now

#

Callframe at: PerformMakeItem function: perform -- file: ISCraftAction.lua line # 58 | Vanilla

bronze yoke
#

sounds like an item required by the recipe is null

vagrant valley
#

Is it on the lua side or the script side

bronze yoke
#

it's happening in the java, so it's hard to say - more likely to be script i'd say

#

function: perform -- file: ISCraftAction.lua line # 58 | Vanilla i'd look at what function this line calls, since that's the one that leads to this error

vagrant valley
#

Dont know where to look for that

#

Okay i found it

#

It's this

#

local resultItemCreated = RecipeManager.PerformMakeItem(self.recipe, self.item, self.character, self.containers);

covert carbon
#

does the isOutside() class work for player built structures?

#

Just tested, yes it does

jolly goblet
#

How can I load elements dynamically?
I want to load elements on the map in the parts that are far from the character.

smoky vine
#

on "rare" loot settings i'm still getting about 12 backpacks per school when i set the chance to 0.01, doesn't seem like it's working like i think it does?

#

there are 5 total backpacks with this code

tulip cipher
#

how do i increase the zombie spawn rate past 4?

queen kraken
#

One message removed from a suspended account.

tulip cipher
covert carbon
slow graniteBOT
#
krypt1kz has been warned

Reason: Bad word usage

magic halo
#

Hello, is there any way to change the weight of items in the game by lua script, instead of having to do it manually in the item script?

I've already tried item:setWeight(), but it doesn't work, it's the only attribute I can't change. I'm trying to change the weights of a bag of food, it's a food type item.

crystal terrace
magic halo
tulip cipher
#

then all you do is pass it v and an array

#

for example

        weightApplication(v, woodWeightMultiplier)
    end```
magic halo
#

That worked!

local function scriptInit_setWeight(itemName, itemWeight, multiplier)
    local item = getScriptManager():getItem(itemName)
    item:setActualWeight(itemWeight * multiplier)
end

for itemName, itemWeight in pairs(objList) do
    scriptInit_setWeight(itemName, itemWeight, 10)
end
#

Thanks @tulip cipher

sour island
#

Anyone experience a weird bug where added context menus to the world somehow breaks that square for context menu? no errors to work with

#

Nvm, I think I solved it last night and forgot to test - some UI was invisible but ontop of the area

#

odd

cinder oyster
#

is there something i can use so that when I wanna reload my mod i dont have to launch pz again? I saw that there was something like that but the page for it got removed

sour island
#

Anyone know if PZ has anything for pack()? 😦
I know unpack() is used instead of table.unpack().

cinder oyster
#

vehicle modding question

#

what do I do if my car does not have wheels.

#

the vehicle im making wont have wheels so im at a loss

sour island
#

What is the vehicle?

cinder oyster
#

it is a jetpacki

#

so

sour island
#

idk if you need to make that a baseVehicle

cinder oyster
#

I was thinking of maybe using the superhuman genes as a template but I dont know how id get it so it would need gas

#

Im really new so I am at a complete loss for even where to start

#

actually nvm

#

this is insane

#

i gotta pick something a little easier to do for my first vehicle mod

keen silo
#

Hey, does anybody know how to change the player and zombie models bone local xy scale in game? (to make them look fatter or thinner)

crude vine
#

Hello, Representative of Last Light here. I'm looking to hire a mod developer to code us a smart Type Indicator. By smart I mean less prone to desync and is optimal for server resources. We will pay for full ownership if the price is reasonable. I Apologise if this is not the place for such a request.

sour island
crude vine
#

We're a roleplay server and we have an issue where people doesn't know if the other is typing to reply or not. So when someone is typing in the chatbox, we'd like for there to be some kind of indication to show that they are typing.

#

We have a roleplay chatbox mod that it needs to function with.

neon bronze
#

there is that chat bubble mod for mp

sour island
crude vine
#

Which is why every large roleplay server has their own indicators tailored to them, we used to have our own but stuff happened, so we're in need of a new one

raw wadi
#

Does poly count for a model matter in PZ? I know everything is relatively lowpoly but is there a limit?

#

Just wondering if my model isn't loading due to it being too "high" poly around 3k tris

bronze yoke
#

there's no hard limit

raw wadi
#

Cool, thank you

undone crag
#

helo can u play doom in zomboid?

keen silo
#

Is there a way to modify the MaleBody.X shape to make it look fatter?
I can import the file to Blender, but can't export as an .X file?
(even if it works just naked)

smoky vine
#

yo can you use a GIF as the poster for your mod?

#

or doesn't it work

crystal terrace
smoky vine
#

ah nice tyty

lean reef
#

Sorry if it's a bit of a weird question, just new and trying to get a grip on recipe scripting, but when you use the "Empty Frying Pan" recipe how does it give you a pan with the same condition that it had been in before you started cooking
Just using the one for emptying pan fried vegetables:

recipe Empty Frying Pan
    {
       destroy PanFriedVegetables,

       Result:Pan,
       OnGiveXP:Recipe.OnGiveXP.None,
       Time:40.0,
       Category:Cooking,
       Sound:EmptyPan,
       AllowRottenItem:true,
    }

I think I'm just not understanding the destroy function, but shouldn't this just destroy the original pan and give you a new undamaged pan?

keen silo
#

does anybody know how to edit a players animations?

crystal terrace
lean reef
#

Which is strange, because it doesn't! Trying to figure out how it knows to give you a damaged one

crystal terrace
#

does it, that's interesting

lean reef
#

I originally thought it'd be something similar to the battery code in luaexamples, but this recipe doesn't call any lua functions, unless im missing something

#

Just trying to figure out how this works in the base game because I want to understand the base game recipes to start writing my own but I just can't seem to get a grip on this one specifically

covert carbon
#

I DID IT

#

@crystal terrace My mod is complete and posted

crystal terrace
#

share the link here as well

crystal terrace
#

maybe break the window of car as well while being shot inside the car, could choose a random window for the future updates.

covert carbon
#

I actually planned on doing that but I had just wanted to release the base mod for now and add a lot more details later

#

I pulled an all nighter so I just wanted it finished

crystal terrace
#

Yea i feel you, sometimes finishing a project is really important. It's always Work in progress anyway.

#

I realized something today, if you leave space between name and modname in your mod.info file. It just says unnamed mod on mod selection menu.

keen silo
#

@bronze yoke Do you know anybody with experience modeling (Players/Zombies specifically)

#

?

#

Im trying to make the naked player character fat, but can't get it

crystal terrace
#

Have you tried #modeling , a lot of folks work with that stuff there.

bronze yoke
#

nope

crystal terrace
#

gotta try again, that's your best shot. Try searching in chat using #modeling to limit search to particular channel. I often do that to find matching keywords and then you sometimes find interesting conversations on the same topic.

crystal terrace
#

is there a way to validate an item by name? for ex before adding an item Base.Needle i'd like to verify if it exists or something like try and catch in lua to atleast not throw errors

cobalt fiber
#

It's a bit hard to see, but I think it's understandable

crystal terrace
#

you got it working? cant tell

cobalt fiber
cobalt fiber
#

but if you open on the browser you will be able to see

crystal terrace
#

so somehow it goes back to focus power settings

cobalt fiber
#

It saves what generator you select to focus

#

when that on it's disabled somehow, reset to split

#

if it got turned on again, it got the focus again

crystal terrace
#

you think its the game files messing it up?

cobalt fiber
#

no, no, that's a feature actually

#

because if the fuel empties out, and you fill it up again, you don't need to set it to focus again

#

there's two modes basically, Split and Focus

#

Split share the power consumption between all generators

#

Focus takes the total power of all of them and focus on one generator

#

the others consume 0 L/h

crystal terrace
#

ah

cobalt fiber
#

is that way to ease filling up with fuel on a very big base

crystal terrace
#

makes sense, you dont want to run again and again to set things up

crystal terrace
#

im thinking if someone were to typo and say goes with Base.Noodle right, then i'd like to handle that error or atleast avoid pulling this item.

tulip cipher
#

Run it against a table of all base items, if it matches set a boolean to true,

#

Then use the boolean false as a "ERROR: no item detected"

crystal terrace
#

ye just found teh script manager, might be able to pull the item list

tulip cipher
#

:D

crystal terrace
#

ty😄

tulip cipher
#

You've given me far better advice, trying to repay my debt XD

bronze yoke
#

if ScriptManager.instance:getItem("Base.Needle") returns nil, the item doesn't exist

vapid quest
#

how can i get all sounds from directory? my directory for sounds: media/sound/MySounds

crystal terrace
#

ye i went with this one instead of pulling the list and checking every item, this is much better.

vapid quest
vapid quest
vapid quest
crystal terrace
vapid quest
vapid quest
bronze yoke
#

is getFileList a function you wrote? if not, the error is that that function does not exist

vagrant valley
#

I still have no idea what broke my oncreate script

vapid quest
bronze yoke
#

i don't think it's possible

#

it's something i was interested in before and i couldn't see a way to do it

#

it was for something completely custom so i just made it so a filelist.txt had to be included that would point to all the files but that won't work for most usages

vapid quest
#

is there any way to get all sounds in my mod?

vapid quest
fathom barn
#

create a script

#

You can add as many as you want

#

got it?

vapid quest
#

yes, but how to define them in lua code??

fathom barn
#

you mean how to do the script that you showed in lua?

#

i mean it already works in lua

vapid quest
#

i mean how to use it in lua

fathom barn
#

just the same way it is

#

my "sound" mod path looks like this

vapid quest
#

i mean how to play them

fathom barn
#

module Base
{
sound EnterSoundScriptHere1
{
category = Zombie,
clip
{
file = media/sound/yoursound1.wav,
}
}
sound EnterSoundScriptHere2
{
category = Zombie,
clip
{
file = media/sound/yoursound2.wav,
}
}
}

fathom barn
#

i think i know what you are talking about

#

C:\Users\Your-Pc\Zomboid\Workshop

vapid quest
#

?

fathom barn
#

build your mod there

#

after that, enable it in-game.

vapid quest
#

nooo, how to play sound

fathom barn
#

How to play sound in Project Zomboid?

#

or in general

vapid quest
#

wait a minute

fathom barn
#

and what sound it is

#

can you send me the file you're working on

#

send it as a zip or something

vapid quest
#

i have to write just like local sound = and what in there, path or it name or what???

fathom barn
#

sound scripts

#

D:\steam\steamapps\common\ProjectZomboid\media\scripts

vapid quest
#

i don't get it, i have client side lua, where i receiving command from server and then play sound but how i have to define this sounds?

fathom barn
#

audio.loadSound( "yoursound.wav" )

vapid quest
#

thanks a lot

fathom barn
#

does this work

vapid quest
#

that what i meant

vapid quest
fathom barn
#

try this if it don't work Sound:Load("media/sound/yoursound1.wav")

vapid quest
#

and 1 more question

#

if i have mp 3 sound it will play?

#

or only ogg and wav

fathom barn
#

on pz i recently did mp3 it didnt work

vapid quest
#

thanks

fathom barn
#

i always use waw

fathom barn
vapid quest
fathom barn
#

here

#

this is my level up sound mod

#

take a look

#

why u using lua for a basic sound mod tho

vapid quest
vapid quest
fathom barn
#

that you are making

vapid quest
fathom barn
#

it's like going to a doctor without telling them whats wrong

#

lets say u are editing death sound,

#

u have to add the death script name

vapid quest
#

i'm not editing sounds

#

just using them

vapid quest
#

thanks

fathom barn
#

you trying to access these?

vapid quest
#

no

#

i don't need all sounds

fathom barn
#

well u cant find them seperately

#

all sounds in a bank file

vapid quest
#

but what is the files in media/sound?

#

there are also sounds

fathom barn
#

yeah

#

I don't know why they made the other sounds in a bank file

#

maybe it reduces file size, maybe they dont want their work to be stolen, maybe its bcz of copyrigh

fathom barn
#

i gotta sleep its 4am here

#

any questions

vapid quest
#

no

#

thanks

fathom barn
#

np

fathom barn
vapid quest
#

just playing random sounds near the player

true nova
#

something i've been working on. have plans to add more colors and ability to place on any bed with context menu. curious if anyone wants to help out

covert carbon
#

that looks cool

#

also I accidently switched my old pfp and cant find it

vapid quest
#

which type i should use in sandbox options to make a choose of settings?

vapid quest
#

can anyone help pls? client side not receiving command

server:

    there are all sounds
}

local function sendCommandToClient()

    local randIndex = ZombRand(1,#sounds)
    local randSound = sounds[randIndex]

    ------------ DEBUG ------------
    print("sound:" .. randSound)
    ------------ DEBUG ------------

    sendServerCommand("randomsound", "sound", {randSound})

end

Events.EveryTenMinutes.Add(sendCommandToClient)```

client:
```local function playRandomSound(module,command,sound)

    if module == "randomsound" and command == "sound" then

        local soundObject = sound[1]
        local soundManager = getSoundManager()

        ------------ DEBUG ------------
        print("sound:" .. soundObject)
        ------------ DEBUG ------------

        local player = getPlayer()
        local x,y,z = player:getX(),player:getY(),player:getZ()
                                     
soundManager:PlayWorldSound(soundObject,false,nil,x,y,z,false)

    end

end

Events.OnServerCommand.Add(playRandomSound)```
bronze yoke
#

are you testing in singleplayer?

#

server commands don't fire in singleplayer (but client commands do tired)

sand citrus
#

Question:
Is there a way to figure out the killer and cause of death of a zombie?

I want to access the inventory of a zombie if hit with a specific weapon. Reading the chat history it looks like the zombie’s inventory does not exist until the OnZombieDead function is triggered and it may not contain all of items that will be on the zombie’s corpse if I understand it correctly.

I am currently using the OnHitZombie function to detect when a zombie is hit with the weapon. Killing the zombie with zombie:die() and then attempting to access the Items arrayList in its inventory results in a null reference. So, I don’t think I can access the inventory of the zombie in the OnHitZombie function since not enough time has passed and/or Lua waits for the function to complete before running OnZombieDead.

Any suggestions on how to find the cause of death of a zombie in a way that I can access their inventory? While maintaining a reference to the killer?

Or how I could somehow flag the corpse to do things in the OnZombieDead function?

sour island
#

Anyone messing with icons knows that custom items and icons need to use the media/item_ prefix. This does not however mean the file itself needs the prefix:

#

Helps a lot more with organization purposes

crystal terrace
#

I thought icon files had to have item prefix. I'll try this out.

limpid leaf
#

Do the ProceduralDistributions.lua tables have a size limit? I'm getting an out of bounds error when trying to add a lot of new items. Works fine when it's just a few

fathom barn
#

Hey guys

#

There are a lot of music files in the game, but where can i learn what triggers them to play?

#

For example, when and what triggers the exploration music? mx_exploration_pressing_on_main_75bpm.wav

#

...What triggers the tension musics?

#

Thanks.

vapid quest
#

which type i should use for choice in sandbox-options and how to use it

vapid quest
vapid quest
#

option just disappearing

median mantle
#

Then you should do something wrong

#

Would you show your code?

vapid quest
#

yeah, wait a minute

#
VERSION = 1,

option RandomSounds.OnceInTime
{
    type = enum,
    default = 1,
    page = RandomSounds,
    values[] = {Option1, Option2, Option3},
}```
median mantle
#

You need 'numValues'

#

instead of values[]

#
{
    type = enum,
    numValues = 3,
    default = 2,
    page = pageName,
    translation = optionTranslation,
}```
#

like this

vapid quest
#

thanks

vapid quest
median mantle
#
Sandbox_optionsTranslation_option1    = "option 1",
Sandbox_optionsTranslation_option2    = "option 2",
Sandbox_optionsTranslation_option3    = "option 3",
...```
vapid quest
#

thanks

median mantle
#

or you can use 'valueTranslation'

vapid quest
#

how to translate this?

median mantle
#
{
    type = enum,
    numValues = 3,
    default = 2,
    page = pageName,
    translation = optionTranslation,
    valueTranslation = dropdownTranslation,
}

Sandbox_optionsTranslation        = "option name",
Sandbox_dropdownTranslation_option1    = "option 1",
Sandbox_dropdownTranslation_option2    = "option 2",
Sandbox_dropdownTranslation_option3    = "option 3",
...```
vapid quest
median mantle
#

yes it is. just optional

vapid quest
median mantle
#

You should make your own tranlsation file in lua/shared/Translate

vapid quest
#

i made it, just want to know how is defining this to translate it

#

other translation is working correctly

median mantle
#

Would you show yours?

vapid quest
crystal terrace
#

Make a translation file for your sandbox options, then define it here translation=yourtranslationfile

median mantle
#

Plz show also your sandbox_~~.txt

#

translation = rSCTranslation, part

vapid quest
#
    Sandbox_rSCTranslation_option1 = "10 минут",
    Sandbox_rSCTranslation_option2 = "30 минут",
    Sandbox_rSCTranslation_option3 = "1 час",```
median mantle
#

There's no problem at all

#

Maybe you're talking about the sandbox option page?

vapid quest
#

yes

median mantle
#

Same with options

#

Sandbox_RandomSounds = "your translation",

vapid quest
#

thanks a lot

#

do you know how to check value that was chosen?

median mantle
#

in lua code?

vapid quest
#

yes

median mantle
#

almost same with other options

#

It's saved as integer value (index of chosen option)

vapid quest
#

just
if Sandbox_rSCTranslation_option1 == value then ?

median mantle
#

nope

#

SandboxVars.RandomSounds.OnceInTime

vapid quest
#

thanks

median mantle
#

every sandbox option value are stored in SandboxVars as table

vapid quest
#

so for option 1 i need to use this? or how to do it SandboxVars.RandomSounds.OnceInTime[1]

median mantle
#

No

vapid quest
median mantle
#

For example, if you choose first option then SandboxVars.RandomSounds.OnceInTime = 1

vapid quest
#

i get it, thanks a lot

sour island
#

So "/media/icon_icon"

#

So icon=folder/file works

#

For /media/icon_folder/file

#

It's a little goofy - not sure why the icon prefix is used tbh as it throws off a lot of new modders -- but it's better than being forced to dump all the images into media - especially if you have more than say a dozen

vapid quest
#

i have an error LuaManager$GlobalObject.require> require("sounds") failed in this: require("sounds")
sounds.lua is in media/lua

sour island
#

The require should include everything after client/server/shared

#

And the require needs to be calling a file from the same subdirectory or shared

#

Lua files can't just sit in /Lua/

#

Needs to be in one of the three subdirectories

vapid quest
#

oh thanks

#

unhappy the same error after require("shared/sounds")

median mantle
#

Use just require "sounds"

vapid quest
sour island
drifting ore
#

Hey! is there anything wrong in this code?

player:getStats():setFoodSicknessLevel(player:getStats():getFoodSicknessLevel() + 10000)```

Why does that throw?
`Object tried to call nil in DealDamage`
sour island
#

If sounds is in the same sub directory as the file you're using require in - there should be no issue

sour island
median mantle
#

setFoodSicknessLevel & getFoodSicknessLevel are in BodyDamage

#

Not in Stats

#

player:getStats() -> player:getBodyDamage()
try this

vapid quest
#

how can i call function every 10 minutes if sandbox value = 1

vapid quest
median mantle
#
  if SandboxVars.RandomSounds.OnceInTime == 1 then
    -- TODO
  end
end

Events.EveryTenMinutes.Add(hello)```
vapid quest
#

oh, dont thought about it, thanks

#

but if minutes are 30 how to calculate them?

median mantle
#
local function hello()
  if timeCheck > 0 then
    timeCheck = timeCheck - 1
    return
  end
  if SandboxVars.RandomSounds.OnceInTime == 1 then
    -- TODO
    timeCheck = 3
  end
end

Events.EveryTenMinutes.Add(hello)```
vapid quest
#

thanks a lot

vapid quest
#

just want to use EveryTenMinutes but before use something like OnServerStarted

median mantle
#

use isClient()

vapid quest
#

how to use it?

#

and can't i just write Events.OnServerStarted.Add(Events.EveryTenMinutes.Add(getSandboxTime)) ?

#
    if getPlayer():isClient() == true then
        getSandboxTime()
    else return
    end
end

Events.EveryTenMinutes.Add(checkIsClient)``` is this right?
median mantle
#

getPlayer():isClient() -> isClient()

vapid quest
#

thanks

#

i have an error in this line: playRandomSound()

playRandomSound() function:


    local randIndex = ZombRand(#sounds) +1
    local randSound = sounds[randIndex]

    local soundObject = randSound
    local soundManager = getSoundManager()

    ------------ DEBUG ------------
    print("sound:" .. soundObject)
    ------------ DEBUG ------------

    local player = getPlayer()
    local x,y,z = player:getX(),player:getY(),player:getZ()

    soundManager:PlayWorldSound(soundObject,false,nil,x,y,z,false)

end```
vapid quest
sour island
#

IsClient will return true if the code is being run in MP

vapid quest
sour island
#

I am not able to decipher that lol

#

You don't need entire files to be different depending on MP or not

vapid quest
#

sorry, i'm bad in english

sour island
#

Server code is ran by clients - no matter what

#

If you want the code to be entirely server side you'd have to put a not isclient check

jolly goblet
#

Hello everyone. Does anyone have an example about dynamically loaded? even if it is very basic. But I need to place notes all over the map. the problem I'm having is that I can't just do it with "AddWorldInventoryItem" because this only works on the tiles that load when the character spawns. but not in areas of the map that have not loaded. They told me that it had to be dynamically loaded but I have no idea how to do it. Will someone have a little sample code and I'll look for more information from there.

vapid quest
#

abstract fmod.fmod.Audio
PlaySound(String name, boolean loop, float maxGain) what is maxGain in there?

crystal terrace
vapid quest
crystal terrace
dusty aspen
#

is there any way to increase moodle UI size with mod without changing resolution?
In javadoc there's public function to set UI size and position of MoodleUI, but I don't know how to access through Lua

bronze yoke
#

i wrote a mod that does this, and the answer is basically just no

bronze yoke
limpid leaf
#

Does anybody have any experience with adding items to ProceduralDistributions? I'm getting the error "java.lang.ArrayIndexOutOfBoundsException: Index 200 out of bounds for length 200". The index is always 200. I've counted and no table I'm adding things to exceeds 200 values. I've also hunted for missing commas and such and while I found a few stray things I'm still running into issues.
I'm adding things with the template below, and I have a bunch of those arrays and loops because most of them only add to one loot table each and I've split up the items array into different item types. So it can be a few loops in the table loop.
I seem get the error if I have too many loops. It doesn't matter which ones I remove or leave, but at a certain point I get the out of bounds error and I don't understand why.
If anybody as any idea please help me because I'm about to go insane here.

    "ListName1",
    "ListName2",
}

local ITEMS_TEMPLATE = {
    "ItemName1", 2,
    "ItemName2", 4,
    "ItemName3", 6,
    "ItemName4", 8,
}

for i = 1, #TABLE_TEMPLATE, 1 do
    for j = 1, #ITEMS_TEMPLATE, 2 do
        table.insert(ProceduralDistributions.list[TABLE_TEMPLATE[i]].items, ITEMS_TEMPLATE[j])
        table.insert(ProceduralDistributions.list[TABLE_TEMPLATE[i]].items, ITEMS_TEMPLATE[j+1])
    end
end```
bronze yoke
#

is it giving you a line number? i can't see why you'd be getting this error since you aren't using any arrays (explicitly) to begin with

#

depending on how many 'too many loops' is, your file could literally be too big - i've heard there is a limit on how much Stuff a lua file can have, but i've never managed to run into it

#

if the loops are all copy-pastes of this with different values using a function instead of copy-paste would probably fix that

dusty aspen
limpid leaf
bronze yoke
#

the call stack makes it look like you've hit a variable limit

quasi geode
#

items meaning variables, functions, tables etc.

limpid leaf
#

Ok, thank you so much for the help! I will consolidate some stuff to get blow the limit. Is it an overall thing or per file?

bronze yoke
#

per file

#

200 variables for the entire game would be a bit difficult to work around stressed

limpid leaf
#

Yeah :p just wanted to be sure. Thanks again!

quasi geode
#

well for any given stack, so files and functions various blocks of code etc

granite ginkgo
#

Guys,anyone here experienced with animated cars??

zenith agate
#

Did anyone experiment with adding functional speakers to TrueMusic?
More specifically;

Allowing attaching speakers to a ghettoblaster, to expand the radius the music plays at, or to play it play on several floors without "turning down volume"?
(I see the vinyl player requires a speaker, but it doesnt actually allows expanding sound radius, it just enables the vinyl to start off with)

vestal belfry
#

Anyone know where the pages read in an xp book is kept?

dusty aspen
bronze yoke
#

nobody's been able to give me a reproduction method so i can't fix that yet

mellow frigate
jolly goblet
# crystal terrace you might have to work with `onGrindLoadSquare` function i think, a while ago Po...

I have the following code but it seems to give an error during LUA loading. Although when loading the map no error is marked I have not been able to make it work.

local function LoadGridsquare(sq)
    if sq:getWindow() and sq:getX() == 3148 and sq:getY() == 7228 and sq:getZ() == 0 then
        print('1qX ---->' .. sq:getX());
        print('1qY ---->' .. sq:getY());
        local sqNote  = sq:AddWorldInventoryItem("Base.wicked_lab01_SheetPaper", ZombRand(0.1, 0.5), ZombRand(0.1, 0.5), 0);
    end
end
Events.LoadGridsquare.Add(LoadGridsquare);
#

I have seen many mod use TimedActions/ISBaseTimedAction
Especially the "Snake Pack". In all hidden events they use that library but I don't have a clear example how to use it. Maybe this will help make things load on the map.

vapid quest
# vapid quest can anyone help?

i used getPlayer():getEmitter():playSound(soundObject) for sound and have this warnings:
GameSounds.getOrCreateSound> no GameSound called "hunterShot.wav", adding a new one
GameSounds.getOrCreateSound> couldn't find an FMOD event or .ogg or .wav file for sound "hunterShot.wav"

jolly goblet
# crystal terrace what sort of error?

If I don't put the conditional. The game hangs or just crashes.
and with the conditional apparently it is never fulfilled because the print() is not generated and the object is not added

bronze yoke
#

the game hangs without the conditional because prints are extremely expensive and when you first load in loadgridsquare can be called tens of thousands of times at once

#

you have to be careful when using prints on events like that, and it's why prints in most cases shouldn't make it through to release code

#

for the conditional not working, you should verify that:

  • you are actually at those co-ordinates
  • there is a window on that square, and that the game considers it on that square and not an adjacent square (since windows are on walls, they're sort of 'between squares' and which one it actually belongs to is unclear)
sharp timber
#

Can someone help me figure out how to call methods from another lua file? I'm trying to use lua_timers api but I keep getting an error pointing at line 439

bronze yoke
#

what error?

sharp timber
#

line 441 is line 439 from prev screenshot

bronze yoke
#

looks like they didn't write it as a module so you don't need to require it

#

remove the require line and change timer**.Create to timer:**Create and it should work

sharp timber
#

ok i'll try that

#

wow thanks! it works now

#

🙏🏾

fathom barn
#

i was sick about my simple sound mod not working

#

then i figured i was typing waw instead of wav in the scripts

#

LOL

fathom barn
#

Is PZ musics mono or stereo?

covert carbon
#

how do you find the player's levels in different categories?

keen silo
#

like this

vapid quest
#

but why if its vanilla sound?

keen silo
#

o o

#

I thought it was a custom sound :v

bronze yoke
#

you need to pass the name of the sound script, not the file

vapid quest
keen silo
#

if you are adding the sound to the game, you need to make a sound script, and pass the name of the sound script

bronze yoke
#

the vanilla ones should already have scripts

vapid quest
bronze yoke
#

unless it is unused

#

and actually the loose files are unused

vapid quest
bronze yoke
#

yeah

vapid quest
#

ok, thanks

keen silo
#

I checked with grep -rnw '.' -e 'hunterShot' and found no results in the scripts folder

#

that sound is probably unused

#

you will have to make the sound script

vapid quest
keen silo
#

Something like this:

Name: sounds_{yourmod}.txt

module Base
{
    sound hunterShot
    {
        category = Object,
        clip
        {
            file = media/sound/hunterShot.ogg,
            distanceMin = 5,
            distanceMax = 50,
            reverbMaxRange = 10,
            reverbFactor = 0,
        }
    }
}
#

and then call hunterShot

vapid quest
#

thanks

bronze yoke
#

if it is used it's not too likely the fmod double would have the same name

keen silo
#

I got a question about setting a models mesh

#

I want the player to have a model different than zombies, and clothing also different than zombies

#

is there a way to set the players model (I already have the models)

bronze yoke
#

no

#

the usual workaround is to use a clothing item that masks the entire body

#

and has the new model

keen silo
#

so if I make the base model Fat, every naked zombie will be fat?

bronze yoke
#

i think they use the same model, so probably

keen silo
#

and there is no way to change this?

bronze yoke
#

not to my knowledge

keen silo
#

Ok, I checked the javascript guide

#

apparently, IsoGameCharacters have a getModelInstance

#

ModelInstance has a Model

#

and I can create a new model, using the class constructor Model​(AssetPath assetPath, AssetManager assetManager, Model.ModelAssetParams modelAssetParams)

#

I'll have to review how this works in Lua, but perhaps it is possible (?)

#

Does anybody know the creator of Special Zombies mods? (like CDDA Zombies, or the Last of Us)?

I gather they had to do what I'm trying to do to make their special infected, so I'd like to contact them to learn how they did it.

covert carbon
#

how do you get a player's level on a certain skill?

bronze yoke
#

player:getPerkLevel(Perks.PerkName)

covert carbon
#

thank you 😊

covert carbon
#

managed to shorten my code by 8 lines

#

feels good

vagrant valley
#

Were you using if statements

covert carbon
#

I am yes

#

where can you find the code that defines clothing conditions?

calm depot
#

install a shell like cygwin or mingw

#

(I'm going to assume you're on windows because you'd otherwise already have one)

tardy wren
#

Hello. If I want to make a custom action that can be done with an item, I do need to extend ISInventoryPaneContextMenu.createMenu or should I do something else? As in, I want the player to be able to right click on an item and do something with it. The final result is me trying to let player pour ethanol between containers that can hold it, much like water

tulip cipher
vagrant valley
#

There's also elseif statements

#

If you really have to go down that route

#

It's like nesting but not really

tulip cipher
#

I think I have 1 else in my whole 200 lines

#

And it's right at the start to stop nill or 0 error

tardy wren
vagrant valley
#

I got basically no code experience under my belt

#

So i dont know much about functions and all that

#

Especially the shitshow that is lua and java

tulip cipher
#

I don't even have a facial expression after seeing that

tulip cipher
covert carbon
vagrant valley
#

I know a lot about modelling though

covert carbon
#

even though I could have done it with one statement

vagrant valley
#

So there's that

tardy wren
tulip cipher
tardy wren
#

Here's the example that does absolutely nothing

tulip cipher
#

Thank you!

#

Redundant return lol

tardy wren
#

I do pass an argument to the function but otherwise, yeah, that's the code

covert carbon
#

does anybody know the file that determines clothing conditions? (holes, patches, how to add or subtract clothing condition, etc)

vagrant valley
tardy wren
#

Well, I could use someone with experience rn

covert carbon
tulip cipher
#

Have you guys seen the code for a lot of the weight reduction mods?

#

Like it works, they did a good job... But it's hundreds of if then else......... 😭

muted garnet
#

Can I check if a player is under the influence of pills like beta blockers or something like that?

    local playerStats = self.character:getStats()
    local currentPanicLevel = playerStats:getStats():getPanic()
    local PanicLevel1 = currentPanicLevel + 20
    local newPanicLevel2 = currentPanicLevel + 60

    if player is under (beta blockers) then
        playerStats:getStats():setPanic(PanicLevel1)
    else
        playerStats:getStats():setPanic(newPanicLevel2)
    end
vagrant valley
#

My lua code doesnt even work regardless of if else or no if else

tulip cipher
#

If I see more than one "if x then" I start spazzing out

vagrant valley
#

Something about referencing a null object

tardy wren
tulip cipher
muted garnet
vagrant valley
#

Yeah i have all the items already in game

tulip cipher
vagrant valley
#

It's OnCreate

tardy wren
vagrant valley
#

All the function does is give the player items

#

After crafting something

tulip cipher
#

Are you referencing the original item AFTER crafting, (it no longer exists)

tardy wren
#

Yeah, you can getBetaEffect from Lua

vagrant valley
#

Nope

#

I wrote the script so that it's supposed to give you an entirely new item

tardy wren
#

Show it

vagrant valley
#

I do have the error that pops out from it

tulip cipher
#

Sure

vagrant valley
#

I sent it a few days ago

neon bronze
#

Whats your oncreate code?

vagrant valley
#
    player:getInventory():AddItem("Base.GoldScrap", ZombRand(3));    player:getInventory():AddItem("Base.CopperScrap", ZombRand(5));    player:getInventory():AddItem("Base.SilverScrap", ZombRand(3));    player:getInventory():AddItem("Base.PalladiumScrap", ZombRand(2));    player:getInventory():AddItem("Base.PlatinumScrap", ZombRand(2));    player:getInventory():AddItem("Base.MetalSlag", ZombRand(2));
end```

You could probably tell what im trying to make here
#

For some reason the copy paste broke some things

#

But it should look proper where i have it here

tulip cipher
#

Wish I wasn't on mobile rn

vagrant valley
#

Im also on mobile

#

Im not on my pc right now

neon bronze
tulip cipher
#
    at zombie.inventory.RecipeManager.PerformMakeItem(RecipeManager.java:1302)```
covert carbon
#

If I wanted to add a hole to clothing, would i use this

drifting ore
#

Hey everyone, Is this the right way to make ModData?
at the start of a new character, and only that. it throws an error. attempted index: dosage of non-table: null
I'm new to coding so i really don't know what's the problem. (or how to fix it.)

function initializeDefaultRadiation(dosage)
    local player = getPlayer()
    local RadiationModData = player:getModData()
    RadiationModData["Radiation"]["dosage"] = 0.5
    local dosage = RadiationModData["Radiation"]["dosage"]
    return dosage
end


function loadPlayerRadiationDosage()
    local player = getPlayer()
    local RadiationModData = player:getModData()
    RadiationModData["Radiation"]["dosage"] = RadiationModData["Radiation"]["dosage"] or initializeDefaultRadiation(dosage)
    local dosage = RadiationModData["Radiation"]["dosage"]
    return dosage
end
tulip cipher
#

Event.add?

drifting ore
#

Yeah

#

OnGameStart

#

i only call loadPlayerRadiationDosage OnGameStart.

tulip cipher
#

OnGameStart doesn't get local player radiation before you are using it

drifting ore
neon bronze
#

my only thought is that you could get a 0 and the game doesnt how to handle it maybe

vagrant valley
#

Yeah

#

ZombRand does go from 0 to n

drifting ore
tulip cipher
vagrant valley
#

But i did this before without the numbers (so it pretty much gives a single quantity) and that doesnt seem to work either

tulip cipher
#

Then it says its null

#

Then you set it, and then don't use it

#

Personally, it only makes sense to... Get the player, set the moddata for it, then read the moddata after, then use it

#

Otherwise if it doesn't start with the moddata and then tries to read it, there's not even a data entry, so it returns null

vagrant valley
tulip cipher
covert carbon
#

still have 0 clue what IsoGameCharacter means, can anybody help?

tulip cipher
#

Where's Albion when you need her 😭

vagrant valley
#

She doesnt even know what caused that error either

#

So im kinda stuck here

fading horizon
#

Anyone have any idea why i'm getting this error when equipping my custom weapon?

ERROR: General     , 1693912264916> ModelManager.newInstance> Model is null.
ERROR: General     , 1693912264916> ExceptionLogger.logException> Exception thrown java.lang.NullPointerException: Cannot assign field "parent" because "<local7>" is null at ModelManager.newStaticInstance line:1798.
ERROR: General     , 1693912264916> DebugLogStream.printException> Stack trace:
java.lang.NullPointerException: Cannot assign field "parent" because "<local7>" is null
    at zombie.core.skinnedmodel.ModelManager.newStaticInstance(ModelManager.java:1798)
    at zombie.core.skinnedmodel.ModelManager.addStatic(ModelManager.java:1762)
    at zombie.core.skinnedmodel.ModelManager.addStaticForcedTex(ModelManager.java:1847)
    at zombie.core.skinnedmodel.ModelManager.addStatic(ModelManager.java:1812)
    at zombie.core.skinnedmodel.ModelManager.addEquippedModelInstance(ModelManager.java:1055)
    at zombie.core.skinnedmodel.ModelManager.DoCharacterModelEquipped(ModelManager.java:976)
    at zombie.core.skinnedmodel.ModelManager.ResetCharacterEquippedHands(ModelManager.java:842)
    at zombie.core.skinnedmodel.ModelManager.update(ModelManager.java:1254)
    at zombie.gameStates.IngameState.updateInternal(IngameState.java:1698)
    at zombie.gameStates.IngameState.update(IngameState.java:1333)
    at zombie.gameStates.GameStateMachine.update(GameStateMachine.java:101)
    at zombie.GameWindow.logic(GameWindow.java:298)
    at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
    at zombie.GameWindow.frameStep(GameWindow.java:765)
    at zombie.GameWindow.run_ez(GameWindow.java:681)
    at zombie.GameWindow.mainThread(GameWindow.java:495)
    at java.base/java.lang.Thread.run(Unknown Source)
#
        DisplayCategory = WeaponCrafted,
        MaxRange = 1.65,
        WeaponSprite = stuartSpear,
        MinAngle = 0.8,
        Type = Weapon,
        MinimumSwingTime = 2,
        KnockBackOnNoDeath = FALSE,
        SwingAmountBeforeImpact = 0.02,
        Categories = Improvised;Spear,
        ConditionLowerChanceOneIn = 10,
        Weight = 3.7,
        SplatNumber = 1,
        PushBackMod = 0.3,
        SubCategory = Spear,
        ConditionMax = 12,
        MaxHitCount = 2,
        DoorDamage = 10,
        SwingAnim = Spear,
        DisplayName = Stuart Little Spear,
        MinRange = 0.98,
        SwingTime = 2,
        KnockdownMod = 0,
        SplatBloodOnNoDeath = FALSE,
        Icon = SpearMachete,
        RunAnim = Run_Weapon2,
        IdleAnim = Idle_Weapon2,
        TreeDamage = 0,
        TwoHandWeapon = TRUE,
        CriticalChance = 30,
        CritDmgMultiplier = 10,
        MinDamage = 1.3,
        MaxDamage = 2,
        BaseSpeed = 0.9,
        DamageCategory = Slash,
        DamageMakeHole = TRUE,
        BreakSound = SpearMacheteBreak,
        HitFloorSound = SpearMacheteHit,
        ImpactSound = SpearMacheteHit,
        DoorHitSound = SpearMacheteHit,
        HitSound = SpearMacheteHit,
        SwingSound = SpearMacheteSwing,
        SoundMap = SpearStab SpearMacheteStab,
        AttachmentType = Shovel,
        Tags = FishingSpear,
    }```
#
model stuartSpear {
        mesh=weapons/2Handed/stuartSpear,
        texture=WorldItems/stuartSpear,

        attachment  {
            offset = -0.0100 0.3400 0.0000,
            rotate = 0.0000 0.0000 0.0000,
        }


    }```
drifting ore
#

Sorry for all the questions

tulip cipher
drifting ore
#

All is well man, take care of yourself and stay hydrated.

covert carbon
#

does anybody know what IsoGameCharacter means?

drifting ore
#

its the player. local player = getPlayer()

tulip cipher
covert carbon
#

so getPlayer() is the same as IsoGameCharacter?

tulip cipher
#

Pretty much?

vagrant valley
#

Okay so how do i put "inventory" in a variable

tulip cipher
#

I just use getSpecificPlayer(0)

vagrant valley
#

Like local inventory = Inventory() sort of thing?

covert carbon
crystal terrace
covert carbon
#

what does "iso" mean

vagrant valley
#

Ah

#

So something more like player:getPlayer():getInventory() then

neon bronze
#

No just getPlayer()

crystal terrace
#

Have no clue tbh, but yes you can pass player object (isoPlayer is a child class of iso character)

tulip cipher
crystal terrace
#

so just a naming convention to represent that

tulip cipher
#

Yee I think

#

From what I can tell isoplayer is just player()

vagrant valley
tulip cipher
#

But from java to Lua

tulip cipher
vagrant valley
#

I dont think you need to do that for crafting

tulip cipher
#

Nope

vagrant valley
#

I dont see that being used in the vanilla recipecode.lua

tulip cipher
#

Just saying for when you really need the exact client

#

Otherwise ignore me XD

covert carbon
#

this returns an error print(getPlayer():getFabricType())

#

idk why

crystal terrace
#

from what i have heard for SP, getPlayer is fine but for MP i think getSpecficPlayer(index) is suggested.

tulip cipher
#

Yee

crystal terrace
crystal terrace
#

Even then i don't think you can print out complex objects, If i wanna look at objects i usually use debugger and mark break points. That way i can look at if im pulling a null obj or what exactly does the object hold.

covert carbon
crystal terrace
#

it's not a method available for player obj, only for item objects

covert carbon
#

so how do I find the item that the player is wearing?

fading horizon
# covert carbon so how do I find the item that the player is wearing?
function backpackFlags.wearThis(stuff, texture, name, reverse)
    local player = getPlayer()
        local inv = player:getInventory() 
        local equip = inv:AddItem(stuff);
        equip:getVisual():setTextureChoice(texture);
        
        local playerObj = getSpecificPlayer(0)
        if not playerObj then
            return
        end

        local wornItems = playerObj:getWornItems()

        for i=1,wornItems:size() do
            local item = wornItems:getItemByIndex(i-1)

            if reverse then
                if item:getFullType() == "backpackFlags.PoleReverse" then 
                    item:getContainer():DoRemoveItem(item)  
                end
            else
                if item:getFullType() == "backpackFlags.Pole" then 
                    item:getContainer():DoRemoveItem(item)  
                end
            end
        end


        player:setWornItem(equip:getBodyLocation(), equip);

        name = "Backpack Flag ("..name..")";
        equip:setName(name)
end
crystal terrace
#

i think, if im not wrong clothing items are in inventory right? If that's the case then you can get inventory items and iterate over it. Not sure if theres a way to pull equipped items.

fading horizon
#

this is how I handle it in my backpack flags mod

covert carbon
#

thank you

#

also does anybody know how to add holes/worsen the condition of clothing? I can find how to patch clothing, its bite defense, and a lot of other stuff

#

but not holes or condition

fading horizon
#

setCondition(int Condition)

#

try this?

#

i'm looking at the clothing class rn

covert carbon
#

what is "int"

fading horizon
#

a number of your choosing

#

it would either be 0 - 1 or 1-100

#

idk

vagrant valley
#

Int is anything up to the integer limit

#

I believe condition cant go above 100

#

Or else the item would invariably break

covert carbon
#

oh okay

#

so I tried doing print(getPlayer():getWornItems()) but it doesnt return a list or anything, just a set of numbers

crystal terrace
#

It's a an object of type worn items

#

Look at worn items class in java docs

tardy wren
fading horizon
#

you have to do it like this

tardy wren
#

Question: If I want to make a custom action that can be done with an item, I do need to extend ISInventoryPaneContextMenu.createMenu or should I do something else? As in, I want the player to be able to right click on an item and do something with it. The final result is me trying to let player pour ethanol between containers that can hold it, much like water.

fading horizon
#
local wornItems = playerObj:getWornItems()

for i=1,wornItems:size() do
local item = wornItems:getItemByIndex(i-1)
console.log(wornItems:getItemByIndex(i-1))

if item:getFullType() == "YOURITEMTYPE" then 
// do whatever
#

so you get an object of worn items

#

you then loop through that object

#

each item is retreived and checked against the item you're looking for

crystal terrace
tardy wren
fading horizon
# tardy wren Question: If I want to make a custom action that can be done with an item, I do ...
local function OnFillInventoryObjectContextMenu(player, context, items) -- # When an inventory item context menu is opened
    local playerObj = getSpecificPlayer(player);
    items = ISInventoryPane.getActualItems(items); -- Get table of inventory items
    local isStuartSpear = nil; -- Define a variable to hold the potential vape item
    for _, item in ipairs(items) do -- Check every item in inventory                         
        if item:getFullType() == 'StuartLittle.stuartSpear' then -- If item is a stuart little spear, it is caught in a variable.
            isStuartSpear = item; -- We check if it's our item first to reduce load time since this is called every time an option is right clicked.
            -- // (item:getFullType())
            break
        end
    end

    if isStuartSpear ~= nil then -- # if the clicked item is stuart spear, add the decoration context menu item

        local isFav = context:getOptionFromName("Favorite");
        local opt
        -- // print(CMIcon)
        if isFav then
            opt = context:insertOptionAfter("Favorite", getText("UI_stuartSpear_action"), isStuartSpear,
                callStuartSpearAction, playerObj) -- !! Need to also pass the player object here so the timed action can use it  |  Insert after "favorite" so it's in the normal "smoke" position
        else
            opt = context:insertOptionAfter("Unfavorite", getText("UI_stuartSpear_action"), isStuartSpear,
                callStuartSpearAction, playerObj) -- !! Inserting option after unfavorite. If neither exists, it will just add it to the bottom of the stack by default.
        end

    end
end

Events.OnFillInventoryObjectContextMenu.Add(OnFillInventoryObjectContextMenu) -- !! When vanilla code is ran, add this custom code```
#

check out this code i just did for my mod

#

its adding a context menu that links to a custom function

fading horizon
#

alternatively, check out my GnomeBar Vapes mod, it does exactly that

tardy wren
#

Oh, so I can just subscribe to an event?

#

Thank you

fading horizon
#

it takes a custom context menu and does a custom timed action when clicked

fading horizon
#

for the loop

tardy wren
covert carbon
#

what is an index number

tardy wren
#

it's... a number that states in which position something is

crystal terrace
tardy wren
#

It's only the second time I praise the codebase

#

After 10 mods

crystal terrace
#

You would need to put a check tho to select certain type otherwise it'll pop up for every item. I can share some code later for reference if you want.

fading horizon
#

my bad lol

tardy wren
#

I just want to write a custom pour action, since I'm running ethanol instead of water

fading horizon
#

it didn't even paste the gif

#

lame

#

oh shit i solved my issue

crystal terrace
#

These are the events btw, except the 2nd one.

tardy wren
fading horizon
#

i had "attachment" instead of "attachment world" under the model definition

tardy wren
#

Ah... I don't know much about those yet

fading horizon
crystal terrace
tardy wren
#

Thanks. This seems to be with world objects?

crystal terrace
#

Ye it's same for inventory ones just you need the diff event for that.

tardy wren
#

I just realized that I will need to make the context menu multi-level

#

Since the player will have to select the item to pour into

#

It will take some fanagling...

crystal terrace
#

Yea, not sure if I can help with that.

tardy wren
#

But there's already code for the water, so I should be able to do this

#

Maybe not in the best way, but it will be done

crystal terrace
#

In that case I think it's best to do what game does, I think you could hook into timed actions I'm a bit iffy on that barely used it once.

#

You could also maybe store the container info somewhere to use that later if you don't wanna go the multilevel route.

tardy wren
#

I'll see how it's implemented with water, and try to recreate it with what I have... Which is hashmaps of ReplaceOnUseOn

#

That's the first time I praised the codebase

#
function Recipe.OnCreate.CreatePetrolManual(items,result,player)
    for i = 0, items:size() - 1 do
        ---@type InventoryItem
        local item = items:get(i)
        if item and item:hasTag("EmptyPetrol") then
            local fuelContainerType = item:getReplaceTypesMap():get("PetrolSource")
            local fuelItem = player:getInventory():AddItem(fuelContainerType)
            fuelItem:setDelta(fuelItem:getUseDelta())
        end
    end
end
covert carbon
fading horizon
#

maybe
getCategory()

local wornItems = playerObj:getWornItems()

for i=1,wornItems:size() do
local item = wornItems:getItemByIndex(i-1)
console.log(wornItems:getItemByIndex(i-1):getCategory())

if item:getFullType() == "YOURITEMTYPE" then 
// do whatever
#

i'm not sure honestly

#

i'm better at making models than lua haha

covert carbon
#

its all good

#

I do want to ask though, what does i-1 do

fading horizon
#

i starts at 1, tables start at index 0

#

so it decreses i by one to account for that

#

you could just do i=0 i think

true nova
#

no that returns the item category as a string

covert carbon
#

what is the difference between an index and a table?

true nova
#

index is position in the table

covert carbon
#

OOOOOOOOOOOOOOOOOOOH

#

everything just clicked

#

thx

true nova
#

getBodyLocation() is what i think you need

covert carbon
#

oh alright

#

ive been trying to use getBloodClothingType

#

local wornItems = getPlayer():getWornItems():getBloodClothingType()

#

it doesnt work

#

I might know why one sec

true nova
#

anyone know the function that gets the direction an isoobject is facing?

covert carbon
#

getDir()

#

I think

true nova
#

ah thats probably right i was searching the wrong things

sour island
#

How feasible would it be to transfer images from host to client?

#

I imagine there's no practice way to do it, I was thinking of adding jigsaw puzzles to the game night - but I thought it would be cool if you didn't need to make a submod for thst

bronze yoke
# drifting ore Hey everyone, Is this the right way to make ModData? at the start of a new chara...
    RadiationModData["Radiation"]["dosage"] = RadiationModData["Radiation"]["dosage"] or initializeDefaultRadiation(dosage)
`````RadiationModData["Radiation"]`` hasn't been initialised yet, so it is null, so ``RadiationModData["Radiation"]["dosage"]`` is attempting to index a non-table (null)
you can fix this pretty easily by adding```lua
RadiationModData["Radiation"] = RadiationModData["Radiation"] or {}
```before that line
drifting ore
#

You are so cool, thank you!

true nova
#

is this the proper way to find if a worldobject is a bed getProperties():Is("bed") ?

jolly goblet
#

Does anyone know this mod?

keen silo
vapid quest
#

can i do it in windows?

river moon
#

Hello, a popular cheat for the game has been released, which works on both the pirated and licensed versions of the game. So... I keep a modeless server and I want to protect it, so there is only one way out - to change the Java code of the game. I have some small operational developments in Java for the server, which limit cheaters a little, but this is not enough. Does anyone else have similar developments?

crystal terrace
vapid quest
keen silo
#

it is a command line

bronze yoke
#

i think you can do it in powershell but i'd just use ide search

crystal terrace
#

ye there's prolly powershell alternative for this but IDE is a bit less complicated if you don't wanna dive deep into commands

vapid quest
#

ohhhhh chatgpt helped me

#

findstr /S /M /I "your_keyword" *.txt

#

its working

#

i just tested this

keen silo
#

I work more with console and powershell than scripting

vapid quest
#

oh

#

i have a problem

#

if i'm trying to cd C:\Program Files (x86) it shows error

vapid quest
vapid quest
queen kraken
#

One message removed from a suspended account.

crystal terrace
#

you don't need 1 in Events.EveryHours.Add(spawnWaterBottle)

queen kraken
crystal terrace
#

damn

#

pretty good tbh, you might wanna validate if you found your player obj as well. Don't wanna call stuff on nil just to be on the safe side.

bronze yoke
#

it's kind of longwinded

crystal terrace
#

ye but i think it's coz gpt wants to make it easier for user to understand.

#

If you need to explain it to someone, this seems perfect

covert carbon
#

does anybody know how clothing is divided?

#

like sleeves and sections

bronze yoke
#

the x,y,z doesn't do anything

crystal terrace
#

tru tru it be like that sometimes

queen kraken
#

One message removed from a suspended account.

crystal terrace
#

they prolly mentioned to spawn at player loc

bronze yoke
#

basically the entire thing could be replaced with a single player:getInventory():AddItem("Base.WaterBottleFull")

queen kraken
#

One message removed from a suspended account.

true nova
#

ive tried it and chatgpt uses functions that don't exist and ads "end"s that aren't needed. its decent at the logic and steps required to get what you want though

crystal terrace
#

ye gives you direction if you have experience, otherwise youd be more confused

#

but then again if you know the right questions to ask

true nova
#

i wonder if you could feed it the entire binaries and it could spit out something useable

crystal terrace
#

is it possible? think it works better with human readable languages (saying that with no idea how language model works)

true nova
#

it seems pretty decent at reading code, it's only source is whatever was on the internet 2 years ago though

bronze yoke
#

it's always going to make stuff up since it's only trying to convince you it generated code

crystal terrace
#

plus it can't do maths 👀

queen kraken
#

One message removed from a suspended account.

queen kraken
#

One message removed from a suspended account.

vapid quest
#

how can i check amount of players on server?

#

or get all players

#

just like getPlayer()

crystal terrace
#

not exactly sure, but could try getPlayer():getPlayers():size

bronze yoke
#

that's a static method so you would just call IsoPlayer.getPlayers(), but iirc that's local players only and the size is always 4

#

if i remember right it just translates an IsoPlayer[4] array into an arraylist since arrays aren't a thing with kahlua

crystal terrace
#

ah

vapid quest
#

i found getPlayerCount

bronze yoke
#

actually not sure how size would behave with that but either way it wouldn't be the total server count

median mantle
#

try getOnlinePlayers()

#

If you want to get player count in MP

tulip cipher
#

its very hard making your code a static amount of lines no matter how much to client would like to do

bronze yoke
#

unfortunately when called on the client getOnlinePlayers doesn't count players you haven't been near yet

median mantle
#

Isn't it return all players when called on server side?

bronze yoke
#

yeah

tulip cipher
#

yeah but i think it includes the host or AFK invis admins too

median mantle
#

Of course it does

vapid quest
median mantle
#

It's almost same with getOnlinePlayers() when called on server side

#

Difference is getPlayerCount returns int and getOnlinePlayers returns list

drifting ore
#

How do you trigger a sneeze or a cough? this code doesn't work, it throws an error but. there is no error.
just says this
`STACK TRACE

Callframe at: setSneezeCoughTime
function: do_sneeze -- file: Cure.lua line # 256 | MOD: psst
`

function do_sneeze()

    local player = getPlayer();
    local bodyDamage = player:getBodyDamage();
    local get_sneeze bodyDamage:getSneezeCoughTime();
    if (ZombRand(50) == 1) then
        --sneeze
        if (ZombRand(0, 1) == 0) then
            print("sneeze?)")
            bodyDamage:setSneezeCoughActive(1);
            bodyDamage:TriggerSneezeCough();
            bodyDamage:setSneezeCoughTime(get_sneeze, 1);
        --cough
        elseif (ZombRand(0, 1) == 1) then
            print("cough?")
            bodyDamage:setSneezeCoughActive(2);
            bodyDamage:TriggerSneezeCough();
            bodyDamage:setSneezeCoughTime(get_sneeze, 1)
        end
        bodyDamage:setSneezeCoughActive(0);
    end
end
bronze yoke
#

typo local get_sneeze bodyDamage:getSneezeCoughTime();

#

missing the = so get_sneeze is initialised as nil

thick prawn
#

Does anyone here make mods? Looking for someone to create a custom mod for server.

#

Not for free either lol

drifting ore
#

Good spot, it still throws the same error. though. it "partially" works by making the character sneeze 24/7

median mantle
#

Doesn't setSneezeCoughTime have only one parameter?

drifting ore
#

setSneezeCoughTime public void setSneezeCoughTime​(int int1)

covert carbon
#

does anybody know where the code is for clothing condition and how to set holes in clothing?

vapid quest
drifting ore
#

wait, so its 1 parameter?

bronze yoke
#

you're confused - int1 is the name of the int

median mantle
drifting ore
#

oh dang it, i thought it was two parameters

sour island
#

In java the type of the arg is written out

tulip cipher
#

we out here using k, v in pairs like a clown 🤡

#

finally its infinitely expandible and will only use two k, v in pairs

sour island
#

Im troubled that you're using k in the second one

tulip cipher
#

WE BALL

sour island
#

everyone hated that

bronze yoke
#

ehh, if it's a load time event the performance penalty of pairs really doesn't matter very much

#

if it makes the code prettier i wouldn't avoid it for stuff like this

sour island
#

Wait, if the keys and values are 1 to 1 why not use a keyed table?

tulip cipher
#

its changing every item the client wants in sections to whatever weight they want, regardless of other settings :D

tulip cipher
#

this took 2h...

sour island
#

You can make a table with string keys, like

Multipliers = {foodmulti=multiplier}
tulip cipher
#

(THIS ISNT CODE USED BY ZOMBIOD)

#

bruh

#

its that simple....

bronze yoke
#

or just my_table["Table Key"] = "Table Value"

covert carbon
#

Does anybody know the code for clothing getting ripped or holes put in them

bronze yoke
#

if it's a string with no spaces or weird characters you can do```lua
my_table = {
TableKey = "Table Value",
}
my_table.TableKey = "Table Value"

tulip cipher
#

i need to rewrite my code brb XD

bronze yoke
#

i'm a pretty huge fan of the table.key syntax but i understand a lot of people don't like it

sour island
#

Sorry my pseudo code is bad, just had to stand out in like 95F weather

tulip cipher
sour island
#

underwear1 🤽‍♂️

sour island
#

I usually use [""] for the top tier of the data, and straight var= for the inner

#

Also stuff like getModData().var looks so weird

bronze yoke
#

iirc a lot of people don't like it because it doesn't look like an array access like it would in another language, and prefer to only use it with pseudoclass properties

#

which makes sense, and having rules is likely more legible, but... i don't wanna

tulip cipher
#

soooo I would make a table, lets call it Keyed_Items_Multipliers
then I would add both the Item table and the multiplier? {WoodItems = woodWeightMultiplier, ...}

#

ive tried to make it very easy to understand but im heatstroked so...

sour island
#

Just to clarify, you have settings for each category of item?

tulip cipher
#

yes

#

every category has its own mult - settable by the client

vapid quest
#

is it possible to make gui without java?

#

if yes how to make gui

#

i want just a small black box

vapid quest
#

and buttons

tulip cipher
#

wait i can just do a multi-dimensional array - so ill start with making two arrays (array 1, Type ; array 2, Multiplier), adding 5 key-value pairs (5 keys to the first and 5 values) then call them both separately but call the same index?

sour island
#

You can

#

It if it's one to one that may not be necessary

#

You can also make either key or value a table in of itself

#

But then things get wild

tulip cipher
#

basically i have

  • multipliers
  • type of item
#

so basically 2 things

vapid quest
tulip cipher
#

so that woodWeightMultiplier goes hand in hand with WoodItems

crystal terrace
#

Yes either that or make item type as index of your main table

sour island
#

You can do

table = {key = {var1, var2, var3}}``` where table.key[1] would be used to access the data. Or ```lua
 table = {key = {a=var1, b=var2}}``` Where you'd use table.key.a to get var1.
tulip cipher
#

little issue ive read up on it, and i just dont get the syntax

sour island
#

Everything is tables in Lua

#

There is no classes, only table

tulip cipher
#

yeah

sour island
#

You can make the category the keys

#

And the values = to the multipliers

#

Then when you're applying the changes to items

#

Multipliers[item.category] would get the associated value/multipliers

#

You should not need to use for() basically ever unless the order is important

#

And in associated pairs there is no order

tulip cipher
#

so basically its two sperate arrays that are just using the same index and lua combines them?

crystal terrace
sour island
#

Effectively you could say that, but no?

#

It's 1 list

tulip cipher
#

1 list... 1 pointer value... finds 2 values?

sour island
#

In Lua the index is the "key"

vapid quest
tulip cipher
#

should just use pointer XD sorry

sour island
#

If the keys are not numeric from 0 to n then you can't actually iterate over them

#

You can make keys anything other than a number

crystal terrace
#

Ye I think that's the one

sour island
#

You can even make keys or values functions given they're not called

#

Cause even functions are stored in a table to call on

tulip cipher
#

hmmm

sour island
#

When ever you call on a table and supply a key it will grab the associated value

#

A clean way to check if somethng is in a table is to actually fill the keys with the intended thing, and fill the values with true

#

Otherwise you're stuck using for()

#

Which isn't that big of a deal, bug depending on how often you need to do it - or how long the list is - it can be a bad idea

#

I'm very lazy, so I'll write a table normally with as little typing as possible and include a for() running when the Lua loads to assemble the list of trues

vapid quest
#

how to check is player a creator of MP?

sour island
vapid quest
#

then how to know steamid?

sour island
#

Check IsoPlayer class file

vapid quest
#

found one

#

public long getSteamID()

#

so i should use getSpecificPlayer(index):getSteamID()?

sour island
#

You get use getPlayer() if you're not interested in co-op

#

Which is the same as getSpecificPlayer(0)

vapid quest
#

is it possible to create new command?

sour island
keen silo
#

@sour island I'm trying to make a mod that makes your character model fat when you are over a certain bodyweight. I have all the clothing models, with a fat version. the problem I have is that if I change the naked model, It will affect all players and zombies.

Is there a way to tell which models to use when for which characters?

sour island
tardy wren
#

Possibly there is

#

Authentic Z does have fat zombies

bronze yoke
#

co-op is often used to refer to in-game hosted multiplayer

#

there's no consistency with the terms

tardy wren
#

I have ran into a conundrum

#

I've been trying to organize my code into modules, but now... I am worried

#

In one mod, I have this code

Daikon =  Daikon or {
    ApocalypseBiofuels = {

    }
}
return Daikon
#

in a different mod, I have this code

Daikon =  Daikon or {
    SandboxOptionsSyncing = {

    },
    Commands = {

    },
    CommandHandlers ={

    }
}
return Daikon
#

Will they conflict somehow?

bronze yoke
#

no

#

it's not really modular if you use a global table though

#

well it is but it sort of misses the point

#

oh wait, yes

#

these do conflict 😅

keen silo
bronze yoke
#

if you do it like```lua
Daikon = Daikon or {}
Daikon.SandboxOptionsSyncing = {}

#

but if you define the table's contents using the or statement, if it already exists nothing will be added

sour island
#

It will conflict in that one won't be accessible?

tardy wren
#

One will be overwritten

sour island
#

Not overwritten - never used

bronze yoke
#

not written in the first place

sour island
#

First come first use