#mod_development

1 messages · Page 334 of 1

thin swan
#

Yeah you're right, it's not gonna be worth it, and is just opening myself up to a lot of headaches

#

I dropped a lite version of the bike that doesn't have the attachment system so it should be compatible with everything, that'll just have to do if people are having conflicts

crisp dew
#

well crap.... realized I need to use the GenericCraftingSurface flag in TileZed and my version doesn't have that field, (at least I can't find it). The newest unofficial build steps start with

QTDIR=~/Qt/5.15.2/gcc_64
SRC=~/Programming/pzworlded

which is never a good sign; hard coded paths to atypical files.

strange dome
#

quick Q for anyone who may know - seems like when wearing a jacket the game completely hides neck jewelry/chokers etc. im not seeing anything relevant to this in the xmls or scripts aka masks etc. is this a hard coded behavior that a mod cant get around? short of not using the jacket location.

bronze yoke
crisp dew
#

I just noticed that; happen to know if there's a current list of properties?

#

(eventually)

#

beautiful.

terse delta
#

Can I use this function to half weight of all liquids?

#

Or use any multiplier, at this point

#

That's like N1 thing I want to do rn

crisp dew
#

Damn, realized there's a PegBoard in the game already, now I'm thinking I should modify the existing item vs creating new, which seems far more complex :/

dusty flint
#

Having issues with recipes..

recipe Make Ice Cream
{
    [Recipe.GetItemTypes.SapphCookingMilk];10,
    [Recipe.GetItemTypes.SapphCookingSugar];10,
    [Recipe.GetItemTypes.BakingFat];1,
    [Recipe.GetItemTypes.SapphCookingEgg]=2,
    keep Spatula/[Recipe.GetItemTypes.Spoon]/[Recipe.GetItemTypes.Fork],

    Result:Icecream,
    Category:Cooking,
    Time:500,
    Category:Cooking,
    OnGiveXP:Recipe.OnGiveXP.Cooking10,
    SkillRequired:Cooking=6,
}
recipe Make Caramel Syrup
{
    keep Spatula/[Recipe.GetItemTypes.Spoon]/[Recipe.GetItemTypes.Fork],
    [Recipe.GetItemTypes.SapphCookingSugar];10,
    keep Saucepan,
    Butter;1,

    result:Syrup_Caramel,
    Time:400,
    Category:Cooking,
    OnGiveXP:Recipe.OnGiveXP.Cooking10,
    SkillRequired:Cooking=5,
    CanBeDoneFromFloor:true,
}

The ice cream recipe is working ingame, but the caramel just isnt showing up. Does anyone know why?

dusty flint
#

Yes.

#

omfg
its the fucking capital letters in Result: isnt it

bronze yoke
#

result in the second recipe should probably be capitalised

bright fog
#

Result yea

dusty flint
#

AAAAAAAAAAAAAAA

bright fog
#

Thx god that can't be an issue in B42 recipes lol

silent zealot
terse delta
#

I need to get original weight into variable

silent zealot
#

Check InventoryItem on javadocs

terse delta
#

Thanks, I'll look it up

silent zealot
#

There's a get weight() or getActualWeight() function

#

You'll need to convert from the item name to an actual item or an item script though

terse delta
#

I'll try to run this and hope it'll work drunk

bright fog
#

the if originalWeight is useless, bcs you will always get a weight

silent zealot
#

That won't work; item is just a string

terse delta
#

Typical thing for lua, isn't it?

bright fog
#

Also you can move that items table outside the function, doesn't change much but you won't redefine it everytime you run the function

bright fog
#

Not everything can give nil

#

And in this case, an item without weight shouldn't be possible

terse delta
#

I'm starting to understand it

bright fog
#

It's better to get used to use this method for this specific kind of table (usually called arrays) because it tends to be faster than ipairs and pairs

terse delta
bright fog
#

Yea

terse delta
#

But I'll note this too

bright fog
#

But like I said, it's mostly of getting used to using this method

#

That way you never have to think about it later down the line

#

Also feel like it teaches you better the difference between iterating over a key table and an array

terse delta
bronze yoke
#

the wiki should probably note how galactically expensive ipairs is

bright fog
bronze yoke
#

it's not just slower than a numeric loop but exponentially more expensive than pairs

#

which is something that takes people who are used to other lua implementations off guard

bright fog
#

But it turns out I didn't do it (or didn't find it)

bright fog
bronze yoke
#

no, pairs is massively better

#

pairs is implemented in java so it's fast

#

ipairs is implemented in lua so it's slow as shit

bright fog
#

Nvm was there lmao

bronze yoke
#

pairs pays function overhead 1 time, ipairs pays function overhead N times

bright fog
terse delta
#

If we ignore the fact that you can't get weight from item string

bright fog
bronze yoke
#

an item is never going to not have a weight

terse delta
#

Pretend it is not here

bright fog
#

Also, you shouldn't implement this kind of prints that shows debug stuff if a scenario doesn't happen

#

This will explain why

crisp dew
bright fog
#

yea fixed it

terse delta
#

Ok

bronze yoke
#

it's fine to print in the case of an unrecoverable error like this

terse delta
#

I'll keep it for testing tho

bright fog
#

And that's how we end up with ItemTweaker 2.0

#

Overall terrible reflex to have in your codes

bronze yoke
#

item tweaker's problem is that it prints when everything is working, printing errors is standard practice

bright fog
#

