MrDoge124 Posted February 5, 2017 Share Posted February 5, 2017 Hello I would like some help. I would like my character to have a light that goes down with his sanity. I have got the light working but I don't know how to make it go down with his sanity. Link to comment Share on other sites More sharing options...
HabdomeRaider Posted February 6, 2017 Share Posted February 6, 2017 You'll want to take a look at rabbit.lua to see how the rabbits respond to your sanity to turn into beardlings. Specifically the WatchSanity function that gets called by OnPickup. You'll probably want to call WatchSanity in an OnEquip function and StopWatchingSanity in OnUnequip. Link to comment Share on other sites More sharing options...
. . . Posted February 6, 2017 Share Posted February 6, 2017 I think you would put something like this in YOURCHARACTER.lua inside the master_postinit ~ inst:ListenForEvent("sanitydelta", function(inst, data) if inst.components.sanity.current >= 150 then -- Set max light level elseif inst.components.sanity.current >= 100 then -- Lower light level elseif inst.components.sanity.current >= 50 then -- Lower light level elseif inst.components.sanity.current <= 50 then -- Set min light level end end) Link to comment Share on other sites More sharing options...
MrDoge124 Posted February 7, 2017 Author Share Posted February 7, 2017 It didn't work. I changed stuff around and it still didn't work. Link to comment Share on other sites More sharing options...
Leonardo Cox Posted February 8, 2017 Share Posted February 8, 2017 (edited) Post your prefab file/mod? Edited February 8, 2017 by DarkKingBoo Link to comment Share on other sites More sharing options...
MrDoge124 Posted February 9, 2017 Author Share Posted February 9, 2017 20 hours ago, DarkKingBoo said: Post your prefab file/mod? Sure I can do that. green.lua Link to comment Share on other sites More sharing options...
RedHairedHero Posted February 10, 2017 Share Posted February 10, 2017 On 2/5/2017 at 10:31 PM, SuperDavid said: I think you would put something like this in YOURCHARACTER.lua inside the master_postinit ~ inst:ListenForEvent("sanitydelta", function(inst, data) if inst.components.sanity.current >= 150 then -- Set max light level elseif inst.components.sanity.current >= 100 then -- Lower light level elseif inst.components.sanity.current >= 50 then -- Lower light level elseif inst.components.sanity.current <= 50 then -- Set min light level end end) This ought to work, you can alternatively call an outside function which is basically the same method. local function sanitylight(inst) if inst.components.sanity.current >= 150 then inst.Light:SetIntensity(0.5) inst.Light:SetRadius(0.9) inst.Light:SetFalloff(0.5) elseif inst.components.sanity.current >= 100 then -- Lower light level inst.Light:SetIntensity(0.5) inst.Light:SetRadius(0.9) inst.Light:SetFalloff(0.5) elseif inst.components.sanity.current >= 50 then -- Lower light level inst.Light:SetIntensity(0.5) inst.Light:SetRadius(0.9) inst.Light:SetFalloff(0.5) elseif inst.components.sanity.current <= 50 then -- Set min light level inst.Light:SetIntensity(0.5) inst.Light:SetRadius(0.9) inst.Light:SetFalloff(0.5) end end --Put this part in Master Post Init inst:ListenForEvent("sanitydelta", sanitylight) Then just change the light settings to whatever you want for each stage like SuperDavid mentioned. Link to comment Share on other sites More sharing options...
MrDoge124 Posted February 10, 2017 Author Share Posted February 10, 2017 So far the game boots up fine, but how should I test it? Link to comment Share on other sites More sharing options...
Lumina Posted February 10, 2017 Share Posted February 10, 2017 http://dontstarve.wikia.com/wiki/Console/Don't_Starve_Together_Commands open the console type : c_give("green_cap", 20) repeat for c_give("green_cap_cooked", 20) Eat the green_cap to loose sanity, eat the green_cap_cooked to recover sanity, see if it's work fine, adjust the values if not. Link to comment Share on other sites More sharing options...
MrDoge124 Posted February 10, 2017 Author Share Posted February 10, 2017 A question about the values are they the percent of sanity or the amount of sanity on the sanity meter? Link to comment Share on other sites More sharing options...
RedHairedHero Posted February 10, 2017 Share Posted February 10, 2017 47 minutes ago, MrDoge124 said: A question about the values are they the percent of sanity or the amount of sanity on the sanity meter? Those would be the amount of sanity on the meter. Link to comment Share on other sites More sharing options...
HabdomeRaider Posted February 11, 2017 Share Posted February 11, 2017 You can use inst.components.sanity:GetPercent() if you'd prefer to have it based on percentage. Link to comment Share on other sites More sharing options...
MrDoge124 Posted February 11, 2017 Author Share Posted February 11, 2017 It works! Link to comment Share on other sites More sharing options...
MrDoge124 Posted February 11, 2017 Author Share Posted February 11, 2017 Is there a way to make the light turn off? I tried, inst.Light:Enable (false). 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