#mod_development

1 messages · Page 147 of 1

faint jewel
#

without anything outside affecting it.

bronze yoke
#

parts can have an update function attached

#

like the oninit oninstall etc stuff

faint jewel
#

I am trying to make a visible trunk

#

is there a "onputitemincontainer"

#

or something similar

faint jewel
#

hmmmm Events.OnContainerUpdate.Add

#

how do i get the vehicle the container is in?

faint jewel
#

OnContainerUpdate and OnFillContainer neither one fires when adding stuff to a truckbedopen

faint jewel
#

GRRRRRR

fast galleon
#

depends what you want to overwrite, same file path will replace the whole file.

ancient grail
#

now im really glitching haha

fast galleon
#

For me this is the first game I mod. But I've been using mods always. It would have been cool if somebody introduced me to modding earlier, but it took a broken game to start me modding.

#

Or rather all the broken mods on workshop, I've been patching stuff constantly.

faint jewel
#

plowing trailer the you turn on and off with the headlights. lol

nova dome
#

sounds like a realistic survivor wiring job

faint jewel
#

it just makes it super easy to turn on and off.

hot void
#

ah looks like the modeling channel dead or peeps got no idea what\s going on

#

i need help with this

#

idk if its uv issue or weights

#

but it doesn't do this in blinder

fading horizon
#

How would I go about adding a counter for how many times an item has been used?

    {
     DisplayCategory     =  Vape,
    Weight               =  0.05,
    CantBeConsolided     =  TRUE,
    UseWhileEquipped     =  FALSE,
    Type                 =  Drainable,
    DisplayName          =  GnomeBar (Rainbow Blast),
    TimesHit             =  0,
    }```

I set a custom parameter like so in the item definition script

Then in my lua I have the following
```lua
local vapeFlavorDelta = item:getModData().Flavor 

How do I change that value? there's no setModData function or anything that I could find

#

or is there a better way to go about this entirely

sour island
#

The modData once gotten is a table that you can modify as is

#

but for an items condition or uses - there's a vanilla function for that

#

Oh you already have it as drainable

fading horizon
#

basically i want this vape item to be a drainable that works off a battery

#

so it can be recharged

#

but i want to limit it to 3 recharges

sour island
#

ah

fading horizon
#

so basically 1 battery will last 20 uses

#

but the vape in total has 60 uses of "flavor"

#

so i'm trying to make a flavor counter for each item but i'm struggling trying to figure out how to assign this new parameter to each item

sour island
#

You could add the counter to the tooltip

#

but all you have to do is grab the item's modData and modify the table

#

it's connected to the item via reference and saves with it

#
local vapeFlavorDelta = item:getModData().Flavor 
vapeFlavorDelta = vapeFlavorDelta + 1
upper mason
#

ModData is the way to assign custom variables to modded items?

sour island
#

Simply, yes. It's a Lua table for the object. You can store anything but references.

fading horizon
#

but will this modify that value for all items of that type or just that specific item?

sour island
#

modData is per item specific

#

it's also something that exists for all isoObjects

#

although behavior changes for certain types

#

If you're setting it up you have to define it first though

#
item:getModData().Flavor = item:getModData().Flavor or 0
local vapeFlavorDelta = item:getModData().Flavor 
vapeFlavorDelta = vapeFlavorDelta + 1
#

Otherwise 'vapeFlavorDelta' is nil

fading horizon
#
local function getVapeFlavorDelta(item)
    item:getModData().Flavor = item:getModData().Flavor or 0
    local vapeFlavorDelta = item:getModData().Flavor 
    vapeFlavorDelta = vapeFlavorDelta + 1
    
    print(vapeFlavorDelta)
    return vapeFlavorDelta
end```
#

it works once, but doesn't increase more than one time for some reason

sour island
#

Where are you calling it?

fading horizon
#

local op2 = context:insertOptionAfter("Favorite","Check Flavor", isVape, getVapeFlavorDelta)

#

just a context menu option

#

so i could call it / check it quickly

#

which that is called by

#
local function OnFillInventoryObjectContextMenu(player, context, items) --# When an inventory item context menu is opened
    local playerObj = getSpecificPlayer(player);
    items = ISInventoryPane.getActualItems(items);
    local isVape = nil
    for _, item in ipairs(items) do                      
        if item:getDisplayCategory() == "Vape" then
            isVape = item;
            break
        end
    end

#
if isVape ~= nil then
  local op2 = context:insertOptionAfter("Favorite","Check Flavor", isVape, getVapeFlavorDelta)
end
sour island
#

Not sure why it's locking at 1

#

Also if you want it to count down you need to make that a - 1

#

You dont have something capping it to 60 do you?

#

Kind of odd it is at 60 to begin with

fading horizon
#

i set it at 60 in the item definition script

#

the + or - didn't matter currently, I was just trying to get a counter working in general

sour island
#

Where is 60 defined?

fading horizon
#
    {
    DisplayCategory   = Vape,
    Weight            = 0.05,
    CantBeConsolided  = TRUE,

    IsTelevision      = FALSE,
    IsHighTier        = FALSE,
    NoTransmit        = TRUE,
    DisappearOnUse    = FALSE,
    Flavor            = 60,

    }```
sour island
#

Those get consolidated into the modData automatically?

fading horizon
#

its able to grab it at least once, so I guess so

#

I saw this technique by searching in the discord here for "custom parameter" and saw someone doing this method

#

theirs was a static, unchanging value ; however

sour island
#

Could be related - I wasn't aware such a feature exsisted

#

Does not seem like it would logically keep referring to the script in this case though

fading horizon
#

hmmm

sour island
#
local function getVapeFlavorDelta(item)
    local modData = item:getModData()
    modData.Flavor = (modData.Flavor or 60) - 1
---since it's being added via script you can get rid of the '( or 60)'
    print(vapeFlavorDelta)
    return vapeFlavorDelta
end
#

You could try getting rid of the local var - it could have been interfering with it as a reference now that I think about it

#

Yeah that is what it is - sorry just woke up

#

You can make locals into tables and retain references but if you localize other stuff it breaks the reference connection

#

Also changed my snippet to my prefered way to handle modData for the sake of readability I try to cut down on repeated calls

hot void
fading horizon
#

this is going to make my mod so much cooler i think

weak sierra
#

any idea what changed? i've seen other mods with this issue, trouble getting tow points to be fixed

#

@sinful vessel has a huge military semi that is stuck with that state

sour island
#

Could it be related to the wheel placement?

red tiger
#

Good morning.

#

Apart from the two questions I've received, I haven't thought about ZedScript & PZ in the past 10 ish days.

#

Haven't had a burnout this bad in years.

#

=/

frank elbow
#

Hope the coder's block wears off soon

tardy wren
#

Is there an event that runs before the game really starts, but after OnInitGlobalModData?

#

Gonna do lua patching and I want to make it run after other patches

bronze yoke
#

like half of the events in the game

#

ongametimeloaded is a random one that comes to mind

tardy wren
#

Okay.

#

I hope modifying items then won't muddle anything

red tiger
#

I already have a lot of updates for the extension. I simply haven't written the changelog and updated it.

faint jewel
red tiger
#

Sad to see so many people confused with scripting and how to do it.

#

A lot of confusing and winding scripts, often full of deprecated and non-functioning properties.

tardy wren
#

Question

#

If I add some mod data to an item

#

Do I need to transmit it to the server afterwards?

bronze yoke
#

no

tardy wren
#

really? To an item instance?

bronze yoke
#

they're synchronised automatically

tardy wren
#

Are you sure

bronze yoke
#

yes

tardy wren
#

Okay

#

That makes my job easier

#

to get how much of an item is left, I call "getUsedDelta", right?

wet sandal
#

On the subject mod data, what about IsoObjects?

tardy wren
#

what about them?

wet sandal
#

If I add some mod data to an IsoObject
Do I need to transmit it to the server afterwards?

bronze yoke
#

yes

#

players and items are the only exceptions, you usually have to

#

with transmitModData()

tardy wren
#

I see.

bronze yoke
#

annoyingly you need to do this even if you only need the moddata on the client

tardy wren
#

Otherwise it won't get saved?

bronze yoke
#

