#mod_development

1 messages · Page 106 of 1

red tiger
#

I can take my generated data for the code and raster documentation JSON from it.

#

Definitely willing to help with the documentation arc for PZ. <3

thick karma
#

Thanks so much A) for your answer, and B) for being so addicted to improving this game that your offtime side project is to improve the game.

ancient grail
#

Yeh wolfie for the win

robust briar
#

Anyone know off the top of their head how to detect if the current client is still loading chunks?

weak sierra
#

lmk if u find something that works reliably ive tried almost every piece of linux software for it with no luck

#

ill run windows software if i must

#

lol

robust briar
#

In regards to chunk loading, I have found WorldStreamer in Java, just have no idea to how to get an instance of it in Lua

ancient grail
#

Gravy what u building bud?

robust briar
#

A customizable loot respawner

#

more fine grained control than the built in one

fast galleon
robust briar
# fast galleon How do you do stuff while chunks are loading?

Afaik chunks stream in another thread. Like when your driving and you get "stopped" because the chunk has not loaded yet. I want to teleport a player, then wait until all chunks are loaded to continue the script. I just need a way to determine if there are chunks still loading

#

I should say this is for MP

fast galleon
#

ah, so wait for sync on client.

zinc pilot
#

is there any best practices for adding body locations?

fast galleon
tame mulch
nova socket
#

Dear devs if you can hear this please give some pointer to any pathfinder or its options so it still will try to find a way to occupied cell pathFindBehavior2 does seem return unsuccessful results instantly trying to reach the cell cancelling actions.

#

square* not cell

#

or maybe some test or function find closest accessible square

red tiger
#

@pulsar heath could make some kind of API utility workshop item. (Or a GitHub repo containing the code to paste into projects)

#

Would be helpful to the community.

bronze yoke
vague raven
#

Is there any easy way to get a list of all the chunks in a cell?

nova socket
red tiger
nova socket
nova socket
#

Hm, you can theoretically create items procedurally

#

InventoryItem has constructor
constructor(arg0: string, arg1: string, arg2: string, arg3: string | zombie.scripting.objects.Item);

red tiger
fast galleon
sour island
#

Someone on my workshop is suggesting to edit my mod manually to 'fix' something changed over a year ago... if people modify the lua files on their end does steam just not update those files?

fast galleon
#

weird typo
*does this game support mom editing

sour island
#

They state a line # and contents that doesn't correspond - but I was able to go back through github to find when it would be relevant - February of 2022

fast galleon
cosmic condor
#

If you don't update the mod then no

sour island
#

I'm thinking, steam doesn't remove added files - or files that we as modders remove -- so it's probably working off a checksum - perhaps they skip files that don't match the last checksum too?

#

I've edited other's mod for debugging compat issues and steam doesn't download over it

cosmic condor
#

Stream will force replace the edit files only when the mod author update it

#

Another surplus files will still be there if you make some changes

sour island
#

I'm testing it... if i change a file it doesn't get removed when I unsub

#

not just that file, the whole mod

#

wait had the game running

#

oops

#

nope removes everything

#

I guess this guy manually moved the mods over

fast galleon
#

true, files from intellij for example won't be removed

sour island
#

I'm just at a loss

#

people will really do all sorts of weird stuff

cosmic condor
#

Steam should delete only the files with the same hash

#

If you made some changes, it won't get removed

#

The mod folder will be missing when you unsubscribe, but it will come back when you resub

#

That's from my observation

bronze yoke
#

i had someone complaining about a mod incompatibility pointing me to a file that wasn't in either mod

spare burrow
#

Anyone knows how to influence or modify fence vaulting trip chance?

undone elbow
#

How to make that the unhappiness doesn't affect my custom action?

bronze yoke
#

overwrite adjustMaxTime(maxTime) on your timed action, or overwrite create() to not call it

rancid panther
#

thanks! i'll try these out!

thick karma
fervent oar
#

Does anyone have Save our Station working on a dedicated server?

#

There are a bunch of fixes and updates and it's a little confusing

nova socket
red tiger
#

Also: That moment when you have transpiled tuple return types.

nova socket
#

I see what Jab wants.

#

He wants to convert Lua to TS and force everyone to use it.

#

Its like TSC (TypeScriptCommunism)

red tiger
#

It's only a suggestion

sick umbra
#

Is there a way to make weapons shoot faster? I'm planning to look at the Brita's Weapon Pack code but if anyone got a quick answer I'd be glad

red tiger
#
local saySomething2 = function(text)
    print(text);
    return 'hi', null;
end
let saySomething2 = function(text: any): [string, null] {
    console.log(text);
    return [ 'hi', null ];
};

@nova socket Are you not entertained?

nova socket
#

Unofortunately incoming args types would always remain any and its up to individual to fix it dismelSad

red tiger
#

Hahaha not so much true with my solution.

nova socket
#

You wanna reverse the type of variables?

red tiger
#

I'm implementing a walk phase for "Type-Discovery".

nova socket
#

oh I see

red tiger
#

Yes and it's already partially done.

nova socket
#

Yeah, that's dope

red tiger
#

All statements and expressions and their expression sub-components will be ordered with unique path IDs and those references will be compiled as potential type candidates.

nova socket
#

at least generic types would recognizible, or you wanna really dig into classes return too?

#

like class -> method returns?

red tiger
#

Fields, parameter expressions, etc.

#

Going to do linking with requires too.

#

I will take = table:derive() and identify pseudo-class structures.

nova socket
#

mm

red tiger
#

class being internally handled as extensions of tables with constructors.

#

I should make the class detection and implementation component as a plugin or something.

nova socket
#

Yeah we don't really have any direct access to Java environment If I'm not mistaken

red tiger
#

Maybe an adapter.

#

(TS classes)

#

I already do this with my first rendition for TypeScript declarations.

#

What sucks is that version not having any type discovery.

nova socket
#

Reversing the types would be a big step forward, leaves you guessing what sort of 3 string that is in there.

#

or 3 numbers when its not obviously a xyz function

red tiger
#

It can get nasty though if you have sub-class methods that restructures itself as either different returns, parameters, visibility scope etc.

#

Oh wait.. Lua doesn't know what a private is.

nova socket
#

nope, no static, no private. Scope is determined solely by locality of your table(interface)

red tiger
#

Yup. Was a joke lol

nova socket
#

ah

red tiger
#

Apparently JS has private using #

nova socket
#

Didn't even knew that JS had private at all

#

only static

red tiger
#

Lua and ES5 JS are very similar.

nova socket
#

Besides JS is OOP

red tiger
#

Most of my JS coding career is ES5.

#

ES6+ is OOP

naive crescent
#

How do you post code here in those expandable boxes?

nova socket
#

ES5 wasn't OOP?

red tiger
#

Nope.

#

You had to use prototype

#

It's much like metatable

nova socket
#

```JS
code
```

red tiger
#

For my situation, I'll have to construct classes through ES5 logic.

bronze yoke
#

