#mod_development

1 messages Β· Page 41 of 1

clear bloom
#

omg

#

another table...

hearty dew
#

@blissful salmon Haven't verified by testing this, but as far as I understand things at this point, using IsoGameCharacter:playSound() should do what you want for other multiplayer clients. However, there needs to be a GameSound associated with the sound, otherwise the range defaults to 70 (not sure if those distance units are tiles or what). That said, since the client that originates the sound doesn't play it after about 20 tiles, you may have to handle that case specially.

Only other option I'm seeing is to do it yourself via client/server commands

#

Yea, that's a good use case for it

#

I should use pcall similarly. I have a thing where I do```lua
local old_isClient = isClient
function isClient() return true end
unsafe_fn()
isClient = old_isClient

Would be bad if `unsafe_fn()` errored πŸ˜…
winter thunder
#

trying to load a mod into my single player for testing, and I am not getting anything to load properly. Anyone willing to take a look it and see if I messed something up somewhere? it is a mod to add short ranged intercom-style radios to the game for factions in MP and stuff

hearty dew
winter thunder
#

I got it to enable at first, but after I tweaked some personal mistakes, it will no longer load at all

thick karma
#

Unfortunately this cosmetic issue is only fixable using an option that affects gameplay slightly. It temporarily, for 2 seconds, zeroes your HoursSurvived, whenever you are doing something likely to reward XP and thus cause a halo note to appear. If you know any more efficient way to accomplish exactly the same goal, I'm all ears. Therefore I am offering a server setting to admins that allows them to block this feature of the mod if they do not want to allow their players to compromise HoursSurvived variable under any circumstances.

#

I tried for many, many hours and requested help many times, and to my knowledge no one on this server has any better solution for preventing all halo notes from showing (at least not something doable in Lua and automatically installable via the Workshop).

#

Please, please prove me wrong.

#

Tyrir recommended a solution that came close, but ultimately failed in more situations and more variations of halo notes than the one I'm finally settling on.

tawdry solar
#

do i retexture all these

thick karma
#

Sure looks relevant to me. @tawdry solar But this assumes you're retexturing his energy drink items... Might be weird because your end result seems like it would be energy drinks that look like beers?

#

Probably need to play with the Lua a bit so that the things that look like beer say Beer.

tawdry solar
#

i will

#

do i use vsc to use luas?

thick karma
#

But, FYI, it's cool, I established a workaround. I can use the Sandbox Var as an extra condition for the hiding of stuff, no problem afaik.

hearty dew
tawdry solar
#

@thick karma can i use vsc to read lua files

thick karma
#

Yeah I use VSC

winter thunder
tawdry solar
#

i have basic knowlage of it

winter thunder
#

Notepad++ works great too, tbh. If you just wanna look at basics and stuff

tawdry solar
#

@thick karma how do i change the name?

hearty dew
tawdry solar
#

WHEEEY

thick karma
thick karma
tawdry solar
#

i textured it

tawdry solar
thick karma
#

Also probably some labels in shared/translate if I had to guess

undone elbow
# hearty dew I should use pcall similarly. I have a thing where I do```lua local old_isClient...

My injections are a bit more complicated. There are double and triple injections. πŸ˜΅β€πŸ’« For example, this is double:

-- main injection
local old_contextMenu = ISVehicleMechanics.doPartContextMenu
function ISVehicleMechanics:doPartContextMenu(...)
  local old = ISContextMenu.addOption -- ninja injection
  function ISContextMenu:addOption(txt, t, o, a, b, ...)
    if b and type(b) == 'userdata' and b.hasModData and b:hasModData() then
      local data = b:getModData()
      if data.feces then
        txt = txt .. 'f'
      elseif data.urine then
        txt = txt .. 'u'
      end
    end 
    return old(self, txt, t, o, a, b, ...)
  end
  pcall(old_contextMenu, self, ...)
  ISContextMenu.addOption = old
end
#

Now it will finish correctly even if there are errors inside (even if the error is in my own injected function).

tawdry solar
#

whats all this

thick karma
#

Looks like they're inserting item objects into a table of items categorized by item type.

#

Not 100% sure, I've never modded items.

#

@tawdry solar

tawdry solar
#

ah

#

alr

#

can you try and help

#

i can paste the lua

wet gorge
#

How to get name of vehicle, not the id but the name that would be in translation file.

#

getFullName() and getName() is just the id...

#

Couldn't find any other methods to do this.

keen shard
#

Anyone know anything about making profession mods? im trying to make one and i cant get the professions to show up in character creation

hearty dew
hearty dew
# tawdry solar whats all this

pz uses the ProceduralDistributions table to generate loot in containers. If you run pz in debug mode and turn on lootZed, I believe it will display the percentages for you when right-clicking a container

wet gorge
hearty dew
# hearty dew pz uses the `ProceduralDistributions` table to generate loot in containers. If y...
hearty dew
#

That's supposed to be a bit more up to date, not that it helps in this case here

wet gorge
#

Cheers, I'll note to use that instead. Sadly I see nothing different.

hearty dew
#
ProjectZomboid/media/lua/client/Vehicles/ISUI/ISVehicleMechanics.lua:   local name = getText("IGUI_VehicleName" .. self.vehicle:getScript():getName());
#

Looks like it isn't done neatly on the java side for ya peeposhrug

#

Have to append the id to the prefix used for the ui string id, then look it up using getText

#
function ISVehicleMenu.getVehicleDisplayName(vehicle)
    local name = getText("IGUI_VehicleName" .. vehicle:getScript():getName())
    if string.match(vehicle:getScript():getName(), "Burnt") then
        local unburnt = string.gsub(vehicle:getScript():getName(), "Burnt", "")
        if getTextOrNull("IGUI_VehicleName" .. unburnt) then
            name = getText("IGUI_VehicleName" .. unburnt)
        end
        name = getText("IGUI_VehicleNameBurntCar", name)
    end
    return name
end
#

Or just call that function passing it a vehicle object

undone elbow
trail lotus
#

i've got a custom server i host. i want to add public locations on the map. is there a way to do this?

#

