#mod_development

1 messages · Page 121 of 1

thick karma
#

I might have to do some performance testing

calm depot
#

I wouldn't worry about perf

#

you have no reason to be loading the JSON more than once per play, no?

thick karma
#

Right.

#

I would store it in mod data

calm depot
thick karma
#

I am trying to figure out the appropriate time to load it from mod data actually.

#

I am wondering if I need to use GlobalModData or something

calm depot
#

parse the JSON eagerly, but lazy-load the current state in the case of a resumed game

thick karma
#

vs ModData

calm depot
#

you can afford to be lazy since PZ will have done all the work of populating the mod data anyway

#

as for function calls, one JSON param should represent the name of the function, and another for a context string

#

(if you want to be fancy, support recursion through tables)

#

otherwise, it's simply _G[funcName](contextStr, dialog_str)

thick karma
#

Oh you're saying I could trigger a global function directly using their string?

#

That is very interesting but I probably won't require them to call a global function...

calm depot
#

yeah, if you want to be a bit "nicer" you can allow them to specify "a.b.c..."

#

it's a little bit more code to then do the walk through the tables

#

arguably unnecessary since you can just encourage people to have a single global function that takes care of dispatch

thick karma
#

I could definitely let them do that without recursion

calm depot
#

or you could even build your own listener machinery that you were thinking of on top of this mechanism, too

thick karma
#

## [Command: commandName, stringArgOne, stringArgTwo, stringArgThree] Alright, stick em up!

thick karma
calm depot
#

if you use JSON, it becomes even easier

#

{ "funcName": "theFunc", "args": ["one", "two"]}

thick karma
#

than :split() :trim()?

calm depot
#

you don't even need to do that

#

_G[funcName](unpack(args))

thick karma
#

Wait is unpack an available global in Zomboid space?

calm depot
#

yes, it's part of lua

thick karma
#

I tried to use table.unpack and it didn't work, I thought it was part of table, I'm dumb.

calm depot
#

oh, heh

thick karma
#

Ended up just writing my own

#

lol

#

I mean trivial

calm depot
#

welp, don't do that, unpack is global

thick karma
#

Haha I'll undo that

calm depot
#

uh, how exactly did you implement that

#

you know what unpack does right?

#

given {1,2,3}, unpack will turn it into 3 separate arguments, as if you did return 1,2,3

thick karma
#

I understand

#

So I would do {unpack(table)} to get a copy of a table basically

calm depot
#

yes

thick karma
#

I didn't need unpack

#

I needed a subtable

calm depot
#

actually, you could implement unpack using recursion

thick karma
#

So I did that directly

calm depot
#

but, unpack is implemented natively, much faster

thick karma
#

For sure.

#

I will consider using it instead now that I know it actually works.

calm depot
#

also, unpack only works for tables with 1..N indices

#

all other keys in the table are ignored

thick karma
#

Great, because that's how I need it to work lol

#

I have mixed keys

frank elbow
#

If you include an n key with the desired length it will include keys in 1..n

calm depot
#

whenever I wrap existing game code, my MO is to always do local ret = {originalFunc(...)} and return unpack(ret)

thick karma
#

Yeah I was thinking if I use command strings they can just do stuff OnServerCommand and I could give them a list of string args to work with

frank elbow
#

i.e., local t = {1, nil, 3, n = 3} print(unpack(t))1 nil 3

calm depot
#

I'm not so sure that's going to print what you think

#

a key with a nil value is nil

frank elbow
#

That's not a key with a nil value ?

calm depot
#

surely that's going to just print 1

#

the key 2 will be set to nil

frank elbow
#

Ah, I thought you meant a nil key

calm depot
#

a key can't hold a nil value

frank elbow
#

You can try it yourself if you want 🤷🏾 works in implementations I'm aware of

#

Yes, but the special n key is considered

#

Just tried it in the debug console and it is 1 nil 3

calm depot
#

it is indeed

#

there's definitely some lua esoterica going on here

#

this doesn't work:

local t = {1}
t[3] = 2
t[2] = nil
print(unpack(t))```
#

so you have to set it to nil within the table declaration

frank elbow
#

You have to assign the n key to the desired maximum for unpack, which isn't done there (unless you've excluded it?)

calm depot
#

what do you mean by n key?

frank elbow
#

t.n = 3

calm depot
#

there is no t.n

frank elbow
#

I think you missed that in my original message, now I see why you were confused lol

#

Well yeah, you have to assign it

calm depot
#

sure, but what's the relevance

#

unpack doesn't care about that

frank elbow
#

It does

#

If you do the example I sent without it, it will only print 1 as you suggested

calm depot
#
local t = {1, nil, 2}
for k,v in pairs(t) do print(k) end
print("---")
print(unpack(t))```
#

there is no n key present

#

yet, unpack correctly prints out 1, nil, 2

frank elbow
#

In which implementation?

calm depot
#

Lua 5.1 Repl

frank elbow
#

Huh, surprising

calm depot
#

it has to be internal, the key is marked as existing and not garbage collected

frank elbow
#

It's respected in versions I've used & in the debug console, so relevant to PZ modding at least

calm depot
#

I've never known .n to be a thing

frank elbow
#

I swear I used 5.1 back in the day and didn't see that behavior

calm depot
#

some non-standard extension

frank elbow
#

I'm willing to bet it works on the official Lua demo, but let me try so I can see if I'll eat my words

#

I ate my words

#

Wait what

#

If I define it in the table initially it works

calm depot
#

yes, that was what I showed you earlier

frank elbow
#

I mean n, not the nil value

calm depot
#

example?

frank elbow
#
local t = {1, nil, 3, n = 3}
print(table.unpack(t))

prints 1 nil 3, whereas

local t = {1, nil, 3}
t.n = 3
print(table.unpack(t))