transmitModData overwrites the moddata for everyone, so if you don't transmit yours it'll get overridden eventually

tardy wren
#

oh god

bronze yoke
#

it kind of seems like there's a race condition there but i've never seen it come up as an issue so i might be wrong about that part

tardy wren
#

It was only added in like... B41.51?

bronze yoke
#

object moddata has existed longer than the patchnotes go, global moddata was recent though

tardy wren
#

Oh I see

#

so the global is new

#

this is how I use it, right?
savedUses = items:get(0):getModData().EasyPackingRemainingUses

#

assuming items is an array of size of 1

bronze yoke
#

yeah

tardy wren
#

To check if the item has mod data I want...

#

hasModData("Tablename")?

bronze yoke
#

no, hasmoddata is pretty much useless

#

essentially all it does is check if the item has ever had getModData() called before

tardy wren
#

oh

#

So I just... try to read it, and check if it's nil afterwards?

bronze yoke
#

yeah

tardy wren
#

Hmm

#

An empty array isn't nil, right?

bronze yoke
#

it isn't

tardy wren
#

then that's a slight issue

#

How do I make sure that there's actually some mod data loaded...

#

Though I might be overthinking it

#

Working for someone else is hard man, you don't know all the use cases

fast galleon
#

modData is like a Lua a table, it's not ArrayList

tardy wren
#

I was about to ask what type of array is it

#

lua or java

bronze yoke
#

the moddata table is created if it doesn't exist, which is why hasmoddata doesn't seem very useful

tardy wren
#

...Oh fuck, that means I have to work on both types from a single loop

fast galleon
#

I think you only need the getModData().myVar here, unless you also want to check other things?

tardy wren
#

no no, I need to, uh...

#

I save some stuff to mod data, then load it back onto the items

#

Packing recipes

#

Can I... Even loop over the result?

#

Or is the result actually a single item?

fast galleon
#

Result is a single item.

tardy wren
#

Ag

#

So if it's a drainable

fast galleon
#

If you have more than one, they are added in the craft action.

tardy wren
#

I meant that more than one of an item type

#

As in, my result is 5 planks, or 5 rolls of tape

#

How do I handle that

fast galleon
#

Which part should be modular?

tardy wren
#

Uh... what?

#

Please elaborate

fast galleon
#

Is the plan to create those manually, or do you set that in the recipe result?

tardy wren
#

Oh, the result of the recipe is the duct tape

#

if I was creating those manually, then that would be less problem... I think

fast galleon
#

and the problem is to add data to them or make them 5?

tardy wren
#

I have data

#

Result is 5 items

#

I use data, to alter those 5 items

#

my data is 5 numbers

#

Can I? if yes, how

fast galleon
#

yeah check the craft action if there's a way to do that. Otherwise spawn them manually with the oncreate.

nova dome
#

what are the reasons to use ModData instead of your own file?

tardy wren
nova dome
#

can you not do that if you save things in other ways?

fast galleon
tardy wren
tardy wren
nova dome
#

I currently have the problem that I got things in moddata I would like to read before moddata initializes

#

but it's like a cross compatibility thing between mods or what?

tardy wren
#

Not even. It's data you need to save for later use, by your own mod or otherwise

nova dome
#

do you mean others as in other players?

#

or the server

tardy wren
#

yes

#

Multiplayer

bronze yoke
#

you can save to your own files if you want but global moddata is basically the game's standard api for that

#

and object moddata is just a million times more convenient than anything you could do with your own formats

nova dome
#

yeah. i will have to check whether in multiplayer the moddata initialises earlier, maybe it'll still be good for that purpose. otherwise I dunno what kind of workaround I should do :-D

bronze yoke
#

what are you trying to do? moddata initialises very early

#

i've run into it myself but it was a very niche use

nova dome
#

need it at character creation

#

at least in sp it's not loaded until after a bunch of textures and radio things when loading the world

bronze yoke
#

yeah, it won't load until the world starts loading

tardy wren
#

oh nevermind, I'm dumb

#

I called HasModData on an ArrayLisyt

#

Right... So, at the moment that OnCreate is called, only a single item exists as a result

faint jewel
#

OKay so i'm STILL working on the issue from last night.

winter thunder
#

Hey, anyone know the different ways to have sounds play? I want to add more options for server owners to play audio for events, but I’m not super well versed with the audio modding aspects

winter thunder
tardy wren
faint jewel
#

Events.OnContainerUpdate.Add(Seeder_Fill_update)

#

this doesn't work with truck beds

bronze yoke
tardy wren
#

For clarity, I create multiple of the same item

#

I cannot seem to be able to do that...

bronze yoke
#

probably because of the audio engine switch, there's a lot of redundant methods and methods that just lie about what they do

#

(e.g. playsoundlooped doesn't loop the sound or do anything at all, it just calls playsound)

tardy wren
#

Beyond then reading the player's inventory and applying the changes there...

winter thunder
tardy wren
#

But no, that wouldn't work

winter thunder
#

It’s roleplay descriptors on the workshop, I’m on mobile rn but I’ll try and get a link rq

#

Got it

tardy wren
#

neat, I already have it

winter thunder
#

Oh! Awesome :)

#

The file has to do with the pinned notes, so you can see kinda what I did there. I could have done better now that I know more 😂 but you can basically just tell it to change each instance of item you add to the inventory

tardy wren
#

Oh, you seem to have misunderstood me

winter thunder
#

Oh?

tardy wren
#

You're creating a paper and a knife

#

I am creating two knives

#

and I need to break both

winter thunder
#

You should be able to do that, just do the same thing 2x times? Basically add an item, and set its durability to 0, and repeat

tardy wren
#

Issue

#

I'm adding the items in the result?

#

and the result is only a single item when that function is called. No other items exist at that point in time

winter thunder
#

You can only ever have 1 resulting item, but you can modify that too (I do that in my mod too), and you can have it add the additional knife on creation of the recipe, and set that durability too

tardy wren
#

Yes

#

The result is a single item in code. However, if the recipe creates multiples of that item, those multiples are made after the OnCreate completes

#

They even note that as a bug in the code

bronze yoke
#

it's not especially useful to modders, it's mostly just used to dirty the inventory ui, it usually doesn't even pass the container that 'updated'

winter thunder
tardy wren
faint jewel
#

well i need a "OnContainerInentoryChange"

#

we have something like that?

winter thunder
#

Gotcha, that seems like the best way imo. The recipe code has some jank, but I’m hopeful that the new revisions for the next update will be better for all of us to make some great stuff haha

tardy wren
#

This however, creates an incompatibilty

#

Since this is a mod update, items may not have had the mod data

#

I guess a table of hard-coded values will have to do

winter thunder
#

Yeah, you could also check for the data at some point, and if it isn’t there, add it in to the items. Could do it “OnTest” for the recipes

tardy wren
#

These are packing recipes

#

The function may be used on a recipe unpacking 4,5,6 or more items

#

I only know based on the amount of numbers stored in the mod data

#

or the result...

Or the hard-coded list I need to make

#

How do I... remove the result from the player's inventory?

#

oh

#

I think I found it

winter thunder
#

Bc you can edit the result on create, you should be able to do it there. Idk the lua for that off hand tho

tardy wren
#

My plan is to yeet the result and just add whatever I want

torn igloo
#

What is the ISAction that responsible for swapping bag front to back or part?

winter thunder
tardy wren
#

Well, this is awkward

#

Apparently when OnCreate is called, the Drainables that went into the crafting are already drained

#

Which makes sense, but it makes things harder for me

#

but if they're set to "destroy", then they aren't used up by that time

#

Okay, now to figure out why my result doesn't get deleted lmao

#

Apparently there's a field in the script that does that for me, which is... convenient

torn igloo
fast galleon
faint jewel
#

@bronze yoke so how does onFillContainer work?

#

i'm guessing when the game fills it with loot?

bronze yoke
#

yeah

faint jewel
#

well that sucks as well lol

#

i just want a listener for when a cars trunk has and item put in or taken out.

bronze yoke
#

you could probably just hook the inventory transfer action

faint jewel
#

Oh??? Any examples?

#

Or something I can look for?

tribal osprey
#