this way when a player joins he can press m, open his map and see where certain areas are, or a location. (essentially one shared map controlled by admin that updates onto everyone's map.)

wet gorge
trail lotus
#

i was looking at that, basically when players join i could share my map possibly? then it would update theres and give them all the custom stuff.

thick karma
# tawdry solar i can paste the lua

Kinda busy with my own modsanity right now but you should try following this https://m.youtube.com/watch?v=N6tZujOPnDw

This tutorial video will show you how to make a simple drink in Project Zomboid. I will go into the steps involved from start to finish. Read more below.

0:00 intro
1:08 Start
1:44 Searching for images to use in game
2:30 Searching for the Sound Effect
3:06 Creating mod file directory
3:54 Creating mod.info
4:34 Creating a poster
7:14 Adding ne...

β–Ά Play video
#

It's about making a drink mod

thick karma
#

Oh man y'all I'm moving to the test-alongside-70-other-mods stage... wheeee

trail lotus
#

any devs that specialize in the uis and game mechanics let me know if youre interested on working on some custom mods for my server. i'd love to pay for some cool systems i need.

#

and im looking to expand my team if you would like to come hangout and work with other modders πŸ™‚

thick karma
trail lotus
#

we are looking for police related systems, like arresting players and moving them and placing them in cars

#

we are looking into custom phones to message players.

#

looking into a respawn system to keep players keys after death and character, however drop all other items

#

hmm, all kinds of rp related systems

#

if interested dm me ill get you in the server or we can dm and talk about the ideas we have. we have 100+ members all with at least one idea haha

#

aiteron normally works on everything for me but hes super busy as they are probably working hard on the actual game right now πŸ™‚

thick karma
trail lotus
#

but you have access to some of the best modders and a game dev on the team!

#

personally i just founded the server, i manage it, the devs work on it and i come up with the plan and they some how always manage to do it they are so talented haha

#

personally they make the stuff and i donate to them when they make it happen.

thick karma
#

I'll consider the texting thing first. If I have any good ideas I'll try some stuff.

trail lotus
#

yes, a big thing also is the police and emergency system as well

#

i have tons of ideas lol, we are still in early beta at the moment the server is only open to goverment workers, emergency services, and store owners.

thick karma
#

The police system sounds like a very big project. A lot would need to go into that. I can only begin to guess about some of it.

#

Right now I am finishing up a few more of my own mods but I will look into some other people's issues more after

trail lotus
#

sort of waiting to get a respawn system built so players dont lose keys at death.

#

but no problem man just let me know what you can work on or what you think may help the server.

thick karma
#

Releasing one mod for hiding UI better than in vanilla (works well for gamepad users, improves things for everyone), another for quickly dismissing windows that clutter the screen (mainly for gamepad users), and another mod that allows me to "meditate" by sitting and thus become invisible to zombies until I move or press buttons. Trying to get all three polished and tested and live asap. Will let you know if I make progress on one of your above ideas after.

trail lotus
#

awesome

thick karma
# tawdry solar outdated

That may be so, but the entire game has not changed in every conceivable way since late 2020... That video is still for build 41, the most recent build of the game. So outdated here means "is no longer correct on a small handful of points at most." I would try to follow it until something doesn't work, and then ask here about exactly the things that don't work... people will probably tell you how to fix you're problem if you can ask specifically enough for the answer.

tawdry solar
#

ah

#

i just need to change names

signal saffron
astral dune
#

the tutorial isn't broken, its deleted. Something about the loot settings not working or being replaced with something else

wet gorge
#

@hearty dewAny idea how to use self.vehicle:getEnginePower()/10? Been trying past few hours.

#

Basically trying to dump vehicle stats. So far got id, real name, and some other stats from vehiclescripts.

thick karma
#

@wet gorge self is coming from the fact that the function in which you found that is an ISVehicleMechanics object with data including a vehicle object. If you check ISVehicleMechanics, you'll find ISVehicleMechanics:new, which instantiates the menu. If you search all your Lua for ISVehicleMechanics:new, you'll see it gets instantiated as mechanicsUI in ISPlayerDataObject.lua... search for mechanicsUI and you'll find in ISPlayerData a function that returns that mechanicsUI for a given player: getPlayerMechanicsUI(playerIndex). If you call that, you can play with the mechanicsUI object. It will not have a vehicle unless you are actually accessing one.

#

E.g., here's how I hide that UI:

    local mechanicsUI = getPlayerMechanicsUI(playerIndex)

    if mechanicsUI and mechanicsUI:isVisible() and interfaceReflexes.options.shortcutsCloseMechanicsMenu then

        mechanicsUI:close()

    end
#

close() is always going to be available when it's visible. Presumably vehicle would also be available at this moment.

wet gorge
#

πŸ€” Confusing.

hearty dew
#
print(self.vehicle:getEnginePower())

?

#

Don't understand what you mean by 'use' in your question

wet gorge
#

getEnginePower seems to only work when a character is inside vehicle though.

trail lotus
#

anyone looking to make a quick buck let me know. i need a mod where when you place a item down you can right click on it and there will be a option that says "set price" so players instead of being able to pick it up they would have to pay the amount once they pay it it picks the item up

#

it would have to work with my servers custom currency mod, aiteron could help you integrate it if needed but hes busy working on the actual game right now haha!

#

it would some how have to reward the player that set the item down the amount of money paid. whether it gets sent to their inventory or to the bank account i dont care. id prefer to the players inventory but what ever makes that system work.

hearty dew
wet gorge
#

This user is onto something about enginepower in particular.

hearty dew
#

If you're just interested in dumping general info about vehicles, why not stick to what's available in the VehicleScript objects?

wet gorge
#

Some of the methods return incorrect values like: getStorageCapacity

hearty dew
hearty dew
hearty dew
#

Those are the fields of a VehicleScript object. They might have info you are interested in

wet gorge
#

Yeah storageCapacity is set to 100 for every vehicle for some reason. Thanks for image.

hearty dew
#

all the get* method results from the first VehicleScript object

#
PyroUtils = PyroUtils or {}
PyroUtils.debugInvokeMethods = function(object, methodName, ...)
    local output = {}
    for i = 0, getNumClassFunctions(object) - 1 do
        local method = getClassFunction(object, i)
        if string.find(tostring(method), "%."..methodName) then
            local result = method:invoke(object, ...)
            table.insert(output, string.format("Method invocation result:\n%s\n%s", tostring(method), tostring(result)))
        end
    end
    print(table.concat(output, "\n"))
end
#

did something similar for the fields

#
PyroUtils.debugInvokeMethods(getScriptManager():getAllVehicleScripts():get(0), "get")
#

probably some mistakes in that output bc I didn't catch the errors when the get* method expected parameters and none were provided and it thus failed to invoke

wet gorge
#

Big brain.

drifting ore
#

how resource intensive are zombie corpses? would a mod to automatically consolidate loot from large piles of corpses into fewer ones be beneficial for crazy population servers?

ruby urchin
#

here a thing

#
---Override a function.
---@param p1 class
---@param p2 string
---@param p3 function
Utils.overrideFunction = function(p1, p2, p3)
    local override = p1[p2];

    p1[p2] = function(self, ...)
        override(self, ...);
        p3(...)
    end
end
#

usage:

UTILS.overrideFunction(ISWorldMap, "onRightMouseUp", function (x, y)
    print("x: " .. tostring(x))
    print("y: " .. tostring(y))
end)
undone crescent
#

does anybody have an idea where i could find some reference on how animated tiles work? like for water and fire? am i correct by assuming that the tiles just replace each other on a specific circumstance? so shouldnt it work like this (just example): function replacesprite OnGameTick getSprite x and setSprite y

#

i would like to make a tile which look different depending on ingame time

#

but im super bad at all the coding stuff πŸ˜„

#

like i can do basic recipes but thats about it

#

thanks in advance for anyone giving me the smallest hint πŸ˜‰ πŸ‘

tardy wren
#

I don't think that they work by replacing tiles, that sounds far too laggy...

fast galleon
copper torrent
#

anyone know why when i try to repair clothing i get an error bottom right and when my character finishes his action it doesen do anything

#

its with any type of clothing no matter if modded or unmodded

tardy wren
copper torrent
#

oh yeah just noticed sorry

tardy wren
#

Is there a somewhat simple mod that implements and uses custom sandbox settings I can refer to when making mine?

marble lynx
tardy wren
#

Thanks, I'll check them out

grim rose
#

guys

#

what happened with distros

#

im tyring to find it in zomboid files

#

i can't

#

nvm

#

i found it

undone crescent
undone crescent
fast galleon
#

sometime I gotta check that mod out, had no idea that thing was animated

undone elbow
#

Hm...

-- a bit faster if x is global (and is not set):
if x == nil then 
-- a bit faster if x is local (and equal to nil):
if not x then 
#

In general "not x" is faster

#

On a square there are functions: ```lua
:getStaticMovingObjects()
:getObjects()
:getSpecialObjects()
:getMovingObjects()
:getWorldObjects()

What is the difference? What is included in "moving" or "world" objects, or just "objects"?
fast galleon
#

hm, moving objects are things like player and vehicle(?)
objects is a list of all objects including those you just drop
special objects are usually those you place like moveables and generator

#

maybe someone has a better defined list

blissful salmon
#

Is there already a function which looksup for example "woodcutting" -> "carpentry" and vise versa? I'm often confused if I have to use the skill or perk name.

#

and another question: To distinguish between solo and multiplayer I currently use:

  return (not isClient() and not isServer())
end```
Is there a better way than this?
undone elbow
#
SoulMod.shared_isSoloGame = not (isClient() or isServer())
#

It's calculated once on initialisation, then it's just a boolean variable.

blissful salmon
void fractal
#

What do you guys use to code the mods? I hear some people use Notepad++ and i am confused on why

tardy wren
#

Notepad++ has syntax highlighting for Lua

#

Also lets you collapse blocks and switch between files as tabs

void fractal
#

Can't you get that with vscode and the right plugins for it?

tardy wren
#

Yes

#

But Notepad++ is just more convenient

#

VSCode works almost like an IDE, whereas N++ is just... An editor

void fractal
#

hmm i see

#

well thanks for telling me on why people prefer to use it

bronze yoke
#

most people here use ides i think

blissful salmon
void fractal
#

ooh

#

yeah vscode is usually my go-to so ill stick to that

blissful salmon
#

I use the sumneko Lua plugin

void fractal
#

Ah i see, Thanks a lot

bronze yoke
sick shore
#

Hey guys I wanna make a mod that retextures some clothes in game but have no experience in coding and stuff, can anyone help me the basic stuff?

#

If there’s like a tutorial vid or anything that would be great

blissful salmon
blissful salmon
blissful salmon
# sick shore Hey guys I wanna make a mod that retextures some clothes in game but have no exp...

I made a quick google search (zomboid modding tutorial) and found this. I remember that I learnd some stuff from it...
https://www.youtube.com/watch?v=N6tZujOPnDw

This tutorial video will show you how to make a simple drink in Project Zomboid. I will go into the steps involved from start to finish. Read more below.

0:00 intro
1:08 Start
1:44 Searching for images to use in game
2:30 Searching for the Sound Effect
3:06 Creating mod file directory
3:54 Creating mod.info
4:34 Creating a poster
7:14 Adding ne...

β–Ά Play video
sick shore
#

Ah thank you very much, I'll be asking some questions from time to time so hopefully everyone can help me out with my first steps in modding. Alright thanks for these starters dude I'm gonna take a look at them now.

#

Oh the video is long this is good

blissful salmon
#

Maybe others here have better sources but this is more or less how I started.

#

Does someone know how LUA gets the globalobjects from java? Are they created at runtime?

drifting stump
#

everything is a java object those simply get exposed to the lua interpreter

#

iirc decompile LuaManager$Exposer.class to see whats exposed

thick karma
#

Anyone know how to trigger a doContextualDblClick(item) on your InventoryPane items manually? So far, I've figured out I can get a highlighted item like this (note, I am using gamepad here, so I am interested in identifying the item based on gamepad focus):

bat = getPlayerInventory(0).inventoryPane.items[getPlayerInventory(0).inventoryPane.joyselection + 1]

Though I am not clear what kind of item this gives me, it returns some kind of Lua table. print(bat.name) seems to confirm this is a bat by printing Baseball Bat. However, then I go on to attempt this:

getPlayerInventory(0).inventoryPane:doContextualDblClick(bat)

And even though there are no errors, nothing happens.

I also tried this:

ISInventoryPaneContextMenu.equipWeapon(bat, true, bat:isTwoHandWeapon(), 0)

That one made the compiler mad, but the error gets thrown from some random file (tsarzones.lua?) so I'm unsure of the problem its actually causing

blissful salmon
# drifting stump iirc decompile LuaManager$Exposer.class to see whats exposed

But can I get a list of exposed stuff in lua? I know about the java file where I can check whats exposed. But I'm looking for a way to get these functions from lua:
https://projectzomboid.com/modding/zombie/Lua/LuaManager.GlobalObject.html
Maybe my goal is weird but my idea was to write these functions into a lua file which I can add as library to my Visal Studio Code. So just make them empty functions so my VS accespts dem as recoginzed... Maybe I could also parse the java class but this seems more complicated. So I just hoped I can do this on the fly.

bronze yoke
# blissful salmon But can I get a list of exposed stuff in lua? I know about the java file where I...

i was just looking for the same kind of thing and found this tool https://github.com/cocolabs/pz-zdoc but it hasn't been updated in 2 years and doesn't seem to work at all on my computer

GitHub

ZomboidDoc is a Lua library compiler for Project Zomboid. - GitHub - cocolabs/pz-zdoc: ZomboidDoc is a Lua library compiler for Project Zomboid.

#

there's signs that people have still been using it successfully very recently though, so it may work for you

blissful salmon
thick karma
bronze yoke
drifting stump
#

Already have the full list of methods can copy paste then a little replace to convert to lua and done

thick karma
#

Ugh I can pull item names from any bag all day 😭

#

But doing something with them? Oof.

blissful salmon
wet gorge
torn geyser
#

recently when i use mods it wont let me pick up anything and when im in the animation of picking something up there is just thousands of errors is there a way to fix it

wet gorge
thick karma
#

Which way is faster kind of depends on you

torn geyser
thick karma
#

You add -debug to Steam launch options, join your game normally, hit F11 in game, click Errors and read the log to see the source files. If it's a mod's file (if you recognize mod name), disable it.

#

Repeat

#

Until errors go away

thick karma
wet gorge
calm acorn
#

not sure what storage capacity is for, but this is from carwanna to get to the container of a vehicle.

        for i = 1, vehicle:getPartCount() do
            local part = vehicle:getPartByIndex(i - 1)            
            local partItem = part:getInventoryItem()            
            local partId   = part:getId()   
            if partItem then  --this part is installed
                    local container = part:getItemContainer()
                    if container then --this part is a container. 
                        print("Container: "..container:getItems():size())  --This holds items
                    end
            end
        end

feel free to pick apart the code: https://steamcommunity.com/sharedfiles/filedetails/?id=2801264901

You should be able to get the size with container:getMaxCapacity()

You can also just go short hand directly to the part: vehicle:getPartById("Trunk"):getMaxCapacity() but some mods dont use the default Trunk (ki5) so you would need to loop though all the parts anyway

undone elbow
#

Can I remove a world item from client? I found this code: lua sq:transmitRemoveItemFromSquare(item); item:removeFromWorld() item:removeFromSquare()

hearty dew
hearty dew
undone elbow
#

Hm... sq:transmitRemoveItemFromSquare(item) causes error.

#

Should item be InventoryItem or WorldItem?

tardy wren
#

so, for float values in a sandbox option, I write... float?

hearty dew
tardy wren
#

okay

hearty dew
#

IsoObject? πŸ˜…

#

Maybe the java code checks the runtime type and handles it specially if it is a Inv or World item

tardy wren
#

What are the "Project Zomboid Modding Tools" I've found on the steam?

hearty dew
#

There should be a directory in your steam games with them all. It includes TileZed... that's all I remember 😝

weak sierra
midnight plaza
#

Hey guys, just a theoretical question. Is it possible to make something like a landmines in PZ?

blissful salmon
# hearty dew ~~might be in the java namespace table that kahlua exposes.~~ It is not unfortun...

Thanks for the feedback. I already found the functions in _G after my last post. I've created a testfunction:

  if type(v) == "function" then
      print(i)
  end
end```
And next step is to write them to a file like normal lua functions. By adding this to VS Code I think I can solve most of the displayed error and have better integration. I'm not sure but I thought I read something that I can't write to files with the normal LUA function but project zomboid has some support to it? Do you know an example?
weak sierra
#

that explains wtf _G is, i saw that in a mod recently

#

was like "where do they define that"

ruby urchin
blissful salmon
hearty dew
# blissful salmon Thanks for the feedback. I already found the functions in _G after my last post....

You're liable to get a bunch of other functions sitting in _G for other purposes (false positives), but that will at least capture them all, heh

    public void exposeGlobalFunctions(Object object) {
        Class<?> clazz = object.getClass();
        readDebugData(clazz);
        for (Method method : clazz.getMethods()) {
            LuaMethod luaMethod = AnnotationUtil.getAnnotation(method, LuaMethod.class);
            if (luaMethod != null) {
                String methodName;
                if (luaMethod.name().equals("")) {
                    methodName = method.getName();
                } else {
                    methodName = luaMethod.name();
                }
                if (luaMethod.global()) {
                    exposeGlobalObjectFunction(environment, object, method, methodName);
                }
            }
        }
    }

    /**
     * Creates a global variable in the environment that points to a function
     * which calls the specified method on the owner object.
     * <p/>
     * The name of the global variable is the same as methodName
     *
     * @param environment
     * @param owner
     * @param method
     * @param methodName  the name of the method in Lua
     */
    public void exposeGlobalObjectFunction(KahluaTable environment, Object owner, Method method, String methodName) {
        Class<? extends Object> clazz = owner.getClass();
        readDebugData(clazz);
        LuaJavaInvoker invoker = getMethodInvoker(clazz, method, methodName, owner, false);
        addInvoker(environment, methodName, invoker);
    }

That's how the globals are exposed in lua. So, justs sits in _G

#

Can use ArendamethUtils.writeFile (or at least look at its implementation)

blissful salmon
hearty dew
drifting ore
#

Hello. Where can I find documentation with functions and descriptions?

weak sierra
hearty dew
hearty dew
#

I need to go find a better way to read console.txt

hearty dew
blissful salmon
hearty dew
weak sierra
#

i have no function made for that

#

i just poke around by hand in debug

#

<_<

#

so now i do :)

hearty dew
weak sierra
#

yeah that'll make it easier

weak sierra
#

have u tried just activating the debug mode console without debug mode?

#

and/or seeing how they implemented that

#

im guessing it's in java or else that'd be super easy

#

but often debug features can be accessed outside of debug mode

#

that console does suck tho

hearty dew
#

It's in java. Yea, I looked at that first. Wanted to make it resizeable, but couldn't

weak sierra
#

yaeh

#

the no resizing is my number 1 complaint

#

followed by it seemingly having EXTRA output that i don't want

#

which might be jsut cuz debug mode

#

there might be a setting for that that im ignorant of tho who knows

clear bloom
#

btw the game is coded in a mixture of lua and java right?

weak sierra
#

yeah

hearty dew
clear bloom
#

from what i am understanding

hearty dew
clear bloom
#

if so do i have to learn lua and java to mod

#

or just lua

shadow vault
#

Is there a mod to pick everything up? Like tvs, water fountains, lamps, etc..?

#

Or is that a thing already

clear bloom
#

you can already pick those things up right?

weak sierra
#

otherwise u have to have users manually install the mods

clear bloom
#

ok good

weak sierra
#

u could also use typescript with something called pipewrench if u wanted to

clear bloom
#

ill try to see if i can understand lua better

weak sierra
#

but it's a limited implementation of typescript on top of a limited implementation of lua

clear bloom
#

my coding knowledge is quite limited

drifting ore
clear bloom
#

but i heard lua is simpler

#

for now the only thing i can do is script related

weak sierra
#

it's simpler but has more pitfalls

clear bloom
#

hmmm i see

hearty dew
clear bloom
#

ok so to edit lua files i have to decompile the .class files and then work on them

weak sierra
#

no, that's java

clear bloom
#

oh damn

weak sierra
#

u dont have to decompile/recompile anything for lua

#

just edit scripts

#

:p

clear bloom
#

ok ok

#

is most modding done with lua editing

clear bloom
#

or is editing the game's vanilla code used a ton

hearty dew
clear bloom
#

i even wonder if what i want to do is in the luas

#

bcs it seems like something that would be out of scripts files

#

but it isn't there lol

fast galleon
#

@hearty dew is there a place I can find all these tools you keep posting from time to time? Maybe also add a link to the modding section of wiki.

drifting ore
#

But as I understand

hearty dew
drifting ore
#

There's no descs

hearty dew
hearty dew
blissful salmon
# hearty dew root for that one is `~/Zomboid/Lua`

Can I break out of this folder? I tried ../dev/lib/filename or c:\path\to\ or c:/path/to/
It's ok when it's not possible for security reasons or so... Thiniking about that I wouldn't make it possible if I did the stuff...

thick karma
#

Can anyone help me make this work as intended?

bat = getPlayerInventory(0).inventoryPane.items[getPlayerInventory(0).inventoryPane.joyselection + 1]
-- intention: get bat item from inventory slot highlighted by joypad focus.
-- result: returns a table of some kind.

print(bat.name)
-- intention: print name of inventory item I grabbed.
-- result: prints "Baseball Bat" (success?)

getPlayerInventory(0).inventoryPane:doContextualDblClick(bat)
-- intention: Trigger a double-click action on the bat in the player's inventory by sending the item to the doContextualDblClick event.
-- result: Nothing happens (no errors).
drifting ore
hearty dew
thick karma
hearty dew
drifting ore
#

Man

#

Ure brathetaking

hearty dew
# blissful salmon Fully understandable...

They all have checks like```java
if (string.contains("..")) {
DebugLog.Lua.warn((Object)"relative paths not allowed");
return null;
}

except this one is missing the check:
```java
public static LuaFileWriter getSandboxFileWriter(String string, boolean bl, boolean bl2)

Maybe the LuaFileWriter has some check internally, idk, but you might try that

thick karma
# drifting ore Thanks A LOT

In Konijima's tutorial, the decompiled build folder appears on the right side of the photos. My decompiled build folders were on the left side of my screen. Just FYI.

#

Was confusing for like 10 seconds.

blissful salmon
fast galleon
hearty dew
clear bloom
#

btw anyone know how the game correlates an items atribute while being crafted to a certain level of a skill

#

like how much hunger it will reduce based on cooking

#

or how high the maintenance of a spear goes up with carpentry

#

i've tried looking at the lua for recipes or the scripts

#

can't find anything

fast galleon
blissful salmon
# hearty dew They all have checks like```java if (string.contains("..")) { ...

I'm one step further... First I include your Utils file with the write stuff and then I created a file with the following code:

for i,v in pairs(_G) do
  if type(v) == "function" then
    SoulUtils.writeFile("lib/exposedFunctions.lua", "function " .. i .. " (var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, var15, var16, var17, var18, var19, var20) end\n", true, true)
  end
end```
Added this under VS Code as Library for the workspace and now the functions are known...
For example:
```function SoulMod.Test(key)
  local player = getPlayer()

  if key == Keyboard.KEY_NUMPAD1 then
    local cell = player:getCell()
    if not cell then return end```
The getPlayer() is now an accepted function. But of course player:getCell() is not... Do you have an idea how I can generate the java objects? Is this even possible? Do you think it should be possible by converting the "Grand Solution" to a lua file? I'm not sure if this even doable because the : also means the first parameter is self in lua.
hearty dew
#
--[[
    Usage example:

    local function func(arg1, arg2)
        print(tostring(arg1))
        print(tostring(arg2))
    end
    local debouncedFunc = MxUtils.debounce(func, 5000)

    debouncedFunc("foo", "bar")
]]
MxUtils.debounce = function(func, timeout)
    local intervalTimer = MxUtils.createIntervalTimer(timeout, nil, false)
    return function(...)
        local args = {...}
        intervalTimer.intervalElapsedEventHandler = function(timer)
            func(unpack(args))
        end
        intervalTimer.start()
    end
end


--[[
    Usage example:
    
    local intervalTimer = MxUtils.createIntervalTimer(5000, function()
        print("5 seconds have elapsed!")
    end)
    
    intervalTimer.start()
    -- ...
    intervalTimer.stop()
    intervalTimer.intervalInMilliseconds = 15000
    intervalTimer.intervalElapsedEventHandler = function(timer)
        print("15 seconds have elapsed, but it will be 25 seconds next time!")
        timer.intervalInMilliseconds = 25000
        timer.myData = timer.myData or {}
        if not timer.myData.doneSomething then
            -- do something
            timer.myData.doneSomething = true
        end
    end
    intervalTimer.autoRestart = false
    intervalTimer.start()
]]
MxUtils.createIntervalTimer = function(intervalInMilliseconds, intervalElapsedEventHandler,
        autoRestart, pollingEventName)
    local timer
    timer = {
        intervalInMilliseconds = intervalInMilliseconds,
        intervalElapsedEventHandler = intervalElapsedEventHandler,
        pollingEventName = pollingEventName or "OnTick", -- Consider Events.OnTickEvenPaused
        autoRestart = autoRestart == nil or autoRestart,
        poll = function(tickCounter)
            local time = math.floor(os.time() * 1000)
            if os.difftime(time, timer.nextIntervalTime) >= 0 then
                if not timer.autoRestart then
                    timer.stop()
                end
                timer.nextIntervalTime = time + timer.intervalInMilliseconds
                timer.intervalElapsedEventHandler(timer)
            end
        end,
        stop = function()
            Events[timer.pollingEventName].Remove(timer.poll)
            timer.isRunning = false
            return timer
        end,
        start = function()
            timer.nextIntervalTime = math.floor(os.time() * 1000) + timer.intervalInMilliseconds
            if not timer.isRunning then
                Events[timer.pollingEventName].Add(timer.poll)
                timer.isRunning = true
            end
            return timer
        end,
    }

    return timer
end
    local function func(arg1, arg2)
        print(tostring(arg1))
        print(tostring(arg2))
    end
    local debouncedFunc = MxUtils.debounce(func, 5000)

    debouncedFunc("foo", "bar")
    debouncedFunc(1, 2)
    debouncedFunc("I", "win") -- Only this one is called 5000ms later

I changed the interval timer a bit, and it fit into being used for debouncing a bit better, I think

gilded hawk
hearty dew
# blissful salmon I'm one step further... First I include your Utils file with the write stuff and...

It is possible to get the methods and fields from the java objects, yes. #mod_development message does that and prints them out.

I'd have to know a bit more about how your autocompletion system works in order to know how to relate the return types of each global function to the appropriate method/fields. Lua isn't statically typed, so it isn't immediately clear how that autocompletion system does it (maybe there is a way you can annotate each function to say this returns an "IsoPlayer" and also give it another file that says "these are the IsoPlayer functions to use for autocomplete", but I'd have to dig into it to see how it accomplishes that for lua since lua doesn't have a static return type for each function (in fact it can change at runtime)

#

Also, you could iterate over __classmetatables. In each field, the key is a java Class (so can use getName(), I believe) and the value is the metatable for that type (containing the instance methods).

static methods and static fields are stored in the table that kahlua generates when the type is exposed e.g. zombie.characters.IsoPlayer. Could iterate over those starting from the namespace roots e.g. zombie, fmod, etc

blissful salmon
#

So thats were I'm standing now... Maybe there are better ways... The additional Library folder of course will never be included in zomboid at runtime. I just thought about it to fake the exposed stuff in one or more files.

#

Posted the image again. Didn't managed to replace it in the message above...

hearty dew
undone elbow
#

I'd like to add "step in shit" feature to Excrementum mod. What do you think about a good balance? By now chances are:

Running = +5%, Sneak = -5%.
Clumsy = +10%, Graceful = -10%.
Unlucky = +5%, Lucky = -5%.
Drunk (level 3 or 4) = +15%.
Tired = +5% (level 1), +10%, +15%, +20%.
Short Sighted = +2% with glasses or +8% without glasses.```
thick karma
#

1 / 10 steps you land in shit?

#

Seems excessive if so

fast galleon
blissful salmon
undone elbow
thick karma
#

Ahhhh that makes sense. Not bad. Would be cooler if you could make it based on proximity to a visible object.

#

Not sure if that's possible

fast galleon
#

wouldn't sneaking have more chance then, like army training literally has you face in shit

thick karma
#

I would prefer to avoid feces mainly by consciousness rather than RPG mechanics, but the idea of being able to get annoyed by stepping in it is classic

#

Will the smell attract zombies or something?

#

Or just make your character unhappy?

thick karma
#

We're not army-crawling in the game

blissful salmon
fast galleon
hearty dew
#

that one?

undone elbow
gilded hawk
hearty dew
#

So that has some info on how to annotate functions

thick karma
thick karma
#

Would be nice to give a way to clean it up instead of taking your chances @undone elbow

hearty dew
#

Presumably the autocompletion system makes use of that

undone elbow
#

Oh I found!
world_item:getWorldPosX()

blissful salmon
#

I'm not sure how it works all in all. I installed the following plugins:
For zomboid I can't (or at least don't) use the debugger. So it's only the sumneko Lua Language Server and VSC itself. I just added the folders as libraries to the Workspace Settings...

undone elbow
#

So these won't affect. Too far))

tardy wren
#

Okay, uhh...

STACK TRACE
-----------------------------------------
function: JarredFoodAdjuster.lua -- file: JarredFoodAdjuster.lua line # 4 | MOD: Jarred Food Spoilage Adjuster

ERROR: General     , 1666813865695> 92Γ‘621Γ‘841> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: Object tried to call nil in JarredFoodAdjuster.lua at KahluaUtil.fail line:82.
ERROR: General     , 1666813865695> 92Γ‘621Γ‘842> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: Object tried to call nil in JarredFoodAdjuster.lua
        at se.krka.kahlua.vm.KahluaUtil.fail(KahluaUtil.java:82)
        at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:973)
        at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:163)
        at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1980)
        at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1782)
        at se.krka.kahlua.integration.LuaCaller.pcall(LuaCaller.java:76)
        at se.krka.kahlua.integration.LuaCaller.protectedCall(LuaCaller.java:117)
        at zombie.Lua.LuaManager.RunLuaInternal(LuaManager.java:559)
        at zombie.Lua.LuaManager.RunLua(LuaManager.java:505)
        at zombie.Lua.LuaManager.RunLua(LuaManager.java:491)
        at zombie.Lua.LuaManager.LoadDirBase(LuaManager.java:334)
        at zombie.Lua.LuaManager.LoadDirBase(LuaManager.java:261)
        at zombie.network.GameServer.doMinimumInit(GameServer.java:1405)
        at zombie.network.GameServer.main(GameServer.java:684)
