Portmanteau

"attempt to index global 'CHARACTER_INGREDIENT' (a nil value)"

Recommended Posts

Portmanteau    89

Hello! So I was trying to do a small test mod quick to see if I could make Maxwell able to craft small critters in the magic tab using AddPrefabPostInits, but it keeps giving me the following error every time I try because of me having health as a crafting ingredient and I really wanted that to be required.

Excerpt from log:

Spoiler

[00:03:11]: scripts/mods.lua(44,1) error calling PrefabPostInit: waxwell in mod Mod Experimentation:
..._starve/data/../mods/Mod Experimentation/modmain.lua:20: attempt to index global 'CHARACTER_INGREDIENT' (a nil value)
LUA ERROR stack traceback:
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/../mods/Mod Experimentation/modmain.lua(20,1)
        =(tail call) ?
        =[C] in function 'xpcall'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/mods.lua(42,1) in function 'mod'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/mainfunctions.lua(144,1)
        =[C] in function 'SpawnPrefab'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/mainfunctions.lua(178,1) in function 'SpawnPrefab'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/gamelogic.lua(535,1) in function 'PopulateWorld'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/gamelogic.lua(1075,1) in function 'DoInitGame'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/gamelogic.lua(1402,1) in function 'cb'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/saveindex.lua(1579,1)
        =[C] in function 'SetPersistentString'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/saveindex.lua(108,1) in function 'Save'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/saveindex.lua(1607,1)
        =[C] in function 'SetPersistentString'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/saveindex.lua(1610,1) in function 'OnGenerateNewWorld'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/gamelogic.lua(1411,1) in function 'cb'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/screens/worldgenscreen.lua(246,1) in function 'cb'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/frontend.lua(413,1) in function 'DoFadingUpdate'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/frontend.lua(465,1) in function 'Update'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/update.lua(46,1)    
[00:03:11]: scripts/mods.lua(253,1) Disabling Mod Experimentation because it had an error.   

Here is my code too if it helps:

Spoiler

STRINGS = GLOBAL.STRINGS
RECIPETABS = GLOBAL.RECIPETABS
Recipe = GLOBAL.Recipe
Ingredient = GLOBAL.Ingredient
TECH = GLOBAL.TECH
RECIPE_GAME_TYPE = GLOBAL.RECIPE_GAME_TYPE

STRINGS.RECIPE_DESC.RABBIT = "Bring to life a small furry creature."
STRINGS.RECIPE_DESC.CROW = "Bring to life a dark craven crow."
STRINGS.RECIPE_DESC.ROBIN = "Bring to life a bird of fire."
STRINGS.RECIPE_DESC.ROBIN_WINTER = "Bring to life a bird of snow."

AddPrefabPostInit("waxwell", function(inst)
local animate_rabbit = Recipe("rabbit", { Ingredient("smallmeat", 1), Ingredient("nightmarefuel", 2), Ingredient(CHARACTER_INGREDIENT.HEALTH, 15)}, RECIPETABS.MAGIC, TECH.NONE, RECIPE_GAME_TYPE.COMMON)
local animate_crow = Recipe("crow", { Ingredient("smallmeat", 1), Ingredient("nightmarefuel", 2), Ingredient(CHARACTER_INGREDIENT.HEALTH, 15)}, RECIPETABS.MAGIC, TECH.NONE, RECIPE_GAME_TYPE.COMMON)
local animate_redrobin = Recipe("robin", { Ingredient("smallmeat", 1), Ingredient("nightmarefuel", 2), Ingredient(CHARACTER_INGREDIENT.HEALTH, 15)}, RECIPETABS.MAGIC, TECH.NONE, RECIPE_GAME_TYPE.COMMON)
local animate_bluerobin = Recipe("robin_winter", { Ingredient("smallmeat", 1), Ingredient("nightmarefuel", 2), Ingredient(CHARACTER_INGREDIENT.HEALTH, 15)}, RECIPETABS.MAGIC, TECH.NONE, RECIPE_GAME_TYPE.COMMON)
animate_rabbit.sortkey = 1
animate_crow.sortkey = 2
animate_redrobin.sortkey = 3
animate_bluerobin.sortkey = 4
end)

Help would be much appreciated. Preferably I want a way to do this still using AddPrefabPostInIts, so take that into account please. Thank you in advance!

Share this post


Link to post
Share on other sites

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