prints only 1, Lua 5.4 (https://www.lua.org/cgi-bin/demo)

#

So yeah, some sort of magic

thick karma
#
t[4] = 4
print(table.unpack(t))

1, 2, nil, 4

frank elbow
#

The actual value of n is ignored altogether, even. I am thoroughly confused

thick karma
#

Unpack is auto inserting nils where they belong

calm depot
#

but unpack can only do that for keys which exist in the table

thick karma
#

No

thick karma
#

Key 3 is not in the above code

#

I just ran that in the Lua demo

#

It autogenerates nil for key 3

#

Because it knows logically between 2 and 4 there is a 3

#

HOWEVER

#

This only works for 1 empty spot!

#

Haha

#
local t = {1, 2}
t[5] = 5
print(table.unpack(t))

1, 2

calm depot
#

yeah, I'm pretty sure this is some garbage-collector related shenanigans

thick karma
#

lol what a cluster

frank elbow
#

The only conclusion I can draw from this is that unpack defies all expectations

calm depot
#

because by defining .n later, you're likely triggering a rehash of the table

#

When you iterate over the elements of the array, the first non-initialized index will result in nil; you can use this value as a sentinel to represent the end of the array.

#

and yet, here we are

#

ah, table.unpack is explicitly able to preserve nils

#

that's since Lua 5.2

frank elbow
#

With the index parameters, that I was not aware of

#

That's much easier

calm depot
#

so, whether it works or not in 5.1 is dependent on if the key is "alive"

#

quite perverse though, the general rule of Lua is that setting a key's value to nil is equivalent to removing it from the table

frank elbow
#

I can only assume I misremembered since I've never actually used this functionality—presumably got mixed up with table.pack—but unpack (list [, i [, j]]) (e.g., unpack(t, 1, 3)) is more reliable and works ingame too

#

Glad we had this talk so I didn't go on giving that poor advice

thick karma
#

@calm depot Do you know if that JSON thing can do infinite nests? I notice it uses [ { } ] in its example... is that strict? Do I have to alternate? Can I Just use one or the other?

calm depot
#

if it's valid JSON, it can parse it. JSON can nest infinitely, so yes

thick karma
#

Cool just making sure that's how they wrote it.

thick karma
calm depot
#

[ {} ] is just a JSON array with a single element which happens to be a json object

thick karma
#

Hmmmm it's tempting. Idk if it's worth it or not. Dialogues would have more delimiter management going on, but that might not be a bad thing.

calm depot
#

generally, your root JSON node should be a JSON object a {}

#
{ "main": {
    "text" : "Intro String",
    "choices" : [
        { "text": "Choice 1", "choices": [ ... ] }
    ...]
  }
}```
#

of course, at some point you terminate and there's only text, no more choices

#

you may or may not have a "luacall" present for any given choice

ancient grail
#

you guys know how to make the halo show a bit longer?

thick karma
#

That's a whole lot of potential mistakes to make compared to "use the right number of #"

calm depot
#

with the right indentation, it'll be perfectly readable

#

also, it means that they can chuck the JSON into a proper validator

thick karma
#

Definitely readable

#

I'm talking about writable

#

By nonprogrammers.

frank elbow
thick karma
#

obviously I find it perfectly easy to edit and read.

#

I am used to brackets and colons everywhere.

#

I live among brackets and colons.

calm depot
#

for writing it, if you're really a noob, do it in YAML and convert that to JSON

thick karma
#

lmao that sounds more complicated but maybe not

calm depot
#

YAML supports stuff like back-referencing so you can "paste" existing chunks into other places

#

it also just uses whitespace for indentation

#

so if you can handle basic python, you can handle YAML

thick karma
#

Fair.

calm depot
#

it also demonstrates the aliasing feature

#

I can definitely see situations where you define an array of choices that you'd want to re-use without having to explictly copypaste it into the document, so YAML is quite a win there

#

heh, someone did make a YAML parser for Lua too, though I don't know how mature it is

thick karma
#

@calm depot Just realized "^#+" won't work

#

Returns 1 occurrence

#

I need the true occurrences for the logic of my loop

#

Gotta split it on the space first

hot patrol
#

Could someone tell me what this error is and how I can fix it? I get it whenever I try crafting my dakimakura armor ```LOG : General , 1677194629647> -----------------------------------------
STACK TRACE

function: dakiCondition -- file: dakiActions.lua line # 109 | MOD: Big Degen's Dakimakura Emporium
Callframe at: PerformMakeItem
function: perform -- file: ISCraftAction.lua line # 58 | Vanilla

LOG : General , 1677194629648>
LOG : General , 1677194629984> creating new sourcewindow: C:/Users/thisi/Zomboid/mods/Big Degen's Dakimakura Emporium WIP/media/lua/server/dakiActions.lua
LOG : General , 1677194710612> creating new sourcewindow: H:/SteamLibrary/steamapps/common/ProjectZomboid/media/lua/client/DebugUIs/ISFastTeleportMove.lua```

calm depot
#

make a capture group for it

#

^(#)+

#

then you can strlen it for the count

#

I'm still on the side of JSON/YAML docs though

thick karma
#
Bob = "#### This is #1."
print(Bob:gsub("^(#)+", ""))

?

calm depot
thick karma
#

To me it looks like it would be harder for a lot of non programmers to understand but idk

fast galleon
#

lua 5.4

zx = {1,nil,3}
#zx
3

stressed

calm depot
#

you say it will be harder, but unless you write a really good validator for your custom spec, any sufficiently complex dialog tree will be a nightmare to debug

#

that is, assuming you don't also write any bugs into your own parser 😉

fast galleon
#

the more you know...

calm depot
#

of course, there's also nothing stopping you from adopting JSON/YAML and also supporting your own format

#

in fact, you could also support people writing their dialog trees purely in lua as well, if they want more flexibility around function calls

#

(specifically, you can detect that the type of your funccall key is already a function)

thick karma
calm depot
#

I suppose it depends what they're building

thick karma
#

I like it

calm depot
#

but you know, there comes a point where the scope of your work is large enough that you need to use a proper, structured format

thick karma
#

Hmmm worthwhile considerations regardless of where I go next

calm depot
#

this is what being a principal is like, most of your time is spent suggesting ways of solving stuff rather than actual programming issues 😄

thick karma
#

And I do want to target the leading #s correctly so I'm glad I talked to you

#

Don't want to get errors because someone says, "You're #1!" in a dialogue.

small topaz
#

that is because op actually wants to add a free trait to a profession. so I tried to explain how to do this by exchanging the "fake" trait with the actual one. the result is that the trait outdoorsman is still correctly displayed in the occupation screen during character creation. (problem is that just adding a vanilla trait to a profession as a free trait results in buggy game behavior. therefore the trick with the fake trait.)

ancient grail
#

ahhhh

#

makes seense

drifting ore
#

anyone know if it works out if I have one mod required by another in the mod.info, but does that make it required to use at all? i'm trying to get it so when the two mods are installed together, it will always goto the assets in one of the two mods first always

calm depot
#

doesn't a profession have a points cost?

#

why don't you subtract the trait cost from the profession cost

drifting ore
#

i dont want it to be forcefully required always, but if it is installed, it will always use the first mods assets

#

if i explained correctly

hollow current
#

i tried running a dedicated server using steam's PZ dedicated server thingy. I can't seem to get a function to be executed when the server starts either, i am not sure why

-- Define a function that will be called when the server starts
function RestartAlert.OnServerStart()

    while(true) do
        print("test")
    end
end

-- Add the RestartAlert.OnServerStart function to the server start event
Events.OnServerStarted.Add(RestartAlert.OnServerStart)```
drifting ore
#

both my mods and i dont mind doing a tiny extra

calm depot
#

AFAIR, if a dependency is present, it gets loaded first, if it's missing it complains in the log that it's missing but I believe it still tries to load your mod anyway

#

but, it may also just skip loading your mod too, I haven't tested, you should 🙂

hollow current
#

the server is working fine, I am not getting any errors, but for some reason, the "test" isn't being printed when the server starts

drifting ore
#

yea i'm messing around with it now. haha

#

i think that event is too soon right

calm depot
#

is your code defined in a mod?

hollow current
#

yes the server is loading the mod no problems

calm depot
#

where is RestartAlert defined

#

you are declaring a function in that table, but I don't see where you declare the table

hollow current
#
RestartAlert = RestartAlert or {}

-- This function checks the current time and displays a message on the player's screen
-- if the server restart time is approaching.
function RestartAlert.CheckServerRestartTime()

    --code removed due to discord's character limit
end

-- Define a function that will be called when the server starts
function RestartAlert.OnServerStart()

    while(true) do
        print("test")
    end
end

-- Add the RestartAlert.OnServerStart function to the server start event
Events.OnServerStarted.Add(RestartAlert.OnServerStart)```
#

This is the whole file

calm depot
#

ok

hollow current
#

soo ye im not sure exactly what im doing wrong here

calm depot
#

where are you looking for the string? in the logs?

hollow current
#

no in-game console

calm depot
#

theoretically that should work, but I'd check the debug log anyway

#

you should also check the log to ensure there were no errors reported loading your lua file

#

(and indeed, that it actually bothered to load your lua file at all)

hollow current
#

checked that as well, doesn't seem to be there anything out of the ordinary

#

it did the load the mod without any errors

calm depot
#

I'm talking specifically about the lua file

#

it will log when it loads the file

#

if you can't find the filename in the log, it didn't run

hollow current
#

server-console.txt ye?

bronze yoke
#

it shouldn't show up in the in-game console, that event is server-side

calm depot
#

I usually use DebugLog-server

#

yeah, I assumed he meant the server's console window

#

I hope that's not what he meant

hollow current
#

erm i actually meant the in-game console thingy for the debug mode

calm depot
#

oh

#

that's obviously not going to work

hollow current
#

I don't have much experience with how mods behave for servers xd

bronze yoke
#

are you hosting in-game? it should be coop-console.txt in that case

calm depot
#

he said he downloaded the dedicated

hollow current
#

using the dedicated server thingy

calm depot
#

so it should be running in a command prompt

hollow current
#

i checked the command prompt and doesn't really show the string either

#

lemme double check

drifting ore
#

you can use that log file you mentioned aren

hollow current
#

ye nothing, according to the code the command prompt should just be spammed withe string

drifting ore
#

it is the console for the server

calm depot
#

right, check the DebugLog-server.txt for the most recent run

drifting ore
#

well the log

hollow current
#

aah that makes sense

calm depot
#

it's in the Logs folder

#

make sure it actually loaded your lua file

hollow current
#

only thing relevant is
[24-02-23 03:37:55.421] LOG : Mod , 1677202675421> 195,268,117> loading RestartAlert.

Followed by a bunch of same lines for loading translation files

calm depot
#

again, the file

#

RestartAlert is just the mod's ID

hollow current
#

yup gotcha, the file isn't actually anywhere

calm depot
#

sounds like your mod has a structure problem

#

paste the full path to the lua file

hollow current
#

C:\Users\{user}\Zomboid\Workshop\Restart Alert\Contents\mods\Restart Alert\media\lua\client\RestartAlert.lua

#

I loaded up another mod and its functioning properly, yet it doesn't show that it loaded the actual files in the log

calm depot
#

rename the client folder to server

hollow current
#

ah

calm depot
#

with the way the game currently works, technically it shouldn't matter, but this is intended for the server, so name it that way

#

at least we should hopefully end up seeing it appear in the logs

hollow current
#

by the way do i need to publish changes to workshop if I am running the dedicated server locally or would it like, read changes directly locally?

calm depot
#

if the server's been provided a Workshop ID, it'll download that and preferentially use the workshop version

#

I forget if a server instance can find your local workshop stuff, though

drifting ore
#

you can use nosteam so i'd think so

calm depot
#

nosteam doesn't use the Workshop folder

#

that uses the regular mods folder

#

as in Zomboid\mods

hollow current
#

meh shouldn't matter imma publish changes so I don't have to go through the trouble anyways. The mod is staying unlisted either ways so shouldn't be an issue

calm depot
#

not Zomboid\Workshop

#

yeah, unlisted, no issue

hollow current
#

i changed the whole file to

RestartAlert = RestartAlert or {}

function onCustomUIKeyPressed(key)
    if key == 21 then
        local currentTime = os.date("*t")
        print(currentTime.hour)
    end
end

Events.OnCustomUIKeyPressed.Add(onCustomUIKeyPressed)```

i'll see if that does anything
drifting ore
#

ah bad at reading apparently lol myb.

calm depot
#

@hollow current this is running on the SERVER

#

it won't receive any key presses

hollow current
#

soooo what should i do

#

im at a total loss

#

also that's weird because it actually worked

#

im not sure how but it did

calm depot
#

that worked because it also loaded on your client

#

so what you are testing is your client, not the server

hollow current
#

aa

calm depot
#

on the bright side, that means the structure is correct

hollow current
#

Alright so presumably with nothing wrong with the structure and that the file is being loaded, then it must be sth wrong with the code, right?

calm depot
#

if you reduce the file to a simple print("hello world") and nothing else, I would expect that string to appear in your server's log

hollow current
#
LOG  : General     , 1677204682862> 197,275,557> Hello World
LOG  : Lua         , 1677204682862> 197,275,558> Loading: C:/Users/{User}/Zomboid/Workshop/Restart Alert/Contents/mods/Restart Alert/media/lua/server/RestartAlert_ISUI.lua```
#

guess it did

calm depot
#

aye

hollow current
#

so technically speaking

#
-- Define a function that will be called when the server starts
function RestartAlert.OnServerStart()
    print("hello world")
end

-- Add the RestartAlert.OnServerStart function to the server start event
Events.OnServerStarted.Add(RestartAlert.OnServerStart)```
#

should do the same thing

calm depot
#

not quite

#

the string will only be seen after startup completes

hollow current
#

oki lemme start up the server and see if it does work

#

LOG : General , 1677205011276> 197,603,973> Server Successfully Started! YAYY!

#

nice

#

okay that's weird that the initial code is now working as intended and the command prompt is being spammed

#

not sure what changed

calm depot
#

forgot to push it to the workshop perhaps?

hollow current
#

nah it actually is working locally

#

i was pushing to workshop before but found out its detecting the changes locally

#

meh if it works it works

#

anyways thanks for the time so much!

drifting ore
#
LOG  : General     , 1677205962589> 337,147,769> Sync Lightswitch custom settings: sq is null x,y,z=10914,10093,0``` this doesn't happen on the host side but happens on the client side. i'm super unfamiliar with folder structure of where certain files should go. is there any kind of reference whatsoever? also not even sure if that's it but assuming it is since it's not happening on the hosted side, but on the player that joined host side
#

everything is in server atm. context menu stuff. recipe scriptmanager changes, updates to property value map, as well as my spritemanager stuff.

#

also does anyone know if OnLoadedTileDefinitions only happens once per load?

#

i'm testing stuff atm but hoping someone may have experience with something similar

calm depot
#

yes, it only happens once

#

i'm super unfamiliar with folder structure of where certain files should go.
what files?

#

there's pretty much only one valid location for anything other than lua code

drifting ore
#

so server should be good for anything?

#

well all i mentioned

#

hmm im gonna be messing with this all night LOL i know it

calm depot
#

I have no idea what you're doing but it's simple right

#

if the code should run on someone's server, put it in server

#

if it should run on only the clients, put it there instead

#

if it should run on both, put it in shared

#

now, there's a minor caveat in that to enforce this behaviour, the file needs to explicitly do an isClient/isServer check

hollow current
#
RestartAlert = RestartAlert or {}

-- Get the Calendar Instance
local cal = Calendar.getInstance()

-- Get the initial time in milliseconds
local initialTime = cal:getTimeInMillis()

-- This function checks the current time and displays a message on the player's screen
-- if the server restart time is approaching.
function RestartAlert.CheckServerRestartTime()
  --irrelevant lengthy code
end

function RestartAlert.RepeatCheck()
    local currentTime = cal:getTimeInMillis() -- Get the current time in milliseconds
    local elapsed = currentTime - initialTime -- Calculate the elapsed time

    if elapsed >= 60000 then -- Check if 1 minute has elapsed
        --RestartAlert.CheckServerRestartTime() -- Run the check
        print("One Minute has passed")
        initialTime = currentTime -- Reset the initial time
    end
end

-- Add the RestartAlert.RepeatCheck function to the server start event
Events.OnServerStarted.Add(RestartAlert.RepeatCheck)```
#

i think im missing some logic here because according to the event im using, the RepeatCheck will only be called once when the server starts

#

but im not really sure what to use in its place

calm depot
#

what is your end goal

hollow current
#

I am trying to get the RestartAlert.CheckServerRestartTime() function to repeat every one irl minute. It uses local currentTime = os.date("*t") to get current irl hour and minute. If it matches a specific time, it'll execute an action, i.e., for example

if hour == 22 and minute == 56 then
  do something
end```
calm depot
#

no, your end goal

#

what is the purpose

#

what are you trying to build

hollow current
#

It's a mod built for a specific server to display to the user an alert 10 mins prior to server restart

calm depot
#

Events.EveryHours should be good enough

#

that's in-game hours, not IRL

hollow current
#

but doesn't in-game time pass only when someone is online?

calm depot
#

yes, but if nobody's online, nobody's going to see the message are they now

#

also, you can actually set an option to make it continue simulating when nobody's on, but I wouldn't, especially for this use-case

hollow current
#

i guess if it won't be problematic (ye you have a point if no one's online doesn't make sense for the code to run anyways), no need to toggle the option

calm depot
#

honestly, it probably makes more sense to trigger this externally and just send a command into the server's RCON

#

/servermsg is the command

#

although I don't think you need the / if you're sending it over RCON

ancient grail
calm depot
#

either way, writing in-game code strikes me as the wrong approach

#

make your restart script - systemd or whatever, call an RCON client 10 minutes before and fire off the servermsg string

hollow current
#

hmm understood. I'll look into the possibility of doing this. Thanks either ways!

calm depot
#

alternatively, you could wrap the server's main function in Java and do whatever your heart desires

#

personally, doing it the scripty way should be good enough, but if you need something heavily custom, that's the way to go. It could even take care of shutting itself down

hollow current
#

yeeeee i doubt im experienced enough to work with Java 😬

#

i think i got it working tho

#

if it doesn't seem to be problematic imma just leave it as is, alternatively imma just set a scheduled rcon thingy

thick karma
#

@calm depot I really like your Lua idea. Leaning that way actually. Seems so obvious in retrospect but I feel it can just do more...

calm depot
#

just make sure your code is wrapped in an isServer() check, otherwise it'll do its stuff on the clients too

thick karma
#

So easily

calm depot
#

which is going to be wrong because not everyone lives in the same timezone

calm depot
thick karma
#

I think Lua would be best

hollow current
#

but actually

#

currentTime = os.date("*t")

#

doesn't this get the os time of the hosting server

#

i.e. the machine running the code?

calm depot
#

it gets the time of the machine running the code, yes

#

and it's going to be running on both the server and client unless you prevent that

hollow current
#

oh i get it now

#

thanks for the headsup

hollow current
calm depot
#

much easier way - stick this at the top of the file:

if not isServer() then
  return
end```
hollow current
#

ah okay that's way better

#

one more question

#

so the way i display alerts is by using UI. I haven't worked much with UI but I did with clientside and it did work correctly. for this code running server-side, im doing the following:

function RestartAlert.CheckServerRestartTime()

    -- Get the current real-world time according to the server's timezone
    local currentTime = os.date("*t")

    -- Extract the current hour and minute
    local currentHour = currentTime.hour
    local currentMin = currentTime.min

    -- Initialize a variable to hold the message content
    local content = nil

    --some stuff in between where content is defined if it meets specific conditions

    if content then
        local myUI = MyUI:new(content)
        myUI:initialise();
        myUI:addToUIManager();
    end

end```
#

Im not sure if this makes sense or if I need to loop over all players to show them the UI

calm depot
#

it's running on the server so you can't do that because there is no UI

hollow current
#

so what's the way around that

calm depot
#

trigger a servermsg

#

which will then send that message to all the clients

hollow current
#

how do you trigger one via code

calm depot
#

to answer that, you need to grep through the game's code

ancient grail
#
local msg = "helloworld"
SendCommandToServer("/servermsg \"" .. msg  .. "\"");



hollow current
#

Thanks!

calm depot
#

(or get lucky that someone in here knows the answer)

#

however, that function is aimed at clients for administration, so I'm not entirely convinced it'll work

hollow current
#

imma test it out now

hollow current
calm depot
#

yeah, I figured

#

I had a poke through the exposed functions, I haven't (yet) found anything that would enable you to trigger a servermsg

hollow current
#

i did as well, no luck. Would be cool to use it tho. way better than UI too

ancient grail
calm depot
#

Yes, that's because you're running the command on a client

ancient grail
#

ah ok ididnt know it was from server sorry myb

#

that wont work

calm depot
#

you don't say

ancient grail
#

any chat commands from server doesnt work

#

you need client admin

hollow current
#

there must be a way to just create such a textdraw and display over all connected players' screens server-side

calm depot
#

what you really want is to get at the ChatServer type, but it isn't exposed to Lua

#

to be honest, this is feeding into the point I made about doing this externally and sending the command over RCON

hollow current
#

what was the command to send to RCON again?

calm depot
#

RCON listens on a port

#

you need an RCON client on your server in order to connect to it

#

the command is servermsg

#

I think that PZ will only bind RCON to loopback, but, if it does let you bind to any IP address, know that it has absolutely no authentication whatsoever, so if you do expose the port to the internet, you're gonna get pwned

hollow current
#

the server is hosted on G-Portal, not on my local machine

#

i THINK it should have a way to schedule such stuff

calm depot
#

I see

#

personally I just rent a linux box and set stuff up myself

#

cheaper and you have root so you can do whatever you like

ancient grail
#

we did a server reminder thing using task scheduler and yeah RCON but problem is you have to have the pc on

#

😦

calm depot
#

he wants to send a server broadcast message to warn people that it's going to reboot

ancient grail
#

o yeah perfect

#

its doable

calm depot
#

yes, obviously it's doable

ancient grail
#

wait let me find the bat file

calm depot
#

he doesn't have a server where you have direct OS access

#

at least, he hasn't indicated that

hollow current
#

ye i don't have direct OS access

#

fingers crossed G-Portal would allow that kind of thing, otherwise, i'll just look for an alternative

calm depot
#

the alternative way (which is quite shitty) is to implement your own client-server command so that the server can notify clients to display the message

#

which is frankly waaaay overengineering the problem

ancient grail
#

-c rcon.yaml -t rcon -l rcon-default.log "servermsg "Server Restart reminder""
-c rcon.yaml -t rcon -l rcon-default.log "servermsg "Server Restart in 2 mins.""
-c rcon.yaml -t rcon -l rcon-default.log "save"

calm depot
#

sighs

hollow current
calm depot
#

that won't help you because it's specific to whatever rcon executable he's using

#

OK, so does GPortal give you RDP access?

#

seems to me he's renting a PZ instance specifically, not a whole server

ancient grail
#

i just placed the rcon on the systemtask32

calm depot
#

"the rcon" - there are various ones

ancient grail
#

then it wont work? i guesss idk

hollow current
#

So how does it exactly work, scheduling the RCON command on G-Portal?

calm depot
#

it won't work unless the server came with an rcon app included, or you link him to the one you downloaded

ancient grail
#

by lua it should also work if you do like the horde event servermsg

calm depot
#

your problem seems like it's better geared towards asking GPortal's support team. if you can get RDP access into your server instance, you can do what Glytch3r has done

hollow current
#

im too beat for today to think about this anymore tbh

ancient grail
#

it has a servermsg thing so idk how it works really but if they manage to that then its doable right

hollow current
#

the code seems workable with. Imma look at it in the morning though since my brain is refusing to function anymore

#
local function HTC_sendWarnToPlayer(player, data)
    HTC_sendCommandToPlayer(player, data, "HTCHordeWarn")
end```
calm depot
#

yes, it does what I said - a custom client & server command

hollow current
#

looks like this is where its handled tho

calm depot
#

that's some pretty gross overengineering for what can be a script that fires before the restart

hollow current
#

ooookay imma head to bed and in the morning imma hopefully be able to figure out an easy way to do it. If not i'll just bite the dust (correct idiom?) and try to reverse-engineer what Glytch3r sent and see if I can do sth similar on a smaller scale

calm depot
#

the bullet

#

biting the dust is to die or be defeated

hollow current
#

ah right i always get confused between those two

#

Well. Thanks SO much for your time gentlemen. I really appreciate it

#

Have a good night (or day/evening, whatever time it is in your timezone) :)