LOG  : General     , 1666813865711> 92Γ‘621Γ‘848> -----------------------------------------
STACK TRACE
-----------------------------------------
function: JarredFoodAdjuster.lua -- file: JarredFoodAdjuster.lua line # 4 | MOD: Jarred Food Spoilage Adjuster
#

What did I screw up

blissful salmon
tardy wren
#
local recipes = ScriptManager.instance:getAllRecipes()
for i=0, recipes:size() - 1 do
  local recipe = recipes:get(i)
  local recipeItems = recipe:getSource():getItems()
  if recipeItems:contains("EmptyJar") and recipeItems:contains("JarLid") then
    local item = recipe:getResult() 
    item:DoParam("DaysFresh", 274)
    item:DoParam("DaysTotallyRotten", 365)
  end
end
hearty dew
#

and @return and @param

blissful salmon
hearty dew
tardy wren
#

Can I just "Print" the whole Recipe?

hearty dew
blissful salmon
gilded hawk
#

@hearty dew You are making a lot of amazing utilities, maybe it's time to put all of them in a github repo and as a workshop item πŸ€”

safe silo
#

So lets say I have 3 items that all will share the same code..

What can I do to like "if var = ALLITEMS" instead of "if var = item1 or var = item2 or var = item3"

tardy wren
#

