#mod_development

1 messages · Page 229 of 1

river anvil
#

Does it require changing up something in different parts of the game files, or am I just missing some flag from my script file? Ngl it's my first time ever actually trying to do something like that so I just went and edited my local "clothing_bags" script file. I did manage to successfully add the item, give it a texture, make it a container but I can't figure out for the love of god how to make it wearable on other parts of the character than the back. I tried CanBeEquipped = Neck, but then I wouldn't get any equip actions in the context menu, tried it with a Clothing = True but that didn't do anything, but when I changed it back to CanBeEquipped = Back it does work as intended so I suppose I'm missing something silly SCwtf

echo lark
#

ooh thanks ill look into that

bright fog
river anvil
bright fog
#

np

hallow cradle
bright fog
#

Expired links

#

Most likely

hallow cradle
#

make sense

#

so imgur is bad site

bright fog
#

yup

#

Use github

hallow cradle
#

can't share with others thats probably why i couldn't put

hallow cradle
bright fog
#

Use Github Desktop and you can link your mods to it to easily have a follow of all the changes you make on your mods

hallow cradle
#

btw will it work if folder is private or it must be a public

bright fog
#

I can test that out

hallow anvil
#

what settings should I use to export my clothing into fbx?

coarse sinew
hallow cradle
#

bruhhh

bright fog
#

LMAO

#

What have you done xDD

hallow cradle
bright fog
#

wuut

hallow cradle
#

i guess they don't like it

#

i got lost there xd

bright fog
#

How did you put a png in there ?

hallow cradle
#

drag and drop

#

IQ move 1000

bright fog
#

lmao there's no way your account got insta suspended

hallow cradle
#

after that

bright fog
#

how long ?

hallow cradle
#

idk

#

mabey they flag me as bot

bright fog
#

bruh

hallow cradle
bright fog
#

hmm

#

I don't have that issue

bronze yoke
#

some vanilla systems (especially lua) aren't ready until OnGameBoot fires, and it leaves room for other mods to mess with your code (e.g. variables for settings) before it actually runs; it also means you can have some confidence that your code will run after *most* modded code when that's useful

OnGameBoot fires every time lua is reloaded, so you don't need to restart the game to trigger it

peak nymph
#

Hi all, hopefully a quick question, how possible is it to add custom attributes to items, like would I be able to add a value such as quality or chance of breaking that can be set on item crafting/creation, and on a similar note would values similar to a frozen value/bar but for a custom attribute instead, or is this not possible within the lua

bronze yoke
#

you can add any arbitrary value to an item's script, any attribute the game doesn't recognise will be added to the item's default moddata

bronze yoke
#
-- in the item script
item MyItem {
    myCustomValue = 5,
}

-- accessing it in lua
item:getModData().myCustomValue
bright fog
#

Amazing

#

That's very cool

bronze yoke
#

you can add these to existing items with DoParam but this doesn't work great because only newly spawning items will have the default moddata added

bright fog
bronze yoke
#

no

#

old items will never have their moddata changed by this, it's not 'default' if it overrides existing items

peak nymph
#

would it be possible to display these custom values on the item tooltip?

bronze yoke
#

it is possible, not nearly as simple though 😅 you can hook into tooltip drawing code and add your own stuff there

bronze yoke
# bronze yoke ```lua -- in the item script item MyItem { myCustomValue = 5, } -- accessin...

by the way, if the value isn't something that can change per instance of the item, it's a bit wasteful to do this as it'll store the value separately for every single instance - it's a lot cheaper to just have a table in lua storing the values per item type:```lua
local myValues = {
["MyModule.MyItem"] = 5,
["MyModule.MyOtherItem"] = 10,
}

myValues[item:getFullType()]

#

no idea what you're actually trying to do with this so i don't know which one is better for your case

peak nymph
#

it was per instance, had two things in mind, one was chance something would break when used, the other was a system similar to pickle items individually in a large container, so would make an item “pickled” when submerged long enough, and to have a longer spoil time while it remains pickled, but shorter if it is removed

#

might not do the second one, just something I was thinking about

#

thanks for the help though, it’s something to get me started

grizzled fulcrum
river anvil
#

Also hi Elyon sad_cat

coarse sinew
river anvil
#

big brain idea

#

not sure why I haven't thought of that SCwtf

coarse sinew
#

And why you need a necklace with a container

bright fog
#

Also make like a keyring visible you know would be amazing 👀

mystic vessel
#

i have a question

#

how hard it's to make a lua file, that Reads all clothing made from such material, and makes a repair recipe

Example: Leather jackets

So any leather jacket will appear in this recipe and can be fixed. it's possible?

bright fog
#

Perhaps check the rip clothing craft ?

mystic vessel
#

but how i will do to repair the clothing especific?

bright fog
#

Aaah you want a crafting recipe that fixes holes in clothing ?

mystic vessel
#

This involves my mod, that if the person stays close to the sewing table they can do this

bright fog
#

hmm

#

Interesting

#

Well you need to trigger a custom function that checks for the clothing within the player inventory (select a specific clothing or do it for every clothing) and then find how to repair holes in clothing

steady lagoon
#

hey folks, how can I override a vanilla recipe? I copied over the Refill Propane Torch recipe and added Override:true, but it is not replacing the original, it creates a duplicate in the menu.

#

Refill Blow torch*

echo lark
#

i asked this earlier today and was given a lead but it didnt pan out. Does anyone know if you can make an item, in this case a Wooden Sewing Needle to break after a certain ammount of uses? or just break randoming when using it?

echo lark
robust briar
#

Alright, I have spent like 40+ hours trying to spawn a tree... Like, I can "make" a tree with brush tool by selecting the trunk and leaves, but its not a proper tree... The leaves are supposed to be "attached" to the main sprite, and some internal data is set to track the season/etc.

I have dug through the java.. extensively. This system is extremely complex (yet kind of simple at the same time) and I think I have an idea of how all the pieces work together:

ErosionMain, ErosionChunk, NatureTrees, ErosionData.

I have gone so far as setup a build environment, make java mods, add a new lua function, and try to manually call into the appropriate functions to get the game to "plant a tree" properly (like I say make a dogwood here, growth stage 4) and it puts the trunk and appropriate leaves on.. but I just can not figure it out..

My current lua:

function createTree(square, type)
    if isClient() then
        local x, y, z = square:getX(), square:getY(), square:getZ()
        sendClientCommand("WL_Utils", "createTree", {x, y, z, type})
        return
    end
    if not square then return end
    local tree = IsoTree.new(square, type)
    tree:initTree()
    square:transmitAddObjectToSquare(tree, square:getObjects():size())
    forceSquareUpdate(square)
end

if isServer() then
    Events.OnClientCommand.Add(function(module, command, player, args)
        if module == "WL_Utils" then
            if command == "createTree" then
                local square = getCell():getGridSquare(args[1], args[2], args[3])
                createTree(square, args[4])
            end
        end
    end)
end

--- Assume called with
createTree(getPlayer():getSquare(), "e_dogwood_1_3")

And the java mod:

public class GravyLua {
    @LuaMethod(
        name = "forceSquareUpdate",
        global = true
    )
    public static void forceSquareUpdate(IsoGridSquare gs) throws Throwable {
        ErosionMain em = ErosionMain.getInstance();
        if (gs != null && gs.chunk != null && gs.getZ() == 0) {
            IsoChunk ch = gs.getChunk();
            Chunk chMd = ch.getErosionData();
            ErosionData.Square gsEd = gs.getErosionData();
            
            ErosionWorld world = getWorld(em);
            world.validateSpawn(gs, gsEd, chMd);
            world.update(gs, gsEd, chMd, getETicks(em));
        }
    }
    
    private static ErosionWorld getWorld(ErosionMain em) throws Throwable {
        Class<ErosionMain> cls = ErosionMain.class;
        Field fld = cls.getDeclaredField("World");
        fld.setAccessible(true);
        return (ErosionWorld)fld.get(em);
    }
    
    private static int getETicks(ErosionMain em) throws Throwable {
        Class<ErosionMain> cls = ErosionMain.class;
        Field fld = cls.getDeclaredField("eTicks");
        fld.setAccessible(true);
        return fld.getInt(em);
    }
}

I just... I pray someone can help me. I will pay you...

#

If I could just figure how how a tree is initially seeded... in the java I will go from there

verbal yew
bright fog
vast current
#

I have.... the most frustrating bug I've come across in a long while, and nothing I have done has fixed it or mitigated it.
Basically, this is stemming from a weather controller, where right now the only event is manually called
When it starts, it creates a "modded" weather period and adds in various stages, and this will work after waiting a while, maybe starting other random weather, but not if the world has just freshly started (even after a minute or two)
No matter what sanity checking I do (ranging from checking if the climate controller is even valid), even specifically adding the supposedly missing strength values to the custom stages, this will crash the world without fail if fired off within a few minutes of loading

#

last thing I can think of doing is maybe starting a vanilla weather period and turning around and killing it before starting this if the current session is under a certain time, but thats just rediculous

verbal yew
#

setMutualExclusive It's only on create menu?`

bronze yoke
#

yeah, trait object is mostly just for create menu

muted garnet
#

please tell me, does anyone know how I can tie two UI windows between two players, so that when one of the players closes his window, the second player’s window also closes? And please explain what the player means after the IGUI, since the player’s name is not displayed in the game


function Window:onAnswerRequest(button)
    if button.internal == "NO" then
        print("123")
        print("123")
        print("123")
    end

    if button.internal == "YES" then
        print("1234567890")
        print("1234567890")
        print("1234567890")
    end

    if button.internal == "OK" then -- CANCEL BUTTON
        print("00098")
        print("00098")
        print("00098")
    end

end

 Events.OnServerCommand.Add(function(module, command, args)

    if command == 'TradeRequestReceived' then

        local playerObj = getPlayerByOnlineID(args[1])
        local modal = ISModalDialog:new(getCore():getScreenWidth() / 2 - 175,getCore():getScreenHeight() / 2 - 75, 350, 150, getText("IGUI_Window_Request", playerObj:getDisplayName()), true, nil, Window.onAnswerRequest);
        modal:initialise()
        modal:addToUIManager()
        modal.requester = playerObj;
        modal.moveWithMouse = true;

    elseif command == 'TradeRequestSent' then

        local clickedPlayer = getPlayerByOnlineID(args[2])
        local modal = ISModalDialog:new(getCore():getScreenWidth() / 2 - 175,getCore():getScreenHeight() / 2 - 75, 350, 150, getText("IGUI_Window_SentRequest", clickedPlayer:getDisplayName()), nil, true, Window.onAnswerRequest);
        modal:initialise()
        modal:addToUIManager()
        modal.recipient = clickedPlayer;
        modal.moveWithMouse = true;

    end
    
end)
verbal yew
#
if state1 then
 elseif state2 then
 elseif state3 then
 elseif state4 then
