#mod_development
1 messages · Page 522 of 1
How do you add attachments to custom guns
Good evening all, I have a complex challenge for you if someone can help 😅
I am trying to trigger a condition depending on the player standing on a defined square. The following code allows me to get a IsoPlayer ⤵️
for i=0,square:getMovingObjects():size()-1 do
local moving = square:getMovingObjects():get(i);
if moving and instanceof(moving , "IsoGameCharacter") then
player = moving;
end
end
But now comes the tricky part, in multiplayer if the IsoPlayer retrieved is the played character, then it's all good I can use functions like hasTraits() or HasItem() and other IsoGameCharacter functions on it. But if the IsoPlayer is another player in MP, it looks like I can't use those functions!
So here is are my questions :
- How can two instances of
IsoPlayercan have different functions? - If I have an instance of an other
IsoPlayerin MP, how can I get thecharactercorresponding to it in order to query its functions?
should probably change the name of the magazine rounds to 7.62
It should retrieve all players equally
It does..? I always thought it called it 5.56
I think he means in the files, the item display names are correct.
Ah
I fixed it
Yeah that is what is driving me nuts, I ran other tests but it just seem that there is some "desync" with some data of the character get from MP 🤔
I will try using other data that does not desync then, but I can confirm that player A sees player B with less traits than they actually have 🤷
By either adding to the attachments' lists of weapons with doParam, or adding the options to the context menu yourself.
just run the code server side, cant expect clients to know everything about other clients (probably a waste of bandwidth)
If you can't find a way around the problem without sending it over the network, you might need to use sendServerCommand and sentClientCommand.
⤴️
Oh this is a good idea
So I will try to use this sendServerCommand but I would have liked to avoid it, I mean, the trade context action is done in client so I hopped to be able to run it without doing that
But I'll try with that anyway
Arf but in server I can no longer do the things I want to do when inside a onClientCommand, it's client code that needs to be executed right after the check 
sendServerCommand is means either "send a command to the server" or "send a command from the server". Maybe it is the second one. I think the on recieve server command is client side code.
Yes but you see, I am currently trying to check if a fitness instructor is nearby to increase regularity of current exercise
if otherPlayer and otherPlayer:getDescriptor():getProfession() == "fitnessInstructor" then
print("FOUND A fitnessInstructor!")
for _,v in pairs(aerobics) do
if v == self.exercise then
self.fitness:incRegularity();
self.fitness:incRegularity();
self.fitness:incRegularity();
self.fitness:incRegularity();
break
end
end
end
But I don't see how I could do that while doing back and forth with the server
Especially considering that this code above is triggered for each rep of a fitness exercise 🤔
how does one use "sendServerCommand"???
When searching "sendServerCommand" this channel (field up right of discord) you can find a handfull of good examples 😉
I mean... I've tried that? Here's what I got:
GetZedOutfit = GetZedList:get(i):getOutfitName();
GetZed = GetZedList:get(i);
sendServerCommand("STR", "GetZed:sendObjectChange(GetZedOutfit, {})", {});```
And my modID is "STR"
seems to not run, like, at all
aaand I forgot to turn off the ping from the reply... Sorry...
Here's the full snippet, called every in-game minute (potentially lag-worthy, I know. Considering switching to every ten in-game minutes).
GetZed:dressInPersistentOutfit("EMSMeade");
GetZed:reloadOutfit();
if isServer() or STR_IsSinglePlayer() then
if isClient() or STR_IsSinglePlayer then
triggerEvent("OnServerCommand", "STR", "GetZed:sendObjectChange('GetZedOutfit', {})", {});
print("deez");
elseif STR_IsSinglePlayer() then
GetZed:sendObjectChange('GetZedOutfit', {});
print("cheese");
elseif isServer() or isCoopHost() then
sendServerCommand("STR", "GetZed:sendObjectChange(GetZedOutfit, {})", {});
print("nuts");
end
end
end```
There is also a website where you can enter "zomboid modding" and be taken to a page with lots of links on it including with documentation on functions including sendServerCommand.
basically: I've got half a year's worth of PZ modding. I know of and use the Javadoc, it's just very vague.
What I'm trying to do here is replace zombies wearing specific outfits.
GetZed:sendObjectChange('GetZedOutfit', {})
Works client-side, just fine. But when used server-side, it complains about "sendObjectChange() can only be used on server"
I've been metaphorically slamming my head against a rock for 5 days now trying to get the outfit changes to save on the server
:o
Hmm what happens if you pass a string like "GetZed:sendObjectChange(GetZedOutfit, {})" into sendServerCommand? I would expect it to just be a string?
sooo, like this?
I think there are no sorts of sendServerCommand that take only one parameter.
ah
sorry for being a noob here, this is the first time I have ever dabbled in anything Multiplayer code
If I am correcly guessing what you are trying to do, this may fail in a different way.
sendClientCommand("STR", "object change thing", {GetZed, GetZedOutfit});
I just remembered you can't pass a zombie as a parameter into those commands though, which is what I mean by this failing in a different way.
You may need the code which picks the zombie to be running on the server from the start.
How would I do that?
something like
if isServer() then
I see
And whatever else is needed in the context.
...assuming it is possible!
yes
gonna try
``` Real quick
it's returning with "sendClientCommand: can't save key,value=1.0,zombie.characters.IsoZombie@55335632."
Do you know if it's possible to add a button here ?
Check my mod, I do that
https://steamcommunity.com/sharedfiles/filedetails/?id=2733680483
Do you remember which file ?
it seem that you must be admin, moderator etc to see other player stats from your client.
GameClient.canSeePlayerStats()
also looking at client\ISUI\PlayerStats\ISPlayerStatsUI.lua might help you find out
sendClientCommand: can't save key,value=1.0,zombie.characters.IsoZombie@55335632
so key is 1.0, the first entery in the kahlua table. Its value is zombie.characters.IsoZombie@55335632. It is failing to send the zombie over the network. Maybe the game can not send zombie references like that over the network.
I get that error and I can't get where it's come from. Hard to describe what I'm doing but if you have an idea:
LOG : General , 1644536115820> STATE: enter zombie.gameStates.IngameState
LOG : General , 1644536115820> [11-02-22 00:35:15.820] ================================================================================.
LOG : General , 1644536116159> Init ISContextManager
ERROR: General , 1644536116304> ExceptionLogger.logException> Exception thrown java.lang.IllegalStateException at UIManager.update line:677.
ERROR: General , 1644536116304> DebugLogStream.printException> Stack trace:
java.lang.IllegalStateException
at zombie.ui.UIManager.update(UIManager.java:677)
at zombie.GameWindow.logic(GameWindow.java:253)
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
at zombie.GameWindow.frameStep(GameWindow.java:745)
at zombie.GameWindow.run_ez(GameWindow.java:661)
at zombie.GameWindow.mainThread(GameWindow.java:475)
at java.base/java.lang.Thread.run(Unknown Source)
LOG : General , 1644536116360> FirstNAME:VirginiaCheung
u can only send basic values
ree
mostly basic values anyways. InventoryItems and IsoDirections are valid
unlesss its the string name of the outfit, no
it is, as far as I gather
if I print "GetZedOutfit", it returns the string value/readable name
local GetZedOutfit = GetZedList:get(i):getOutfitName();
GetZed:dressInPersistentOutfit("EMSMeade");
GetZed:reloadOutfit();
sendClientCommand("STR", "sendObjectChange", {GetZed, GetZedOutfit});
print("nuts");
end```
@winged lotus
ClientSide:
local function requestPlayerStats(username)
sendClientCommand("MyModule", "requestPlayerStats", { username = username });
end
local function onReceivePlayerStats(username, stats)
-- do your stuff here
end
local function onServerCommand(module, command, args)
if module == "MyModule" then
if command == "receivePlayerStats" then
onReceivePlayerStats(args.username, args.stats)
end
end
end
Events.OnServerCommand.Add(onServerCommand);
ServerSide:
local function onClientCommand(module, command, playerObj, args)
if module == "MyModule" then
if command == "requestPlayerStats" then
local otherPlayer = getPlayerFromUsername(args.username);
if otherPlayer then
local data = {
username = args.username,
stats = {},
};
-- get otherPlayer stats
sendServerCommand(playerObj, "MyModule", "receivePlayerStats", data); -- send the stats the the same player who requested it.
end
end
end
end
Events.OnClientCommand.Add(onClientCommand);
your not sending just the name though sendClientCommand("STR", "sendObjectChange", {GetZed, GetZedOutfit}); <<< GetZed is the first value in that table your trying to send, which is a IsoZombie
ahhh
so removing "GetZed" should, in theory fix it?
aka
"sendObjectChange", {GetZedOutfit});
anyone know what timedaction is used for opening car menu
\client\Vehicles\TimedActions\ISOpenMechanicsUIAction.lua
run into a problem
i set it to 1000
and *200 instead of divide 20
to test out if its working
it doesnt slow down at all
when testing hooks like this make sure to go back to main menu, reloadin the script will only add the hook a second time
setting this to ridiculous number
it should take forever to wash
but hes washing fast
what is item? its not defined anywhere.
you forgot to add this.
look at the original method to know what is accessible and returned
so I should add these?
no
they here inside this
we call the original and store it into a variable this and we return it at the end like the original do
so even if
local function CalculateItemFilth(item)
is local, we can call it here
and it doesnt need to be the same with (item)
so i can use (this.item)
?
btw "item" here is a "parameter"? is that what you call it
yes its a param, and yes the method CalculateItemFilth is local to this file.
so its usable in that file.
add a print
i thought local was per block
print(this.maxTime)
well its per file and per block, depend how its nested
a file is a block/object itself
FileA
local stuff = {};
function stuff.test()
print("test");
end
return stuff;
FileB
local stuff = require("FileA")
stuff.test();
what does callstack mean
am I right into thinking these are warning/errors
line 146
line 38
wait
is there even a
getDirtyness
Callstack refers to the "function stack" of your program, if you call A() - the computer puts "A" on the "call stack"
If you call B() inside A(), your callstack would be like
function: B()
function: A()
function: originalCallsite
the bottom frame is the place where you call A(), the middle is the function where you call B()
When a function ends/returns, the stack frame is "popped" and the program goes to the next function down the stack, just after you called that function
0 + true
why is dirtAmount true
I dunno fam, it's your code
Presumably some function is returning in different datatype to the one you expect
What does item:getDirtyness() do? Could be a boolean. Notice how to get the actual value for blood it's item:getBloodLevel()? Perhaps there is a corresponding method for getDirtyLevel
the corresponding method for getBloodLevel() is getDirtyness()
Love that for us
This is why naming conventions are important
Let me check the docs
Is there lua documentation? I'm looking at the pz java docs but don't see anything related
cant tell, new at lua
clothes.lua is my mod
What are you trying to do here? I might be misunderstanding
trying to make a mod where water usage is based on dirt and blood level
scaling based on a max i set
lets say I want max of 10 water at 100%blood and 100% dirt
for now, scaling linearly to 10
Yeah, I get you
So time currently scales.. but water use does not
is water use a hardcoded variable somewhere?
return 10
end```
Line 70
I managed to change water
but its not getting the bloodlevel and dirtyness right
so water right now is always 1/1
i have here one with 74 bloodyness
You did an overload of GetRequiredWater? What does that look like
according to math should be 3.65 water
and then filth is calculated by
bloodLevel + dirtyness
because I'm thinking max of bloodlevel and dirtyness is 100 each so total of 200
with a divisor of 20 we have 10 = 10 water
so 74/20 = should be 3.7 water
but since math.floor converts it to integer
it should be 3 water
right now its 1/1 water
Okay I think I get where you're coming from..
screenshot of locals. i dont know for sure whether to follow this
So, this is a bit hacky BUT
o has a variable called maxTime
\
and maxTime is calculated as ((bloodAmount + dirtAmount) * 15);
Why not just do your math based on maxTime?
Oh they change maxTime based on itself
That's really annoying
Also arguably just bad code
The intention is to clamp maxTime between 1 and 1000
Oh I understand the intention, it just could have been a different variable
the issue is 'filth' calculation
my theory is
getBloodLevel and getDirtyness are not working
did you write CalculateItemFilth?
double-clicking soapList in game
shows that it ?containts bloodlevel and dirtyness?
mr/mrs konijima
And where is this getting logged from?
Because it seems like dirtAmount/bloodAmount are local to the function
so if it's not getting logged in the function, those values don't represent what it is
Not sure.. I think there is an error() function?
ctrl f?
Seems like you're missing character in the call to the original function
The overwritten function, I mean. So some other parameter that's a boolean is being passed as the value for dirtAmount
Should be self, character, ...
oh, but I thought . . . already called for character
Nah, ... is varargs, which means the remaining argument values
... is the parameters you pass into the constructor
So it's everything after character
Since you precede it with character, you're capturing the first arg but not forwarding it
I considered that, but I thought that self was character, what is self?
self is a special value in Lua which refers to the object that the function is being called on (usually a table)
The colon is syntactic sugar which defines self as the object before the colon (i.e., you can use self without the colon, but it has to be explicitly defined if you do so)
So self in this context is ISWashClothing
It's passed into the original one so that the original also has the correct reference for "itself", since it's not being called with colon syntax
so self is kinda like this in other languages?
Mhm, exactly
Can you elaborate on this a little please
Sure
Which line are you referring to?
In that image, line 37
Anyone know how to modify one param of a vehicle script without needing to copy and redefine the entire thing in a script?
local Container = {}
function Container:someFunc(...)
print(self == Container) -- true
end
this is the original
So you're calling the someFunc on Container?
Oooh you're feeding container into someFunc as the context for it
That defines someFunc on container, which can then be called as Container:someFunc() or Container.someFunc(Container)
So you can do shit like self.valueOfContainer?
Mhm
Nice, okay cool
Why would you do that rather than feeding Container in as a param into someFunc? access to private variables?
Just syntactic sugar, they mean the same thing so the only real reason is for convenience
This is with character added? Can you send the whole script
Okay dope
local function CalculateItemFilth(item)
local bloodAmount = 0;
local dirtAmount = 0;
if instanceof(item, "Clothing") then
if BloodClothingType.getCoveredParts(item:getBloodClothingType()) then
local coveredParts = BloodClothingType.getCoveredParts(item:getBloodClothingType())
for j=0, coveredParts:size()-1 do
local thisPart = coveredParts:get(j)
bloodAmount = bloodAmount + item:getBlood(thisPart)
end
end
if item:getDirtyness() > 0 then
dirtAmount = dirtAmount + item:getDirtyness()
end
else
bloodAmount = bloodAmount + item:getBloodLevel()
end
return bloodAmount + dirtAmount;
end
function ISWashClothing.GetRequiredWater(item)
local filth = CalculateItemFilth(item);
if filth > 10 then
return 10
elseif math.floor(filth/20) < 1 then
return 1
else
return math.floor(filth/20)
end
end
local ISWashClothing_new = ISWashClothing.new;
function ISWashClothing:new(character,...)
local this = ISWashClothing_new(character,self,...);
local filth = CalculateItemfilth(this.item);
this.maxTime = filth *5;
if this.maxTime > 1000 then
this.maxTime = 1000
elseif this.maxTime < 1 then
this.maxTime = 1
end
if this.character:isTimedActionInstant() then
this.maxTime = 1;
end
return this;
end
print("filth")```
I feel that it's necessary to clarify above that all self really refers to in colon syntax is the first argument that was passed to the function; you just don't really have to think abt it if you also use the function call syntax with the colon, which in most cases you would if you're defining a function like that
now theres 1 left
Seems like that should be a number at that point, weird
Unless the line that the error occurred on is wrong, which it has been for me before. Can you check console.txt?
Does lua do the js thing where it automatically converts data types into other types?
Nah, it would've thrown an error if the + was a problem bc numbers only have + defined for other numbers
Pretty sure it doesn't even like it when you try to concatenate a number with a string without converting Nevermind, quickly tested it and that is not the case
Lol
Tbf though concatenation is done with .. so I guess in Lua it makes sense, hard to accidentally do it when you mean to add (but easy to accidentally add when you meant to concatenate)
Oh, you can't add strings together? it has a specific concat symbol?
I kinda like that tbh
You can if you modify the string metatable (so no by default), but I also think having a separate symbol is nice
Yeah I agree
Can you please crop the whole thing
this is from game debug screen
local function CalculateItemFilth(item)
local bloodAmount = 0;
local dirtAmount = 0;
if instanceof(item, "Clothing") then
if BloodClothingType.getCoveredParts(item:getBloodClothingType()) then
local coveredParts = BloodClothingType.getCoveredParts(item:getBloodClothingType())
for j=0, coveredParts:size()-1 do
local thisPart = coveredParts:get(j)
bloodAmount = bloodAmount + item:getBlood(thisPart)
end
end
if item:getDirtyness() > 0 then
dirtAmount = dirtAmount + item:getDirtyness()
end
else
bloodAmount = bloodAmount + item:getBloodLevel()
end
return bloodAmount + dirtAmount;
end
function ISWashClothing.GetRequiredWater(item)
local filth = CalculateItemFilth(item);
if filth > 10 then
return 10
elseif math.floor(filth/20) < 1 then
return 1
else
return math.floor(filth/20)
end
end
local ISWashClothing_new = ISWashClothing.new;
function ISWashClothing:new(character,...)
local this = ISWashClothing_new(self,character,...);
local filth = CalculateItemfilth(this.item);
this.maxTime = filth * 5;
if this.maxTime > 1000 then
this.maxTime = 1000
elseif this.maxTime < 1 then
this.maxTime = 1
end
if this.character:isTimedActionInstant() then
this.maxTime = 1;
end
return this;
end
print("filth")```
this is code
Are you calling ISWashClothing:new somewhere in your own code? I think it's the same issue you were having before, looking at the line referenced by the error
Line 146 of the original one is o.maxTime = ((bloodAmount + dirtAmount) * 15);, so presumably one of bloodAmount or dirtAmount is not a number
Asking if you're calling it somewhere else to check if the argument values are correct
how do I call it somewhere in my code
doesnt lua local ISWashClothing_new = ISWashClothing.new; already call it
Is this the only file in your mod?
That doesn't call it, but it creates a reference to the original function. It's okay if you aren't calling it, just wanted to check
I have another file for wash self but that uses another file ISWashYourself
Is clothes.lua yours?
yes
Can you show that one, or at least part of it? In particular, the area around line 37
this is it
line 37 is
Ohh
The rest of the stack trace is right there, idk how I didn't see that lol. In that case I'm not too sure abt why that's happening
original ISWashingClothing can getBloodLevel fine
i dont think its using anything other than (item)
but i am using (item) but it cant find bloodlevel?
brain small, D stuck in ceiling fan
Since noSoap is a boolean I think the params are somehow shifted by one, but I've no idea why
that reminds me i forgot
if noSoap then
this.maxTime= this.maxTime*{insert multiplier}
does it have something to do with metatable or self._index
btw it keeps outputting an error
unexpected symbol near '10' for the longest time
I wouldn't assume so, the actual parameter values are unmodified at that point
if I modify maxtime
modifying water alone, removing maxtime code = no error
the only thing that has 10 is
the original return 10 water
I'm making an API for make simple UI windows:
https://github.com/MrBounty/PZ-UI_API/blob/main/README.md
Can you try it with the explicit parameter names, so you can see what their values are in the debugger?
how may I do that
Replace the ... with sink, soapList, item, bloodAmount, dirtAmount, noSoap
And in the debugger if you click a line of code I believe it should make a breakpoint (i.e. tells it to open the debugger at that point), have only used it a little bit
Mhm, then in the debugger click that line before testing
What in the world
there is a self,character instead of self.character
Should be self, character; passing in a reference to ISWashClothing
What is the last error ?
seems like bloodAmount or dirtAmount is a nil
Can you add print(type(bloodAmount), ' ', type(dirtAmount))?
Seems like it's an int and a float in the debugger
But lua can add int to float
At least it looks like a float from here, on my phone so I can't see very well
Lua can add an int to a Lua number, and I assume there's automatic conversion with Java floats
I think I know
Try don't put self in ISWashClothing_new
Like that local this = ISWashClothing_new(character, sink, soapList, item, bloodAmount, dirtAmount, noSoap);
Give the full error
wrong error
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.pcallBoolean(KahluaThread.java:1924)
at se.krka.kahlua.integration.LuaCaller.protectedCallBoolean(LuaCaller.java:104)
at zombie.ui.UIElement.onMouseUp(UIElement.java:1228)
at zombie.ui.UIManager.update(UIManager.java:808)
at zombie.GameWindow.logic(GameWindow.java:253)
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
at zombie.GameWindow.frameStep(GameWindow.java:745)
at zombie.GameWindow.run_ez(GameWindow.java:661)
at zombie.GameWindow.mainThread(GameWindow.java:475)
at java.base/java.lang.Thread.run(Unknown Source)```
Do you have the line of code where the error comes from? It is the most important
When you get a moment, this might provide some insight
Just add that line to your override, before the call to the overriden
console.txt, in your project zomboid folder
Sorry, your user* zomboid folder
For me it's C:\Users\Name\Zomboid, should be smth like that
Add the print to the new function, before you call the original one
The console.txt file should be in a Zomboid folder in your user directory
sorry I dont know where exactly do I insert
If you're on windows, it should be accessible as %APPDATA%/../../Zomboid, if you put that in the explorer window
Above the line that begins with local this
Does the error still occur with the variables explicitly declared, btw? Seems like with those values it should be fine
Dunno why it'd be any different from ... though
Did you find console.txt?
Did you run the code that should print? Not seeing anything that looks like it
I see the strange error you mentioned with the 10
what code
this runs?
does this run by itself?
You have to wash something
i did try to wash a cloth
Also, what is the change?
How would I go about spawning military hunvees and modded military vehicles when I zone?
i had a super simple probably cheaty or buggy code
just like copy paste
?
first version of code
already outputs that error
changed it to this code, still errors
Not Sure if that code worked
now that i changed code
I mean not sure if imagination or washing was faster
Yeah looking at the old code that wouldn't have run, so imagination is correct
As for the current version, though: can you run it without the old file & get the output from that print?
i dont have the old files anymore
i dont know why im not getting the print
ill just put it in every function
What files are included right now? clothes.lua and you said one other?
Other functions won't have access to those variables, so that'd just add unnecessary outputs
I don't see anything wrong there but I could be missing it. What happens when you try to wash something with the latest code, though? If the debugger didn't pop up then there wasn't an error (assuming you're still in debug mode)
Can you show what shows up?
That means the old file is still active
Do you have the existing mod enabled in the save?
Okeydoke, good luck w it whenever you get to it
---@param item InventoryItem
local function CalculateItemFilth(item)
local bloodAmount = 0;
local dirtAmount = 0;
if instanceof(item, "Clothing") then
if BloodClothingType.getCoveredParts(item:getBloodClothingType()) then
local coveredParts = BloodClothingType.getCoveredParts(item:getBloodClothingType())
for j=0, coveredParts:size()-1 do
local thisPart = coveredParts:get(j)
bloodAmount = bloodAmount + item:getBlood(thisPart)
end
end
if item:getDirtyness() > 0 then
dirtAmount = dirtAmount + item:getDirtyness()
end
else
bloodAmount = bloodAmount + item:getBloodLevel()
end
return bloodAmount + dirtAmount
end
local ISWashClothing_GetRequiredWater = ISWashClothing.GetRequiredWater;
function ISWashClothing.GetRequiredWater(item)
local vanillaWaterAmount = ISWashClothing_GetRequiredWater(item);
local filth = CalculateItemFilth(item);
if filth > vanillaWaterAmount then
return vanillaWaterAmount
else
return filth
end
end
local ISWashClothing_new = ISWashClothing.new;
function ISWashClothing:new(...)
local this = ISWashClothing_new(self, ...);
local filth = CalculateItemFilth(this.item);
this.maxTime = filth * 50;
if this.maxTime > 1000 then
this.maxTime = 1000
elseif this.maxTime < 100 then
this.maxTime = 100
end
print("Washing Information")
print("filth: " .. filth)
print("maxTime: " .. this.maxTime)
if this.character:isTimedActionInstant() then
this.maxTime = 1
end
return this;
end
Here a working code, there was a typo in your function name.
I shoulda worn glasses
Thank you so much 🙏
I will work on it later, am taking a break rn
https://steamcommunity.com/sharedfiles/filedetails/?id=2356682893 @thin hornet thanks for the help again, just published the update to the mod with the few lines you helped on!
So I spent 5 hours troubleshooting a mod I had worked on, found out it was just a single apostrophe out of 8000 lines of code that broke it
ffs
The joy of coding 😂
Did the same with one variable somewhere that was fontzoom instead of fontZoom
i dont get
cannot use '...' outside vararg function
researching says to "wrap the varargs in a table outside of the nested closure:"
code 1 working
code2 not
confused now
okay
try tostring for both.
line 18 unexpected symbol near "."
ISWashYourself:GetRequiredWater?
Or i could be wrong, not sure.
it is
I am currently trying to execute a lua function I've written 50 ticks after a certain custom event occured. My current way of doing this can be found in the attached screenshot and this works fine. Problem is that the function myCustomFunction is called on every tick which is in fact not necessary (although relevant code is only executed 50 ticks after the event). I am afraid that this might not be an optimal usage of the OnTick event from a performance point of view. Any ideas how this could be done better? Or would you consider my approach as a somewhat acceptable way?
The myCustomFunction does on every tick at least two checks. Not much but I am not sure about how this might affect game performance on the long run...
--add monies
if (sellValue > 0) then
for i=1, sellValue do
--print("adding money #" .. i);
local moneyItem = instanceItem("Base.Money");
oc:AddItem(moneyItem)
oc:addItemOnServer(moneyItem)
end
end
to create multiple monies, should I be using a loop like this? or can i create one money item instance and then edit quantity
also how do i paste a code block with formatting wth
ok so i'm trying to make a edited version of VFE (was given permission too) and for SOME reason, when i try to launch a MP server with it it makes the server not launch right, instead of giving me an error it just says "normal termination". the thing that's puzzling me is i essentially just took the entire mod folder for the VFE mod and made it into one of my own so i could edit it properly. so it really shouldn't have issues here. as the VFE mod itself works fine anybody got any ideas?
cause i'm completely stumped
the only thing i'm changing is like 2 lines of script for 2 guns so i really don't understand how it's causing a server to not permit a launch
Multiple items: player:getInventory():AddItems("Base.ButterKnife", 2)
Code blocks:
---@param character IHumanVisual
local ISWashYourself_GetRequiredWater = ISWashYourself.GetRequiredWater;
function ISWashYourself.GetRequiredWater(character)
local charafilth = ISWashYourself_GetRequiredWater(character);
local units = 0;
local vis = charafilth:getHumanVisual()
for i=1, BloodBodyPartType.MAX:index() do
local partt = BloodBodyPartType.FromIndex(i-1)
if vis:getBlood(partt) + vis:getDirt(partt) > 0 then
units = units + 1
end
end
return units
end
local ISWashYourself_new = ISWashYourself.new;
function ISWashYourself:new(...)
local reqwater = ISWashYourself_GetRequiredWater(character);
local washing = ISWashYourself_new(self, ...);
local waterUnits = math.min(reqwater, sink:getWaterAmount())
washing.maxTime = waterUnits * 0.1;
if washing.character:isTimedActionInstant() then
washing.maxTime = 1;
end
print("Bathing information")
print("Washing time: " .. washing.maxTime)
print("selfwater: " .. ISWashYourself.GetRequiredWater(character))
return washing;
end
can somebody point out what's wrong
completely lost
i thought i could do it
just out of curiosity, what is the purpose of "addItemOnServer"?
Dunno I adopted this mod off someone else, haven't gotten to MP testing not sure if thats necessary or not
ok... not suggesting it might be unnecessary... just asking to learn 😉
whats the issue with it?
doesnt work
something wrong with
getHumanVisual()
attempted index: getBlood of non-table: null
You could add and remove the event when you need it, i.e. add the event listener whenever the custom event occurs, then remove it when it hits the 50 tick trigger. This would make it only run for those 50 ticks
Depending on how often the custom event runs, that could offer some savings
Great! Thanks! Sounds like the feature I am looking for! How do I access the "event listener"? What chunk of code is needed?
By event listener I mean your function. You can remove it by passing the same function to Events.OnTick.Remove
Since you'll want to do it within the same function, you'll need to change the declaration to
local myCustomFunction
myCustomFunction = function(currentTick)
-- code
end
The forward reference so that you can access the function within its own block
ERROR: General, 1644574691060> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: attempted index: getHumanVisual of non-table: null at KahluaThread.tableget line:1689.```
Can you include the stack trace of the error?
java.lang.RuntimeException: attempted index: getHumanVisual of non-table: null
at se.krka.kahlua.vm.KahluaThread.tableget(KahluaThread.java:1689)
at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:641)
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.pcallvoid(KahluaThread.java:1812)
at se.krka.kahlua.integration.LuaCaller.pcallvoid(LuaCaller.java:66)
at se.krka.kahlua.integration.LuaCaller.protectedCallVoid(LuaCaller.java:139)
at zombie.Lua.Event.trigger(Event.java:64)
at zombie.Lua.LuaEventManager.triggerEvent(LuaEventManager.java:169)
at zombie.ui.UIManager.update(UIManager.java:930)
at zombie.GameWindow.logic(GameWindow.java:253)
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
at zombie.GameWindow.frameStep(GameWindow.java:745)
at zombie.GameWindow.run_ez(GameWindow.java:661)
at zombie.GameWindow.mainThread(GameWindow.java:475)
at java.base/java.lang.Thread.run(Unknown Source)```
@small topaz I was adding to this, but my phone died: I'm doing something similar but with real-time, and I'm unsure if it matters for your use, but: I'd recommend removing the listener before executing your code, so if anything goes wrong the event listener has already been cleaned up
I was jast abt to ask for the Lua stack trace
So that means character is nil in that first function
yea
Charafilth* I mean
no clue why its getting nil
i tried setting a local to see if it would change things
or fix it, it didnt
Seems like charafilth should be an integer at that point
That error makes more sense
You're trying to call getHumanVisual on the return value of the original GetRequiredWater, which is an integer
original is
character:getHumanVisual
I'm assuming you meant character? If your intention is to override that function completely, maybe you don't need to call the original at all
so trying to character table from getHumanVisual
It's not the same as the new function in that a table is not returned, it'll just be a number, so if you change the calculation as long as you return a number it should function
You're using it with charafilth, which is an integer
character contains HumanVisual
and HumanVisual contains BloodBodyPartType and
Blood and Dirt
ahhh.... so, roughly, that means that i can simply put commands like Event.MyEvent.Add/Remove within the code of a function instead of using them "globally"...?
that was a test, I reverted them back for simplicity purposes. unnecessary code
Yep, those are just functions so you can add or remove them wherever
local ISWashYourself_GetRequiredWater = ISWashYourself.GetRequiredWater;
function ISWashYourself.GetRequiredWater(character)
local units = 0;
local vis = character:getHumanVisual()
for i=1, BloodBodyPartType.MAX:index() do
local part = BloodBodyPartType.FromIndex(i-1)
if vis:getBlood(part) + vis:getDirt(part) > 0 then
units = units + 1
end
end
return units
end```
What is the code that produced this error?
many thanks! think i got it then. 🙂
both codes same error
One of them is different though ?
because getHumanVisual() is the issue
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.pcallvoid(KahluaThread.java:1812)
at se.krka.kahlua.integration.LuaCaller.pcallvoid(LuaCaller.java:66)
at se.krka.kahlua.integration.LuaCaller.protectedCallVoid(LuaCaller.java:139)
at zombie.Lua.Event.trigger(Event.java:64)
at zombie.Lua.LuaEventManager.triggerEvent(LuaEventManager.java:169)
at zombie.ui.UIManager.update(UIManager.java:930)
at zombie.GameWindow.logic(GameWindow.java:253)
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
at zombie.GameWindow.frameStep(GameWindow.java:745)
at zombie.GameWindow.run_ez(GameWindow.java:661)
at zombie.GameWindow.mainThread(GameWindow.java:475)
at java.base/java.lang.Thread.run(Unknown Source)```
am confused now
If you run this code, what error is produced, if any? It seems like it matches the original code so I'm unsure why there'd be an issue
let me restart game for a fresh console.txt
if the error is caused by this function, then my first guess is simply that vanilla calls this functions with a nil value (i.e. character = nil). or some other value for character where getHumanVisual() cannot be applied to...
I assume world static model refers to the model when placed. Does anyone know what the static model is for?
100% same code from ISWashYourself.lua
except the local override
local ISWashYourself_GetRequiredWater = ISWashYourself.GetRequiredWater;
I just want to modify units
self.lua line 17 is the code you showed above?
this one? line 1
line 17 is
Oh, character is not defined
what does that mean
It should be the first parameter in new
i thought character was a global
Nah, check out the original code
function ISWashYourself:new(character, ...) should do it
?
May be best to avoid them until you understand what they're doing (which is the case for many concepts!)
I can try to offer an explanation of what varargs are for, if you'd like
i guess better is even function ISWashYourself:new(character, sink,..) since sink is also used in your code
Oh yeah, good call
Another thing to note that I meant to note earlier: your current code won't call your overwrite* of GetRequiredWater
Which I assume is the intention
yeah I want to call my override
You're calling the original function which you've saved to the variable; if you want to use yours you should call it as usual, with ISWashYourself.GetRequiredWater(character)
right i should use ISWashYourself.getrequiredwater
Yep
yeah but i think the issue still is
getHumanVisual
since that errors, then everything else errors? unsure
What's the current code?
The full error gives you the issue; the entire thing says you're attempting to index on "non-table: null", which means you're trying to index into nil, which is not a table (which means character is the problem)
Is it still running the old code? Did you reload it from the debugger or restart? According to the stack trace it's still calling the original function
Which implies that it's not running the current code
I'm fairly certain that would be fine, but I'm not 100% sure
If it was reloaded from the debugger that should be fine
Can you try running it fresh, either with a restarted game or reloaded from the debugger?
I think so yeah, the full error is in console.txt though
yea it also froze until i clicked something.
it also just now updated in console.txt
java.lang.RuntimeException: Object tried to call nil in GetRequiredWater
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.pcallBoolean(KahluaThread.java:1924)
at se.krka.kahlua.integration.LuaCaller.protectedCallBoolean(LuaCaller.java:104)
at zombie.ui.UIElement.onMouseUp(UIElement.java:1228)
at zombie.ui.UIManager.update(UIManager.java:808)
at zombie.GameWindow.logic(GameWindow.java:253)
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
at zombie.GameWindow.frameStep(GameWindow.java:745)
at zombie.GameWindow.run_ez(GameWindow.java:661)
at zombie.GameWindow.mainThread(GameWindow.java:475)
at java.base/java.lang.Thread.run(Unknown Source)```
Oh, on line 18 you're not passing in character and sink to the original one
So essentially soapList is being passed as the value of character
I think removing the varargs so it doesn't cause further confusion would be good 😅
TAYZEHH's House Rules
This is a Mod pack containing TaYzehh's mod list.
MOSTLY QUALITY OF LIFE MODS, SOME MAPS, WEAPONS AND ARMOUR AND VEHICLES.
Painstakingly perfected to have the best effect and immersion in game whilst still being fun and reliable.
❤️
For this mod pack to work properly, WARNING! Disable Paw Low Loot Fantasy Pack!!!!!
right i still need soaplist
if you're not too busy
would you have a go
---@param character IHumanVisual
local ISWashYourself_GetRequiredWater = ISWashYourself.GetRequiredWater;
function ISWashYourself.GetRequiredWater(character)
local units = 0;
local vision = character:getHumanVisual()
for i=1, BloodBodyPartType.MAX:index() do
local part = BloodBodyPartType.FromIndex(i-1)
if vision:getBlood(part) + vision:getDirt(part) > 0 then
units = units + 1
end
end
return units
end
local ISWashYourself_new = ISWashYourself.new;
function ISWashYourself:new(character, sink, ...)
local reqwater = ISWashYourself.GetRequiredWater(character);
local washing = ISWashYourself_new(self, character, sink, soapList);
local waterUnits = math.min(reqwater, sink:getWaterAmount())
washing.maxTime = waterUnits * 0.1;
if washing.character:isTimedActionInstant() then
washing.maxTime = 1;
end
print("Bathing information")
print("Washing time: " .. washing.maxTime)
print("selfwater: " .. ISWashYourself.GetRequiredWater(character))
return washing;
end
if i load up this
character shows up in locals fine
and when i return units
its 17
should work
but why
probably some index thing
i dont get indexing
sadly I have only made half of mod
im tired
you cannot change GetRequiredWater params
that function is used in many other vanilla scripts
and they all pass item as first param
not much you can do about it
even specific to
ISWashYourself?
Want to change amount of water taking a bath does
cant do it?
ah sorry didnt realise it was ISWashYourself
---@param character IHumanVisual
local ISWashYourself_GetRequiredWater = ISWashYourself.GetRequiredWater;
function ISWashYourself.GetRequiredWater(character)
local units = 0;
local vision = character:getHumanVisual()
for i=1, BloodBodyPartType.MAX:index() do
local part = BloodBodyPartType.FromIndex(i-1)
if vision:getBlood(part) + vision:getDirt(part) > 0 then
units = units + 1
end
end
return units
end
local ISWashYourself_new = ISWashYourself.new;
function ISWashYourself:new(character, sink, ...)
local reqwater = ISWashYourself.GetRequiredWater(character);
local washing = ISWashYourself_new(self, character, sink, soapList);
local waterUnits = math.min(reqwater, sink:getWaterAmount())
washing.maxTime = waterUnits * 0.1;
if washing.character:isTimedActionInstant() then
washing.maxTime = 1;
end
print("Bathing information")
print("Washing time: " .. washing.maxTime)
print("selfwater: " .. ISWashYourself.GetRequiredWater(character))
return washing;
end```
le code
the error
the irony. making mod to save time
takes time to make mod
havent played yet
yep
havent played in weeks now
by the way dont pass the param again
local ISWashYourself_new = ISWashYourself.new;
function ISWashYourself:new(...)
local washing = ISWashYourself_new(self, ...);
local reqwater = ISWashYourself.GetRequiredWater(washing.character);
local waterUnits = math.min(reqwater, washing.sink:getWaterAmount())
washing.maxTime = waterUnits * 0.1;
if washing.character:isTimedActionInstant() then
washing.maxTime = 1;
end
print("Bathing information")
print("Washing time: " .. washing.maxTime)
print("selfwater: " .. reqwater)
return washing;
end
you already have access to those variable when running the original one
for the error i have no idea where it come from
when posting errors always post the callstack
or we cannot see enough info
roger
ERROR: General , 1644588346648> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: attempted index: 1.0 of non-table: null at KahluaThread.tableget line:1689.
ERROR: General , 1644588346649> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: attempted index: 1.0 of non-table: null
at se.krka.kahlua.vm.KahluaThread.tableget(KahluaThread.java:1689)
at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:492)
at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:163)
at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:1243)
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.pcallBoolean(KahluaThread.java:1924)
at se.krka.kahlua.integration.LuaCaller.protectedCallBoolean(LuaCaller.java:104)
at zombie.ui.UIElement.onMouseUp(UIElement.java:1228)
at zombie.ui.UIManager.update(UIManager.java:808)
at zombie.GameWindow.logic(GameWindow.java:253)
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
at zombie.GameWindow.frameStep(GameWindow.java:745)
at zombie.GameWindow.run_ez(GameWindow.java:661)
at zombie.GameWindow.mainThread(GameWindow.java:475)
at java.base/java.lang.Thread.run(Unknown Source)```
callstack
local ISWashYourself_GetRequiredWater = ISWashYourself.GetRequiredWater;
function ISWashYourself.GetRequiredWater(character)
local units = 0;
local vision = character:getHumanVisual()
for i=1, BloodBodyPartType.MAX:index() do
local part = BloodBodyPartType.FromIndex(i-1)
if vision:getBlood(part) + vision:getDirt(part) > 0 then
units = units + 1
end
end
return units
end```
only this has indexing
... i think
yeah
part is nil
nvm
changed code to this same error
omg
wat
i removed all the print()
and no error
yea it works
thank you so much guys @frank elbow and @thin hornet. couldn't have done it without you
I now present my 1st mod
mod options is a bigger mountain that I do not have to corss 😅
other mod. not optimized code (probably), but works
could have been cool mod
sadly not work
finally i can play
I get that rly weird error:
ERROR: General , 1644592682027> ExceptionLogger.logException> Exception thrown org.sqlite.SQLiteException: [SQLITE_BUSY] The database file is locked (database is locked) at DB.newSQLException line:941.
ERROR: General , 1644592682028> DebugLogStream.printException> Stack trace:
org.sqlite.SQLiteException: [SQLITE_BUSY] The database file is locked (database is locked)
at org.sqlite.core.DB.newSQLException(DB.java:941)
at org.sqlite.core.DB.newSQLException(DB.java:953)
at org.sqlite.core.DB.throwex(DB.java:918)
at org.sqlite.core.DB.exec(DB.java:178)
at org.sqlite.SQLiteConnection.commit(SQLiteConnection.java:404)
at zombie.vehicles.VehiclesDB2$SQLStore.updateDB(VehiclesDB2.java:313)
at zombie.vehicles.VehiclesDB2$SQLStore.updateVehicle(VehiclesDB2.java:249)
at zombie.vehicles.VehiclesDB2$WorldStreamerThread.unloadChunk(VehiclesDB2.java:637)
at zombie.vehicles.VehiclesDB2.unloadChunk(VehiclesDB2.java:946)
at zombie.iso.IsoChunk.Save(IsoChunk.java:3724)
at zombie.iso.IsoChunk.Save(IsoChunk.java:3551)
at zombie.iso.ChunkSaveWorker.Update(ChunkSaveWorker.java:71)
at zombie.iso.WorldStreamer.threadLoop(WorldStreamer.java:494)
at zombie.iso.WorldStreamer.lambda$create$0(WorldStreamer.java:567)
at java.base/java.lang.Thread.run(Unknown Source)
LOG : General , 1644592686293> EXITDEBUG: ToggleEscapeMenu 1
LOG : General , 1644592686294> EXITDEBUG: ToggleEscapeMenu 3
I do stuff with the game UI, but sqlite? This is for SQL databases.
I don't see what this has to do with my thing
a lot of things
Lets me think what was the last thing I added
Maybe it's just that I forgot one line somewhere when I tried to add dragging item
Nop, not that
Mmmmm, do you have any idea of a function that does this?
Ok I get where it's come from
Thx @jagged fulcrum
Cant text in #old_techsupport so im askin here. If i change the zombie settings on my server before a restart will the changes take effect
Like zombie start pop and multiplier really
So ur saying itll only change for unexplored areas?
Would i have to soft reset?
Anyone added custom perks and professions and realized that when dieing and clicking on new character in MP the new profession is not available? But the custom trait are still available.
Need to logoff and login again
I've searched the workshop but can't find anything, does anyone know of a mod where you can claim Spawn Buildings.
I saw a video on good base locations and it mentioned a bar, my friend spawned in that bar so i suspect we won't be able to make it a safehouse. Which is kinda weird.
Are all spawn location buildings predetermined or does it vary from server to server?
Does anyone out there use CommunityAPI ?
No its not released yet
ok but can i do that after someone has spawned in, lets say, that bar?
oki
so spawnpoints are server specific, got it.
should be fine if you've replaced BaseGameCharacterDetails.DoProfessions, professions get reset and this function is called again. Thats what i do with the profession framework its never been a issue
oh man ty
welp. Update on my issue.... Apparently sendObjectChange won't work for IsoZombie, instead sendZombie seems more reasonable... Only issue? Everytime I try to use sendZombie, it blasts about "trying to call nil"
that's usually when you're indexing a table and the field doesn't exist
e.g. myTable.doFunc() and doFunc doesn't actually exist in it, possibly because you typo'd it
you can try to just append a new "doMyProfessions" creating your new professions to the vanilla doProfession function to make your professions available again
local GetZed = GetZedList:get(i);
GetZed:sendZombie();
did you client the "Error Log" button and examine the stack trace?
the debug log?
that'll tell you which exact line caused the error
yes, it points to the line with sendZombie
no, when you get an error, it brings up the debug window (F11), there's a button at the top to view the error log
mhm
how are you iterating it?
iterating sendZombie???
like this
no, getZombieList
oh
it's a list and I see you have a variable called i
I don't see any function in IsoZombie called sendZombie
well, I don't know why you expected that to work
public static void sendZombie(IsoZombie zombie) It's in GameServer, my bad... How does one call "gameServer"?
you're writing this as a server side mod yeah? what are you trying to do
I've been metaphorically slamming my head against a rock for about a week now to get my changes to zombie outfits to save server side
basically
is your lua code for the outfits in lua/server or lua/client ?
I have the mod scan for zombies wearing outfitA, right? It replaces them with a persistent outfitB, but it won't save attachedItems on SP, and MP just refuses to save...
It's in shared
ah OK
doesn't work in server either, last time I checked...
what doesn't work?
saving the outfit on MP
AFAIK you shouldn't need to do anything special to make the items save once you've mutated them, providing that mutation is happening on the server side
if you're just doing it client side, then the server never sees it and, consequently, there's nothing for it to save
well, it should just run, unless you've wrapped the code in some isClient check that prevents the server doing it
there's no isClient check at all
I believe you should be able to run your lua only on the server as it'll sync it to clients, but give it a shot
so chuck it into the server folder?
yeah
it'd be easier to investigate if you chucked the code on GitHub or a pastebin or something
sure
Hello all. Im gonna feel dumb asking this but figured i would give it a shot vs being dumb.
Can i use a UI mod for myself on a multiplayer server? Or would it not work because server doesnt have it?
Wow. :/
all lua gets checksummed as it's loaded as well
now, obviously it's not impossible, if you want to go wild with patching the Java classes, have at it
Shame It doesn't function like some other games where client to servers can have some differences. I.e UI/Graphics etc.
Here you go
https://pastebin.com/uRzq27wv
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
since everything executes in a single lua state, that's impossible to do safely
maybe if they refactor each mod to run in its own little sandbox, that might become an option
Guess I got to try harder to sell the mod to the Admins. They dont want "ui changes that can break things" even tho the mod makes things easier to use
and by safely I mean "without making it trivial to cheat"
@fiery pecan yeah, you can chuck that in the server folder. You can still test it on Solo because there's still a kind of server running
that's just it. It saves fine on solo
just tested it in the server folder, on a server
no saving
have you verified that your server instance is definitely loading the mod?
well, that could just be your client doing it
just doesn't persist beyond a reload
I'd move it to server and see if you can still see it on the client
I already moved it to the server folder?
ah, I see, so it's now just in the server folder, but still not saving?
yes
hm, where in your code is the setAttachedItem call?
well, you said that the outfits save but attached items don't, not?
but I don't see anywhere in the code where you're setting any attached items
I'm trying to tackle the outfits themselves first
i.e. Zombie spawns with a hat and glasses. Loses hat and glasses, and has a completely different skin color on reload
ok, so attachments aren't a factor
for now, right
hm, I don't see anything special in the java code for persistent outfits
it's all on WornItem
uhhhhh, one thing
you're calling Reset() straight after you apply the outfit
from what I see here that's basically undoing what you just did
remove the Reset calls.
oh wait, that's not in your code
ah sorry, yes it is, indirectly through reloadOutfit
what happens if you remove reloadOutfit ?
let's find out
iirc it doesn't update the changes to the client. But I'm double checking right now.
is there any kind of a quest api?
no, but there's a GUI, you can write one
yeah, it'll only update about half the changes (i.e. shirt only)
a gui you say?
ok, let's try this as a shitty hack: right after reloadOutfit, immediately call dressInPersistentOutfit again
@faint jewel yeah, as in, the windows you see in the game
inventory, character health, etc
i... but... wow.
everything you need to do can be done in lua, take a look at the ISUI/<stuff> files in the game sources
if you were hoping for some simple addQuest style function, no, that doesn't exist
that is what an API is.
and that's why I said "no"
the materials and tools for building the house are there, but it hasn't been prebuilt for you
"there is a gui" = there is an ability to write code which utilizes the GUI. I think that is where the confusion happened (that is, I think it was misunderstood as "there exists a quest gui")
I mean, I literally said "no, but"
🤷🏾♂️
if it wasn't clear, I was stating that the primitives exist for you to build it
agreed. "there is a gui" tells me there is part of a system i can use. "you can see menus ingame" is nowhere near that.
Just seemed like a misunderstanding, thought I'd pop in to clear that up to try to avoid any argument
👍
I'm not saying I agree w that interpretation, just miscommunication. Happens
aye
did not save
bugger, and the mod code is still running server-side only right?
no lingering copies in other folders right?
right
also, why are you writing it so that it replaces what they're wearing? why not make it so they spawn with those clothes in the first place?
well
mainly for the random zone stories, like police blockades
I'm open to an alternative that removes said zombies, and replaces them with mine?
can anyone aid me with brita's?
@fiery pecan you mean the randomised vehicle stories?
it seems to be working but its only spawning ammo
Quick question - does getModData get synced in multiplayer?
right, another attempt at a hack - after the second call to setpersistentoutfit, add DoCorpseInventory
as in GetZed:DoCorpseInventory()
looks to me like the Java code doesn't bother to update the inventory of the zombie without that getting called so it doesn't persist
I see
also, you might find it cleaner to structure your code via a table - e.g.
end }```
Then you can just do `lookup[GetZedOutfitName](GetZed)`
to handle the case where the outfit isn't one you care about, just set a metatable on it so that __index returns a function that does nothing
eliminates your tree of if/else statements
hmmm
but first, let's see what happens with this DoCorpseInventory call
yeah
question, there was mod to allow you to auto-generate a list of items in a container, what mod was that? i can't find it
it makes a list of stuff in a piece of paper, or a notepad, or something like that. at least, you need to have one of those in order to generate it - i only saw it in passing before my power went out and i lost the tab, so i can't remember specifics
oh i guess i should have asked in #mod_support (my apologies)
yeah, no dice. How would I try the remove and replace method???
no dice as in it didn't work or as in, you got some sort of error
didn't work
can you pastebin the code as it currently stands
sure
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
oh, no, DoCorpseInventory() needs to be the very last thing
it is?
GetZed:dressInPersistentOutfit("PoliceRosewood");
--Refresh Zombie For Visual Purposes
GetZed:reloadOutfit();
GetZed:dressInPersistentOutfit("PoliceRosewood");
GetZed:DoCorpseInventory();
--Save The Zombie
-- GetZedVisual:setOutfit("PoliceRosewood");
-- GetZed:setAttachedItems(GetZedItems);```
oh they're commented out
yeah
sorry, you should have chosen Lua syntax highlighting 😛
yeah, Pastebin can do that
ah, one thing, is this still on the server only?
yeah
move it back to shared and see what happens
so, when you say they don't save - the zombie itself saves right?
but it loads back in with random attire?
yeah. The outfit and skin color/hair are randomized
and you're testing this by having your player near them, quitting and then reloading it?
with the random vehicle story option?
with the horde manager
ah, hmm, that may not be a valid test
go to a road and use the random vehicle story menu
I'm not entirely sure you'll be able to get any zombie to persist
I suspect it needs to be initialised in a certain way, which is how it does them for stories
I see
welp
there's the issue I keep having with spawning vehicle zones on servers
they disappear on reload
are you admin?
as in, you see the "Admin" menu button on the left hand side
I never saw that shit automatically give you admin
always had to grant it in config separately
if you don't see the "Admin" button and white text, you don't have it
I get that now. How do I get it?
no idea - I just run the server separately and do it from the console window
k
I guess you could try running /help from the chat box and see if it lets you do stuff
k
Evening all, I am having trouble transmitting mod data to client from server side, I have this following code ⤵️
ModData.getOrCreate('myModMD')[playerObj:getUsername()] = false
ModData.transmit('myModMD')
But the clients does not receive the ModData (I check it with Debug menu > GlobalModData & prints, the data does not get there)
I even tried to add
ModData.request('myModMD')
local modData = ModData.get('myModMD')
on the client and it does not get retrieved...
Any idea of what I may be doing wrong here?
Ps: I works in singleplayer, but never in MP
When I click on mods in the main menu and select my mod the image for it doesn’t show up - it’s just black. How do I fix this?
you should save a .png file in the same folder as the mod.info file and then also have a line in the mod.info that references it
if I recall, it's poster=blah.png
look at any decent workshop mod's mod.info to see how it's done
it's separate from the image used by Steam Workshop
Thanks @calm depot!
@winged lotus are you sure that the .request call is actually executing?
chuck in a print line before and after it and see if they appear in the console
anyone has the mod that lets you equip more weapons on your back , i think its a belt mod but idk which one
you need to receive it on the client
local function OnReceiveGlobalModData(key, modData)
--do something
end
Events.OnReceiveGlobalModData.Add(OnReceiveGlobalModData)
So this would mean if I want it to sync I have to do this on the client ⤵️
local function OnReceiveGlobalModData(key, modData)
ModData.getOrCreate('myModMD') = modData(key)
end
Events.OnReceiveGlobalModData.Add(OnReceiveGlobalModData)
can anyone think of a mod where you press a button and a ui comes up?
i wanna look at some stuff.
local function OnReceiveGlobalModData(key, modData)
if key == "myModMD" then
ModData.add(key, modData)
end
end
Events.OnReceiveGlobalModData.Add(OnReceiveGlobalModData)
anyone found the part of the code that open doors automatically in MP? Been searching trough lua and java and for now haven't found where that "Desync?" come from
Yeah I tried that but it triggers a unexpected symbol near '=' at the line doing ModData.getOrCreate('myModMD') = modData on game load
Do
is there a mod to remove sleep from solo, like MP?
ModData.add(key, modData)
Ah! Right 👍
That's not how it is done, ModData.getOrCreate(key) just creates the key, it is not a table. use ModData.add(key, moData) after that
does anyone know if getModData syncs with multiplayer?
I'm having trouble with one of those claim safehouse mods, does anyone know if i need to restart a world after having it installed?
true actions comes to mind, but i think that hooks into the emote menu
I wanna do a "job board" of sorts.
Thanks @drifting stump and @nimble spoke it worked! ❤️ 🙏
Anybody knows how long it takes for a mod pack to be uploaded?
Like a steam pack uploaded in game
@calm depot guess who did a dumb and forgot they copied their files from the workshop folder to the mods folder?
Hello. Is there any good tutorials / resources that talk about Client/Server logic ?
Is it possible to add more than 6 seats to a vehicle?
Usually just a few seconds for me. I guess it depends on your internet upload speed.
Hello people. I'm trying to make a mod that overrides the zombies distribution so that there is only one available zombie. Every zombie that spawns will look exactly the same, clothing, hairs, etc. I did add a MY_HairOutfitDefinitions and MY_ZombieZoneDefinitions to try to empty the original "lua/shared/NPCs/NPCs/ZombiesZoneDefinition" and then table.insert my own zombie into. I did a clothing.xml to create its outfit too. But there seems to be something missing since i dont see any zombies in game looking like my custom zombie. I also tried simply having a ZombieZoneDefinition.lua which has the same name as the Zomboid one so it would replace it, but it didn't change the spawn neither. Hope i can fin help. Thx !
my goals are beyond your understanding
https://steamcommunity.com/sharedfiles/filedetails/?id=2744139061
How do you guys test multiplayer stuff when modding?
are there ways to simulate a 2nd client or do you just test out with another pc?
Has anyone had any luck getting Brita's weapons to work on MP?
@stiff venture why didnt you just make a collection so that your pack doesnt become useless once any of those mods update?
how would i do that?>
see link i sent you
@stiff venture Also you have one of my mod in there for which I strictly forbid the use in a modpack
ya that too... @stiff venture you probably didnt ask every person that has a mod in you pack
@stiff venture might want to read this https://theindiestone.com/forums/index.php?/topic/2530-mod-permissions/&tab=comments#comment-36478
Ask for permissionThis mod can only be added to and extended with the express permission from the original creator. Having received permission, credit must be given to the original creator, both within the files of the mod and wherever the mod roams online. If no permission is received you may no...
Not trying to make you feel bad or anything, but you might just have covered yourself with barbeque sauce and thrown yourself into the lions den here.
You need to get permission for using other's people's mod in your steam workshop uploads, or other such usages, aside from situations where permissions is already granted on the workshop page and such.
A lot of modders, including a fair amount of people who's mods you have are in that modpack, post here. And you're probably going to receive a criticism from them, and others, for not getting permissions.
As well, your modpack may well get removed from steam if people make complaints about you using their property without your permission.
oopppps my bad
Well, at least I'm offended that you didn't use any of my mods, instead of being offended that you used any of my mods without permission 😄
kinda just deleted the whole thing
would it be possible to make a *Quantum Crate IE an item that shared the same inventory with other versions of it placed everywhere?
Usually people will make a mod pack for themself and not for the public. Imagine, you don't want to be responsible to updating all the mods and keeping your mod pack up to date and releasing update randomly that prevent server user to login.
Well done, people make mistakes, and that's probably the right move to make 🙂
MY BAD GUYS D:
I swear you would go nuts if you needed to maintain that amount of mods xD
the more subs the nuttier
Finaly finish my mod ! I can play now 😂
https://steamcommunity.com/sharedfiles/filedetails/?id=2733680483
so is it acceptable to put mods into a collection instead?#
I wont be promoting it or anything just figured that i need a modded save for my mates
Yeah ofc, you use the mod from the creator workshop so np
Ok, just wanted to be sure, I understand now that collections are linked to their profile. damn guy cheers for the heads up
copyright n that smh
saved my skin haha
It's not copyright issue, you gonna get nothing. It's just that modder do for the community so the last to do is give them the credit of they work
Imagine you have 50 mods in the pack, now imagine you get 15,000 subscriber activly using the pack. Now 20 mods updates. You have to find out what mods updated. you have the update your pack. Now all server using the pack have to restart. 15,000 user have to unsub the pack to allow to join back. Now you get bunch of conflict between mods and cant fix em. Just a pain in the ass for you to take on a big pack like that. But if you make the pack unlisted and use it for yourself. I dont see no problem is it for your personal use. Other than that i know some modder want to be asked for permission so thats an other thing to keep in mind.
I messed up pretty bad, this is supposed to be a mod pack for me n my mates however not looking for workshop fame or whatever
I've turned it into a collection
Nah i don't say you messed up, its not even a problem. As long as its not fully public it shouldnt matter.
yeah man 🙂
I'm making a mod for this as we speak 🙂 time to get that resident evil vibes/supernatural up in here
lemme know how it goes I'm rootin for ya
Hey Azakaela its been a min
uwu
whats up
I shutdown the Fallout 2085 mod project(still have the files if anyone wants) and refocused on my own core mod https://steamcommunity.com/sharedfiles/filedetails/?id=2750649304 so that I learn more and just got really busy at work. what about you any new mods releases?
did you make any leveraging that bunker trick we discovered for vaults?
I noticed someone release the elevator mod as an extension of that tech
Yeah 😄
I mean I could but its a lot of work to build subterranean areas
I used it for Echo Station
If i wanted say a vehicle to roll a little bit before coming to a stop. Which line of code would i be looking at for the vehicle script. rollInfluence, or wheelFriction. Or both?
Is there a way to run a function every 10 minutes on the server side rather then the player
wish i could help ya man. This stuff is difficult. lol.
I want to say it's going to be "stoppingMovementForce"
I think if you put the .lua file in the server folder, it's gonna be call by the server
And next just use the every10minutes event
@fiery pecan LOL, oh jesus man, that sucks. So what ended up being the correct code? What you originally had?
I am trying to upload to the workshop and it is saying that there is not a preview.png file even though there is one. How do I fix this?
not sure if it would make a difference. But here is the dimension of a poster for a mod ive been messing around with from the steamwork shop. the dimensions are 512x512 32depth. maybe try changing the dimensions of the image to see if that would work. But im not 100% sure.
@modders make jumper cables that let me jump start vehicles from other vehicles and i'll give you ten real dollars
also valid is allowing a method to recharge car batteries using other methods than running the engine
wall outlets, generator, a generator bike, whatever
You know about the battery charger item that's vanilla? It can be used to charge vehicle batteries if it's placed in a square with electricity from a generator.
Looks cool
Anyone knows if removing item from distributions changed on the stable branch? I have code that used to work before IWBUMS went stable and now it doesnt and I'm stumped as to why. The code looks like this:
local function postDistributionMerge()
RemoveItemFromDistribution(SuburbsDistributions, "CustomModule.Itemname");
RemoveItemFromDistribution(ProceduralDistributions, "CustomModule.Itemname");
print("ZDebug: Removed CustomModule.Itemname")
end
Events.OnPostDistributionMerge.Add(postDistributionMerge)
The print message is printed but the item still shows up in shelves. Tried disabling every other mod, problem still stands. The code is located in lua/server/Items
Alternatively, is there any way to remove an item completely from the game, not just loot tables? If I remove lets say a skill book from the loot tables it still shows up under the character's tab potential learning material that you can find.
And on an unrelated note, code to remove vehicles from spawning need an event to work - just putting VehicleZoneDistribution.medium.vehicles["Base.car"] = nil; in lua/shared won't work. Coincidentally none of the workshop mods that have this purpose do this. Since they need to be removed before the world is generated, I'm wondering if using Events.OnInitWorld.Add or Events.OnGameStart.Add is better. I had success with both IIRC.
This method will stop items from spawning with ordinary loot spawning; I believe it won't work for clothing items that zombies wear, or items that are attached to zombies, such as the weapons that are stuck into them.
local item = ScriptManager.instance:getItem("Base.Spiffo")
if item then
item:DoParam("OBSOLETE = TRUE")
end
This will remove a recipe book from the learning material tab
ISLiteratureUI.SetItemHidden("EngineerMagazine2", true)
Thanks Algol, as always you are a lifesaver. I will try these and see if I can get everything working.
Right on, good luck! 🙂
Using
ScriptManager.instance:getItem("Base.Spiffo"):DoParam("OBSOLETE = TRUE")
Should work, right? Since I'm doing multiple items, setting a local variable for each of them just to shorten each line seems a bit cumbersome.
I believe that it can crash to mainscreen/desktop if the code tries to DoParam for a script item that doesn't exist?
I cut and paste the code block, and don't find it that bad. TBH those sorts of "safety checks" might seem fussy and unnecessary, but I've just found it to be a time saver in the long run?
I don't set a unique local variable for every item either, I just reuse item as such
local item = ScriptManager.instance:getItem("Base.Spiffo")
if item then
item:DoParam("OBSOLETE = TRUE")
end
item = ScriptManager.instance:getItem("Base.SpiffoSuit") -- Both of these will work, in that item has already been defined as local above
local item = ScriptManager.instance:getItem("Base.SpiffoSuit") -- But I still define it as local as a "safety measure" + I just spam cut and paste
if item then
item:DoParam("OBSOLETE = TRUE")
end
Got it. Looking at it as a safety check makes a compelling case for that syntax.
Though I guess I still prefer unique local variables as to make things a bit more readable. Thanks again!
👍
any good guides or mods that use globalmoddata between client and server?
Yep, Algol's solution works perfectly. The items do not spawn (no idea if they are still "rolled" to spawn though) and the literature vanishes from the learning tab.
Still curious why the old code stopped working - especially since a few mods still use it (like Snake mods) and also because it made it easy to clean the logs from stuff like
ItemPickerJava.ExtractContainersFromLua> ignoring invalid ItemPicker item type "BallpeenHammer"
So I could hunt for spawning errors.
textures fucky, please help
ive been trying to follow daddy dirks newest tutorials, but I could not open Worded without setting a path to my tiles which I did
I originally set my patn to ../tiles/2x but corrected it to ../tiles but its still messed up
ok I deleted my old project and closed the programm and it seems to be normal now
seems like it just didnt update the path change
#mapping is the channel where people will be able to help you with that.
Alrwady helped myself
Hi! Does anyone knows what the jave class "HumanVisual" does and how I can call one of it's methods during game? What I need is probably the method getSkinTextureIndex() but I don't know to call it. In my setting, I have the "player" object to work with.
A related question: On the client side, can I just use "MainScreen.instance.desc" while in game to get data about the current player? This MainScreen stuff definitely works in the pre-game menus (e.g. during Character Customisation) and contains a lot of data about the player but I am not sure whether it can be called while in game.
I don't know about the second question, but IsoPlayer has a method called getHumanVisual that you can call
Assuming player is a reference to a player obtained by calling getPlayer or getSpecificPlayer (or anything else returning IsoPlayer), it'd be called like player:getHumanVisual()
ya, i mean the IsoPlayer. thanks! i'll try that
other question: is current vanilla game, is it true that certain underwear items like the various underpants cannot get dirty/bloody?
I'm not sure, hopefully someone else who knows the answer will come along
I'm also look to get dirty undies
did a test run and killed dozens of zeds in debug mode (god mode ofc). no dirty bloody underwear so far...
i think the script txts for clothing have a field called BloodLocation but the underwear don't seem to have that field...
Gotta check how other clothing item works about dirty and bloody
My electricity is down i cant code 🤬
Well if there's one mod to check if underwear gets dirty, I guess it's the defecation mod.
https://steamcommunity.com/sharedfiles/filedetails/?id=1436878551
maybe adding BloodLocation = Pants may work for blood but no idea how to allow them to get dirty
Yep, they do not get dirty at all.
TIS please we want dirty underwear ty 
does anyone knows how the "BloodLocation" in the script file work somehow? if i just add it to the script txt of new clothing items (given only by textures) i get errors
what is strange is that when i search the whole project zomboid installation folder for the phrase "BloodLocation", all matches I have are in the ones in the script txts. shouldn't there be some other files accessing the "BloodLocation" data somehow???
makes no sense...
It's handled in the java side code then.
that's not good news for me an my current project...
is the java code somehow encrypted? cause I use a special search function which should search all text files including the java ones (except they are encrypted somehow...)
You have to decompile them. Ugh, there's a learning curve with that business but here https://github.com/Konijima/PZ-Libraries/blob/Tutorial/README.md
thanks... but anyway... even if it would work, i'll better not touch it and try to find another solution...
maybe i ask the people from the modelling section how they add blood to clothing stuff.
I know it's a feature coming Soon™ but is there currently a way to figure out which mod an item comes from?