CaptainToad Posted July 22, 2016 Share Posted July 22, 2016 I've been working on a DST character mod and One of their Cons is supposed to be Massive rain/wet damage (Taking damage from the rain/wetness, like 10 damage per second) Would anyone know what i'd have to put where. I tired searching for WX-78s Codes and stuff But I couldn't find them. Please help. Link to comment Share on other sites More sharing options...
IvanX Posted July 22, 2016 Share Posted July 22, 2016 (edited) That's how the 'speed bonus' is done for WX-78. inst:DoPeriodicTask(1, onupdate, nil, 1) OnUpdate function is called every second, and reduces 'overcharge counter' by 1. As for your character, there is a built in 'components/moisture' component. So in your case I would probably (that's if you modify an existing character tho): AddPrefabPostInit("MyCharacter", AddMyCharacterPostInit) get inst.components.wetness and then modify it in the following way: local AddMyCharacterPostInit = function(inst) local old_on_update = inst.components.moisture.OnUpdate local new_on_update = function(inst, dt) old_on_update(inst,dt) -- .. your code here -- inst.moisture will give you current wetness level end inst.components.moisture.OnUpdate = new_on_update end Point is, you do not need to put any functions inside your very character, you just need to modify his moisture component. And only HIS moisture component Edited July 22, 2016 by IvanX Link to comment Share on other sites More sharing options...
IvanX Posted July 22, 2016 Share Posted July 22, 2016 (edited) In exactly YOUR case, add the code into the master_postinit local master_postinit = function(inst) local old_on_update = inst.components.moisture.OnUpdate local new_on_update = function(inst, dt) old_on_update(inst,dt) -- .. your code here -- inst.moisture will give you current wetness level end inst.components.moisture.OnUpdate = new_on_update end Edited July 22, 2016 by IvanX Link to comment Share on other sites More sharing options...
CaptainToad Posted July 22, 2016 Author Share Posted July 22, 2016 4 hours ago, IvanX said: In exactly YOUR case, add the code into the master_postinit local master_postinit = function(inst) local old_on_update = inst.components.moisture.OnUpdate local new_on_update = function(inst, dt) old_on_update(inst,dt) -- .. your code here -- inst.moisture will give you current wetness level end inst.components.moisture.OnUpdate = new_on_update end I really do appreciate the help, but I don't quite understand what you mean by "adding code into the master_oistinit" Im a bit new to the whole coding stuff.... Link to comment Share on other sites More sharing options...
IvanX Posted July 22, 2016 Share Posted July 22, 2016 (edited) your character prefab will have this function, because it's one of the functions required to actually create a prefab. Look at the last line of "prefabs/wx78.lua" or any other character prefabs: Quote return MakePlayerCharacter("wx78", prefabs, assets, common_postinit, master_postinit) Thus i just brought up the piece of code required to modify moisture for your character, but master_postinit may still have 999 more modifications P.S. Just knock me on steam, ivanxru, I'd rather keep the entire conversation in here as the reference, but I'm not sitting here all day refreshing every 1 min So you can just ask your question and knock-knock Edited July 22, 2016 by IvanX Link to comment Share on other sites More sharing options...
CaptainToad Posted July 22, 2016 Author Share Posted July 22, 2016 Well I tried to find you on steam but there were no results for "ivanxru" So maybe there's a typo or, can you link your steam profile? Sorry about this. (My Steam is I R WIZARD btw) Link to comment Share on other sites More sharing options...
IvanX Posted July 22, 2016 Share Posted July 22, 2016 Oh, it's actually "ivanx". And its impossible to find profile by it's name like I R WIZARD, only the alias. 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