```lua
in most cases

nova socket
red tiger
#

It doesn't mean I won't use the class syntax in TS. It means I have to interpret the Lua code differently.

#

It's why I commonly refer to Lua classes as "pseudo-classes".. because it is literally just that.

#

Lua can support OOP.. It doesn't mean it is packaged with OOP.

#

Same with ES5 JS.

nova socket
red tiger
#

Kotlin-script too.

nova socket
#

TypeScript if for anything that looks like application.

#

I wouldn't say that JavaScript is suitable for L7 solutions, not like it cant but still.

red tiger
#

It's not at any complaint or diss towards Lua OOP projects going on in here.. I feel like I'm being honest about my desire to have OOP support and guard-rail / type-safety checks by simply going to TS rather than implementing it inside of Lua, which it isn't designed to do.

nova socket
#

Lets remember that JS doesn't have types either.

red tiger
#

I don't use a language for a solution that it isn't designed to handle.

red tiger
nova socket
#

I sometimes have feeling like TS first concept was somebody "fuck that, I want to know types"

red tiger
#

Hahaha

#

TS is beyond simply compiling to JS though.

#

A lot of people get trapped in that mindset that it's only designed for JS.. even though TS is a superset of JS.

#

It's so goddamn flexible and intermediary that it is a pseudo-language in a technical sense of the definition.. A Haxe but actually useful.

nova socket
#

I mean bruv, I completely undestand what you saying. I managed to fully describe my needs to operate with RAGE Engine on pure TS.

red tiger
#

Apparently a lot of Warcraft modders use TSTL.

#

So yeah.. I love the phrase "TypeScript Communism"

#

hahah

nova socket
#

Its simply enough flexible to just study it for being hand.y

red tiger
#

"From each according to his interface, to each according to his implementations".

nova socket
#

It's like frontenders with their React and Angular. Like you can do your own, but why if its either first or second.

red tiger
#

Well you could write any kind of transpiler extending from TS and have any TS code transpiled to it.

#

What's to stop me from converting Lua to TS, to Java?

nova socket
#

None, but your will to do it pretty much.

red tiger
#

Exactly.

#

My drunken ass started this 2nd transpiler yesterday lol.

#

Either I have a lot of willpower or I'm silly enough to waste my time on these projects. <3

naive crescent
#

I'm trying to overwrite variables of items and I cant just seem to get it to work. As an example I'm just trying to change the name only in dried chick peas the game seems to recognize the Item Dried Chick Peas is overwritten because when I mouse over the item it'll tell me mod: ChickenPeas but the item name still remains Dried Chick Peas. I'm aware there is an Item editor but I don't want to use it in this case.

module Base
{
    item DriedChickpeas
    {
        DisplayName = Chicken Peas,
        DisplayCategory = Food,
        Type = Food,
        Weight = 2,
        Icon = DriedChickpeas,
        EvolvedRecipe = Soup:10;Stew:10;RicePot:10;PastaPot:10,
        FoodType = Bean,
        Packaged = TRUE,
        HungerChange = -60,
        ThirstChange = 60,
        UnhappyChange = 40,
        Calories = 2851,
        Carbohydrates = 544,
        Lipids = 0,
        Proteins = 181,
        WorldStaticModel = DriedChickpeas_Ground,
        Tags = DriedFood,
        EvolvedRecipeName = Chick Pea,
        Override:true,
    }
}    

nova socket
#

However I'm too new to know if you can set a load order for scripts in any way.

naive crescent
#

Its odd that the game says Dried Chick Peas now comes from my mod but the values dont change. Maybe someone else will know the answer. This is my first time dabbling in modding scripts and the only work around I can think of is using the obsolete function and just creating a whole new item but I doubt it will let me use that as well.

robust briar
naive crescent
nova socket
naive crescent
#

OBSOLETE = true,

sour island
#

You guys know that display name and category get translated right?

naive crescent
#

Any reason why I shouldnt use this or just curious?

naive crescent
#

Big ass brain fart right there

sour island
#

Adding a script occupying the same ID will overwrite the old one

#

Recipes are a different matter

naive crescent
sour island
#

Happens alot unfortunately

true vault
#

Alright so, need some assistance; where would I find where I can change the requirements for the basic wooden wall and door frames?

Ideally I would like to add an alternate recipe for each rather than overwrite, but either will do for now.

naive crescent
# sour island Happens alot unfortunately

development can be a cruel but I got to walk away with learning an easy way to do it and a more complicated way to do it that I figured out all on my own. Thats a win in my books.

true vault
naive crescent
robust briar
#

Anyone know a a reliable way to detect in mp if the client is still loading chunks?

true vault
true vault
true vault
bronze yoke
#

the base structures are defined in lua

true vault
#

Okay, so I'm thinking the multistagebuild that's in the scripts folder. Should I be checking elsewhere?

bronze yoke
#

you should be checking the lua folder

#

all the build menu stuff is just hardcoded

#

or as 'hard' coded as lua gets anyway

robust briar
#

I found a class in Java called WorldStreamer but it doesn't seem to be accessible from Lua

bronze yoke
#

it's not designed in the least for extensibility and the code is even ugly as hell to boot

true vault
bronze yoke
robust briar
bronze yoke
#

so why do you need to teleport a player and test if chunks are loaded?

true vault
#

Would it not be possible to detect when a chunk is loaded somehow, and use that to daisy-chain you functions?

No need to force-check it's loaded, if an event/function was fired by the client because it loaded.

robust briar
#

I hijack the right click respawn mechanism to refill the containers. Only way I know to do that is to have it done on client. Everything is working perfectly except once in a while some containers are missed because the chunk isn't loaded yet when I trigger the search for containers

true vault
#

I don't know if the base game includes something like an onChunkLoad(), but that would be where I would start looking, if it does.

robust briar
#

All the simple ideas I have burned though

bronze yoke
#

i have a mod that needs to run on chunk load and it just uses LoadGridsquare and modulos the coordinates

robust briar
#

LoadGridSquare... Searching now. If this works I'll save a special place in my heart for you forever

bronze yoke
#

keep in mind loadgridsquare is pretty notorious for its performance hit - i use every performance trick i know when i have to work with it

true vault
#

Alright, I'm finding the parts that create the build menu itself, but I'm not seeing where the requirements for each piece are. Like for example, wood wall frame requires 2 planks and 4 nails.
I am either blind, or not sure what I'm looking at here.

robust briar
rancid panther
#

im starting to wonder if it is even possible to make a character start bitten with profession framework

#
ProfessionFramework.addTrait("Bitten", {
    name = "UI_trait_Bitten",
    description = "UI_trait_Bittendesc",
    cost = -10,
    OnGameStart = function(trait)
        Events.OnCharacterCreateStats.Add(function()
            local player = getSpecificPlayer(0)
            if player:HasTrait("Bitten") then
                player:getBodyDamage():getBodyPart(BodyPartType.ForeArm_L):SetBitten(true, true)
            end
        end)
    end
})
#

i think i have tried every combination of suggestions and ideas from reading other posts in this chat

naive crescent
#

Take a look at the extended traits mod, it has a trait for injured

#

Id use that as a base

rancid panther
#

i have looked at that mod and it has like 500 ZombRand rolls for random injuries and the types of injuries, but none of them are bitten

bronze yoke
#

what is OnCharacterCreateStats? i don't think that event exists anymore

rancid panther
#

and all i wanna do is make it a guaranteed bite

bronze yoke
#

iirc the OnGameStart function will be called automatically when a character is created with that trait, you don't need to add it to an event

rancid panther
rancid panther
bronze yoke
#

if you want to capture player creation only once, use OnCreatePlayer and set a mod data on the player

rancid panther
#

replace OnCharacterCreateStats?

bronze yoke
#

then if you function checks for that moddata before running it won't run more than once

rancid panther
#

oh wow. i have no idea what any of this means

#

i dont know how to code and this is my first mod, but i wanted to add this feature

bronze yoke
#

but i think profession framework probably already does htat

#

let me check what OnGameStart actually does

rancid panther
#

how do i check that? or the list of all this game's vocab and what they do

naive crescent
#

You learn through skimimng code

rancid panther
#

i figured

#

i found a thing about zombie damage from a dif post on here that i was trying to understand

bronze yoke
naive crescent
#

I dont want to sound like a dick but maybe take a deep breath or a break. I can tell through discord how frustrated you are right now.

rancid panther
#

other mods i have looked at that use profession framework use repeating events (like neurodiverse traits)

rancid panther
bronze yoke
#

the basic idea is like

Events.OnCreatePlayer.Add(function(_index, player)
    local modData = player:getModData()
    if modData.yourModData then return end
    -- the actual code for adding the bite goes here
    modData.yourModData = true
end)
naive crescent
#

Do you understand what all of that means? We can break it down for you if you dont

rancid panther
#

everything i have done so far involves just adding stats and items, so this is completely different from what i've done before

bronze yoke
#

i'm not sure if going through profession framework will actually help in this case, you might just want to add this to that event directly

rancid panther
#

that's what i figured, but i had issues when i tried doing some things with profession framework and some things without

#

unless i just make a completely new mod that only adds a bite trait so i dont have to worry about the rest

bronze yoke
#

in that case the only change you really need to make is like

Events.OnCreatePlayer.Add(function(_index, player)
    if not player:HasTrait("TraitName") then return end
    local modData = player:getModData()
    if modData.yourModData then return end
    -- the actual code for adding the bite goes here
    modData.yourModData = true
end)
#

(actually this would be needed even if you went through profession framework... disregard the first one)

rancid panther
#

and then the moddata stuff is that code about the get body part and add damage etc?

#

what happens in the first instance of modData.yourModData vs the second time? i assume i dont write the same thing there twice

bronze yoke
#

at the first point, we check if it's already been set, and if it has we just cancel the function

#

at the second point we actually set it

rancid panther
#

oh i see

bronze yoke
#

that way the function only runs if it has never run before

rancid panther
#

so do i change yourModData to what im actually doing?

bronze yoke
#

yeah, you can call it whatever you want

rancid panther
#

so like giveBite? or something

#

did i do this right?

#

if it doesnt work cuz im using prof framework then i'm ok with not having this on my mod. just wanted to see if i could do it. it's just for personal use

naive crescent
#

No. local modData is just a place holder name.

rancid panther
#

i see

naive crescent
#

Its asking you to name a local variable

#

so I would name it something like local playerIsBitten

#

'local' means that variable can only be used inside the script or function depending how you use it. It stops it from being a public variable which can be called from other places that you dont want.

#

playerIsBitten is a bit unique but when you name a variable 'speed' for example. You could have a ton of other functions or scripts that have theyre own speed variable and can accidently call it when you dont want to.

#

Someone correct me if im wrong anywhere. Ive been coding for many years but this is my first time trying to explain

rancid panther
#

i understand

#

but what do i do about the yourModData part? i see we set a variable for local modData, but i dont understand what to do with getModData or yourModData

naive crescent
#

that part to im a little confused about too. Lua is still new to me.

rancid panther
#

i see. thanks anyways

#

i'll just tinker around with this

naive crescent
#

The idea is though is the if statement is checking to see if what its suppose to do has already been done to you.

rancid panther
#

so is it something i can/should change as well? i was thinking i would change it to CheckForBite or something?

naive crescent
#

In the method there is modData.yourModData = true at the bottom, that means all the code thats suppose to be above it gets called, thats where youll add the logic for being bitten.

#

Yes that would be a good one

rancid panther
#

so is my code for the bite in the wrong spot atm? should it go below the true statement?

naive crescent
#

The code runs from top to bottom so when the if statement is false it will start with your logic to make yourself bitten then make a boolean true.

rancid panther
#

oh okay

#

so it is in the right spot? or it doesnt really matter since the check already happened by then?

naive crescent
#

After that the if statement 'if modData.yourModData' is now true so its stop it from running the if statement again

naive crescent
#

Which part of it?

rancid panther
#

the player:getBodyDamage goes above the true or below? or doesnt matter

naive crescent
#

above

rancid panther
#

ok

naive crescent
#

modData.yourModData = true stays at the very bottom

#

If you have it on top the code will turn the boolean true before any of the other code gets to fire off

rancid panther
#

and once all that is settled i just need to make sure i'm actually properly assigning a bite to the forearm?

naive crescent
#

Something like that

#

Its looking much better

#

But you need to work on your code format. Its incredibly hard to read.

#

Can you send it over in that grey box thing

#

ill clean it up and show you what I mean about code format

rancid panther
#
ProfessionFramework.addTrait("Bitten", {
    name = "UI_trait_Bitten",
    description = "UI_trait_Bittendesc",
    cost = -10,
    OnGameStart = function(trait)
        Events.OnCreatePlayer.Add(function(_index, player)
            local player = getSpecificPlayer(0)
            if not player:HasTrait("Bitten") then
                return end
            local PlayerIsBitten = player:AssignBite()
            if PlayerIsBitten.CheckForBite then
                return end
            -- the actual code for adding the bite goes here
            if player:HasTrait("Bitten") then
            player:getBodyDamage():getBodyPart(BodyPartType.ForeArm_L):SetBitten(true, true)
            PlayerIsBitten.CheckForBite = true
            end
        end)
    end
})
thick karma
#

I would write a conditional as short as

if not player:HasTrait("Bitten") then
  return end```