Hi Folks! axe Is there a C# project for PZ mods on GitHub or anywhere? I code C# and know some unity

bronze yoke
#

i don't think there's ever been anything like that

tribal osprey
#

Ok, whats the best way to start modding? Apologies for the super open question

#

What do you use for an IDE? Is there youtube channel on this or wiki?

bronze yoke
#

i use intellij idea, but visual studio code is pretty popular too

sour island
faint jewel
#

but how i do that?

minor snow
#

Wasn't there modding guide or something?

ancient grail
#

Check threads

faint jewel
#

what red name do I have to hump to get "OnContainerInventoryChange" added as an event?

upper mason
bronze yoke
#

not quite, it's a reference library of the game's java for modders to refer to

tardy wren
#

Can I somehow refer to a recipe that was calling the OnCreate function?

#

Generic OnCreate

bronze yoke
#

it might pass the recipe object

#

oncreate gets passed a whole bunch of crazy stuff everyone either doesn't know about or ignores

tardy wren
#

Ah, then no...

#

It passes the list of items going in, the result, the specific selected item, and the item held in the right and the left hand

#

Not the recipe that went in... Drat

left field
#

Hi, there's already an mod about electronics or a research tree under development?

nova dome
#

Does anyone know of a low memory map option for mod development to run dedicated on the same machine? It seems 16BG of ram can only do so much

fading horizon
#
   {
     keep GnomeBarRB,

     Result:Battery,
     Time:30,
     OnTest:Recipe.OnTest.VapeBatteryRemoval,
     OnCreate:Recipe.OnCreate.VapeBatteryRemoval,
     StopOnWalk:false,
     AllowOnlyOne:true,
     Prop1:Battery,
     Prop2:Source=1,
   }```
#

is there a way to remove the "all" option?

#

AllowOnlyOne:true, didn't do the trick

#

that's on a single item, not a stack

fast galleon
#

drainbales have uses, that's probably what it's refering to.

fresh ice
fading horizon
#
  1. itemType=Count,

Specifies the type of item and the quantity of the item that will be used. If the item is Drainable, then the uses of the item are used. If only one item is needed, then only the item type can be specified.

#

it is because of the drainable

#

this is what i got from the wiki

#

i just don't know if there's a way around that

faint jewel
#

when you OnExitVehicle how do you get the vehicle you are exiting?

fading horizon
#

for anyone who searches for something similar in the future

nova dome
# tribal osprey What do you use for an IDE? Is there youtube channel on this or wiki?

vscode is nice, am doing my first mod by forking another one. if you like a video format I found this one to be a pretty nice one, covering the whole process in order. https://youtu.be/-yrmCAwzTbY

1:11 Step 1 - Know your file locations
4:06 Step 2 - Storyboard your ideas out
9:03 Step 3 - Get your files from the game or other mods
11:47 Step 4 - Build your mod files
1:01:54 Step 5 - Create the textures (mislabeled in the video, oops)
1:19:45 Step 6 - Put your mod files in the right structure
1:30:37 Step 7 - Test your mod (please back up ...

▶ Play video
ancient grail
#

Posted on the nod resource thread

tardy wren
faint jewel
#

this .... IS the official discord?

tardy wren
#

yes?

faint jewel
cosmic condor
#

there are so many discords related to pz mod developments. doesn't hurt to be specific

ancient grail
#

Oh sorry mybad

#

Youre right im stupid

#

Good catch

fading horizon
#

i finally got it all to work. Now each vape has separate flavor and battery level mechanics

cosmic condor
fading horizon
#

ty each flavor has its own color

cosmic condor
#

would be great if you could reduce the size of WorldItems textures

nova dome
#

if you're testing a mod for multiplayer on a steam dedicated server is the only way to do it via uploading the mod to the workshop every update?

ancient grail
fading horizon
#

i feel like instead of a % for flavor remaining it should be one of those progress bars like vanilla

#

because realistically you don't know the exact value

#

you just guess based on if it tastes burnt or not

ancient grail
#

Thats how most modder test MP

nova dome
#

ty

fast galleon
#

I'm thinking of reordering parts in the ISVehiclemechanics self.bodyworklist, are there mods that interact with this I should be aware of for compatibility reasons?

plush heath
#

Hi can someone help me with how to upload a mod? I have custom textures in my game files that I wanted to upload but idk how

pastel glen
plush heath
#

Ah oki thanks I’ll try that out

upper mason
#

Can I reload mod from inside game without relaunching whole game?

neon bronze
#

You can reload lua

upper mason
neon bronze
#

Or if you are in sp just quit to main menu and continue

neon bronze
upper mason
neon bronze
#

Yes

upper mason
#

Thanks!

bleak current
#

Heyyyyyo, is there some way to get player list of server knowing its ip and port ??? (Doing it from code ofc)

ancient grail
#

Steam masks it somehow
Which is why you can see the same person login but then the ip is inconsistent

#

Tho im aware of dynamic ip and such but still it doesnt seem thats the reason

upper mason
frank lintel
#

MAC ID ftw

odd fjord
#

do you guys know of an item mod that does something if the item gets added to the inventory of a player?

#

trying to create that effect but to no avail. hoping to find something i can use as a reference

bleak current
#

Knowing current IP of SERVER not player, I think that's obvious enough. for your knowledge tho, ip addresses are inconsistent for players for two reasons, one dynamic public ipv4 address allocation, and in case of using steam servers to connect to the game server (steam relay servers)

tiny wolf
#

Hello everybody 🙂 i hope you're fine !
Trying to find to command to get a player foodsickness
Like getBodyDamage but to increase foodsickness
And i don't find it into wiki
Do somebody know what I could use please ?

bleak current
upper mason
frank lintel
#

its even more fun when you only got IP6

upper mason
frank lintel
#

I can tell you a model that sure does cuz its what I use... a Nighthawk :P

#

that and my motorola gateway

upper mason
frank lintel
#

my ISP would give me one for a lovely monthly fee but I was like f that.

humble oriole
#

Hey, I'm not seeing a way to get an ambient temp for a square. I can get the current world temp, but I'm looking to get the temp of areas affected by a stove or other heat source

frank elbow
humble oriole
#

Yea, I think getAirTemperatureForSquare

#

Didn't see that one

#

the "airtemp" is what threw me

frank elbow
#

I wouldn't have even thought to check ClimateManager so I can't blame you

humble oriole
#

Yea, that's where I first looked, then when down the ClimateValues hole, then when and looked at the square functions, then the isoObject I'm working with is a container so I went that route, and then I went over to rooms to see if there was a room temp

#

ahha, figured I'd just ask at that point

#

perfect thanks @frank elbow

winter thunder
#

Anyone able to explain to me / provide an example of how to modify existing item without overwriting the initial script?

Basically I want to create a patch for an existing mod, but I want to edit the values of the items after the fact. I am fairly certain I would use the doParam Function, but I wanna be certain before I jump the gun on it

bronze yoke
#
local item = ScriptManager.instance:getItem("Base.Whatever")
if item then
    item:DoParam("Weight = 5")
end
winter thunder
#

Thank you! When should i trigger that? If I need to

bronze yoke
#

it's fine to leave it outside of a function as long as you don't need sandbox options

winter thunder
#

Nah, that should be fine! Is there a good way to edit a lot of items? Or should I just duplicate that code for each

bronze yoke
#

you can make it into a function to simplify things, and of course you can use loops

winter thunder
#

Like, make a table with the items and the values to change.

IE,

  1 = {
  itemNameVar = "xyz"
  itemNewWeight = x
      }
   
2 = {
    }

3 = {
    }
  etc..etc
}```

Then just run a loop using the variables from the table, using that data in the one function
#

???

winter thunder
tiny wolf
#

Do someone know where we can find the "Zombie proximity infection" vanilla script into the game files please ? 🙂

willow crest
#

Go ahead, do as you please

humble oriole
#

Hey @bronze yoke do you know if ClimateManager.getAirTemperatureForSquare is client only?

#

if I run it in my code and print it, it returns the global temp, if I run it in game it prints the ambient temp.

bronze yoke
#

it doesn't look like it's intentionally client only

#

if the square is indoors and power is on you would expect to get room temperature if that's what you're getting

