loopuleasa Posted October 6, 2019 Share Posted October 6, 2019 I got this from Klei's official API docs, it's the double damage example ----------------------------------- -- Component mod example -- -- AddComponentPostInit("componentname", initfn) -- Use this to modify a component's properties or behavior ----------------------------------- local function DoubleHealthDeltaInit(component) print("DOUBLE DAMAGE ENABLED") local original_dodelta = component.DoDelta component.DoDelta = function(self, amount, overtime, cause, ignore_invincible) print("DOUBLE DAMAGE") local double_amount = amount*2 original_dodelta(self, double_amount, overtime, cause, ignore_invincible) end end AddComponentPostInit("health", DoubleHealthDeltaInit) No prints are being shown when taking damage. Similarly, I was trying to get it to work on my Moisture:OnUpdate component, and nothing is printed there either. AddComponentPostInit("moisture", function(self) _OldOnUpdate = self.OnUpdate print("AddComponentPostInit") function self:OnUpdate(dt) print("moisture update") trip_over_chance_on_maxwet(self.inst) _OldOnUpdate(self, dt) end end) Anyone know what is happening here, or any examples on components? Been struggling for 3 days to get this one working. Loop Link to comment Share on other sites More sharing options...
loopuleasa Posted October 6, 2019 Author Share Posted October 6, 2019 nevermind, solved, the file itself was not getting loaded the component code is fine, it prints now 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