Jump to content

Recommended Posts

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

local Builder = require "components/builder"

local Recipe = GLOBAL.Recipe

local RECIPETABS = GLOBAL.RECIPETABS

local TECH = GLOBAL.TECH

function Builder:CanBuild(recname)

if self.freebuildmode then

return true

end

local recipe = GetRecipe(recname)

if recipe then

for ik, iv in pairs(recipe.ingredients) do

local amt = math.max(1, RoundUp(iv.amount * self.ingredientmod))

if not self.inst.components.inventory:Has(iv.type, amt) then

return false

end

end

return true

end

return false

end

Error:

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

Force 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

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