Jump to content

Recommended Posts

I am trying to add my custom food called "borsh" but game always crashes if mod is enabled. Help me please, i am new to dst modding

Log:
[00:02:03]: [string "scripts/cooking.lua"]:20: table index is nil
LUA ERROR stack traceback:
        scripts/cooking.lua(20,1) in function 'AddCookerRecipe'
        scripts/modutil.lua(646,1) in function 'AddCookerRecipe'
        ../mods/borsh/modmain.lua(18,1) in main chunk
        =[C] in function 'xpcall'
        scripts/util.lua(780,1)
        =(tail call) ?
        scripts/mods.lua(572,1) in function 'InitializeModMain'
        scripts/mods.lua(546,1) in function 'LoadMods'
        scripts/main.lua(376,1) in function 'ModSafeStartup'
        scripts/main.lua(506,1)
        =[C] in function 'SetPersistentString'
        scripts/mainfunctions.lua(29,1) in function 'SavePersistentString'
        scripts/modindex.lua(119,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(106,1) in function 'BeginStartupSequence'
        scripts/main.lua(505,1) in function 'callback'
        scripts/modindex.lua(735,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(709,1) in function 'Load'
        scripts/main.lua(504,1) in main chunk

-- modmain.lua

local _G = GLOBAL
local require = _G.require
local FOODTYPE = _G.FOODTYPE
local TECH = GLOBAL.TECH
local Ingredient = GLOBAL.Ingredient
local RECIPETABS = GLOBAL.RECIPETABS
local Recipe = GLOBAL.Recipe
local AllRecipes = GLOBAL.AllRecipes

Assets = {
	Asset("IMAGE", "images/borsh.tex"),
	Asset("ATLAS", "images/borsh.xml"),
}

local customrecipes = require("borsh_food")

for k, v in pairs(customrecipes) do
	AddCookerRecipe("borsh", v, true)
end

-- borsh_food.lua

local foods = {
    borsh = {
        test = function(cooker, names, tags)
            return (tags.meat and tags.meat <= 2)
            and tags.veggie
            and not tags.inedible
            end,
        priority = 0,
        foodtype = FOODTYPE.MEAT,
        health = 120,
        sanity = 0,
        hunger = 110,
        cooktime = 0.75,
        potlevel = "low",
        floater = {"small", 0.1, 0.8},
        oneaten = function(inst, eater)
            local original_attack_period = eater.components.combat.min_attack_period
            local original_walkspeed = eater.components.locomotor.walkspeed
            local original_runspeed = eater.components.locomotor.runspeed
            eater.components.combat.min_attack_period = 0
            eater.components.locomotor.walkspeed = original_walkspeed * 2
            eater.components.locomotor.runspeed = original_runspeed * 2
            eater:DoTaskInTime(10, function()
                eater.components.combat.min_attack_period = original_attack_period
                eater.components.locomotor.walkspeed = original_walkspeed
                eater.components.locomotor.runspeed = original_runspeed
            end)
        end,
    },
}

return foods

 

1 hour ago, ulybaka said:

what do you mean?

What do you mean by adding food recipes into brosh?

It is usually

    AddCookerRecipe("cookpot", recipe)
    AddCookerRecipe("portablecookpot", recipe)
    AddCookerRecipe("archivecookpot", recipe)

 

Edited by Rickzzs
4 hours ago, Rickzzs said:

What do you mean by adding food recipes into brosh?

It is usually

    AddCookerRecipe("cookpot", recipe)
    AddCookerRecipe("portablecookpot", recipe)
    AddCookerRecipe("archivecookpot", recipe)

 

oh thx i thought name between " is food bame

On 7/19/2023 at 10:35 AM, Rickzzs said:

What do you mean by adding food recipes into brosh?

It is usually

    AddCookerRecipe("cookpot", recipe)
    AddCookerRecipe("portablecookpot", recipe)
    AddCookerRecipe("archivecookpot", recipe)

 

ok, now i have


-- modmain.lua

local customrecipes = require("borsh_food")

for k, v in pairs(customrecipes) do
	AddCookerRecipe("cookpot", v, true)
end

but game still crashes 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...