humble oriole
#

well, I'm trying to see if I can get the temp of the square to reflect there being a campfire or other heat source near it

#

I also tried running the code from shared, but get the same result. The code being run from the mod returns the global temp, but if I do it from the lua console on the same coords it gives me the adjusted temp as it should.

#

which leads me to believe that the server doesn't know what the squares adjusted temp is, which really sucks 😦

bronze yoke
#

it doesn't feel like anything in this should be client only

#

you should check if the square exists

#

it'll return the global temperature if it doesn't

humble oriole
#
function SBioGasSystem.getModifiedOutput(square)
    local cutOffTemp = SandboxVars.BioGas.cutOffTemp
    local minTemp = SandboxVars.BioGas.minTemp
    local maxTemp = SandboxVars.BioGas.maxTemp

    local currentAmbientTemp = round(getClimateManager():getAirTemperatureForSquare(square))
    print("Square X: ",square:getX())
    print("Square Y: ",square:getY())
    print("Temps: ",currentAmbientTemp)```
bronze yoke
#

you might be grabbing it wrong

#

hmm if getX isn't causing issues it must

humble oriole
#

and that's from in game

bronze yoke
humble oriole
upper mason
#

Skill books do not unlock recipes, only recipe books correct?

#

I.e. skill level won't unlock new recipes as well, correct?

humble oriole
#

yea

upper mason
# humble oriole yea

Is there any way to make specific recipe book finished reading on start, or no need to bother and just add recipes to profession directly?

humble oriole
#

I think most people do it to the profession directly

upper mason
humble oriole
#

correct

humble oriole
upper mason
#

I don't see "NightOwl" implemented anywhere in game's LUA. Do I need to decompile java or something?

bronze yoke
#

it's implemented in java

upper mason
bronze yoke
#

you can

#

a lot of the vanilla stuff is java for performance or convenience, most things are still doable from lua

red tiger
#

Good afternoon.

fading horizon
#

Good afternoon!

left field
#

Hi, there some mod under develop about electronics, I would like to make one, but if there are some under develop, I must help in the development

frank elbow
left field
frank elbow
#

Gotcha, not me then—might do something with computers, but not planning on it anytime soon

#

Sounds interesting, though

primal remnant
#

Hey guys, general question: .obj files or maybe .X files have a model and a texture. I exported a blender model in .fbx but I dont see a .mtl file or anything like that.

The code looks like this:

model LargeSaltContainer
{
mesh = WorldItems/LargeSaltContainer,
texture = WorldItems/LargeSaltContainer, <-------- Coders block occurs here
scale = 0.1,
}

item LargeSaltContainer
{
Weight = 0.5,
Type = Normal,
DisplayName = Large Salt,
Icon = LargeSaltIcon,
SurvivalGear = TRUE,
WorldStaticModel = LargeSaltContainer,

}

But my question is WHAT DO I PUT IN THE TEXTURE PATH? Will this code work as is because the material is part of the .fbx file or do I need to rework how I write this code? Thanks in advance.

red tiger
#

That is also script, not code. ;)

#

AFAIK the mesh and texture are paths from a folder in media.. one sec.

#
Specifies the model file to be used. File must be located in "media\models_X". Write path to filename without extension. Example for file "media\models_X\Burger.fbx":

mesh = Burger,
#
Sets the texture for model. File must be located in "media\textures". Write path to filename without extension. Example for file "media\textures\BurgerTex.png":

texture = BurgerTex,
#

@primal remnant

faint jewel
quiet matrix
#

running into this problem with making custom perks where, when you remove a trait from your chosen traits, it duplicates the trait. this is happening with both positive and negative ones, base traits and modded ones. what could be making this happen?

faint jewel
#

le sigh

ancient grail
#

Im not at home skiz i could have helped with this 😦

faint jewel
#

if i can get this working my trailers are don, just atm it leaves the water spraying.

#
local function MowerWater_OnExitVehicle(character)
    local vehicle = character:getVehicle()
    if vehicle == nil then 
        print("No Vehicle")
        return 
    end
end

it always says no vehicle 😦

fading horizon
#

oml

#

stuart little mod got front page

#

😭

faint jewel
#

GetLastVehicle() would be GREAT

bronze yoke
#

onexitvehicle is a lua event so just hook the function that calls it if you need to do something before it

pastel glen
#

how do i change all footstep SFX to 1 or 2 custom sounds? can someone help me with this? is it possible?

faint jewel
#

wassat?

#

hmmmm

#

what happens if there are multiple vehicles of the same script?

fast galleon
#

just add if not script then return vehicle or whatever

fast galleon
faint jewel
#

LOL

faint jewel
#

got one like "OnContainerInventoryChange" ?

#

i can work with that other than it's being a pain lol.

#
function GetLastVehicle(scriptName)
    local allVehicles = getCell():getVehicles()
    local test
    for i = allVehicles:size() - 1, 0, -1 do
        test = allVehicles:get(i)
        >>>print(test:getScriptName())
        if scriptName == test:getScriptName() then
            return test
        end
    end
end
    local vehicle = GetLastVehicle("Base.MowerWater_trailer");
    if vehicle == nil then 
        print("No Vehicle")
        return 
    end
``` vehicle is always nil.
#

but if i add a print to show all the tests.

#

i SEE ir there

#

so why does it NOT return my vehicle?

#

😦

bronze yoke
#

capitalisation error

#

"trailer" ~= "Trailer"

faint jewel
#

HAH! it would also help.... if i was getting the mower instead of the trailer XD

#

but thank you albion and poultrygeist!

#

that bug is fixed though!

#

all i need now is how to tell if a vehicles trunk contents have changed.

red tiger
#

Nothing says fun like being up all night to catch up on IRL work.

primal remnant
#

Are there any good tutorials on reading the lua files for PZ? I get the gist of what's happening, but my syntax skills are a lacking and I'm not sure where to find particular function/method names. Just wondering how those who are skilled in PZ Lua got their start.

Also @red tiger gotta burn the candle at both ends to keep warm.

red tiger
#

Try to learn modules and use this approach.

primal remnant
#

I was afraid of that. I'm trying to figure out drainables, but the closest I've found is combining water bottles. Kinda messy to read.

red tiger
#

Drainable items are part of the scripting data format which is not Lua.

#

Any .txt file in media/scripts/ is scripts.

#

They do affect some Lua function executions though.

#

I can't tell you anything specific to scripting or doing what you're doing. I only know what I do from past experience in Lua and the current projects I have right now to make scripting in PZ much easier.

#

This is what I'm working on / toward:

reef karma
#

Hey @ Poltergeist, are you still working on the solar panel mod by any chance?

red tiger
#

People are generally so lost with scripting...

#

It's such a headache to anyone fresh to modding PZ.

bronze yoke
#

oh, decompile the java

#

everyone seems scared of reading the java but you'll be solving the puzzle with half the pieces if you don't

red tiger
#

I believe that the goal should be working towards making this not necessary to mod.

bronze yoke
#

yeah, most of the time i'm only reading the java because there's no other indication of what most methods actually do

reef karma
#

Fair enough, I assume radius is 20 for power delivery. Any way to change that to be configurable (I would really like to increase it)? I don't really wanna request an entire mod update just or that but I figure I should ask before I go digging in myself (and probably fail at it)

quiet matrix
fast galleon
red tiger
#

Heheh

#

You hit the nail on the head though if you were trying to state the main goal of PipeWrench.

bronze yoke
reef karma
bronze yoke
#

i've seen this issue before, i think i even solved it in my own mods, but i don't remember what the issue was really, but i was using that previously and don't anymore

quiet matrix
# bronze yoke does your trait use profession framework?

i am 99% sure (it was made by one of my team’s members) it is based on base game coding, not the prof framework, as profession framework was preventing our custom occupations from appearing despite no errors in code format

red tiger
#

I think that it's going to get silly in here when I get my VSCode extension feature-complete.

quiet matrix
#

upon loading in, the traits are fine. but removing them from one’s build causes duplication

faint jewel
#

well if anyone can figure out how to tell when items are being added to or removes from a vehicle trunk that would be AMAZING.

red tiger
bronze yoke
#

just hook the inventory transfer action