Also I don't understand what you suggested to me

hearty dew
safe silo
hearty dew
#

Yes, you could use some java method that does it for you

safe silo
#

Or like making an array possibly? Items = { Item1, Item2, Item3 }

Not super into LUA which is why i am asking haha

hearty dew
#

If you are dealing with java objects, == for equality comparison may not be what you want to be use though.

#

If you have a more specific situation, maybe someone could provide a more appropriate solution e.g. trying to check if an item has certain tags or certain name, etc

safe silo
#

Oh it's not java objects, it's legit just strings I'd iterate through

hearty dew
thick karma
#

Anybody online right now have any way to trigger a call to equip an item in your inventory manually?

tardy wren
#

oh, I think I know

#

GetSource returns me an array, not an object

#

findSource returns me the object...

#

GetResult does give me the result object...

#

It didn't NRE now so I guess that's progress

hearty dew
undone elbow
#

If I'm running using Alt key, player:IsRunning() is false.

hearty dew
#

That's how you can use that function to see what those methods return

tardy wren
#

Ah, I see...

thick karma
#

I DID IT

#

YES

#

I WIN

placid egret
#

hey guys i need help

#

how do you get truemusic to work

thick karma
#

Lmao well I just Used my bat.

#

Result: Bat vanishes from inventory, but still have it...

#

And can still swing it...

#

100/100 will love, publishing now

weak sierra
#

lol

thick karma
#

lol I think it did the breaking animation on 1st whack but remained in existence

#

So it became indestructible

#

By virtue of defying the Matrix

weak sierra
#

magic bat

thick karma
#

OKAY

#

