Fredson Posted January 15, 2017 Share Posted January 15, 2017 Say i want to add a Science value to a book, so it unlocks all the tier 1 science recipes, another book that adds the tier 2 science recipes and a third that adds ancient science (Pseudoscience) recipes, with just having the books in your inventory, How could it be done ? I need help with this since is to fix an outdated mod of mine. Link to comment Share on other sites More sharing options...
Fredson Posted January 15, 2017 Author Share Posted January 15, 2017 Bump Link to comment Share on other sites More sharing options...
zUsername Posted January 16, 2017 Share Posted January 16, 2017 Upload your mod here. Link to comment Share on other sites More sharing options...
Fredson Posted January 16, 2017 Author Share Posted January 16, 2017 Here it is, the problem is in all the gfbooks (1,2,3) in the prefabs dip.rar Link to comment Share on other sites More sharing options...
zUsername Posted January 17, 2017 Share Posted January 17, 2017 Remove these lines in your gfbooks (1,2,3) prefabs: inst.components.inventoryitem:SetOnDroppedFn(OnDropped) inst.components.inventoryitem:SetOnPutInInventoryFn(OnPickup) And add these lines to your modmain.lua: local function NewBuilder(self) local _EvaluateTechTrees = self.EvaluateTechTrees self.EvaluateTechTrees = function(self) _EvaluateTechTrees(self) if self.inst.replica.inventory then local changed = false if self.inst.replica.inventory:Has("gfbook2", 1) and self.accessible_tech_trees.SCIENCE < 2 then self.accessible_tech_trees.SCIENCE = 2 changed = true elseif self.inst.replica.inventory:Has("gfbook1", 1) and self.accessible_tech_trees.SCIENCE < 1 then self.accessible_tech_trees.SCIENCE = 1 changed = true end if self.inst.replica.inventory:Has("gfbook3", 1) and self.accessible_tech_trees.ANCIENT < 4 then self.accessible_tech_trees.ANCIENT = 4 changed = true end if changed then self.inst:PushEvent("techtreechange", { level = self.accessible_tech_trees }) self.inst.replica.builder:SetTechTrees(self.accessible_tech_trees) end end end end AddComponentPostInit("builder", NewBuilder) Link to comment Share on other sites More sharing options...
Fredson Posted January 19, 2017 Author Share Posted January 19, 2017 Thanks ill try it later today Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now