#mod_development

1 messages ยท Page 149 of 1

red tiger
#

If ranged integer values, then all values.

#

If string for items or sounds, empty.

drifting stump
#

i meant for example

red tiger
#

I use auto-complete for values yeah? I'm saying though like a item template for a certain type of weapon category or maybe a template for heavy vehicles.

#

Ah.

drifting stump
#
item Bag_ToolBag
    {
        DisplayCategory = Bag,
        Type = Container,
        DisplayName = Duffel Bag,
        ClothingItem = Bag_ToolBag,
        CanBeEquipped = Back,
        WeightReduction    =    65,
        Weight    =    1,
        Capacity    =    18,
        Icon    =    Duffelbag,
        OpenSound   =   OpenBag,
        CloseSound   =   CloseBag,
        PutInSound   =   PutItemInBag,
        RunSpeedModifier = 0.95,
        CanHaveHoles = false,
        ReplaceInSecondHand = Bag_DuffelBag_LHandTINT holdingbagleft,
        ReplaceInPrimaryHand = Bag_DuffelBag_RHandTINT holdingbagright,
        WorldStaticModel = DuffelBag_Ground,
    }
#

theres a lot more possible parameters and also some could be omitted

red tiger
#

Exactly.

#

I agree with you on this 100%.

#

The idea of templating is to help reduce time writing the same properties again and again.

#

What if I wanted to make an extended bags mod..

#

Create new Bag

#

Hit enter and then this template is then applied to your document.

#

Creating templates for very common scripts will reduce a lot of time spent building from scratch. =)

#

The problem: I have no experience scripting so I wouldn't know.

#

@drifting stump Here's some of the helper features in the extension.

drifting stump
#

very nice

#

should mention in the icon it should be think it was 16x16

#

because the vanilla inventory render function doesnt scale the icon and anything else will mess it up

red tiger
#

Thanks.

#

I've improved a couple dozen pages today for properties for simple inconsistencies or some wording issues.

frosty stirrup
#

Hm, so if I want to get the script name of an item, not a DisplayName with translation or something, would it be getName() or getFullName()? What's the difference between these functions?

frank elbow
#

Do you mean the name of the item after "item" in the script? It's referred to as the "type" and the "full type" is the fully qualified name including the module

#

I know for full type it's getFullType, I assume for type it's getType. Less certain bc I prefer the former when it's needed

obsidian horizon
#

when i try to get the game to recognise that this item does have a 3d model it just throws me a questionmark
here is the code
`module Base
{

item alexshead
{
    Type = Clothing,
    DisplayCategory = Accessory,
    DisplayName = Alex Helmet,
    ClothingItem = Hat_alexhelm,
    BodyLocation = FullHat,
    Icon=Item_alexhead,
    CanHaveHoles = false,
    BloodLocation = FullHelmet,
    BiteDefense = 100,
    ScratchDefense = 100,
    BulletDefense = 100,
    DisplayCategory = Armor,
    ChanceToFall = 0,
    Insulation = 0,
    WaterResistance = 0.40,
    Weight = 1.0,
    Tooltip ="This is alexs head its unique",
    WorldStaticModel =alexshead,
}

    model alexshead
    {
        mesh = WorldItems/alexshead,
        texture = WorldItems/alexhead,
        scale = 0.5,
    }

}`

red tiger
#

Your icon format is wrong.

#

Icon_ is for the file name.

obsidian horizon
red tiger
#

But yes without the Item_ prefix.

obsidian horizon
#

ah perfect

#

then what about
model alexshead
{
mesh = WorldItems/alexshead,
texture = WorldItems/alexhead,
scale = 0.5,
}

obsidian horizon
#

ty

faint jewel
#

can i make trunks NOT spawn items?

fast galleon
#

sure, why not?

#

why can't YOU do it?

faint jewel
#

lol i just was wondering if it was like a "nofill" command or something

fast galleon
#

setExplored or set the car some table with no items

echo fiber
#

does anyone have an example i could follow for creating a context menu for a tag.. or how they did the PillsVitamins iv been struggling while looking threw the base game files for how to do this and im just getting more confused by the second

fading horizon
#

Yeah one sec

#

first, we need to patch OnFillInventoryObjectContextMenu

#
local function OnFillInventoryObjectContextMenu(player, context, items) 
--# When an inventory item context menu is opened
    local playerObj = getSpecificPlayer(player);
    items = ISInventoryPane.getActualItems(items);                              
-- Get table of inventory items
    local isVape = nil;                                                         
-- Define a variable to hold the potential vape item
    for _, item in ipairs(items) do                                             
-- Check every item in inventory                         
        if item:getDisplayCategory() == getText("IGUI_ItemCat_Vape") then       
-- If item is a gnome bar, it is caught in a variable.
            isVape = item;                                                      
-- We check if it's our item first to reduce load time since this is called every time an option is right clicked.
            -- // (item:getFullType())
            break
        end
    end
#

if item:getDisplayCategory() == getText("IGUI_ItemCat_Vape") then This might be the part you're looking for

#

I check for display category rather than tag

#

then, after we see if it's the vape item

#
if isVape ~= nil then               
-- # if the clicked item is a vape, add the vape context menu item

        local isFav = context:getOptionFromName("Favorite");
        local opt
        local CMIcon = vape_config.ModOptions.options.box3 and true        
-- !! if option is not enabled, true. If it is enabled, false
        -- // print(CMIcon)
        if isFav then
            opt = context:insertOptionAfter("Favorite",getText("UI_vape_action"), isVape, callVapeAction, playerObj)    
-- !! Need to also pass the player object here so the timed action can use it  |  Insert after "favorite" so it's in the normal "smoke" position
        else
            opt = context:insertOptionAfter("Unfavorite",getText("UI_vape_action"), isVape, callVapeAction, playerObj)  
-- !! Inserting option after unfavorite. If neither exists, it will just add it to the bottom of the stack by default.
        end

        if CMIcon == true then
            opt.iconTexture = getTexture('media/textures/context.png');                 
-- Icon that displays adjacent to context menu item
        end

        if not (isVape:getUsedDelta() > 0) then
            --print("no charge")
            opt.notAvailable = true;
            opt.tooltip = "this vape is dead"
        end

        
-- local op2 = context:insertOptionAfter("Favorite","Check Flavor", isVape, getFlavor) --DEBUG 

    end
end```
#

and after that, we run the vanilla code

#

Events.OnFillInventoryObjectContextMenu.Add(OnFillInventoryObjectContextMenu) -- !! When vanilla code is ran, add this custom code

#

this is what is actually creating the context menu

#

opt = context:insertOptionAfter("Unfavorite",getText("UI_vape_action"), isVape, callVapeAction, playerObj)

#

callVapeAction is a function that gets called when the context menu is clicked

#
local function callVapeAction(vape,player)                  
-- # Callback function to start the hitvape timed action - triggered by hitting "vape" context menu
    ISTimedActionQueue.add(hitVape:new(player,vape));
end```
#

and that function calls my custom timed action (the vape action)

#

check out the vanilla ISContextMenu.lua

#

that's where most of this stuff can be found

echo fiber
#

so how do i get that context menu to apply StressChange and UnhappynessChange, as when i was looking at the pills it does not let you just put that in the code for a drainable but yet they have some of the pills (antidepressants) for example change the players unhappyness over time

#

is that still done threw the context menu or is that filled out in another script when calling back for it?

fading horizon
#

That's why I have my action as a new timed action

#

There's no simple tag or something to be able to do what you're trying to do

#

You're going to need custom Lua script to do that

#

Probably using the same timed action method I did

#

That way you can inject your own status effect code

#

One sec I'll show a little how I did it

echo fiber
#

would you be able to VC? might be easier to explain lol

fading horizon
#

I can't rn sorry

#

But I'm able to text at least

echo fiber
#

thats okay ill try to follow along as best as i can then

fading horizon
#
local bodyDamage = character:getBodyDamage()
local stats = character:getStats()

stats:setStressFromCigarettes(stats:getStressFromCigarettes - CONFIGURE ME);
-- Removes stress from cigarettes

stats:setStress(math.max(((stats:getStress()) - (CONFIGUREME)),0))
-- Set regular stress to the players stress - your variable or 0 if it's under 0.

bodyDamage:setUnhappynessLevel(math.max(((bodyDamage:getUnhappynessLevel()) - happiness),0));         
-- !! Add happiness bonus when hitting a vape
        bodyDamage:setBoredomLevel(math.max(((bodyDamage:getBoredomLevel()) - boredomDecrease),0))            
-- !! Reduce boredom when hitting vape
fast galleon
#

M's buckets adds new tags and makes use of them too ๐Ÿ‘

fading horizon
#

inventoryItem also has this function

#

getTags()

#

which returns a table

#

you could check that table for your custom tag

faint jewel
#

player:getForwardDirection():getDirection(); how would i get the vehicle version of this? as the angles are not the same using vehicle:getAngleY()

fading horizon
#

or wait

#

hasTag(String tag)

#

this will be even easier

#

you would just do something like