To make my bat equip itself, I need the bat object from getInventory():getItems(); then I can simply call getPlayerInventory(0).inventoryPane:doContextualDblClick(bat), and voila, the bat is equipped. The catch is that the index of the bat in the ArrayList returned by getItems() does NOT match the index returned by getPlayerInventory(0).inventoryPane.joyselection... So my last little mission here is to figure out how to translate the bat as getPlayerInventory(0).inventoryPane.items[getPlayerInventory(0).inventoryPane.joyselection + 1] into the bat as getSpecificPlayer(0):getInventory():getItems():get(10) in order to use the highlighted item in the double-click call...

#

If anyone knows the answer, feel free to chime in... haha

weak sierra
#

that is.. convoluted more than it has to be iirc

#

can't u just find the item in the inventory and set primary to it

thick karma
#

Well it sounds so simple in English, but I do not know how that looks in Clusterfuck.lua

#

(the favored library of PZ)

thick karma
#

My goal is not simply to equip an item with a given name

#

I have not explained my goal well, clearly

weak sierra
#

indeed

#

nor have i necessarily followed this

thick karma
#

My goal is to equip the item that I am actively focusing with my joypad.

weak sierra
#

i followed this from magic bat

#

ah

thick karma
#

(it began before that but no worries)

weak sierra
#

yeah that's gonna be more irritating

thick karma
#

Exaaactly

weak sierra
#

i'd uh

#

still use this method

#

for equipping

thick karma
#

The link between what I'm highlighting with joypad and the actual item data is not obvious

weak sierra
#

and just use the other thing to get the item id or whatever

thick karma
#

I can get real item data easily from my player, but I cannot easily determine what I'm highlighting

#

I see that InventoryItem has an ID, but getPlayerInventory(0).inventoryPane.items[getPlayerInventory(0).inventoryPane.joyselection + 1] does not have an id

#

and isn't even a proper InventoryItem

weak sierra
#

oof

#

ok

#

yeah that's.. weird

#

i dont know shit about that layer of UI

thick karma
#

but getPlayerInventory(0).inventoryPane.joyselection + 1 IS the correct location in inventoryPane.items of the bat.

weak sierra
#

was hoping u cud just loop thru each

#

and correlate

thick karma
#

I COULD use the name of the item

weak sierra
#

might mistarget

thick karma
#

The item's name is accessible

#

Exactly

#

I could target an alternate bat

#

It would not be ideal

weak sierra
#

what type is the result in the ui layer anyway

thick karma
#

Having two unique indexes for the items in my inventory is just one of those special benefits of Clusterfuck.lua

thick karma
weak sierra
#

huh.

thick karma
#

See print(bat) in the log

weak sierra
#

well that won't really return the

#

the type

#

but

#

it depends on the scenario

thick karma
#

Well fair

#

But print(type(bat)) also returns "table"

#

So I have no better info

#

Afaik its only accessible field is "name"

weak sierra
#

yeah cuz type is ignorant of kahlua

thick karma
#

No WONDER they didn't give us gamepad players a way to activate double-click using our controllers

weak sierra
#

but it would usuuuuually say something wonky rather than table

#

like userdata or something

thick karma
#

They probably couldn't figure it out their damn selves

#

Convoluted as this is

weak sierra
#

these bits don't seem to be in the javadocs

#

i'd dig into the decompile

#

and look at the types returned by items

#

inventoryPane.items

thick karma
#

Right

weak sierra
#

then look at that and see if anything else is accessible

#

or map it out in debug

thick karma
#

Lemme see if inventoryPane.items exists in my decompile

#

Not even inventoryPane exists in camel case

#

Only shows up in LuaManager.java in Pascal case.

weak sierra
#

LuaManager is where it maps stuff to lua

#

so

#

go look at that

#

and see what it's mapped to ig

thick karma
#

lol only appears here

      LuaClosure var1 = getDotDelimitedClosure("ISInventoryPaneContextMenu.dropItem");
      caller.pcall(thread, var1, (Object)var0);
   }```
#

Must be Lua side

#

Ugh why two different indexes there has to be a connection point right?

#

I mean the gamepad can activate most of the item functions that mouse can

#

There has to be a way it grabs the actual item object

#

Ugh

#

Aha! @weak sierra

#

for k, v in pairs(bat) do print(k) end revealed secrets!

weak sierra
#

gud

tawdry solar
#

i think i got it right

weak sierra
#

setlla

tawdry solar
#

ah ty

weak sierra
#

mhm

thick karma
#

buahaha it's in bat.items[1]... that's the "item" I actually need.

tawdry solar
#

i did an oopsy

#

its not showing ingame

thick karma
#

YYYEEEEESSSS @weak sierra

tawdry solar
#

wait nvm

#

i thought it would be alphabetical

weak sierra
#

x3

#

glad i could poke u in right direction

thick karma
#

Get Joypad-selected item and equip it:

inventorySelection = getPlayerInventory(0).inventoryPane.items[getPlayerInventory(0).inventoryPane.joyselection + 1]

item = inventorySelection.items[1]

getPlayerInventory(0).inventoryPane:doContextualDblClick(item)
#

Honestly the key was randomly Googling how to dump the keys of that table in Lua.

#

That is a crucial trick I will not forget.

#

Now, to integrate!

safe silo
#

If I have a table like this:

local ElectricHeaterObject = {

    itemType = "ElectricHeater",
    itemName = "Electric Heater",
    heatRadius = 15,
    heatTemperature = 30,
}

Couldn't I technically call ElectricHeaterObject.itemType and get the string "ElectricHeater"?

For some reason it keeps giving me nil

weak sierra
#

yup

tawdry solar
#

i cant change my name tho

#

of the can

weak sierra
#

oh hey it's the heater person

#

xD

safe silo
#

Yeah that's me hahah, hi!

weak sierra
#

it's local

#

so

#

make sure ur in scope

#

but yeah u shud be able to do that

safe silo
#

If I had the table in another lua file, HeaterSettings.lua

And I just use require "HeaterSettings" wouldn't that also be able to be used in the new file?

weak sierra
#

can also do ElectricHeaterObject["itemType"]

safe silo
#

Oh yeah that looks even better

safe silo
#

So I would have to remove the local part?

weak sierra
#

are u trying to reinvent sandbox options?

#

:P

#

or is this for an individual heater's settings

tawdry solar
#

looks good

safe silo
#

It's for a global heater setting

weak sierra
#

if it's global, use sandbox options

#

already exists

safe silo
#

Thank you, couldn't have done it without this discord lol ❀️

tawdry solar
#

would this change names

tawdry solar
weak sierra
#

ive been watching it, will probably add it to my server when it's a bit further along

weak sierra
#

mhm

#

:)

tawdry solar
#

winter is coming on a server i play will ask soon

safe silo
#

Yay! Will be using it on my own once it's more stable too

weak sierra
#

and when indoor heaters are not battery powered

safe silo
#

We're doing crazy weather conditions for Season 2 which is why I actually developed the mod hahah

weak sierra
#

lol

safe silo
#

I have the generator heater coded already actually

weak sierra
#

i am interested in making winters shittier if we had enough tools

#

cool :)

safe silo
#

I resorted to car batteries being used for now instead of regular batteries.. Still a duct tape solution but that has to work until I get along with coding the UI Menu for it

#

OK that actually worked

#

I'm crediting you UdderlyEvelyn

#

You want me to credit some other name? Or is that what you use

#

If I want a message to pop up above the players head could I just use player:say("Hello World!")

thick karma
#

@weak sierra omfg I am jacked about this final touch of awesome for this interface mod...

#

About to test it

tawdry solar
#

@thick karma this isnt an option in the eng ver only Russian will this change names ?

weak sierra
#

DisplayName works if a language doesn't have a translation file

weak sierra
#

im sure

tawdry solar
weak sierra
#

np

tawdry solar
#

i also have the slow learner trait

#

how

#

do i change it

#

i want to change the name

#

in eng

#

bc this is the only thing in the eng file

thick karma
blissful salmon
tawdry solar
#

@weak sierra im sorry but i dont really understand what you meant

clear bloom
#

man i think i might give up on my mod haha

#

i just can't find the parameter i'm looking for

hearty dew
clear bloom
#

it was a fun learning about modding

#

also thank you soul for helping me so much ❀️

blissful salmon
# hearty dew <@355732070435258368> Haven't verified by testing this, but as far as I understa...

I almost forgot... About the sound problem: I didn't understood what you meant in your last post with "handle that case specially". Where should I start for this approach?
I'll already tried to do it with commands from server to client. But I never achieve to hear the sound from father away. (But I'll test this again because I already tested a lot of stuff and maybe I do something better this time).
My worst case scenario is to send the command to the client and calculate the angle between the zombie and the player. Then find the most appropriate square within hearing distance and play the sound from there (and play with the volume if possible).

blissful salmon
hearty dew
thick karma
#

YES! It works! Joypad users rejoice! I can use the double-click shortcut by pressing start on the highlighted item!

hearty dew
#

My worst case scenario is to send the command to the client and calculate the angle between the zombie and the player.
Yea, that's sort of what I mean. Not sure if the angle is important (if it does surround sound)

thick karma
#

(start cannot open menu while inventory is visible on Joypad (in vanilla))

clear bloom
#

hell ye dude

#

congrats

blissful salmon
tawdry solar
#

i still cant change name

clear bloom
#

also hi mellon

tawdry solar
#

hi

#

of the mod im working on

#

i just need to change item names

clear bloom
#

cool

#

the beer one?

tawdry solar
#

yeah

clear bloom
#

cool

#

i think i might give up on mine

#

i made stakes fixable but i can't do the third step

#

where the maintenance is boosted by your level of carpentry

#

i tried looking at the scripts or the luas and can't find it@tawdry solar πŸ˜”

clear bloom
#

thank you

#

but you don't have to if it takes a lot of time btw

#

i don't want to bother you that much

tawdry solar
#

no worries

#

release the stake mod

blissful salmon
clear bloom
#

like spears

#

they have their maintenance boosted by your level of carpentry

blissful salmon
#

do they? I didn't know that. So the spear has a smaller chance to loose durability if you have a higher level of carpentry?

clear bloom
#

yes

blissful salmon
#

or don't you talk about the maintenance skill/perk?

clear bloom
#

no no

#

it's better durability

blissful salmon
#

ah...

clear bloom
#

i've heard other people say it but this is the only video that says it

blissful salmon
# clear bloom https://youtu.be/j2SuGiFRROw?t=303

the lua file is /media/lua/server/recipecode.lua
and the function for the spear is:

    local conditionMax = 2 + player:getPerkLevel(Perks.Woodwork);
    conditionMax = ZombRand(conditionMax, conditionMax + 2);
    if conditionMax > result:getConditionMax() then
        conditionMax = result:getConditionMax();
    end
    if conditionMax < 2 then
        conditionMax = 2;
    end
    result:setCondition(conditionMax)
    
    for i=0,items:size() - 1 do
        if instanceof (items:get(i), "HandWeapon") and items:get(i):getCategories():contains("SmallBlade") then
            items:get(i):setCondition(items:get(i):getCondition() - 1);
        end
        if items:get(i):getType() == "SharpedStone" and ZombRand(3) == 0 then
            player:getInventory():Remove(items:get(i))
        end
    end
end```
clear bloom
#

