Jump to content

Adding a Tech to TechTree.AVAILABLE_TECH


Recommended Posts

  • Developer

I tried doing this by modifying the actual game files and got what i wanted working correctly...

Now I want to know how to do this from a mod perspective... I have tried:
 

local TechTree = GLOBAL.require("techtree")
TechTree.AVAILABLE_TECH[#TechTree.AVAILABLE_TECH+1] = "EYEBONE"
GLOBAL.TECH.NONE = TechTree.Create()

And now the issue is that whenever it encounters my tech entry it compares a number(my new tech entry.) with nil (recipes made before my entry in "AVAILABLE_TECH".)

Any idea how to fix this?

Edited by Zarklord
Link to comment
Share on other sites

  • Developer

well i resolved my issue and made quite a nice lib for adding custom tech types: customtechtree.lua

currently this supports custom tech hints and custom bonus's but it doesn't support custom tech ingredients I will probably update this soon for support with that...

if Klei wanted to they could very easily improve their api to allow this to be done better without my code injections. this would be done by

A: treating nil as 0(this would mean if you add a custom tech but don't add the TECH = 0 it wouldn't throw a error), this would also mean you could get rid of TechTree.Create() as the entire purpose of it is converting nil to 0.

B: in components/builder.lua lines 186-195 should probably be:

  1. --add any character specific bonuses to your current tech levels.
    for i, v in ipairs(TechTree.AVAILABLE_TECH) do
    	self.accessible_tech_trees[v] = (self.accessible_tech_trees[v] or 0) + (self[string.lower(v).."_bonus"] or 0)
    end

as currently in order to do custom bonus's I must add it to the self.accessible_tech_trees in replica.builder:SetTechTrees,(since this only gets called if the tech tree changes, its the safest place to do it...) and that's still quite hacky and could definitely cause some issues.

C: for the tech recipe hint. in widgets/recipepopup.lua store the array at 357- 365 somewhere were we can add to it/modify it, this helps, but lastly to determine which string to use in GetHintTextForRecipe, you should really do a compare of recipe.level with all the techs in GLOBAL.TECH[x,] and if it matches exactly use X text hint based on GLOBAL.TECH[x](possibly something along the lines of how tech ingredients are handled). that's how i do it and it works great for my library...

Link to comment
Share on other sites

  • Developer
5 hours ago, Lumina said:

I'm not totally sure, but didn't @Marisdid something similar ?

he did but I found it lacking for what I needed, plus mine overwrites WAY less methods and does custom bonus's, which his doesnt. I did look at that code some tho, tho I didnt really use much of it(basicaly only the custom tech recipe hint). This is basicaly v2 of that tho in terms of functionality.

Edited by Zarklord
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...