1daBread Posted August 24, 2014 Share Posted August 24, 2014 Trying to overwrite the CanBuild function in builder.lua.It always throws an error on GetRecipe. Not sure exactly how to make it see the function. Is there something I need to import. At this point I am just trying to overwrite the with the vanilla function (no changes).Code:local require = GLOBAL.requirelocal Builder = require "components/builder"local Recipe = GLOBAL.Recipelocal RECIPETABS = GLOBAL.RECIPETABSlocal TECH = GLOBAL.TECHfunction Builder:CanBuild(recname)if self.freebuildmode thenreturn trueendlocal recipe = GetRecipe(recname)if recipe thenfor ik, iv in pairs(recipe.ingredients) dolocal amt = math.max(1, RoundUp(iv.amount * self.ingredientmod))if not self.inst.components.inventory:Has(iv.type, amt) thenreturn falseendendreturn trueendreturn falseendError:...tarve/data/../mods/resurrectionstatuefix/modmain.lua:55: attempt to call method 'GetRecipe' (a nil value)LUA ERROR stack traceback:X:/Games/SteamLibrary/steamapps/common/dont_starve/data/../mods/resurrectionstatuefix/modmain.lua(55,1) in function 'CanBuild'X:/Games/SteamLibrary/steamapps/common/dont_starve/data/scripts/widgets/craftslot.lua(122,1) in function 'Refresh'X:/Games/SteamLibrary/steamapps/common/dont_starve/data/scripts/widgets/craftslot.lua(177,1) in function 'SetRecipe'X:/Games/SteamLibrary/steamapps/common/dont_starve/data/scripts/widgets/crafting.lua(137,1) in function 'UpdateRecipes'X:/Games/SteamLibrary/steamapps/common/dont_starve/data/scripts/widgets/crafting.lua(78,1) in function 'SetFilter'X:/Games/SteamLibrary/steamapps/common/dont_starve/data/scripts/widgets/crafttabs.lua(93,1) in function 'selectfn'X:/Games/SteamLibrary/steamapps/common/dont_starve/data/scripts/widgets/tab.lua(192,1) in function 'Select'X:/Games/SteamLibrary/steamapps/common/dont_starve/data/scripts/widgets/tab.lua(44,1) in function 'OnControl'X:/Games/SteamLibrary/steamapps/common/dont_starve/data/scripts/widgets/widget.lua(112,1) in function 'OnControl'X:/Games/SteamLibrary/steamapps/common/dont_starve/data/scripts/widgets/widget.lua(112,1) in function 'OnControl'X:/Games/SteamLibrary/steamapps/common/dont_starve/data/scripts/widgets/widget.lua(112,1) in function 'OnControl'X:/Games/SteamLibrary/steamapps/common/dont_starve/data/scripts/widgets/widget.lua(112,1) in function 'OnControl'X:/Games/SteamLibrary/steamapps/common/dont_starve/data/scripts/widgets/widget.lua(112,1) in function 'OnControl'X:/Games/SteamLibrary/steamapps/common/dont_starve/data/scripts/widgets/widget.lua(112,1) in function 'OnControl'X:/Games/SteamLibrary/steamapps/common/dont_starve/data/scripts/widgets/widget.lua(112,1) in function 'OnControl'X:/Games/SteamLibrary/steamapps/common/dont_starve/data/scripts/screens/playerhud.lua(291,1) in function 'OnControl'X:/Games/SteamLibrary/steamapps/common/dont_starve/data/scripts/frontend.lua(236,1) in function 'OnControl'X:/Games/SteamLibrary/steamapps/common/dont_starve/data/scripts/input.lua(138,1) in function 'OnControl'X:/Games/SteamLibrary/steamapps/common/dont_starve/data/scripts/input.lua(312,1)scripts/frontend.lua(723,1) SCRIPT ERROR! Showing error screenForce aborting...if I do:local Recipe = require "recipe"...local recipe = Recipe:GetRecipe(recname)It throws an error attempt to index upvalue 'Recipe' (a boolean value) Link to comment https://forums.kleientertainment.com/forums/topic/39792-help-overwrite-function/ Share on other sites More sharing options...
Heavenfall Posted August 24, 2014 Share Posted August 24, 2014 try local recipe = GLOBAL.GetRecipe(recname) Link to comment https://forums.kleientertainment.com/forums/topic/39792-help-overwrite-function/#findComment-526511 Share on other sites More sharing options...
1daBread Posted August 24, 2014 Author Share Posted August 24, 2014 (edited) Thank you again Heavenfall Edited August 24, 2014 by 1daBread Link to comment https://forums.kleientertainment.com/forums/topic/39792-help-overwrite-function/#findComment-526761 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