HOW THE FUCK DID I MISS THAT

#

IM SO DUMB 😭

blissful salmon
#

so you have to make your on lua file with your adapted function of this.

tawdry solar
clear bloom
#

ye ye

#

i even used the tool to find words in the doc

#

and typed spear

blissful salmon
tawdry solar
#

looking to change the name

#

but

#

i think ik how

calm acorn
#

@weak sierra

getCell():getGridSquare(x, y, z):isVehicleIntersecting()

off of IsoGridSquare

clear bloom
#

k foud it

clear bloom
#

-- get the spear, lower its condition according to woodwork perk level
-- also lower the used knife condition

#

this isn't code right?

#

it's just words

blissful salmon
#

-- means comment

clear bloom
#

ok ok thank you

wet gorge
#

Know if there is a way to force generate a chunk server side without having a player visit it personally?

safe silo
#

How can I print a table? Currently getting like Table 0x32938293823 in the console

blissful salmon
#

if you have to test/debug stuff you can take some stuff out of your code by this and later put it in again by removing the comment.
Or most important you should write in comments what your code does. So you and maybe other have an easy live later.

clear bloom
#

ok

blissful salmon
# safe silo How can I print a table? Currently getting like Table 0x32938293823 in the conso...

I think other have better stuff than me... But most often this is enough for me:

  if not (type(tbl) == "table") then return end
  if not indent then indent = 0 end
  if not maxDepth then maxDepth = 2 end

  if not (indent <= maxDepth) then return end
  
  for k, v in pairs(tbl) do
    formatting = string.rep("    ", indent) .. k .. ": "
    if type(v) == "table" then
      print(formatting)
      SoulMod.shared.tablePrint(v, maxDepth, indent+1)
    else
      print(formatting .. tostring(v))
    end
  end
end```
clear bloom
#

so that means means that the max condition will be boosted by carpentry

#

and that the knife used to make the spear will lose durability

#

and sharpenedstone

#

interesting

safe silo
#

Like for quick testing purposes

wet gorge
blissful salmon
#

you can have sub tables and in worstcase loops... so you can put in for example 3 for the maxDepth and in general you don't have to pass an ident.

safe silo
#

Sweet! I'll test it

blissful salmon
#

the ident number is how many repeats of the spaces are printed.

#

But it doesn't do metatable stuff....

blissful salmon
clear bloom
#

i can send it here

#

function Recipe.OnCreate.CreateSpear(items, result, player, selectedItem)
local conditionMax = 2 + player:getPerkLevel(Perks.Woodwork);
conditionMax = ZombRand(conditionMax, conditionMax + 2);
if conditionMax > result:getConditionMax() then
conditionMax = result:getConditionMax();
end
if conditionMax < 2 then
conditionMax = 2;
end
result:setCondition(conditionMax)

for i=0,items:size() - 1 do
    if instanceof (items:get(i), "HandWeapon") and items:get(i):getCategories():contains("SmallBlade") then
        items:get(i):setCondition(items:get(i):getCondition() - 1);
    end
    if items:get(i):getType() == "SharpedStone" and ZombRand(3) == 0 then
        player:getInventory():Remove(items:get(i))
    end
end

end

#

@blissful salmon

#

im also using this as a kind of way to learn coding haha

blissful salmon
#

you don't have to send me the code again. I just need to have a look to confirm your statements...

clear bloom
#

ok ok

safe silo
#

So the table I'm grabbing is from:

local invItem = self.object:getItem()
local args = heaters[invItem:getID()]

sending the args over the server and getting heaters[args.id]

I'm then doing the table on heaters[args.id]

Values that I find in here, how would I grab them? Say I have variable in there called itemType, could I call it with heaters[args.itemType]? Or would it be heaters[args.id].itemType?

#

Found out it was heaters[args.id].itemType. Thank you!

fallen thunder
#

ayeee guys, im looking for some decent mods yall have recommendations? specifically PvP faction mods but anything helps

blissful salmon
# clear bloom and that the knife used to make the spear will lose durability

The code does in the first part some calculations for the condition and the sets it to the result with result:setCondition(conditionMax)
after that the code goes through the provided items and checks if its a knife with some conditions (category etc.) if yes it lowers its durability. If the item is a SharpedStone then it will be removed from your inventory.

clear bloom
#

ok

blissful salmon
#

What I dont know for sure is which items are passed to the function? Maybe someone else can tell you this if needed... But I think you can achive your goal just by copy the function and adapt...

clear bloom
#

ok ok

#

ill try changing some things

#

like i would like to make it so that making the stake take less damage to the knife

#

but it says getcondition() -1

#

so is that the smallest unit

#

can i put -0.5 or something

blissful salmon
safe silo
#

It worked yes, I got it printed!

#

Now I'm just struggling with if/ifelse and what not πŸ‘€

blissful salmon
# clear bloom so is that the smallest unit

it's the smallest. But you can make it random by using somethink like:

if ZombRand(3) == 0 then
  items:get(i):setCondition(items:get(i):getCondition() - 1);
end

like the random chance you lose the stone...

clear bloom
#

so zombrand is just a random value?

blissful salmon
safe silo
#
    
if args then
  if args.state == "On" then
    sendClientCommand(self.character, 'heater', 'turnOff', args)
  elseif args.itemType == GeneHeaterObject.itemType then
    if sq:haveElectricity() == TRUE then
      sendClientCommand(self.character, 'heater', 'turnOn', args)
    elseif sq:haveElectricity() == FALSE then
      print("This is a heater that gets power from Generator. Can't activate due to no generator nearby!")
    end
            
   else
    sendClientCommand(self.character, 'heater', 'turnOn', args)
end
end

Okay so I'm getting very fucked up in all these if/ifelse statements πŸ’€

So basically normally allow the item to be turned off/on works. It even works with above code.

What I need is two checks so first:

  1. Is the item a specific item? args.itemType = GeneHeaterObjec.itemType
  2. Does the square it's on have electricity?

If both yes turn on.

If no elec on square display print msg

blissful salmon
left citrus
#

Im curious can you only mod with lua or is java an option too?

summer rune
left citrus
#

I love java

#

The reason i asked

summer rune
#

well then thank you, for doing the jobs that i dont wanna do πŸ˜„

clear bloom
#

that's so smart

#

you are a genius

#

if i release the mod on the workshop i'll probably just say that you made it lmao

#

you helped me so much

left citrus
summer rune
#

for moding purposes they provide their api by using lua. if u want to access stuff that is not provided by the api and neither by patching java functions with lua, then u can modify the original java files. but i think u need a decompiled version of the game files first.

left citrus
#

Ok so they don’t have a java loader

#

Thats what i wanted to know

summer rune
#

and the java files are not checked for checksum afaik. so that can maybe introduce problems. no there is no java loader afaik.

clear bloom
#

jd gui is a decompiler

#

in case you are interested

left citrus
#

I would use fernflower if i was interested

summer rune
left citrus
#

Because its more limiting

#

Like i said im not really interested i was just curious

summer rune
#

i feel like the only limiting factor is the sparse documentation and what is provided by the lua / java api globally or by some game manager / service.

#

but in that specific problem case this awesome community has helped me so many times

left citrus
#

I just find it interesting that a java game wouldnt have support for java modding

blissful salmon
summer rune
left citrus
blissful salmon
# safe silo ```LUA if args then if args.state == "On" then sendClientCommand(self...

for clearness what elseif does is kind of a shortcut:
If you write something like:

if condition1 then
  print(1)
elseif condition2 then
  print(2)
elseif condition3 then
  print(3)
else
  print(4)
end

means

if conditions1 then
  print(1)
else
  if condition2 then
    print(2)
  else
    if condition3 then
      print(3)
    else
      print(4)
    end
  end
end

Someone correct me if I'm telling bullshit...

summer rune
# left citrus there are a lot of reasons why using a compiled language for modding like c or c...

ok i will bite. what are the pros for using a compiled language like java for writing mods? as far as i know and can tell, lua is blazingly fast, u can also load it as compiled bytecode. object orientation, which java has, is just an abstraction trend/paradigm, and not necessarily needed. i would even argue it would prevent this seemless integration between different mods, which we have right now. what else does java provide? maybe open source frameworks, but they would blow any mod out of proportion.

left citrus
blissful salmon
#

@left citrus I made some mods for Valheim which is Unity -> C#. Most of the modder used the bebinex with hamony stuff to make mods. There we patched the methods for example manipulate the params bevor or the result after the Methods. What you always try to avoid is overwriting methods. And as far as I can say an often problem was the compatibility between mods.
But I don't know the true reasons the developers had. Maybe also because this is more sandbox like. So the lua can't do much harm on the pc... I didn't check how save it is. But maybe also a reason.
In Valheim I checked every mod I used because they can do a lot of stuff within the rights the user have on the pc...

left citrus
#

idk if you know about minecraft but minecraft basically has two competing mod platforms, one that uses patches(fabric) and one that uses an api(forge)

blissful salmon
#

Like I said I don't know the true reasons...

left citrus
#

i can almost guarantee is security reasons, while you could send java code to the client from the server and have it be secure it would be very easy to fuck up

blissful salmon
#

I'm also not aware of how good java can execute stuff in a sandbox like environment.

left citrus
#

not very lmao

#

the only way to do it would be to analyze the imports of code and check for anything problematic before you run the code

gilded hawk
hearty dew
#

In windows, I prefer to setup cygwin and use tail -F Zomboid/console.txt in the terminal cygwin installs (mintty).

#

I think windows powershell supports ansi colors too, if you want to use that

gilded hawk
#

Okay thank you!

hearty dew
#

How to tail a file in powershell

gilded hawk
#

Also, when I mentioned that you should put all your code in a repo I hope you do, all your utils are gold gold and they should be preserved if one day this channel gets wiped

left citrus
#

just install linux smh

blissful salmon
# gilded hawk What are you using to see the logs like this? is this some sort of cat tool? Lik...

Maybe this is also an approach on windows.But I never tested it so far. Maybe its time to setup my WSL again πŸ™‚
https://devblogs.microsoft.com/commandline/integrate-linux-commands-into-windows-with-powershell-and-the-windows-subsystem-for-linux/

Windows Command Line

A common question Windows developers have is β€œwhy doesn’t Windows have yet?”. Whether longing for a powerful pager like less or wanting to use familiar commands like grep or sed, Windows developers desire easy access to these commands as part of their core workflow.

hearty dew
hearty dew
visual abyss
#

Nah it's no biggie

clear bloom
#

@blissful salmon

#

i tried doing the code for the thing

blissful salmon
clear bloom
#

could you tell me what you think

blissful salmon
#

just post what you have...

clear bloom
#

function Recipe.OnCreate.CreateStake(items, result, player, selectedItem)
local conditionMax = 1 + player:getPerkLevel(Perks.Woodwork);
conditionMax = ZombRand(conditionMax, conditionMax + 1);
if conditionMax > result:getConditionMax() then
conditionMax = result:getConditionMax();
end
if conditionMax < 1 then
conditionMax = 1 ;
end
result:setCondition(conditionMax)

for i=0,items:size() - 1 do
    if instanceof (items:get(i), "HandWeapon") and items:get(i):getCategories():contains("SmallBlade") and ZombRand(3) == 0 then
        items:get(i):setCondition(items:get(i):getCondition() - 1);
    end
    if items:get(i):getType() == "SharpedStone" and ZombRand(6) == 0 then
        player:getInventory():Remove(items:get(i))
    end
end

end

#

i tried making the zombrandom thing for the blade

#

as well as doubling the halfing the chance for the sharped stone to disapear

#

the thing is idk if for example

#

zombrand(3) is actually 4 values or 3

#

like 1,2,3 or 0,1,2,3

hearty dew
bronze yoke
blissful salmon
clear bloom
#

ok ok

#

thank you

#

i also changed some stuff on the code

#

local conditionMax = 1 + player:getPerkLevel(Perks.Woodwork);

#

conditionMax = ZombRand(conditionMax, conditionMax + 1);

#

if conditionMax < 1 then
conditionMax = 1 ;
end

#

bcs the condicion lower chance is 1 instead of 2 for the spear

blissful salmon
#

you code should work. But the item Stake has a MaxCondition of 5 so with Woodwork 4 you always reach the max condition.
Since you start with conditionMax = 1 + level you never will get a lower condition with the current calculations.

bronze yoke
#

conditionMax = ZombRand(conditionMax, conditionMax + 1); doesn't do anything, because ZombRand()'s highest possible value is 1 less than the second number

clear bloom
#

hmmm

#

what if i could do something like making it + the woodworklevel/2

#

the game only uses whole numbers

#

so idk if it could work

blissful salmon
# clear bloom bcs the condicion lower chance is 1 instead of 2 for the spear

Thats true. When you hit something with the stake it's alway -1 but if I remember correctly this is also calculated with your maintenance level so uf your have maintenance level 1 the real lower chance will be one out of 3 I think. I'm not quite sure if it's the ConditionLowerChance + Perklevel * 2 but something like that I think.

clear bloom
#

hmmm

blissful salmon
#

you can do it like math.floor(woodworklevel/2) to round down or math.ceil(woodworklevel/2) to round up

clear bloom
#

oh ok ok

blissful salmon
#

did you function work so far? so it creats your stake with the condition you want?

clear bloom
#

im still writing it

#

i was trying to make it by myself since i also want to learn about it πŸ™‚

blissful salmon
#

Just take your time.

clear bloom
#

i'm still taking the information you guys have given me

#

i think im going to work on it

#

tomorrow

#

it's getting a bit old

#

i mean

#

late

astral dune
#

This channel has been active today. I normally sit down after work and read everything I missed but I had to start skimming this time

weak sierra
#

i gave up a while ago

#

heh

astral dune
#

Did see someone talking about me, I hope they figured out what they needed

undone elbow
#

That's why we need forum.

astral dune
#

there is a forum

undone elbow
#

Not that forum)

