Lavbun Posted April 21, 2021 Share Posted April 21, 2021 Heyo! I hope someone can help it would be great! I need help making code for my friends character which involves - Heat resistance during the summer and - A speed boost during the summer I found this in an old post, but it doesn't seem to work? inst.components.temperature.inherentsummerinsulation = 70 Thanks in advance for taking the time to read and help me with this!! Link to comment Share on other sites More sharing options...
Yakuzashi Posted April 23, 2021 Share Posted April 23, 2021 (edited) local function summerspeed(inst) if TheWorld.state.issummer then inst.components.locomotor:SetExternalSpeedMultiplier(inst, "CHARACTERNAME_speed_mod", 1.65) -- summer speed else inst.components.locomotor:SetExternalSpeedMultiplier(inst, "CHARACTERNAME_speed_mod", 1.25) --normal speed end end inst:DoPeriodicTask(60, summerspeed, nil, inst) I think it should still work. Run some tests and find out. I mean this: Quote inst.components.temperature.inherentsummerinsulation = 70 For increased speed during summer copy and paste stuff above inside "master_postinit" inside character.lua and change "CHARACTERNAME" to your character's name. That's all. Cheers! Edited April 23, 2021 by Yakuzashi Link to comment Share on other sites More sharing options...
Lavbun Posted April 23, 2021 Author Share Posted April 23, 2021 It worked! Thank you so much for your time and help! It means a lot! ;w; 1 Link to comment Share on other sites More sharing options...
-t- Posted April 23, 2021 Share Posted April 23, 2021 @Yakuzashi Is checking whether it's summer every 60 seconds necessary? You could probably do it with world watchers instead. Add a WatchWorldState("season", summerspeed) to your character and make the function take 2 variables: local function summerspeed(inst, season) -- Added a 'season' variable if season == "summer" then -- Check the season inst.components.locomotor:SetExternalSpeedMultiplier(inst, "CHARACTERNAME_speed_mod", 1.65) -- summer speed else inst.components.locomotor:SetExternalSpeedMultiplier(inst, "CHARACTERNAME_speed_mod", 1.25) --normal speed end end This way the function will be called only when seasons are changing. Additionally run this function on initialization: local function OnInit(inst) -- Run this function in your master_postinit summerspeed(inst, TheWorld.state.season) end This function is needed to set the appropriate speed boost when the character is created (when you join a game), while the other only sets the value when the seasons change. 2 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