. . . Posted May 24, 2016 Share Posted May 24, 2016 Helloo, I need someones help to me a kind of code that would inst.components.sanity:DoDelta(-50) any players in a med range of my character upon going insane, since I got my character to roar upon going insane now I just need help with lowering other's sanity by 50 points ! Please I beg of the coding gods here on Klei Forums, please, please, please help I really need this for make my character !!!! I thank you for everything you all done for me, 100% credit to you !!!!! Link to comment Share on other sites More sharing options...
CarlZalph Posted May 24, 2016 Share Posted May 24, 2016 In your event of going insane callback: local theCharacter = <event callback data for going insane for your player's inst> if(theCharacter.Transform) then local x, y, z = theCharacter.Transform:GetWorldPosition() local players = FindPlayersInRange(x, y, z, (range here), true) for _, v in pairs(players) do if(v~=theCharacter) then if(v.components and v.components.sanity) then v.components.sanity:DoDelta(-50) end end end end Link to comment Share on other sites More sharing options...
. . . Posted May 24, 2016 Author Share Posted May 24, 2016 Please help I did this and it crashed local theCharacter = <"goinsane" for "goinsane" for "adam"> if(theCharacter.Transform) then local x, y, z = theCharacter.Transform:GetWorldPosition() local players = FindPlayersInRange(x, y, z, (range here), true) for _, v in pairs(players) do if(v~=theCharacter) then if(v.components and v.components.sanity) then v.components.sanity:DoDelta(-50) end end end end So close!!!! Please CarlZalph help !!!!!!!!!!!!!!!!! Link to comment Share on other sites More sharing options...
CarlZalph Posted May 24, 2016 Share Posted May 24, 2016 3 minutes ago, SuperDavid said: Please help I did this and it crashed So close!!!! Please CarlZalph help !!!!!!!!!!!!!!!!! Of course it crashed, you need to shove it into your event callback for going insane. Ala: inst:ListenForEvent("goinsane", function(inst) --The big code block above local theCharacter = inst end ) Then change (range here) into some real floating point number for your range you want. Link to comment Share on other sites More sharing options...
. . . Posted May 24, 2016 Author Share Posted May 24, 2016 (edited) I did this inst:ListenForEvent("goinsane", function(inst, data) local theCharacter = <"goinsane" for "goinsane" for "adam"> --line 293 if(theCharacter.Transform) then local x, y, z = theCharacter.Transform:GetWorldPosition() local players = FindPlayersInRange(x, y, z, (1), true) for _, v in pairs(players) do if(v~=theCharacter) then if(v.components and v.components.sanity) then v.components.sanity:DoDelta(-50) end end end end local theCharacter = inst end) but it says ":293: unexpected symbol near '<'" please help !!! Edited May 24, 2016 by SuperDavid Link to comment Share on other sites More sharing options...
CarlZalph Posted May 24, 2016 Share Posted May 24, 2016 (edited) 9 minutes ago, SuperDavid said: I did this but it says ":293: unexpected symbol near '<'" please help !!! Lol. inst:ListenForEvent("goinsane", function(inst, data) if(inst.Transform) then local x, y, z = inst.Transform:GetWorldPosition() local players = FindPlayersInRange(x, y, z, (range here), true) for _, v in pairs(players) do if(v~=inst) then if(v.components and v.components.sanity) then v.components.sanity:DoDelta(-50) end end end end end ) Put it in your character's master postinit function callback or after the pristine state/TheWorld.ismastersim check. Though you should have already have an event listener for your character's roar sound on going insane. My snippets generally need some minor work to get it into your code portion. Also a range of 1.0 is the size of 1/4th of a turf square. Edited May 24, 2016 by CarlZalph Link to comment Share on other sites More sharing options...
. . . Posted May 24, 2016 Author Share Posted May 24, 2016 Thank you, thank you, thank you SO MUCH!!!!!!! Now I have nice roar, really thanks so much I never could do this without you definitely give you all credit for roar of my character !!!!!! Really thanks again !! 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