No no I don't agree with that, because let's take the case of his code actually having the possibility of a nil, in a situation where it's likely that in some cases this if check doesn't pass, then you end up with people not being able to make the difference with "is it normal that the if doesn't pass" and "the if here should always pass" (tho for that last one you shouldn't ever need the if anyway)

#

So I will keep my position that I will not teach people to put such prints in their code, because dear god I KNOW FOR A FACT people will then get used to put them at places they don't understand why they shouldn't put it. Also taking into account here that Serenity here thought that "checking for a nil is normal pratice in Lua" .... which means they considered that this nil check could likely not pass

#

Also that error print is in freaking russian so no one gives a shit about it but the mod author !!!! like I stated in the mod optimization page: literally the entire population of this galaxy doesn't care about your prints but mostly yourself and a few random nerds that can ACTUALLY read console logs AND understand that this error print is not some bullshit that the game prints thinking the information is useful but it's actually bloating the console, and that how you get constant cases of people asking if these random weird ass vanilla errors are the source of their problems when in fact these are literally nothing and just present anyway

terse delta
#

You really don't like print, aren't you?

bright fog
#

No

bronze yoke
#

so how the hell are you supposed to debug other people's errors without prints? 😭

terse delta
#

I added it for myself so I can easily read it

bronze yoke
crisp dew
#

breakpoints.

bright fog
#

I almost had to go in all their mother fucking files to comments out every fucking prints

crisp dew
#

"Break on Error" is enabled by default.

bronze yoke
bright fog
#

Yea >:(

crisp dew
#

It is a pretty rubbish debugger, but at least it's better than nothing.

bronze yoke
#

i use the debugger heavily for my local testing but i need someone else's error log to say what the error is before i can start locally debugging it

bright fog
#

I personally do not care for prints for errors from modders that ACTUALLY understand the shit they are making AND the informations that they should ACTUALLY give to people

red tiger
#

Might write my own debugger lol

#

Currently occupied with writing a strict class framework in Lua.

crisp dew
#

Waiting for Doggy to write a mod that globally disables print()

red tiger
#
__G.print = function() end
bronze yoke
#

did anyone ever actually release a mod that buffers prints? i know a few people did that locally and it worked really well

#

iirc it massively improved performance with mods that were spammy

red tiger
bronze yoke
#

yeah, the benefit was for other mods that already had spammy prints

bright fog
red tiger
bright fog
#

Also didn't Chuck want to add that in error fixifier lol ?

bronze yoke
#

anyway, the biggest benefit to logging error info is that things don't break silently

#

i design my code to break as soon and loudly as possible when there's an issue so that mistakes and bugs don't make it out to public release in the first place

bright fog
#

Yea but you know your shit and you know when something's actually not meant to break

red tiger
#

If you can get the stack of a call then you can catch this in your overrided print function and then mute or buffer-stack prints.

#

That's probably what that local code did.

bronze yoke
#

nah, it literally just replaced print with a buffered version

#

it wasn't anything fancy

bright fog
#

@sour island did you implement the disabling of prints in error fixifier ?

bright fog
sour island
#

Oh disabling print like that is possible, sorry misread/misremembered what I was trying to do was to disable console errors

#

Which isn't possible

bright fog
#

Aaaah

#

Yea that was it

red tiger
#

Write code in a way that validates or returns code flags / status.

#

I had to write a json validator that doesn't stacktrace.

sour island
#

The stuff for logs isn't exposed, and filesystem isn't exposed to let one touch stuff where console is

red tiger
#

mute print and use DebugLogger

sour island
#

The farthest I got was to break the debug console a bit- which broke the game

terse delta
#

lmao

sour island
sour island
#

Right now it stencils the error area incompletely

bronze yoke
#

here's a pretty legitimate example of a debug print:```lua
local traitMetatable
if Trait and Trait.class then
---@type Trait
traitMetatable = __classmetatables[Trait.class].__index
else
log("Another mod has corrupted the global environment (replaced global Trait).", "warn")
if instanceof(Trait, "TraitFactory$Trait") then
log("The mod that adds the trait %s is probably to blame.", "info", Trait:getType())
traitMetatable = getmetatable(Trait).__index
log("Workaround succeeded.", "info")
end
end

if not traitMetatable then
log("Unable to get trait metatable. Sandbox options affecting traits will not work. See previous messages for info.", "error")
return
end

sour island
#

So that whole area skips the UI rendering 😅

bronze yoke
#

(ignore the gross logging api that i'm not really very happy with anymore 😅)

sour island
#

Hmm can't I replace log() to any useful effect for what I need?

bright fog
sour island
#

I assume stack traces are directly from java

terse delta
terse delta
#

Unironically, useful sometimes. I get quite a bunch of harmful errors, but popups annoy a little

sour island
#

People have gotten GBs of console logs cause they can't see errors in game

terse delta
crisp dew
#

When I'm evaluating which mods to install on my servers, I run them through the local game with -debug and refuse to include any that throw errors.

terse delta
#

I think there's case where it can throw nil

sour island
#

Some errors can be ignored tbh

terse delta
#

If I'll list modded item, but don't have the mod itself

bright fog
terse delta
bright fog
#

You will error on trying to get the weight

terse delta
bronze yoke
#

any error will end the current function

bright fog
#

You just straight up shouldn't leave errors in your mod

bronze yoke
#

it's a lot more lenient than is normal 😅

terse delta
#

So, if I want to add optional mod support, I have to create function like this, but with mod check

#

Right?

red tiger
#

Speaking of errors, I'm writing error handling code that's verbose AF but professionally.

lua: ...coding\zomboid\CSSBoxLua\cssbox\layout\Dimension.lua:228: Lua Class (Dimension): Attempted to assign field "width" with type "string". Expected type(s): [
    number
]

Strict Lua class framework in-development.

#

Gonna make this strict class framework make class objects act like Java objects.

bronze yoke
bright fog
#

Probably the best way

dry mist
#

I want to explore modding Project Zomboid/modding in general and potentially one day making a game from a mod, my question is how much Indie Stone is ok with it?

bright fog
dry mist
bronze yoke
#

i mean, if you're not planning to reuse their work or ip, i'm not sure why you're even worrying about TIS, they have nothing to do with your game

dry mist
#

I’m completely new to this kind of thing

#

so I’m trying to learn what the, boundaries? are with this kind of thing

#

Gotta start somewhere

terse delta
#

Looking at fluid javadocs

#

I can't find anything about weight

terse delta
#

Let's look if I can apply patch to this using lua

bronze yoke
#

that's not what that code is doing

terse delta
bronze yoke
#

the fluids block defines the amount of that fluid the container should spawn with, as a fraction of the total capacity

terse delta
#

Oh, got it

#

You've created the javadocs, have you found anything about fluid weight?

#

It's fixed to 1 weight per 1L, I want to start from changing it to 0.5, and then attach sandbox setting

bronze yoke
#

i haven't looked at fluids in particular but a lot of the new script types in b42 aren't very flexible in the way the older ones are

terse delta
#

I have a really bad idea

#

In theory, it is possible to dynamically change the weight of an object with liquid with each liquid update

#

Considering the weight of the empty container

#

So basically, I have a bucket of 1 weight, being able to hold 10L with total encumbrance of 11 weight. I run a function to get liquid amount and original weight of empty container, then I assign to this item the weight of liquid divided by two + empty container weight

#

And this function happens each time amount of liquid in the container updates

#

Rate how horrible this idea from 0 to 10

silent zealot
terse delta
#

So I came up with this yanderedev ahhh solution

#

The only missing component of this scheme is the event onFluidUpdate or smth like this

silent zealot
#

Setting container weight probably won't work

#

It will set the container weight, ignoring the liquid

#

Then you ask for weight, it gives you that plus the weight of the contents

terse delta
#

Anyway it's joever, I can't update it dynamically since I can't really hook this function to any event

terse delta
terse delta
#

Currently looking at ProceduralDistributions.

#

I get what roll means, it is amount of times games "drops a dice" to spawn something from a list

#

But I don't understand: what those chances actually mean (if it is not percentage or weight), and where is the chance that roll spawns nothing?

bright fog
bronze yoke
#

that's not what a roll is

bronze yoke
#

the game rolls *every single entry in that distribution table* that many times

bright fog
#

Yea

bronze yoke
#

in other words they aren't weighted

terse delta
bright fog
#

The wiki page explains all of these

bronze yoke
#

the meaning of the chance value is more or less arbitrary

#

there are too many factors involved to be able to reliably say what the actual chance ends up being

bright fog
#

It varies on a bunch of factors

terse delta
#

So there's 4 rolls for each entry if set so

bright fog
terse delta
#

So what are those chances? How do i read them?

bronze yoke
#

in that example distribution, Item1 is rolled with a chance of 10 out of (SOMETHING, WHO KNOWS) three times, then Item2 with a chance of 5 three times

bright fog
#

You don't really read them

terse delta
bronze yoke
#

you just feel them

terse delta
#

lmfao

bronze yoke
#

look at vanilla stuff that has a similar spawn rate to what you want

terse delta
#

in the case of rolls for each item, they could've implemented percentages

bronze yoke
#

it's not accidental that it's like this

#

the chance of loot spawning is mostly scaled by the zombie population of the area

#

that's why it's not easy to know the effective chance, because even in the same kind of container it will be different in difference places

terse delta
#

So, rolls is the amount of attempts to spawn item, it goes through every item in the list. And the spawn chance is just something

bright fog
#

And apply your distribution based on that

#

There's also an API which allows you to set the same distribution for your item as other items

terse delta
#

Yeah, I know it, but it's not suitable in my case

bright fog
#

👌

terse delta
#

Can I see distribution category in-game via debug mode?

silent zealot
#

For loot generation?

#

Cheats -> lootzed

#

right click container

#

lootzed

#

lets you see what objects can spawn in there

sour island
#

Wrapping distro changes is a good handrail for newer modders- but if you understand how Lua tables work it's generally fine to do anything you want with it.

terse delta
#

math ain't mathing

sour island
#

note the scientific notation (if that's what you mean)

#

It's kind of silly it does that when its just 1 more 0 than the other stuff 😅

silent zealot
terse delta
#

what could be the issue?

bright fog
#

Should help us have a fixed image of it bcs rn it hurts my eyes

#

Tho I can't look at it now

#

Got to go

bright fog
#

You're inside the game files

#

Not in the cache folder

#

That Workshop folder you're in is wrong

#

It's unused

#

Read the part about the cache folder on the wiki page

#

In Game files if I remember right

terse delta
#

It's in user files

#

Got it

#

It even worked from the first time

silent zealot
#

@late hound (and anyone else wanting to see something funny) - this is what enabling ragdoll on the player part of the "player drags a corpse" animation looks like.

#

The moment I stopped moving, full ragdoll.

terse delta
#

I'm more surprised that player can ragdoll

silent zealot
#

The animation system is the same for players and zombies, just with different sets of animations

#

The real challenge is setting up animations to use ragdoll properly and not just make a huge mess or curl up into a little ball

terse delta
#

Solar power mod replaces several container distribution types across the map, like carton box with solar inc stuff

#

I want to apply the same treatment to lectromax factory in scenic grove

terse delta
#

hmm

silent zealot
#

Is that mod changing the loot type of containers

#

Or replacing a tile with a different tile

terse delta
#

It replaces some crates on the map with its own container with special loot table

silent zealot
#

Personally I don't like mods that replace tiles on load, I've had performance issues with that start of thing in the past since the game already struggles to load when driving and having to also go though every object on every time as well is not ideal.

terse delta
#

I want to do this to lectromax factory

#

So it has loot table that actually makes sense

silent zealot
#

Do you need to replace tiles, or do you need to change the loot in containers?

#

And do you know what loot tables it uses... If you're lucky there's a lectromax table that just needs the proper stuff put into it

terse delta
#

very fitting for company that produces electrical appliances 👍

#

I want to replace containers with default factory loot to containers with my new lectromax loot table

#

I think I need to do it same way solar power mod does it

finite scroll
#

Does anyone know of an event triggered when a players injury heals?

finite scroll
odd parrot
#

Hey @terse delta you manage to understand distributions? bc im facing the same problem now

finite scroll
odd parrot
#

and chatgpt isnt chatgpting

terse delta
#

What's your problem?

odd parrot
#

I dont understand how to write it to make it work

#

Basically i just modify the texture and properties of a cereal box, and i want to make it spawn naturally at the same points of cereal, without overwritting the base lua distribution

#

if that makes sence

terse delta
#

I've added my entry to base distribution list

odd parrot
terse delta
#

It is a dependency

#

There's no meaning to inject lua script into global lua distribution for a cereal copy

silent zealot
odd parrot
#

Thanks Sere i know the existence of this api (im gonna take a look on it if i get stuck)

silent zealot
#

You can have a look at the code in easy distro, then do your own version of that. Or just do the loot all by hand

#

The code is a bit ugly, but not complicated

odd parrot
#

Yeah, im for sure doing that (taking a look on it)

#

I feel is a little empty on resources to make mods

terse delta
#

If you really hate dependencies that much

sour island
bronze yoke
sour island
#

The worst case scenario to using a dependency is that one that it might be outdated and you may need to fix it yourself. By sticking in a copy, you're kind of starting off on that worst case.

odd parrot
sour island
#

Not even about stealing- you can ask permission and chances are most API writers would love for someone to use their work even if you're including a version of it. 😅

odd parrot
bronze yoke
#

avoiding dependencies for performance reasons is a little silly

bronze yoke
#

dependencies don't inherently cause any performance difference whatsoever, it is exactly the same as if you had copied it into your mod, and you're banking on your own version being better than a mod specifically designed to do that one thing

#

in this case, this mod doesn't do anything outside of load time so performance shouldn't really matter either way, it won't affect performance during actual gameplay

odd parrot
#

i see, maybe i was comparing pz modding with MC modding a little

sour island
#

For better or for worse most APIs/Libraries (Not even sure what the actual industry term is) in PZ are 1-2 features a piece, and I don't think it would work the same way where you'd be loading a bunch of stuff you wouldn't actually be using(?)

bronze yoke
#

should be 'library', the usage in this community of 'api' is a little off 😅

sour island
#

I feel like all the terms are to an extent

bronze yoke
#

yeah, that's just what happens in amateur scenes really

#

there's a bunch of computer science terms we've all heard informally and think we know what they mean

sour island
bronze yoke
#

i've got a 'stats api' too 😅

sour island
bronze yoke
#

it's not far off anyway, a library has an api, and the intention of the mod is probably exclusively to implement that api so it's not really wrong to name the mod after the api

odd parrot
#

My brain status rn
tired
stressed

bronze yoke
#

but i think 'library' sounds a little better 😅

sour island
#

I guess it's a glass half full/empty in terms of how much of the lifting the api/library is doing

odd parrot
#

Correct me if im wrong, Distributions.lua is for the actions of spawn items and the ProceduralDistribution.lua is for the tables, like the items that could appear?

#

(in a general way)

bronze yoke
#

Distributions maps containers to specific spawn tables, ProceduralDistributions is the actual spawn tables they're being mapped to

sour island
#

Dist has some containerIDs too though

#

I was trying to word it cleanly, but distributions is kind of a nest lol

bronze yoke
#

yeah, some types of containers aren't procedural (just bags and zombie outfits i think?) so they're defined directly in Distributions

sour island
bronze yoke
#

and there's some random bonus files in b42 too

sour island
#

Some of the stuff is confusing at first glance, like everything being shoved into another table

#
table.insert(Distributions, 1, distributionTable);
#

Also the .list thing threw me off for the longest, but I think that was to keep the option open to include functions to the main table

odd parrot
#

i make some code

#

wanna see?

odd parrot
#

i put metal shelves to see if that actually works and then i gonna change it to another container

sour island
#

Becareful naming files exactly the same, the game will override vanilla files, it's path sensitive, so you could include an extra folder or rename the files with a prefix.

silent zealot
#

And everyone yelled at ne

#

🤣

terse delta
#

It just injects new entry into distrolist, extremely compatible and has 0 issues possible

sour island
#

Yeah, I forgot to mention that -- by defining the table again you're wiping it out as well 😅

silent zealot
odd parrot
terse delta
#

I wanted to add propane tank specifically to gas stations and that's all

silent zealot
#

I made easy distribution because I wanted it to be a thing, and figured it would actually be useful elsewhere

odd parrot
sour island
#

I feel like a dozen people including myself have written a distribution function that inserts stuff into a pool of entries

silent zealot
odd parrot
silent zealot
terse delta
#

You can upload this as challenge mod

#

only scooby snacks can spawn

odd parrot
silent zealot
#

Challenge: all loot replaced by tins of beans.

odd parrot
#

the real "schizophrenia" mod

silent zealot
#

So youre limited to foraging and what you can recover from zombies lol

#

And vehicles probably since they have a seperate set of loot tables

sour island
terse delta
#

I just spent 8 hours and learned almost nothing drunk

#

starting at modding be like

sour island
#

Change ProceduralDistributions.list = { to
ProceduralDistributions.list.sSnack = { ditch the ending }

odd parrot
terse delta
#

Oh, I know what next distro-magic i'm going to do

#

I'll add reloading, long blade and aiming books into libraries with a lowered chance

solar rover
#

So.. if I want a script to add players to a safehouse with addPlayer(String player) How do I know what the string is for the safehouse in question?

silent zealot
silent zealot
solar rover
#

I want to add players (safehouse members) back to the house after a resize.

silent zealot
#

Other tricks are seeing how something is used in vanilla Lua code

solar rover
#

yeah, I do that a lot. For this I have no idea what the add member does when a player accepts an invite.

silent zealot
#

I'm guessing it's a multiplayer thing, since for single player I can't think of any way a string would identify a player (also, no need for a safehouse)

solar rover
#

and no members.. because single player

#

lol

bronze yoke
#

if you mean what string the method is expecting, it's a username, player:getUsername()

solar rover
#

I was just searching through the safehouse inputs for a way to add someone directly as a member at that looked like the way. Its under the safehouse heading in the modding doc

#

my safehouse resize tool is pulling the member list from the safehouse data before it resizes the zone by dropping and replacing the zone but doing so removes any members. I wanted my players to do less work.

silent zealot
#

I'm waiting for B42 to learn multiplayer modding quirks so I don't need to relearn everything.

solar rover
#

You have a few years to study I would say lol.

silent zealot
#

Also lets me put off multiplayer stuff for ... Probably another year.

#

Absolute minimum six months, but only if they leave a lot of stuff broken and just go ahead with multiplayer.

late hound
#

now does anyone know of a "reset" function for the player animation skeleton? I've gotten the character stuck sometimes when adding/subtracting conditions and whatnot to the AnimSet xmls

sour island
#

Whats that UI 😮

bronze yoke
#

the anim monitor

#

i don't remember if it's in the main debug menu or if it's one of the ones you need to right click a character to open

late hound
#

its not a new tool by any means, originated from b41

silent zealot
silent zealot
bronze yoke
#

it was definitely in b41 too

silent zealot
#

I thought it was new - the debug menu in B41 looks so lacking when I run that to check something after B42

late hound
#

I haven't figured out how to use half the tool lol

#

so looks like I either have to reset or clear the anim layer

silent zealot
#

Does mashing the ESC key a bunch fix it?

terse delta
#

Quit/load will fix it

late hound
late hound
ancient grail
#

your player cant move?

late hound
#

yes

ancient grail
#
            local pl = getPlayer() 
            pl:setBumpType("stagger");
            pl:setBumpFall(true);
            pl:setVariable("BumpFallType", "pushedFront");   --pushedFront --pushedbehind
            pl:setBumpDone(true);
            pl:reportEvent("wasBumped");
#

try that paste it on the lua console and hit enter

#

thats what i use whenever my char ggets stuck cuz of animation

#

i have this ready with chat command so i just /stag and it will unstuck

late hound
ancient grail
#

weird it might be doing that on a loop or something

late hound
#

huh ok, will work with it some more

terse delta
pulsar charm
#

I'm following https://pzwiki.net/wiki/Adding_new_tiles to make a tile for my mod
so in tilezed when i create the .pack, I also have the option to add .tiles files, but the tutorial doesnt mention doing that. Am I supposed to add my .tiles here to make the .pack? If so why do i also need the .tiles in the mod folder

Edit: seems optional based on posts ive found in this channel

bright fog
bright fog
silent zealot
#

You fix one balaclava and suddenly everyone wants you to let them wear watches and vambraces, or shoulderpad and a backpack, or an eyepach under their gasmask...

bright fog
#

What did you use to do it ?

solar rover
#

Is there an driving event similar to OnPlayerMove?

silent zealot
#
-- This runs after Bodylocations.lua, so we need to clear all exclusives in 
-- all bodylocations since it's too late to prevent them in the first place
-- 
-- That's BodyLocations(plural of BodyLocation), not to be confused with BodyLocations 

local group = BodyLocations.getGroup("Human")
local locsUpdated = 0
local exCount=0

for i=0,group.locations:size()-1 do 
    exCount=exCount+group.locations:get(i).exclusive:size()
    group.locations:get(i).exclusive:clear()
    locsUpdated=locsUpdated+1
end
print("WAWA: "..locsUpdated.." locations updated, "..exCount.." exclusions removed.")
#

that's the entire mod. BodyLocations-> Human BodyLocationGroup -> ArrayList of BodyLocation -> ArrayList of Exclusions

#

Iterate through and clear all the exclusions ArrayLists.

#

Can you do a quick test of it? First comment is "doesn't work" but I don't trust bug reports like that.

#

Works for me in debug and normal mode, without other mods running, and now I'll verify on my full modlist.

silent zealot
#

My first plan was to block lua from using setExclusive(), but... too late to do that.

ancient grail
#

wouldnt this cause problems if mods use the function to attach the item
like "back" or something

silent zealot
#

Only if the mod somehow relies on exclusions for... I don't know what it would rely on them for other than the intended purpose.

#

All the body locations are intact, other than the stuff that gets set like this:

#

works with all my mods. two eyepatches under glasses under a football hetmet with a bunny ears hat, which was impossible before I added the mod.

uncut hemlock
#

Hey I just joined and was wondering if anyone could tell me what it takes to edit the vision cone angle during night. I'm just kind of interested in removing the vision cone reduction during night so I can enjoy nighttime a little more (it also seems like kind of a stupid mechanic tbh) I'm not a modder or anything, so I looked around on the workshop and didn't find anything, but If it's as easy as editing some values I can probably just make my own mod that does it, but I don't really have any idea what I'm doing so I figured I'd ask in here and see what happens.

uncut hemlock
#

That's unfortunate, also explains why there's no mods for it, I'm sure I'm not the first to have this idea

versed viper
#

Could someone tell me what the cause is when, for example, for a mod that has a speech popup for an event that happens with the player, instead of displaying the text of the speech, it displays "IGUI_whatever"?

#

I'd like to know what to look for in my mod list to try and figure out which mod is causing it

silent zealot
#

From memory If you make an piece of clothing with a -100 vision penalty it will give you a max vision cone even at night

silent zealot
#

The "whatever" should give you a hint what mod is from, subs people normally name the translation key something related to the way it is used.

versed viper
#

Thank you.

silent zealot
#

Or use PowerShell or another tool to check every Lua file in your mod download folder for IGUI_whatever

versed viper
#

I know which mod is causing manifesting the most egregious case of it for me, so I'll check that one first, but I appreciate the advice very much

bright fog
silent zealot
#

It doesn't change that, you're still limited to one item per slot.

#

I don't think that can be changed, but I'll have a look later in case it can be.

#

My feeling is the data structure would support it, but it would be an issue with anything that does getClothingByLocation() or whatever that function is called

#

And the code the un-equips the existing item may be in the java. Or it may be in 15 different places in the lua.

silent zealot
#

Or make a dedicated "English translation" mod lol

versed viper
#

Yeah I used to make my own patches for Bethesda games but it was a bit easier with the tools there lol. I will learn how to do that for PZ sooner or later

terse delta
#

I think the only way to change liquid weight is replacing whole Java class

#

I'll try to locate it

chilly flint
#

Hey, anyone able to help me out on this one?

terse delta
chilly flint
#

really? sure thing then

silent zealot
#

How did you replace the spawn points? I've added spawn points (make a map mod with no map, just spawn points) but never removed them

#

The extra "maps" in the base game like like ProjectZomboid\media\maps\Echo Creek, KY still show the Mauldraugh, KY world map... but they don't do anything to disable the Mauldraugh, KY map.

terse delta
#

I really want to tinker a bit with ki5 vehicles

#

I can make loot and vehicle categories not so obnoxious

#

AI suggested me to shorten my table.insert. Don't have time rn to check it, does it works that way?

bronze yoke
#

no

terse delta
#

welp that was expected

#

Also, does this work if I want to completely remove entry from the table?

bronze yoke
#

no

terse delta
bronze yoke
#

you need to pass the index of the value that you want to remove, not the value

terse delta
#

Do I need the cycle for it?

bronze yoke
#

you can simplify your while loop to for i = 1, #items, 2 do

terse delta
bronze yoke
#

yeah

terse delta
#

In summary, will this script work?

bronze yoke
#

i think so

terse delta
#

Also, do I need to hook this function to event?

#

Or it will start up by itself

bright fog
terse delta
#

Events.OnInitGlobalModData.Add(removeSpecificItem)

#

?

bronze yoke
#

assuming all you need is to run this code, no event is needed, you can just call it

#

if you need sandbox options then you will need to wait for that event

#

and you will also need to re-parse the loot tables afterwards

terse delta
bright fog
#

Remove the function entirely

bronze yoke
#

it's fine to use a function, personal preference

bright fog
#

Yea

#

But here it sounds more like a common missunderstanding of how it works

#

This is a common misconception that new coders have I feel like, that to run your code it needs a function or something like that

terse delta
bronze yoke
#

in most programming languages you need to define a function and then call it, in lua files *are* functions so there is no need to do that

#

stylistically it is still preferable to mostly stick to functions though

silent zealot
#

I see having a single defined entrypoint as being part of the distinction between a programming language and a scripting language

#

But there's no much crossover it's an academic argument, not a useful one.

terse delta
#

Final version of cycle, now I gotta test it

silent zealot
#

Albion, you probably know this: I'm trying to access a public ArrayList. I can get... something. When I use print to try to get a clue what it is, it prints []

#

So it's not nil

#

but.. I can't figure out exactly what it it or how to use it.

#

in the java

bronze yoke
#

that just means the arraylist is empty

#

they have a custom tostring so they don't show the type there

silent zealot
#

oh, that's disappointing lol

#

I thought I've just saved myself a big pile of work by getting access to the list of all zones along with some helpful functions that the Zone class has.

terse delta
#

Albion, there's no way to change global fuel generators properties, right? Coudn't find info on javadocs

bronze yoke
#

nope, all hardcoded

silent zealot
#

Some are in in sandbox settings

terse delta
#

I swear I'm going to use leaf someday ded

silent zealot
#

including range now

terse delta
silent zealot
#

Is this about the condition not going down for one brand?

#

no such luck

terse delta
#

Road blocks are everywhere 😔

#

That's why I prefer when game allows to code in its source language

silent zealot
#

C# compiled using Mono == so nice to mod.

bronze yoke
#

well writing in java wouldn't let you change this either

#

it's not lack of access from lua, it's just not dynamic to start with

terse delta
#

Or at least change the class and recompile it

bronze yoke
#

you could recompile it but that's a different scope entirely

silent zealot
#

Java mods are possible, but they are not something you want to undertake lightly

#

And a lot of people won't install them because it means manually overwriting .class files

#

You'll need to be ready to redo the java code and recomile with every update

#

Better if you can come up with a workaround.

#

For example, what if you made something using a fuel drum you placed next to a generator that would automatically top up the generator with periodic setFuel() calls?

terse delta
#

That's what UsefulBarrels is trying to do, but it's taking him a long time

#

Perhaps he met another road block?

silent zealot
#

Figuring out how to handle things when it's not loaded maybe?

#

the gobalobjects system is really confusing

#

And a lot of generator stuff is in java

bronze yoke
#

generators aren't actually global objects at all

#

the generator global object code i suspect you're looking at is unused

terse delta
#

I had a concept for upgrading the generators in the list, but it looks like this will require not only changing the Java Class, but also installing a bridge between this class and Lua

#

I can imagine that it is extremely difficult.

bright fog
bronze yoke
#

leaf would yeah

#

but it's nothing trivial, you'd basically just have to rewrite all the logic

#

generators use static final fields, accesses to which are optimised to literals at compile time so even with reflection changing the values of the field it doesn't actually change anything

#

so it's not something standard reflection would help with, nor prefix or postfix patches

terse delta
#

Tis would optimise anything but lighting ded

frank elbow
#

That's more of a Java compiler optimization

silent zealot
silent zealot
#

it's all compiled to literals, both for tiles and chunks.

#

(since it keeps track of which chunks are affected by which generators)

arctic shore
#

Hello, I'm developing a mod. I'm still in the early stages, but I'd like some help.
The first issue is that I want the character to have only one cloth bag when he starts the game, and it turns out that he always spawns with an ID card, 9mm pistol, box of bullets, belt, 9mm magazine and keychain. Could someone help me remove these items and add only the cloth bag via codes in the mod?
Thank you very much

terse delta
arctic shore
terse delta
#

First idea when I want to implement something, I try to remember a mod that does something similar

pulsar charm
pulsar charm
#

Do yall know of any movables that call scripts on placing them?
All i can think of are generators and rain barrels, but generators are unique and rain barrels are crafted

bright fog
#

Wdym by calling a script ?

#

Like triggering an event ?

#

It's probably an event that triggers and they identify the object and run code based on that

pulsar charm
#

yeah, i need a lua file that runs when placing a movable
I see the functions onNewWithSprite and onLoadWithSprite

bronze yoke
#

those should work i think

#

i'm not really familiar with anything using onNew but onLoad definitely works reliably

pulsar charm
#

do you know when onLoad is called?

bronze yoke
#

when you load a chunk for the first time (since you created the save) with an object of that sprite

#

it's mostly used to convert map objects to global objects but you can run whatever script you want

pulsar charm
bronze yoke
#

i'd guess from the name onNew is to do with the player placing/crafting objects

silent zealot
#

I found the zones!

#

The way I was getting the metagrid was wrong

bronze yoke
#

oh yeah, i didn't pick up on that, but this is something i've had trouble with before: basically, don't trust any .instance, or any static field in general

#

ScriptManager.instance is reliable, GameTime.instance is not

#

when kahlua exposes static fields there's no link to the actual field, it just copies the value at the time of exposure

#

so if it changes, the field will point to the old instance, only the getter will return the real instance

arctic shore
silent zealot
#

Good progress for tonight.

#

Mod goal: start knowing all the major roads on the map.

#

By reading from the foraging zone data

arctic shore
#

Hello guys!

I have over a thousand hours of PZ playing time and I would like to create a mod that is not extremely complex but that seems quite interesting to me. I managed to complete some steps, but others are beyond my knowledge. Would anyone with more experience in creating mods like to join me in this project? I can explain more about it if you accept. Let's go? Please...DM

silent zealot
#

Heck yeah!

silent zealot
silent zealot
#

I'm not getting involved in a one-on-one conversation with no details

sturdy salmon
#

Good day. I have a consultation. Why is Windows-1252 used in the language (ES and AR)? Within a mod, I added a file called Language.txt, using UTF-8 (which is the one that all other languages ​​use) and I had no problems with the accents. Excuse me for using this channel, but it doesn't let me write on the #translations channel.

silent zealot
#

Also, it's 2:30am and I was going to go to bed 3 hours ago when I noticed the forage zones might be the solution to my "start knowing roads" idea... oops.

arctic shore
silent zealot
#

I don't know that show.

#

I'm guessing the player starts naked (easy to do)

#

Do you have a list of specific game effects that you want?

#

Then you work through them all one by one

#

I've got too many things I want to make myself to do team ups, but this channel is an excellent resource that can help you work through what you need piece by piece.

#

Have you done any programming/scripting before? (any language, just enough to the basic of variables/functions/conditionals... if you have that lua is an easy language to pick up)

arctic shore
# silent zealot I don't know that show.

It's not just about being born without items. In addition to being born naked, I managed to implement a day count that goes up to 21 days of survival. This is the time it takes for the player to reach a specific location for an extraction, which can also be the destruction of an item to end the game (as occurs in the Zring mod). That would be the basics. Later, I would like to add some extras, but they could be in a next stage, such as animals damaging the player, failure in crafting attempts, and finally a specific forest or island map, but for now we can use a map that has already been created, such as "the forest".

silent zealot
#

The game already keeps track of time, so it's easy to tell how many days have passed.

#

What would "extraction" look like in the game? And what would not getting to the extraction point look like?

arctic shore
terse delta
#

i'd assume

#

Stalker, are you nepentho?

silent zealot
#

Ah, but what sort of death? Just falling over dead isn't very saisfying, but it easy.

silent zealot
#

I am.

bright fog
#

Just ask

terse delta
silent zealot
arctic shore
terse delta
#

Now I want to make a system of "Hidden Sprinters". These are zombies that initially spawn with this hidden property. When a certain condition is met, with a certain chance, they become sprinters. Where I should start from?

bright fog
#

Bcs that fully depends on that

terse delta
pulsar charm
terse delta
#

and else

bright fog
terse delta
patent lichen
#

can someone review some code snippets for me?

bright fog
#

When any of these actions happen, have a random chance that the zombie becomes a sprinter

silent zealot
#

My "minimum naked survival mod" plan would be:

Character spawns in a pre-chosen forest location
All items are removed from the player.
The area around the pre-chosen extraction zone is revealed on the map so they know where to go.
The expected path is a low zombie count area with some water source
The helicoptor event spawns every day.
On Day 21 if they have not extracted they catch fire, everything around them explodes, and if they are still alive they die anyway.
At the extraction point is something they can right click -> win game, and a "you won a prize!" noise plays/a message is displayed.

terse delta
#

Each condition has a tied chance

bright fog
bright fog
#

Which you shouldn't do

silent zealot
#

Obviously adjust the list because it's yoru mod and I've never seen the show

terse delta
bright fog
#

That would basically be the same thing

silent zealot
bright fog
#

The question is: why would you need a hidden property ?

terse delta
silent zealot
patent lichen
bright fog
pulsar charm
#

is road width tracked somehow in vanilla? im curious how you plan on implementing that

bright fog
#

Also don't associate a hidden property to every zombies, use a predeterministic random using the trueID of a zombie

bronze yoke
#

why so hostile doggy? if you want feedback on your code you can send it

silent zealot
bright fog
arctic shore
silent zealot
#

or a polyline, which has a specified thickness

#

or a polygon, which I will deal with when I get to them.

pulsar charm
#

cool approach. should be compatible with map mods then too no?

bright fog
silent zealot
pulsar charm
silent zealot
arctic shore
silent zealot
#

you absolutely can make it variable

#

With whatever logic you come up with

#

The reason I suggest picking pre-chosen spots is for this to work won't the player need a path with appropriate resources? e.g.: water, but no urban areas full of loot

#

Or maybe you intend loot rarity to be insanely low... it's all up to you, but the key thing is to have a list of specic and implementable things to work through to get the mod going, and you can build that list out as you come up with new idea/have time tom implemt more complex ones.

patent lichen
bronze yoke
#

i guess leading your answer with 'no' was misleading when you meant 'yes' 😅

patent lichen
#

It's all good, figured it was worth a shot.

arctic shore
silent zealot
#

I don't think anyone had hostile intent, we just want questions asked here instead of dragging people away to ask one-on-one

#

yup, lua.

arctic shore
#

i created a SandBoxOptions.lua on lua folder thats de description, but isnt works...

SandboxVars = {
Zombies = 1, -- None
Distribution = 1,
WaterShutModifier = 0,
ElecShutModifier = 0,
DayLength = 2, -- 2 = 1h = 1 dia
StartMonth = 7,
StartDay = 9,
StartYear = 1993,
Temperature = 3,
Rain = 3,
ErosionSpeed = 5,
FoodLoot = 1, -- Insanely Rare
WeaponLoot = 1,
OtherLoot = 1,
NatureAbundance = 1, -- Very Low
Alarm = 6,
LockedHouses = 6,
StarterKit = false,
Nutrition = true,
Helicopter = 1, -- Never
StatsDecrease = 3,
ClothingDegradation = 2,
InjurySeverity = 3,
BoneFracture = true,
InfectionMortality = 1,
LootRespawn = 1, -- None
SeenHoursPreventLootRespawn = 0,
}

silent zealot
#

A lot of this is stuff you want to do once when the game starts. So in your lua file, you make a function and attach it to the event OnNewGame. Then it runs the first time a player enters the world,

#

Typically you let the player choose their sandbox settings

#

And you recommend what they should be.

#

For a fixed scenario, you'd have to look at how the pre-made scenarios do it.

terse delta
silent zealot
#

You said you had the day being announced every day, so I assume you've already got a mod that loads properly and does something?

terse delta
#

Also, I wanna know if this is worthwhile. I won't do this if checks like this are too bad for performance

silent zealot
#

Have a look at available events:

#

You can attach a function to those events, and it will run your code when the event happens.

#

eg: OnHitZombie triggers when the player hits a zombie with an attack.

terse delta
#

I need SetZombieState or smth to change him

#

So, about predetermined random based on zombie ID...

arctic shore
terse delta
#

Let's say I want every fifth zombie to be hidden sprinter

silent zealot
#

then you set sprinter percentage to 20 in sandbox options

#

(in B42)

#

(there's a mod for that in B41)

arctic shore
terse delta
pulsar charm
#

I think your challenge will be turning a walker into a sprinter, not finding ways to trigger that

silent zealot
silent zealot
#

But all sprinters are hidden until they start to charge at you.

#

Or you see them running around in the distance

terse delta
#

Hidden sprinter is the zombie that behaves like normal walker until the condition is triggered. You fight zombie, smack him, bam, he is a sprinter now

silent zealot
#

Suggestion: you don't need to actually decide which zombies are sprinters

#

You need to trigger then to being sprinters at the appropriate time/with the appropriate chance.

#

Then player has no idea of the difference between "those three zombies sprinted at me because they were pre-chosesn to do so" and "those three zombies sprinted at me because of random numbers"

arctic shore
silent zealot
#

And if you want persistant zombies... do a search, there have been a few big discussions on it recently

silent zealot
#

Having a helicoptor appear as in actually see it will need something like a a helicopter vehicle mod or custom tiles, just playing the sound is easy though

arctic shore
terse delta
#

Cause if all zombies are going to check condition every update tick, I expect peformance getting worse exponentially with increasing amount of zombies

bronze yoke
#

you can't really tick 20% of zombies though

#

either way you're going to need some amount of code on tick for every zombie

sour island
#

You can set a max number of allowed processed zombies, but then you'd need a way to handle skipping previously processed ones to avoid reprocessing the same few

#

But there's always going to be overhead costs - and in most cases the code you're doing shouldn't be killing your computer

silent zealot
terse delta
#

To start I'd need a function that rolls some number on zombie getting hit, and attach a function that would change zombie speed

silent zealot
#

You wish out a sneaky way to check for the conditions you want with other events, and do the becomeSpinter stuff then

terse delta
#

Yup

sour island
#

Yeah, keep the footprint of the thinking elsewhere -- the ontick should just be if X true then do thing

odd parrot
#

Update of the code: im cooked queasy

silent zealot
sour island
#

Oh wait, yeah that's true - if the condition is combat

#

Something to note though -- zombies are a bit finicky when it comes to storing data, and you have to be careful. Unless you're ok with it resetting when unloaded due to exploration.

#

It's not recommended to use zombie modData (at least in b41) as it's not cleared when recycled -- same for using the object directly

silent zealot
#

You could also do things like a function that goes off every minutes, rolls a random number, if that pssses it picks a random nearby zombie and sprintifues it.

sour island
#

We've figured out you can use the unique outfit ID (with some trickery regarding hats dropped) but it depends how much depth you want in this feature

#

if you want persistence

silent zealot
#

Personally I think it's fine if it's not persistent; it's not about knowing which zombies are sprinters, it's about dealing with them when they sprint at you. If you escape and return, that exact same zombie doesn't need to sprint again

#

Id honestly not even worry about players quitting and reloading to reset sprinters, let people do that if they really want.

pulsar charm
#

seems like IsoZombie has a getter but no setter for canSprint

pulsar charm
silent zealot
#

That might be a function to day "can they sprint right now" not "are they a sprinter"

#

Eg: cant sprint when sitting, falling over, attacking etc

pulsar charm
#

ah true

terse delta
silent zealot
#

That why you fake it; when the condition happens, random chance to make a sprinter.

#

Story generator, not accurate simulator.

wide sedge
#

Just curious how hard is it to make a map?

#

Like a small-medium one

terse delta
#

Is that the right thing?

#

I hope so

silent zealot
silent zealot
pulsar charm
#

in IsoZombie.java:

silent zealot
#

Find some code that changes zombie speed using Lua. Look for the B41 mod that let you have random speeds

#

Check the java

#

In this case, you now need to look at what walk type does

terse delta
silent zealot
#

And also see if there is a field in there that holds the speed, probably as a enum slowsshambler shambler sprinter crawler

arctic shore
#

Naked and Afraid mod:

Steps completed:

  1. Player is born naked with only a cloth bag - OK (problem: being born without a belt in the inventory but the right and left belt options still appear in the shortcut bar)

  2. At 6 am every day the message x/21 days of survival appears - OK

Steps that I am not able to complete

  1. Create a designated extraction point on the map at the beginning of the game so that being in that location on day 21 it is possible to "win the game" (this could be the appearance of the helicopter event and a message "you won Naked and Afraid")

  2. Set the sandbox conditions such as lack of loot, amount of zombies, etc.

Could someone help me with steps 3 and 4?

silent zealot
#

For 3

#

local Extraction_x= 10545

#

local Extraction_y=890

terse delta
silent zealot
#

There, you have coordinates

terse delta
#

Force settings through a functions

silent zealot
#

(but use better numbers)

arctic shore
pulsar charm
#

you should look at existing mods

silent zealot
#

You already have a mod, right?

#

That has Lua in it?

arctic shore
silent zealot
#

"set an extraction point" is just deciding where it will be

#

If you're thinking "but that doesn't actually do anything" you're right

arctic shore
silent zealot
#

Why are those all in separate files?

#

...you didn't ask AI to write them, one by one, did you?

arctic shore
silent zealot
#

You can separate things into multiple files to make it easier to manage, but removing the starter gun and removing the starter belt...

#

Oh

#

No, sorry if that was not clear

#

Look at other mods, see how they do things, use that to help you write code

#

Don't just copy whole files over

arctic shore
#

when i tried to remove the starter pistol and bel on the same file doesnt works... i dont know hoe to mange the commands like end..onevent etc

terse delta
silent zealot
terse delta
#

You didn't hooked belt removal to an event

arctic shore
#

and the belt is bugged because it keeps appearing in the shortcut bar even though it's not in the inventory...

terse delta
#

Arent' you?

silent zealot
#

It's easy to pick up if you have done programming if scripting before

pulsar charm
#

I have a hunch he's very new to programming

#

which is definitely okay, you just need to learn some basics

arctic shore
silent zealot
#

But if you are completely lost, which I suspect you are, you're going to need to start with learning a bit about Lua in general

terse delta
#

It really makes things clear when you start

silent zealot
#

Don't ask AI to write code though

terse delta
silent zealot
#

Ask it how to do very specific lua things, then do then yourself

arctic shore
terse delta
#

when you provide enough of context, it starts to orient good enough

silent zealot
#

When you say "partner" I hear "someone to do all the work"

terse delta
#

He already made a few scripts

silent zealot
#

Did we not just establish those were from other mods?

terse delta
#

We all rip apart mods to get the functions prototypes drunk

arctic shore
#

I am very grateful for the help I have received here

silent zealot
#

I suggest stepping back and doing some lua tutorials if you have not programmed at all before

#

You don't need to be good at it, but you need to be able to understand the basic structure of the code

arctic shore
#

Furthermore, English is not my native language so it is more difficult to find content or interpret tutorials in English for me, but even so I am trying very hard.

silent zealot
#

Are there tutorials in your native language?

#

(also, your English is really good)

arctic shore
silent zealot
#

Ah, that explains some of the confusion/lost meaning

terse delta
#

Learning programming without tutorials is like jumping into foreign language environment without any preparation. You don't know anything, but your brain starts to understand things REALLY quickly

#

It is possible

#

By ripping apart already made mods

#

It became really easy when there's AI that can explain things to you

bronze yoke
#

to be honest i feel like the majority of lua issues i help with are caused by people jumping in without tutorials and not actually knowing how anything works 😅

arctic shore
#

It seems to me that it will take me hours to resolve issues that if I had a partner could be done in minutes.

#

Furthermore, I have no intention of being a modder, so this partner can take all the credit. It's not a problem for me, I just want to do the mod and I think it would be very interesting.

arctic shore
terse delta
#

(Open it in browser or download, you won't see it in discord)

#

You can question AI to describe you code, as I said, this is very effective

arctic shore
patent lichen
terse delta
#

Use this link

patent lichen
#

ah DEEP AI, now we can read it

#

thanks for sharing

arctic shore
terse delta
#

It was an invention for me

arctic shore
#

thanks

terse delta
#

AI catches up context really good

#

And elaborates syntaxis for you

#

That's not even AI for coding, just language model

tight elm
#

And AI is only helpful up to a certain point

#

I personally spent a lot of time banging my head against the wall over the code produced by the likes of ChatGPT, and I have a CS degree

arctic shore
bright fog
#

Digging through existing mods is a good idea tbf

#

It depends which mod

#

But if you find some decent mod, you can check how it works and reverse engineer the important bits

arctic shore
#

im still trying but its hard to identify the parameters for me...

bright fog
#

What parameters ?

arctic shore
#

all of them, im not used with programming

bright fog
#

That's why you can ask questions here

#

Go through code, and ask about the bits you don't understand

arctic shore
#

I don't understand anything and even so I managed to solve some steps of the mod I'm trying to make, but it seems that these next steps are more difficult without knowledge. I'm using other mods as a reference but they have so many folders and files that sometimes I don't even know where to start...

bright fog
#

Did you read the various wiki pages ?

arctic shore
#

a lot, and also videos...but still so hard..

bright fog
#

Did you read the Lua (language) page ?

arctic shore
#

i think so, but if you want to send me a link i aprecciate

arctic shore
bright fog
arctic shore
# bright fog What are the other 2 functions ?

This mod has the extraction function that I would like to implement. In my case, it would be much simpler than this, but when I look at the files, I don't even know where to start.

I would like to implement an extraction function that shows the map a location for the extraction of the player who finishes the game.

The conditions would be: be on day 21 of survival and light a fire. Then the helicopter event happens (the same one that already exists in the game) accompanied by a message that you have won.
https://steamcommunity.com/sharedfiles/filedetails/?id=2987772693&searchtext=extraction

arctic shore
# bright fog What are the other 2 functions ?

the other function would be to be able to have a fixed sandbox configuration for all players who use the mod, defining the number of zombies, loot and all other parameters that exist in the sandbox

bright fog
bright fog
#
  • detect day 21
  • detect the player is next to a fire on day 21
#
  • define a fixed coordinate valid for the campfire
  • define a random coordinate valid for the campfire (or multiple possible coordinates)
#

Go step by step

#

Start simple first

#

Break down what you're trying to achieve into numerous tiny tasks which sound less challenging than every bits together

arctic shore
bright fog
woven pecan
#

anybody know the api calls for integrating custom shaders in b42?

bright fog
#

Wdym by custom shaders ?

arctic shore
# bright fog I suggest breaking it down into steps

I managed to make a count of days with a message printed on the screen of x/21 days of survival, but making the extraction point and its conditions is impossible for me, I have no knowledge of the moon.... I managed to make them spawn without an item and without clothes, which was one of the objectives, but it seems that I can't advance any further.

woven pecan
#

like tree shadows moving in sync with the sun

bright fog
#

The ones I gave you I think are a good start

arctic shore
arctic shore
# bright fog No

Naked and Afraid is an extreme survival reality show in which two people (a man and a woman) are left naked in a hostile, wild environment — such as forests, deserts, or swamps — and must survive for 21 days.
They are given no food, water, or clothing, and are only allowed to choose one survival item each (such as a knife or flint). The goal is to reach an extraction point after 21 days, facing hunger, thirst, extreme weather, predators, and disease.

arctic shore
# bright fog The ones I gave you I think are a good start

detect day 21
detect the player is next to a fire on day 21
define a fixed coordinate valid for the campfire
define a random coordinate valid for the campfire (or multiple possible coordinates)

good goals, but i dont know how to do it....im never programmed before...

arctic shore
#

sry about my english, im using google translator

bright fog
#

I'll personally don't look at it

arctic shore
bright fog
#

And overall you can't expect people here to completely study your mod, that's usually way too much work that you are asking most people for

bright fog
#

Ok so, take the detecting a campfire problem

#

First off, what's the range ?

#

Is it a radius ? A square area around the player ?

arctic shore
#

The player needs to make and light the bonfire within the specified location for extraction and stay very close to it

bright fog
#

No no

#

Keep it simple

#

Does the player need to place the campfire at EXACT coordinates, or in an area ?

#

If it's at exact coordinates, that makes it easier bcs you just have to check that the square has the campfire (tho this brings the problem of making sure the player actually knows where to build the fire EXACTLY)

#

If it's an area, you got different ways to go about it

#

Depends on what you want as an "area"

arctic shore
#

a specific area of ​​approximately 10x10 squares but it can be a specific square as long as it is marked

bright fog
#

This is an interesting area, because you could use something that exists in the game

#

The map is divided in cells, which are divided in chunks

#

If you're on B41, a cell is 300x300 and a chunk is 10x10

#

In B42, it's 256x256 and chunks 8x8

#

So you could set a specific chunk as the one which should have a campfire in

#

The issue is that this fixes the borders of the area, so if you wanted to chose a specific border, you can't use chunks then

arctic shore
#

This, ideally, should be random each time the player starts a game.

#

I understand what you're saying but I have no idea how to program this

bright fog
#

Which is simple, because it involves generating two random numbers on creating a new save

arctic shore
#

Yes, but it is important that the player sees the position on the map even if the map is not yet fully open.

bright fog
#

Again

#

Keep it simple !

#

Problem per problem

arctic shore
#

Where would I start?

bright fog
#

Generate two random numbers

#

Which are your chunks coordinates

arctic shore
#

and how do I do that?

bright fog
arctic shore
#

I know less than that, for example, should I create a .txt file? a .lua file? What should I write in the file besides those random parameters that you sent me?

bright fog
#

That's Lua code

#

So you need a lua file

arctic shore
#

ok, i created it

bright fog
#

Where ?

arctic shore
#

Client folder

bright fog
#

That's good for now

arctic shore
#

🙂

bright fog
#

So your objective rn, is to use Random to generate 2 numbers when loading the Lua file

#

Try to do that

#

And print the numbers in the console to read what the output is

arctic shore
#

I've never programmed before, so I don't know how to print the numbers on the console...
I don't even know where to start the text of the file, you know? Excuse my ignorance

bright fog
#

Look it up

arctic shore
#

something like this:?
local random_instance = newrandom()

local coinFlip = function()
return random_instance:random(0,1) == 1

local randominstance = 10
print(randominstance)
end

bright fog
#

Yes !

#

And you can call this function

#

Tho

#

Kind of

#

there's mistakes

#

But that's a good start !

#
local random_instance = newrandom()

local coinFlip = function() -- creates a new function
    return random_instance:random(0,1) == 1 -- generate a 0 or 1, and if 1 then returns true, else false
end

print(coinFlip()) -- run the function, and print the result (return)
#

This will randomly give you True or False

#

So that's one usage of generating a random number

#

With comments

arctic shore
#

local random_instance = newrandom()

local extrationarea = function()
return random_instance:random(0,1) == 1
end

print(extractionarea())

#

so, now i put this file in client folder?

bright fog
#

Yes

#

Since you are calling the function in root, this will call the function when loading Lua

#

You probably won't see the print in the console because it'll be lost in-between lots of other stuff

arctic shore
#

How do I call the function at the root? What is the root?

bright fog
#

The core of your file

arctic shore
#

where i can found it?

bright fog
#

It's basically your file

#

For example

#
print("Hello World") -- this is in the core, and will run when your file gets loaded




local function OnPlayerUpdate(player)
    -- this will run every OnPlayerUpdate trigger
end

Events.OnPlayerUpdate.Add(OnPlayerUpdate)
#

Usually, you don't run stuff in the core, most of the time

#

In your case, you will have to do it in an event

#

An event which triggers when a new game is created

arctic shore
#

but the root is a file?

bright fog
#

I probably shouldn't have used these terms, this seems to confuse you a lot

#

core == root here

#

Tho you could argue technically the two words describe two different things

arctic shore
#

ok. it is a file?

bright fog
#

Remove this from your head

#

Just you have your lua file, and when the game loads it will run this file

arctic shore
#

i did this for my counter and it works

#

local lastNotifiedDay = -1

local function showDayMessage(day)
local text = "Dia de sobrevivencia: " .. day .. " de 21"

local panel = ISPanel:new(0, 0, 300, 50)
panel:initialise()
panel:addToUIManager()
panel:setVisible(true)

panel.render = function(self)
    local screenWidth = getCore():getScreenWidth()
    local screenHeight = getCore():getScreenHeight()
    local x = (screenWidth - self.width) / 2
    local y = screenHeight * 0.2
    self:setX(x)
    self:setY(y)
    self:drawTextCentre(text, self.width / 2, 15, 1, 1, 1, 1)
end

-- Remove após 5 segundos
panel.removeTime = getTimestamp() + 5
Events.OnTick.Add(function()
    if getTimestamp() > panel.removeTime then
        panel:removeFromUIManager()
    end
end)

end

Events.EveryTenMinutes.Add(function()
local player = getSpecificPlayer(0)
if not player then return end

local gametime = getGameTime()
local day = gametime:getDaysSurvived() + 1
local hour = gametime:getHour()

if day <= 21 and hour == 6 and lastNotifiedDay ~= day then
    showDayMessage(day)
    lastNotifiedDay = day
end

end)

bright fog
#

So anything which isn't in a function, will trigger instantly

arctic shore
#

but i have lots of lua files, one for each goal...

bright fog
#

Bcs you're telling me you don't know shit about programming so you didn't make this yourself ?

arctic shore
#

also did this and works too

Events.OnCreateLivingCharacter.Add(function(player)
if not player or not instanceof(player, "IsoPlayer") then return end

-- Remove todas as roupas
local inv = player:getInventory()
local wornItems = player:getWornItems()
for i = wornItems:size() - 1, 0, -1 do
    local item = wornItems:get(i):getItem()
    if item then
        inv:Remove(item)
    end
end
player:getWornItems():clear()
player:resetModel()

-- Adiciona uma bolsa improvisada (SheetSling bag)
local bag = inv:AddItem("Base.Bag_SheetSlingBag")
if bag then
    bag:setActualWeight(1.0)
    bag:setMaxWeight(8)
    bag:setName("Bolsa Improvisada")
    bag:setCustomColor(true)
    player:setClothingItem_Back(bag)
end

end)

arctic shore
bright fog
#

Then I invite you to read your codes, and figure out what's going on here

#

Try understanding this one


Events.EveryTenMinutes.Add(function()
    local player = getSpecificPlayer(0)
    if not player then return end

    local gametime = getGameTime()
    local day = gametime:getDaysSurvived() + 1
    local hour = gametime:getHour()

    if day <= 21 and hour == 6 and lastNotifiedDay ~= day then
        showDayMessage(day)
        lastNotifiedDay = day
    end
end)
arctic shore
#

I did it but I have no idea what I'm doing. At the moment I've managed to make my player born naked, just with a cloth bag and that every day at 6 am the counter appears on the screen

bright fog
#

Stop rn making random ass codes if you don't know they do

#

Read your codes

#

Figure out how these works

arctic shore
bright fog
#

I mean

#

Sort of

#

Some parts yes

arctic shore
#

Well, how do I call the function at the root?

frank elbow
#

I'd advise listening to Jvla's advice to become familiar with what the code is actually doing. A pretty good resource for that is Programming in Lua, for Lua 5.1—you can find this online. There are some things that don't apply to Kahlua (the version of Lua that PZ uses), but for the language itself it should teach you what you need to know

#

If you prefer to learn from videos rather than reading, there are plenty of those too & if anything is unclear you should feel free to ask general Lua questions here as well

fresh lodge
#

What is the correct command for accessing fluids? (b42)

item = ScriptManager.instance:getItem(name) -- for items
recipe = getScriptManager():getCraftRecipe(name) -- for recipes
-- ??? for fluids
fresh lodge
#

yes getFluid() is correct