local function isVape(item)
  return item:hasTag("vape")`
end
#

this will return true if your item has the vape tag

echo fiber
#

so im looking at the They Knew mod as they did pills as well and i found something weird, where they used a crafting recipe to make the take pills thing then they had there own TakePill.lua setting the players infection to 0 would this be done the same way? but idk how they got it to do that from a recipe

fading horizon
#

its probably something in TakePill.lua

#

i'm not aware of any script parameter that changes that value

primal remnant
#

The Lua is more detailed and powerful than script text

fading horizon
#

^

echo fiber
#

can you make it where when you craft a recipe it makes the players Unhappyness go down with a lua?

primal remnant
#

Yes

fading horizon
#

i just showed you that

echo fiber
#

thats kinda cool

fading horizon
#

bodyDamage:setUnhappynessLevel(math.max(((bodyDamage:getUnhappynessLevel()) - happiness),0));

echo fiber
primal remnant
echo fiber
#

XD

#

hes not wrong!

fading horizon
#

no worries i'm just trying to help ๐Ÿ™‚

echo fiber
#

i was supposed to be the art creator for this vape mod now im helping with code

fading horizon
#

i know how frustrating it can be

primal remnant
#

You are the most helpful โค๏ธ

fading horizon
#

i only started a couple weeks ago and was in the same spot

#

this is why i try to make my code have lots of comments

primal remnant
#

THANK YOU

fading horizon
#

so people seeing it can maybe understand better

echo fiber
#

yes truly helpful i screen grabbed it all to use for later! thank you so much Maemento!!

fading horizon
#

of course! I'm looking forward to seeing what you create

echo fiber
#

i would love to know where or what to name the scripts and where they go in the folders >.<

#

as that one gets a bit umm complex

hot patrol
#

ok so I am trying to make a new attachmentType for my item so I can reduce clipping when on the back an I am using Peach's backpack attachments mod as an base to work off but I am failing to understand what determines the name here in the weapon script. AttachmentType = Shovel, This is what I have so far in an attachment script I made that currently just takes the positioning of the shovel and gives it a new name ```module Base
{
model FemaleBody
{
mesh = Skinned/FemaleBody,

    attachment daki_back
    {
        offset = -0.0390 -0.0990 0.1520,
        rotate = -7.0000 87.0000 -55.0000,
        bone = Bip01_BackPack,
    }

    attachment daki_back_bag
    {
        offset = -0.0040 -0.0980 0.1350,
        rotate = 90.0000 0.0000 -179.0000,
        bone = Bip01_BackPack,
    }
    
model MaleBody
{
    mesh = Skinned/MaleBody,

    attachment daki_back
    {
        offset = -0.0390 -0.0990 0.1520,
        rotate = -7.0000 87.0000 -55.0000,
        bone = Bip01_BackPack,
    }

    attachment daki_back_bag
    {
        offset = -0.0040 -0.0980 0.1350,
        rotate = 90.0000 0.0000 -179.0000,
        bone = Bip01_BackPack,
    }```
fading horizon
#

ill show my folder structure

#

on sec

#

bc its ugly rn

echo fiber
frosty stirrup
fading horizon
primal remnant
#

Let me ask this of you @fading horizon (great username btw), if I make a custom lua file in my mod, will the game understand that script is talking about just my mod? Assuming of course I use local where needed and all that.

fading horizon
#

media\lua\client\ is where the ISUI folder is located. This is where you will create a new file for your custom tooltip if you want to go that route

#

in the same client folder is the TimedActions folder

primal remnant
#

OHHHHH

fading horizon
#

this is where my custom hitVape.lua (the custom timed action where most of the code I showed you is)

#

inside medi\lua\server you have the Items folder

#

this is where you create an itemsDistribution.lua

echo fiber
fading horizon
#

and handle how your items are spawned

#

one sec lemme finish this then ill answer the next questions

#

media\lua\shared is basically only for translation files from what ive seen but it may have other edge case functions

primal remnant
#

Ima leave that to the linguists.

fading horizon
#

its actually not hard and it gets your mod out there a lot more

#

I added russian translations and all of a sudden i had tons of russian ppl commenting

#

translation files are easy anyway

#

you literally just replace the english text with the foreign text

fading horizon
#

it needs a unique name for one

#

if you just name yours distributions.lua (or whatever the vanilla one is called, or another mods custom name), it will instead overwrite that file (depending on which mod is loaded first)

primal remnant
#

Ok so a nice prefix can fix that

fading horizon
#

but this is also why it's good to immediately do a check in your functions to determine if it's your mod or not

frosty stirrup
fading horizon
#

such as here

#
local function OnFillInventoryObjectContextMenu(player, context, items) --# When an inventory item context menu is opened
    local playerObj = getSpecificPlayer(player);
    items = ISInventoryPane.getActualItems(items);                              
-- Get table of inventory items
    local isVape = nil;                                                         
-- Define a variable to hold the potential vape item
    for _, item in ipairs(items) do                                             
-- Check every item in inventory                         
        if item:getDisplayCategory() == getText("IGUI_ItemCat_Vape") then       
-- If item is a gnome bar, it is caught in a variable.
            isVape = item;                                                      
-- We check if it's our item first to reduce load time since this is called every time an option is right clicked.
            -- // (item:getFullType())
            break
        end
    end

if isVape ~= nil then 
do whatever
#

so basically when any item is right clicked (the OnFillInventoryObjectContextMenu function, which is vanilla)

#

it grabs a table of items in the inventory

#

then it checks the item to see if it has the "vape" displayCategory immediately

#

We check if it's our item first to reduce load time since this is called every time an option is right clicked.

fading horizon
#

but yes, most likely

echo fiber
#

so if i wanted to make it check for a tag instead of checking if it has the displayCategory id put hastag where you have getText?

faint jewel
#

damn, it's vapechat time

echo fiber
#

xD yes it is

#

mostly me just learning lua or trying to understand it cuz youtube was not helping at all

faint jewel
#

player:getForwardDirection():getDirection(); how would i get the vehicle version of this? as the angles are not the same using vehicle:getAngleY()

#

i am still trying to get this answered lol.

fading horizon
#

yes

#

it is

#

C:\Program Files (x86)\Steam\steamapps\common\ProjectZomboid\media\lua\client\TimedActions\ISTakePillAction.lua

#

ISTakePillAction.lua

echo fiber
# fading horizon yes

okay so timed actions is what gives that call back for making the players unhappyness (Ex.) to change? or is the takePillAction used in something else that im skipping over

fading horizon
#

no, you're correct

echo fiber
#

yay i learned somethin!

fading horizon
#

basically every timed action will have the following functions

#

luckily

#

i commented this out so i can show it

#

lmao

#

COMMENT YOUR CODE KIDS

echo fiber
#

xD

#

ill have to start adding comments to all mine haha

red tiger
#

Documentation even.

fading horizon
#

every timed action will have these essential functions

echo fiber
#

so how do i tie this into crafting?

fading horizon
#

most of my code happens in the "perform" section

#

so now that you understand timed actions, lets go back here for a moment

echo fiber
#

id probably lose the vaping sounds though

fading horizon
#
local function OnFillInventoryObjectContextMenu(player, context, items) 
--# When an inventory item context menu is opened
    local playerObj = getSpecificPlayer(player);
    items = ISInventoryPane.getActualItems(items);                              
-- Get table of inventory items
    local isVape = nil;                                                         
-- Define a variable to hold the potential vape item
    for _, item in ipairs(items) do                                             
-- Check every item in inventory                         
        if item:getDisplayCategory() == getText("IGUI_ItemCat_Vape") then       
-- If item is a gnome bar, it is caught in a variable.
            isVape = item;                                                      
-- We check if it's our item first to reduce load time since this is called every time an option is right clicked.
            -- // (item:getFullType())
            break
        end
    end
#

so this is me creating the context menu

#
if isVape ~= nil then               
-- # if the clicked item is a vape, add the vape context menu item

        local isFav = context:getOptionFromName("Favorite");
        local opt
        local CMIcon = vape_config.ModOptions.options.box3 and true        
-- !! if option is not enabled, true. If it is enabled, false
        -- // print(CMIcon)
        if isFav then
            opt = context:insertOptionAfter("Favorite",getText("UI_vape_action"), isVape, callVapeAction, playerObj)    
-- !! Need to also pass the player object here so the timed action can use it  |  Insert after "favorite" so it's in the normal "smoke" position
        else
            opt = context:insertOptionAfter("Unfavorite",getText("UI_vape_action"), isVape, callVapeAction, playerObj)  
-- !! Inserting option after unfavorite. If neither exists, it will just add it to the bottom of the stack by default.
        end

        if CMIcon == true then
            opt.iconTexture = getTexture('media/textures/context.png');                 
-- Icon that displays adjacent to context menu item
        end

        if not (isVape:getUsedDelta() > 0) then
            --print("no charge")
            opt.notAvailable = true;
            opt.tooltip = "this vape is dead"
        end

        
-- local op2 = context:insertOptionAfter("Favorite","Check Flavor", isVape, getFlavor) --DEBUG 

    end
end```
#

that's the context menu created

red tiger
#

I filled out a decent portion of properties for the extension

echo fiber
#

and thats under ContextMenu.lua?

fading horizon
#
local function callVapeAction(vape,player)                  
-- # Callback function to start the hitvape timed action - triggered by hitting "vape" context menu
    ISTimedActionQueue.add(hitVape:new(player,vape));
end```
red tiger
#

Got stuff done today.

#

Food, literature and drainables

fading horizon
#

callVapeAction gets called when the context menu is clicked.

callVapeAction adds my custom "hitvape" timed action to the timed action queue

#

this is all in the same lua file, just a custom one in timedActions folder

echo fiber
#

so where i need to start first is making a timed action

fading horizon
#

that's how I did it at least

#

I tried modifying vanilla functions

#

tried using pills too, actually but I also ran into issues

#

i tried a bunch of different stuff because making a timedaction seemed overwhelming

#

but in the end, if you want full control and no vanilla wonkyness, making your own timed action is the way to go

faint jewel
#

๐Ÿ˜

echo fiber
#

sorry Skizot >.<

fading horizon
fading horizon
#

bc idk but i'm sure someone does

echo fiber
#

time for me to go learn how to make a timed action ๐Ÿซก

fading horizon
#

i think i have a guide

#

ill look

#

regarding where files go

primal remnant
#

Any idea how to set up a console.txt error file? My mod has seemingly broken the item list in debug mode, and I can't figure out how to see the error that shows up when I reload lua at the start screen.

fading horizon
#

C:\Users\YOURUSERNAME\Zomboid\console.txt is where it should be located

#

then you can ctrl+f for "stack trace" or "error"

primal remnant
#

found it, thanks so much.

#

Caused by: java.lang.NullPointerException: Cannot read field "name" because "this.module" is null
at zombie.scripting.objects.Item.getModuleName(Item.java:1009)

I have given everything custom names, but do I need to rename my custom items with a prefix to my mod?

fading horizon
#

at the beginning of your item script file do you have something like the following?

#
{
imports
    {
        Base
    }```
primal remnant
#

I do. It doesnt seem to be working.

fading horizon
#

can you post one of the items

#

maybe theres an issue there

primal remnant
#

item LargeSaltContainer
{
DisplayName = Large Salt Container,
DisplayCategory = Food,
Type = Food,
Weight = 0.75,
Icon = Salt,
CantBeFrozen = TRUE,
EvolvedRecipe = Pizza:1;Soup:1;Stew:1;Pie:1;Stir fry Griddle Pan:1;Stir fry:1;Burger:1;Salad:1;Roasted Vegetables:1;RicePot:1;RicePan:1;PastaPot:1;PastaPan:1;Sandwich:1;Sandwich Baguette:1;Taco:1;Burrito:1;Beverage:1;Beverage2:1;Beer:1;Beer2:1,
Spice = true,
HungerChange = -10,
ThirstChange = 20,
UnhappyChange = 20,
WorldStaticModel = LargeSaltContainer,
FoodType = NoExplicit,
Tags = MinorIngredient;Salt,
}

#

WARN : Recipe , 1681339127130> RecipeManager.resolveItemModuleDotType> WARNING: module "Base" may have forgot to import module Base

tough leaf
#

Hello, trying to create a fire starting/stopping tool however on key presses nothing happens

CheatCoreCM.CM_TempCoord = nil;
function CheatCoreCM.OnKeyKeepPressed(_keyPressed)

    if CheatCoreCM.FireBrushEnabled == true then
        local GridToBurn = CheatCoreCM.getSqObjs()
        if _keyPressed == 49 then
            GridToBurn:StartFire();
        elseif _keyPressed == 33 then
            GridToBurn:stopFire()
            if isClient() then
                GridToBurn:transmitStopFire()
            end
        end
    end
``` Its supposed to be N to start and F to remove fire
fading horizon
#

that all looks correct

primal remnant
#

java.lang.NumberFormatException: For input string: "LargeSaltContainer" at FloatingDecimal.readJavaFormatString.
ERROR: General , 1681339127126> DebugLogStream.printException> Stack trace:
java.lang.NumberFormatException: For input string: "LargeSaltContainer"

#

And it was all working a couple days ago.

fading horizon
#

my method of troubleshooting would be removing one line at a time from the item script until something changes

#

or take a look if any of your recipe code is using that item and maybe theres an error there if that doesn't work

primal remnant
#

Ill try removing the recipe entirely.

#

Maybe make it a simple normal item.

tough leaf
#

are GridToBurn:StartFire(); and GridToBurn:stopFire() still valid vanilla functions to use?

faint jewel
#

why DONT vehicles have getForwardDirection??

bronze yoke
#

is getForwardVector() no good?

primal remnant
#

Ok this is weird "The NumberFormatException is an unchecked exception in Java that occurs when an attempt is made to convert a string with an incorrect format to a numeric value."

So then why is it trying to convert my items name into a number?
"java.lang.NumberFormatException: For input string: "LargeSaltContainer" at FloatingDecimal.readJavaFormatString."

faint jewel
#

it gives me shit on the first line

#

nowa better quest.. and might save me a TON of grief. how can i get all objects in a parts area?

primal remnant
#

Ok, here's where I think the issue is happening.
It appears to be trying to create a table of items from my module and is just failing at it. Any ideas?

versed prism
#

Off the top of your head, how difficult would it be for me to make an "it follows" mod with basic understanding of lua but the motivation to learn?

#

By "it follows" I mean spawn a single zombie that knows where you are at all times and has infinite health

primal remnant
#

Not sure, what you meant by F code thing, Im using visual code community edition.

#

Im about to make a forum post about it. Ill share the link when its up

versed prism
#

Is there any documentation for creating a custom zombie entity or class?

echo fiber
#

@fading horizon so where it says IsInfected would i put IsStressed?

fading horizon
#

There's no isStressed

#

There's only set stress

echo fiber
#

so it would be SetStress?

fading horizon
#

That has the functions

#

Sorry, afk rn

red tiger
#

Thinking about buying some sushi.

#

Then coding on my extension.

echo fiber
#

lol thank you Maemento for the fast reply also Jab get some sushi its healthy โค๏ธ

fading horizon
#

Of course! Happy to help

red tiger
#

I've eaten a fair bit last week.

fading horizon
echo fiber
#

so how do i change IsInfected?

#

to check for stress unless its in that code one sec ill look over it again i have ADHD im everywhere atm

fading horizon
#

getStress() is how you get stress

#

You got is infected right

#

You just set it to false

echo fiber
#

we are using the timed action from They Knew to kind of get an idea

#

tbh im a visual learner and am struggling with this

red tiger
#

2 things of sushi later (one cooked, one raw), I'm feeling a bit better.

primal remnant
#

Has something materially changed with the game in the past 48 hours? Any patches or anything like that?
I'm using PantryPacking as an example and copied it to a T, but my mod that was working perfectly two days ago is no longer functional and I can not troubleshoot it further. Now, not even pantry packing is working in debug mode. I've hit an absolute wall and can not progress my mod any further.

bronze yoke
#

we haven't had a patch since 2022

frank elbow
#

Are you testing on the same save you been testing on? Maybe the save is the issue

primal remnant
#

Ive been generating a new save with each test.

#

And what's so frustrating is I have duplicated the mod, split a single item into each mod, changed all naming conventions and id's so there's no overlap, and it's still not working.

#

But one will work randomly lol

#

Here's the entire code if you want to take a look and tell me what obvious thing Im missing.

module BusketsBaking
{
imports Base
{

}

model LC_Salt
{
mesh = WorldItems/LargeSaltContainer,
texture = WorldItems/LargeSaltContainer,
scale = 0.1,
}

item LC_Salt
{
DisplayName = Large Salt Container,
DisplayCategory = Food,
Type = Food,
Weight = 0.75,
Icon = LargeSaltContainer,
CantBeFrozen = true,
Spice = true,
HungerChange = -10,
ThirstChange = 20,
UnhappyChange = 20,
WorldStaticModel = LC_Salt,
FoodType = NoExplicit,
Tags = MinorIngredient,
}

recipe Pack up Salt
{
Salt = 5,

    Result = LC_Salt,
    Time:20,
}

}

frank elbow
#

Have you already checked console.txt

primal remnant
#

Sure have. Found plenty of errors, none of which make sense. I'm starting to think that the mod I was using for reference wasnt done properly. It also does not work in debug mode.

#

Yup, confirmed. The PantryPacking mod is no longer functional. Gonna try it without my mod activated.

#

My mod was interfering with PantryPacking. Gonna swap some file names around and see if that does the trick.

#

I think I found it.

Result = LC_Salt, should be Result : LC_Salt = 1,

echo pecan
#

who here is developing a prone mod

#

like

echo fiber
#

so we keep getting this error when we call to our function in our timed action, but in our timed action we have it labeled the same are we missing something?

bronze yoke
#

the function might be local

echo fiber
#

so right now this is the thing we are trying to get the timed action to call to

#

so when it is created it will make the player do an animation a sound and then change the players stats so the OnCreate: RedVapeUseVape is the function and in the timed action it does not play and throws that error

#

not sure if im making things difficult doing it this way but we choose this way as it seamed simpler

dusty wigeon
#

how do i create a new function

echo fiber
#
require "TimedActions/ISBaseTimedAction"

UseVape = ISBaseTimedAction:derive("UseVape");

function UseVape:isValid()      -- Check if the action can be done
    return true;
end

function UseVape:update()       -- Trigger every game update when the action is perform
    print("Action is update");
end

function UseVape:waitToStart()  -- Wait until return false
    return false;
end

function UseVape:start()        -- Trigger when the action start
    print("Action start");
end

function UseVape:stop()         -- Trigger if the action is cancel
    print("Action stop");
    ISBaseTimedAction.stop(self);
end

function UseVape:perform()      -- Trigger when the action is complete
    print("Action perform");
    ISBaseTimedAction.perform(self);
end

function UseVape:new(character) -- What to call in your code
    local o = {};
    setmetatable(o, self);
    self.__index = self;
    o.character = character;
    o.maxTime = 30;              -- Time take by the action
    if o.character:isTimedActionInstant() then o.maxTime = 1; end
    return o;
end

This is what we have so far (Note: changed it from RedVapeUseVape to = UseVape but when we try to call it from the recipe above it just says it cant find that function or says, function does not exist

faint jewel
#

dammit... so close

#

the remove is ALWAYS up left

#

which looks great if you are facing bottom right

#

stupid matrixes crap.

echo fiber
#

can i pay someone to sit in a VC and teach me how to make a timed action ๐Ÿ˜…

echo fiber
#

@fading horizon how did you get the function to work? i keep getting no such function "UseVape"

faint jewel
faint jewel
#

i need to get the exit point to be the middle of an area.

primal remnant
#

I want the following line of code to give me 5 salt items instead of one, but Im unsure of the syntax here. I can just copy paste it 5 times, but I'm wondering if there's a simpler way to do it.

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

#

Im going to do some useDelta checks to give only the full portions of a large combined item back.

sour island
unborn radish
#

I would like to bump this

#

I really need help

primal remnant
#

@unborn radish The first thing I would check is does the mod come with a server side lua file. It may not be designed for MP at all.

#

The top comment on April 11th, says it does not work in MP and the creator has yet to respond.

#

@sour island I finally saw that bolded S, and it works like a charm. Thanks so much. I JUST WROTE MY FIRST CUSTOM LUA FUNCTION WOOOOOO!

sour island
#

Yeah, I probably should have been more specific drunk

echo fiber
#

lol wanna help me out captin XD

primal remnant
#

I can try man, but Im as new as you. You wanna hop in a VC? I'll give ya 20 minutes to look this over then back to the grind for me.

echo fiber
#

that would be amazing!

#

we just need fresh eyes

primal remnant
unborn radish
#

the original car mod does work in MP, they just spawn with their original names instead of my edited ones

#

in singleplayer, however, my edits work

fast galleon
craggy ruin
#

@frank elbow thanks you dude for everything, it was 3 night shift in order to do it, but I managed to learn how to develop mods on LUA using official API, and successfully created the respawn timer that I needed.

thanks you very much! let me know if any of wants to take a look at the code or something ;))

unborn radish
fast galleon
#

if you have something specific or explain what you do to change the names then this is the place. You'll still have to test yourself probably though.

primal remnant
#

Hey guys, just got a syntax question. There's this ---@ symbol in the following code. Just wondering if it's saving the variables type and passing it onto the next declared variable, or it if does something else entirely.

for k,savedUse in pairs(savedUses) do
---@type DrainableComboItem
local newItem = inventory:AddItem(itemToAdd)
newItem:setDelta(savedUse)
end

fast galleon
#

it's a comment that doesn't affect the execution of code

frosty stirrup
#

Hello, could someone help my failing google-fu and remind me, how to adjust WorldStaticModel scale without changing actual model?

#

I seem to recall there was a way to do it, inside of model itself.

#

But is there a way to adjust scale for specific items only, without changing the model properties?

#

Or is it impossible because the only thing actual item has, is a reference to a model, and the rest is just a model property?

primal remnant
#

scale = 0.1,

frosty stirrup
#

That's in the model, yep.

#

But I am curious if there's a way to adjust scale of a specific item only, it seems like the answer is no

primal remnant
#

No. Youd need to create another model, use the same mesh, and adjust the scale accordingly.

#

You could do a model that was large, medium, and small and then call which one you wanted.

#

@frosty stirrup I'd also suggest checking with the modeling group chat. They're a bit more helpful than the mod dudes, lol.

#

I guess your question could go either way though :\

fading horizon
#

is there a way to make the character throw an item at the nearest wall

#

lol

fast galleon
#

The game has an item Football, and other throwables. Or you can just remove it from inv. and place it near wall.

#

PhysicsObject = Ball

tiny wolf
#

Hello everybody ๐Ÿ™‚
I'm trying to increase the foodsicknesslevel of players in conditions on a server with my mod and i'm encountering difficulties : do you know a lua function or something that time or wait for few seconds or something ? Like a Wait(10) or something like that ? it could be really usefull because foodsicknesslevel increase really to quickly even if i use 0.001 unit

fast galleon
fading horizon
#

you can now waterboard stuart little

hot patrol
fading horizon
#

i'm just gonna copy the description since it explains it perfectly

#

Do you also have a never-ending hatred towards that disgusting rodent who plagued both our eyes and our minds as he presented his unparalleled evil to us in its rawest and most disgusting form?

Don't believe me? Go ask him where he was on November 22nd, 1963...

I've heard he even facetimes the orphans back at the orphanage just to rub salt in the wound.

Heโ€™s got an annoyingly smug face and I donโ€™t understand how he tried to get into a relationship with a bird (a completely different species) and also the fact that the Little family adopted him instead of orphaned children who obviously needed it a lot more than Stuart.

I have terabytes of accumulated hate speech against Stuart Little but I will spare you the details.

fading horizon
#

you too

drifting ore
#

player:getInventory(); how do I get something like this but for backpacks as well?

neon bronze
#

getItems() if im not wrong

drifting ore
#

Thank you!

tiny wolf
merry storm
#

Which lua version are you using to modding PZ? i cant create a module cause it says its deprecated

fast galleon
#

PZ uses Kahlua, it's sort of Lua 5.1.

merry storm
#

i see , thank you

hot patrol
#

can anyone help me with exporting weapons? Are you supposed to export them under the X axis because when I do they appear correctly in your hands but when I try to make adjustments for back placement using the attachment editor they are placed all wrong. Exporting them above the x axis like I would asume you should fixes the attachment editor but then breaks the hand positioning.

#

I'm beating myself over the head with how you handle weapon models

sour island
#

My avoidance of scripts has come back to hurt me -- in recipes what's the difference between just using the ingredient as a line and including destroy?

fast galleon
#

example for destory would be a drainable like battery will be removed instead of used

sour island
#

ah

#

trying to use parseScript in realtime to create a recipe from a sandbox option

#

it's refusing to work with [getypefunction] for some reason

#

defaults to a black digital watch that isn't really a black digital watch

fast galleon
#

There's some functions in Recipemanager like OnLuaLoaded I think.

#

Otherwise you can autopopulate the source items.

sour island
#

Give ingredients gives me paper but it refuses to become valid - I wonder

#

ah I left the oncanperform function empty

#

that wasn't the issue

#

seems like the issue is using parseScript in real time

hollow current
#

hello gentlemen

#

I have a problem with one of my mods. What the mod basically does is adding a search button to containers, then when type a string, it sorts the items in said containers according to best matching items. The problem with the mod is that if the container has a really big amount of items, it may cause extreme FPS drops, sometimes even freezing the game

#

I've tried different approaches with the logic, and at this point I am not sure if the problem is even fixable with that kind of mod, or if I am looking in the wrong place

#
-- Function to return similarity score between two strings using the Jaccard similarity coefficient algorithm

function searchContainers:stringSimilarity(a, b)
    local n = #a
    local m = #b
    if n == 0 or m == 0 then
        return 0
    end

    local min_len = math.min(n, m)
    local max_len = math.max(n, m)

    local intersection = 0
    local j = 1
    for i = 1, min_len do
        local c = a:sub(i, i)
        while j <= m do
            if b:sub(j, j) == c then
                intersection = intersection + 1
                j = j + 1
                break
            end
            j = j + 1
        end
    end

    return intersection / max_len
end```

The function used to measure similarity between strings
#
function searchContainers:sortByStringMatch(items, searchString)
    -- Create tables to store matching and non-matching items
    local matchingItems = {}
    local nonMatchingItems = {}

    -- Loop through the items and add them to matching or non-matching table
    for _, item in ipairs(items) do
        local name = string.lower(item:getName()) -- convert name to lowercase for case-insensitive comparison
        local match = string.find(name, string.lower(searchString)) -- check for partial match
        if match then
            table.insert(matchingItems, item)
        else
            table.insert(nonMatchingItems, item)
        end
    end

    -- Sort the matchingItems table based on how closely the item's name matches the search string
    table.sort(matchingItems, function(a, b)
        -- Calculate the similarity score for each item's name compared to the search string
        local scoreA = searchContainers:stringSimilarity(string.lower(searchString), string.lower(a:getName())) or 0
        local scoreB = searchContainers:stringSimilarity(string.lower(searchString), string.lower(b:getName())) or 0

        -- Sort the items in descending order based on their similarity score
        if scoreA == scoreB then
            -- If the similarity scores are the same, sort alphabetically
            return a:getName() < b:getName()
        else
            return scoreA > scoreB
        end
    end)

    -- Concatenate the two tables to create a new sorted table with all items
    local sortedItems = {}
    for _, item in ipairs(matchingItems) do
        table.insert(sortedItems, item)
    end
    for _, item in ipairs(nonMatchingItems) do
        table.insert(sortedItems, item)
    end

    -- Return the sorted table
    return sortedItems
end```
Function used to actually sort the items
#
ISInventoryPane.itemSortBySearchContainer = function(a, b)
    local sortedItems = ISInventoryPane.sortedItems
    local sortedIndex = {}

    -- Create a lookup table for the sorted items
    for i, item in ipairs(sortedItems) do
        sortedIndex[item:getName()] = i
    end

    -- Compare the positions of the items in the sorted table
    local aIndex = sortedIndex[a.name]
    local bIndex = sortedIndex[b.name]

    if aIndex and bIndex then
        return aIndex < bIndex
    elseif aIndex then
        return true
    elseif bIndex then
        return false
    else
        -- If both items are not in the sorted table, use the default sorting function
        return ISInventoryPane.itemSortByNameInc(a, b)
    end
end```
#

Rest of code ^

#

there are a few irrelevant lines in between to put the code together

sour island
#

You are running this for every frame or just when the search bar is changed?

hollow current
#

the code runs when the player clicks "ok" in the modal that pops up after you press "search"

#

Supposedly, at least.

#
function ISInventoryPage:onSearchSuccessful(button)
    -- Check if the OK button was clicked
    if button.internal == "OK" then
        -- Check if the textbox input is not empty
        if button.parent.entry:getText() and button.parent.entry:getText() ~= "" then
            searchString = button.parent.entry:getText()
            self:onSearchContainer(searchString)
        end
    end
end```
#

then onSearchContainer calls searchContainer function

function ISInventoryPage:onSearchContainer(searchString)
    self.inventoryPane:searchContainer(searchString)
end```
solar wharf
#

Sorry for the dumb question but is this python?

hollow current
#

no its Lua

solar wharf
#

Never heard about it but thx i will check it

hollow current
solar wharf
#

Thx im trying to learn programming and also modding :)

hollow current
#

Best of luck though :)

fast galleon
solar wharf
#

Thx u rn im learning java so gonna take a while

frosty stirrup
#

Hello, how would I go about deleting a specific item in LUA script?

#

There doesn't seem to be item:delete() or item:remove()

#

Just to explain what I want to do. I want to improve weapon upgrade in Scrap Guns mod.

It currently says "REMOVE MAGAZINE" in recipe, and it basically destroys the original gun and then creates a new one.

I want to keep the condition, magazine etc.

I am trying to do something like this

  1. At first I "keep" the item in the recipe
  2. Then
function Recipe.OnCreate.UpgradeSAR(items, result, player)
    local addTypeBase = "Base.LeatherStrips"
    
    
    for i=0,items:size() - 1 do
        local item = items:get(i)
        if item:getType() == "SAR" then
            --<the code to inherit properties of item goes here>
            item:destroy(?)
        end
    end
    --<the code to create SARB goes here, and then the code to inherit properties>
end
#

Can't figure out how to destroy the item porperly

#

And I've just realized that it's also unclear how to get the actual magazine object from inside of the gun, since HandWeapon doesn't have such field or method...

frosty stirrup
#

Ah, I think I found a solution, sorry for spamming

obsidian horizon
#

so i have managed to get the item ingame, but when i try to drop the item it throws errors, i can equip the item as i yoinked the motercycle helmet code
i just cant seem to get the 3d model in game
what am i doing wrong?

frosty stirrup
#

If someone finds my question and doesn't know how I solved it, here it is


function SAR_Upgrade(items, result, player)
    for i=0,items:size()-1 do
        local item = items:get(i)
        if item:getType() == "SAR" then
            result:setCondition(item:getCondition())
            result:setCurrentAmmoCount(item:getCurrentAmmoCount())
            if result:haveChamber() and item:haveChamber() and item:isRoundChambered() then
                result:setRoundChambered(true)
            end
             if item:isContainsClip() or ( item:getCurrentAmmoCount() > 0 and item:getMagazineType() )  then
                result:setContainsClip(true)
            end
            local modData = result:getModData()
            for k,v in pairs(item:getModData()) do
                modData[k] = v
            end
            result:attachWeaponPart(item:getScope())
            result:attachWeaponPart(item:getClip())
            result:attachWeaponPart(item:getSling())
            result:attachWeaponPart(item:getCanon())
            result:attachWeaponPart(item:getStock())
            result:attachWeaponPart(item:getRecoilpad())
                player:setPrimaryHandItem(result);
                player:setSecondaryHandItem(result);
            return
        end
    end
end```
#

I call this in OnCreate, so all source item properties including attachments etc are passed to target item

obsidian horizon
#

one sec let me pull the file

dusty wigeon
#

is there a simpler way to write a distributions.lua for a mod with a ton of items

red tiger
#

PLEASE. FIX. YOUR. SPACING.

#

lol

obsidian horizon
#

ffs

#

better?

hot patrol
#

Sometimes this modding thing can be painfully annoying. I have been stuck with this attachment editor issue for like 3 days doing everything to get my weapons to appear the way I want to no avail only to finally figure it out by.. literally doing what I've been doing that was failing. Idk if I was just missing something the past few times or PZ just wants me to rip my hair out but I am just happy to be done with it.

red tiger
# obsidian horizon better?
module Base
{    
    item alexshead
    {
        Type = Clothing,
        DisplayCategory = Accessory,
        DisplayName = Alex Helmet,
        ClothingItem = Hat_alexhelm,
        BodyLocation = FullHat,
        Icon = alexhead,
        CanHaveHoles = false,
        BloodLocation = FullHelmet,
        BiteDefense = 100,
        ScratchDefense = 100,
        BulletDefense = 100,
        DisplayCategory = Armor,
        ChanceToFall = 0,
        Insulation = 0,
        WaterResistance = 0.40,
        Weight = 1.0,
        Tooltip = "This is alexs head its unique",
        WorldStaticModel = alexshead,
    }
    
    model alexshead
    {
        mesh = alexshead,
        texture = alexhead,
        scale = 1.0,
    }
}
#

Trust me, keeping things orderly and formatted will help with your sanity.

#

I'm going to be drafting two format options for ZedScript.

#

At this point I'm going to assume that I'll be the only one to set standards with ZedScript.

obsidian horizon
#

TYSM

obsidian horizon
red tiger
obsidian horizon
#

i will look into that thanks

red tiger
#

In computer programming, an indentation style is a convention governing the indentation of blocks of code to convey program structure. This article largely addresses the free-form languages, such as C and its descendants, but can be (and often is) applied to most other programming languages (especially those in the curly bracket family), where w...

#

This is also a good reference for industry-standard formats for c-style bracing.

#

I use this

#

C# uses Allman bracing.

dusty wigeon
#

any ideas on how i could write a simpler distribution file that would work with more items. Like would i be able to somehow set items just to spawn completely at random

#

without specific loot tables

drifting stump
#

haskell style is truly the best identation style

drifting stump
dusty wigeon
#

pretty much

drifting stump
dusty wigeon
#

i want to be able to have all my items as one singular called item and able to implement it into the distributions

drifting stump
#

you can iterate over the distribution table and assign the same table to the leaves of the tree

red tiger
#

"Haskell"

frosty stirrup
drifting stump
red tiger
drifting stump
#

๐Ÿ˜”

#

i didnt need to see its indentation applied to conventional languages

frosty stirrup
#

@drifting stump Oh hey, huge thanks to you personally too.

#

It feels so nice when your mod is finally functional 100% you want it to be ๐Ÿ™‚

#

I have that huge influx of endorphin now

dusty wigeon
#

@drifting stump still confused

red tiger
#

The mental lift from that experience may pull you from reality for a bit.

drifting stump
#

you have tables containing other tables which are branches

#

tables at the edges meaning no child tables contain the actual information and are called leaves

#

you can iterate over it and any edge table you replace with your table

dusty wigeon
#

this type of thing is whats bugging me

drifting stump
#

just iterate over it

dusty wigeon
#

how

red tiger
#

xD

drifting stump
#
for key, value in pairs(hashTable)
    --do your thing
end

for index, value in ipairs(arrayTable)
    --do your thing
end
dusty wigeon
#

im still new this is my second day learning all this so im sorry if im not understanding fully

drifting stump
#
for key, value in pairs(ProceduralDistributions["list"])
    table.insert(value.items, "Vape?")
    table.insert(value.items, 0.05)
end
dusty wigeon
#

...so the hashtable is the things like the procedural list and the other lists of sorts?

drifting stump
#

a hashtable is a table in the style of table["key"] = value

#

arraytable is table = {"aa", "bb", "cc"}

#

one is accessed with keys and other with indexes

dusty wigeon
#

so would i use the array to list the items and the hashtable for the distributions locations

drifting stump
#

those are multiple hashtables

red tiger
#

Couldn't you simply call it without array-like-syntax?

drifting stump
#

when you do table.insert it inserts at the final index

red tiger
#

ProceduralDistributions.list.SecurityLockers.items

drifting stump
#

yes

red tiger
#

Seems like excess to do it the way shown.

drifting stump
#

[""] is only needed when there are spaces in the key

red tiger
#

Or illegal characters yeah.

dusty wigeon
#

im just looking for the easiest way to build a distribution of my items

red tiger
#

Don't mind me.

#

I'm not helping anyone by saying this. xD

#

Programming is a hell of a learning curve for first-timers.

#

So be patient with yourself.

#

It'll take time.

dusty wigeon
#

ive been doing nothing but trying to learn this for i think 2 full days now and im working on 2 mods

#

was getting aggravated with my first one as i bit off more than i thought and this one i thought would be easier

merry storm
#

Hi guys, i need some help. Any idea about how to reference a function from a new item into his action function?
This is looing for the OnInject_ExperimentalSyringe function, i have created it on client with the same name in a lua file, but i think im missing something to connect there two functions

bronze yoke
#

as long as the function is global and named correctly it should connect

merry storm
#

I think its because im trying to use it in a server environment

red tiger
#

The server-side of PZ is in such a mess right now..

#

I see so much of this problem here.

merry storm
#

yeah, it was just that. I just had to add that file in the server side, ahg! Thanks ๐Ÿ™‚

unborn radish
#

So the original mod has got one file where all the names are. I copied it to my mod, changed it, then uploaded it

#

There is no other name file in the original mod as far as I can see

#

and I did check

red tiger
#

=)

frank elbow
red tiger
#

I'm too technical to be helpful to most people here.

frank elbow
#

Striking that balance can be difficult & I don't think I always get it either

red tiger
#

I help people with solutions.

frank elbow
#

There have been a few times here where I've explained something and then someone else has had to explain it in better words

#

Or more accessible words, I suppose

red tiger
#

Yeah.. It's a tradeoff to get how things work.

#

You lose some of your humanity in the process.

#

Working on clothing properties

#

Enum templates are powerful.

#

Means less time spent looking up definition tables in Lua code.

red tiger
# red tiger

It might also be a good idea to look at possibly generating these Lua functions and storing them on the OS's clipboard.

#

I can see copying generated functions as a good way to aid in implementing Lua properties for scripts.

#

More useful that those generated functions could provide documentation of the parameters passed to it.

ancient grail
#

My workshop is down for some reason

There was an error loading user files: 16```

Anyone knows about this
fast galleon
#

same

#

works if I use the link from my profile

frosty stirrup
#

There are problems with workshop now for everyone

wet sandal
#

Insurgent is gone?

#

Oh

#

Errors for everyone

#

maybe thats it

#

My notification area says the item was deleted though pepehmmm

wheat kraken
faint jewel
#

anyone know how to check the distance between a car and the center of a vehicle area?

hot patrol
red tiger
#

(This actually happened)

#

It's not frowned here as long as you don't spam it.

hot patrol
#

lol nah I'm not that desperate. and yea good to know

wet sandal
hot patrol
#

geez I just noticed that 48,000 people use that mod. I am equal parts disgusted and proud

#

much like my parents I assume

#

only not proud

red tiger
#

I saw that ~40 people are using my extension even though it's not complete.

hot patrol
#

funny thing is only a little over 1000 people use my mod that is actually not a shit post and meant to be helpful..

#

ok I am done now

red tiger
#

At one point I believe that several hundreds of thousands of people used my first Java patch mod.

#

Was during 2015-2016.

hot patrol
#

very nice.

bronze yoke
#

did zomboid even have hundreds of thousands of players in 2016?

hot patrol
#

That's a pretty good question. I was much more of an on and off player before B41.

#

I was more DayZ back then

#

PZ was always that game that had a solid foundation but not enough to keep me gripped

wet sandal
#

I keep trying to get my friends to play the game with me

#

But they all hate the inventory system

hot patrol
#

I can't entirely blame them. It took a while for it to grow on me as well.

red tiger
#

Hydrocraft had over a million subs at that point.

hot patrol
#

your next update for the inventory will be awesome since I've always like the tertis style inventories

red tiger
#

Hydrocraft and ORGM used my patch to add custom 3D models into the game at that point.

wet sandal
#

Really wish the core of my grid code was in TS

#

I need to refactor how moddata is stored and its a huge pain with lua

red tiger
hot patrol
#

I was nevver a fan of hydrocraft. still not tbh. it's not bad or anything but it's just too much for me. it reminds me of those super advance tech minecraft mods. Plus the art inconsistencies on things were not pleasing to the eye.

#

I always think of that one reddit post

#

of all the pets with different pixel art

wet sandal
red tiger
wet sandal
#

PipeWrench is what I'm looking for?

red tiger
#

Yup.

#

If you need help, ask questions.

#

(I made PipeWrench)

wet sandal
#

I know, haha

#

Thank you

red tiger
#

No problem.

wet sandal
#

Lua is great for fast development and smaller mods, but this one has deifnitely passed the sanity threshold

viscid drum
#

does anyone know if Nolan still updates his mods? I love the backpack attachment mod, but unfortunately the insurgent backpacks haven't been included in it

red tiger
#

Lua is not made for this scale of code.

frank elbow
hot patrol
polar trail
#

LUA helps maroons like me mod

frank elbow
#

Of course I haven't seen the code you're referring to, so maybe it truly is better suited for TS. But I don't think languages are often to blame for things like that

red tiger
polar trail
#

Iโ€™ve made a few personal mods for recipes

#

Iโ€™m not a coder so I wouldnโ€™t know much tbh

red tiger
wet sandal
frank elbow
#

I get intellisense just fine through a somewhat annoying process of generating the type stubs

red tiger
frank elbow
#

Once you do the process once, though, it's fine

red tiger
#

I'm open about how helpful that is for my work. It makes me comfortable when in the PZ environment.

wet sandal
#

Dammit

frank elbow
#

???

red tiger
#

Haha what was that.

wet sandal
#

No one saw that

frank elbow
#

Imagine this:

wet sandal
#

copy pasta i sent on a private server earlier

frank elbow
#

Lmao

red tiger
#

Damn bro take a lap.

wet sandal
#

Courtesy of NalMac actually

bronze yoke
#

the only major issue i have with lua is performance (pz especially), but ts won't fix that

red tiger
bronze yoke
#

there's a few things that bug me (i think a global keyword would make more sense than a local keyword) but nothing that makes me not want to use it

red tiger
#

Only rewriting the Lua code to TS might have a performance effect however the Java Engine PZ has is the biggest component of performance issues.

wet sandal
#

I've only run into performance issues once with Lua. Building air quality modeling in Louisville for the upcoming Susceptible update.

hot patrol
frank elbow
#

Society would be so much better if Lua variables were local by default

#

We would have flying cars by now I think (I agree that'd be preferable, to be clear)

wet sandal
#

I copy pasta'd ur steam description on another server, and accidentally pasted it here while correcting a typo I made.

red tiger
bronze yoke
#

yeah, ts generated lua might run a bit better than human written lua, but the main problem is lua itself

hot patrol
#

I am sad to have missed that

frank elbow
#

True

red tiger
#

Agreed.

bronze yoke
#

especially with pz singlethreading it stressed

red tiger
#

Having something guide you to optimize your work and compile to optimized Lua is a good idea.

#

PipeWrench also sells itself on IntelliSense combined with additional API / libraries to forward information on what you are using with things like Events.

#
  Events.onObjectAdded.addListener((object: IsoObject) => {
    if (object != null) {
      print(`IsoObject added: ${isoObjectToString(object)}`);
    }
  });
polar trail
#

Has anyone ever messed around with the infected wound code

#

Or no where itโ€™s at

red tiger
#

You can waste a lot of time simply looking up what you're using.

polar trail
#

Know

red tiger
#

I'm solving the exact same issues with ZedScript as I did with PipeWrench.

bronze yoke
#

probably in bodypart

#

i've looked at it before but i don't remember exactly where

frank elbow
#

I was thinking bodydamage but I'm not home to check

viscid drum
#

Sorry i had the wrong name, meant to ask if Noir still updates his mods?

red tiger
#

Anyways I'm done discussing it lol.

polar trail
#

Yeah I think it may be body parts

#

This might be more trouble than itโ€™s worth lol

bronze yoke
#

infected wounds do basically nothing so there isn't likely to be anything interesting to find there

abstract pine
#
local function UpdateObject(isoObject, dir)
    local square = isoObject:getSquare()
    local lightSource = getWorld():getCell():getLightSourceAt(square:getX(), square:getY(), square:getZ())
    if lightSource ~= nil then
        local x = lightSource:getX()
        local y = lightSource:getY()
        local radius = lightSource:getRadius()
        noise('Updating lightSource with radius '..radius..' at '..square:getX()..','..square:getY()..','..square:getZ())
        if dir == "E" then
            lightSource:setX(x+5)
        elseif dir == "W" then
            lightSource:setX(x-5)
        elseif dir == "S" then
            lightSource:setY(y+5)
        elseif dir == "N" then
            lightSource:setY(y-5)
        end
        lightSource:setRadius(13)
        isoObject:transmitCompleteItemToClients()
        isoObject:sendObjectChange('lightSource')
        isoObject:transmitModData()
    end
end

I'm calling this function using MapObjects.OnNewWithSprite, MapObjects.OnLoadWithSprite, and Events.OnObjectAdded.Add. It runs on the server and like the other files in the lua/server/Map folder I based my script on, it has a if isClient() then return end check. Why does it work fine in single player, but not do anything at all in multiplayer? (It's not due to the isClient check, the lightsource change doesn't function even with that commented out.)

bronze yoke
#

is your noise showing up?

abstract pine
#

No message in the client console, I'm looking in the server console and it shows up there as expected without any error:

LOG  : General     , 1681414569606> 272,279,912> MOFloodLights.lua: Updating lightSource with radius 8 at 11556,7688,0
LOG  : General     , 1681414570118> 272,280,424> MOFloodLights.lua: Updating lightSource with radius 8 at 11540,7709,0
LOG  : General     , 1681414570120> 272,280,426> MOFloodLights.lua: Updating lightSource with radius 8 at 11540,7715,0

But I wonder if this later message is related?

LOG  : General     , 1681414644286> 272,354,592> SyncIsoObject: index=2 is invalid x,y,z=11540,7709,0
LOG  : General     , 1681414644769> 272,355,076> SyncIsoObject: index=2 is invalid x,y,z=11540,7709,0
LOG  : General     , 1681414646452> 272,356,758> SyncIsoObject: index=2 is invalid x,y,z=11540,7709,0
LOG  : General     , 1681414646960> 272,357,266> SyncIsoObject: index=2 is invalid x,y,z=11540,7709,0
LOG  : General     , 1681414652713> 272,363,019> SyncIsoObject: index=2 is invalid x,y,z=11540,7709,0
LOG  : General     , 1681414657304> 272,367,611> SyncIsoObject: index=2 is invalid x,y,z=11540,7715,0
bronze yoke
#

is this from the server console?

#

the later messages, i mean

#

this error means that the server doesn't have the isoObject in the square's object list - now that i'm thinking about it i think the MapObjects functions run before they actually get added to the square

#

it uses the co-ordinates and square object list index to identify the same object on each end, so these changes can't really be networked until after they get added

red tiger
#

Combining & categorizing my item property documentation in my VSCode extension. I expect the final list to be closer to 10000 lines.

abstract pine
#

Both those are from the server console. Sort of unsure what you mean, what would I need to do in order for it to work in multiplayer then?

bronze yoke
#

basically it's working up until the part where it tries to send the changes to the clients

#

that's odd - now that i'm looking more into it, that error should only be printed when the server *receives* the update, but it's the one sending it

#

oh, is the isClient check still removed? that would explain that

abstract pine
#

Yeah, it didn't work when I checked earlier so I tried with that check removed to see if that made a difference

bronze yoke
#

that sort of makes things even weirder though, because if the code is running on the client, then you should see the changes anyway even if the networking doesn't work...?

abstract pine
#

The latter messages might have been when I tried picking up and placing the type of lights the script runs on. Yeah I really don't get it, the lighting changes made by that function work with no issue in single player, but nothing happens at all in multiplayer to the lighting. Only thing that was affected was after removing the isClient check, the isoObject itself was duplicated (I assume due to the client running the client transmission, so to be expected), but no change to the lightsource.

polar trail
#

I wanted to see if I could mess around

red tiger
#

For scripts, is MaxAmmo used in anything other than Weapon types?

abstract pine
#

It's used by Normal types for magazines.

red tiger
#

Looks like it was accidentally placed in the Normal type.

#

Ah.

#

Thanks.

drifting ore
#

Hey. Did you find why?

abstract pine
#

@bronze yoke That message still occurs even with the isClient check ๐Ÿค”
LOG : General , 1681418488529> 276,198,836> SyncIsoObject: index=2 is invalid x,y,z=11540,7711,0
It also duplicates flood light tiles even still, which is different from the light source change not being applied, but I assume I am using the transmit functions incorrectly?

#
        isoObject:transmitCompleteItemToClients()
        isoObject:sendObjectChange('lightSource')
        isoObject:transmitModData()

Not sure whether or not any of these are right for what I'm doing to be honest.

bronze yoke
#

isoObject:sendObjectChange('lightSource') doesn't do anything, lightSource isn't a valid change

#

isoObject:transmitModData() probably isn't relevant either

#

wait, is the lightsource even attached to the object?

#

if it's not then isoObject:transmitCompleteItemToClients() wouldn't be relevant either ๐Ÿ˜…

abstract pine
#

I assumed it is? The script modifies flood lights by finding their sprite, I just wasn't sure another way to get the light source than how I did there.

bronze yoke
#

i didn't see any networking methods in IsoLightSource so if it's not attached to the object you might have to network it manually, at which point it'd probably just make more sense to have it run clientside instead

abstract pine
#

How would you network it manually? I'm new to lua and sorta just going off of looking at how other things work, which is making this difficult since there's only one example of anything similar to what I'm doing here (MOLampOnPillar.lua which is creating an object rather than editing an existing one).

tawdry girder
#

this is more server issue but why isnt this 'updating' ?

echo fiber
#

is it possible to have a timed action reduce stress and unhappyness? if so what would be the command lines for it as iv been told you cant just use setStress or setUnhappyness

fast galleon
#

ISReadABook probably does exactly that

echo fiber
frank elbow
fast galleon
#

this file is probably in client/TimedActions/

red tiger
#

A lot of writing today..

#

What's up @fast galleon

echo fiber
#

ill look into it thank you poltergeist!

fast galleon
red tiger
#

Oh.

fast galleon
#

do you have a guide to make java mods ๐Ÿ™‚

#

How does that work, can java mods be compatible if they try to change similar parts.

echo fiber
#

@fast galleon you are amazing i love you

fast galleon
echo fiber
#

like i see setStress and a setUnhappyness but so what i wanna do is have a timed action that sets the stress and unhappyness to 0

fast galleon
#

This is not about Lua, this is finding the PZ java commands though. In this case you need to pass numbers to these functions.

fast galleon
echo fiber
#

do you know what it might look like? when written out to just set stress to 0 for the player, as i cant find examples or guides anywhere for this stuff

fast galleon
#
function self.giveStats(player)
    self.playerLock[player] = true

    HaloTextHelper.addText(player,"Mood",HaloTextHelper.COLOR_GREEN)

    local bodyDamage = player:getBodyDamage()
    local stats = player:getStats()
    bodyDamage:setBoredomLevel(bodyDamage:getBoredomLevel() - self.boredomMod)
    bodyDamage:setUnhappynessLevel(bodyDamage:getUnhappynessLevel() - self.happinessMod)
    stats:setStress(stats:getStress() - self.stressMod)
end
red tiger
echo fiber
abstract pine
ancient grail
echo fiber
echo fiber
#

what is the easiest way to call to a function so i can test it in game to make sure the function i made works

#

also does anyone know if onCreate: work on calling a function cuz if it does then my function is not working

nimble spoke
#

OnCreate works, what are you trying to do in that function?

dusty wigeon
#

we are trying to call to a function that effects certain stats

#

@nimble spoke

echo fiber
# nimble spoke OnCreate works, what are you trying to do in that function?

we are trying to make a time action that comes from that,

so like this

when you "make" the vape on its create it would then call to the timed action that would then reduce the unhappiness and stress levels

atm every time iv tried i cant get the function to work iv even tried just trying to clear the Unhappiness on a timed action and it wont go threw in game so im not sure what im doing wrong

nimble spoke
#

You're probably calling the timed action the wrong way but calling a timed action from a recipe is bizarre. You should call it from a right click option directly

echo fiber
#

so we are using the crafting system to make a menu lol >.<

echo fiber
reef karma
#

@ socialtroglodyte (i dont like pinging people lol), any updates on the calm before the storm issues ?

echo fiber
#

i need guidance lol

bronze yoke
#

bodyDamage isn't defined

#

use player:getBodyDamage()

#

also nothing is calling the giveStats function

opal rivet
#

I like to ask this is it possible for the lying and sitting mod to sit in many directions?

#

I just want to know if it's possible to code it

bronze yoke
#

do you mean if it's possible to sit facing north/west? as the mod doesn't let you do that

opal rivet
#

Yes

#

I know it doesn't

bronze yoke
#

the mod doesn't let you do that because there's no way to layer the chair/whatever over the player correctly, because it's 2d

#

that's expected to change with b42's weird pseudo-3d stuff

opal rivet
#

But is it possible to code?

nimble spoke
bronze yoke
#

it's possible to code, it just won't look good

opal rivet
#

Oh I get what you mean

#

Well I hope the next update will improve a lot to come

#

Thanks Albion

echo fiber
echo fiber
#

also does that onCreate need to be onCreate or OnCreate?

#

lol i have no clue how to right this timed action or the thing that calls for the function >.<

red tiger
red tiger
#

I prefer you use PascalCase.

#

OnCreate

nimble spoke
echo fiber
echo fiber
red tiger
#

camelCase PascalCase snake_case

primal remnant
#

Hey guys, if I make a set of custom functions to execute on an items use, how do I go about calling them?

Recipes for creating and destroying an item are one thing, but if I want to use a drainable, say a pill, how do I actually call the functions I've made so that they... ya know.. do stuff.

echo fiber
#

im still very new to all of this so my apologizes if i dont understand some of the words you use

#

iv tried looking up guides and teachings for lua and cant find videos on it, i am a visual learn and it is hard for me to learn just from text forms >.<

still perch
#

does anyone know if there's a mod that allows you to change zombie class stats. For ex- change it so that only sprinters specifically have low strength and only shamblers have high strength

echo fiber
# red tiger

im assuming this is an extention on VSC but im not sure how to use it as i found it but it gives no detail on how its really used

red tiger
echo fiber
#

thats what comes up when i do Ctrl Shift P

echo fiber
faint jewel
#

anyone happen to know how to detach a trailer via lua?

echo fiber
#

had to install zedScript i didnt even know it was a thing omg

bronze yoke
#

pascalcase is just a way of capitalising things, it's not an extension

lusty kindle
#

itsJustA way_to_format_and_style YourFunctions andVariables

primal remnant
#

Hey guys, we're trying to make a custom lua script that reduces a players stress on the use of a drainable. Any recommendations on which call to use for this? We've attempted the OnCreate: DoFunction in the recipe with some limited success, but I'm beating my head against the wall on getting the function to work. I can use print() just fine, but when I add any other code to it, the games tells me it can't even find it for some stupid reason.

How do you handle reducing a players stats? Are you attaching code to the item itself, to the recipe, or what?

bronze yoke
#

if the game can't find it after you add code, your code is causing errors, read the log

echo fiber
#

what we are trying to make is a OnCreate: UseVape,
then calls to that function to try and get it to change the players stress level with lines like

function UseVape(items, result, player)
    local o = player
    print ("Good shit, that Super Food!");
    o:getStats():setStress() = o:getStats():getStress() - 10;
    return o;
end

if that makes sense?

red tiger
#

I really hate seeing it gather dust.

#

Was supposed to be haunting sounds you'd hear rarely from handheld walkie talkies and TVs with static.

fading horizon
#

put that somewhere in the lua function

#

it uses decimals

#

so to reduce stress by 5, you would change CONFIGUREME to 0.05

primal remnant
#

You are awesome, as always, thank you.

fading horizon
primal remnant
#

It looks like I set up a similar line of code but wasnt passing the arguments in properly. Seeing it here Im facepalming a little.

fading horizon
#

i used a simple version in what i showed you

#

but this is preferable

#

stats:setStress(math.max(((stats:getStress()) - (CONFIGUREME)),0))

#

that makes it so it doesnt go below 0

primal remnant
#

Now THAT's the coding I'm looking for!

fading horizon
#

max.max returns whichever is a higher number, your new stress value or 0

primal remnant
#

Ima go stomp some nerds in ARAM, then I'll try applying it.

fading horizon
#

in other news

#

i got my model sucessfully in game

#

the baseball rat

echo fiber
fading horizon
#

this is just an update to stuart little

echo fiber
#

how did you go about scaling the bat down btw XD want to add a model for my vape when i have the coding done

fading horizon
#

just the scale setting in blender when you export

#

it updates on the fly

#

so you can keep the game open

#

and keep exporting with different scaling options to overwrite the file

#

and itll update

echo fiber
#

0.o thats cool

faint jewel
#
            if not (luautils.stringStarts(obj:getTextureName(), "blends_street_01_0") or luautils.stringStarts(obj:getTextureName(), "blends_street_01_16") or luautils.stringStarts(obj:getTextureName(), "blends_street_01_21")) then
                LastRoad = obj:getTextureName() 
            end
            if (luautils.stringStarts(obj:getTextureName(), "blends_street_01_0") or luautils.stringStarts(obj:getTextureName(), "blends_street_01_16") or luautils.stringStarts(obj:getTextureName(), "blends_street_01_21")) then
                obj:setSpriteFromName(toString(LastRoad))
            end 
#

why is it still setting it to 0 16 and 21 even though its not supposed to.

#

now if i do a SET name... it changes them.

#

but trying to use the name of the road near it.

#

it give me hell.

primal remnant
#

@fading horizon I watched that devilish little stress moodle wiggle. IT WORKED! ๐Ÿ˜„

fading horizon
#

this is related to the vape mod right

primal remnant
#

Yes indeedy

#

Im just helping them with it. It's Valzarens and Rush's mod

fading horizon
#

stats:setStressFromCigarettes(CONFIGUREME);

character:setTimeSinceLastSmoke(CONFIGUREME);

#

you'll need these too

primal remnant
#

And how do those work?

fading horizon
#

or else the character will probably start gaining stress when the item is used

#

basically if the character has the smoker trait, they get stressed if theyve gone without a cigarette for a long time

primal remnant
#

Oh I see.

fading horizon
#

so basically you want to reset the stress from cigarettes when the vape is hit

#

and then reset the time since the last smoke

primal remnant
#

So just set them to 0 each time the item is used?

#

Seems simple enough

fading horizon
#

if you want it to complete remove the stress, yes

primal remnant
#

Perfect

fading horizon
#

i have mine set to only reduce a little bit because 1 hit of a vape is not equal to a full cig

primal remnant
#

Facts

#

Ill add it in the comments and we'll get it implemented.

fading horizon
#

got the craft animation all set up now. I think it's all ready to go

ancient grail
primal remnant
#

@fading horizon I am appalled at the lack of comments in mods. I shall be the change I want to see.

fading horizon
#

based

#

get this extension if you want it to be even better

fading horizon
#

thats how mine looks so nice

#

haha

primal remnant
#

It's so vibrant!

#

I figured dark colors were more your thing. I need skull icons in my comments, then I can rest.

bronze yoke
#

be careful of over commenting ๐Ÿ˜…

young edge
# fading horizon

this supports regions, as well? Or should it be used on top of that?

fading horizon
#

no idea, sorry

young edge
#

kk, ty

fading horizon
#

never even heard of regions

young edge
fading horizon
#

oh wow

#

thats awesome

young edge
#

very useful for those who write a lot of stuff

fading horizon
#

YOOOOOOOOOO

#

doesnt seem to work for me unfortunatelyy

#

just get errors

young edge
fast galleon
golden basin
#

can anyone help or guide me to a resource or adding a 3D model to an item that I can place in the game world? I tried figuring it out on my own, I added the model fbx file and updated the item to include WorldStaticModel, but when I go to place the item in game, there is no model while placing, after I place it it just displays the sprite for the item instead of the model. thanks for any help!

primal remnant
#

Tag me when you see this. I can give you a hand. Im about to work on my own models.

golden basin
primal remnant
#

Awesome, lets jump in a DC room over on the left and get to fixing.

wind horizon
frank elbow
abstract garden
#

is there anyone knew about respawn cooldown of a player?

faint jewel
#

is that not what i did?

fast galleon
#

I'm on phone, hard to see

#

sorry

#

is there a default value for LastRoad btw?

#

you should print the texture names and try that command from console too

faint jewel
#

if i put a default, that's all it sets it to.

dusty wigeon
#

is there a way to make this work. Im trying to make a table of all the items that i want to spawn in the distribution file and from that i am trying to get them to call back to a single word that i would put in place

neon bronze
#

I thint it would be better if you said that .items = Drugs

#

Since it may try to insert the table as an element there

dusty wigeon
#

ok i hover over it now and its calling the table let me test cause this is going to save so much work building the dist. table

ancient grail
neon bronze
dusty wigeon
#

yea thats all still the same

#

i just try doing the = drugs instead of .drugs and the code has a problem with it

#

so im wondering if i have to create the distr in a diferent way for it to work

neon bronze
#

Dont do the first table.inser

#

Just leave it as a line

dusty wigeon
#

?

#

can u explain i dont understand

neon bronze
#

You doin the table.insert(.items = Drugs)?

nimble spoke
#

Do not make an existing spawn table = your table. You will delete everything that is already in there

dusty wigeon
#

ok

#

how would i make it work then

nimble spoke
#

Looks like what you're trying to achieve is a for loop that inserts each item in the table

dusty wigeon
#

how would i go about doing that

nimble spoke
#

For i = 1, #drugs do
table.insert(spawntable.items, i)
table.insert(spawntable.items, spawnchance)
end

#

You must insert a numeric spawn chance right after inserting an item or you will break the spawn system

dusty wigeon
#

im confused

nimble spoke
#

Sorry. Drugs[i] not i inside the table.insert

#

for, not capitalized and #drugs

dusty wigeon
red tiger
#

I'm not sure that you understand the fundamentals of programming applied in Lua.

#

It'll be very hard for you and hard for us to help you if you don't understand what you're working with / trying to code.

dusty wigeon
#

im sorry for trying to learn

red tiger
red tiger
red tiger
#

It's not malicious.

#

Fundamentals are a must in this field.

frank elbow
#

I recommend giving all of PIL a read. LearnXInYMinutes is a good reference, but PIL has more detail

red tiger
#

^

#

Thanks for linking those, @frank elbow

dusty wigeon
#

well i feel like your trying to attack me for not fully understanding the language and trying to learn. i have limited knowledge rn and im trying to learn thats what counts i have troubles whith a lot of methods of learning. I cannot learn from a book

frank elbow
#

I don't think Jab was trying to attack youโ€”what he said about it seeming as if you lack fundamental knowledge was accurate. It's okay to be learning

#

Ignorance is not something to be ashamed of (assuming you don't stay that way), it's an opportunity to learn more ๐Ÿค 

red tiger
dusty wigeon
#

@red tiger im sorry im frustrated. ive been trying to figure this out for 2 days now. I cant learn from a book i have to learn hands on by doing it. I understand that its going to be hard for me to understand what is going on.

red tiger
# faint jewel Jab, fissit.
local texName = obj:getTextureName();
if not (string.find(texName, "blends_street_01_0") == 0 
    or string.find(texName, "blends_street_01_16") == 0
    or string.find(texName, "blends_street_01_21") == 0) then
    LastRoad = texName; 
end

if string.find(texName, "blends_street_01_0") == 0 
    or string.find(texName, "blends_street_01_16") == 0
    or string.find(texName, "blends_street_01_21") == 0 then
    obj:setSpriteFromName(texName);
end
#

There's some textual cleanup.

faint jewel
#

shouldn't all the tops ones be not?

frank elbow
#

Never thought abt that startswith shortcut (I tend to use sub). Obvious in retrospect

#

I think not 0 is meant to be ~= 0 though

frank elbow
red tiger
#

This is your logic.

frank elbow
#

There's parentheses around those first conditions

red tiger
#

Oh you

#

Yeah he did a boolean enclosure.

#

Fixed it.

obsidian horizon
#

anyone know would it be possible for fireplaces and stoves to be able to heat custom built rooms?

frank elbow
#

Unsure whether there are setters, but ClimateManager has functionality related to ambient air temperature so I'd look there

obsidian horizon
#

ty

red tiger
#

Working on some cleanup atm

frank elbow
#

That "categories" bit seems handy for avoiding confusion with some similarly named properties

red tiger
#

A lot of misplaced and deprecated properties too.

frank elbow
#

Unfortunate considering vanilla scripts are the first place most people, including myself, would look for a reference ๐Ÿ˜„ although by now I know to check the source too

faint jewel
#

it's still reading 16 and 21 though

red tiger
#

I'm adding notes on deprecated properties too so during my diagnostics feature's development I can display a warning showing deprecation.

red tiger
faint jewel
#

lol

frank elbow
faint jewel
#

yeah

ancient grail
faint jewel
#

but he problem is it's like it's reading the name but not giving any fucks about it.

red tiger
ancient grail
red tiger
frank elbow
#

I think people areโ€”for the most partโ€”capable of regulating conversations related to that so that they don't get to the point that's a cause for concern

#

Meant to bring that up when it came up before but became productive (that is, productive enough to put down discord)

faint jewel
ancient grail
#

My bad boss
@red tiger won't happen again

red tiger
faint jewel
#

it involves the tiles names.

#

coordinates are never brought into it.

red tiger
#

Sure, however you're asking about position, correct?

faint jewel
#

no.

red tiger
#

I don't know the specifics of tile names or their relation to your issue so I can't help further.

nimble spoke
faint jewel
#

see all the smooth tiles? I want THEIR names. see those shitty dirt ones, LastRoad should never be that.

dusty wigeon
#

@nimble spoke yea i got that down im testing to see if it works

red tiger
faint jewel
#

so i can set the dirt tiles to the road near them

merry storm
#

Any idea why getSquare returns a nil object when im using the same function for a vehicle spawning and it works? I might be missing something
Im getting this error:
"attempted index: getCell of non-table: null"

red tiger
#

You're calling to an unloaded or absent square.

merry storm
#

Ohhh, so i need to a player to get in it to be able to spawn the item

red tiger
#

Or it to be loaded.

#

Load, transact, unload.

merry storm
#

The state will be saved after unload it? it wont be overriden if someone gets in and load it again?

fading horizon
merry storm
ancient grail
red tiger
#

Lua is not a real programming language.

#

This is the fix:

            local texName = obj:getTextureName();
            if not (string.find(texName, "blends_street_01_0") == 1 
                or string.find(texName, "blends_street_01_16") == 1
                or string.find(texName, "blends_street_01_21") == 1
                or texName == nil) then
                LastRoad = texName; 
            else
                print("foobar")
            end
            
            if (string.find(texName, "blends_street_01_0") == 1 
                or string.find(texName, "blends_street_01_16") == 1
                or string.find(texName, "blends_street_01_21") == 1
                or texName == nil) then
                obj:setSpriteFromName(LastRoad);
            end  
#

I rest my case.

fading horizon
#

it removed the default vanilla code folding function for me

#

but i do have custom comments with the '#' tag so that may be interfering

#

but I thought I would let you know regardless

fading horizon
fast galleon
merry storm
fast galleon
#

ah ok

#

I have an API that needs testing ๐Ÿ˜…

ancient grail
#

Is that the alternative to loadgrid thing?

fast galleon
#

yeah

sour island
# dusty wigeon <@183299843240886272> im sorry im frustrated. ive been trying to figure this out...

I'm the same way, you should try to look around for examples then. I think you'll go crazy trying to figure out syntax (how programming is phrased) without examples. Google is also your friend here, even though this is PZ searching for 'how to do a for loop in Lua' would show examples.

I also like to test stuff here: https://www.lua.org/demo.html

Beats booting up the game to see if your lua isn't working.

dusty wigeon
fading horizon
#

@dusty wigeon I also DM'd ValZaren with some info that will help y'all when they wake up

#

regarding animations and sound

dusty wigeon
#

ok awesome thanks. im working on my own mod while trying to work on that lol

fading horizon
#

tfw i'm stuck, all my mods are updated and complete & i can't think of any new features, yet all I want to do is code

#

i have an idea for a mod I just have legitimately no idea how to implement it

cosmic condor
#

Take a break and come back again

fading horizon
#

i just have nothing else to do rn

#

god forbid i actually play the game

cosmic condor
#

Play the game

fading horizon
#

I haven't played the game in almost a month, i've just been making mods lol

cosmic condor
#

Lurking on Twitch and Reddit to get more ideas

red tiger
#

The last time I played was to test my anti-cheat patch.

cosmic condor
#

Many of my mods are feedback from Twitch

sour island
#

@dusty wigeon
Also if you're trying to add spawn chances that are different between the drugs creating a key paired table would help here.

---it is generally better to make variables local rather than global
--You can have things put into a module and returned for access later once you have a better understanding - it does not seem to be needed here so I left out that technqiue.
local Drugs = {
---keys using strings need to be encased in [], due to the string including `.` you can't forgo the [""]
   ["KIDrugMod.Shrooms"] = 0.1,
}
---Pairs() takes a Lua table and returns two sets of variables derrived from their keys and values
--You can rename `key, value` to `drug, chance` for clarity.
--Using `for var1, var2, etc in pairs() do` you can iterate through the returned set of variables.
for key, value in pairs(Drugs) do
   table.insert(SuburbanDistributions["all"]["side--table"].items, key)
   table.insert(SuburbanDistributions["all"]["side--table"].items, value)
end
red tiger
#

It was funny reading "local drugs"

fading horizon
#
local itemNames = {
    "GnomeBars.GnomeBarRB",
    "GnomeBars.GnomeBarBlueRazz",
    "GnomeBars.GnomeBarWatermelonIce",
    "GnomeBars.GnomeBarPinkLemonade",
    "GnomeBars.GnomeBarBlackIce",
    "GnomeBars.GnomeBarCoolMint",
    "GnomeBars.GnomeBarBananaIce",
    "GnomeBars.GnomeBarLemonMint",
    "GnomeBars.GnomeBarStrawNana",
    "GnomeBars.GnomeBarCherryIce",
    "GnomeBars.GnomeBarAppleIce",
    "GnomeBars.GnomeBarGlitch",
}

--  #   Add GnomeBars to zombie inventories
for _, item in ipairs(itemNames) do 
    table.insert(SuburbsDistributions["all"]["inventorymale"].items, item);
    table.insert(SuburbsDistributions["all"]["inventorymale"].items, zombieChance);
    table.insert(SuburbsDistributions["all"]["inventoryfemale"].items, item);
    table.insert(SuburbsDistributions["all"]["inventoryfemale"].items, zombieChance); 
    -- // print("Loading GnomeBar ("..item..") to INVENTORIES ....... SUCCESS!");
end

--  #   Add GnomeBars to generic locations
local GBLocaleGeneric = {"DeskGeneric", "BathroomCounter", "JanitorMisc", "BedroomSideTable", "OfficeDesk", "OfficeDeskHome", "PlankStashMoney", "PoliceDesk", "PrisonCellRandom", "CrateElectronics", "BedroomDresser", "WardrobeChild", "BreakRoomCounter", "BreakRoomShelves", }
    for i in pairs(GBLocaleGeneric) do
    if ProceduralDistributions.list[GBLocaleGeneric[i]] == nil then
      print("FAILURE -- could not find " .. GBLocaleGeneric[i] .. "!");
    else
      if ProceduralDistributions.list[GBLocaleGeneric[i]].items == nil then
        print("FAILURE -- could not find " .. GBLocaleGeneric[i] .. "!");
    else
          for _, item in ipairs(itemNames) do 
        table.insert(ProceduralDistributions.list[GBLocaleGeneric[i]].items, item);
        table.insert(ProceduralDistributions.list[GBLocaleGeneric[i]].items, regularChance);
    end
-- // print("Loading GnomeBar Generic items to " .. GBLocaleGeneric[i] .. " ....... SUCCESS!");
            end
        end
    end```
#

@dusty wigeon here's an example of how I did some of my distributions

#
local zombieChance = 0.3
local regularChance = 0.2;
local schoolChance = 0.005;
local emptyChance = 0.075;
#

this is supposed to be at the top but I hit the character limit

red tiger
faint jewel
nova dome
fading horizon
#

Thanks guy from YouTube

nova dome
#

nah his point was to make good names for functions and variables in the first place. i've not programmed much but when the code has been otherwise easy to read what i've missed is some larger overview of what the code does. some kind of flowchart or sth, dunno what is best to use

#

also probably there are automated tools to create those but i dunno how to use em :-D