#mod_development
1 messages ยท Page 97 of 1
It's like riding a bicycle, only need to learn it once.
yeah you never forget... but you will still crash regularly ๐
almost done with the testing... so far so good... no errors no impact on performance
is there a way i can overwrite a mod original code
if it's in a global/returned function you can just overwrite the function
otherwise you can overwrite the entire file by making one with the same name and directory and messing with the load order
Ok thx
at this point I'm lost, is there anyone that could help me with BodyLocations stuff?
I've got a custom body location to manage amputations, just added at the end of the body locations so it shouldn't affect item rendering
except it does
for a while, it didnt
do you have the fbx file for the large backpack?
and are you using blender
sorry, I'm not modifying anything backpack related, I'm applying a mesh to show an amputated limb on the right arm
with a custom body part
oooohhhh
should have been clearer
No, It's fine
m_masks shouldn't affect clothing afaik
and I'm trying to null everything else mask related
for some reasons, in some saves it works, in some other it doesn''t
I'm not sure what I'm missing
over 10k lines but atleast working
im trying ( and its working kinda ) to create a UI Element that is "animated"... for now i have a timer running and when i trigger the function it changes the texture in the ui everytime the timer reachs 0 (timer has around 2 seconds duration ) and loops until the counter is 5 ( around 10s animation ).
am i just complicating whats already easy to do some other way? Is there a better way to do this?
If you're doing it in render you're probably fine
yup doing in render
render is always running, that made my life easier when changing the amount of elements in the UI without player interaction
Do you have an FBX file for the Large Backpack? I am trying to make a different model for the large backpack through blender and I believe I need the FBX file to import.
I don't do models, sorry
ah ok..
Try again tommorow and the day after. Infact spam every hr
ok ok... needs some improving but atm i can get the image from a twitch user account send it to the mod, and do some basic animations messing with another elements alpha ( another image )
Ok i will speak less here
so this way i can change the player say to that animation with some text related to the event triggered
ProccessMsg i forgot the syntax
But you can check the ISChat i think
Or just use Halo
@pulsar heath
yeah im using halo for the temporary traits
but for zombie events and heli events i want to do something... different
No one else sees this msg tho
Just the player itself
Im not sure if there a way to make other see it
yeah but thats not the point
Then just type what he wants to say
im trying to do something like the alerts we use on twitch
like a sub alert and stuff like that
Use servermsg
client server msg
local myMsg = "hello world";
SendCommandToServer(string.format("/servermsg \"" .. myMsg .. "\""))
but ill simplify what im trying to do: i have right now an animated heli or jet for the EHE events bought via twitch
Idk what else is there. Proccess msg
Servermsg say halo
running in game... the jet crosses the screen from left to right has has a "banner" behind with the name of the viewer that bought it
Ah then thats UI
Ok i dont know anything about that anymore goodluck hehe
Im sure you will figure it out
Does anyone know if AllowRandomHue or AllowRandomTint or a similar command, works non-clothing objects like pillows for example.
You might have gotten a syntax wrong
A file thats not suppose to be part of the mod.
Wrong directory structure
Or you have something wrong with your game files verifying files will fix this
I fixed that long ago already
But thanks
I found out what I did wrong
๐ค this a good question . No idea
Nice
i doubt they will care enough
does anyone know how to make a mod pack including various mods for easier download?
What we do for our server is
We use spreadsheet
There you can enter the
mod id | workshop id
column 1 | column2
The. It will auto create two cells containing the merged list of both that you can easily copy and paste
The whole thing
This would make placing and removing mods easier
Idk a t the steam collection feature i think they gave that where you can group em so its easier to sub and resub ithink.. idk how it works ihavent tried that
Would it be possible to make a mod that shows the "remaining" Zombies under the kill counter? I normally play without any respawn and i am curios how much progress i am making ๐ (Playing on Insane population without ramp up. First week and i am 4k zombies in. xD)
Last person who tried says it couldn't be accurate.
it's not something i know enough about, but i can't think of a way to do it
it cant be done afaik if you look at the zeds population data there are zeds that are virtual local remote and ithink theres more
but if you test it out and figure out whaqt thoes are then maybe we can figure out how to merge the zeds
or like do the math of it based on the spawn rate if its not random
I need someone to help make a few mods for my server im working on (PAID)
Hmm gonna fish around the debug mode and see what values are exposed to count against
has there been a recent vanilla update?
https://steamcommunity.com/sharedfiles/filedetails/?id=2911874981
Finished anyone intreasted of changing spawns of Aresnal(26) mod you can use this mod for it , works in MP
any mod devopers that could either point me in the right direction or i could maybe hire?
next() is not available?
it's apparently implemented in kahlua so i'm a little confused by that
did the zomboid devs recently removed the feature that you can cook food with rotten ingredients??
you need a high cooking level
I have now the situation that I cannot craft jars when having rotten food in my inventory even I have enough fresh food to craft them too.
is this a known issue? I could swear that a few weeks ago, this was not a problem
do you have any mods changing jarring behavior?
no. I tested vanilla. even after a fresh install!
<m_2DBlends referenceID="3">
<m_AnimName>Bob_Idle</m_AnimName>
<m_XPos>0.00</m_XPos>
<m_YPos>0.04</m_YPos>
<m_SpeedScale>0.80</m_SpeedScale>
</m_2DBlends>
sounds like the onTest / onPerform might need to be fixed/changed
anyone know show to use that
it's crazy. I could swear that this problem wasn't around a few weeks ago. I am working on a mod changing the jarring behavior and playtested the system quite deeply. now, I have this strange issue without any mod...
maybe I only playtested stuff with high cooking skill and therefore didn't notice the problem. but definitely seems to be a vanilla bug...
there's a mod to chain zeds like Michonne? or to lock'em down?
Quick easy question I think, is there a place in one of the txt files that I should declare dependency on another mod? I've listed the dependent mod on steam but wonder if there's anything I should do in the mod as well to help people notice the dependency
U plan to make that? @honest shard
I wish I could, I don't know how can do that. I'm currently making a sound mod tho
I have a zombie I don't want to kill, I need a mod like that rn
If you require it on the steam page it will show its required before they can sub the other mod thats require will popup and ask to be downloaded too
This is the mod dev chat . We talk about developing mods here
in your mod.info use
require=modid
But just so you know zed is hard to manipulate and it will need you to like configure probably the groupings on the sandbox
if you have multiple separate them like this
require=modid,modid (don't add spaces between them)
And make em like always attract to each other by noisewhich would be difficult to control
ah awesome, thanks albion!
there is a OnBeingHitByZombie event on the wiki but it seems like it's obsolete, is there any alternative?
OnWeaponHitCharacter?
OnHitCharacter
Character can be zed you or other players
Ow wait i could be wrong
You're talking about OnWeaponHitCharacter
and no
it doesn't work
zombies do not trigger it
you can use onplayergetdamage but it's not 'precise'
depends if you need it to *only* run when hit by a zombie or not
although that event is super laggy so be careful with it regardless
You cant isolate the dmg comming from the zed. Why did that zedhit event got removed
a lot of the 'obsolete' events were just never implemented
some of them aren't even events
all the hooks are listed as obsolete events on there
it's not in the lua events page though
wiki is old
i have notes about it here
it literally gets called every frame, often multiple times every frame, while you're taking any damage, so it's only useful as like a last resort for catching things and not a consistent 'zombie damage' event
Adding this to the list of reference
that's fine for what I need then
do you know what variables are passed to it?
in the message i linked
today I'm blind, nvm
i wanted to write a more up to date event guide (since the wiki can't really be updated) but it's a lot of work, probably need to automate it to a certain degree and i don't really know anything about that
Nice
probably in the same format as my hook guide
ok wow you weren't kidding, every single blood droplet calls it
yeah, you literally get a call for every negative health change, most of which happen every frame, for every BodyPart it is happening to, *and* the BodyDamage as well
not getting the body part there kinda sucks
Hey all, I'm brand new to modding, no coding experience to speak of, and I'm looking to get help with figuring out a component of a project. Mostly just trying to figure out how to determine what exactly gets returned by things like getTimeOfDay and getDawn.
I'm trying to get the mod to determine if it's daytime, and return true if it is. I assumed getDawn returned a time and I could just compare it with greater than/less thans to the getGameTime, but it doesn't seem to work that way.
getDawn and getDusk, that is.
Any help would be greatly appreciated!
Look at the foraging lua
It has a function that does that @orchid carbon
alright... where would I find the foraging lua?
media/lua
Not sure where exactly
Or what it's called
You might need to have your id index your folders so you can just search easily
If you need references
Thanks. I'll try to slog through it, its just hard as a non-coder to understand what other coders intend the code to do without really good commenting.
it looks like getClimateManager():getSeason():getDawn() is used instead
So the event you wrote here not ont he events lost for some reason
Did you just make them
they aren't events, they're hooks
Alrighty. And that returns a number that can be compared to getTimeOfDay?
yep, that's what the code i found it in does
Does the game assign a unique, immutable ID to vehicles? I've just tried to capture a reference to a vehicle using the getId() method of https://zomboid-javadoc.com/41.78/zombie/vehicles/BaseVehicle.html, however, after disconnecting and logging into the server again, I get a different value (I got 247 originally, now I get 251).
gametime's dawn/dusk are integers and i don't see any indication that the game actually updates them with seasons and stuff, they might just be a relic
I remember skizot tried this before but dont know if he manage to figure it out.. but afaik they say itsbuggy
Alrighty, I'll try using the seasons version and see if that fixes it. Thanks!
BaseVehicle:getSqlId()
@faint jewel you manage to solve your vehicle id problem before
what would i need to do to obsolete an item? i cant seem to remove an item i want from distribution
Hi, are there any devs here with audio/ai-audio/tts knowledge? I've created a mod with talking zombies -> twitch chatters can make them talk through twitch chat. I'm using google cloud, but the voices there are much to clean
How does this mod work?
Copy the item script and add obsolete = true
websocket to twitchchat, analyzes messages, if it encounters the tts command, it makes a call to a small backend component to fetch a wav file and run it on the zombie (zombie.getEmitter().playSound(wav)).
The small backend just sends some voice and audio parameters and the text to google cloud tts service
wowza! That's pretty epic actually. Whish I knew how to help you with the AI voices -- but I suspect if you wanted something better, it might be something you'd have to pay for I'm guessin', most free text to speech sites are pretty clean/robotic sounding
gc seems a good niche - for the basic product I would pay peanuts. Free test account with 300$ for 3 months. But once you go way from basic products, you pay big $$$.
I've seen a project for tts on bulldogs github account. But I haven't done anything yet with Python and AI.
Any hints are appreciated.
The problem with bulldogs tts: it's entangled with plenty of other services on his gh account + no/not enough docs. I don't know where to start
when I have a string of the form "Base.MyItem" which refers to an item defined via the script.txt, is there an easy way to retrieve the string "MyItem" from it?
so just deleting the "Base." in the prefix?
if you know the module is always going to be the same you can just trim it that length
otherwise you have to do some weird regex (or whatever lua uses)
you can probably just trim using string.find to find the . actually
Local mytext = luautils.split(text, ".") [2]
lua has a method called string.gsub for this. I just thought that there might be a pz java command for this situation...
its probably not what you are looking for but i saw this so i thought you might find it useful idk
function ISSpawnHordeUI:getZombiesNumber()
local nbr = self.zombiesNbr:getInternalText();
return tonumber(nbr) or 1;
end
that's a curious case, where do you need that
isn't that the number you type in the box to spawn zombies?
getPlayer():getStats():getNumVisibleZombies()
getPlayer():getStats():getNumChasingZombies()
getPlayer():getStats():getNumVeryCloseZombies()
@fast galleon Looking into the registerWindow() stuff and the intended behavior is the windows that were open will reopen onCreate - I suppose the issue is registering the window leads to it being 'nil' on death?
I don't understand what you mean. It's main purpose is to save the layout for next time. But it also keeps the instance cached to save it on exit, so they don't get garbaged
Using the registerWindow in your PR leads to the debug windows not being open on create new character
there're exists such funcs? have nver seen lul
you added registerWindow
to the vanillaOpen yes
I added ISDebugMenu.RegisterClass(_class)
. _ .
It closes the UI on player death
Is there wa way to disable sneaking when holding a certain item?
i mean the "stop player from running while holding stuff" doesn';t work.
it says it does but it dont.
you can TOTALLY sprint even when it says you cant.
I mispoke a bit but I'll retest it - what I was seeing was that on death the windows close (good), but on creating a new player the windows that were open don't reopen.
but the windows that were opening on their own did not open on their own atleast
ah, so you'd like to keep the instances saved
If possible yes, I'd like the debug "setup" so to speak to come back
The issue isn't present when relogging - only seems to happen when you die and make a new character
I'm guessing there's something I missed in the new() for isoregionwindow and generaldebug
players have the setSneaking(), setRunning(), setSprinting() functions. Might need to just set these repeatedly OnPlayerUpdate or something when you have an item equipped.
can't sprint, can jog
i wanna force them to walk when carrying heavy stuff lol.
@sour island
so this, but keep the instances
function ISDebugMenu.OnPlayerDeath(playerObj)
for _,class in ipairs(ISDebugMenu.classes) do
if class.instance then
class.instance:setVisible(false);
class.instance:removeFromUIManager();
class.instance = nil;
end
end
end
It should be the same for all ui you open, not only those two.
well it's still using the new() of the original classes
and those are kind of all over the place
Im setting the items as obsolete and they still spawn in game? ```module Base
{
item MechanicMag1
{
Obsolete = true
DisplayCategory = SkillBook,
Weight = 0.1,
Type = Literature,
DisplayName = Laines Auto Manual - Standard Models,
Icon = MagazineMechanic1,
TeachedRecipes = Basic Mechanics,
ReplaceOnUse = MechanicMag1,
Tooltip = Tooltip_item_MechanicMag1,
StaticModel = Magazine,
WorldStaticModel = MagazineMec1Ground,
}
Obsolete = true line should have a comma at the end
ty
I wonder if I could use layout and just use a different variable than visible to track if it was open or not
@sour island
--ISDebugMenu.RegisterClass(_class)
Events.OnPlayerDeath.Add(function() _class.instance:close() end)
that's a bit slicker than what I had
function generic.OnPlayerDeath(playerObj)
for req,args in pairs(generic.overwrites) do
require(req)
local _class = _G[args[1]]
if _class and _class.instance then
_class.instance:close()
_class.instance = nil
end
end
end
Events.OnPlayerDeath.Add(generic.OnPlayerDeath)
hmm
I got it working but I'm not sure at what point
I'll remove the = nil to check
interesting
with =nil removed this is what I get
the only windows I had open was cheats and stats
@fast galleon Appreciate the help, added your PR and name for credit
backlog? damn I'd feel so much anxiety ๐
Heh. They like my work. =)
Also some are friends.
I try to let people know every now and again that I have a market for commissions but not many used it.
I'd like to see people in here who work really hard on their hobby projects get rewarded. =)
Also me lol
Mainly the work I get is bug-fixing or updating older mods.
I'v been using Kofi for comissions but there isn't a way to accept/decline - it's all instantly accepted and money upfront
Probably where my anxiety stems from lol
that's so scary
Yikes
That will completely remove the item from the game
Time to debugggg
Is there any way to fix the bug that causes Walkies to only work if players have met each other, by changing who has access to get all players?
Perhaps a sandbox setting?
i wish
im equally annoyed at that change.
if not moreso
it's possible that a java mod on the server end might be able to fix it
anyway
though that's irritating in its own ways
You think there may be a server end thing that could be changed?
I have gone through the sandbox settings and the .ini because i heard there may be but i have not found anything- I am curious if there's any i missed or any files i missed
oh you mean a java mod on the server end i misread
yeah
there's no setting
i' begged them to add one, as im sure u saw in the support thread
this is terrible for all RP servers
and any servers that wanna VC without discord involved
oh shit yeah you're The Guy lmao
I have established just now that by making somebody admin they are able to send and recieve voice messages once they are no longer admin
yes
they were attempting to prevent non-admins from getting a list of player positions
because a specific scenario in which a hacker could teleport between players and kill them rapidly
this seems pointless to me because if they can teleport between players they already have access and this probably would not stop them, plus you can just java mod the client to bypass most limitations
but i don't decide their priorities
if i were them id've made it an anti-cheat setting or something, at least.
Do you know how one might go about java modding the client to fix them?
Decompile. Fix . compile. Distribute manually
Not ideal which is why no one jumping on it
I'm not very literate with code and i kinda get what you are saying but not entirely
๐
Looks like I need to get back to updating CraftHammer for server-side plugins.
Someone also asked me to look into the bugs for walkie-talkies a while ago.
I'm guessing the bug is still around.

I'm back with another episode of "probably made a stupid mistake and need someone to point it out for me."
Long story short, I have different items spawning based on sandbox options, and so I need to run the distributions file after loading said sandbox options. I have it linked to OnInitGlobalModData, which works fine in other cases. But while the file works fine when not in a function, it's not spawning items once I wrap it in a function and wait for that event.
Is there any reason why this wouldn't be working?
require "Items/ProceduralDistributions"
require "Vehicles/VehicleDistributions"
local function modnameSetDistributions()
-- This works fine when it's not wrapped in the function / triggered on event.
table.insert(ProceduralDistributions.list["BedroomDresser"].items, "modname.clothingitem");
table.insert(ProceduralDistributions.list["BedroomDresser"].items, 0.05);
etc.
end
Events.OnInitGlobalModData.Add(modnameSetDistributions)```
it's only useful if it's server-side-only unless you have a small technical userbase lol
i suspect the walkie thing can be fixed server-side since it works fine for admins atm
I hypothesized that because the file load is being delayed the vanilla distribution file (which loads first) is just taking over, but I'm not sure if that's actually true.
Is there a particular server side file that I may want to look at for a setting to switch like other zomboid files? Or will Java not be as easy to read as Lua
Is it something in here?
don't use sandbox options for distributions, the sandbox options aren't loaded at that point in the load process
you CAN force them to load code-wise
but presently all mods that do that just.. placebo..
So there's currently no way at all to affect what might appear in a container based on sandbox options?
just call ItemPickerJava.Parse() at the end
End of the Event function, or literally the end of the file?
at the end of the event function
So:
table.insert(ProceduralDistributions.list["BedroomDresser"].items, "modname.clothingitem");
table.insert(ProceduralDistributions.list["BedroomDresser"].items, 0.05);
etc.
ItemPickerJava.Parse();
end```
?
that's right
Would it not be as easy to find in the java file as in the Lua files?
Shouldn't expect anything otherwise at this point, but it worked perfectly. Thanks again.
LUA event question - when I use OnGameBoot to load a profession it works fine when someone is making a character the first time, but it does not load that profession if they die and make a new character without restarting. Is there an event which does similar things as OnGameBoot but applies to character recreation after death as well?
I'm slowly working my way down the list on the wiki of events that sound like something that works at any character creation, but figured someone here might be able to save me some time. ๐ Much appreciated if so.
i think usually people just hook the vanilla profession function for that
Alright. I'll look at another mod that adds professions and see how that works then. Thanks!
Just throwing out a concept here for a child trait along with some concept art
Negative Trait
-3 Strength
-1 Fitness
+2 Nimble
+3 Sneaking
+1 Sprinting
Personally would pretty much exclusively use this to emulate a Joel and Ellie duo.
Clementine and Lee too
Does anybody know a way to change server files so that all players can getOnlineUsers?
to fix walkies
Would be great if someone could figure out a way to deform the player models -- make 'em smaller, etc. Or has this been done already?
how did you fix the floating bag?
Sorry to disappoint itโs not in game
Though Iโve explored the issue
You would need to create new clothing items with different connecting points
Same with hats
So child exclusive clothes and items
yes, that's a lot of headache
I mean, that in and of itself makes sense from a realism perspective. Most adults can't just wear children's clothing and vice versa.
I actually considered making a "clothing sizes" mod just to make scavenging for outfits a bit more involved than purely "does this look good on me"
Add a small mobility debuff or something for clothes one size too small/large and then make anything more than one size out completely unwearable
I'm working on a mod that needs custom sprites for the a custom world object. I think I need TileZed but when I launch the Linux version from the forums it errors out with:
Error renaming file!
From:
To: /home/jaql/.TileZed/Tilesets.txt
Invalid cross-device link
(while reading Tilesets.txt)
Is TileZed the right tool? Is there documentation on setting it up?
you can get the tool from steam https://steamdb.info/app/380880/
That's Windows only...
oh... no idea then ๐
Are you on Linux or Mac then?
If you're on Linux, can run it with Proton via Steam. Not sure how stable it is as I don't use this often, but it loads.
Ah, is there a way to get to it in Steam?
That said I'm a C++/Qt dev. I found the GitHub and could fix the crash, but I'm not a GitHub user so I don't know where I'd send the patch...
I'll figure something out. Just a bit of a faff to simply add a tile...
You can get it in Steam, just make sure that you have "Tools" enabled in your Library and you'll find the "Project Zomboid Modding Tools". If you right click on it in your Library and choose "Properties" -> "Compatibility", you can choose to run it through Proton. This is assuming you're on Linux. ha
Awesome, it works - that at least unblocks me on the modding. I'll see if I can patch the bug as well. This mod description might end up having a rant in it ๐
Na dont waste too much efforts on rant.
Atleast you got it working
can you only have one item module per modID?
no, no restrictions like that
Man a single } hangs the whole server haha
yea thats just normal for me.. i always make mistakes like this whenver im copy pasting from another file to another file like piece by piece or like converting from a script into lua variables
Yea, I was refactoring our server's items and shops and everything into separate mod IDs and when I was splitting the recipes into their own files I missed a closing } aahah.
does anybody know where in the java files i would be able to change permissions for getOnlineUsers or getOnlinePlayers so that walkie talkies can do voip again
Alternatively could i make interested parties admins and or observers, allowing them permissions to see players connected, and just have them disable godmode and invisibility
๐ป
the plane flies... kind off
it looks like a drunk fly on a bad winters day
but it goes through the animation cycle
๐

oh and i finally got to test dynamic traits branch in the more traits mod
thinking about adding some stuff to the twitch integration, gonna make the char trip and have a panic atack stuff like that
Is there any way to either allow regular players to access player info or to limit the abilities of mods so they can't sprint infinitely?
is there a correlation between the two questions?
Yes, i want to fix walkie talkie VOIP on my private server and the thing that is broken is that players cannot draw user data unless they have been physically close to the player they are drawing from, and pulling that data is how the voip over talkies works
However mods can pull player data, and disable godmode on themselves and it seems like they can still interact with locked doors, however they can sprint at max speed infinitely and idk how to disable that
I either need to give players the power or take a different power away from observers
i would like to help, but i cant make sense of what you are asking
How do I mark a mod as a required?
@tardy wren i did that for one of my mods but cant remember how
lemme check my notes
I want to use the in game voice chat over walkie talkies
That feature broke a few patches ago because a function of the game was restricted to moderators, specifically the ability to pull user data of people on the server
I do not think i can change the game's files so that the function is re-enabled for players so I want to either enable that feature, or disable a feature of being a moderator
because my other option is to make everybody a moderator and just let them play like that with god mode off
But mods can sprint infinitely and i want to disable that
in your mod.info just add require=MODid
That may require javamodding
thanks
Yeah i think it does and that's where i'm stuck so i'm trying to find alternatives or workarounds
boycot IndieStone harder?
Though it didn't work when we tried when it first was released
question
playerModData['DaikonPanic_ZombieKills']
What if I do this when That index isn't defined
It'll just be nil
alright
Hey does anyone do UI stuff who is awake?
yes, but only by tiles replacing not by coding 
what are you needing burryaga?
working on ui atm
if is there anything i know, ill happy to share
almost done with animating a UI element
using still images extracted from a gif
still a bit janky but... it works
๐
yikes lol
but tbh i dont think this will be viable
animated pngs not available?
it will probably impact perfomance a lot
i just extracted the images from the gif into png format
and in animates 6 frames
1 per second
and loops back
1 fps?
depends on the question ๐ค
what is it?
but... why? lol! zomboid slug?
true.
what kind of bullshit you have to do in pz...
best game 
i do what i want in the game my friend
if you dont like it, thats just your problem
vishnya is just playin lol.
here comes the victim, i just said i do what i want, its not your concern and thats bullying? just block me or ignore me and youll be happier... i will im sure
why would I want to block you? I just said in pz u even can't render gif format and u should create shit like animation via pngs. u really things I want to hurt u someway? bro.. u trolled urself
just chill, lol
i misunderstood you then, sorry about that
Events.OnRenderTick.Add(functionName) i thought this would be a good event to call the timer function but i guess i was wrong
it's fine 
and i cant put the frame changer in the :render ...
wdym?
tried it, it just didnt update the render properly
but i can try it again... i've changed the fram changer function... maybe that was the problem and not having in the render
yup it was the function... but still kinda janky
but better... kind off
nop... the game cant handle it ๐
btw if I got right in pz no render order, right? all render divides to 2 parts: world and UI, and for second all elements is panels? worked before only with render in panels and didn't check how to render, for example, just simple text somewhere
it has to be outside of the render
i use panels mainly
even for text
at least the way i need to use it
second
cos as I remember there's only panel objects have draw methods, no global ones so... seems right
function STATSTab:render()
local player = getPlayer()
local KillModData = player:getModData().AKCModData
local alivefor = player:getTimeSurvived();
local zkills = player:getZombieKills()
local fkills = 0
if KillModData then
fkills = KillModData["fk"]
self.KillCount = true
end
if self.leftside then
if not self.KillCount then
self:drawTextureScaled(getTexture("media/ui/calendar.png"),0,-15,70,70,1,1,1,1)
self:drawTextureScaled(getTexture("media/ui/zedkills.png"),0,25,70,70,1,1,1,1)
self:drawText(alivefor,55,10,1,1,1,1, UIFont.Large);
self:drawText(tostring(zkills),55,45,1,1,1,1, UIFont.Large);
else
self:drawTextureScaled(getTexture("media/ui/calendar.png"),0,-15,70,70,1,1,1,1)
self:drawTextureScaled(getTexture("media/ui/zedkills.png"),0,25,70,70,1,1,1,1)
self:drawTextureScaled(getTexture("media/ui/firekills.png"),0,65,70,70,1,1,1,1)
self:drawText(alivefor,55,10,1,1,1,1, UIFont.Large);
self:drawText(tostring(zkills),55,45,1,1,1,1, UIFont.Large);
self:drawText(tostring(fkills),55,85,1,1,1,1, UIFont.Large);
end```
it was the only way to change the ui on the fly
was using the children method
but that isnt very flexible ...
plus this way it allow to add and remove elements on the fly when certain conditions are met
like in my mod, since everyone was asking for fire kill count... i just used the data from another mod that does that already and is well coded
so no point in doing something that already exists, i rather make a require in my mod
I remember, while have been creating new mod, draw methods don't use panel bounds and render context can be free outside of panel bounds, so maybe it's fine to create panel with 0, 0 size and use draw methods on it
yup
im doing something like that
the panel is only the size of the icons
so it can be dragged around
the text appears oustide of the panel with no problems
cool, so then there's way to draw smth "without" panel
yeah if you define the size 0,0 the only stupid thing you have to do is to use "weird" xy locations, since the element xy is based on the panel size
I can set pos 0, 0 too and just use screen size to get position
im just getting the width of the panel and base on that adding or subtracting x and y values on the elements
self:drawTextureScaled(getTexture("media/ui/zedkills.png"),self.width-55,25,70,70,1,1,1,1)```
thought about using the screen size but this way no matter the resolution the ui itself will be on the right place
it will prolly work with the screen size as well but this was simple and easy to implement
when i say the ui itself i meant the panel elements ๐
nop, the function to change the frame cant be inside the render
the game ends up not responding ๐
for panel context it's fine, yea, but for my way to draw smth somewhere by (0, 0, 0, 0) panel it won't work 
ha-ha
never tried it with 0 size
mine are 60x120 and 60x80
just big enough to have the icons inside and 1 or 2 px border for when you "anchor" the panel to the screen limits
if 0 doesnt work you can always make it 0,0,1,1 ๐
so 0x 0y 1w 1h
when started with pz modding anchor was nothing for me, I literally can't get how it works until check in pz source
always have did in manually but in pz for it is anchor
useless discovery for me xd
too strange way
the problem with pz modding is the lack of proper documentation and no standard in a lot of things
you wanna do this the syntax is this way the naming logic is x
the next thing you wanna do the naming logic is totally diferent or the syntax changes
so its more digging throught the damn file to make sense out of how thing works than it is actually coding the mod
its like 4 or 5 hours digging around the vanilla code then around 1h to actually make the code you want..
but while I tried to find anchor I found that pz surprisingly have stencil functions
at least some good news
are they exposed?
that would allow to do animations easier and less prone to impact performance
yea, I already saw some mods that uses them
hmm i need to check those out then
but don't know how much of it tis provide to us
just know there they are but didn't use yet
a good thing would be a pz "IDE" to test stuff out
pz ide?
an "interpreter"
a tool, a modding tool
something for you to test UI code and crap like that
without having to do it ingame
ah
all the math functions and stuff like that are easy to test without running the game, the UI
....
I think will be too complex to create such thing with ALL logic from pz

im sure theres a event in lua that will allow me to do this
but... which one...
maybe OnPostUIDraw?
even if the render tick made more sense
ill give that one another try
can u show the code? I can try to do smth
print("----------------LOADING AniMOD UI ------------------")
local aniframe = 1
function AniModUI:initialise()
ISPanel.initialise(self)
end
function startanimodui()
AniModUI = AniModUI:new(900, 250, 90,48)
AniModUI:addToUIManager()
AniModUI:setVisible(true);
end
function AniModUI:new(x, y, w, h)
local stats = {};
stats = ISPanel:new(x, y, w, h);
setmetatable(stats, self);
self.__index = self;
stats.title = "AniModUI";
stats.background = false
stats.moveWithMouse = true
return stats;
end
function AniModUI:render()
self:drawTextureScaled(getTexture("media/ui/" .. tostring(aniframe) ..".png"),0,0,90,48,1,1,1,1)
end
function AniModUI:onRightMouseDown(x,y)
print("------------ r mouse click -------------")
self:removeFromUIManager()
self:setVisible(false)
end
function stopanimodui()
AniModUI:setVisible(false);
AniModUI:removeFromUIManager()
end
function updateTimer()
local calendar = PZCalendar.getInstance()
return calendar:get(Calendar.SECOND)
end
function myaniTimer()
local second = updateTimer()
local endframetime = second + 1
while endframetime >= second do
if endframetime > 60 then
break
end
second = updateTimer()
if endframetime == second then
aniframe = aniframe + 1
if aniframe == 7 then aniframe = 1 end
break
end
end
end
Events.OnRenderTick.Add(myaniTimer())```
render gif as a few pngs is a shit but for pz it's fine XD
interesting to try
can u give frames too?
still need to replace that break for some logic about the seconds value
but for now i just want to see it run ๐
Is there a function for preloading chunks?
kinda, nobody uses it because it's not safe. that's what I heard last
Just having a problem with teleporting players above z0 as they'll just fall through the floor and take fall damage
thats just an homage pz devs made to skyrim
it isnt a game until a player can fall through the floor
sorry for the bad joke ๐
good morning fellow modders
I have a question about a clothing item that i made
I tried to add a flag to be worn on the back
so I made an item with following variables
imports {
Base
}
item CFlag
{
DisplayCategory = Accessory,
Type = Clothing,
DisplayName = Beavers Flag,
BodyLocation = UnderwearTop,
Icon = CLbeavers,
ClothingItem = CFlag,
WorldStaticModel = CFlagGround,
}
I tried BodyLocation= Back (but this didn't allow me to wear a bag at the same time)
Thus I tried underwear, necklace, neck, LeftWrist, and also ZedDmg
necklace, neck, LeftWrist these locations cut my item render into wierd shape
when it suppose to look like this
Ive tried ZedDmg which worked great flag + Bags however, I couldn't take the flag off. When I do take off, i can place it on the ground but game still shows that it's attached on my back..
Could anyone help me if there's any simple solution for this?? I would like to wear both flag and rest of items;including bags at the same time
@pulsar heath first ur problem is Events.OnRenderTick.Add(myaniTimer()) ๐
local delay = 0.1
local change_frame_time = os.time() + delay
function myaniTimer()
if change_frame_time < os.time() then
aniframe = aniframe % 6 + 1
change_frame_time = os.time() + delay
end
end
Events.OnRenderTick.Add(myaniTimer)
you have access to os in pz?
sure
i thought i didnt thats why im using the pz calendar ๐
he-he
oh that makes things a lot simpler and less impact on perfomance
so you got it to work?
yep, works well
oh wow that's amazing
as I sent, yeah
i need to change my other mod then
to use os.time
no need for bloated functions anymore
you just made my day
that's so cool m3ss
Its trying to use a mask I think, try doing the body location as a scarf.
I used os.time for benchmark lib but it not so good, will be so cool to get highly accurate time by any way
mb do u know such func?
ill try that thanks
I think you're supposed to use timestamp in console log
hmm
at least in console time saves just in seconds
I sure it's just formatted but there's used not highly accurate time func, think so
even os.time returns time with millseconds but this func not so accurate
as long as it works without having to much impact in the game performance
mb some function that returns time since game/server starts will be more accurate
but yet don't know such one
this worked wonderfully
but can't wear it with the scarf
well thats smoething they should think about adding in the future?
a timer function
is there a way to make an extra body part to wear somthing
Isn't it in tick ?
thats not related with anything else
or make ZedDmg bodypart refresh?
I done timer lib too but used os.time
https://pzwiki.net/wiki/Modding there's a 'A Note Regarding Optimization and Timestamps' that discuss it here
@jaunty marten this will do just fine, now just need to make the movement bit, mess around with the alpha a bit and im set
cool 
and update my integration mod to use os time
that cuts around 40 lines of code ๐
i was convinced that os wasnt available in pz lua dunno why... never even tried to use it
i think someone told me that?
whatever... im happy... another step in the right direction
Ooooo i want to use this too
๐
How many ssprite frames it would be cool if you hover then it animates
whats stopping you?
just detect the move hover and trigger the code
thats what im doing in one of my UI's
it should be a way do to it on game objects
I see it now
don't forget to cache textures ๐
When i find the use for this ill gove credit to you thnx
How
Nvm ill just learn that when. Cuz i dont need it yet
Yeah sure vishnya always gets credit on my code cuz lua timers a staple code for me
local textures = {
[1] = getTexture(...),
[2] = getTexture(...),
[3] = getTexture(...),
end
:drawTexture(textures[...], ...)
glad to hear, btw I hope u remember that timers going even when game paused ๐
now the sound...
@ancient grail werent you making a mod with a chainsaw?
that looped the sound?
how did you loop the sound?
You need the code for surio
Ok wait
if not getPlayer():getEmitter():isPlaying('chainsawLoopsfx') then
getPlayer():getEmitter():playSound("chainsawLoopsfx");
addSound(getPlayer(), getPlayer():getX(), getPlayer():getY(), getPlayer():getZ(), 50, 50)
end
elseif handWeapon:isBroken() then
getPlayer():getModData()['chainsawDBG'] = nil
if getPlayer():getEmitter():isPlaying('chainsawLoopsfx') then
getPlayer():getEmitter():stopSoundByName('chainsawLoopsfx')
end
ISTimedActionQueue.add(ISUnequipAction:new(getPlayer(), handWeapon, 10))
end
thank you
function chainsawLoop(pl, chainsaw)
if pl:getEmitter():isPlaying('chainsawLoopsfx') then
pl:getEmitter():stopSoundByName('chainsawLoopsfx')
end
end
Events.OnEquipPrimary.Add(chainsawLoop)
๐ซก
@ancient grail You should really store that player object and call it. (Makes the code long and is vulnerable to wasteful calculations when grabbing objects in general)
local player = getPlayer();
local emitter = player:getEmitter();
-- ...
if not emitter:isPlaying('chainsawLoopsfx') then
-- NOTE: Could probably tuple these.
local x = player:getX();
local y = player:getY();
local z = player:getZ();
emitter:playSound("chainsawLoopsfx");
addSound(player, x, y, z, 50, 50);
end
elseif handWeapon:isBroken() then
player:getModData()['chainsawDBG'] = nil;
if emitter:isPlaying('chainsawLoopsfx') then
emitter:stopSoundByName('chainsawLoopsfx');
end
ISTimedActionQueue.add(ISUnequipAction:new(player, handWeapon, 10));
end
now to build a decent animation adding more elements to the UI
and make one for the helis and zombies events ๐
are you taking into account render speed?
render speed?
you can change ui fps so some people may be running it at higher values
are you accounting for that in the animation?
the animation is based on a real time timer
and its like 1 fps
oops
6
its prolly more than that
but i dont think it will be an issue
need to find better gif cos looks not so good
since its a timed function to change between 6 images
yeah this one is for testing
now to get decent images
and make my own
and maybe cut the images number from 6 to 3
even 6 too laggy, 3 will the hell
thinking about using something like this for the zombies event
Right.. the thing is when im still writing the code i often copypaste verbose debug
And do optimizations later
Who am i kidding i never really cared abt that yet ๐คฃ
Clean as you cook my friend..
dunno to what point using a better "animation" will impact the perfomance
FPS won't matter much here. The main villain in the UI code is the update() method. It is very slow.
the ideal would be at least 16 images
You should use a OnTickEvenPaused() Event-hook.
This is how I get around this limitation for my HTML render engine project.
to pause the animation if the game is paused?
like ive said before update ticks at a fixed rate
while render and prerender tick every ui frame
this is meant to be a simple thing
just plays the animation doesnt care if the game is paused or not
theres no need for updating animations on tick when you already have the perfect hook with render
OnRenderTick ?
Events.OnRenderTick.Add(myaniTimer)
dont use events for this
I'll argue that it is not wise to mix update code with render code, however in PZ's case, render code for UI is on the main thread...
ui in pz is a pain to work with
btw @red tiger do u know in pz some accurate time function instead os.time? for benchmarking
os.time is the best you can get
i dont see any other way to do what i want to do without using onrendertick
There will be cases where it is a good idea to use the event. It's good to know about it as an alternative while respecting update code being in its own thing vs render code being in its own thing.

Sec
๐ฎ
ive asked the devs for a nanosecond timestamp but alas nothing
print("----------------LOADING AniMOD UI ------------------")
local aniframe = 1
local delay = 0.1
local change_frame_time = os.time() + delay
local AnimPosX = 1400
function AniModUI:initialise()
ISPanel.initialise(self)
end
function startanimodui()
AnimPosX = 1800
AniModUI = AniModUI:new(AnimPosX, 250, 90,48)
AniModUI:addToUIManager()
AniModUI:setVisible(true);
end
function AniModUI:new(x, y, w, h)
local stats = {};
stats = ISPanel:new(x, y, w, h);
setmetatable(stats, self);
self.__index = self;
stats.title = "AniModUI";
stats.background = false
stats.moveWithMouse = true
return stats;
end
function AniModUI:render()
self:setX(AnimPosX)
self:drawTextureScaled(getTexture("media/ui/" .. tostring(aniframe) ..".png"),0,0,90,48,1,1,1,1)
self:drawText(tostring(AnimPosX),55,85,1,1,1,1, UIFont.Large);
if AnimPosX <=0 then stopanimodui() end
end
function AniModUI:onRightMouseDown(x,y)
print("------------ r mouse click -------------")
self:removeFromUIManager()
self:setVisible(false)
end
function stopanimodui()
AniModUI:setVisible(false);
AniModUI:removeFromUIManager()
end
function myaniTimer()
if change_frame_time < os.time() then
aniframe = aniframe % 6 + 1
change_frame_time = os.time() + delay
AnimPosX = AnimPosX - 10
end
end
Events.OnRenderTick.Add(myaniTimer)```
I hope Jab know the some secret
Oh yeah nano? Nah.
They don't have an exposed API for it.
I can add this to Crowbar.
yeah every exposed timestamp was ms
u need to update X pos in some other event, not in function with 1 seconds delay
yeah that would make it more smooth
i had a really efficient animation system need to find where it is

but atm while im building this up it will have to do
first the blueprint then the fiddling and improving

im probabbly gonna end up making a panel with the screen width
and move the elements inside of it
and not the panel itself
@LuaMethod(name = "nanoTime", global = true)
public static long nanoTime() {
return System.nanoTime();
}

hmmmmm
Added it to CrowBar.
That method is not in the game without modding it so don't try it.
waiting for ur tool 
local time, totalTime, frameCount = 0, 0, 0
local function OnPreUIDraw()
time = getTimestampMs()
end
local function OnPostUIDraw()
local milli = getTimestampMs() - time
totalTime = totalTime + milli
frameCount = frameCount + 1
print(string.format("UIFrame took %.0fms to render", milli))
end
UIProfiler = {}
function UIProfiler.start()
totalTime, frameCount = 0, 0
Events.OnPreUIDraw.Add(OnPreUIDraw)
Events.OnPostUIDraw.Add(OnPostUIDraw)
end
function UIProfiler.stop()
Events.OnPreUIDraw.Remove(OnPreUIDraw)
Events.OnPostUIDraw.Remove(OnPostUIDraw)
print(string.format("Average UIFrame render time: %.3fms", totalTime/frameCount))
end
remove the print on postuidraw for a more accurate reading prints slow things down a lot
let it run for a while before you stop because the minimum time it can represent for each frame is 1ms
more samples gives a better average of the real performance
Phew. You ever break the game so hard it refuses to load to the main menu?
not even i managed to do that
Also remember that the time it takes Lua to convert from Java and execute pcall will also affect the times.
but i make it crash a lot ๐
I've made the game stackdump, not stacktrace.
What does that mean
It means I made the JVM very angry.
I see
Hmmm
My submod didn't load in the sandbox settings
Its translations did override the base mod's but it should've added an extra option which isn't showing up
Failed to parse...
option DaikonGeneralAnxiety.MoodleListMoodleFramework
{
type = string,
page = DaikonGeneralAnxiety, translation = DGR_MoodleListMoodleFramework,
}
Why did it fail to parse this?
I didn't miss a comma at the end did I
I have this idea of sort ranking system but only based on days survive
It will change the players name and everyone should be able to see the color change
Is it possible?
I'm not sure if it's on lua side but if yes then u can try to override get player name method
about color change idk, I think there's just a color without reference
Ayt thnx
Only if you mod the server's Java code to send another name to the client.
yea btw I think if even override name method on lua side other features can be broken due to usage from java no lua
Well, crud, I fixed the mod option but now the translations load in the wrong order
dumb question is there a way to name the elements inside a panel?
?
im adding ui elements manually
self:setX(AnimPosX)
self:drawTextureScaled(getTexture("media/ui/" .. tostring(aniframe) ..".png"),0,0,90,50,1,1,1,1)
self:drawText(tostring(AnimPosX),55,85,1,1,1,1, UIFont.Massive);
if AnimPosX <=0 then stopanimodui() end
end```
it warms me heart to see browser talking code again.
ok, is there anyway to name the drawcalls?
no
you could have another uielement drawing that but youd just be moving the draw call somewhere else
i guess il make 2 panels and manipulate everything inside each panel
or something even simpler... thanks @drifting stump
draw calls are as simple as it gets
yeah im saying simpler in what i want to do
as always refer to https://github.com/Browser8/PZ-Server-Points for a proper ui implementation
ill frankenstein some code and post it so you can at least try to understand wth im doin'/talking about
i doubt that covers what im trying to do but will have a look
Hmm, so now it loads the lua correctly
But my function is now nil?
How do I reference a function from a different file across a global table?
I'm making a submod that will provide a function, and the main mod should only call it if the submod is loaded
I did something like this
local daikonGeneralAnxiety = daikonGeneralAnxiety or {}
local DGA_extraAnxietyMoodleFramework = daikonGeneralAnxiety.DGA_extraAnxietyMoodleFramework or nil
you could make a module exposing your main mod
In the main mod
then require it in your sub mod and add the function to the module
So... Have my main mod have a dummy function that the submod will override?
bit by bit ill get where i want... i hope
Bowser you're not helping
local MyModule = {}
local function doTheThing()
if MyModule.subModFunction then
MyModule.subModFunction()
end
end
return MyModule
local MyModule = require("TheFileContainingTheAbove")
function MyModule.subModFunction()
end
there you go
thank you
error not a table
fixed
To require multiple mods, I need to put them after a comma?
yes
Oh are you kidding me
My mod didn't load because a mod it depends on loaded later in the order
Is there a way to have the โread sheet of paper/journalโ UI show up without the player having access to the paper? Iโm trying to make a mod that allows using the computers as a sort of chat room for multiplayer and I canโt think of a way to display the saved messages
ah yes one of my many projects
a fully functional pc
you probably want to make a custom ui
Thatโs not something I really want to do though. I guess I could try it.
For a different mod Iโm making, is there a way to override the speed penalty imposed by injuries? A mod Iโm working on will include a lot of drugs, and I want morphine to make players temporarily unaffected by speed penalties from injuries, but I donโt know how to do that
that would be awesome
ok, got everything working... apart from the sound
but time for a break
i need to get the base ui elements for the community framework done before anything else
but im not happy with the way it is now
mmmm I love it.
If you need insight I could possibly provide some.
yes please im banging my head against this
UI is such a pain if you don't know how it's designed from the bottom up.
I've probably spent around 400 to 500 hours doing UI code in PZ since 2015.
Why not simply work with me with Crowbar? My goal is to write a new UIElement Java class.
i want annotations to not show every single method available and actually act like a class
I'm planning to add draw calls for things like circles and other useful bits.
Also the HTML render engine project. <3
if you call on the class only static methods should show up
PipeWrench. :D
The real reason I wrote PW was for UI.
That's the white paper for it.
I'm glad to see someone else taking action to improve the UI API.
this should only show for instances aka the return of new
Lua?
of course
this is derived from emmylua
Now we have two languages with documentation as options.
I planned on baking in my own third-party documentation to UIElement when finishing up what PipeWrench is right now
So our priorities are aligned. xD
๐ฅบ
Hey you know the project is open-source right?
I simply need more time to get to it. =(
I thought it's still on dev branch
It's not ready yeah. (Not close)
(private)
But the framework's basically there.
yea, cool, will check 
I paused when I started writing CSSChain. (My attempt at rulesets and order of CSS rules)
You can easily argue that a bit of it isn't organized in a way that would be better however most of it is documented to all hell.
@jaunty marten This is the example file so far: https://github.com/asledgehammer/PipeWrench-UI/blob/main/src/client/example/ExampleUI.tsx
i could have a table of static and another of instance methods then do some metatable magic
but might not be very user friendly adding functions to those tables instead of the main one
Surprised that TIS didn't place drawPolygon in UIElement. It's currently in RadialMenu.
---@class CFUIElement
local CFUIElement = {}
CFUIElement.InstanceMethods = {}
CFUIElement.StaticMethods = {}
setmetatable(CFUIElement, CFUIElement)
CFUIElement.__index = CFUIElement.StaticMethods
function CFUIElement.StaticMethods:new()
local o = {}
setmetatable(o, o)
o.__index = self.InstanceMethods
return o
end
something like this
awesome ๐
I won't be offended if you end up critiquing it. It's a WIP.
nah, it's fine

@red tiger think something like that would work or too complicated for newcomers to extend the class?
Like what? Pre-made element types would make things a lot easier.
Typescript / Lua would then be used to manipulate those elements much like how JavaScript is used to on websites.
before i get to any pre-made element i need to get the super class done
which is what im working on
Oh, I'm talking about my stuff.
this
I plan on writing things like ```html
<radialmenu onclick="..">
<option />...
</radialmenu>
but that will have to get translated to lua code
which is what this is addressing
making the lua side of things actually usable
As of version 0.42.0, TypeScriptToLua supports the use of JSX. To enable it, add "jsx": "react" to your tsconfig - other values are not supported.
Lua API is doable even if written in Typescript.
I wrote my own CSS parser.
I can also write an HTML parser.
The goal is to be able to use it in Lua too.
why?
I mentioned it above. I'm writing a HTML render engine for UI design in PZ.
oh, I was initially thinking something like SASS/SCSS/etc. but I think I see what you mean now, you wrote a parser for the game to parse CSS
well this works flawlessly now its just a matter of how user friendly it is for extending the class
depends on what you mean by extending the class, derive should work perfectly normally with the syntax there
unless you're asking how he's going to handle that in typescript, which is a good question I suppose
that's irrelevant, plenty of non-UI stuff uses inheritance in the base game
unless by "extension" you mean something else entirely
youre a bit lost XD
im rewritting it all
the way inheritance works atm has issues with documentation
how so?
also I'm not really lost, just asking you to clarify 
given any ui class
in fact ill examplify
im operating on the class yet its showing me instance methods
This is of course my personal opinion, however as big as ISUI is in PZ's Lua codebase, ISUI needs scalability with error checking / strong types / object types.
only static methods should show up
IMHO ISUI should be rewritten as TS.
agree
typing is solved with the documentation
Both options requires work.
you're using a colon, so wouldn't you be operating on an instance there (that'd be shorthand for CFUIElement.<function(CFUIElement)> wouldn't it?)
no because of the way the inheritance mechanism works
new and derive are static methods yet they still need self to make the inheritance work
with my friend that know coding
soo the issue is obvious the npcs dont spawn in mp[
yes they dont theyre too afraid of you
(When we call Account:new, self is equal to Account; so we could have used Account directly, instead of self. However, the use of self will fit nicely when we introduce class inheritance, in the next section.) [...]
to understand the mechanism behind it
Keep in mind that Kahlua isn't real Lua and is 5.1. (You may know this but others don't)
oh I see what you're saying, the implementation that ISBaseObject uses has its constructor set up via :new() rather than .new(), so that causes issues with static encapsulation
no
.new is a thing Kahlua does with Java objects.
:new is the pseudo-class implementation that TIS uses for Lua code.
the column is needed to make inheritance work in lua
dude im saying the truth
but conceptually the method is static
it doesnt operate on an instance of the object
i just found the issue
It's a silly nuance that trips people up when they start modding PZ.
Thank goodness that I can rid of that nuance in Typescript using @customConstructor
no, the difference exists in lua - : is for functions that pass self as an argument, . is for anything that doesn't (or that explicity passes self)
Exactly. I'm saying this.
but you mentioned Kahlua/TIS's implementation, that's what threw me off - it's not specific to that
I've clarified already that Kahlua uses .new for Java classes that are exposed.
x and fbx
https://imgur.com/jeB9ytG not smooth but will work on it (personal proj this time)
its just shove
heh nice
]so its never gonna be solid unless i do somehit reaction to the zed
idk how to do that via xml so i guess ill have to do it using lua
๐
right, but the discussion we're having is about why inheritance with ISBaseObject won't work for static methods
and I think the reasoning is that ISBaseObject makes a mistake in using :new() when it should be .new() and identify self as a new object within the constructor, rather than assigning the metatables/meta flags to the ISBaseObject class via self
Yeah there's static-like code being implemented as instanced code in the codebase. I haven't seen ISBaseObject's example yet.
whats the right way to get the resolution that the game is running? I only know getPlayerScreenWidth() and that give my screen resolution and not the game
no theres no mistake in the implementation
-- vanilla
function ISBaseObject:new()
local o = {}
setmetatable(o, self)
self.__index = self
return o
end
-- cleaner, fixed static function encapsulation
ISBaseObject.new = function()
local self = {}
self.__index = self
return self
end```
the self parameter is needed for the inheritance to work
your version is not going to work
the vanilla way, yes - but not really
that's one way to do it, but it's not the best way (imo)
Im also going to make use of spear stab anim for the shove of the riffle with bayonet but im not sure if its possible
Is it?
local newClassLmao = {}
newClassLmao.new = function()
local self = ISBaseObject.new()
return self
end```
this is what inheritance would look like, if you want to keep proper static encapsulation (using the above change to `ISBaseObject`)
and it does
but youre already doing it wrong having to call the new of the parent
that's not "doing it wrong" if it maintains encapsulation
(and it does, unlike the vanilla way)
I'm fine with using :new() for now.
to explain why that's "the right way": any static members shouldn't be inherited with the class, because static members are inherently (lol) tied to the class. if you're trying to pass those members down, they shouldn't be static in the first place
and that's perfectly fine, if encapsulation isn't a goal of yours (and it doesn't really need to be if you know what you're doing and you aren't expecting other people to use your code, but otherwise it's not clean)
the issue with this is that it wont inherit any method at all from the parent
sure it will, just none that are statically defined
can someone explain wtf is going on with __index and setmetatable there anwyay? while i've picked up lua i still have no fuckin idea
(or private, naturally)
not statics nor instance
he doesnt understand whats happening either
read here
i gather setmetatable associates a lua-interpreter-internal kind of table for something
but that's about the extent of my understanding lmao
setmetatable just copies the existing metadata from whatever table you supply, while __index is a meta flag that changes the behavior of the table's accessors
right so by what youre saying if i add instance methods to ISBaseObject then it will inherit?
huh
yup! as long as you aren't making them private or static, by OOP terminology
such weird stuff, as someone who comes from C# and Python
right ill prove you wrong real quick then
okay!
yeah metatables and the flags associated with it are weird, but they're fairly straightforward once you understand them. think of them as "table traits" that define the behavior of a table
because that's a static function, my friend
I don't know what you expected when you wrote it wrong lmfao


you still dont understand
I don't think you understand
if you're trying to emulate OOP, this is how it's done
anything that isn't explicity added to self is static (or if it's local, then it's private)
which is how encapsulation is maintained - only data added directly to the object should be passed via inheritance to any child classes
that's OOP 101
massive facepalm having to explicitly declare every function
Suppose you have a file with a lot of small functions, those functions are then called in another big function which is then added to OnEvent callback. How can i overwrite just that one small function of someone else mod?
massive facepalm not understanding encapsulation workflows in a language that wasn't explicitly designed for it
there are two options - name the file like ZZZ which will overwrite function or copy the one with big function and all others, but maybe theres cleaner way to overwrite function?
if those functions are local, you can't
they dont have local keyword, ok so i can overwrite them in other file
yup! just do ModNameOrWhatever.FunctionName = function() <your code> end
Im just modding for myself, but i want to prevent steam erasing my shit if the mod update
what is the name of this application
is there a way to override locals besides overriding the whole file, some lua dark magic perhaps?
also you can do Events.<whatever>.Remove(ModNameOrWhatever.FunctionName) if you just want to remove it from the event handler, I believe
while im asking people who know more lua than i
there is but not in kahlua at least exposed
damn
not as far as I'm aware, that'd be "reflection" in Java and Lua has no counterpart that I'm aware of
if namespaces are global[?] couldnt we just overwrite like that "namespace.functionname"?
you can get the stack for a given function and overwrite the value at that memory location with debug functions
yup!
even if function is local?
that makes sense
if it's local, then passed into the namespace (MyNamespace.FunctionName = localFunction) then yes, you can still overwrite
because you're overwriting the reference to that function, not the function itself
right, exactly