as
```if not player:HasTrait("Bitten") then return end```
personally...
naive crescent
#

Thats what I was talking about

rancid panther
#

i see

thick karma
#

But if not that, then

if not player:HasTrait("Bitten") then
  return 
end

is also standard.

rancid panther
#

i see

thick karma
#

But never return end because you make it look like end is the thing that you are returning

rancid panther
#

i see

thick karma
#

You are not returning end, you are returning nothing at all (a.k.a. nil in Lua, null in Java)

#

You delimit the end of the if block using end.

rancid panther
#

u helped me earlier with the SetBitten(true, true) thing earlier right? thank u for that

thick karma
#

Did that work?

rancid panther
#

i still havent figured out what im doing wrong tho

#

no, but im sure i can figure something out

thick karma
#

Did you try that command in debug console?

#

/ do you know how

rancid panther
#

-debug mode?

thick karma
#

Yes

rancid panther
#

i havent

thick karma
#

Would be a good place to start, just to make sure you even have the right command for making yourself bitten

rancid panther
#

as in run it without the mod activated? or with the mod

thick karma
#

You don't need a mod to call getPlayer():getBodyDamage():getBodyParts():get(3):SetBitten(true, true)

#

Or alternatively the form of the command you were using above

#

getPlayer():getBodyDamage():getBodyPart(BodyPartType.ForeArm_L):SetBitten(true, true)

#

That's a vanilla command

#

Should work from debug to make you bitten

#

At least... that's the dream

rancid panther
#

and i have seen ppl use getPlayer and getSpecificPlayer and player

im assuming player is just the local term, but what about the other two