drifting ore
#

not 100% but seems like moving this to shared fixed my sync issue for hosted player

local vals = IsoWorld.PropertyValueMap:get("PickUpLevel") or ArrayList.new()
    for i = 1, 10 do
    local val = tostring(i)
    if not vals:contains(val) then vals:add(val) end
    IsoWorld.PropertyValueMap:put("PickUpLevel",vals)
    end
calm depot
#

that map is local to the host

drifting ore
#

in shared?

calm depot
#

the map doesn't get synchronised

drifting ore
#

i was having some weird issue where if a connected player altered the modded lightswitches, the host would get that spam

#

oh so it needed to be in shared you are saying

calm depot
#

but, unless you had some sort of isClient/IsServer check, it would be running on both client and server anyway

drifting ore
#

sorry my brain is ded

calm depot
#

currently, the game doesn't properly separate loading of code

drifting ore
#

gotcha

#

you think this will be fine running without an event?

#

i couldnt find one that worked lol

#

if you have suggestion please feel free but wasn't sure if it was needed in this case

#

the last part of the light switch overhaul has been a giant pain in the ass

calm depot
#

OnLoadedTileDefinitions sounds like the most probable

drifting ore
#

i'm using that for the function trigger for changing the value itself, wouldn't cause any issue with it?

#

