Jump to content

Recommended Posts

Added custom recipe with AddRecipe like this;

AddRecipe("torch", {Ingredient("charcoal", 1), Ingredient("twigs", 1)}, RECIPETABS.LIGHT, TECH.NONE)

But game crash and give this error;

attempt to index global 'RECIPETABS' (a nil value)

 

Have got globals imported in modmain as well like this

local Ingredient = GLOBAL.Ingredient
local RECIPETABS = GLOBAL.RECIPETABS
local Recipe = GLOBAL.Recipe
local CHARACTER_INGREDIENT = GLOBAL.CHARACTER_INGREDIENT

Why this happen any idea?

Ok sorted it out a bit better and have globals declared before AddRecipe. But now it give error about AddRecipe and not recognise it;

variable 'AddRecipe' is not declared

When I have this code among globals

local AddRecipe = GLOBAL.AddRecipe

It look like it recognise Recipe though and I know it common practice to use AddRecipe for mods, why can I not use AddRecipe?

I got it work but only with Recipe not AddRecipe. Attached example mod with AddRecipe problem and you have to go into mod change all AddRecipe to Recipe then enable mod in game, exit game, change back references to AddRecipe and open game again to see error otherwise it just shut down crash and you not see error and mod disabled next time you launch.

image.thumb.png.cf1df9f3bbd08327a293bce4e7a76dc3.png

May be Klei did something and removed AddRecipe from working? Work fine with just Recipe.

AddRecipeNotWork.zip

Try removing your modimport, and just put this in your modmain.lua

local Ingredient = GLOBAL.Ingredient
local RECIPETABS = GLOBAL.RECIPETABS
local TECH = GLOBAL.TECH

AddRecipe("torch", {Ingredient("charcoal", 1), Ingredient("twigs", 1)}, RECIPETABS.LIGHT, TECH.NONE)

You only need CHARACTER_INGREDIENT if you're adding ingredients like health, max health, sanity or hunger.

in your modmain

local Recipe = GLOBAL.Recipe
local Ingredient = GLOBAL.Ingredient
local RECIPETABS = GLOBAL.RECIPETABS
local TECH = GLOBAL.TECH

local torch_recipe = Recipe("torch", {Ingredient("charcoal", 1), Ingredient("twigs",1)}, RECIPETABS.WAR, TECH.NONE)
                        torch_recipe.sortkey = 1
                        torch_recipe.atlas="images/inventoryimages/torch.xml"
 

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...