end

if i have state3 and state4, it's trigger only state3, right?

bronze yoke
#

yeah

verbal yew
# bronze yoke yeah

but if i have state1 and it's trigger first and create state2

if state1 then
    state2 = true;
 elseif state2 then
 elseif state3 then
 elseif state4 then
end

state2 be triggered?

bronze yoke
#

no

#

elseif statements are only evaluated if the previous statement was false

vague bay
bright fog
#

Oh wait that's for decompiling ?

vague bay
coarse sinew
bronze yoke
#

the konijima guide is very old and getting increasingly impractical to follow

#

iirc it doesn't work in newer versions of intellij without some configuration

#

and if you're doing it for the type stubs it generates they're significantly worse than umbrella's which don't require you to manually generate them

#

imo umbrella + beautiful java (or even any generic java decompile tool really) replaces capsid completely

vague bay
#

for starters I want to modify the vehicle framework for me and my friends, but as i checked the lua documentation there aren't any lua events that deal with what i want (?) unless i am mistaken. what i aim to do is modify vehicle behavior on zombie collision such as speed, damage, conditional damage based on body work, etc (bespoke tweaks's)
so if i want to do these am i correct in setting up a workspace to decompile the game?

bright fog
bright fog
#

Probably the same at least

bronze yoke
#

yeah vehicle behaviour is java stuff, i recommend using beautiful java or some standard java decompiler over this guide still

vague bay
bronze yoke
#

it's not really a good place to dive into modding though, almost nobody does java modding so you won't be able to find much documentation or help

bright fog
#

Yup lmao

#

Like recompiling

bright fog
upbeat sequoia
#

recompiling seems like a unicorn guide

bright fog
#

Not sure if I'll be able to find it back tbf I don't use it

vague bay
#

So what's the recommended steps to develop a java mod ?

bright fog
#

You don't lmao

#

I mean like there really is not much about it

candid ridge
#

The IntelliJ's compiler is bad

#

Compared to cjr

#

I've just compared both of them and IntelliJ seems to assign variable names like var01, var02 and so on

#

Is there no official decompiler from Project Zomboid?

bright fog
#

Yeah, which isn't that bad tbf

bright fog
candid ridge
#

Well that's just how modding works

bright fog
#

Give the tools to people to steal their work, sure go on lmao

candid ridge
#

By decompiling java source it's more easy to create client sided cheats

#

Unless your going to start obfuscating code

bright fog
#

Well, yeah ofc

#

But the point of decompiling for modders isn't to make cheats

candid ridge
#

🤷

#

There's always two sides of a coin

bright fog
#

Doesn't make it less an issue that giving the tools to decompile your code means giving half the tools to steal your game

vague bay
bright fog
bronze yoke
#

no, that's some dota crap that decided to use the same name as us a year later

candid ridge
bronze yoke
#

not that we own such a generic name but it's a real pain 😅

bright fog
# vague bay ?

Install Lua, then ctrl shift P > addon manager > seafch Umbrella

candid ridge
#

And use encryption keys which only PZ can decompile it during run time

#

That'd kill modding

bronze yoke
#

it's kind of a waste of time

bright fog
upbeat sequoia
#

honestly this wouldnt be that much of an issue if lua modding had more access to tweaking a lot more in the game rather than just having to go through a lot of decompiling effort

bronze yoke
#

the game has a lua interface to most of its api, all you need to cheat is an injector

candid ridge
bronze yoke
#

restructuring the game's networking so that security is actually remotely possible is a much better solution than just trying to slow down hackers with obfuscation

candid ridge
#

What we are doing now is also decompiling the game source code to understand or modify it in a way it's never intended by the devs

upbeat sequoia
#

i think the game's netcode needs restructuring either way

bronze yoke
#

nearly everything is client auth, cheaters are basically omnipotent

candid ridge
#

Yeah basically that

#

Need to move to server sided auth

#

Game has no anticheat, I don't know if it even has some sort of authentication with steam when using cracked clients

bronze yoke
#

i think anyone serious about modding should decompile, you're very limited when you can't actually see what the api does, but java edits and recompiling is almost never done and you're not likely to find any resources regarding it

vague bay
#

do you know any mods I can look up as reference ?

vestal gyro
#

I think with vanilla pipebombs/molotovs the player who throws them has to look at them till they land

#

And if they throw them but get killed before it lands nothing happens

upbeat sequoia
#

lmao

vestal gyro
#

Also if you throw it out of a car the explosion will visually happen on the car where it got thrown from

thick karma
# bronze yoke not that we own such a generic name but it's a real pain 😅

I feel like a little image on the GitHub clarifying this would spare a lot of new people trouble when trying to install Umbrella. I've seen several people get this wrong. I know the instructions are clear if you follow them but it is human to think you recognize a process when the words sound very similar to a process that you are familiar with following.

#

Just my two cents

#

Which are figurative and therefore actually worth 0 cents

bronze yoke
#

i don't really know how we'd demonstrate it

peak nymph
#

Hi all, does anyone know why when I use :setSprite on my Iso object it seems to lose collision and context menu items, like using setsprite seems to be turning it into nothing but a sprite as far as the game is concerned, was using tchernolib so tried to update spritename by the update function in the but it had no visual effect, so tried using setSprite and getting this
anyone have any ideas what I'm missing?

edit: using setSpriteFromName instead seems to work 🤷

rough aurora
#

Good afternoon guys! I was looking how campfire is defined so I can take a idea for a new container that will be able to burn, but i am no able to find where campfire is defined... anyone knows?

bright fog
#

Perhaps

#

Check the java of isCampfire() and what it access

#

Perhaps it links to another IsoObject

bronze yoke
#

it's a global object

#

look in client/Camping/ and server/Camping/

grizzled fulcrum
rough aurora
thick karma
#

That's how I do it at least

hallow cradle
#

@bronze yoke you look like u know this game better than devs xd

woven horizon
#

i want to add the civilian bullet vest and beret to the ranger outfit have tried to change xml but not working ?

maiden monolith
#

does anyone here want to make mods exclusively for my server for a wage?

bright fog
#

Click that and it leads you to an invite to the server

maiden monolith
bright fog
#

You can even make a post in #project to shard your plans

maiden monolith
bright fog
#

And you can ask that in the server lmao

#

Also if you plan on doing such a thing I suggest you open a legal business for this kind of things

#

Anyway you can ask for modders, commissions or more, on the link I sent so you do yours

maiden monolith
#

im not joining a modders server. the modder will be joining my server

bright fog
maiden monolith
bright fog
#

You can tell modders to then join your server lol

maiden monolith
#

+like just let it go its nothing to do with you

#

do you have to keep commenting on everything

bright fog
maiden monolith
mild sundial
#

Hello, new to modding, I want to make a mod that will reset the water/power timer and the radio/TV Shows as if it was day 1, independently of the game calendar, so the time and seasons would still go on, but the water, power, radio, and TV shows will reset periodically, can you throw me into the right direction?

river anvil
#

just wanted to try and do something fun

gilded hawk
#

In vanila pz how are .ini files loaded and parsed? I'm struggling to save data to files at the moment

gilded hawk
mellow frigate
gilded hawk
torn igloo
grizzled fulcrum
#

Is there a way to add dynamic translations? If not, I will make an api for it

#

I am just asking because I didn't see any on the workshop and there'd be no point in me reinventing the wheel

frank elbow
#

What do you mean by dynamic translations? Adding a string translation from Lua?

frank elbow
grizzled fulcrum
#

Having translations that change dynamically and are not static definitions

mellow frigate
grizzled fulcrum
#