#

i don't think they can really get in or out any other way

faint jewel
#

me too

bronze yoke
#

oh they can fall out actually

faint jewel
#

i can't find an invetory transfer action lol

quiet matrix
#

hasn’t udderlyevelynn made a patch to prevent items from falling out?

#

could you see what she has done and see if there is an inventory transfer action?

faint jewel
bronze yoke
#

i mean the timed action

#

it's not java

faint jewel
#

i can't find the action lol

red tiger
#

Find in Files

faint jewel
#

what's the name

#

ISInventoryTransferAction

#

?

bronze yoke
#

i'm not at my computer but something like that

primal remnant
bronze yoke
faint jewel
#
function Seeder_Fill_update(container)
    print("Updating a Container")
    local container = container:getContainer();
    if container then
        local vehicle = container:getParent()
        if vehicle ~= nil then
            local Trailer = playerobj:getVehicle():getVehicleTowing()
            local bedpart = Trailer:getPartById("TruckBed")
            local truckbedcontainer = bedpart:getItemContainer()
            bedpart:repair()
            bedpart:setContainerCapacity(25)

            local CurrentAmount = bedpart:getContainerContentAmount()*4

            print("Current % full = " .. CurrentAmount .. "%")
        end
    end 
end

Events.OnContainerUpdate.Add(Seeder_Fill_update)
#

this si what i was TRYING to do.

#

but that on event is what i am needing 😦

red tiger
#

It's too bad that I don't have some gin nearby.

#

Get slammed on some gin & tonic and go for a 17+ hour coding jam.

faint jewel
#

still aint code jammed my menu to completion., lol

faint jewel
#

das right

fast galleon
faint jewel
#

ffs.

#

when you remove items via code it doesn't update the container.

#

and i need to to UPDATE

upper mason
# sour island also this: https://github.com/Konijima/PZ-Libraries

It fails for me at id 'io.pzstorm.capsid' version '0.4.2' part. No Load Gradle Changes appear.
EDIT: seems like it happened because I was using standalone version of IDE, and not installed one.
EDIT #2: it also seems that I have to name project as capsid to make it work.

upper mason
# sour island also this: https://github.com/Konijima/PZ-Libraries

Now I'm stuck at this part: Unable to find method ''org.gradle.api.tasks.JavaExec io.pzstorm.capsid.zomboid.task.ZomboidVersionTask.setMain(java.lang.String)'' 'org.gradle.api.tasks.JavaExec io.pzstorm.capsid.zomboid.task.ZomboidVersionTask.setMain(java.lang.String)'Do I need a specific version of IDE as well?

upper mason
#

Since I can't use tutorial to get all lua APIs, question to the modding community: where I get all lua APIs on my own?

red tiger
#

So basically most Lua code is invocated via events.

#

UI has exceptions to this rule but it's technical.

#

You'll need an IDE or rich-text environment to search through the lua folder in PZ's media folder for existing Lua code.

upper mason
bronze yoke
#

there's a page dedicated to them on the wiki

upper mason
#

41.65, not the latest one.

upper mason
red tiger
bronze yoke
#

there are a couple new events, and some of the parameters on the wiki are outdated or wrong

red tiger
#

lol

bronze yoke
#

i sent a pr to correct the ones i've noticed ages back (since those pages are generated) but it hasn't been noticed

red tiger
#

Forward that as an issue for PipeWrench-Events

#

I'll fix it for my stuff.

bronze yoke
#

i'll go find my documentation on one of the new events and do that tomorrow

red tiger
#

Thanks.

#

I don't know what the wiki community is doing but I'm keeping my stuff up to date.

#

Were you asking for PZ Wiki to fix?

#

Or somewhere else?

bronze yoke
#

yeah, the wiki

red tiger
#

I can edit the wiki lol

#

I'm probably going to need to go into the wiki at some point and start cleaning & clarifying some stuff.

upper mason
# red tiger Haven't heard of any new events added since.

Yesterday there were talk that all perk's features (for example, Night Owl) can be implemented in LUA. I'm trying to understand structure and figure how to do it. As reference I'm looking at Insurgent profession mod and how traits are handled and see that everything handled via getModData() and events. Hence, I wanted to know all Lua APIs available for modding: events, and parameters that can be called (for example: from attacker, target, weapon & etc.) such as :setHealth() or .hunger or something else.

red tiger
#

Sorry. I'm a documenter / tools developer. (Not a dev for PZ)

#

I don't know technical stuff in detail for helping people with their mods.

nova dome
#

hmh because of how selecting traits normally works I guess there is no easy way to check for mutual exclusives within a list of traits? as in whether an existing player's selection of traits is valid

red tiger
#

I am making tools to make your nightmare a simple gassy daydream.

bronze yoke
red tiger
#

And if you want to be a freak like me and code in TypeScript, PipeWrench is a set of compiled typings for PZ that is used to compile to Lua.

bronze yoke
#

yeah, that thing is pretty old and took a bit of messing around for me to get it to work too

#

i didn't encounter your specific issues though so i can't help you there

upper mason
bronze yoke
#

i don't really remember, it was a decent while ago that i did it

#

i remember having to mess with the memory allocation because i kept getting out of memory errors, but there were definitely other issues i don't remember

upper mason
bronze yoke
#

no, i use the latest

red tiger
#

It's fernflower.

#

I don't typically decompile the entire game to look at and modify stuff.

#

Zip up all the class files into a Jar archive, import it in an IDEA workspace and then double-click the .class files.

upper mason
red tiger
#

And a MANIFEST.

#

And certs if needed.

upper mason
red tiger
upper mason
red tiger
#

JAD also handles constant values better than Fernflower that are above 32767.

red tiger
#

I've used Fernflower since 2010.

upper mason
red tiger
#

I would rather decompile into semi-broken code and fix it, modify it, then recompile it against the code it compiled with.

upper mason
#

Where do I download fernflower from?

red tiger
#

I can have projects spanning 100+ modified Java files doing this.

#

Commenting helps me keep track of every change I make.

red tiger
#

You can use fernflower as a CLI as well.

upper mason
red tiger
upper mason
red tiger
upper mason
upper mason
sour fern
#

I've been using cfr to decompile, although tbf I haven't tried the others

upper mason
lyric turtle
#

I wonder

#

Since minimal display bars shows that it is possible to show customized UI displays for lots of stuff

#

Wouldn't it be plausible to get The Sims UI to display our character's stats and what not?

craggy ruin
#

Hey dudes I don't know if I'm not figuring this out for myself or it does not exist, I want my custom server to have a timer when a player dies in order to respawn. any advice?

upper mason
#

I want to verify something. Basically, when you do target:setHealth(float) you call actual Java function setHealth() from Lua, correct?

frank elbow
frank elbow
upper mason
#

At least this is what it seems from code point of view (as setHealth() is real name of a function from IsoGameCharacter.class).

frank elbow
#

If you're talking about setHealth on a character, yes it calls into Java

#

x:y(...) is not always a Java call, though. It's just Lua syntactic sugar for x.y(x, ...)

upper mason
frank elbow
#

As long as the class is exposed, yeah. With some caveats, though, since you can't call an implementation with parameter types that aren't exposed (as far as I know, anyway)

#

Since it won't be able to resolve the implementation you're trying to call

frosty estuary
#

One question here... if I call getNumActivePlayers() on client side... it will return me just the number of player on the client ( 1 or more if split screen) or it will return the number of all players in a server ?

frank elbow
#

On the client

frosty estuary
#

Thanks

spring wind
#

If I copy code from someone else's mod - Zach and Pookie wrote some good stuff for managing options in Players on Map - is a "Portions shamelessly copied from <link to steam workshop item>" blurb at the top of the file sufficient?

#

My mod isn't related to the map at all, I just like the code they wrote for tying config options to their UI elements and wanted to use it cuz it works well.

frank elbow
#