naive crescent
#
ProfessionFramework.addTrait("Bitten")

    name = "UI_trait_Bitten",
    description = "UI_trait_Bittendesc",
    cost = -10,
    OnGameStart = function(trait)
    local player = getSpecificPlayer(0)
           
    
    if not player:HasTrait("Bitten") then return end
        local PlayerIsBitten = player:AssignBite()
        
        if PlayerIsBitten.CheckForBite then return end
            
            if player:HasTrait("Bitten") then
            
               player:getBodyDamage():getBodyPart(BodyPartType.ForeArm_L):SetBitten(true, true)
               PlayerIsBitten.CheckForBite = true
            end

        end

    end

    Events.OnCreatePlayer.Add(function(_index, player)

This is what I mean by code structure, what I wrote here is not correct at all in syntax since I dont have time to correct everything but you need to make it easier to read

rancid panther
#

is getspecificplayer for splitscreen?

thick karma
#

getPlayer() gets player 0, getSpecificPlayer(X) gets player X

rancid panther
#

ic

naive crescent
#

You should look at the PZ lua files and observe how they place everyhing like indent functions and follow that.

rancid panther
#

in debug mode can i just keep testing the mod without exiting the game and reloading then by resetting lua?

naive crescent
#

Its the standard for code structure

#

yes

#

as long as your only editing the logic in the lua script. You gotta reload the lua script first though

#

its in the f11 menu

rancid panther
#

what are the shortcuts for reopening the console and stuff after closing them?

naive crescent
#

then you find your script in the list click it then click reload. If its not there its because theres a major error in your script and the game removed it

#

If your talking about the console in the bottom left hand corner of the screen, I have no idea

rancid panther
#

okay so the bite actually works the way i have it

#

tested in debug

thick karma
#

Nice

naive crescent
#

Awesome, now you just gotta figure out how to make the code work.

rancid panther
#

yes. ah the bane of my existence

#

i cannot just copy a framework and type silly numbers anymore

naive crescent
#

Id start with you () {} markers

#

They seem to be all over the place

rancid panther
#

the ones on the outside r from profession framework

thick karma
rancid panther
#

here is an example of a trait that works properly, because im not using Events

#

and because it is just in the format of profession framework

thick karma
#

I have no idea how events work in that addTrait function but have you considered simply adding the bite OnCreatePlayer like I originally recommended?

rancid panther
#

and here is a profession framework example of a special trait

thick karma
#

I don't know if it would work

rancid panther
#

yeah i tried it but i was probably doing everything else wrong

#

so none of my attempts have given the player a bite so far

thick karma
#
Joy.biteMe = function(playerIndex, player) 

  if player:HasTrait("Bitten") then
    player:getBodyDamage():getBodyPart(BodyPartType.ForeArm_L):SetBitten(true, true)
  end

end

Events.OnCreatePlayer.Add(Joy.biteMe)
naive crescent
#

Keep at it man, trust me the high and sense of accomplishment youll get when it finally works is worth all the trouble

true vault
#

lolz... Joy -> Bite Me

thick karma
#

lol thanks

rancid panther
#

thank u. i have been trying and failing for hours

true vault
#

Might I request a look at the question I asked earlier @thick karma? Not sure you'll be able to help, but I think I've caused myself temporary blindness staring at files the past hour or so jaja

thick karma
#

I mean I dunno if I'll know but I'll definitely take a look! lol

naive crescent
true vault
#

I've found just about everything related to building things, minus the one part I meed; actual definitions that get passed to the functions, indicating the required material(s).

naive crescent
#

Perseverance is the key ingredient.

thick karma
#

@rancid panther Fwiw, I think something like this would bite a random part:

Joy.biteMe = function(playerIndex, player) 

    if player:HasTrait("Bitten") then
        local part = ZombRand(player:getBodyDamage():getBodyParts():size())
        player:getBodyDamage():getBodyParts():get(part):SetBitten(true, true)
    end

end

Events.OnCreatePlayer.Add(Joy.biteMe)
#

Haven't tested it but it looks right

rancid panther
#

i see

thick karma
#

(getBodyParts() just returns a Java ArrayList of BodyPart objects, so things like add, get, remove, contains, and size are available on the object)

#

@rancid panther And if you want to make sure player is only bitten once, you do this:

Joy.biteMe = function(playerIndex, player) 

    if player:HasTrait("Bitten") and not player:getModData().bitten then
        local part = ZombRand(player:getBodyDamage():getBodyParts():size())
        player:getBodyDamage():getBodyParts():get(part):SetBitten(true, true)
        player:getModData().bitten = true
    end

end

Events.OnCreatePlayer.Add(Joy.biteMe)
thick karma
# true vault Might I request a look at the question I asked earlier <@470376476445900801>? No...

@true vault You try modding this?

ISBuildMenu.onWoodenWallFrame = function(worldobjects, sprite, player)
-- sprite, northSprite, corner
    local wall = ISWoodenWall:new(sprite.sprite, sprite.northSprite, sprite.corner);
    wall.canBarricade = false
    wall.name = "WoodenWallFrame";
    -- set up the required material
    wall.modData["xp:Woodwork"] = 5;
    wall.modData["need:Base.Plank"] = "2";
    wall.modData["need:Base.Nails"] = "2";
    wall.health = 50;
    wall.player = player;
    wall.completionSound = "BuildWoodenStructureLarge";
    getCell():setDrag(wall, player);
end
#

(in ISBuildMenu.lua)

true vault
#

facepalm I didn't even see that, no.

Sadly, I was even in that file already too, further up lolz

#

I'll try that now, thanks!

thick karma
#

I searched all the lua/script files for WoodenWallFrame to see what the Lua did with them

#

Fwiw

true vault
#

I tried using the Windows equivelant of GREP and it didn't turn up anything for "woodenwall" string ;-;

thick karma
#

You should index your ProjectZomboid folder.

#

And your Steam/steamapps/workshop/content/ folder

#

Then you can just search in Windows.

true vault
#

huh... didn't realize indexing worked on file contents

frozen leaf
#

sorry, wrong channel

rancid panther
#

when i try to give the player a bite with the mod enabled, i get this error

my mod removes the vanilla professions

#

same way i used console to add a bite without the mod

thick karma
#

@true vault This seems like the best way tbh . . .

#

Lets you just right click folders and index them, and tell yourself why.

#

shrug

thick karma
#

Or just post your console.txt from %userprofile%/Zomboid/

true vault
# thick karma <@275129919598755840> You try modding this? ```lua ISBuildMenu.onWoodenWallFrame...

Sadly, this didn't quite work either;

ISBuildMenu.onWoodenWall = function(worldobjects, sprite, player)
    -- sprite, northSprite, corner
    local wall = ISWoodenWall:new(sprite.sprite, sprite.northSprite, sprite.corner);
    if getSpecificPlayer(player):getPerkLevel(Perks.Woodwork) >= 8 then
        wall.canBePlastered = true;
    end
    wall.canBarricade = false
    -- set up the required material
    wall.modData["wallType"] = "wall";
    wall.modData["xp:Woodwork"] = 0;
    wall.modData["need:Base.Plank"] = "3";
    wall.modData["need:Base.WoodenNails"] = "3";
    wall.player = player;
    getCell():setDrag(wall, player);
end

ISBuildMenu.onWoodenWallFrame = function(worldobjects, sprite, player)
-- sprite, northSprite, corner
    local wall = ISWoodenWall:new(sprite.sprite, sprite.northSprite, sprite.corner);
    wall.canBarricade = false
    wall.name = "WoodenWallFrame";
    -- set up the required material
    wall.modData["xp:Woodwork"] = 0;
    wall.modData["need:Base.Plank"] = "2";
    wall.modData["need:Base.WoodenNails"] = "2";
    wall.health = 50;
    wall.player = player;
    wall.completionSound = "BuildWoodenStructureLarge";
    getCell():setDrag(wall, player);
end

doesn't throw any errors, but doesn't change the build menu options either crying

rancid panther
thick karma
#

Error suggests you wrote getPlayer somewhere you meant to write getPlayer()

rancid panther
#

ah

thick karma
#

It thinks you want to access a table but it's a function

#

It assumes table because no parentheses

rancid panther
#

i just did that with getSpecificPlayer(0) and it worked fine so i missed that with getPlayer

#

but the character is not losing health or taking damage

#

lemme check if they will get sick if i fastforward

#

yeah they are anxious now

thick karma
#

Do they show up as bitten? They may still turn eventually.

#

I do not know.

rancid panther
#

yea they seem properly infected

thick karma
#

I would just accelerate the rate of turning to test it

rancid panther
#

just without the bleeding, which im fine with. i think this might actually be better

thick karma
#

Make players turn super fast

rancid panther
thick karma
#

You may be able to deliver an artificial injury with it, I'm not 100% sure how to fake a bite wound.

#

Interesting...

rancid panther
#

and now i am losing health, just not from the wound

thick karma
#

Could be hunger though

rancid panther
#

drank water and ate

#

also i am bleeding on the floor. the rate is just not changing and im not taking damage from it

#

make a player who starts out bitten, for ppl who want a rush to find a cure or force themselves to play a short game

#

to work with a mod that adds a cure or delays infection speed

#

lol

true vault
thick karma
#

Ohhhhhh I did not see what you changed, got it.

#

Are WoodenNails vanilla items?

#

Is Base the proper module?

#

Idk tbh

#

Never seen them

true vault
#

I placed them in Base, yes. Crafting the nails themselves works.

#

I might have figured something out.
Testing it out now

thick karma
#

@rancid panther Try adding damage

#
Joy.biteMe = function(playerIndex, player) 

    if player:HasTrait("Bitten") and not player:getModData().bitten then
        local part = ZombRand(player:getBodyDamage():getBodyParts():size())
        player:getBodyDamage():AddDamage(part, 0.5)
        player:getBodyDamage():getBodyParts():get(part):SetBitten(true, true)
        player:getModData().bitten = true
    end

end

Events.OnCreatePlayer.Add(Joy.biteMe)
#

I just died of bite that way

naive crescent
rancid panther
#

i see. i'll try to get the other stuff to work first, but i actually think i like that it is a non-damaging bite

naive crescent
#

Its come to a point I dont know whats vanilla or not anymore

naive crescent
rancid panther
#

it is open, but i'll probably give them a bandage on spawn

#

as it is, the wound is open

thick karma
#

Actually, it works @rancid panther

#

This will work fine:

Joy.biteMe = function(playerIndex, player) 

    if player:HasTrait("Bitten") and not player:getModData().bitten then
        local part = ZombRand(player:getBodyDamage():getBodyParts():size())
        player:getBodyDamage():getBodyParts():get(part):SetBitten(true, true)
        player:getModData().bitten = true
    end

end

Events.OnCreatePlayer.Add(Joy.biteMe)```
#

I just tested it

#

And died purely of infection

#

You need to turn down the time it takes to die of infection

true vault
#

Aww shizz, it works.... now to figure out how to allow players to use both nails and wooden nails, instead of wooden nails only... lmfao

thick karma
#

I turned mine down to 0-30 seconds and died quite quickly

rancid panther
#

ok. this is tested purely as just that command tho?

#

i mean like with a trait without using profession framework

thick karma
#

Unless there's a cool tag someone knows about for either:or

true vault
#

That would be great TBH; if there was a way to get the funciton to look for any item tagged as "nail". Would make further mods so much easier.

thick karma
#

@rancid panther I sent these three lines via debug console:

        local part = ZombRand(player:getBodyDamage():getBodyParts():size())
        player:getBodyDamage():getBodyParts():get(part):SetBitten(true, true)
        player:getModData().bitten = true

And died quickly thereafter and became a zombie.

rancid panther
#

ah

thick karma
#

So if there is an issue in your process, it's elsewhere.

#

those lines work.

rancid panther
#

it may just be an issue with using profession framework

thick karma
#

(obv the .bitten thing isn't even necessary in retrospect for the test, I just grabbed the inside of the if statement real quick)

rancid panther
#

i could probably make a standalone mod just for the bite

thick karma
#

I have no clue how that framework works

#

Are you adding a profession or a trait??

rancid panther
#

this is a trait

#

the framework allows for both, but it might not work for making a bite, or i need to do work outside of the framework to enable it

thick karma
#

Why not

-- Or use your local module.
local Joy = Joy or {}

Joy.bittenTrait = function()
    local name = getText("UI_trait_Bitten")
    TraitFactory.addTrait(name, name, -10, "You're screwed.", false)
end

Events.OnGameBoot.Add(Joy.bittenTrait)

?

faint jewel
#

anyone have an idea on my issue in #modeling ?

rancid panther
#

when i try to add a trait without using the framework, it doesnt work, so i think if i were to do it that way i'd need to make a separate mod to enable this trait

#

but im trying to see if i can do it within the same mod for mod list simplicity

thick karma
#

That doesn't seem like it should be the case

#

If ProfessionFramework makes vanilla TraitFactory stop working, I'd call that a bug...

rancid panther
#

i am pretty sure it is only me

#

but i dont know how to fix it so i've been keeping everything in the framework format

thick karma
#

Well maybe try the code above?

#

It's like 6 lines... just try em

#

Throw them at the bottom of your mod and boot up

rancid panther
#

it makes the game stuck on the menu background

bronze yoke
#

so GameTime.getRealworldSecondsSinceLastUpdate() does not return the real world seconds since the last update u_u

thick karma
thick karma
rancid panther
#

jaques_beaver i left it unchanged aside from the name

thick karma
#

I wasn't clear at all at first, sorry, but when you use a prefix like Joy., you are indicating that the function is in a module, i.e., a Lua table that neatly contains all your crap for whatever mod you're doing

rancid panther
#

ah

thick karma
#

if it's a local module, Joy = {} at the top is sufficient

#

If it's a global module, Joy = Joy or {} may be better

#

Because then you can not worry so much about whether Joy is declared in this or that file first (unless the functions in different files depend on one another of course)

rancid panther
#

when you write Joy, is it looking for something actually named joy?

#

like my username? or is it just something arbitrarily named for the example

thick karma
#

@rancid panther

local Joy = Joy or {}

Joy.bittenTrait = function()
    local name = getText("UI_trait_Bitten")
    TraitFactory.addTrait(name, name, -10, "You're screwed.", false)
end

Events.OnGameBoot.Add(Joy.bittenTrait)

Joy.biteMe = function(playerIndex, player) 

    if player:HasTrait(getText("UI_trait_Bitten")) and not player:getModData().bitten then
        local part = ZombRand(player:getBodyDamage():getBodyParts():size())
        player:getBodyDamage():getBodyParts():get(part):SetBitten(true, true)
        player:getModData().bitten = true
    end

end

Events.OnCreatePlayer.Add(Joy.biteMe)```
thick karma
#

(I don't have your translation file)

#

(So my pic just shows the stuff I fed getText as a fallback)

rancid panther
#

okay that actually does work

#

waot

#

it still doesnt give me a bite

thick karma
#

Did your trait show up as "Bitten" or "UI_trait_Bitten" when you did this?

rancid panther
#

oh it showed up as what i named the actual trait

thick karma
#

What is the name of the actual trait?

rancid panther
#

[Misc] Bitten

thick karma
#

Then you need player:HasTrait("[Misc] Bitten")

rancid panther
#

oh

#

that's the translation name

thick karma
#

My code assumes you named it Bitten

rancid panther
#

the name itself is Bitten

#

lemme try one more time

thick karma
#

If it showed up as [Misc] Bitten in your trait selection, I would try tagging it that way in the conditional

#

idk

rancid panther
#

that's only in translation files

dark wedge
#

If the name is Bitten, you also need to create it as such:
TraitFactory.addTrait("Bitten", name, -10, "You're screwed.", false)
This will let you reference it as:
player:HasTrait("Bitten")
The first name in the example given is the internal name, the second is the translation

#

Otherwise, you have to reference it always as:
player:HasTrait(getText("UI_trait_Bitten"))

thick karma
#

@rancid panther See the edit please for easier code to copypaste.

dark wedge
#

afaik, the internal name is never displayed. so you don't need to use the translation for that part.

red tiger
#

I did the code jam I said I'd do this weekend. 14 hours today, 6 hours yesterday. :D

#

I now have a somewhat fleshed out Lua to TypeScript transpiler, pre type-reverse lookup.

thick karma
#

So then this:

local Joy = Joy or {}

Joy.bittenTrait = function()
    TraitFactory.addTrait("Bitten", getText("UI_trait_Bitten"), -10, "You're screwed.", false)
end

Events.OnGameBoot.Add(Joy.bittenTrait)

Joy.biteMe = function(playerIndex, player) 

    if player:HasTrait("Bitten") and not player:getModData().bitten then
        local part = ZombRand(player:getBodyDamage():getBodyParts():size())
        player:getBodyDamage():getBodyParts():get(part):SetBitten(true, true)
        player:getModData().bitten = true
    end

end

Events.OnCreatePlayer.Add(Joy.biteMe)

Alternatively.

red tiger
#

Once type-discovery is coded into my transpiler then I can move onto more complex Lua coding patterns. :D

thick karma
#

Once I have redone the animation for lefthanded swinging and stabbing I might not hate fragmotion so much anymore 😭

#

dhert knows . . . dhert knows . . .

dark wedge
#

It hates you as much as you hate it.

#

And everyone else.

rancid panther
#

it worked! thanks!

naive crescent
dark wedge
#

But sometimes it works and does what I want it to!

thick karma
#

Honestly, though, it's not Fragmotion entirely

#

Those damn prop bindings are infuriating.

#

I would have the animation done by now if not for them

rancid panther
#

this is with a random bite location tho, can i change the getBodyParts() back to getBodyPart(BodyPartType.ForeArm_L) and it should work? or is this example purely for if i want a random bite location

thick karma
rancid panther
#

also, the arbitrary parts are all the things that say "Joy" so i can change that too right?

thick karma
#

You could find and replace Joy (match case and whole word for best results when doing this kind of thing) with anything you want to use for the name of the module

#

But the name of your module must be PascalCase or you're a traitor to humanity.

#

And there will be consequences.

#

Not programmatic consequences or anything.

#

Just spiritual ones.

rancid panther
#

and i can change "You're Screwed" back to pull from translation files with gettext("UI_trait_bittendesc")

thick karma
#

Nah just kidding just kidding.

naive crescent
#

You almost got me.

thick karma
#

If you insist on changing that, I GUESS

naive crescent
#

We all know camelCase is better

thick karma
#

camelCase is for VARIABLES not MODULES you knave.

#

It's for objects

rancid panther
#

mine in translation files is already "Your days are numbered"

but... "You're screwed" was already a contender LOL

thick karma
#

Not containers

naive crescent
#

Oh interesting

#

Apperently im just ignorant

thick karma
#

hahahaha

#

I mean I'm absolutely kidding

#

Half-kidding

naive crescent
#

I never thought you werent xD

#

But is that actually a thing?

thick karma
#

I mean stylistically, a static class or the class used to insantiate objects IS more often than not PascalCase

#

In most languages

#

And in Zomboid that is the pattern followed.

#

Probably because they inherit a lot of habits from Java

naive crescent
#

Then ill stick to it then

thick karma
#

Where that is the official pattern

naive crescent
#

Gotta keep it uniform

thick karma
#

However, I am not really a nazi about style things, I don't think Joy will ruin the world by choosing to use camelCase module names

#

I am exaggerating my concern for comedic effect

#

But it will help some programmers immediately understand your intentions better.

naive crescent
#

I didnt know they were used for different things. I always just thought it was outta personal preference.

#

Honesly I was repping camelCase but I always use PascalCase anyways

thick karma
#

In Lua things are painfully inconsistent, but in most languages, different cases preferentially indicate different things

naive crescent
#

It feels more natural when my fingers are flying

thick karma
#

FINAL_VARIABLE

#

StaticClass

#

localVariable

rancid panther
#

i figured there was a pattern but i have not really learned it. i just kept the casing from other things i looked at

thick karma
#

objectVariable

#

e.g.

#

but NEVER local_variable. That's just wrong. 😉

#

(*local_variable is objectively right in some languages, I just hate underscores.)

true vault
thick karma
#

🤢

#

Why are you trying to hurt me?

#

I just helped you!

#

What's wrong with you!?

true vault
#

I mean, everything is wrong with me (I primarily code C#, PHP, and JS, sooo.... everything... everything is wrong), but that's besides the point...

thick karma
rancid panther
#

ah, yes, when i explore more languages 😅

naive crescent
#

Man I didnt realize until today how bumping this side of the PZ discord is.

rancid panther
#

i wonder if i should even make it always on the left forearm, or keep it a random bite location

quasi kernel
#

Lua is my first and C# is gonna be my second proper.

#

Assuming I keep up with programming that is.

true vault
#

"Hmm, why isn't it adding rocks?" "oh, maybe if I actually put in Stone instead of Rock, since that's the correct name...""

LL_facepalm_taiga

thick karma
#

Lua is my last. Death

rancid panther
#

cuz i feel like the left forearem is a good tropey location for a bite that doesnt hinder your combat too much

#

ok it works! nice!

naive crescent
quasi kernel
#

Me when everyone hates on Lua, I know it's for good reason but at the same time Lua my beloved

#

It was my first programming love

rancid panther
#

so i really was held back trying to keep it within the framework

quasi kernel
thick karma
#

lmao nah I don't mind Lua, although I do find its system of indexing to be a bit unnecessarily tedious, given that it seems purposed for working with languages where that is not the norm or even reasonably appropriate for the structures used.

quasi kernel
#

Lua does have some stupid crap in it but I still love it anyways

copper sleet
#

Anyone know any good economy mods? Where I could sell jewellery for cash and then use that cash to buy things (Preferably configurable)

quasi kernel
#

(Why are global variables a thing? Why not all local? There's a noticable performance increase from local and you should be using local anyways.)

thick karma
#

The table system is very useful and cool for its concise flexibility.

quasi kernel
#

Tables my beloved

naive crescent
quasi kernel
#

The rage

#

It's probably not as big of a deal in C# but I wouldn't know.

naive crescent
#

but you gotta put public instead of local to make it a global

true vault
rancid panther
naive crescent
thick karma
quasi kernel
#

It's stupid, but I ended up learning programming from Roblox of all places, and because of how they set up Luau over there globals are frowned upon.

thick karma
#

😉

naive crescent
quasi kernel
#

We all gotta learn from somewhere though.

naive crescent
#

I learned in school

true vault
#

Anyone know how to target a broken version of an item, as a valid/required recipe "ingredient"? lolz

quasi kernel
#

I self-taught myself nearly everything I knew before I finally took programming classes in school.

#

Then my last teacher said I'd never be fit for programming.

true vault
naive crescent
#

I went to school for Game Design and Development and Programming was my weakest area the enitre time

#

It was only when I left school and started working on a solo project it became my strongest

rancid panther
#

okay now to give them a bandage on spawn

naive crescent
#

I learned more in 3 months in programming working on my shit then I did in the 2 years of school

#

School was just a good launch point

rancid panther
#

thankfully, i have the old code from when i made the traits without profession framework

quasi kernel
#

School kinda taught me what I already knew but introduced proper OOP which I couldn't wrap my head around at the time.

naive crescent
jaunty marten
bronze yoke
#

for me school mostly taught me about algorithms and stuff

quasi kernel
#

I haven't gone to college or anything and tbh I don't really want to, if I do I think I'm gonna do PC and Networking maintenance stuff.

jaunty marten
#

lua even don't have official code style

naive crescent
#

I have a working knowledge in all aspects of Game Development so I can pick up anything and just start fucking around and ill make progress

quasi kernel
#

Coding I think fits me best as a hobby.

#

I cant reasonably do it for 8 hours a day, 5 days a week without going insane.

naive crescent
#

Which is why im here xD

#

Because mods are more fun to make then your own game

quasi kernel
#

Yess

#

I do wanna get into Unity someday and start making my own little game, but it's admittedly a bit intimidating.

naive crescent
#

Unity is pretty easy to learn

#

Before I went to school I had a good understanding of how the engine worked.

#

People can talk shit all they want but Unity has a place in my heart forever

#

Also Unity has amazing tutorials and resources out there.

#

Like a substantial amount compared to any other engine

#

Holy fuck! If Im correct I just completed my first mod 🏆

thick karma
#

wudjudoo

naive crescent
#

Its going to blow your mind

#

The greatest QOL mod ever to come to PZ

#

I changed the spelling of the Baloney food item

#

to Bologna

thick karma
#

FINALLY

#

THANK YOU

#

JESUS

naive crescent
#

What a rush

#

I never noticed it till today and I got straight to work

dark wedge
#

What baloney. Downvote.

rancid panther
#

congrats!

#

do you think i can create the bitten trait using profession framework and complete all the functions outside of it?

dark wedge
#

Nah, I did notice that and always thought I was just wrong. lol

rancid panther
#

like the name and cost and all the easy stuff?

#

or better to just keep it all together

thick karma
#

Well it's sort of wrong and sort of not, in my pedantic opinion.

#

Arguably "baloney" is not "balogna" because most Americans couldn't guess how to pronounce that second word if their lives depended on it

#

We all say "baloney" when we see "balogna"

naive crescent
#

Im aware of why they made that design choice

#

doesnt make it right

thick karma
#

but "balogna" is not buh-low-nee.

#

It's bah-low-nyuh.

dark wedge
#

blasphemy

true vault
#

Buh-log-nah

thick karma
#

Basic Italian.

#

gn = ny

#

In Italian.

#

In this situation

rancid panther
#

player:getInventory():AddItem("Base.Bandage");

how do i squeeze this in here?

thick karma
#

wdym?

rancid panther
#

before, when i was making the traits without profession framework, it looked like this

#

which worked, but i had issues doing this at the same time as using profession framework, which is why everything is in that now

#

but when i want to add a bandage to the inventory as is, how you made it for me, it doesnt show the trait

#

do i need to put it in a certain spot or create a new event and function like i did with these

thick karma
#

According to the Java doc OnGameBoot does not send you any parameters to work with.

#

@rancid panther Therefore I would work with OnCreatePlayer for player stuff

#

OnCreatePlayer gives you a player index and object:

rancid panther
#

ok

bronze yoke
#

stressed GameTime.instance and GameTime.getInstance() return different objects

thick karma
bronze yoke
#

my issues have been coming from some cursed gametime instance

thick karma
#

It brings balance to the other instance

#

But you must seek understanding to tap into its power

#

Use the Force, albion.

bronze yoke
#

and getInstance doesn't do anything weird - it literally just returns instance

#

i didn't factor in the force tired

faint jewel
#

yeah i need help with time too.

pulsar heath
#

i gave up on the gametime 2 weeks ago

rancid panther
#

giving them items on spawn seems to make the trait disappear from the select screen completely

#

which tends to be the issue when i do something wrong

thick karma
#

If the trait is disappearing from select, it's likely because your mod is catastrophically failing. If the mod can't even begin to load because of a major error, the file will simply be left out under some circumstances I haven't quite clarified myself.

#

But it suffices to say I have seen my mods with errors fail to load the file at all

rancid panther
#

i think i had an extra end in there actually

thick karma
#

And then obviously nothing at all will happen

#

No traits will load, etc.

rancid panther
#

i reverted it back to how it was without the bandage

#
local function BittenTrait.assignBittenStuff (player, square)

    if player:HasTrait("Bitten") then
        player:getInventory():AddItem("Base.Bandage");
    end
end

Events.OnNewGame.Add(BittenTrait.assignBittenStuff);

and here is the info im trying to add that is messing things up

#

oh it still says onnewgame in this one

#

i'll try on character creation again

thick karma
#

OnCreatePlayer

#

playerIndex, player

#

Not player, square

#

When you change it

#

However, player, square is correct for OnNewGame. I'm not sure how that one works though... may only happen on a brand new server, idk.

rancid panther
#

that's still there for the other stuff, i was just adding from the old version of my mod for the items

#

okay i'll do playerIndex

thick karma
#

If the function is a listener for the OnCreatePlayer event, it receives playerIndex, player in that order, and you can use player the way you already are.

#

so local function BittenTrait.assignBittenStuff(playerIndex, player)

rancid panther
#

it doesnt show up in character creation

thick karma
#

But actually

rancid panther
#

should it be withint or outside of all the other stuff i did?

thick karma
#

That's a little bit of an odd way to write the function header

#

If you have local BittenTrait = {} above your function somewhere, you can just go BittenTrait.assignBittenStuff = function(playerIndex, player)

eternal garnet
#

Does anyone know what file the code specific to the "Composter" is located?

thick karma
#

@rancid panther I don't know what you mean

rancid panther
#

i'll just do something and then send it

#

after testing first if it even works

#

here is how it looks rn. the trait isnt on character select screen atm

thick karma
#

This is the entire code?

rancid panther
#

of the trait yes

thick karma
#

Oh I see

#

You have a fundamental misunderstanding of how the module works in Lua

rancid panther
#

the entire mod has like 6 professions and 15 traits

thick karma
#

You don't say

local BittenTrait = {}
  -- do stuff 
end
#

That's not a thing

rancid panther
#

ah

#

i didnt use local stuff before

thick karma
#

You say

local BittenTrait = {}

BittenTrait.name = "Bitten"

BittenTrait.anotherExampleField = 4121505219

BittenTrait.yetAnotherExampleField = {
  i = "am",
  a = "table",
  inside = "another",
  one = "!",
  thisCouldEvenBeAnotherFunction = function(someInput)
    print(someInput)
  end
}

BittenTrait.doBittenTraitStuff = function()

end

BittenTrait.doBittenTraitStuff()

Events.WhenYoMamaGetsBack.Add(BittenTrait.doBittenTraitStuff)

return BittenTrait
#

The last two are just examples of using the function in the module two different ways

#

As a listener or just called directly

thick karma
#

(Returning BittenTrait at the end may be useful to other modders interacting with yours down the road.)

rancid panther
#

it worked!

thick karma
# rancid panther ah

Added some examples above... showing how to use fields and tables within your module (which is also technically a table).

thick karma
rancid panther
#

so this is how it looks now. it works, but is there anything i can do to clean it up or remove any arbitrary stuff i added in my inexperience

#
local BittenTrait = {}

    BittenTrait.bittenTrait = function()
        TraitFactory.addTrait("Bitten", getText("UI_trait_Bitten"), -10, getText("UI_trait_Bittendesc"), false)
    end
    
    BittenTrait.assignBittenStuff = function(playerIndex, player)
        if player:HasTrait("Bitten") then
            player:getInventory():AddItem("Base.Bandage");
        end
    end

    Events.OnGameBoot.Add(BittenTrait.bittenTrait)

    BittenTrait.assignBite = function(playerIndex, player) 

    if player:HasTrait("Bitten") and not player:getModData().bitten then
        player:getBodyDamage():getBodyPart(BodyPartType.ForeArm_L):SetBitten(true, true)
        player:getModData().bitten = true
    end

end

Events.OnCreatePlayer.Add(BittenTrait.assignBite)
Events.OnCreatePlayer.Add(BittenTrait.assignBittenStuff);
eternal garnet
rancid panther
#

or if i applied your advice incorrectly and still somehow got lucky,

thick karma
#

Your functions should not be tabbed in more than local BittenTrait = {}

#

Your last end statement and your last if block are correct, but BittenTrait.assignBite needs to be in line with local BittenTrait

rancid panther
#

i see... i did it because the lines pointing down from the other lines helps me visualize

thick karma
#

And you should not add a new tab level to your code unless you are entering a deeper scope.

rancid panther
#

i dont understand what you said about tabbing. which keywords do you mean, and what do you mean by a line below that keyword

thick karma
#
first scope
{
  second scope
  local bob = 5
  {
    third scope
    {
      deepest scope
      more stuff happening
    }
    back in the third scope
  }
  back in the second scope
  bob still equals 5
}
back in the original scope
bob is dead
end of file
#

Scope is used to indicate where local variables exist

#

Local variables exist from the point at which they are declared until the point at which their scope ends.

#

So if I add a local variable named bob above...

rancid panther
#

so they should all be on the first scope?

thick karma
#

When you enter a function, that's a new scope. when you enter a conditional, that is a new scope in many languages but honestly in Lua I'm not sure, however, we tend to punctuate it that way.

bronze yoke
#

it is in lua

thick karma
#

Okay I wasn't sure; I think I've seen some people declaring local things inside conditionals in Lua mods, and that looks weird a.f. to me

#

didn't know what to make of it.

bronze yoke
#

you can even use```lua
do

end

thick karma
#

Yes I am aware of do end

rancid panther
#

so is pretty much everything tabbed too far in by 1?

bronze yoke
#

yeah pretty much

rancid panther
#

like this? or still some spots are not right

thick karma
bronze yoke
#

BittenTrait.assignBite's code can be indented

thick karma
# rancid panther ?

Your if block in the function albion's talking about is inside the scope of its function

#

Therefore the whole thing would get 1 more tab

rancid panther
#

how about that events thing

#

should it stay where it is and not indented or indent it or move it to the bottom with the other things

#

i didnt wanna move it cause where it is rn is when the trait started to work

thick karma
#

Events lines are correct but you didn't indent the whole if block.

#

You only indented its header and its end statement

#

Since the conditions also open new scopes, you should also indent their contents.

#

After each if then line, the stuff below it should be tabbed more than the if until you get to the end.

rancid panther
#

ngl this feels like what i had before minus a line or two

thick karma
#

There you go

#

Wait

#

What happened above

thick karma
rancid panther
#

should the function lines stay on the first indentation?

thick karma
#

Yes

#

The functions are all being defined at the root scope of the document

rancid panther
thick karma
#

Highlight 131 - 134 and hit Shift + Tab

#

Highlight 128 and hit Shift + Tab

#

And then you have it

#

Though 139 could go

#

Little oddly inconsistent spacing

rancid panther
#

ok that makes a lot more sense now. thanks!

#

i was confused which things warranted an end statement and pretty much indented what i thought was supposed to be before it

thick karma
#

Also

#

Small point of style

#

You have unnecessary semi-colons

#

Lua does not require semi-colons at the end of lines

#

Only if you want multiple discrete commands on one line do you need to delimit commands with ;

rancid panther
#

ah, that was left over from when i was copying something else

thick karma
#

e.g., if weird() then print("Weird"); return end

#

Otherwise you never need them

naive crescent
#

Hope posting the link is cool here I just had to share it.

thick karma
#

Nobody seems to mind

rancid panther
#
local BittenTrait = {}

BittenTrait.bittenTrait = function()
    TraitFactory.addTrait("Bitten", getText("UI_trait_Bitten"), -10, getText("UI_trait_Bittendesc"), false)
end
    
BittenTrait.assignBittenStuff = function(playerIndex, player)
    if player:HasTrait("Bitten") then
        player:getInventory():AddItem("Base.Bandage")
    end
end

Events.OnGameBoot.Add(BittenTrait.bittenTrait)

BittenTrait.assignBite = function(playerIndex, player) 
    if player:HasTrait("Bitten") and not player:getModData().bitten then
        player:getBodyDamage():getBodyPart(BodyPartType.ForeArm_L):SetBitten(true, true)
        player:getModData().bitten = true
    end
end

Events.OnCreatePlayer.Add(BittenTrait.assignBite)
Events.OnCreatePlayer.Add(BittenTrait.assignBittenStuff)

here is how it looks now

thick karma
#

I think the people here generally have favorable attitudes regarding the existence of new mods 😉

quasi kernel
#

Yess

rancid panther
#

oh i think one end is still indented too much

naive crescent
#

I figured here of all places it was going to be cool since were all in this together.

quasi kernel
#

We're all one big, catastrophically sleep deprived family.

rancid panther
#

is that right?

thick karma
thick karma
#

You have it now

rancid panther
#

yay!!

#

now to test if it still works

naive crescent
#

Im exhausted as fuck

thick karma
#

Again, a final return BittenTrait at the end is good practice @rancid panther

#

Though in your case I highly doubt anyone will want to intervene or hook this particular code

rancid panther
#

at the very very end? or after the last end?

thick karma
#

At the very end

#

After the Events

#

Literally must be the last line

rancid panther
#

i see

thick karma
#

More code after an inevitable return statement is a strict coding no-no.

rancid panther
#

so if i make any other traits without profession framework, it should look something like that

rancid panther
#

all my traits share a space based on their category

#

though i might need to move my skill traits to a dif file from the misc traits

thick karma
#

Right. However, fwiw, you could make your code a bit more concise perhaps:

local Bitten = {}

Bitten.trait = function()
    TraitFactory.addTrait("Bitten", getText("UI_trait_Bitten"), -10, getText("UI_trait_Bittendesc"), false)
end
    
Events.OnGameBoot.Add(Bitten.trait)

Bitten.apply = function(playerIndex, player) 
    if player:HasTrait("Bitten") and not player:getModData().bitten then
        player:getBodyDamage():getBodyPart(BodyPartType.ForeArm_L):SetBitten(true, true)
        player:getModData().bitten = true
        player:getInventory():AddItem("Base.Bandage")
    end
end

Events.OnCreatePlayer.Add(Bitten.apply)
rancid panther
#

ok i thought i could concise it up a bit

thick karma
rancid panther
#

thanks

thick karma
#

Also, each function can only have one inevitable return statement.

#

And inevitable return statements must not be followed by more code within their own scopes.

rancid panther
#

so if i wanted to add a bunch of traits on one file and end with a return statement, would i make it more general like

local AddTrait = {}

?

#

and at the end
return AddTrait

thick karma
#

How about "Joyful Traits":

local JT = {}
rancid panther
#

maybe

thick karma
#

Then you can have stuff like this:

rancid panther
#

i should make a special file then for all the traits that might need that

#

since i dont think i need it in the ones i make using profession framework

thick karma
#
JT.Bitten = {}

-- Bitten stuff.

JT.Blitzed = {}

-- Blitzed stuff.

JT.Godlike = {}

-- Godlike stuff.
#

(IF you wanted it all in one file in a legible way, in one local module that you could return at the end of the file)

rancid panther
#

ok i'll have a separate file in case i need to add things in the future

thick karma
#

I mean you can also do that

#

Have a Bitten.lua with local Bitten = {}, etc.

#

That's a style choice that depends a lot on how many custom traits you have planned and how complicated they are.

rancid panther
#

rn i made a MiscBitten.lua and put it all there

thick karma
#

Sure whatever works

rancid panther
#

thanks!

thick karma
#

Yeah big takeaway here is if you try something, and it works, and you try something seemingly unrelated, and the first thing no longer works, make super duper certain you haven't simply borked your file outright in an unusual way.

jaunty marten
rancid panther
#

can i make the bite not bleed?

thick karma
rancid panther
#

rn it is SetBitten(true, true) so is there another boolean for [isBleeding]?

thick karma
#

The JT parent table would be the single-file option

#

He could also just do a set of local table files

jaunty marten
rancid panther
#

that was one of their suggestions. for bitten trait (as i have it rn) it is BittenTrait

thick karma
#

It could be. We are discussing possible layouts. Nothing is really set in stone.

rancid panther
#

but if i wanna make a bunch of traits then i'd probably use something more general

#

these are just a bunch of things for my personal server with friends or solo play

#

so im not really doing too much crazy stuff with it.

#

although, now we can make bitten characters! i wonder who would actually use it... maybe it just becomes a free trait down the line when we find a cure

jaunty marten
rancid panther
#

the bite isnt 100% lethal. it is 100% infected

thick karma
#

I think they want to find a cure mod

rancid panther
#

if you use a mod with a cure, you will survive

jaunty marten
#

ah, u want to use it with that mod

#

yea, then it's make sense

rancid panther
#

and if you want to just have a challenge mode where you wanna kill as many zombies as you can before you die, there is that too

jaunty marten
thick karma
#

Do you have a good cure mod Joy? I'm curious if any active ones still work properly.

rancid panther
#

theyknow (no space) is a modification of they knew that lets you use a medication that resets your infection timer instead of fully cure you

#

and they knew also works, but it does not yet have an option where you delay the cure

#

ideally, i'd like to have a mod where you can never be cured, but you are constantly searching for medicine that will extend your life

#

but i feel like without hope of a cure, most ppl will kill themselves when they are bitten even when they can extend their life, so i would add a low chance of finding the cure, while making most instances of finding only a sample

thick karma
cyan holly
#

hi guys, is there a way to disable stunlock in pvp?

rancid panther
#

but the mod description says they plan on it

cosmic condor
rancid panther
#

Soon™

thick karma
#

Nice, They Knew does seem to work.

#

I am currently not dying from the bite that killed the last three versions of me

rancid panther
#

nice

#

the secondary option, Zomboxycycline, adds a pill that prevents infection for 24 hours (cannot cure or slow down set infections)

thick karma
#

Nice

rancid panther
#

i almost have a perfect professions/traits mod

#

perfect as in a little bit on the easy side, and catered to playstyles rather than lore based occupations

spare burrow
naive crescent
#

There is a mod called Tripping Zombies I believe, use that as a launch point

dark wedge
#

welp. I couldn't resist once i found the vanilla punch animation. Got that mirrored to the left, and now I have a special state that you activate when aiming and holding control (or left bumper) and your player is unarmed, which allows you to punch. 😄 No balance yet, but it works!

naive crescent
#

Is there a left handed weapon mod out there yet? Or is this the first?

#

That is really cool

#

oh wow, I like that.

#

Could make an occupation like Boxer to go with it.

#

And if your feeling really ambitious hand to hand combat skill

dark wedge
#

there are 2, currently. one has not been maintained, and the other is a bit exploitable/janky (no disrespect, i used it for a bit).

drifting ore
#

oh man

dark wedge
#

and thanks! yea, i do plan to expand this a bit more. this is more just me messing around and trying to make this the best i can for right now. haha

naive crescent
#

The last time I played I got injured on the right forearm and it fucked me

#

I was honestly useless in my crew

#

I wished then for a left handed mod

drifting ore
#

dude i will never use a weapon again

dark wedge
#

Well, this will work for you then. it already supports swinging with JUST an offhand equipped if you want

drifting ore
#

me literally this second lol

naive crescent
#

Yo I would love that

dark wedge
naive crescent
#

I play the least amount of clothes possible meta but my right forearm I realized is carrying me all the way

drifting ore
#

i love it dude. i will 100% start a new char just for it lol

naive crescent
#

Yea please send it, im eager to try that.

drifting ore
#

some of the best stuff in mods is the stuff after the mods done lolol

#

at least the core

#

dhert your mods are dope though man, all of them

naive crescent
#

Gonna check out your collection

drifting ore
#

QOLNation

ancient grail
spare burrow
drifting ore
#

it's what he's doing... lol

dark wedge
spare burrow
ancient grail
#

I know

dark wedge
spare burrow
naive crescent
#

That is what were talking about

drifting ore
#

i misread that anyways disregard

#

i have no idea if he's doing that lol im dumb

naive crescent
#

oh yea.

#

Misread as well

spare burrow
# dark wedge Yup! Eventually, will balance it around that.

If you want some kind of inspiration, cataclysm dda adds several types of combat stances for martial arts and etc; you can add a trait that increases melee damage or knockback/critics, even a boxer/martial artist profession, etc, now its a world of possibilities

naive crescent
#

Thats a really good mod to skim to use as a reference

stable flame
#

Is there a way to set a recipe to not give anything, except EXP? I already have a script for OnGiveEXP, but im forced to specify the Result field in the recipe, setting quantity to 0 doesn't work 😦

bronze yoke
#

there's a RemoveResult or something

stable flame
#

hmmm thanks for the pointer, ill go investigate the functions

bronze yoke
#

i think some vanilla recipes have it so if you search for similar terms i'm sure you'll find it

#

it's in the actual script i think

#

i'd check it for you but i'm not at my computer right now

cyan holly
#

is there any mod that allows you to learn traits by reading book?

naive crescent
#

I havnt seen one

#

Unless one got released over the past month when I last went through most if not the entire workshop then im gonna say no

spare burrow
#

I remember one that gave the nutritionist trait by reading a magazine, but can't remember which one

stable flame
drifting ore
#

there is a way

#

removeResult is right

#

removeResult=true

stable flame
#

many thanks

thick karma
#

@rancid panther So if I made a patch that allowed players to turn They Knew into a resistance-extending drug that provided +X minutes of immunity per dose, that would be basically worthless and not at all interesting to you, right?

hot patrol
cyan holly
hot patrol
thick karma
#

I think the mod has vaccine pills, but they don't work after you're infected.

#

After infection, it's cure or no cure. @hot patrol

spare burrow
dark wedge
stable flame
bronze yoke
#

it should be put in the recipe script

rancid panther
drifting ore
#

zombie virus vaccine for multiplayer is one of the better atm if you like to work for your cure

rancid panther
#

the way the mod im using does it, is that it resets infection stage to 0 basically
i think it is basically a copy of the cure except instead of disabling infection, it resets infection

so it keeps the cure, and the resistance, and also adds a life extender

rancid panther
#

i dont like the idea of developing a cure urself in this game

stable flame
rancid panther
#

i think i might have come across an issue with my mod

#

i think i outlasted the bite and the infection doesnt seem to be in effect anymore

#

i might need to cause the player to be infected rather than the bite itself

rancid panther
#

and in my experience, strength has a lot faster passive gain than fitness (even in running (for some reason))

dark wedge
#

Who needs sleep anyways?

rancid panther
#

how can i check if im still infected in debug mode?

#

i was able to make my character infected initially with my trait, but after a while the symptoms disappeared and the bite healed

#

if you can just outlive the bite i might need to rethink how i made this trait

#

i think im good actually

#

infection level refers to knox virus right? just making sure

naive crescent
#

No

#

Backpeddling. I dont think so

#

im pretty sure it refers to wound infection.

dark wedge
#

You can check this with: player:getBodyDamage():getBodyPart(BodyPartType.ForeArm_L):IsInfected()

ancient grail
#

anyone knows how to force drink using lua

naive crescent
#

Okay after some testing it defintley is not

rancid panther
naive crescent
#

I got it 100 and let my self get to terminal and I still dont have the zomified moodle

rancid panther
#

i see

#

so should i add something to my mod to set the player to infected instead of just the wound

naive crescent
#

Im not 100% sure what infection level is referring too but its definitely not the Knox virus. When you have it your last few moments youll get a moodle or maybe just a some words in the health screen saying zombified

#

I dont rememver I havent died like that in a while

rancid panther
#

is there a different place i can check if they are infected?

naive crescent
#

Look at what dhert said above

dark wedge
# ancient grail anyone knows how to force drink using lua

By "force", I assume this is something that will just happen after X amount of time? If so, when your event occurs, check if the player has the item you are looking for in their inventory, and then: ISInventoryPaneContextMenu.eatItem(item, amount, player:getPlayerNum())

naive crescent
#

You can use a consol command

ancient grail
#

thnx ill try this

#

im actually lost in confusion

#

im trying to add drink with ice cube on every context that has drink

dark wedge
#

Are you trying to have this be "crafted" first, and then drank? that might be easiest as you just trigger that above command in the crafting function

#

if its a recipe, the game will just add it to the context menu for you as it does. otherwise, you have to add the option to the context menu and consume your item that has the added benefits (or something) from the ice cube.

naive crescent
#

Ive had not much success with custom context menu actions

rancid panther
#

surely this must mean im infected

dark wedge
#

Yes, you are

ancient grail
#
function drinkWithIce(player, context, items)
        items = ISInventoryPane.getActualItems(items)
        local playerObj = getSpecificPlayer(player:getPlayerNum())
        local inv = getPlayer():getInventory() 
        local drinkOption = context:getOptionFromName(getText("ContextMenu_Drink"))
        local subMenuDrink = context:getNew(context)
        context:addSubMenu(drinkOption, subMenuDrink)
        for _, item in ipairs(items) do
            if drinkOption and inv and inv:FindAndReturn("Sapph.IceCube") then
                subMenuDrink:addOption("Drink with Ice Cubes", item, function()
                    item:getContainer():DoRemoveItem(inv:FindAndReturn("Sapph.IceCube"))
                    ISInventoryPaneContextMenu.eatItem(item, 1, playerObj)
                end)
            end
        end
end
rancid panther
#

im dumb. it was like 2 lines below the infected level

#

however, it does bother me that the bite healed

naive crescent
#

Okay so you need to have that checked and then the infection slider goes up

rancid panther
#

my world is on 1-2 weeks infection time because i thought it would be harder to find a cure -.-

fast galleon
rancid panther
#

i found 3 cure zombies already and 1 had a cure