for example tranlsation strings in a pool to be selected at random (so for example the moodle description translations aren't always the same)

bright fog
#

That's already doable I'm fairly certain lol

#

You can always randomize the choice within a table of strings

frank elbow
#

I see. I think generally that's done by appending a number & using randomization to determine the number

grizzled fulcrum
#

true it is already doable but I don't see a reason not to have an api where it's not having to be implemented differently in every mod

#

I only thought of this because I hate how static the text seems for the ui

mellow frigate
frank elbow
#

I'm unsure the Translator class exposes enough to make that feasible with just Lua, although I'm not at my home computer to confirm

#

So without a Java mod you could override the getText functions and it'd work Lua-side, but wouldn't be able to affect the Java getText calls

grizzled fulcrum
#

I could make the api work for vanilla translations too if thats what you mean

mellow frigate
mellow frigate
frank elbow
#

Write a converter for the project zomboid translation files to ftl, boom. But I imagine that'd be a hard sell to the devs

grizzled fulcrum
frank elbow
#

I think Tchernobill is talking about dynamically overriding vanilla strings, if I'm not mistaken. Like we can override them in translation files

grizzled fulcrum
#

if thats so vanilla can have dynamic translations too then I don't see why just overriding them and letting mods specify what to override with would be a bad option?

mellow frigate
grizzled fulcrum
#

I could just override getText on the lua side then to my own implementation then right?

#

or am I missing the whole point ;-;

frank elbow
#

It wouldn't affect Java-side calls

grizzled fulcrum
#

oh well I don't think there's a way to directly affect java stuff from lua side unless it's reflected (in some way im not sure how)

frank elbow
#

Yep, which is the problem

mellow frigate
grizzled fulcrum
#

so that the same key returns a different translation based on a variable (among other things)?

#

so something like this as an example?

local isDead = false
getText("Vanilla_IsDead") -- returns "I am not dead!"
isDead = true
getText("Vanilla_IsDead") -- returns "I am dead :("
#

I am like 99% sure I am just so bad that im missing the point entirely

#

not sure why I can't piece it together

frank elbow
#

I can imagine a setText('VanillaKey1', 'Text1_2') call between the two example getText calls given, rather than being based on variables directly

#

(setText being a made-up function, with a name derived by analogy to getText)

grizzled fulcrum
#

why would you want it to directly effect java side calls anyway?

frank elbow
#

For the same reason you'd want to affect Lua-side calls

grizzled fulcrum
#

I don't see there being a point besides having vanilla game translations be dynamic (like "Extremely Heavy Load" moodle) but then you'd just be able to do that on lua side anyway

frank elbow
#

To change the text that's retrieved. Take, for example, the sneeze and cough text that appears when the player is sick. The calls for these are hardcoded in Java

mellow frigate
grizzled fulcrum
#

is there like any example I can work with

#

from the game preferably like a test string or something

frank elbow
#

See the last message I sent

#

I don't remember the exact string name but if you search “Cough!” you'll find it in the translations

grizzled fulcrum
mellow frigate
frank elbow
mellow frigate
grizzled fulcrum
#

but what is stopping you from overriding it? (the translation not the key)

frank elbow
#

As in, doing so in a translation file?

#

Nothing is preventing that, but that wouldn't be dynamic

grizzled fulcrum
#

yes but that'd fall more towards the lua side which is 100% doable

frank elbow
#

I mean the key is hardcoded, to be clear

mellow frigate
frank elbow
#

There are Translator.getText calls Java-side

mellow frigate
frank elbow
#

Teleportation is real confirmed

grizzled fulcrum
rich reef
#

Hello all, I have a quick question I hope someone can help me with.

I have 4 recipes that use wallets to search for money within them, and then returns an empty wallet upon searching, depending on the wallet that was used.

When I right click on the group of wallets to run the recipe, I have to click 4 separate times on the same pile, as they are 4 different wallets.

Is there a way to run the script on the entire batch of wallets in one click instead of having to do it 4 total times?

Appreciate any advice, thank you!

grizzled fulcrum
rich reef
# grizzled fulcrum like an "Open All" button?

Yes, I suppose that would be the case here. All the wallets are piled together under the item name "Wallet", but their are 4 variants, Wallet, Wallet2, Wallet3, etc. So when it gives the option to run the recipe, it only runs it on one set of wallet types at a time, instead of all of them.

mellow frigate
rich reef
mellow frigate
rich reef
#

Thank you Tchernobill.

#

So I will run this function from the recipe onCreate, and then within this function, run my own script?

grizzled fulcrum
#

also tchernobill if you don't mind could you explain more about the translation stuff? I want to know what you want to see if it'd be possible.
There's a few routes I believe I could take, and if it has some use cases then id be glad to help if I can

grizzled fulcrum
#

so all you need to do I think is check if your wallet is the item being clicked (where they wrote the comment) and do whatever you want after that (run the wallet search code for each wallet)

rich reef
#

Thank you aoqia, appreciate the help!

grizzled fulcrum
#

I did nothing, tchernobill was 99% of the help 😭

rich reef
#

Well, I am very grateful for both of your help and insight.

gilded hawk
#

Does anyone know why player:setZombieKills does not seem to work in MP?

bright fog
gilded hawk
#

Is there a way around this?

bright fog
#

Have you looked in the java ?

gilded hawk
#

Not really, but good idea

#

I'll have a look

bright fog
#

You definitely should

grizzled fulcrum
#

any guides on decompiling the java? I plan on looking at the game code myself

grizzled fulcrum
#

ty

muted garnet
#

please tell me, does anyone know how I can tie two UI windows between two players, so that when one of the players closes his window, the second player’s window also closes? And please explain what the player means after the IGUI, since the player’s name is not displayed in the game


function Window:onAnswerRequest(button)
    if button.internal == "NO" then
        print("123")
        print("123")
        print("123")
    end

    if button.internal == "YES" then
        print("1234567890")
        print("1234567890")
        print("1234567890")
    end

    if button.internal == "OK" then -- CANCEL BUTTON
        print("00098")
        print("00098")
        print("00098")
    end

end

 Events.OnServerCommand.Add(function(module, command, args)

    if command == 'TradeRequestReceived' then

        local playerObj = getPlayerByOnlineID(args[1])
        local modal = ISModalDialog:new(getCore():getScreenWidth() / 2 - 175,getCore():getScreenHeight() / 2 - 75, 350, 150, getText("IGUI_Window_Request", playerObj:getDisplayName()), true, nil, Window.onAnswerRequest);
        modal:initialise()
        modal:addToUIManager()
        modal.requester = playerObj;
        modal.moveWithMouse = true;

    elseif command == 'TradeRequestSent' then

        local clickedPlayer = getPlayerByOnlineID(args[2])
        local modal = ISModalDialog:new(getCore():getScreenWidth() / 2 - 175,getCore():getScreenHeight() / 2 - 75, 350, 150, getText("IGUI_Window_SentRequest", clickedPlayer:getDisplayName()), nil, true, Window.onAnswerRequest);
        modal:initialise()
        modal:addToUIManager()
        modal.recipient = clickedPlayer;
        modal.moveWithMouse = true;

    end
    
end)
clever palm
thick karma
muted garnet
grizzled fulcrum
#

burryaga has good advice

grizzled fulcrum
muted garnet
#

Does anyone know how I can prevent the player from pressing the right mouse button during ISModalDialog, like in vanilla with the trade system, but without changing the vanilla worldobjectcontext code?

boreal condor
#

Hi guys! I'm trying to avoid repeating recipes over and over, for example if I wanted to add Sliced Fruit to the game:

  1. I currently have to manually enter all the fruits in the recipe, for example "Peach/Pineapple/Cherry/"etc.. Can I create a collection somewhere, and call it Fruits? (or if I wanted to add custom items that aren't Fruits in the game files, for example Tomato) Something similar to [Recipe.GetItemTypes.SharpKnife] I see FoodType = Fruits, in them but I can't seem to get them that way.

(That would help me so I can just modify the collection when I need to add items, instead of having to check the whole list one by one, everywhere I use it)

  1. (This is probably a no) is there a way for a recipe to return the ingredient used? seeing the code block:
recipe Slice Fruit
{  
    Peach/Pineapple/Cherry/Grapes,
    keep [Recipe.GetItemTypes.SharpKnife]/[Recipe.GetItemTypes.Saw]/Axe/HandAxe/AxeStone/WoodAxe/MeatCleaver,
    Result:Mymod.SlicedFruit,
    Sound:PZ_FoodSlicing,
    Time:80,
    Category:Cooking,
    OnGiveXP:Recipe.OnGiveXP.Cooking3,
    AllowRottenItem:false,
}```

SlicedFruit is a generic object, but I'd like it to be Sliced Peach, Sliced Pineapple, etc. Do I have to create the recipe block over and over and just make it with the specific fruit? or how can I grab the ingredient used for the recipe, see that it's a Peach, for example, and then replace SlicedFruit with SlicedPeach
bronze yoke
#

you can create a custom GetItemTypes lua function to return whatever items you want, and you can use an OnCreate function to implement custom functionality such as changing the result item based on the source

boreal condor
bronze yoke
#

the best way is to look in media/lua/server/recipecode.lua to see how the vanilla ones work

#

iirc GetItemTypes just passes an arraylist of strings, which you're expected to insert the full types of applicable items to

boreal condor
#

thank you! I'll have a look

muted garnet
#

Does anyone know how I can prevent the player from pressing the right mouse button during ISModalDialog, like in vanilla with the trade system, but without changing the vanilla worldobjectcontext code?

austere sequoia
#

Hey guys! Does one of you know where I can find vanilla item icons?

bronze yoke
#

they're in the UI texture packs

#

if you're just looking for a specific one or something it's a lot easier to grab them off the wiki than to extract it

austere sequoia
#

Great idea, I will just do that, thank you!

muted garnet
#

Does anyone know how I can prevent the player from pressing the right mouse button during ISModalDialog, like in vanilla with the trade system, but without changing the vanilla worldobjectcontext code?

peak nymph
#

Hi all, does anyone know how i'd go about configuring/creating a tile so that it can be placed inside a container for distribution, like how the antique oven can be found in warehouse crates (I know very little about tiles and moveables so assume I know nothing)

verbal yew
#

how load priority for lua?
for example (all this overwrite same aspect):

name_mod1
folder/lua/server/c.lua

name_mod2
folder/lua/server/npcs/a.lua

name_mod3
folder/lua/server/traits/b.lua

#

i mean... like... load mod priority have weights for this or last lua overwrite all, like !!overwriter3000.lua or zzzzMyMod.lua

bronze yoke
#

the mod order set by users has no affect on lua, lua files always load in alphabetical* order

#

if they all overwrite the same thing whichever one loads last will overwrite whatever the previous files did

verbal yew
bronze yoke
#

files load shared -> client -> server, all files from that folder will load before any files from the next

#

and all vanilla files load before modded files

#

if a mod overwrites a vanilla file, it will take that file's spot in the normal vanilla file load order, and iirc the mod set to load last takes priority

bronze yoke
verbal yew
#

hmhmmhmh....

#

name_mod1
folder/lua/server/a.lua

name_mod2
folder/lua/server/npcs/a.lua

mod2 overwrite a.lua in mod1?

#

total (same name)

bronze yoke
#

no, it would have to be in the same subdirectory

#

the full path after client/shared/server is what's considered

verbal yew
bronze yoke
#

yeah

verbal yew
#

understrood, thanks

bronze yoke
#

it also uses the path for sorting (so server/a.lua -> server/a/z.lua -> server/b.lua )

slow graniteBOT
#
anaveragerat has been warned

Reason: Bad word usage

crystal oar
#

can someone remind me how to add requirements to the mod info?

stable wren
#

Does anyone know how to play mp3 or music stuff using RakVoice?

#

(long long1, long long2, byte[] byteArray, long long3) - what's that about ;-;?

#

I can use RakVoice.SetChannelsRouting to create a custom radio channel but idk how to send sound to them

muted garnet
#

Does anyone know how I can prevent the player from pressing the right mouse button during ISModalDialog, like in vanilla with the trade system, but without changing the vanilla worldobjectcontext code?

steady lagoon
#

Does anyone have a good comprehensive modding guide for vehicles? I would like to edit the property of a trunk of my custom vehicle.

hallow cradle
#

Hi everyone. This is code from VHS first aid mode: { text = "RM_1536de5b-09ea-4fec-9c34-fc34d42e7351", r = 0.80, g = 0.50, b = 0.00, codes = "BOR-1" }, -- You are watching, KY Medical Frontline!

#

I see diffrent for every other dialog

#

why

#

and how and from where did he/she get this numbers from?

echo lark
echo lark
#

its just a random generator with so many possibilitys its almost impossible for two of the same strings to be generated ensuring theres no fuck up between mods and stuff

hallow cradle
#

so GUID is not necessary for VHS right ?

bright fog
#

Possibly not I guess

hallow cradle
echo lark
bright fog
#

Yeah I see what they did here

#

Basically used GUID (but not mandatory in this case) to make sure their lines are unique from other mods

#

He could have given a unique them to all of them I think and it would have most likely worked

echo lark
#

yeah, could have put like anything there realy

bright fog
#

But at least using that, they are sure that their variable names won't get overwritten by another mod

#

tho they could have just done:
modNameVHSNameLineNumber_N
and increment that
and would most likely have still been unique

wheat raven
#

Does anyone have a working and/or updated version of WordZed? I'm looking to make a radio mod and the original seems to be gone from the forums.

peak nymph
#

might be a long shot but does anyone know why WorldObjectSprite wouldn't be reading my tile properly from my pack or .tiles file
pulling it in to item like this

  {
    Type = Moveable,
    Icon = ElectricKiln,
    Weight = 25.0,
    DisplayName = Electric Kiln,
    DisplayCategory = Moveable,
    WorldObjectSprite = hiemsk_tiles_3,
  }```

that is the correct tilesetname
as I am using hiemsk_tiles_2 in a lua file fine

but when I try place the item (hovering over place I want to place it, not yet placed) I get this error a lot on loop

ERROR: General , 1713272923911> ExceptionLogger.logException> Exception thrown java.lang.reflect.InvocationTargetException at GeneratedMethodAccessor570.invoke.
ERROR: General , 1713272923912> DebugLogStream.printException> Stack trace:
java.lang.reflect.InvocationTargetException
at jdk.internal.reflect.GeneratedMethodAccessor570.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
...
Caused by: java.lang.NullPointerException: Cannot read field "offsetX" because "<parameter1>" is null
at zombie.ui.UIElement.DrawTexture(UIElement.java:316)

When I do place it the tile has no sprite in game

I'm really not sure what I am doing wrong, have been taking apart other mods and can't see whats different
coarse sinew
echo lark
#

I got a question about using OnCreate in recipes. ive been searching the discord and found a method to do what i want, but im curious if theres a better way. currently i have seperate functions to do the same thing for diferent weapons, the code uses oncreate to set the weapons condition back to its max and the code works. but im wondering if i could generalize the function and use 1 function for all the weapons i have insatead of making a new function for each weapon.

peak nymph
echo lark
#

baically trying to figure out if i could pull the item being used in the craft and repair that, instead of having to specify which weapon to repair. so i can use one function for all the repair recipes

coarse sinew
peak nymph
peak nymph
echo lark
#

just trying to figure out if instead of specifying in the function to check for a particular item, i could change it so that it only checks the first item used in the craft or something

#

very new to lua coding so, not sure whats possible

peak nymph
coarse sinew
# echo lark I got a question about using OnCreate in recipes. ive been searching the discord...

if I understood correctly what you want to do, you can use this

function Recipe.OnCreate.SlapMWGeneralRepair(items, player)
    local itemToRepair = nil
    local repairableItems = {
        ["SlapMW.BladeOfBlue"] = true,
        ["SlapMW.OctoSword"] = true,
        -- add other repairable item full types here
    }

    for i = 1, items:size() do
        local item = items:get(i-1)
        if repairableItems[item:getFullType()] then
            itemToRepair = item
            break
        end
    end
  
    if itemToRepair then
        local condition = itemToRepair:getConditionMax()
        itemToRepair:setCondition(condition)
    end
end
echo lark
echo lark
coarse sinew
#

the first item it finds in the items list

peak nymph
echo lark
#

then that would be perfect, ill test it out. thanks!!

coarse sinew
#

I guess you won't repair 2 items from the repairableItems table in the same recipe

peak nymph
echo lark
#

no i dont wna repair them all, only the weapon that was right clicked in the repair

peak nymph
#

I think first one should be fine then

echo lark
#

basically the vanilla fixign system reverts the weapons stats on repair. so if we hand out event items which stats we have changed it gets reverted

#

so im making a recipe that requires the weapon + other items that we will hand out during events to fix the event weapons

#

so the recipe i have has an oncreate to set the durability back to its max

#

but i didnt wana have like 20-30 seperate functions that all do the same thing if i could generalize it more to one function

peak nymph
peak nymph
echo lark
verbal yew
#

its possible to get hit bodypart on target from OnWeaponHitCharacter?

bright fog
#

The issue I think is that there isn't anything that checks body part hit and shit like that, it just randomly choses a body part to hit I belive or some shit like that

verbal yew
#

but wait...

#

in 42 devs want create normal stuff for armor, like real armor, yep?

#

okay... nvm...

bright fog
#

Uh

#

The issues is that there's no way to properly add a limb targeting system so sadly I don't think it will change

#

Currently the game targets logical areas the zombies and players should hit depending on their attack types

pseudo apex
#

Hello! I'm very new to this and I'm trying to make a mod that creates boxes with food at manually defined coordinates.
I have been seeing several mods how they define some things.
But I have a problem with this code, where do I put the file with the coordinates that I need to use?

echo fiber
#

and it puts it all under one function

bright fog
# verbal yew yeah...

You could technically overwrite the current damage limb system and add aiming possibilities

verbal yew
echo fiber
#

@echo lark if you wanted to have it all in one function you can do this as well, where it checks to see what item it is first then uses that item for the output

#

this part was also for a randomize feature

bright fog
#

The hard way:

  • Java modding aPES3_CursedDemon
echo fiber
#
function UseVapeB(items, result, player)
    local stats = player:getStats();
    local bodyDamage = player:getBodyDamage();
    local char = player;
    print ("Aww yeah, that's the stuff!");
    stats:setStress(math.max(((stats:getStress()) - (0.15)),0));
    bodyDamage:setUnhappynessLevel(math.max(((bodyDamage:getUnhappynessLevel()) - (8.0)),0));
--xx Smoker Trait
    stats:setStressFromCigarettes(math.max(((stats:getStressFromCigarettes()) - (0.15)),0));
    char:setTimeSinceLastSmoke(math.max(((char:getTimeSinceLastSmoke()) - (3)),0));

    local r = ZombRand(8)+1;
    if r == 1 then
        char:Say("Tastes just like strawberrys!")
    elseif r ==2 then
        char:Say("This stuff is amazing!")
    elseif r ==3 then
        char:Say("So much better than the stuff iv made!")
    elseif r ==4 then
        char:Say("Strawberry liquid is the best!")
    elseif r ==5 then
        char:Say("Tastes so good and takes the edge off!")
    elseif r ==6 then
        char:Say("*Cough* Hit that one too hard *Cough*")
    elseif r ==7 then
        char:Say("*Cough* That was so dry... *Cough*")
        stats:setStress(math.max(((stats:getStress()) + (0.15)),0));
        bodyDamage:setUnhappynessLevel(math.max(((bodyDamage:getUnhappynessLevel()) + (8.0)),0));
        for i=0, items:size()-1 do            
            local item = items:get(i)
            if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.RedVape") then
        char:getInventory():AddItem("VapeMod.RedVapeBurnt", item:getUsedDelta());
        item:getContainer():DoRemoveItem(item);
            end
                if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.BlueVape") then
                char:getInventory():AddItem("VapeMod.BlueVapeBurnt", item:getUsedDelta());
                item:getContainer():DoRemoveItem(item);
                end
                    if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.GreenVape") then
                    char:getInventory():AddItem("VapeMod.GreenVapeBurnt", item:getUsedDelta());
                    item:getContainer():DoRemoveItem(item);
                    end
                        if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.GoldVape") then
                        char:getInventory():AddItem("VapeMod.GoldVapeBurnt", item:getUsedDelta());
                        item:getContainer():DoRemoveItem(item);
                        end
        end
        
    end
end
``` @echo lark found a cleaner part of my code if you want to try to make that repair thing a single function
echo fiber
#

? why do you say that

bright fog
#

You could probably fit all this within hmmm 3 lines lmao

#

Bro your indentation is completely wrong

#

That's the worst part xD

echo fiber
#

how are you going to put that on 3 lines 0.o

bright fog
#

First, better indentation

echo fiber
#

the indentations where for my self, as i have a hard time reading my ends

bright fog
#

Ok so first off, optimization on your method, you are doing a bunch of useless checks here

            local item = items:get(i)
            if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.RedVape") then
        char:getInventory():AddItem("VapeMod.RedVapeBurnt", item:getUsedDelta());
        item:getContainer():DoRemoveItem(item);
            end
            if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.BlueVape") then
            char:getInventory():AddItem("VapeMod.BlueVapeBurnt", item:getUsedDelta());
            item:getContainer():DoRemoveItem(item);
            end
            if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.GreenVape") then
            char:getInventory():AddItem("VapeMod.GreenVapeBurnt", item:getUsedDelta());
            item:getContainer():DoRemoveItem(item);
            end
            if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.GoldVape") then
            char:getInventory():AddItem("VapeMod.GoldVapeBurnt", item:getUsedDelta());
            item:getContainer():DoRemoveItem(item);
            end

this is wrong because it's impossible for your item to be multiple types right ?

echo fiber
#

incorrect

#

the item is 3 types

#

and the mod i made does work all of the code works

bright fog
#

Can it be VapeMod.GoldVape and VapeMod.BlueVape at the same time ?

echo fiber
#

those are dif items

bright fog
bright fog
echo fiber
#

its checking to see what vape you used

#

as there are 4 vapes

bright fog
#

So your item when it checks one of those getFullType conditions, it can't be the other 3

echo fiber
#

all 4 vapes use this same function

bright fog
#
            local item = items:get(i)
            if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.RedVape") then
        char:getInventory():AddItem("VapeMod.RedVapeBurnt", item:getUsedDelta());
        item:getContainer():DoRemoveItem(item);

            elseif item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.BlueVape") then
            char:getInventory():AddItem("VapeMod.BlueVapeBurnt", item:getUsedDelta());
            item:getContainer():DoRemoveItem(item);

            elseif item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.GreenVape") then
            char:getInventory():AddItem("VapeMod.GreenVapeBurnt", item:getUsedDelta());
            item:getContainer():DoRemoveItem(item);

            elseif item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.GoldVape") then
            char:getInventory():AddItem("VapeMod.GoldVapeBurnt", item:getUsedDelta());
            item:getContainer():DoRemoveItem(item);
            end
#

First off so you don't do all those other useless checks for nothing

echo fiber
#

there are 4 vape liquids and 4 vapes, so there are 4 other functions that look like that, and they need to check to see what vape called the function

bright fog
#

If one triggers, there's no point checking the others since it can't be the others for a single item

echo fiber
bright fog
#

Your item can't be multiple getFullType() right ?

#

Can it ?

#

You said no, it's either Red, Blue, Green or Gold no ?

echo fiber
#

correct

bright fog
#

So then if it's one of those, it can't be the others ?

verbal yew
#

item get Module not req here... yep... its strange...

echo fiber
#

if i take that part out the code string breaks though

#

iv tried and it didnt work

#

only time it worked was with that part in there

bright fog
#

Next, don't check item:getModule() == "VapeMod" everytime, check it once

            local item = items:get(i)
            if item:getModule() == "VapeMod" then
                if (item:getFullType() == "VapeMod.RedVape") then
            char:getInventory():AddItem("VapeMod.RedVapeBurnt", item:getUsedDelta());
            item:getContainer():DoRemoveItem(item);
    
                elseif item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.BlueVape") then
                char:getInventory():AddItem("VapeMod.BlueVapeBurnt", item:getUsedDelta());
                item:getContainer():DoRemoveItem(item);
    
                elseif item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.GreenVape") then
                char:getInventory():AddItem("VapeMod.GreenVapeBurnt", item:getUsedDelta());
                item:getContainer():DoRemoveItem(item);
    
                elseif item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.GoldVape") then
                char:getInventory():AddItem("VapeMod.GoldVapeBurnt", item:getUsedDelta());
                item:getContainer():DoRemoveItem(item);
                end
            end
echo fiber
bright fog
#

This way instead of doing 8 checks, you went to 1 + 1 min max + 4

bright fog
#

That reduces the charge on the program

#

Less stuff to process, better performances

echo fiber
#

i think you lost me a bit there

bright fog
#

How to explain that a different way hmm

echo fiber
#

could just wright out the code how you think it should look

bright fog
#

If I don't explain it to you I'm just doing your job lmao

verbal yew
bright fog
#

You need to understand it to make your next codes better

echo fiber
#

like do you mean

elseif item:getModule() == "VapeMod" and (item:VapeMod.BlueVape")
verbal yew
echo fiber
bright fog
#
            local item = items:get(i)
            if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.RedVape") then
                char:getInventory():AddItem("VapeMod.RedVapeBurnt", item:getUsedDelta());
                item:getContainer():DoRemoveItem(item);
            end
            if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.BlueVape") then
                char:getInventory():AddItem("VapeMod.BlueVapeBurnt", item:getUsedDelta());
                item:getContainer():DoRemoveItem(item);
            end
            if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.GreenVape") then
                char:getInventory():AddItem("VapeMod.GreenVapeBurnt", item:getUsedDelta());
                item:getContainer():DoRemoveItem(item);
            end
            if item:getModule() == "VapeMod" and (item:getFullType() == "VapeMod.GoldVape") then
                char:getInventory():AddItem("VapeMod.GoldVapeBurnt", item:getUsedDelta());
                item:getContainer():DoRemoveItem(item);
            end

This is your original code and this is is what it does:

  1. get the item from the list
    2.1 Checks if is your module
    2.2 If passes then checks item RedVape
    3.1 Checks if is your module
    3.2 If passes then checks item BlueVape
    4.1 Checks if is your module
    4.2 If passes then checks item GreenVape
    5.1 Checks if is your module
    5.2 If passes then checks item GoldVape

So you have 5 steps that you run through

#

But within those 5 step you go up to 9 steps if your item is in your module

echo fiber
#

so what your saying is even if its the redvape its still checking the other ones?

echo fiber
#

so how do you get it to stop checking after it gets the right one

bright fog
#

And the elseif makes sure that if one of those passes, it doesn't check the others since they will be false for sure

echo fiber
#

so where does that go in the code line

#

does that take the place of "if"

echo fiber
#

so all i have to do is replace if with elseif

#

like so?

bright fog
#

Here the steps are:

  1. get item from list
  2. check if module

if item is not in module, it stops here
if it's in module continue steps:
3. checks a first time the item is RedVape

if passes it stops the code here and that's 3 steps
else continue for check for other type

repeat

bright fog
# echo fiber

I need more context here, make sure you don't put an end between each elseif and the original if, only one at the end

#

tbf you can just copy my code

echo fiber
#

lol very ture XD

#

one sec let me fix the block and ill send a ss

#

@bright fog

#

i think i have to many ends now >.<

bright fog
#

yup, that's better

#

no it should be good

echo fiber
#

thank you for showing me that XD

#

also sorry for coming off hostile XD i got defensive, this was my first mod i ever made by my self lol

slow graniteBOT
#
anonimo27099 has been warned

Reason: Bad word usage

bright fog
#

@echo fiber now my way of showing off

local itemType = {
    ["VapeMod.RedVape"] = "VapeMod.RedVapeBurnt",
    ["VapeMod.BlueVape"] = "VapeMod.BlueVapeBurnt",
    ["VapeMod.GreenVape"] = "VapeMod.GreenVapeBurnt",
    ["VapeMod.GoldVape"] = "VapeMod.GoldVapeBurnt",
}

local r_s = {
    "Tastes just like strawberrys!",
    "This stuff is amazing!",
    "So much better than the stuff iv made!",
    "Strawberry liquid is the best!",
    "Tastes so good and takes the edge off!",
    "*Cough* Hit that one too hard *Cough*",
    "*Cough* That was so dry... *Cough*",
}

function UseVapeB(items, result, player)
    local stats = player:getStats();
    local bodyDamage = player:getBodyDamage();
    local char = player;
    print ("Aww yeah, that's the stuff!");
    stats:setStress(math.max(((stats:getStress()) - (0.15)),0));
    bodyDamage:setUnhappynessLevel(math.max(((bodyDamage:getUnhappynessLevel()) - (8.0)),0));
--xx Smoker Trait
    stats:setStressFromCigarettes(math.max(((stats:getStressFromCigarettes()) - (0.15)),0));
    char:setTimeSinceLastSmoke(math.max(((char:getTimeSinceLastSmoke()) - (3)),0));

    local r = ZombRand(8)+1;
    char:Say(r_s[r])

    if r == 7 then
        stats:setStress(math.max(((stats:getStress()) + (0.15)),0));
        bodyDamage:setUnhappynessLevel(math.max(((bodyDamage:getUnhappynessLevel()) + (8.0)),0));
        for i=0, items:size()-1 do            
            local item = items:get(i)
            if itemType[item:getFullType()] then
                char:getInventory():AddItem(itemType[item:getFullType()], item:getUsedDelta())
                item:getContainer():DoRemoveItem(item)
            end
        end
    end
end
bright fog
bright fog
echo fiber
#

did you just make the items and the comments locals?

#

might have to use that XD

bright fog
#

I haven't made the function local indeed but you should

#

Or store it in a module

#
-- file module.lua
local yourModule = {}

return yourModule
-- other file
local yourModule = require "module"

function module.yourFunction()
  -- do stuff
end
-- another file again
local yourModule = require "module"

-- run function defined in other file
local function exampleFunctionToRunModuleFunction()
  module.yourFunction()
end
bright fog
#

When you start getting massive if statements like that, it's the best way to use dictionaries

echo fiber
#

okay i can try that XD might not look pretty at first

verbal yew
#

if im not wrong he use item from recipe

bright fog
#

But yeah for recipe functions they need to be global

verbal yew
#

look like that

bright fog
#

Yeah

verbal yew
#

it recipe

echo fiber
#

it is a recipe function

bright fog
#

yeah then keep it global

echo fiber
#

how do i do that

#

can i not do this

bright fog
#

No that stays local

#

This is not a function

echo fiber
#

what part needs to be globle?

bright fog
#

This is a dictionary and is stored localy in the file so it can be accessed within the function

bright fog
#

this

#

keep it written like that

echo fiber
#

o yea it is

bright fog
#

don't do:

local function UseVapeB(items, result, player)
echo fiber
bright fog
#

yeah

echo fiber
#

i wrote what you did step by step to make sure i understood where everything went and what called what

bright fog
#

Good to do that

echo fiber
#

to show its running that part

echo fiber
verbal yew
#

something with your tag and mod name

bright fog
#

(about prints)
I suggest keeping those for debugging only but remove them the moment you post the mod
AND I BEG YOU, DON'T PUT THEM BEHIND A CHECK TO VERIFY YOU ARE IN DEBUG MODE
Remove EVERY SINGLE PRINT you have besides those that can happen like on mod load (for example I do a print to say I overwrite a specific function from a mod)

The reason you remove your prints is to:

  1. not clog the player's consoles (a print every single tick is just a fucking no)
  2. performance reasons (they can actually lag the game very hard depending on the print frequency)
  3. for modders who use your mod in debug mode, they will end up with print spams out of fucking nowhere for no fucking reasons (you can tell I hate modders who do that shit)
verbal yew
#

like function zReVapeMod_UseVapeB for example

bright fog
#

true

echo fiber
#

but Sir Doggy i will make sure to remove the prints if i ever publish this mod

bright fog
#

The prints are useless for EVERYONE but yourself and modders who might fuck around with your mod (and that's their problem, they'll add their own prints to things they want to study anyway)

echo fiber
#

its been done for years but never desided to publish it

bright fog
echo fiber
#

i assume just due to the fact of other mods might have it

#

and you dont want a clash of functions

echo fiber
#

is there a quick way to comment a block of code out

verbal yew
#

in lua
--[[
code here not read
]]

bright fog
#

yeah

echo fiber
#

thank you so much

bright fog
#

or select the whole thing and CTRL + another key depending on your IDE

verbal yew
#

in script:
/*

*/

#

in xml
<<--

-->>

echo fiber
#

--[[ worked

#

but good to know the other ones

#

only have one xml file XD

echo fiber
#

atleast i have a cool signature XD

#

time to make sure it still works >.<

vague bay
#

Greetings,
First time modding. Past few days I have been trying to create a mod that aims to reduce the speed reduction when driving a car and hitting a zombie. I was learnt about player:isDriving() and player:getVehicle(). Additionally I think the class I want to modify is Class BaseVehicle.HitVars (https://projectzomboid.com/modding/zombie/vehicles/BaseVehicle.HitVars.html#calc(zombie.characters.IsoGameCharacter,zombie.vehicles.BaseVehicle))
But I don't know if that is correct, could anyone give me some help ?

#

From what I understand,
the method calc(IsoGameCharacter target, BaseVehicle vehicle) calculate the hit speed based on what it hit and then set the vehicle speed

public void calc(IsoGameCharacter var1, BaseVehicle var2) {
            var2.getLinearVelocity(this.velocity);
            this.velocity.y = 0.0F;
            if (var1 instanceof IsoZombie) {
                this.vehicleSpeed = Math.min(this.velocity.length(), 10.0F);
                this.hitSpeed = this.vehicleSpeed + var2.getClientForce() / var2.getFudgedMass();
            } else {
                this.vehicleSpeed = (float)Math.sqrt((double)(this.velocity.x * this.velocity.x + this.velocity.z * this.velocity.z));
                if (var1.isOnFloor()) {
                    this.hitSpeed = Math.max(this.vehicleSpeed * 6.0F, 5.0F);
                } else {
                    this.hitSpeed = Math.max(this.vehicleSpeed * 2.0F, 5.0F);
                }
            }
  • Code from the BaseVehicle
echo fiber
#

@bright fog so i think the code is broken a bit, its not putting the burnt vapes in my inv or removing the good vape

#

so it checks to see if its the right vape, (i think) but its not giving or taking the vapes

verbal yew
#

like when vehicle get damage, get current speed, set current speed minus small delta

bright fog
# echo fiber atleast i have a cool signature XD

Nice
that's mine:

--[[ ================================================ ]]--
--[[  /~~\'      |~~\                  ~~|~    |      ]]--
--[[  '--.||/~\  |   |/~\/~~|/~~|\  /    | \  /|/~~|  ]]--
--[[  \__/||     |__/ \_/\__|\__| \/   \_|  \/ |\__|  ]]--
--[[                     \__|\__|_/                   ]]--
--[[ ================================================ ]]--
bright fog
#

oof

bright fog
echo fiber
#

i like it

#

it says the text yes

#

and is correct for each flavor used

#

but it wont use the code for removing and adding the burnt vape

bright fog
#

It's supposed to give the burnt vape if it's r == 7 right ?

echo fiber
#

when it does hit the burnt vape call i get an error

bright fog
echo fiber
#

how do i look at the error

bright fog
#

console.txt

#

in /Zomboid/

coarse sinew
#

!console

slow graniteBOT
#

Help the people helping you by posting your console.txt from %UserProfile%\Zomboid.
For hosted servers, please also post the coop-console.txt from the same folder.

https://i.imgur.com/weyNseY.png

echo fiber
bright fog
echo fiber
#

o dear god

bright fog
#

Check the line where you have an error

echo fiber
#

k one sec

bright fog
#

You need to learn how to read errors or you can't mod properly

vague bay
echo fiber
#

idk how to find it........ anywhere i see errors in it, it looks like something thats not what im looking for

verbal yew
#

getCurrentSpeedKmHm()

slow graniteBOT
#
trickeditsx has been warned

Reason: Bad word usage

vague bay
verbal yew
#

whats it is

vague bay
#

isn't that the rpm ?

verbal yew
#

im not sure

thick karma
native gale
torn igloo
#

ItemContainer.new is to create a new ItemContainer
But how do you remove it when I don't need it?

bronze yoke
#

an if statement is one of the cheapest things possible

#

tables are more efficient when they replace huge if trees, but just four if statements is going to be faster

bronze yoke
bronze yoke
#

table accesses are fast but not faster than an if statement, and your code redundantly accesses the table twice + gets the item's full type twice so there's an extra speed loss there

bronze yoke
#
local item = items:get(i)
if itemType[item:getFullType()] then
    char:getInventory():AddItem(itemType[item:getFullType()], item:getUsedDelta())
    item:getContainer():DoRemoveItem(item)
end
``````lua
local item = items:get(i)
local newItemType = itemType[item:getFullType()]
if newItemType then
    char:getInventory():AddItem(newItemType, item:getUsedDelta())
    item:getContainer():DoRemoveItem(item)
end
```i would optimise this way
echo fiber
bright fog
bronze yoke
#

but in this case there's few enough cases that an if statement would probably be faster, the table solution is just cleaner + more extendable

bright fog
#

Yeah I see

torn igloo
echo fiber
#

@bright fog thank you again for you help today, i put you in the credits of the readme lol, not like its getting posted but

bright fog
#

np

#

I mean if the if statement is faster you can take the version I showed before

echo fiber
#

yea i went back to the first one you did

#

the other one wasint reading the items correctly

bronze yoke
#

maybe i don't know what i'm talking about

coarse sinew
#

No, you're right that CPUs are very good at optimizing simple conditional checks rather than direct table access which involves calculating a hash of the key and then looking up the value. Maybe it's the JIT compiler optimization fault

bright fog
#

Surely I'm not clicking that shit

#

Send a github link so we can see what's inside before

bronze yoke
#

yeah, definitely something very strange about lua that these end up like that, i found that the table access was only slower than *one* if statement, and even then it was marginal

#

this was tested on a standard lua compiler so results in zomboid might be different

thick karma
#

Seems highly unlikely and counterintuitive to me...

bronze yoke
#

no, only shorter if statements are faster

#

(though longer if statements would usually be compiled to something faster anyway, which is why you're always told to benchmark instead of theorising about speed)

thick karma
#

I see

bronze yoke
#

table accesses have an amount of overhead that should make them slower than a couple simple evaluations

#

but it seems that logic doesn't carry over to lua

bright fog
#

classic

mellow frigate
#

hello there, is there a mod that inserts flawlessly new build option in the MetalWelding building context menu ? It looks as difficult as adding to Carpentry is easy.

thick karma
#

This exists but Idk if it will help:

function ISContextMenu:getSubMenu(num)
    return getPlayerContextMenu(self.player):getSubInstance(num)
end
#

If you have the submenu you could just addOption to it all day I'd imagine.

crystal oar
#

in the script for a recipe, what line do i add to make the recipe hidden from the crafting menu?

thick karma
#

Never tried adding to existing submenus.

frank elbow
#

Submenus are ISContextMenu instances, so it should work. Fairly sure I've done so

violet shell
#

Hi ! I would like to make a very small mod that act like Braven's Erase Map Mod, but to only forget the "visited" zones, not the whole map, because I want the map already known. But I still want that players "forget" the areas already visited on the map on death.
would it be something like WorldMapVisited.getInstance():
clearKnownInCells(0,0,65,52)
Or WorldMapVisited.getInstance():clearVisitedInCells(0,0,65,52) ?

echo lark
#

is it possible to get ontest to only check the first item? im trying to get so the craft is only possible if the first items condition is < 5 but every time i do it the 2nd item in the recipe is grayed out as if its checking that items condition to or something

bronze yoke
#

just make your ontest check the type of the item too

#

e.g. if item:getFullType() == "Base.Hammer" and item:getCondition() > 5 then return false end

echo lark
bronze yoke
#

you can always do something like this if you want multiple types```lua
local validItems = {
["Base.Hammer"] = true,
["Base.Wrench"] = true,
}

function myOnTest(item, result)
if validItems[item:getFullType()] and item:getCondition() > 5 then
return false
end
return true
end

#

a tag for one recipe is kind of overkill

echo lark
# bronze yoke a tag for one recipe is kind of overkill

probably yeah, but i was giving the items a unique tag anyways so i could use it for other things in the future, they are gonna be unique event items that the admins will edit the stats on, i have a recipe for each weapon set its condition to max using oncreate (since the fixing method of repairing resets the stats to default). so i was just trying to get a ontest so the recipe only shows if the items condition is below 5. so i figured if i could make the function check for the tag i could avoid having a like list of items if i manage to make lots of event weapons

#

kind of like how SOMW uses SReward tag to stop the stats of the honored weapons from reverting onswing

bright fog
bronze yoke
bright fog
#

Confirmed ?

bronze yoke
#

that was the result of a benchmark i did with an online lua compiler

#

i ran it a dozen times and got about the same results each time

thick karma
#

So interesting

bronze yoke
#

cpu seconds, 1 million iterations for each test

#

results may be different in kahlua

bright fog
#

With any amount of IF or table sizes ? (tho table size doesn't change ?)

bronze yoke
#

table size shouldn't really matter, and i found that *one* if is very marginally faster than a table access

#

i'll test a larger table but hash maps should be O(1) anyway

thick karma
#

So don't make a table for a literal single conditional variable... lol I would sure hope not.

bronze yoke
#

technically speaking if your first if statement catches 99.99999...% of cases it would be faster than using a lookup table

#

but don't optimise around stupid bullshit like that

echo lark
bronze yoke
#

lua is lua i suppose

mellow frigate
# thick karma Can't say for sure whether that works, so feel free to let me know.

Got the MetalWelding submenu insertion with: ```lua
myfunc = function(player, context, worldobjects, test)
--hide some protection against: test==true / invalid inputs..
local buildMWOption = context:getOptionFromName(getText("ContextMenu_MetalWelding"))--get the option --I depend on translation but have no choice afaik. anyway vanilla protects it so it is a valid key
if not buildMWOption then return end
local subMenuMW = context:getSubMenu(buildMWOption.subOption)--get the menu
if subMenuMW then
addMyOwnOptionToMetalWeldingSubMenu(subMenuMW, player)
end
end
Events.OnFillWorldObjectContextMenu.Add(myfunc) --entrypoint

thick karma
#

Excellent, I was curious how you'd get the right submenu number

#

Glad you solved it

mellow frigate
muted garnet
#

Does anyone know how I can prevent the player from pressing the right mouse button during ISModalDialog, like in vanilla with the trade system, but without changing the vanilla worldobjectcontext code?

thick karma
# muted garnet Does anyone know how I can prevent the player from pressing the right mouse butt...

I've never tried this, but I do believe you can attach onRightMouseUp and onRightMouseUpOutside to that object, so you may in theory be able to do this:

local yourModalInstance = ISModalDialog:new(x, y, . . . .) 
-- use whatever your inputs really are in the line above

function yourModalInstance:onRightMouseUp()
  -- do nothing
end

function yourModalInstance:onRightMouseUpOutside()
  -- do nothing
end
#

Give it a shot and let us know how it goes because I honestly don't know if it'd work or not. I barely touch KBM.

muted garnet
#

hmm, thanks, let's try it now

thick karma
#

Might also need to bind Down I guess?

thick karma
#

meaning onRightMouseDown and onRightMouseDownOutside

#

Same way

#

To fully block it

muted garnet
#

got it

thick karma
#

In fact I guess for the sake of clean code...

#

I could recommend...

#
local yourModalInstance = ISModalDialog:new(x, y, . . . .) 

function yourModalInstance:blocked()
  -- do nothing
end

yourModalInstance.onRightMouseUp = yourModalInstance.blocked
yourModalInstance.onRightMouseUpOutside = yourModalInstance.blocked
yourModalInstance.onRightMouseDown = yourModalInstance.blocked
yourModalInstance.onRightMouseDownOutside = yourModalInstance.blocked
#

that would in theory also work.

#

Whichever notation you prefer.

#

Could also make that do-nothing function a local function I guess since it's garbage anyway to further simply how that looks.

#
local function blocked() end

local yourModalInstance = ISModalDialog:new(x, y, . . . .) 

yourModalInstance.onRightMouseUp = blocked
yourModalInstance.onRightMouseUpOutside = blocked
yourModalInstance.onRightMouseDown = blocked
yourModalInstance.onRightMouseDownOutside = blocked
#

I suppose there's no reason this wouldn't also work for the same reasons

muted garnet
#

not working, maybe I can return a ISWorldObjectContextMenu.createMenu function, like in vanilla?

#

but from my code

thick karma
#

Not sure. What exactly is the context? You just have a modal dialog box open and don't want players to open context menu while they're in it?

bronze yoke
#

the ui only eats mouse events that actually land on the ui

muted garnet
#

now its look like:

        if command == 'TradeRequestSent' then
            local clickedPlayer = getPlayerByOnlineID(args[1])
            modal = ISModalDialog:new(getCore():getScreenWidth() / 2 - 175, getCore():getScreenHeight() / 2 - 75, 350, 150, getText("IGUI_SentRequestto:" .. " " .. clickedPlayer:getDisplayName()), nil, true, WindowUI.onAnswerRequest);
            modal:initialise()
            modal:addToUIManager()
            modal:removeChild(modal.ok);
            modal.moveWithMouse = true; 

        else
            local playerObj = getPlayerByOnlineID(args[1])
            modal = ISModalDialog:new(getCore():getScreenWidth() / 2 - 175,getCore():getScreenHeight() / 2 - 75, 350, 150, getText("IGUI_RecieveRequestby:" .. " " .. playerObj:getDisplayName()), true, nil, WindowUI.onAnswerRequest);
            modal:initialise()
            modal:addToUIManager()
            modal.moveWithMouse = true;
        end
teal fulcrum
#

Does anyone know which soundbank the zombie death noise is stored in?

thick karma
thick karma
# muted garnet one player can send another player an offer, the second player has a window with...

Based on what albion is suggesting, I'm not sure there's an easy way to stop the context menu from opening during that time without decorating something that I'd be thrown into a well and left to die for helping you decorate -- especially if you want it to prevent gamepad players from doing it, too. Why exactly are you trying to prevent opening of context menu at that time? What's the issue with opening the context menu at that time?

muted garnet
thick karma
muted garnet
# thick karma If you explain why you need to prevent it, we may be able to think of other ways...

I want to make these windows perfect, the easiest way to do this is to make it impossible to right click and create a table like for the trade menu in vanilla, the bugs are that when the player can be sent an infinite number of requests with the window already open, the player can start send requests in response, which will drive the UI windows crazy and they will start to behave like crazy, being created by another player, not closing when necessary and the data (maybe for some, small errors terrify me), but I didn’t want to explain due to the fact that these errors you may consider these errors not requiring solutions and tell me not to pay attention, but I have never worked on the UI part before, so it’s not clear to me how to implement this as efficiently as possible and how to generally implement some ideas about the UI part

#

I don’t even know how to connect the code of modal windows and the instance table together

thick karma
muted garnet
#

my own

#

I dont creating trade system

thick karma
#

Can you just tell your code not to spawn a second window if one exists, and not to allow a second request to be sent if they never receive a response from the first request?

#

e.g., if MyWindow.instance then return else createMyWindowInstance() end, in pseudocode?

#

And similarly, if MyUtilityModule.sentRequest[player] then return else sendRequest(player) end?

#

(This would assume you would have a table of sent requests to other players, and you would clear them as the responses came back, good or bad. Also assumes you destroy the instance when you close the UI.)

#

(Again, this is pseudocode above just to give an idea of what could be done.)

muted garnet
#

thanks, I'm trying to implement this now

thick karma
#

Good luck!

verbal yew
#

it's block spam request

#

after player push cancel - it's change moddata back to 0

#

or nil (nvm)

verbal yew
#
table.insert(ProceduralDistributions.list.ArmyHangarOutfit.items, "EHE.Vest_PilotSurvivalVest");
table.insert(ProceduralDistributions.list.ArmyHangarOutfit.items, 3);

same as

table.insert(ProceduralDistributions.list["ArmyHangarOutfit"].items, "EHE.Vest_PilotSurvivalVest");
table.insert(ProceduralDistributions.list["ArmyHangarOutfit"].items, 3);

?

bronze yoke
#

yeah

#

.foo is just syntatic sugar for ["foo"]

bright fog
#

There's some key sybtax you can't .key

#

I believe whenever you have - you have no choice but to write it in ["key"]

bronze yoke
#

yeah most weird characters won't work

#

. can't work for obvious reasons, neither does $

#

- can't be in it because it isn't distinguishable from an actual subtraction

#

t.a-t.c could be interpreted as either t.a - t.c or t["a-t"].c

#

it can't start with a number either

#

but numbers can be present, just not the first character

bright fog
verbal yew
#

god damn... i wanna change soundbanks on days gone + left 4 dead + something else...

#

ou ou ou ou! dying light!

upbeat sequoia
#

the java documentation is a bit confusing 😵‍💫 can anyone tell me which event or method ingame is responsible/called during a car collision?
im still new to pz modding btw

bronze yoke
#

nothing is called or triggered in lua during a car collision

upbeat sequoia
#

:(

bronze yoke
#

the best you can do is to check the car's health periodically to see when damage has occurred

upbeat sequoia
#

that'd be incredibly unoptimized. maybe i can do a routine that stores x amount of last vehicle health and speed into a table

#

that runs in a tick

#

would that be too much (?)

bronze yoke
#

that's what i was suggesting

#

it's not ideal but there isn't really a better way to do it

upbeat sequoia
#

damn ok thanks

upbeat sequoia
#

yes i was studying that mod

#

me and @vague bay where wondering if there was another way to do it

#

but thx

bronze yoke
#

actually there's a thought

#

OnPlayerGetDamage has a specific damagetype for being in a car crash

upbeat sequoia
#

🤔

#

but afaik playerdamage from a car crash happens if its like an incredibly highspeed crash right

#

and only on static objects

bronze yoke
#

i don't know the exact conditions but it's not all crashes for sure

upbeat sequoia
#

alright ill look into it, ty

violet shell
#

Hi ! I would like to make a very small mod that act like Braven's Erase Map Mod, but to only forget the "visited" zones, not the whole map, because I want the map already known. But I still want that players "forget" the areas already visited on the map on death.
would it be something like WorldMapVisited.getInstance():
clearKnownInCells(0,0,65,52)
Or WorldMapVisited.getInstance():clearVisitedInCells(0,0,65,52) ?

bright fog
#

I know some frameworks add custom events for other mods to use but was curious how they did it

#

Like can you add an Event ?

bronze yoke
#

yeah

#

LuaEventManager.AddEvent("MyEvent")
triggerEvent("MyEvent", ...)

#

personally i prefer using home grown callbacks since the lua -> java -> lua ping pong is a little unnecessary

#

but from my testing the overhead isn't all that significant so do whatever

bright fog
#

Hmm

bright fog
empty rock
#

Has anyone managed to use redis/mysql on a lua mod or is json files the only way to go currently? I assume java modding would do the trick but that would require others to download the mod files and patch the game, not viable.

bronze yoke
#

events don't have set signatures at all

empty rock
#

Redis or Mysql is what I mean of course.

bronze yoke
#

they just *usually* pass the same things so it seems like they do 😅

bright fog
empty rock
# bright fog No idea what that is

Redis is an open-source, in-memory data structure store used as a database, cache, and message broker. It excels in speed and efficiency for real-time applications, supporting various data structures like strings, hashes, lists, and more.

MySQL is a popular open-source relational database management system known for its reliability, scalability, and robust SQL support. It's widely used in web applications for data storage and retrieval, offering features like transactions, indexing, and replication.

#

I know you can use json files but its tedious....

bright fog
#

And what do you plan on doing with those exactly lol ?

empty rock
#

Talk with external services like discord bots and/or websites etc

#

I can do it with json files but its not ideal because of all the reading and writing... Also the message broker function is something I miss a lot 😩

slow graniteBOT
#
usernameloadlng has been warned

Reason: Bad word usage

#
evrythngisawsme has been warned

Reason: Bad word usage

upbeat sequoia
#

any clue how this can be utilized or if its exposed to lua

#

its isoobject

neon bronze
#

On what do you intend to use it?

vague bay
#

is this the correct way to add keybind ?

bind = {}
bind.value = "MOGrTrigger";
bind.key = Keyboard.KEY_G
table.insert(keyBinding, bind)

copied it from another mod but it doesn't work for me

small topaz
#

Hi! When I make a new food item, how do I tell the game that it should display a new icon when the food item is rotten? So as in vanilla, it should have a normal icon when fresh or stale and a rotten-version of the icon when it is rotten.

bright fog
#

Also I believe this method doesn't do what you think it does

#

That probably is used to damage things the vehicle hit perhaps ?

#

However you could probably make a java decoration to link a lua function to the triggering of the method (even within the java)

#

(all of this is done via lua)

upbeat sequoia
violet shell
#

Is it possible to mod the loading screen (the black one with text, before you can click to enter the world, which ends with "this is the story of your death" or something like that) ?

bright fog
#

Search for custom loading screens

bright fog
#

(do you know what a decoration is ?)

bronze yoke
#

you might have heard it referred to as hooking in other spaces

violet shell
neon bronze
#

Java hooking is a bit tricky in theory

bronze yoke
#

while it's correct that the javadocs only display methods that are exposed to lua, keep in mind that they do show some classes that aren't exposed

upbeat sequoia
bronze yoke
#

so you'll never have half a page be unhelpful, but sometimes you'll have an entire page that is 😔

bright fog
upbeat sequoia
#

i just wish there was an api for running over zombies its so tedious 😭 im trying to find the simplest methods of getting it, me and mogr thought of an idea of triggering an onobjectcollide and run a condition if it was a zombie character id + the players vehicle id
turns out zombies touching a car don't trigger onobjectcollide

#

then running them over doesnt actually trigger anything in the output log

#

now my 3rd attempt is finding which class is responsible for adding ur car kill counts to player stats, maybe it'd have a good pointer for me to study via java code

upbeat sequoia
bright fog
#

looks a bit tricky at first but once you understand how it works

bronze yoke
#

hooking is the practice of replacing a function with a new function that calls upon the original, so that your code is called when that function is, but the original functionality isn't actually lost

bright fog
#

I'll write an example

bronze yoke
#

it's not as useful for java methods as strictly speaking what you're hooking isn't the java method but lua's reference to it, so your hook isn't actually triggered by calls from java, only calls from other lua scripts

#

but sometimes it is very handy

bright fog
#
-- file 1
function yourFunction(variable) --needs to be accessible from elsewhere, so stored in a module or stored in global
  -- does some stuff
  return stuff
end
-- file 2
local old_yourFunction = yourFunction -- store first version
function yourFunction(variable) --replace first version
  -- do your own stuff, so alter variable for example or do a call elsewhere
  return old_yourFunction(variable)
end
#

That way if a mod rewrites the original function for example, it doesn't matter and it will still work

#

Also you can do stuff like run code AFTER the original that way:

-- file 1
function yourFunction(variable) --needs to be accessible from elsewhere, so stored in a module or stored in global
  -- does some stuff
  stuff
end
-- file 2
local old_yourFunction = yourFunction -- store first version
function yourFunction(variable) --replace first version
  old_yourFunction(variable)
  -- do stuff after the original runs
end
bronze yoke
#

not if you return ^^

bright fog
#

yeah just saw that

#

In this case no

bronze yoke
#

yeah, the main utility is either to use other functions being called as triggers for your code, or to mess with the arguments/return values of a function

bright fog
#

yup

neon bronze
#

Sadly cant hook into a function directly

bright fog
#

I used it once or two already

bright fog
neon bronze
bright fog
#

hhaaa

#

Nah yeah you can't

neon bronze
#

Not before or after but directly in the middle

bright fog
#

You'd have to replace the original in this case, which usually means possible incompatibilities with mods that also do it

neon bronze
#

Sadge

verbal yew
#

it's right construction:

require 'Items/ItemPicker'    
require 'Items/Distributions'
require 'Items/ProceduralDistributions'
require 'Items/SuburbsDistributions'
require 'Vehicles/VehicleDistributions'

    local zReVehicle_InstrumentalDistr = {
        ['MetalWelderTruckBed'] = 'items',
        ['CarpenterTruckBed'] = 'items',
        ['ConstructionWorkerTruckBed'] = 'items',
        ['PainterTruckBed'] = 'junk',
        ['SurvivalistTruckBed'] = 'items',
    }
    -- "LabItems.ChHydrochloricAcidCan"  "LabItems.ChSodiumHydroxideBag" "LabItems.ChSulfuricAcidCan"
for k, v in pairs(zReVehicle_InstrumentalDistr) do
    if v == 'junk' then
        table.insert(VehicleDistributions[k].junk.items, "LabItems.ChHydrochloricAcidCan");
        table.insert(VehicleDistributions[k].junk.items, 1.8)
        table.insert(VehicleDistributions[k].junk.items, "LabItems.ChSodiumHydroxideBag");
        table.insert(VehicleDistributions[k].junk.items, 1.8)
        table.insert(VehicleDistributions[k].junk.items, "LabItems.ChSulfuricAcidCan");
        table.insert(VehicleDistributions[k].junk.items, 1.8)
    else
        table.insert(VehicleDistributions[k].items, "LabItems.ChHydrochloricAcidCan");
        table.insert(VehicleDistributions[k].items, 3)
        table.insert(VehicleDistributions[k].items, "LabItems.ChSodiumHydroxideBag");
        table.insert(VehicleDistributions[k].items, 3)
        table.insert(VehicleDistributions[k].items, "LabItems.ChSulfuricAcidCan");
        table.insert(VehicleDistributions[k].items, 3)
    end
end
#

?

vague bay
bronze yoke
#

it's definitely not called from lua so you wouldn't really be able to do much with that method

bright fog
upbeat sequoia
#

theres multiple methods that mention char hits in base vehicle, but pinpointing the exact one is the issue atm

#

we can probably make a robust code that mitigates speed if we figure out a good collider logic

vague bay
#

is this the correct way to add keybind ?

bind.value = "MOGrTrigger";
bind.key = Keyboard.KEY_G
table.insert(keyBinding, bind)

copied it from another mod but it doesn't work for me

bright fog
vague bay
#
  • Class GameKeyboard
    isKeyDown(int key)
    Why is key an int ?
    How to lookup the int for the G keybind ?
violet shell
bright fog
#

couldn't find it

#

But keys are linked to numbers

bronze yoke
#

something like Keyboard.KEY_G

zenith igloo
#

also you can use input. smt if you dont wanna use a int but I dont remember

bright fog
#

👌

vague bay
#

I found BaseVehicle.HitVars which has attributes like hitSpeed and vehicleDamage
I can acess BaseVehicle class with vehicle = player:getVehicle() but how do I change the value of vehicleDamage which is member of HitVars subclass ?

bright fog
#

You probably can't if these are fields

#

Unless a method allows it

vague bay
#

Guess I can't

#

What about the calc method ? can I override it ?

#
   public static class HitVars {
      private static final float speedCap = 10.0F;
      private final Vector3f velocity = new Vector3f();
      private final Vector2 collision = new Vector2();
      private float dot;
      protected float vehicleImpulse;
      protected float vehicleSpeed;
      public final Vector3f targetImpulse = new Vector3f();
      public boolean isVehicleHitFromFront;
      public boolean isTargetHitFromBehind;
      public int vehicleDamage;
      public float hitSpeed;

      public void calc(IsoGameCharacter var1, BaseVehicle var2) {
         var2.getLinearVelocity(this.velocity);
         this.velocity.y = 0.0F;
         if (var1 instanceof IsoZombie) {
            this.vehicleSpeed = Math.min(this.velocity.length(), 10.0F);
            this.hitSpeed = this.vehicleSpeed + var2.getClientForce() / var2.getFudgedMass();
         } else {
            this.vehicleSpeed = (float)Math.sqrt((double)(this.velocity.x * this.velocity.x + this.velocity.z * this.velocity.z));
            if (var1.isOnFloor()) {
               this.hitSpeed = Math.max(this.vehicleSpeed * 6.0F, 5.0F);
            } else {
               this.hitSpeed = Math.max(this.vehicleSpeed * 2.0F, 5.0F);
            }
         }

         this.targetImpulse.set(var2.x - var1.x, 0.0F, var2.y - var1.y);
         this.targetImpulse.normalize();
         this.velocity.normalize();
         this.dot = this.velocity.dot(this.targetImpulse);
         this.targetImpulse.normalize();
         this.targetImpulse.mul(3.0F * this.vehicleSpeed / 10.0F);
         this.targetImpulse.set(this.targetImpulse.x, this.targetImpulse.y, this.targetImpulse.z);
         this.vehicleImpulse = var2.getFudgedMass() * 7.0F * this.vehicleSpeed / 10.0F * Math.abs(this.dot);
         this.isTargetHitFromBehind = "BEHIND".equals(var1.testDotSide(var2));
      }
   }
#

if I understand correctly the calc method is resposible for calcuating the hitspeed and setting vehicleSpeed

vestal gyro
#

When overriding modded traits is the loadorder important or what is there to consider?

bronze yoke
#

mod load order doesn't affect lua load order, files load alphabetically

#

so unless you're modifying something outside of the lua, load order shouldn't matter

#

you probably want your file to load after the original mod's does but you can do that by just making the name later alphabetically (e.g. by prefixing the name with Zs)

verbal yew
vestal gyro
#

So the lua file that overrides it just has to be alphabetically later than the file being overridden?

bright fog
#

Uh

frank elbow
vestal gyro
#

It has to happen basically at the same time so Events.OnGameBoot.Add(function)

red tiger
#

Hey y'all. How are yall? It's been a long time since I've been here.

bright fog
#

yo

red tiger
#

Hey @frank elbow

torn igloo
#

setMaxHitCount doesn't change hitcount persistently, is it hard coded?

frank elbow
red tiger
#

I'm currently recovering from a major brain surgery.

frank elbow
#

I'm doing well! & oh, I hope you have a swift recovery

red tiger
#

Hopefully I can get back into things with pz modding.

frank elbow
#

Heck yeah, glad to hear it

red tiger
#

I did make major progress on my 2nd anti-cheat before all of that. Will find the code and continue working on it.

red tiger
#

Hey @tame mulch You guys ever consider forwarding API wrapper calls for Bitwise operations? There's also a fancy Java AES library that would be great for Luanet encryption.

#

This would've saved me around 20 days of writing a bitwise ops emulator purely in Lua 5.1.

#

My solution is actually good because it's handled on the dynamic runtime level where interception hacking couldn't reroute or compromise encryption math.

#

It's very slow but it's also secure which is epic.

frank elbow
#

A built-in bit32 implementation would be very welcome

#

Understandably not prioritized, though. JSON built-in would also be handy

wicked crane
#

Welcome back just in time to prepare for b42:)

red tiger
#

I'd like to see a more expansive, open approach to the server-side of PZ over time.

#

It's actually really good that I was pushed as far as I was to need to implement a bitwise ops library emulation because the whole point is for security.

#

I'm sort of breaking the game in a way to fix and improve on it.

#

Oh @frank elbow I have made progress on Rosetta.

#

I'm currently working on a bootstrap 5 web application that will give the ability to write in custom third-party documentation for Lua.

#

This rendered from some of that progress. =)

#

Sooo yeah. I'll try to get that web app done and then get to work on ISUI documentation.

violet shell
#

I'm working on a Little mod that adds drain stats when Reading, based on the variable minutesperpage of the Sandbox options. I was wondering if it should be better to tie it to onplayerupdate or ontick events, server workload wise. Any Idea ?

red tiger
#

If you tick you are hitting every tick. If your player updates and the code isn't needed to be ran all the time then this works.

#

If you ever plan on writing code that needs to run periodically, look at the slowest options for updates first. If this doesn't work, then put it on something that updates more frequently and / or consistently.

steady lagoon
#

does anyone have any idea about what:

variable:addXPBoost(Perks.MAX, 10);

does this raise all perks to 10? I don't recognise this MAX field

violet shell
red tiger
#

State-monitoring is boring code anyways. =)

stone linden
#

Has anyone made a mod adding electrical wiring for things or is it all still based on range from a generator?

violet shell
red tiger
verbal yew
red tiger
#

The point of having events is to filter when something happens so I'd be concerned if this is a deprecated, redundant tick event.

#

@frank elbow

verbal yew
#

and see in -dubug

#

how offen this events call

red tiger
#

Also as a reminder: The wiki isn't fully accurate with events.

#

It'll get whackier with 42.

#

Albion has worked against the problem.

#

She does the documentation for Lua events for Umbrella.

#

So if you need insight for documentation from things like JavaDocs and Lua events, you can use Umbrella in vscode to get documentation in IntelliSense when calling API.

violet shell
red tiger
#

Or wait one sec.

#

You need lua-server extension

#

But yeah typings for Lua are available. <3

violet shell
#

I'm a self-taught in modding and lua/java programing

red tiger
#

=)

