Jump to content

Recommended Posts

I have been looking for a way to change the radius of the area trigger around the prototype machines so that I can craft from a larger distance in my camp, rather than having to sit right next to the machine. How is this possible? I have tried looking in area_trigger.lua, but no luck.

@Heavenfall

Could you explain how adding a new tech tree works? I know of your old topic on it, but its outdated (It's for Hungry for Your Hunger) and the code has been squashed into single lines.

 

I'd probably be able to sort it out, but I'd really like to know the reasoning behind how it works. Tables are still something I'm getting acquainted with.

I think this is all I have

 

 GLOBAL.TECH.NONE.SKELETON = 0for k,v in pairs(GLOBAL.TUNING.PROTOTYPER_TREES) do    GLOBAL.TUNING.PROTOTYPER_TREES[k].SKELETON = 0endGLOBAL.TUNING.PROTOTYPER_TREES.SKELETON = {SCIENCE = 0,MAGIC = 0,ANCIENT = 0,SKELETON=1} local function enteringradiusofskeleton(inst)    --print ("entering proximity of skeleton")endlocal function leavingradiusofskeleton(inst)    --print ("left proximity of skeleton")    local playervar = GLOBAL.GetPlayer()    if playervar then        playervar.components.builder.accessible_tech_trees = GLOBAL.TECH.NONE    endend-- add undeadskeleton prototype type to skeletonsfunction HF_addskeletonprototype(inst)    inst:AddTag("prototyper")    inst:AddComponent("prototyper")        inst.components.prototyper.trees = GLOBAL.TUNING.PROTOTYPER_TREES.SKELETON        inst.components.prototyper.onactivate = function()            inst:DoTaskInTime(0.1, function()                --print("running onactivate")                local playervar = GLOBAL.GetPlayer()                if playervar then                    for k,v in pairs(playervar.components.builder.recipes) do                            if (v == "summonskeleton") then                            playervar.components.builder.recipes[k] = nil                            playervar.components.builder.recipe_count = playervar.components.builder.recipe_count -1                        end                    end                end                inst:Remove()            end)        end        -- these functions have to exist even if one does nothing        inst.components.prototyper.onturnoff = leavingradiusofskeleton        inst.components.prototyper.onturnon = enteringradiusofskeletonendAddPrefabPostInit("skeleton", HF_addskeletonprototype)

 

and an example recipe

    local temprecipe0 = Recipe( "summonskeleton", { Ingredient("nightmarefuel", 2),  Ingredient("papyrus", 1) }, RECIPETABS.SUMMONS, {SKELETON = 1})    temprecipe0.atlas = "images/inventoryimages/summonskeleton.xml"

Looks like they changed a builder component function, you'll need to hook this to make it work

 

function Builder:KnowsRecipe(recname)    local recipe = GetRecipe(recname)    if recipe and recipe.level.ANCIENT <= self.ancient_bonus and recipe.level.MAGIC <= self.magic_bonus and recipe.level.SCIENCE <= self.science_bonus then        return true    end    return self.freebuildmode or table.contains(self.recipes, recname)end

Looks like they changed a builder component function, you'll need to hook this to make it work [...]

Unfortunately, that change is bound to be problematic for mods... This method needs to be overriden, so it'll very likely create compatibility issues between mods. I talked about it here.

@Heavenfall

Could you explain how adding a new tech tree works? I know of your old topic on it, but its outdated (It's for Hungry for Your Hunger) and the code has been squashed into single lines.

I'd probably be able to sort it out, but I'd really like to know the reasoning behind how it works. Tables are still something I'm getting acquainted with.

I wrote a sample mod for adding new tech branches. But, as I said in the description of the mod, this and other general hardcodedness in the Builder component made the implementation be much less clean and simple than I'd like.

I did this because my recipe for skeletons should never be unlocked, just repeatedly prototyped. But I think you could do something similar if you just check if the recipe is unlocked in your ifs.

function builderpostinit(inst)    local oldKnowsRecipe = inst.KnowsRecipe    inst.KnowsRecipe = function(self, recname)        local recipe=GLOBAL.GetRecipe(recname)        if oldKnowsRecipe(self, recname) and not self.freebuildmode then            if recipe and recipe.level.SKELETON and recipe.level.SKELETON > 0 then                return false            else                return true            end        end        return oldKnowsRecipe(self, recname)    endendAddComponentPostInit("builder", builderpostinit)

A return is a "break", so you can really do whatever check you want before you run oldKnowsRecipe right? Like so:

if (stuff_in_my tech_tree) return check() else return oldKnowsRecipe() end.

Looks fairly modular to me.

Edited by Heavenfall

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