astral dune
#

For the record, since I can't find the conversation again but maybe they'll see this, its not really viable to find the storage capacity of the trunk of a vehicle from the script. Its there but there are no get functions to retrieve it, so you'd have to do a bunch of reflection shenanigans to get the capacity. Not to mention it can be altered, so if you want that information you really should be getting it from the particular instance of the vehicle you're interested in.
Also, the trunk is called TruckBed on all the vanilla vehicles afaik

#

from base vehicle you just need to do vehicle:getPartById("TruckBed"):getContainerCapacity()
For modded vehicle that doesn't use the TruckBed ID, you'll have to figure out some other way to figure out which part is the trunk. Can't just look for containers, since chairs and the glove compartment, and modded roof racks and stuff all have capacity. Would likely have to write custom checks for each vehicle, bleh

wet gorge
#

@astral dune Hey there, I managed to get things figured out thanks to Xyberviri, UdderlyEvelyn, and Tyrir.

#

I do have new weird issue that I'm unsure why it's erroring.

#

script:getHasSiren()

bronze yoke
#

i don't know why that's giving you an error, but from poking around with it myself it doesn't seem like that even gets set anyway

wet gorge
humble oriole
#

anyone have any thoughts on how to prevent melee in vehicles

bronze yoke
#

like swinging weapons from inside of a vehicle?

#

that's being disabled in 41.78 anyway

thick karma
#

Guys I think I'm in an abusive relationship with programming

vast nacelle
#

I have a mod that takes the items on a dead body, adds them to a new container placed in the world, and then removes the corpse but I'm having difficulties getting the container's items to sync in MP.
If I just use container:addItem, none of the items are synced to the server so other clients see an empty container.
If I use container:addItemOnServer, only the first item gets added because I guess I am calling it too quickly?
So what should I be calling to properly sync the container's contents between the client who created it and the server.

tardy wren
#

How can I check if an item has a property defined at all? Like, how do I check if the item defines daysFresh?

bronze yoke
blissful salmon
#

I often use for example instanceof(object, "IsoZombie"). Is their a similar function which gives me the string of the object?

bronze yoke
#

if they're exposed, there's java functions like that

#

getSimpleName() likely being the most useful

blissful salmon
hearty dew
#

Be aware that getSimpleName() and getName() on the Class objects are only available in -debug mode

tardy wren
#

How can I check if an item defines a field?

#

Like, if it has "DaysFresh" set to any value?

blissful salmon
fast galleon
#

wait, I'm confused how do you get others to see the container and not the items, you transmit the item before adding the items?
@vast nacelle

#

I use isoObject:sendObjectChange("containers") from server if that's of any use to you

vast nacelle
# fast galleon wait, I'm confused how do you get others to see the container and not the items,...
local corpseItems = self.corpse:getItemContainer():getItems()
if corpseItems then
  local bagItems = bodybag:getItemContainer()
  for i=1,corpseItems:size() do
    bagItems:addItem(corpseItems:get(0))
  end
end```
I'm guessing AddWorldInventoryItem is sending the new item to the server before I start adding items.
Maybe I should instead create the container, then add it to the floor inventory after I've added the items?
hearty dew
#

@blissful salmon With these functions, I'll usually do something like```lua
f=function(...) l.inspectAll(...) end; Events.OnWorldSound.Add(f)

It will print out the types for most all java objects.

