Charsis Posted April 17, 2019 Share Posted April 17, 2019 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? Link to comment https://forums.kleientertainment.com/forums/topic/105013-trying-to-add-edited-recipe-but-game-crashes/ Share on other sites More sharing options...
Ultroman Posted April 17, 2019 Share Posted April 17, 2019 Are those globals declared BEFORE the call to AddRecipe? Link to comment https://forums.kleientertainment.com/forums/topic/105013-trying-to-add-edited-recipe-but-game-crashes/#findComment-1179637 Share on other sites More sharing options...
Charsis Posted April 17, 2019 Author Share Posted April 17, 2019 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? Link to comment https://forums.kleientertainment.com/forums/topic/105013-trying-to-add-edited-recipe-but-game-crashes/#findComment-1179646 Share on other sites More sharing options...
Ultroman Posted April 17, 2019 Share Posted April 17, 2019 I'm not sure. AddRecipe should be available without GLOBAL. Post me your modmain.lua here. I'd like to see if I can figure this out, just for learning purposes. Link to comment https://forums.kleientertainment.com/forums/topic/105013-trying-to-add-edited-recipe-but-game-crashes/#findComment-1179764 Share on other sites More sharing options...
Charsis Posted April 17, 2019 Author Share Posted April 17, 2019 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. May be Klei did something and removed AddRecipe from working? Work fine with just Recipe. AddRecipeNotWork.zip Link to comment https://forums.kleientertainment.com/forums/topic/105013-trying-to-add-edited-recipe-but-game-crashes/#findComment-1179830 Share on other sites More sharing options...
Ultroman Posted April 17, 2019 Share Posted April 17, 2019 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. Link to comment https://forums.kleientertainment.com/forums/topic/105013-trying-to-add-edited-recipe-but-game-crashes/#findComment-1179833 Share on other sites More sharing options...
Charsis Posted April 17, 2019 Author Share Posted April 17, 2019 @Ultroman then I get this error With this code Link to comment https://forums.kleientertainment.com/forums/topic/105013-trying-to-add-edited-recipe-but-game-crashes/#findComment-1179840 Share on other sites More sharing options...
Ultroman Posted April 17, 2019 Share Posted April 17, 2019 Oh wait...this is DS. Link to comment https://forums.kleientertainment.com/forums/topic/105013-trying-to-add-edited-recipe-but-game-crashes/#findComment-1179844 Share on other sites More sharing options...
MidrealmDM Posted April 30, 2019 Share Posted April 30, 2019 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" Link to comment https://forums.kleientertainment.com/forums/topic/105013-trying-to-add-edited-recipe-but-game-crashes/#findComment-1187520 Share on other sites More sharing options...
Ultroman Posted April 30, 2019 Share Posted April 30, 2019 Yeah, in DS there is no AddRecipe. Recipe is right. Link to comment https://forums.kleientertainment.com/forums/topic/105013-trying-to-add-edited-recipe-but-game-crashes/#findComment-1187551 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now