Jump to content

Is it possible to overwrite the recipe of another mod?


Recommended Posts

I tried to use this.

 

local recipe_ctor_base = Recipe._ctor
function Recipe._ctor(self, name, ingredients, tab, level, placer, min_spacing, nounlock, numtogive)
   recipe_ctor_base(self, name, ingredients, tab, level, placer, min_spacing, nounlock, numtogive)
   if(name == "bloodSword") then
     self.atlas         = resolvefilepath("images/inventoryimages/bloodsword.xml")
     self.image         = "bloodsword.tex"
   end
end

local bloodSword = GLOBAL.Recipe("bloodSword",
{
    Ingredient("nightmarefuel", 1),
    Ingredient("pigskin", 1),
},
    CUSTOM_RECIPETABS.VAMPIRIC, TECH.NONE, nil, nil, nil, nil, serasV
)
bloodSword.atlas = resolvefilepath("images/inventoryimages/bloodsword.xml")

 

 

and it didn't work.

Link to comment
Share on other sites

@afetogbo, Tabs are a nightmare right now.

 

I think you can just redo the recipe as if you're making a new one, since they're attached to the AllRecipes table indexed by name, so if it's the same prefab it'll have the same name, and overwrite that entry in the table.

Link to comment
Share on other sites

when i tried that it gave me two exact copies of the tab.

 

I am just going to put all the recipes in a custom tab. and since I am borrowing code i used if hastag "character" and i hope everyone has that.

AddClassPostConstruct("widgets/crafttabs", function(class)    if class.owner:HasTag("character") then        local v = CUSTOM_RECIPETABS.AFETOPIA        local k = #class.tab_order + 1        local tab_bg =        {            normal = "tab_normal.tex",            selected = "tab_selected.tex",            highlight = "tab_highlight.tex",            bufferedhighlight = "tab_place.tex",            overlay = "tab_researchable.tex",        }                class.tabs.spacing = 750/k        local tab = class.tabs:AddTab(STRINGS.TABS[v.str], resolvefilepath("images/hud.xml"), v.icon_atlas or resolvefilepath("images/hud.xml"), v.icon, tab_bg.normal, tab_bg.selected, tab_bg.highlight, tab_bg.bufferedhighlight, tab_bg.overlay,                    function() --select fn                if not class.controllercraftingopen then                                    if class.craft_idx_by_tab[k] then                        class.crafting.idx = class.craft_idx_by_tab[k]                    end                                        class.crafting:SetFilter(                        function(recipe)                            local rec = GLOBAL.AllRecipes[recipe]                            return rec and rec.tab == v                        end)                    class.crafting:Open()                end            end,                        function() --deselect fn                class.craft_idx_by_tab[k] = class.crafting.idx                class.crafting:Close()            end)        tab.filter = v        tab.icon = v.icon        tab.icon_atlas = v.icon_atlas or resolvefilepath("images/hud.xml")        tab.tabname = STRINGS.TABS[v.str]        class.tabbyfilter[v] = tab                table.insert(class.tab_order, tab)        end    end)

so if you haven't guessed I am working on a custom all recipes in one mod mod for my server. no one is downloading the files to play on my server so I have to make it downloadable from the workshop :(

 

And well I hope they can download it even if it is hidden because I don't think I can get all those authors to agree to let me post it in a timely manner.

Link to comment
Share on other sites

@afetogbo, Yes, tabs would copy, but recipes will replace. Since you're trying to make a bundle, you can throw compatibility concerns out the window, I suppose, and just replace widgets/crafttabs.lua. It'd be a lot easier to add tabs that way. You can just add extra parts like Wickerbottom's bookbuilder tab:

    local tabnames = {}    for k,v in pairs(RECIPETABS) do        table.insert(tabnames, v)    end    if owner:HasTag("bookbuilder") then        table.insert(tabnames, CUSTOM_RECIPETABS.BOOKS)    end

(by replace, I mean make the folder scripts/widgets in a mod, copy crafttabs.lua from the game into that, and then edit it)

 

Edit: And then just comment out the tab-creation code in the other mods

Edited by rezecib
Link to comment
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
 Share

×
  • Create New...