violet shell
#

What is vscode ? I use notepad++ to code my mods

red tiger
#

Umbrella replaces a burdensome old library called Capsid that forced you to compile your own typings from Java without any human documentation.

red tiger
red tiger
#

Yeah PZ has a huge notepad++ community.

#

I've slowly worked on y'all to get to vscode. =D

frank elbow
red tiger
#

Font rendering in vscode is a big deal.

red tiger
#

I still can't believe that I can make a fucking uint32 work in Lua 5.1 in Kahlua. It's so wild.

#

I broke myself figuring this out.

frank elbow
#

I only needed to JSON encode primitives, but break with kahlua how? Not encoding objects correctly?

red tiger
#

I think something like evaluate was bugging up because it didn't exist. os.time as well

frank elbow
#

Ah, that. I did have to replace next but that's about it

red tiger
#

Yeah.

#

You're fine then.

#

People will trip on that issue because most here follow instructions for more simple code solutions on mods.

#

(Content mods)

#

So if someone needs it that exists.

red tiger
#

Old screenie but yeah

frank elbow
#

Heck yeah

red tiger
#

I want modders to know just how powerful they are when they can take the wheel on documenting code that needs help.

#

=)

#

For real and being serious, so much discussion here are largely the same questions that would be answered with modest documentation from a few minutes of contributions over time.

#

I'm going to target the ISUI / UI Lua libraries so that it can get a good head-start.

#

This one might be dated not sure. Will need to grab my flashdrive for the current one. You can see it though.

coarse sinew
#

I'm not sure how else I could let them choose whether to be floor or ceiling

mellow frigate
mellow frigate
bright fog
bright fog
#

Is that an admin thing tho ?

coarse sinew
coarse sinew
thorn brook
#

hey if i'm doing procedural distributions for a true music addon

#

and i have for example this:
table.insert(ProceduralDistributions.list["OfficeDesk"].items, 0.01);

#

0.001 would make it even rarer right?

#

can i make it even more rare than 0.001? because i got about 600 tapes and they still seem to be spawning a lot

bright fog
coarse sinew
#

I haven't played normally in like half a year or so . I've just been working on it

bright fog
#

yeah exactly like me with my mods lol

vestal gyro
#

Since its a double you wont be running out of decimal places when the maximum is 17^-324 in java

thorn brook
#

seemed to work fine on apocalypse preset