Does the mod have a section in its description for licensing? The default is usually to ask for permission when copying code outright (I believe that's the default per TIS modding policy, too), but if it's minor it may not matter. No one can very well copyright a method of doing a thing, but since you're just copying it I'd ask (see https://projectzomboid.com/blog/modding-policy)

Hello survivor! Here’s the modding policy for Project Zomboid. Long story short, you can make mods, but must follow the rules below...

spring wind
#

K I Feel good about that. I'm not lifting content and an attribution saying which portions I copied feels right. It's not particularly clever or novel code, I'm just lazy and am a fan of using things that are proven to work.

#

Thanks Omar

craggy ruin
frank elbow
sour fern
#

Personally I made a fork that lets it take a txt file of paths since I'm too lazy to do that every time

visual island
#

could i somehow get the list of all items in the game through lua code? i want to edit some items with a .lua file, without replacing the .txt scripts

#

because i want to change the data of all items provided by a mod, but the mod is updating

red tiger
#

I feel like that is something that'll happen eventually.

#

That scenario of those like it worry me.

sour fern
#

Pretty sure copyright law in most countries is the code itself

#

not it's overall function

#

unless someone wants to patent a mod I think lol

red tiger
sour fern
#

Ah like reporting to steam/indie stone?

#

Well in that case I got no idea

red tiger
#

Yeah it's more to do with bullying / cornering and holding the workshop hostage in a way.

sour fern
#

Frankly if two mods do the same thing I don't think there's an issue

#

Starting an argument over something like that is just petty in my opinion

red tiger
#

Yeah however I wouldn't expect Steam to look into the report to see whether the mod actually does infringe the other.

#

It wouldn't be the first time someone has abused the report feature for workshop to bully another content creator.

sour fern
#

mm that is a fair point

red tiger
#

I bring this up because I think it'll more than likely show up at some point.

#

You are all interesting however I couldn't count the amount of people who I would judge % wise to approach things with other modders here in less than good faith.

#

20 years of modding will teach you that real fast. =)

sour fern
#

Welp you're a lot more experienced than me lol

#

I'm just poking around in the source for now

frank elbow
red tiger
#

People will always try to bend things to see how far they can get away with getting ahead of others. It's my concern over how we handle that going forward.

sour fern
#

Couldn't get capsid to work so now I'm going about trying to do something similar myself

red tiger
sour fern
#

Although somewhat more crudely

sour island
frank elbow
sour fern
#

I actually had the same issue as WarStalker

sour island
#

The guide is pretty thorough -- make sure you click the drop down for images

sour fern
#

Was running JDK 19

red tiger
#

Well we'll eventually see it.

#

Hopefully it won't be a trainwreck.

#

I see more talk about capsid in here everyday.

#

Join the dark side and code in Typescript.

sour fern
#

Eeh, I've already made it my own excuse to try learning reflection by writing a jar to export the exports

#

I've seen your projects

#

pretty cool

red tiger
#

I made my own excuse to write a full-blown reflection mapper with nested generics support.

red tiger
sour fern
#

I'll join the dark side if it has intellisense

#

XD

red tiger
#

It does.

frank elbow
#

Loosely related, I've been strongly considering forking pz-zdoc to handle stuff in a way that works better for me

sour fern
#

How'd you get it workin

red tiger
red tiger
sour fern
#

haha

frank elbow
#

A lot of static members are documented as being methods by pz-zdoc, which is a very slightly inconvenience (because it's easy to fix in the type stubs) but worth fixing

sour fern
#

I also saw your wip zedscript vscode plugin

red tiger
#

My IRL job comes first.

sour fern
#

Had an idea the other day, maybe could write a plugin that lets you do it in json with all it's existing plugins etc, which then compiles into zedscript

#

Fair enough

#

I'm unemployed so I've got time to burn lmao

#

Just graduated in december

red tiger
sour fern
#

been rough

red tiger
#

Language structure and design is something of a thing I dabble with.

sour fern
#

It is interesting yeah

red tiger
#

I'd like to redesign ZedScript from the foundation and then write a compiler to ZedScript.

sour fern
#

More 'interesting' when it's a lesser used thing too

#

like json5 lol

red tiger
#

Json is too unfriendly.

sour fern
#

As a user-configuration thing yeah

red tiger
#

It's a data storage format, not a pneumonic or expressive language.

sour fern
#

that's what yaml is for etc

red tiger
#

Yet Another Markup Language

sour fern
#

sometimes I wonder why they invented pzscript tbh

#

why reinvent the wheel

red tiger
#

I would be adding stronger syntax patterns for properties. Arrays would be defined more programmatically. Vectors would have their own syntax.

#

Inheritance models.

sour fern
#

mm

red tiger
#
item BaseAxe {
  // ...
}

item StoneAxe extends BaseAxe {
  // ...
}
sour fern
#

A way to export/import to CSV would be something I think a lot of people would find useful

#

for balancing/tweaking

#

Although that is a bit of a tangent

red tiger
#

Why individually edit and mentally keep track of 50 items with the same groups of properties when you could edit one or two instead.

sour fern
#

Yeah

red tiger
#

My concept language is to follow some of the same goals as SaSS.

sour fern
#

I always use that in my web projects lol

red tiger
#

A language with more syntax rules isn't a problem if you have a competent IDE / editor with support for it.

frank elbow
red tiger
frank elbow
#

Which I get, I suppose. JSON is the obvious choice to match the structure but it's not great as a language for scripts

red tiger
#

Specifically a C / C++ programmer mindset.

sour fern
#

yeah I suspect it's a 'not broke don't fix it thing'

red tiger
#

It's the "I own and do things myself" way.

frank elbow
#

That would make sense

sour fern
#

I was surprised to see things like blacksmithing/npcs stuff still in the code when I was digging around

red tiger
#

ZedScript is a product of trying to make scripting less cumbersome while not limiting users.

#

I think it's poorly patched up over the years however the idea isn't bad.

#

Good idea implemented rather poorly.

frank elbow
#

Personally the requirement of a trailing comma makes me 😡 but other than that I don't mind it

sour fern
#

Oh damn just found your /java folder in pipewrench

#

you write all that manually?

red tiger
#

ZedScript would be pretty ok if it were documented thoroughly and a lot of needless gotchas & pitfalls resolved.

red tiger
sour fern
#

ah yeah just saw

red tiger
#

Months to a year if manually. 5-10 seconds if automatic.

#

Makes 8 months of development work not seem so bad.

sour fern
#

yup

red tiger
#

It's there for anyone to pick up and use. It has what you'd look for in terms of intellisense and documentation support.

frank elbow
#

I wish Lua's type annotation ecosystem were just a bit more evolved

sour fern
#

The major plugins seem to invent their own yeah

frank elbow
#

It's already pretty nice but at least the annotations I use are missing some essential stuff

#

They're based on EmmyLua

red tiger
#

It's not EmmyLua's fault. It's the language itself.

frank elbow
#

I use LuaCats (used in sumneko's Lua Language Server)

faint jewel
#

are zero turn vehicles possible?

red tiger
#

Prioritizes speed of execution over form.

#

It's the wild-west of scripting.

#

JavaScript ES5 but much worse.

frank elbow
#

The system I use doesn't have complete support for generics which is annoying

red tiger
red tiger
sour fern
#

I think the luacats thing is somewhat backwards compatible with some of emmylua anyway

red tiger
#

=)

frank elbow
#

I wouldn't say Lua is necessarily to blame either, anymore than Python would be to blame if its typing system weren't mature

red tiger
#

That's why PipeWrench-Events plugin allows templated event listeners that shows you what objects are passed for each event.

#

Generics.

sour fern
#

I have a bit of beef with python tbh, mainly that it can teach some bad habits to beginners

frank elbow
#

How so?

sour fern
#

But at the same time it probably stems out of my beef with people not using things for what they were made for

#

like using python to build something that would be better done in C++

frank elbow
#

Definitely going to remind myself to take a peek at that—I considered writing a type stub for the same purpose

frank elbow
#

But figured I'd be better off just using the info from the wiki to generate it, since the event code itself can't very well be used to do so afaik

red tiger
#

Right here.

#

You can write your own events in this plugin.

frank elbow
#

Nice, I'll just process that & make it spit out Lua annotations when I get the chance

red tiger
#

Heh.

frank elbow
frank elbow
#

I prefer Typescript for JS development by far but I'm more comfortable with using Lua in this environment

red tiger
#

I've spent time modding with Lua since 2015 and I chose to move to TS out of sheer will.

#

... and rage.

sour fern
#

like people trying to write bulk-processing code in python, then wondering why it's so slow and not keeping their mind open to maybe doing it in a different language

#

a bit specific, but I've seen it before and it triggers me lol

frank elbow
#

Gotcha, that's fair

red tiger
#

I usually ignore people who blame languages first because it almost always is the fault of the programmer.

#

Usually it's those people who bitch about loops.

#

Heh.

#

Java is absolutely capable of running The Sims 1 in 2023.

frank elbow
#

Very much agree, language superiority discussions are tiresome imo

#

Like yeah we can discuss their strengths and weaknesses but saying "X language is bad, full stop" is boring

#

Use Brainf**k to make a game for all I care

red tiger
#

Use JavaScript.

frank elbow
#

Now, we have to draw a line somewhere (joking)

sour fern
#

lmao yeah

#

did my final year project in that instead of TS

#

never again

red tiger
frank elbow
#

I don't mind JS all that much. I find some design decisions questionable but it's fine

faint jewel
#

CODEMONKIES! i need to be able to save a VEHICLE into an inventory. make that happens.

frank elbow
#

You got it boss, we'll have it done by yesterday

sour fern
#

Yeah it's not bad, but it got a little out of control, since we ended up writing our own janky type correction anyway

#

using jsdoc annotations

faint jewel
#

i was thinking more adding vehicles to trailers.

red tiger
sour fern
red tiger
frank elbow
#

JavaScript's prototype chain 🤝 Lua's metatable “classes”

#

(being strange)

red tiger
#

What's cool is that script actually does what you'd expect it to.

#

I had to figure this out when I was working on my Lua to Typescript transpiler.

frank elbow
#

Lua to TypeScript? You have it going the other way too ?? (idk whether that was a typo)

red tiger
red tiger
frank elbow
#

To migrate existing code to use PipeWrench?

red tiger
frank elbow
#

Ah, gotcha

red tiger
#

What if I want to make my own ISUI?

#

Let's use OOP. Maybe interfaces. Inheritance. Types.

#

Type-Joins.

#

ISUI as it is currently contains a lot of dead code.

#

Also, same property names are used entirely differently in sub-classes in some places making interpretation increasingly difficult.

frank elbow
#

Have an example?

red tiger
#

there's a mouse event function that doesn't even execute in several ISUI classes.

#

Forget the name.

#

Also joydata. Who knows what's passed with that by memory.

frank elbow
#

Mouse up, mouse down, mouse up outside, mouse down outside, right mouse for all of those, double click, mouse wheel. That should be everything, I think, do some of them assume more than that?

frank elbow
red tiger
#

Been too long for me to recall exact examples.

frank elbow
#

Fair enough

drifting stump
#

howdy folks been a while

red tiger
#

Hundreds of hours spent in ISUI world has shown me that it's almost necessary to use something like Typescript to properly rebuild it.

drifting stump
#

it seems i was summoned by ui code talk

#

youre probably thinking of

---Java hook triggered when a key is pressed.
---
---Requires WantKeyEvents to be true to be called.
---@param keyID integer The id of the pressed key.
function CFUIElement:onKeyPress(keyID)

---Java hook triggered when a key is held.
---
---Requires WantKeyEvents to be true to be called.
---@param keyID integer The id of the held key.
function CFUIElement:onKeyRepeat(keyID)

---Java hook triggered when a key is released.
---
---Requires WantKeyEvents to be true to be called.
---@param keyID integer The id of the released key.
function CFUIElement:onKeyRelease(keyID)

---Java hook triggered to determine whether the pressed key was used by the UI element.
---
---Requires WantKeyEvents to be true to be called.
---@param keyID integer The id of the key being tested.
---@return boolean
function CFUIElement:isKeyConsumed(keyID)

---Sets whether this UI element receives key events.
---@param wantKeyEvents boolean Whether key events are to be enabled
function CFUIElement:setWantKeyEvents(wantKeyEvents)
frank elbow
#

Those are all executed as expected; I'm wondering what isn't

#

Doesn't really matter for me, just curious

faint jewel
#

lol hi browser!

drifting stump
#

hey

faint jewel
#

CANNAE DM YE?

drifting stump
#

most of the dead code in isui is unused render functions

#

usually overloaded java methods that never end up getting used

drifting stump
frank elbow
#

Curious about the unused mouse events because I'm wondering what functionality doesn't exist that those elements expect

drifting stump
#

life got in the way of the new ui system

#

hmmm i dont recall any unused events

frank elbow
#

Jab mentioned that something doesn't execute—maybe I misunderstood what he meant and it's just that the events are being consumed

drifting stump
#

theres a bunch of gotchas with mouse events

frank elbow
#

Yeah, I've learned as much recently

drifting stump
#
---Java hook triggered whenever this UI element is left clicked. Clicks on child elements do not trigger this.
---@param x number The horizontal position where the click happened.
---@param y number The vertical position where the click happened.
function CFUIElement:onMouseDown(x, y)

---Java hook triggered whenever this UI element is double clicked. Clicks on child elements do not trigger this.
---@param x number The horizontal position where the click happened.
---@param y number The vertical position where the click happened.
function CFUIElement:onMouseDoubleClick(x, y)

---Java hook triggered whenever a left click is released in this UI element. Clicks on child elements do not trigger this.
---@param x number The horizontal position where the click happened.
---@param y number The vertical position where the click happened.
function CFUIElement:onMouseUp(x, y)

---Java hook triggered whenever a left click happens outside this UI element. Clicks on child elements also trigger this.
---@param x number The horizontal position where the click happened.
---@param y number The vertical position where the click happened.
function CFUIElement:onMouseDownOutside(x, y)

---Java hook triggered whenever a left click is released outside this UI element. Clicks on child elements also trigger this.
---@param x number The horizontal position where the click happened.
---@param y number The vertical position where the click happened.
function CFUIElement:onMouseUpOutside(x, y)

---Java hook triggered whenever this UI element is right clicked. Clicks on child elements do not trigger this.
---@param x number The horizontal position where the click happened.
---@param y number The vertical position where the click happened.
function CFUIElement:onRightMouseDown(x, y)
#
---Java hook triggered whenever a right click is released in this UI element. Clicks on child elements do not trigger this.
---@param x number The horizontal position where the click happened.
---@param y number The vertical position where the click happened.
function CFUIElement:onRightMouseUp(x, y)

---Java hook triggered whenever a right click happens outside this UI element. Clicks on child elements also trigger this.
---@param x number The horizontal position where the click happened.
---@param y number The vertical position where the click happened.
function CFUIElement:onRightMouseDownOutside(x, y)

---Java hook triggered whenever a right click is released outside this UI element. Clicks on child elements also trigger this.
---@param x number The horizontal position where the click happened.
---@param y number The vertical position where the click happened.
function CFUIElement:onRightMouseUpOutside(x, y)

---Java hook triggered whenever this UI element or a child is left clicked.
---@param x number The horizontal position where the click happened.
---@param y number The vertical position where the click happened.
function CFUIElement:onFocus(x, y)

---Java hook triggered every UI frame when the mouse is moved inside the UI element.
---@param dx number The delta change in the horizontal axis.
---@param dy number The delta change in the vertical axis.
function CFUIElement:onMouseMove(dx, dy)

---Java hook triggered every UI frame when the mouse is moved outside the UI element.
---@param dx number The delta change in the horizontal axis.
---@param dy number The delta change in the vertical axis.
function CFUIElement:onMouseMoveOutside(dx, dy)
frank elbow
#

I'm getting around the child element consuming events in my use case by forwarding the event to the “correct” handler based on where the click occurred

#

Sounds much more evil than it is in practice, I assure you

drifting stump
#

perfectly fine to do

#

think i did it once to allow mouse dragging when clicking a child

#

was annoying not being able to drag if you clicked on the child

frank elbow
#

I think it's a little dirty, but it is what it is

#

As long as it's consistent I'm okay with it

drifting stump
#

you could use onFocus if youre using left clicks

#

its always triggered

frank elbow
#

I'm using all of those events except onFocus actually lol, saw it but decided I'd rather handle that behavior myself

upper mason
#

How often event OnPlayerUpdate() is called?

ancient grail
#

i wonder why my sprint animation its not working well

frank elbow
#

Why what's not working well?

#

Oh

ancient grail
#

my bad

#

wtf why is it uploaded like download able

cosmic condor
#

TOO LARGE

#

better upload as mp4

ancient grail
#

i wonder how im going to be able to make blood droplets fall down? i would need an animated tile to follow the playerZed

pastel glen
#

how do i change all footstep SFX to 1 or 2 custom sounds? can someone help me with this? is it possible?

upper mason
upper mason
#

Hm... Licker β will make all these stairless safe houses rather horrible trapbox 😄

grizzled isle
#

Player Zed for multiplayer huh

#

🆒

ancient grail
#

Our team and collaborators are building it slowly

#

If you want to join just dm me

#

Ill add you to the collab chat
Send you the repo link and the plan

grizzled isle
#

Boss monster when

#

I kinda want a demon zombie that has bone sword ooo

#

And juggernaut

#

This will make OP mod less OP

#

Mutation trait when

#

Also swimming hmm

#

Jumper zombie

#

Boom zombie

#

Siren

#

Fire resistant zombie

#

Anything from left4dead hehe

#

Child zombie and baby zombie

#

Maybe also a flesh blob that can spread

#

Hmm

ancient grail
grizzled isle
#

Oo nice

#

Acid vomitter

ancient grail
grizzled isle
ancient grail
#

wait that is possible using the throw

#

but then

#

the projectile itself sucks

#

like its not gona stay wherevr it land it will bounce

grizzled isle
#

Ye

ancient grail
#

and its java sided i bet

grizzled isle
#

It has to be like

#

Puddle

ancient grail
#

but this is an immortal zed whenver its not moving

#

you can only hit it when it is moving

grizzled isle
#

Oo

#

Bozz

ancient grail
#

links in my profile if you want to see progress and details

grizzled isle
#

Make youtube reel

ancient grail
#

reel will follow when its done i guess

grizzled isle
#

Yea

upper mason
grizzled isle
#

Bozz

#

Grab people is well

upper mason
#

wrote it =_=

grizzled isle
#

Maybe make them immobile then but the animation,,, how

upper mason
grizzled isle
#

I can't imagine how to implement it

#

Using the engine

#

Projectile is a no go

upper mason
#

But animation will be lacking.

ancient grail
#

Yeah you just teleport the play infront vut you cant have animations like the toungue to behonest

crude garnet
#

hello cuties, I'm banging my head against the wall trying to learn Lua scripting for PZ modding

frank elbow
#

I don't think banging your against a wall will be very helpful in that process but whatever works

abstract pine
#

If I want to change a weapon's script item properties, is there any way to make my changes savegame compatible? Since all weapons of a type already existing on a save will use whatever the old values were. Adjusting the values of an item object itself is itself simple enough, but I'm not sure how you would get all of the items to manipulate their data in the first place, if there's even any feasible/practical way to do so.

On further thought, can't think of any way better than adjusting weapons on OnEquipPrimary/OnGameStart events, but if anyone has another idea let me know.

crude garnet
#

@frank elbow nkoDerp

#

In short, I'm trying to script up some magic that has a check run against any container, if the ambient temperature reaches 0c, to treat said container like a freezer, without needing electricity.

#

A ghetto way to make freezing weather cause food to freeze if it's in a container, and it's not in a heated room

#

also checks if it's already a fridge/freezer, so that it doesn't tinker with those

fast galleon
#

Is there a reason vehicle mods use the Base module? I test now with custom module

Vehicle: ok
template: ok
custom parts: ok
models: ok

???: not ok?
wet sandal
#

In my experience a lot of mods just don't realize that they're not supposed to use base

fast galleon
#

only downside is, it seems to require adding your module before everything so it's myModule.template, etc.

neon bronze
#

maybe convenience? or just more simpler time writing stuff? I would be a bit tired if i would have to write module.xyz all the time

fast galleon
bronze yoke
#

it only searches base

ashen adder
#

Any tips for how to get started with modding? I have a very, very small amount of coding experience (Mostly doing very simple edits to GMod mods) but other than that I'm completely clueless.

fast galleon
bronze yoke
#

how did you do it? what's the syntax?

#

i might be mixing two things here but i remember checking the code and seeing that it was written to only check base

ashen adder
fast galleon
#
module AVC
{
    imports { Base }

    model WindshieldArmor1 { mesh = Vehicles/WindshieldArmor1, texture = Vehicles/Black_Steel, scale = 0.004, shader = vehiclewheel, }

    template vehicle TeamOrbitProtectionParts
    {
        part WindshieldProtection { area = Engine, model { file = AVC.WindshieldArmor1, } }
        ...
    }
}
module AVC
{
    imports { Base }
    vehicle CarStationWagonTiered
    {
        template = AVC.TeamOrbitProtectionParts,
        ...
    }
}
bronze yoke
#

hmm, that does seem to be what the code says too, i must have been thinking of something else

red tiger
#

Inline bracing is so much prettier.

ancient grail
drifting ore
grizzled isle
#

How many poly is the model btw

craggy ruin
faint jewel
#
function GetLastVehicleArray(scriptName)
    local allVehicles = getCell():getVehicles()
    local test
    local carlist = {}
    for i = allVehicles:size() - 1, 0, -1 do
        test = allVehicles:get(i)
        print("Array:" .. test:getScriptName())
        if scriptName == test:getScriptName() then
            table.insert(carlist,test)
        end
        if i = allVehicles:size() then 
            return carlist
        end
        
    end
end

``` i know this is wrong... how the hell do i add the cars to the array
frank elbow
frank elbow
faint jewel
#

test = allVehicles:get(i)

frank elbow
#

I see that part, I'm asking about carlist

faint jewel
#

i need them in a list that i can run through

#

local carlist = {}

frank elbow
#

So you're trying to add all cars that match the script name you're searching for?

faint jewel
#

yes

#

there is my whole function.

#

i edited it.

frank elbow
#

Dunno why you're looping backwards, but the general idea of the code is okay? The if statement condition should use == and I think you meant to check for equality with 0, but rather than returning in the loop you can return carlist after it

faint jewel
#

i want to find all the cars in that cell with that script name. i wan to return a list of all those vehicles.

bronze yoke
#

return outside of the loop, checking within the loop if you've reached the end is redundant and bad for performance

#
function GetLastVehicleArray(scriptName)
    local allVehicles = getCell():getVehicles()
    local test
    local carlist = {}
    for i = 0, allVehicles:size()-1 do
        test = allVehicles:get(i)
        print("Array:" .. test:getScriptName())
        if scriptName == test:getScriptName() then
            table.insert(carlist,test)
        end
    end
    return carlist
end
faint jewel
#

i said it was wrong 😦

#

lol

bronze yoke
#

i'm not scolding you

faint jewel
#

hey @fast galleon

#
function GetLastVehicle(scriptName)
    local allVehicles = getCell():getVehicles()
    local test
    local playerO = getPlayer()
    for i = allVehicles:size() - 1, 0, -1 do
        test = allVehicles:get(i)
        if test:getDistanceSq(playerO) < 1 then
            return test
        end
    end
end
``` this works WAY better when you exit a vehicle.
#

so if you need to do something you can grab that car right away.

#

now for the array bits!

little kraken
#

hi guys how do you apply two oncreate methods in recipe?

fading horizon
#

have one onCreate function
have another function
have the onCreate function call the other function

#

That's what I would do

#

alternatively, there is a difference between onCreate in the item definition script and recipe.onCreate

#

item definition onCreate is the function that occurs when the item is originally instantiated

#

@little kraken

fading horizon
#

How can I make my custom context menu item have a requirement / be red depending on a certain condition?

#

for example the "vape" context menu option

#

i want it to appear like the smoke option from when you try to smoke without a lighter / matches

#

but i need to do it without the requireInHand parameter

#

any ideas?

#

the condition that needs to be checked is the usedDelta of the item (battery charge)

#

i looked through ISContextMenu.lua but there wasn't anything I could find besides coloring the entire context menu

faint jewel
#

i need to stuff a vehicle into another cars glovebox, how do?