jupiter1390 Posted October 23, 2021 Share Posted October 23, 2021 I want to make player gain/lose sanity on doing specific emotes, and have no idea on tracking player performing emote, any way to do it? Link to comment Share on other sites More sharing options...
Monti18 Posted October 23, 2021 Share Posted October 23, 2021 When the player does an emote, an event is pushed to the player called emote. Spoiler local function CreateEmoteCommand(emotedef) return { aliases = emotedef.aliases, prettyname = function(command) return string.format(STRINGS.UI.BUILTINCOMMANDS.EMOTES.PRETTYNAMEFMT, FirstToUpper(command.name)) end, desc = function() return STRINGS.UI.BUILTINCOMMANDS.EMOTES.DESC end, permission = COMMAND_PERMISSION.USER, params = {}, emote = true, slash = true, usermenu = false, servermenu = false, vote = false, serverfn = function(params, caller) local player = UserToPlayer(caller.userid) if player ~= nil then player:PushEvent("emote", emotedef.data) end end, displayname = emotedef.displayname } end See emotes.lua You can then listen to the event emote and run your function. The data contains data.anim which has the string of the anim that is used so you can distinguish the different emotes. 1 Link to comment Share on other sites More sharing options...
jupiter1390 Posted October 24, 2021 Author Share Posted October 24, 2021 (edited) 16 hours ago, Monti18 said: When the player does an emote, an event is pushed to the player called emote. Hide contents local function CreateEmoteCommand(emotedef) return { aliases = emotedef.aliases, prettyname = function(command) return string.format(STRINGS.UI.BUILTINCOMMANDS.EMOTES.PRETTYNAMEFMT, FirstToUpper(command.name)) end, desc = function() return STRINGS.UI.BUILTINCOMMANDS.EMOTES.DESC end, permission = COMMAND_PERMISSION.USER, params = {}, emote = true, slash = true, usermenu = false, servermenu = false, vote = false, serverfn = function(params, caller) local player = UserToPlayer(caller.userid) if player ~= nil then player:PushEvent("emote", emotedef.data) end end, displayname = emotedef.displayname } end See emotes.lua You can then listen to the event emote and run your function. The data contains data.anim which has the string of the anim that is used so you can distinguish the different emotes. So, how should I fetch anim string data? Tried inst.components.anim but gives nil value local function bonesawDeluxe(inst, data) local emotetype = inst.components.anim print(emotetype) if emotetype == "emoteXL_bonesaw" then inst.components.health:DoDelta(-10) inst.components.sanity:DoDelta(5) inst.components.talker:Say("true") else inst.components.talker:Say("false") end end Edited October 24, 2021 by jupiter1390 Link to comment Share on other sites More sharing options...
Monti18 Posted October 24, 2021 Share Posted October 24, 2021 You fetch it how I told you, by using data.anim local function bonesawDeluxe(inst, data) local emotetype = data.anim print(emotetype) if emotetype == "emoteXL_bonesaw" then inst.components.health:DoDelta(-10) inst.components.sanity:DoDelta(5) inst.components.talker:Say("true") else inst.components.talker:Say("false") end end 1 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