i suppose its in server so it will run after anyways

calm depot
#

what do you mean "changing"

drifting ore
#

im setting the Val of PickUpLevel

calm depot
#

if you have code in that event, you can either create the key/value pair if it doesn't exist, or redefine it if it does

drifting ore
#
Events.OnLoadedTileDefinitions.Add(function(manager)
    local canMove = SandboxVars.Nipswitch.Movelevel
    local noMove = SandboxVars.Nipswitch.Movedisabled
    local lights = {"lighting_indoor_01_0", "lighting_indoor_01_1", "lighting_indoor_01_2", "lighting_indoor_01_3", "lighting_indoor_01_4", "lighting_indoor_01_5", "lighting_indoor_01_6", "lighting_indoor_01_7"}

    for _, light in pairs(lights) do
        local switchSprite = manager:getSprite(light):getProperties()
        if not switchSprite then return end
        switchSprite:Set("PickUpLevel",tostring(canMove),false)

        if noMove then
            switchSprite:UnSet("IsMoveAble")

        end
    end
end)
``` in server
#

the code above this is in shared

#

code below is shared, above is server

#

i was told to trigger the propertymap update prior to loadtiledefs

calm depot
#

as I said, in the absence of an isClient/isServer check, it doesn't matter

drifting ore
#

got it

calm depot
#

you should still organise code properly and not rely on that fact, but just moving it to shared won't change behaviour

#

unless the other file had an error that prevented it loading, and your cut code doesn't 😉

drifting ore
#

got it. no loading errors everything works 100% right now

#

only thing just not using event for the propmap update

calm depot
#

also, rather than using pairs, you should use ipairs

#

it's faster for sequential tables

#

pairs is just for when you have arbitrary keys

drifting ore
#

ahh lol

#

thats probably the best explanation i've gotten on it really

ancient grail
#

@sour island it works i just tested it

rancid panther
ancient grail
#

Ow then my texute sucks if that what you see hehe

calm depot
#

texture? that's a complete model

ancient grail
#

Well it didnt look skinny for people when it was obvious skeleton

sour island
#

Are you setting animation variables? I hadn't had a chance to work on much @ancient grail

hollow shadow
#

didnt the devs use "animzed" or something? it got mentioned quite a few times when b41 got released

jaunty marten
pulsar heath
#

anyone knows a good decompiler for net framework? A client needs an update on a app i did 10 years ago and i dont have the code and dont remember crap of what i did there

#

good enough for me to have a guideline of how i made it... i dont feel like developing it from scratch...

wheat kraken
#

@sour island hey, as an veteran mod developer, did you know what menu options are controllers friendly,

recently I discover that combobox are not (or i did something wrong)

what are the options for ui that support controllers?

there are a list of elements with good support?

@tame mulch it will be nice to list and mention that elements on wiki,

it will be useful for mods have great support for controllers


if we have a list of good mods for controller support I can extract a list of currently used elements


I will mention some people that deal or try deal with controller support to help in this topic: @dark wedge @thick karma

unfortunally I dont have a physical controler to do proper tests


other modders looking for that and similar discussion
#mod_development message


update: i manage to do combobox work on controller in my mod rebalance items yourself
need to use onjoypaddown, thanks burryaga

function RebalanceIt:onJoypadDown(button, joypadData)
    if button == Joypad.AButton then    
        self.selected = self.popup.selected    
        RebalanceIt.onEditItemChange(self.target,self)
        self.parent:close()
        setJoypadFocus(joypadData.player, getPlayerInventory(joypadData.player))
    elseif button == Joypad.BButton then
        self.parent:close()    
        setJoypadFocus(joypadData.player, getPlayerInventory(joypadData.player))
    end
end
--and link it when create combobox entry
comboentry.onJoypadDown = RebalanceIt.onJoypadDown
calm depot
#

it'll even let you hotpatch

scenic cradle
#

hey folks - anyone have any experience (or an example) with the LUA to cycle through a server on boot and remove certain tiles based on x/y/z co-ords? I've got a rough bit of code working to randomly place tiles at x/y/z on boot, but I also need to clean up those tiles from previous boot as well and am unsure how to achieve this easily.

calm depot
#

by default the server makes a backup each time it boots

#

unless you've changed the default, or restarted it over 5 times, you'll have a backup save

#

which is orders of magnitude easier than trying to figure out which random tiles have some incorrect entity on them

scenic cradle
#

@calm depot I have the tile coordinates/names that I want to check if are present and then subsequently remove on boot; I'm just not sure how to go about bouncing to each of those co-ords and performing the remove of the tile.

pulsar heath
#

if only they listened to me 10 years ago and went with sql for the database and not a access database now i wouldnt have to go through this... who uses access db in a media company.... idiots...

#

who uses access dbs... period... makes no sense

calm depot
#

I assume you don't still work for them. Stop complaining and bill them exorbitantly

#

Shit like this is where you get "special" pricing for not having listened all those years ago

thick karma
vivid linden
#

cam anyone help me with understanding lua script? I know what I want to do just not sure where to start like I know I need to add a context menu and stuff

thick karma
# wheat kraken <@55792318204092416> hey, as an veteran mod developer, did you know what menu op...

FYI, you need to play with onJoypadDown(button, joypadData) and onJoypadDirUp/Down/Left/Right. Wookiee Joypad Support adds functions for adding button images to menus for stuff like L1 and R1 and the D-Pad.

You also need to learn to give the joypad focus to the correct object and you need to make sure that object is prepared to handle joypad focus; I personally convert ISPanels to ISPanelJoypads, deriving the fundamental structures from that in order to prepare for support to be added when I am adding support to something.

bronze yoke
#

the most you can do is keep a persistent table of tiles to remove and detect when they do become loaded

scenic cradle
#

@bronze yoke so assuming I have a table with x/y/z/tile already built (it's how I'm loading the tiles) what would I call to delete/remove said tile?

bronze yoke
#

i think IsoObject:removeFromWorld() is enough

scenic cradle
#

ok - that's what I thought; just need to figure out how to iterate thru my table and have it pass the data over - thank you.

cunning canyon
#

Does the game make a distinction between wetness received from rain vs sweat? I know the moodle implies it doesn’t, but is rain wetness and sweat wetness (sweatness if you will) tracked separately then added together? Or do both just pile on to the same wetness stat?

thick karma
#

@cunning canyon Before you get wet, definitely... after, it seems no.

#

And the game may make you wet from Java. idk...

cunning canyon
#

I hate spilling coffee on myself

#

Alright, I think I can figure something out.

thick karma
#

Oof that is totally the worst

#

@clever turret I have reason to believe that may be a bug in Brutal Handwork (new dual wielding mod). We are working to get to the bottom of that one, but I am not sure about it.

clever turret
#

Good to know, thank you

thick karma
#

It should be intermittent and nonfatal to your server afawk but feel free to play it safe on that one by awaiting the patch. @clever turret

clever turret
#

The server can run it just only runs for about 15 minutes before that comes up and it crashes

digital moon
#

Would there be anyone willing to help me with a container script I'm trying to complete? The model, tile properties and overlays are finished - but I'm still struggling with learning how to get it to only accept specific items. Ideally, once I get this to work it will open the door for completing a large(r) project I've been wanting to do.

clever turret
#

But only when other players are on the server, if its just me testing on my multiplayer server it dose not happen

ancient grail
#

Omg he mentioned a bunch of people

fast galleon
digital moon
#

It would be a moveable tile like a shelf or cabinet. I saw what you suggested on Github but admittedly, I'm still a little confused which is slightly embarrassing. I figured my knowledge of Python would help me with the logic behind it but I'm still lost lol

fast galleon
#

how far did you get?
do you have a way to grab the container for testing?

digital moon
#

I haven't gotten it into the game yet - but I believe everything is done except finishing the item script and lua file. I can bring it into the game and test - in your comment:

myGlobalFunction = function(container,item)
--return true or false
end

Am I understanding if the container name was "toolbox1" and the item/category I wanted it to accept was "screwdriver" it would be:

myGlobalFunction = function(toolbox1,screwdriver)
--return true or false
end?

fast galleon
#

I think if you wanted to accept only tools you could use setOnlyAcceptCategory("Tools"), that needs some tweaking and I don't use that.
*probably wouldn't work, checks different category?

digital moon
#

Oh gotcha - I've probably overlooked it completely - but is there a list of functions somewhere I can peruse?

fast galleon
#

for screwdriver it would be

myGlobalFunction = function(container,item)
 return item:hasTag("Screwdriver")
end
digital moon
#

Ok - thanks again for this.

#

That makes sense - and this would be in the lua file for the container I'm creating?

fast galleon
#

yeah lua

digital moon
#

Perfect - thank you.

fast galleon
#

if you make the global function it's a good idea to put into the table for AcceptItemFunction, which means the lua file would better be in server directory and have require "Items/AcceptItemFunction" on top

#

so that not to pollute the global space

digital moon
#

Got it - good to know!

drifting ore
#

At least not even close to game breaking

clever turret
#

Just came over from mod support i can link you the original thing i posted if you want, not sure how many mods i have running i am using Burryaga's server settings, yeah not game breaking just annoying for the server to shut down every 15 minutes, otherwise the mod tends to run great

drifting ore
#

I just realized he mentioned some update or something. But sorry to hear about the mods conflicting. Weird how you have that error using it when I have a crap ton of mods installed. Interested to see what is causing the bug because as much as it’s showing those things, I still don’t think its brutal handwork unless another mod is doing something to it. I have gotten 0 stack trace from it so far. I am a kb and mouse user though.

#

Assume you tested the mod by itself no issues?

clever turret
#

Will be able to test it later it only happens when another person is on the server so just waiting on my mates to help me test

thick karma
#

Dhert is aware of this bug and he acknowledged recognizing it to me in DMs

#

It is simply intermittent

#

And therefore you may not experience it at all

drifting ore
#

Ahh you know what causes it by chance?

#

That’s so weird that I haven’t experienced it at all

thick karma
#

He is not 100% sure yet what triggers it, but he believes it may pertain to a failed initialization of an inventory item in the Java side of the maths.

drifting ore
#

10 hours of testing at least

clever turret
#

Thats good then, be sure to thank them for me for looking into it

drifting ore
#

Ahhhh

thick karma
#

But I was aware of it from conversations with him.

drifting ore
#

Well I’ll keep an eye out also if it’s something he hasn’t narrowed down

thick karma
#

I know it's a bit counterintuitive, but in this one case I think it is not a conflict.

#

Yeah I am gonna work on reproducing it when I get done with some other stuff and see if I get lucky.

drifting ore
#

Gonna spawn all weapons and just test them all in different combo

thick karma
#

He says he thinks it only happens during unarmed attacking

#

But that may or may not be accurate since it's so intermittent

#

@clever turret Any idea if that matches your experience?

drifting ore
#

Extra weird. I have around 600 kills with fists. Tyty I’ll specifically check that. I may have to test without the auto dial wield on. What sandbox setting do you use also Angelo?

#

I want to use the same

#

I have everything checked atm since I prefer the back and forth personally but I’m sure most may not play that way

clever turret
#

Default settings for it so 1st one un checked, 2nd checked 3rd unchecked

frank lintel
#

PZ is using Java 17 is it not?

#

I mean I know LUA for the mod coding but making the build environment etc for the IDE

rugged flicker
#

Hey, lads.
What are the arguments in this function?

#

After the string

#

Is it color or

dark wedge
#

The thing with Brutal Handwork is a random bug that can happen with dedicated servers only (doesn't happen with the Host option), and only with unarmed. Not sure exactly what causes it, but it is harmless from my testing; you would be the first to report it is actually killing the server @clever turret
It only happens when you're unarmed, and now that I think about it more, I think its an issue with vanilla in how its doing damage on the server. i.e. it received damage from your player but there's not actually a weapon equipped since I do it in my code locally and the game throws an error there.

clever turret
#

I am running hosted when this happens, from my players report what seams to lead up to the server crash is them using the unarmed attacks to fight zombies

#

Interestingly both the players who reported that started with amputated characters using The Only Cure Mod

drifting ore
#

I run dedicated and 10 hours of usage no issue also

#

Not a single error

dark wedge
#

The OG Only Cure, or the Only Cure but better?

#

Yea, its hit or miss. lol

drifting ore
#

I don’t use toc

clever turret
#

There a chance its them fighting unarmed without the other arm is bugging it out?

drifting ore
#

Just sharing anything to narrow down

clever turret
#

The only cure but better

rugged flicker
#

❤️

dark wedge
#

Ah, cool. It might be something to do with that, not sure. My TOC compat has gotten better too, so maybe. I'm working on a big update for the mod, so here's hoping that issue is resolved then.

hollow shadow
#

anyone know what these do in a gun script?

clever turret
#

Hopefully, the mod is amazing otherwise the duel wielding is so cool

frank lintel
#

why they using floats for a color is beyond me though...

rugged flicker
#

is it like 0,0 to 1,0 or 0,0 to 255,0

frank lintel
#

dunno it doesnt have a descriptor, given its a float I'd say 0-1.0 is likely.. Im totally new to this myself just familiar with java/IDE's etc from MC days

rugged flicker
#

gonna test

fast galleon
#

usually it's 0 to 1

frank lintel
#

right now Im just pulling hair trying to get my workspace set up cuz its saying use Java 8 and Im like why?

drifting ore
#

One of those rags is the chat stream I’m sure

#

Args

azure rivet
#

Hello, what program does anyone recommend to work with .pack files?

pulsar heath
digital moon
digital moon
rugged flicker
vivid linden
#

would anyone teach me some lua? I don't need anything crazy but like how to add modifiers or like actions to items and like that stuff

#

but im an expert on spawn mods now lol

drifting ore
#

i think they are labeled by some id

drifting ore
#

weird did you test it?

#

doesn't seem right

rugged flicker
#

Ye

drifting ore
#

what kinda values did you use for coloring if i may ask?

cunning kestrel
#

quick animation question: do you need a new fbx file per animation ?

rugged flicker
#

0.0 to 1.0

drifting ore
#

how did you convert them? or just kinda test until worked haha

rugged flicker
#

1.0 = 100% red

drifting ore
#

got it

rugged flicker
#

= 255 r

frank lintel
#

the javadocs dont got details but the values are labeled what its expecting it for

finite sonnet
#

Hello, does anyone have a guide or something that explains on how to patch some mods?
Trying to fix compatibility with Spongie's Clothing and Brita's Armor Pack, but am unsure on how to do it.

frank lintel
#

ya in the same spot Im at Im trying to see if I can fix some issues with superior suvivors

drifting ore
#

patching mods is specific to the user having the conflicts TBH. mainly because everyone uses different mods and setups and settings

scenic cradle
#

Ugh okay - so I did what I thought would work and rewrote the spawning functioning to be a removal function, and then swapped it out in the same place the spawn function gets called hoping it would step thru the table of map coords and use the IsoObject:removeFromWorld() function to do the removal ala my conversation with @bronze yoke earlier, but to no avail - no errors, but it's also not doing it - leaving the code dump here if anyone has a minute and could lend any insight into how I'm screwing this up it'd be greatly appreciated.

quasi kernel
#

Are you able to change data in Shared from the server or does that not work?

bronze yoke
#

do you mean can you change data cross-folder? the answer to that is yes, but your wording makes it sound like you expect data in shared to be networked, which it isn't

quasi kernel
#

Nono I dont expect it to be networked

#

I mean like

#

There's some shared data, I change it on the server, would the server still see the changes?

#

If so then my lead may be dead but oh well

finite sonnet
# drifting ore you'd have to know what issues you are having first lol

Oh, the issue is simple:
Brita's and Spongies have Bomber Jackets. 1:1 the same names, but different ones when worn opened. Depending which one is loaded first, it'll overwrite the other.
My newbie guess in modding is to simply change the file names and directions, but the "brute force" would be to copy the mod and have it release as a standalone lol

drifting ore
#

the fix is practically the same either way so uploading another version of the mod really makes literally no sense

#

my guess is you will have to update item information in scripts, but anything thats tied to it also will require some changing. i'd use the pzwiki and threads up top to get started on figuring out what will work best for your scenario. but for the most part changing some item info would net decent results. you may need someone with clothing experience since i have no idea what's affected in that dept. but doing some research yourself on how item scripts work will be a big advantage to you

#

tools up top in threads also if i didnt mention

finite sonnet
#

Looked through them, will look through again then

#

But that'll be atleast something to start with

finite sonnet
#

Ah, thanks

jaunty marten
#

it's a shit

red tiger
#

Good afternoon.

scenic cradle
# jaunty marten it's a shit

Well - that's good to know, however it's working for the purposes of spawning right now - can you recommend a better format?

red tiger
#

Took a break from PZ for a couple days.

jaunty marten
scenic cradle
#

thanks @jaunty marten - I'll refactor my code to use that tabling format at some point - likely once I figure out how to get the actual deletion working lol...

jaunty marten
#

may be u don't know why ur method is bad: problem is on each string concat "1" .. "2" lua creates new string object so each ur get/set func call creates at least 2 unnecessary ones

#

it's bad for performance

scenic cradle
#

I mean, if it wasn't clear from my code markup - I bashed this together based on code I observed in other mods; I'm completely new to LUA.

jaunty marten
#

sadly most of workshop mods creators have no knowledge about good code PepeProgrammerCry

scenic cradle
#

lol - I will do my best to learn as I move forward; I was just happy to get this working for the spawning/placing of the tiles I need - now I want to have them "move" randomly every in game day - that's proving a lot harder than I thought it would be cause of the removal.

ancient grail
#

anyone knows how to print if the player is listening to music

bronze yoke
#

listening to music in what sense? true music?

ancient grail
fast galleon
#

why you prefer this?

#

also this needs more checks

jaunty marten
#

visually his way is faster to use but it's actually worse

#

yeah

jaunty marten
#

auto 3d table roflan

fast galleon
#

what's that?

drifting stump
#

keepInBounds or keepWithinBounds which one would you prefer

jaunty marten
#

metatable with __index using
so just

tbl = create3DTable()

tbl[93][57][45] = val
local val = tbl[91][567][84]
fast galleon
frank lintel
#

return tbl?

jaunty marten
#

didn't test performance for it so I'm using it only while dev, on release will redo to 2nd method

jaunty marten
fast galleon
#

would string.format("...",x,y,z) be better ( i assumed it's worse)

jaunty marten
frank lintel
#

in your posted code get_value ?

jaunty marten
#

tbl[x] is nil so what u want to return

#

result should be nil

frank lintel
#

'how do you get xyz' with what you returned from get_value is what I was saying. might got lost in translation

jaunty marten
frank lintel
#

oh I totally understand why you dont like using concat.

fast galleon
#

interesting I assumed concat was fast, I'll look into this later 👍

frank lintel
#

imho Im still stuck just setting up my enviroment to start playing with this cuz Im just stressed as to why I cant use JDK 17...

#

depends on the language

fast galleon
#

would global ModData save a metatable

bronze yoke
#

function objects can't be saved

jaunty marten
#

anyway u don't need to save metatable, u can just easily recreate it in next time

fast galleon
#

I can't see myself using table[x][y][z] , too many useless tables also seems like str = x .. y .. z makes only one string (?)

frank lintel
#

is that an actual function or just a generic name?

drifting ore
#

i love reading these debates. i honestly write down all this stuff lol

frank lintel
#

Im only asking cuz Im new to lua totally and sadly gonna be unlearning java it seems. ^_^

fast galleon
#

I think I got it, you get minimum 100 new strings for gc every time you load a chunk

jaunty marten
#

lua creates new string on EACH concat

fast galleon
#

stackoverflow said only one if it's one liner

jaunty marten
#

too many tables, yea, but lua is good with indexing tables so it's fine

bronze yoke
#

and xyz will cause overlapping values, so it actually has to be x..","..y..","..z, so actually 5 strings

jaunty marten
scenic cradle
#

lol... love the discussion this has sprung and appreciate all the input on formatting of my data table - still doesn't fix the original problem I'm trying to address though drunk

jaunty marten
frank lintel
#

tbh Im still wondering why you'd even store xyz as a string in a 3d array.

scenic cradle
#

ahem, as stated before: The Trip Doctor — Today at 4:01 PM
I mean, if it wasn't clear from my code markup - I bashed this together based on code I observed in other mods; I'm completely new to LUA.

jaunty marten
#

I think will be single for liner concat only if concat not variable but literally strings. like optimised it on actually loading code

fast galleon
#

not to blame chuck for example but it seemed simpler and nicer as well

jaunty marten
#

not sure about that

jaunty marten
fast galleon
#

a lot of garbage

bronze yoke
#

i'm still using it in a mod of mine because it'll make the code really messy if i don't, but i will take the string.format advice

jaunty marten
fast galleon
#

@scenic cradle I didn't check the whole code yet but if you remove objects from server you need to use the transmit command

bronze yoke
#

i don't think the latter exists 😅

scenic cradle
#

well you'll have to excuse my lack of LUA knowledge for trying to beat that into submission @bronze yoke LOL

bronze yoke
#

so the square:removeFromWorld(isoObject) line in SimuVTS_SpawnVendors.Remove should be isoObject:removeFromWorld()

scenic cradle
fast galleon
#

but I won't be making changes before v42 or ever

scenic cradle
#

I am prepared for anything I make to break with v42 😄

jaunty marten
#

will wait 42 too

frank lintel
#

oh there an eta on when that is cuz Im wondering if I should just chill and try and learn lua more before even trying to get into modding cuz of possible major changes

fast galleon
#
--remove obj from server
square:transmitRemoveItemFromSquare(isoObject)

--add object from server
square:AddSpecialObject(isoObject)
--if combined with remove then use square:AddSpecialObject(isoObject,index)
if isServer() then
  isoObject:transmitCompleteItemToClients()
end
sour island
#

Personal opinion, stuff won't change enough to be that concerned. The biggest change was the reimplementation of MP, and most mods survived that.

#
  • you still have to get a handle on Lua either way
frank lintel
#

one Im looking into debugging has not

sour island
#

Which?

frank lintel
#

superior surviors

sour island
#

That's never been MP compatible to begin with - even before

frank lintel
#

yeah I was looking into maybe fixing some stuff and look into if its possible that right now Im just looking at why making a workspace doesnt like jdk17

fast galleon
#

@scenic cradlein code far above you make a new isoObject and then try to remove that, what's the point of that?

frank lintel
#

right now that mod slapping me with a UI update error

sour island
frank lintel
#

yep just started down this road last night using IntelliJ

scenic cradle
sour island
#

Are you using Konijima guide?

#

It's far easier to use than the original documentation

scenic cradle
#

@fast galleon I figured because I was able to place my tile via Place(square,sprite) a quick modification of that function to add in the removal code should take the input of (square, sprite) and remove them.

sour island
fast galleon
frank lintel
#

Im just getting hung that the reverse engineering isnt using the same jdk the game actually uses.

#

yes that page plus pz-zmod and a few other pages

sour island
#

This is the only page you should need

scenic cradle
#

@fast galleon each location has a specific sprite, so I COULD do removal via sprite name if that's possible? May be easier.

fast galleon
#

also if it's just for debugging you can use something even simpler

#

getSquare(x,y,z), then find object and remove it

#
local function OnLoad(isoObject)
  local square = isoObject:getSquare()
  if square and etc then
     square:transmitRemoveItemFromSquare(isoObject)
  end
end
MapObjects.OnLoadWithSprite("sprite_tileset_01_0", OnLoad, 5)
void tiger
#

Does someone know what "GroceryBagnumber" is In-Game or how I can find out?

scenic cradle
frank lintel
# sour island This is the only page you should need

spinning wheel rolling now... and that explains why I was having issues on that page and thought the instructions were too basic cuz I wasnt seeing the highlighting showing the hidden windows on each step... derp.

sour island
#

Ah yeah, there's drop downs for each piece. Unfortunately it's not a quick 1-click to get started.

#

But intelliJ, with the emmyLua plugin + those steps should set you up for some success.

barren junco
#

do you guys know how to turn a corpse into a skeleton?

gilded hawk
barren junco
#

thanks

#

that should work for "living" zombies

bronze yoke
#

that will only work on living zombies

barren junco
#

if i access a dead corpse's zombie would it work?

#

like IsoDeadBody.character:setSkeleton(true)

#

i personally dont think so, since wasSkeleton in IsoDeadBody seems to only be assigned at the constructor

#

and in UpdateRotting()

frank lintel
#

yeah my layout just wasnt making it clear there was more detail to each step but looks like I might be set-up now.

ancient grail
#

Lots of new faces

bronze yoke
#

for corpses, you can use IsoDeadBody:sendObjectChange("becomeSkeleton"), but only from the server (or in singleplayer)

barren junco
#

i see

#

thanks for the info guys

bronze yoke
#

if you need to do it on a client you might be able to just directly edit the rot stage of the corpse so that it becomes a skeleton on the next corpse update, otherwise you can send a clientcommand to the server to do it

barren junco
#

can you send commands to the server?

#

that sounds like a security issue

bronze yoke
#

it's just the term, you basically just send a string and a table of arguments to the server and it's up to the mod to handle it based on that

barren junco
#

ah smart

#

thanks

plucky mauve
#

is it possible to make a mod that changes the aiming guns animation?

hexed swan
#

where could i learn to mod

#

zomboid

#

or is there like a documentation that i could read

jaunty marten
wet osprey
#

is there any mod that secure spawns x item in certain locations?

like 100% chance of x item to spawn in louisville hospital

drifting ore
# wet osprey is there any mod that secure spawns x item in certain locations? like 100% chan...
drifting ore
foggy bone
#

hwo does one get into modding this game and resources to lear

foggy bone
#

ty

ancient grail
scenic cradle
#

ugh - just more headaches - thanks for the help everyone today; get up and try again tomorrow.

zinc pilot
sour island
#

That'd be up-to how it's handled, but realistically not many mods create items / remove items outside of crafting or recipes.

barren junco
#

any channel where i can discuss pixel art?

fast galleon
#

but a lot of mods track item transfers

sour island
#

track item transfers?

frank elbow
barren junco
#

modding purposes

fast galleon
#

hook to transfer item

frank elbow
#

Oh, then here I suppose

fast galleon
#

and adding / removing items is not that uncommon generally

barren junco
#

im working on an icon for the cannibal trait, thoughts?

#

its a liver

sour island
#

Plenty of mods do it, but I'd have to say not that many tbh.

barren junco
#

this is the icon for addict cannibal

sour island
#

Looks like a liver

#

so there's that

barren junco
#

well nice

sour island
#

What size are these? Aren't traits like 16x16

barren junco
#

18x18

rancid panther
#

the first comment on my mod 🤣

barren junco
#

they can vary in size actually

barren junco
rancid panther
#

traits are indeed 18x18

#

but some traits icons dont touch the edge pixels

sour island
#

I think it looks good, maybe a knife and fork if it's not too much detail to fit?

barren junco
#

i did try the fork but it didnt look that good

#

i also tried to add a little bite but it just looks weird

rancid panther
#

maybe put a sliced part of the liver

#

kinda like the penisham icon

barren junco
#

o hey not a bad idea

#

might be too much detail for the size though

#

thanks for the feedback

rancid panther
#

i cannot believe the ham emote on the official project zomboid server is named penisham

barren junco
#

maybe this does the trick?

barren junco
frank elbow
# sour island

I can only imagine they saw the Q&A format and assumed it's a FAQ without reading anything

rancid panther
#

you can also try the trick of the utensil being off the edge a bit instead of fitting the whole thing inside

sour island
#

I chose to be a slightly less mean person today

barren junco
#

not very kind i can tell

#

but he deserves it

prisma imp
#

Hey y'all, new here. Is there a "Requested Mods" section somewhere?

jaunty marten
barren junco
prisma imp
rancid panther
barren junco
#

that would be great

rancid panther
#

but sometimes ppl have an idea or are asking if there is a mod for something, and if there isnt u can help them

jaunty marten
prisma imp
#

I second this measure.

rancid panther
#

also in project zomboid discussions people sometimes post mod ideas or update ideas

jaunty marten
#

ah, btw

#

u can try to check pz forum

prisma imp
prisma imp
rancid panther
#

very tru

prisma imp
sour island
#

@pulsar heath https://www.youtube.com/watch?v=084ZHk6U_2M Anyway to make zombies talk to you using twitch?

Play World of Tanks here https://tanks.ly/3I98IYY
Thank you World of Tanks for sponsoring this video.
During registration use the promo code TANKMANIA to get for free:
● 7 Days Premium Account,
● 250k credits, Premium Tank Excelsior (Tier 5)
● 3 rental tanks for 10 battles each: Tiger 131 (Tier 6), Cromwell B (Tier 6), and T34-...

▶ Play video
modern hamlet
#
function TestFunction(player, otherPlayer)
    player:Say("x")
    otherPlayer:Say("y")
end

Would something like this work on the client side? Or should I move it to the server side?

jaunty marten
frank lintel
#

you dealing with JS or some other way to do the integration?

rancid panther
frank lintel
#

We're here to talk to you about your AIO extended warranty.

drifting ore
#

this is for developing mods

mint jolt
#

Sorry

#

Thought developers might know

drifting ore
#

all good we all love mods 😄

frank lintel
#

anyone using IntelliJ care to look at zombie/commands/CommandBase.java and tell me if accessLevelToInt is showing up different then the .class file?

barren junco
#

you mean this?

frank lintel
#

yep and do the diff and check out that function pls

barren junco
#

this is the one in the .class

frank lintel
#

yeah and the decompiled one is nothing like that

barren junco
#

yeah

#
public static int accessLevelToInt(String var0) {
      byte var2 = -1;
      switch(var0.hashCode()) {
      case -2004703995:
         if (var0.equals("moderator")) {
            var2 = 2;
         }
         break;
      case 3302:
         if (var0.equals("gm")) {
            var2 = 4;
         }
         break;
      case 92668751:
         if (var0.equals("admin")) {
            var2 = 0;
         }
         break;
      case 348607190:
         if (var0.equals("observer")) {
            var2 = 1;
         }
         break;
      case 530022739:
         if (var0.equals("overseer")) {
            var2 = 3;
         }
      }

      switch(var2) {
      case 0:
         return 32;
      case 1:
         return 2;
      case 2:
         return 16;
      case 3:
         return 8;
      case 4:
         return 4;
      default:
         return 1;
      }
   }
#

worst decompiler

frank lintel
#

okay... I thought I was tripp'n

barren junco
#

nah, hope i was of help

#

i am tripping now actually

frank lintel
#

well Im still wondering which one I should be using honestly I think I grasp why its using hashcodes but I dont wanna assume

sour island
#

The sources received from the process in the guide should provide a .java and .class file - I believe the java is used to compile the lua library.

#

I always refer to .class for referencing what to do/how things work

barren junco
#

it does feel like the best one to use

sour island
#

I also havn't seen such a drastic difference before though

frank lintel
#

yeah thats where they from I was backtracking why there a .class file in this mod so I ended up back into the libraries when I came across this

#

I think its to work around issues with character sets

sour island
#

Could be why some people find very odd stuff in the java files now that I think about it

tribal shuttle
#

Hello. I was hoping to make a mod to encourage wider exploration by fuly randomizing all loot containers. Anyone have any ideas where to start? I was thinking about a master loot table injected into all of the container lists, but I'm not sure how to do it.

fast galleon
#

that's the opposite of exploring if you can find everything at one place

#

You'd then need to edit tables found in Distribution.lua, ProceduralDistribution, Vehicle, etc?

sour island
#

I think he means make it so containers dont have expected items

#

If you think about it like a randomizer run for other games

#

Imagine running into rosewood and it has mall pop ded

#

I'm working on a mod that deals with shuffling a list

#

Idk if it helps, but you could technically try to shuffle the loot tables

cunning canyon
#

How unique are RoomIDs?

#

and do they change between updates ever?

calm depot
#

I'm moderately sure they're consistent for the lifetime of a save

#

if I'm wrong, that's a terrible excuse for an ID

tribal shuttle
# sour island If you think about it like a randomizer run for other games

That's roughly the idea. The game's gotten pretty stale for me, knowing where the best stockpiles of any given item are. You can get fully equiped and set for long term survival on Apocalypse in about 45 minutes. So I figure instead of just bulleting over to the local grocery store every game, make it so the goods are thinly distributed across every place. No one place is going to have everything, and I have to do more general building exploration than simply Warehouse > Grocery > Bookstore > GG.

sour island
#

If you understand lua tables you can manipulate it pretty well I'd imagine

tribal shuttle
#

I'm not particularly fluent with lua. But I'm cobbling together a list of item IDs right now. What I don't know is if there's a more elegant solution than overwriting every individual distribution table.

sour island
#

You could scramble them with a single function

tribal shuttle
#

That'd be neat. But alas, no idea how it's done. 🤷‍♂️

sour island
#

let me see if my list shuffler can be used on keyed tables

tribal shuttle
#

It's probably going to require a more nuanced solution anyways. Just scrambling the tables could easily result in items that are supposed to be rare becoming far too common.

sour island
#

You could make it only scramble certain tables I suppose

#

also it wouldn't make items more rare - just change the locations

#

I guess it might provide more locations for it to be rare in

#

🤔

tribal shuttle
#

Take military gear for example. Guns and ammo. The boxes at the military checkpoint have a HIGH chance of them. Suddenly that table gets a chance to be put in ANY container. Guns and ammo everywhere.

#

Even if the chance of an individual container being a military container is low, the number of containers that end up being military gear is MUCH LARGER by comparison

sour island
#

So you can't simply shuffle the distro list as it's a keyed pair- but you can create a list of IDs and shuffle those

#

You could also make some exceptions to that rule - or modify values as needed

tribal shuttle
#

Right, I'm just awful at finding what commands let me actually do that. I'm pretty much only self taught via cutting up code from other sources.

ancient grail
#

All sorts of crazy are found here on this chat

sour island
# tribal shuttle Right, I'm just awful at finding what commands let me actually do that. I'm pre...
local function scramble()

    local origRoomLoot = {}
    local foundRoomLoot = {}

    for roomID,data in pairs(SuburbsDistributions) do

        for containerID,contData in pairs(data) do
            ---if room's container's data has an items list OR if it has a junk list with items
            if (contData.items and #contData.items>0) or (contData.junk and contData.junk.items and #contData.junk.items>0) then
                ---Add extra exceptions here if needed
                table.insert(origRoomLoot, roomID)
                table.insert(foundRoomLoot, roomID)
            end
        end
    end

    ---shuffle found list
    for origIndex = #foundRoomLoot, 2, -1 do
        local shuffledIndex = ZombRand(origIndex)+1
        foundRoomLoot[origIndex], foundRoomLoot[shuffledIndex] = foundRoomLoot[shuffledIndex], foundRoomLoot[origIndex]
    end

    ---using the original order found replace the entries with the shuffled version
    for n,_ in pairs(origRoomLoot) do
        SuburbsDistributions[n] = foundRoomLoot[n]
        ---Make changes to distro here as well if needed
    end
end
Events.OnPostDistributionMerge.Add(scramble)

Not tested at all

tribal shuttle
#

I guess I'll have to try it out to see then.

sour island
#

edited a typo

#

This was drafted using media\lua\server\Items\Distributions.lua and media\lua\server\Items\SuburbsDistributions.lua

tribal shuttle
#

Thank you, I'm sure I'll be able learn something about what I'm doing from this.

sour island
#

good luck

barren junco
#

made this little debug menu im proud of

#

best part? you can easily add/remove traits

jaunty marten
#

too common name

barren junco
#

its actually not global

#

but CONSTANT as a local name is probably a bad idea as well

#

thanks for the feedback though

jaunty marten
#

for local name it's fine

#

but if it's local then better to name it in lower case

#

upper case uses for global ones

barren junco
#

oh i see

#

Lua naming standards

jaunty marten
#

lua have no official code style

#

but upper case for global it's just a common thing for everywhere

barren junco
#

i see

jaunty marten
barren junco
#

thanks for the info :D

#

i renamed it to config

jaunty marten
frank lintel
#

just gonna follow java syntax

quasi kernel
#

Curious question

#

I may have had a breakthrough for UFP with use of metatables, I was curious if there was a way to get the current mod a segment of code is running from

#

Or rather, what mod is currently loading.

#

If so, I might have a major lead.

bronze yoke
#

so i'd look there

quasi kernel
#

Thank you for the lead

#

Oh this is interesting

#

Very strange, but interesting.

#

Makes sense though.

#

@sour island If you find some time soon, I may need your help understanding some of your code so I can possibly repurpose it for something else. I'd like to understand what you're doing rather than just copy pasting it, since I don't know if there's unnecessary stuff for what I'm doing or not.

#

I understand if you're busy too tho, so plz take your time

#

I might head to sleep soon tho so idk if I'll be here if and when you get here

kindred dawn
#

Anyone think that we should be able to grab house alarms and then use them to attract zombies? Something for a zombie trap.

weak sierra
#

that'd be cool for like.. an advanced noisemaker

#

house alarms aren't presently a tangible thing afaik

#

just a chance event per house

kindred dawn
#

Plus, you can’t remove them, or make them currently

#

So I’m currently trying to make a mod that makes em

#

Then I need to learn how to make the noise

#
module Base
{
    recipe Make Home Alarm
    {
        keep [Recipe.GetItemTypes.Screwdriver],
        ElectronicsScrap=5,
        Amplifier,
        Radio.ElectricWire,
        Screws=2,

        Result:HomeAlarm,
        SkillRequired:Electricity=3,
        NeedToBeLearn:false,
        Time:100.0,
        OnGiveXP:Recipe.OnGiveXP.DismantleElectronics,
        Category:Electrical,
    }
}
#

This is what I currently have to make the Home Alarm

#

I used the xp for dismantling cause i was looking on the xp for it too

ancient grail
#

Its just addsound
Or fo you want the trigger alarn?
Give it to you later once i get back to my pc . Im afk atm

kindred dawn
#

Would like to learn how to add a way to make it start/stop the noise, like an alarm

ancient grail
#
getPlayer():getSquare():getBuilding():getDef():setAlarmed(true);
kindred dawn
#

Hmm, you think that for certain servers, like rp servers, having the ability to set off Home Alarms in buildings is a good idea?

#

I don’t do it myself, but you could technically also use that idea to make zombies swarm to that location

#

Though my idea was just to make it so that a home alarm makes the alarm noise when triggered

#

I could theoretically add a new “Home Alarm”, by giving it a battery and making it into a throwable too, setting the noise to home alarm…

ancient grail
#

welp this code will sset the alarm yeah but if you are a player then it will also set it off

#

lol

#

you have to figure out how to get the definition from outside and stuff like that on your own

fast galleon
#

I sometimes think of something similar but I reposition buildings / rooms. (bad idea currently)

ancient grail
fast galleon
unborn linden
#

oh mb wrong chat

fast galleon
#

you can add items vanilla way with ItemPicker.fillContainer(container,getPlayer()), the items will be based on container type and the room.

#

containerType you normally set in TileZed e.g crate

ancient grail
fast galleon
#

but that can be solved with loot respawn so you probably think about placing containers back

tawdry solar
#

is this code correct?