It will give you output like:```
LOG  : General     , 1666845987273> -----  arg 1/2: string  -----
"done!"
LOG  : General     , 1666845987279> -----  arg 2/2: string  -----
"yahoo"
fast galleon
#

@vast nacelle

public InventoryItem AddWorldInventoryItem(InventoryItem var1, float var2, float var3, float var4, boolean var5) {
            if (var5) {
               if (GameClient.bClient) {
                  var14.transmitCompleteItemToServer();
               }

               if (GameServer.bServer) {
                  var14.transmitCompleteItemToClients();
               }
            }
vast nacelle
#

Yep. That was really obvious in retrospect. Fill the container then add it to the floor. πŸ˜΅β€πŸ’«

#

Thanks @fast galleon and @bronze yoke

tardy wren
#

So, how do I check if an item defines a field?

blissful salmon
tardy wren
#

Hmm, there are a ton of getters in the Item class... Maybe I can null check those

blissful salmon
tardy wren
#

I don't know if my jarred food is food

#

You can't exactly eat them straight away

#

Also it seems like it's for a specific item, whereas I crave general item definition... I think Item is the way

blissful salmon
ancient grail
undone elbow
#

What is the best way to get world time?

blissful salmon
#

If I call player:getX() or the player:getSquare:getX() is this x an absolut value on the whole map or is this based on the current cell?
What I want to achive is to get a square with an offset to the player for example if I calculated: x = -5, y = 8
I want to get the Square: player:getX() + x, player:getY() + y

summer rune
#

I want to track which player build what structure, and later allow them to only sledgehammer destroy their own structures. Which java function is called that has access to the structure/tile id that is being build? Does anyone know?

fast galleon
grizzled wyvern
#

LETS GO I FOUND A DUMBELL

blissful salmon
#

ah, damn it... there is a Global function:
getSquare(double x, double y, double z)

ancient grail
#

Anyone has a snippet of deleting items on the ground? I lost mine

thick karma
thick karma
thick karma
#

Can anyone tell at a glance why this code is hiding my inventory and loot when IR.mod.options.shortcutsCloseInventory is verifiably set to false and the Say(AND I got here...) line is not printing (which should confirm that the chunk with inventory:setVisible(true) is skipped)?

#

I've been hiding and showing chunks for over an hour (because game so slow to relaunch, and I'm using decorator functions in this mod)... Can't seem to identify the specific moment where inventory would vanish. Makes no sense. It seems like none of the code after inventory is confirmed visible should change that...

blissful salmon
thick karma
#

Sorry just woke up

blissful salmon
#

np πŸ™‚

thick karma
#

Lol thought you said you would also like to know

#

In response to him

#

Obv you said nothing of the sort in retrospect

blissful salmon
#

If have a problem when pressing F11 in debugmode. The debug window opens when I press F11 but it shows me no error. But it breaks on if not ISFastTeleportMove.cheat then return end But this isn't from a mod. Did anybody experienced the same problem?

#

Or is this just what I have to see by pressing F11?

thick karma
blissful salmon
#

ok

thick karma
#

No error indicated.

blissful salmon
#

I was alway confused why it breaks there.

thick karma
#

Well it doesn't break per se for me

#

It just opens and shows that file by default when you open F11

#

"breaking" is when your code stops running

#

The Lua has not stopped running in that file

blissful salmon
#

ok

#

thx

fast galleon
#

I always think that file has an onKeyboardPressed and is the last thing executed.

limpid moon
#

does anyone know where i can find a site with all the pz commands for scripting

#

or a good guide on it

#

im trying to create an auto turret and all I have so far is a model

#

which I dont think ive imported correctly

scenic cradle
#

hey guys..I'm tryin to make a function to add a context menu option to the wallet junk item. I've made it equippable (with double-click) but can't sort out how to add the contextual option to equip it. I had a script written that I couldn't get to work, got discouraged and deleted it and gave up. Unfortunately I obsess over crap like this and can't stop thinking about how to make it work. If I were to rewrite it, would anyone be willing to help me sort it out? I don't want to put myself through it all again just to end up in the same place.

#

sorry for wall of text. I have some mental issues that cause me to hyperfocus and obsess over things

undone elbow
#

How to create custom texturepacks?

#

There is also file with "tiles" extension. It seems that this file is needed for the texture pack to work.

scenic cradle
thick karma
scenic cradle
#

Worst part is its not even my mod, im just trying to help someone

thick karma
#

Let me guess, your delete button isn't working?

scenic cradle
#

I think its busted

thick karma
#

I'm not sure how to add context menu options yet. if you ask any specific questions that I can answer along the way and I see them first, I'll probably answer you.

scenic cradle
#

Hey that works for me. Someone elses input on any of it would help greatly

thick karma
#

I would guess that the contextual option for items is added by ISInventoryPaneContextMenu.lua

thick karma
#

In that class there is a function called ISInventoryPaneContextMenu.createMenu

#

Seems relevant

#

I believe it appears when you right click an inventory pane item

scenic cradle
#

Thats what i was using actually

bronze yoke
#

i have some code for this, let me get on pc real quick

scenic cradle
#

Oh wow thank you

#

I could get the option to appear but it didnt work, plus it was throwing errors on any other items I rightclicked

bronze yoke
#
local function onFillInventoryObjectContextMenu(player, context, items)
    for i,v in ipairs(items) do
        local item = v
        if item:getType('desiredType') then
            context:addOption('Custom context option', item, yourFunction, arg1, arg2, etc)
        end
    end
end

Events.OnFillInventoryObjectContextMenu.Add(onFillInventoryObjectContextMenu)
grim rose
#

i have runned into problem

#

i used MX code for pills, all looks great but i can't use option to drain pill cointainer

fast galleon
scenic cradle
#

Thank albion, Ill try this and see if i run into/create any problems

grim rose
summer rune
#

do you guys also experience the behavior that the zombie amount and respawn gets less and less over time in MP ? we have set the respawn and and pop to static never changing values. But somehow 1-2 RL months later, the cities are sooo much less populated, even if no one has entered the server for a full day. we play with pop 0.8 and very strong zombies. so i guess this problem is more prominent in our case. we dont have any mods that mess with zombie respawn.

bronze yoke
#

is wordzed still used? the download on the forums is dead

thick karma
#

Aaaand... it's finally here! Interface Reflexes! (If you hate the name I'm honestly over it πŸ€ͺ). Do you want to close those annoying pop-ups at server launch by simply aiming (or spamming B on a controller)? Do you need to get your HUD out of your face because a horde just burst through the door? Do you want to rapidly equip items in your inventory while you're playing with a gamepad? Do you want to fully customize all of that, deciding which windows you will or will not close in an emergency? Well, this mod is for you!

https://steamcommunity.com/sharedfiles/filedetails/?id=2880580885

weak sierra
hearty dew
#

How do you think the interface to something like this would look? I'm writing something to do this and curious how others might imagine the interface to it working

weak sierra
#

interface as in API or as in UI'

hearty dew
#

api

weak sierra
#

RequestData(commandName, callback)

#

RequestData(commandName, args, callback)

#

or something along those lines

#

actually could simplify that if the commandname matches a key of callbacks

#

in a table

#

to just RequestData(commandName, args)

#

with args optional

#

and a table of callbacks["commandName"] = function(args)

#

and maybe

#

RegisterCallback(commandName, function)

hearty dew
#

Mm, I think the premise of his statement was to avoid callbacks specifically since he wanted an interface to "wait for the reply before continuing"

weak sierra
#

that's irrelevant since the only way is callbacks

#

:P

#

has to be based on the command system

#

so

#

not really a lot of options

#

you can make it block on purpose

#

but there's no getting away from the idea that it is essentially a callback

#

since to react to the data and collect it it must run through a function in the receiving event

#

afaik

hearty dew
#

Yea, that's fine if the implementation uses callbacks, because that can be abstracted away to some degree. I'm just wondering about the interface that looks like it waits for a reply before continuing

#

i.e. what would be useful to others

thick karma
#

And then just proceed when the input returns?

hearty dew
# weak sierra to just RequestData(commandName, args)
WipUtils.CommandModules.CrazyModule = WipUtils.CommandModules.CrazyModule or {}

WipUtils.CommandModules.CrazyModule.request = function(args, player)
    print("request received "..tostring(args.callback).." "..tostring(args.callbackArgs).." from "..player:getDisplayName())
    WipUtils.sendRemoteCommand("CrazyModule", args.callback, args.callbackArgs, player)
end

WipUtils.CommandModules.CrazyModule.callMeMaybe = function(args, player)
    print("I was called maybe!")
end
function requestData(commandName, args, player)
    WipUtils.sendRemoteCommand("CrazyModule", "request", {callback = commandName, callbackArgs = args}, player)
end

function testrequest()
    requestData("callMeMaybe", {"this is crazy"}, getPlayer())
end
LOG  : General     , 1666895617765> 1,041,685,768> I was called maybe!
LOG  : General     , 1666895622165> 1,041,690,168> I was called maybe!
hearty dew
thick karma
#

Maybe await(function, args) or something

#

Unless I'm misunderstanding the goal here

#

Then the function will send a server command, and then the server sends a command that tells code to continue from the await?

#

Or perhaps await will send it after the function has finished

#

I could imagine that being useful idk if doable

#

would be sugary to me lol

hearty dew
#
local function fn(context)
  print("starting! waiting for 'go' message..")
  context.waitForMessage("go")
  print("done!")
end

local x = LUtils.createCoroutine(fn)
x.start()
-- I go on to do other things ...
-- later
x.receiveMessage("go")

Was thinking something like that

thick karma
#

That's also great.

#

I would prefer awaitMessage but that's me hahaha

#

Not everyone would obv

hearty dew
thick karma
#

Right, I would imagine this would only be done in a function that was already done on its own thread...

#

I wasn't sure how you would spawn that in this environment, but I assume waiting for signals in general is not a thing in the normal flow of modding most things I see modded in this game

hearty dew
#
local function fn(context)
  print("starting! waiting for 'work results'..")
  local result = context.awaitMessage("work results")
  print("got results "..result)
end

local x = LUtils.createCoroutine(fn)
x.start()
sendRemoteRequest(function()
  local workResult = 1 + 1
  sendReply(workResult)
end)
function receiveReply(result)
  x.receiveMessage("work results", result)
end
thick karma
#

LUtils.createCoroutine(fn) creates the thread?

#

It's that simple?

#

or you wrote that function?

hearty dew
hearty dew
#

Trying to figure out the interface for it still though

thick karma
#

Would be super nice. Looks legit.

#

I am so glad I waited to release Meditation lol

#

original way this mod worked was wonky a.f.

#

I am making it so much less demanding (system resource wise) now that I know how to add and remove tick events at good times and decorate more crap

#

It's gonna be doperino

hearty dew
#

Your ux is going to be super zen

#

No ui, and just gamepad :)

thick karma
#

Meditation is actually an AFK mod for online πŸ™‚

#

Sit on Ground = become invisible to zombies

#

(If they have not seen you recently and you haven't seen them recently)

#

may also become invisible to players, haven't tested / decided what I prefer

#

May be admin option by the time I'm done

#

Since pausing clearly is not going to work out in MP

hearty dew
#

Oh, cool. Didn't end up needing admin/higher privilege to become invis to zombies?

thick karma
#

Might need to require people to disable an anticheat. I haven't fully tested that because I already disable anticheats 3 and 12 iirc, but my user had no issues becoming invisible with those off

#

I will confirm which anticheats need to be off before I release it

weak sierra
#

my head is spinnin a bit, maybe someone else can give me some ideas for how to structure this

#

vehicle respawn mod, fires on player move with throttling

#

it triggers updates to the last seen variable of a vehicle if it's not set or if it's below X age, but if it's over X then it despawns it and asks the server to generate <some vehicle> at <a place in a zone in a cell randomly>

#

since that place may not be loaded, it tries, but if it fails it puts it in a table of things to check later

#

as players move around, it checks each newly loaded cell for any vehicles to spawn there via lookup

#

this all works great