RaymondFoxford Posted August 30, 2016 Share Posted August 30, 2016 Hey guys, I've been studying the "meteorshower.lua", "Meteorspawner.lua", "meteorwarning.lua", "shadowmeteor.lua" and "terrain_rocky.lua" files, and I was wondering if it is possible to make a character mod that spawns a meteor shower when his sanity gets low, a same meteor shower that happens randomly at the Rocky biomes, it would be something like this: sanity reachs 30, it will spawn a level 1 meteor shower; if sanity reachs 20 it will spawn a level 2 meteor shower; and if sanity reachs 10 it will spawn a level 3 meteor shower; if sanity reachs 0 another level 3 meteor shower will spawn. is it possible to make something like that? Link to comment https://forums.kleientertainment.com/forums/topic/69871-low-sanity-meteor-spawner/ Share on other sites More sharing options...
Serpens Posted August 30, 2016 Share Posted August 30, 2016 I think this might help you : Link to comment https://forums.kleientertainment.com/forums/topic/69871-low-sanity-meteor-spawner/#findComment-808505 Share on other sites More sharing options...
RaymondFoxford Posted August 30, 2016 Author Share Posted August 30, 2016 14 minutes ago, Serpens said: I think this might help you : Thanks Serpens but I already saw this post before, he wants to spawn just one meteor at time, not an entire meteor shower at one defined level. Link to comment https://forums.kleientertainment.com/forums/topic/69871-low-sanity-meteor-spawner/#findComment-808513 Share on other sites More sharing options...
rezecib Posted August 30, 2016 Share Posted August 30, 2016 (edited) @RaymondFoxford in the master_postinit: inst:AddComponent("meteorshower") if inst.components.meteorshower.task then --it automatically scheduled a shower inst.components.meteorshower:StopShower() --remove the automatically-scheduled shower end --override the StartCooldown on this particular component instance so it does not schedule more showers after completing one inst.components.meteorshower.StartCooldown = inst.components.meteorshower.StopShower --Watch sanity to know when to trigger the showers inst:ListenForEvent("sanitydelta", function(inst, data) --data provides the oldpercent and newpercent for sanity, so it is easier to do thresholds in percents --... but you could convert like this local oldsanity = data.oldpercent * inst.components.sanity.max local newsanity = data.newpercent * inst.components.sanity.max local level = nil if newsanity <= 0 and oldsanity > 0 or newsanity <= 10 and oldsanity > 10 then level = 3 elseif newsanity <= 20 and oldsanity > 20 then level = 2 elseif newsanity <= 30 and oldsanity > 30 then level = 1 end if level then --we passed a threshold and need to spawn a shower inst.components.meteorshower:StartShower(level) end end) Edited August 30, 2016 by rezecib Link to comment https://forums.kleientertainment.com/forums/topic/69871-low-sanity-meteor-spawner/#findComment-808595 Share on other sites More sharing options...
RaymondFoxford Posted August 30, 2016 Author Share Posted August 30, 2016 17 hours ago, rezecib said: @RaymondFoxford in the master_postinit: inst:AddComponent("meteorshower") if inst.components.meteorshower.task then --it automatically scheduled a shower inst.components.meteorshower:StopShower() --remove the automatically-scheduled shower end --override the StartCooldown on this particular component instance so it does not schedule more showers after completing one inst.components.meteorshower.StartCooldown = inst.components.meteorshower.StopShower --Watch sanity to know when to trigger the showers inst:ListenForEvent("sanitydelta", function(inst, data) --data provides the oldpercent and newpercent for sanity, so it is easier to do thresholds in percents --... but you could convert like this local oldsanity = data.oldpercent * inst.components.sanity.max local newsanity = data.newpercent * inst.components.sanity.max local level = nil if newsanity <= 0 and oldsanity > 0 or newsanity <= 10 and oldsanity > 10 then level = 3 elseif newsanity <= 20 and oldsanity > 20 then level = 2 elseif newsanity <= 30 and oldsanity > 30 then level = 1 end if level then --we passed a threshold and need to spawn a shower inst.components.meteorshower:StartShower(level) end end) It worked! Thank you so much! Link to comment https://forums.kleientertainment.com/forums/topic/69871-low-sanity-meteor-spawner/#findComment-808839 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