Koro sensei Posted September 29, 2018 Share Posted September 29, 2018 (edited) Hey so I've been thinking of making a Koro Sensei mod (Assassination classroom), and he moves slower in the rain, however i can not figure out how to create a attribute like that, I have seen the post about basic perks to your character however that does not work with dont starve together, someone please help im stupid at coding korosensei.lua Edited October 5, 2018 by Koro sensei Link to comment Share on other sites More sharing options...
Ultroman Posted September 30, 2018 Share Posted September 30, 2018 (edited) You could always listen for the "moisturedelta" event on the player's moisture component, and make it call a custom function in your script. which updates the runspeed and walkspeed variables of the player's locomotor component, depending on the "new" variable. Something like this: local function myMoisureDeltaFunction(inst, data) -- data.new holds the new value, and data.old holds the old value. Check out the PushEvent call in the moisture component code. -- Do some nice calculation for figuring out how much to lower the movement speed depending on how wet he is. -- The following is PSEUDO CODE. I can't remember the possible moisture values, but if the maximum moisture is 100, -- then the following will lower his movement speed to 0 when moisture is 100, which is probably not what you want, -- but it's an example. var speedRatio = (100 - data.new) / 100 -- normalWalkSpeed and normalRunSpeed should be saved somewhere at the start of your script, so you always know which -- value to return to when the player is no longer wet. inst.components.locomotor.walkspeed = normalWalkSpeed * speedRatio inst.components.locomotor.runspeed = normalRunSpeed * speedRatio end -- At the bottom of your player initialization function, add this. inst:ListenForEvent("moisturedelta", myMoistureDeltaFunction) Edited September 30, 2018 by Ultroman Link to comment Share on other sites More sharing options...
Koro sensei Posted October 1, 2018 Author Share Posted October 1, 2018 (edited) On 9/30/2018 at 9:36 AM, Ultroman said: You could always listen for the "moisturedelta" event on the player's moisture component, and make it call a custom function in your script. which updates the runspeed and walkspeed variables of the player's locomotor component, depending on the "new" variable. Something like this: local function myMoisureDeltaFunction(inst, data) -- data.new holds the new value, and data.old holds the old value. Check out the PushEvent call in the moisture component code. -- Do some nice calculation for figuring out how much to lower the movement speed depending on how wet he is. -- The following is PSEUDO CODE. I can't remember the possible moisture values, but if the maximum moisture is 100, -- then the following will lower his movement speed to 0 when moisture is 100, which is probably not what you want, -- but it's an example. var speedRatio = (100 - data.new) / 100 -- normalWalkSpeed and normalRunSpeed should be saved somewhere at the start of your script, so you always know which -- value to return to when the player is no longer wet. inst.components.locomotor.walkspeed = normalWalkSpeed * speedRatio inst.components.locomotor.runspeed = normalRunSpeed * speedRatio end -- At the bottom of your player initialization function, add this. inst:ListenForEvent("moisturedelta", myMoistureDeltaFunction) u-uh........ i don't really know how to do it... but i get how it works now, I'll try my best, thank you! Edited October 1, 2018 by Koro sensei Link to comment Share on other sites More sharing options...
Ultroman Posted October 1, 2018 Share Posted October 1, 2018 Read some of the tutorials pinned in this forum ([Don't Starve Together] Mods and Tools). If you don't know LUA scripting, there's a crash course here, and that site has a bunch more advanced tutorials. You kind of need to learn scripting in order to make mods. There's no easy mode. The code I presented is almost complete for your purposes. Link to comment Share on other sites More sharing options...
Koro sensei Posted October 5, 2018 Author Share Posted October 5, 2018 (edited) On 10/1/2018 at 9:28 PM, Ultroman said: Read some of the tutorials pinned in this forum ([Don't Starve Together] Mods and Tools). If you don't know LUA scripting, there's a crash course here, and that site has a bunch more advanced tutorials. You kind of need to learn scripting in order to make mods. There's no easy mode. The code I presented is almost complete for your purposes. alright, thanks so much for your help! I'll just try to poke around with wx78's lua edit:(quick question where exactly is the player initialization function? is it the "local common_postinit = function(inst)" at -- This initializes for both the server and client. Tags can be added here." Edited October 5, 2018 by Koro sensei Link to comment Share on other sites More sharing options...
Ultroman Posted October 5, 2018 Share Posted October 5, 2018 Download a popular character mod, which has seen an update within the last 2 months, and look at the code. That's really the best way to figure out how to do things. I can't remember all this stuff, and I don't have time ATM to look. Sorry. 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