Jump to content

Recommended Posts

I know this sounds strange but, i added a recipe, for my character only, that gives me the possibility to craft butterflies;

The problem here is that when i kill butterflies now they drop the item's recipe;

The recipe require 3 nightmare fuel and 1 petal to craft a butterfly, but when i kill one it drops 2 nightmare fuel, 1 petal and 1 butterfly wings;

so i was wondering, how do i fix butterflies and make them not dropping nightmare fuel nor petals?

Here's my code, this is inside modmain:

Spoiler

local Ingredient = GLOBAL.Ingredient
local RECIPETABS = GLOBAL.RECIPETABS

Recipe = GLOBAL.Recipe
Ingredient = GLOBAL.Ingredient
TECH = GLOBAL.TECH

local ezerald_recipe = AddRecipe("butterfly", {Ingredient("nightmarefuel", 3),Ingredient("petals", 1)}, RECIPETABS.MAGIC, {MAGIC=0}, nil, nil, nil, nil, "ezerald")

 

Edited by Ezerald

The lootdropper component checs for the recipe and gives the loot accordingly.

You could hook the GetRecipe function to stop if it gets the butterfly recipe, but this is not the optimal way.

Spoiler

function LootDropper:GenerateLoot()
    --------------
	local recipe = AllRecipes[self.inst.prefab]
    if recipe then
        local recipeloot = self:GetRecipeLoot(recipe)
        for k,v in ipairs(recipeloot) do
            table.insert(loots, v)
        end
    end

 

I think there are a lot of different spawners in the game that remove themselves as soon as they spawn something after are built. So you could make another prefab which gives the butterfly to the character that built it and then removes itself.

This way, there is no recipe directly for the butterfly and the drops remain the same.

 

  • Like 2

How does one "You could hook the GetRecipe function", the ways I have tried it all crash the game. :(

via inst.components.lootdropper:GetFullRecipeLoot(onmurderfn), ect.

 

local function onmurderfn()
    local recipe = {}
        return recipe
end

Edited by JadeKnightblazer

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