icantevenname Posted April 21, 2017 Share Posted April 21, 2017 Think it's possible to give characters text to say when doing certain emotes? Link to comment Share on other sites More sharing options...
DarkXero Posted April 21, 2017 Share Posted April 21, 2017 local emotesay = { wilson = { research = "Yay", -- /joy emoteXL_annoyed = "Ugh", -- /no }, willow = { research = "Fire", -- /joy emoteXL_annoyed = "Water", -- /no }, } local function EmoteReact(inst, data) if data then local saytable = emotesay[inst.prefab] if saytable then local saying = saytable[data.anim] if saying and inst.components.talker then inst.components.talker:Say(saying) end end end end AddPlayerPostInit(function(inst) inst:ListenForEvent("emote", EmoteReact) end) You can see the rest of animations at emotes.lua. Link to comment Share on other sites More sharing options...
icantevenname Posted April 21, 2017 Author Share Posted April 21, 2017 31 minutes ago, DarkXero said: local emotesay = { wilson = { research = "Yay", -- /joy emoteXL_annoyed = "Ugh", -- /no }, willow = { research = "Fire", -- /joy emoteXL_annoyed = "Water", -- /no }, } local function EmoteReact(inst, data) if data then local saytable = emotesay[inst.prefab] if saytable then local saying = saytable[data.anim] if saying and inst.components.talker then inst.components.talker:Say(saying) end end end end AddPlayerPostInit(function(inst) inst:ListenForEvent("emote", EmoteReact) end) You can see the rest of animations at emotes.lua. So if one wanted to do this for a mod character...? Link to comment Share on other sites More sharing options...
Lumina Posted April 21, 2017 Share Posted April 21, 2017 replace "wilson" or "willow" by the name of your character i guess. Link to comment Share on other sites More sharing options...
icantevenname Posted April 21, 2017 Author Share Posted April 21, 2017 5 minutes ago, Lumina said: replace "wilson" or "willow" by the name of your character i guess. I dunno, how Xero has it set up feels like its own thing. Like a script only mod of some sort. Then again, Xero could intend me (and anyone else) to put this in the character's prefab script. I'll try it out tomorrow, it's getting late for me. Link to comment Share on other sites More sharing options...
Serpens Posted April 21, 2017 Share Posted April 21, 2017 (edited) yes, you have to add your character prefab to this. And also the emotes you want, at the moment it onyl contains "emoteXL_annoyed" and "research". As he said, you can find the other emotes in emotes.lua. BUT: It is not that easy, the data.anim is not always a string. It can also be a table:anim={"emoteXL_pre_dance0","emoteXL_loop_dance0"} or even a "tabled" table:anim={{"emote_pre_sit1","emote_loop_sit1"},{"emote_pre_sit3","emote_loop_sit3"}} I already made a function to check this for my quest mod, you could use it: Â -- all the emotes you can actively do at the moment. To add mod emotes, or emotes like research, add them the same way to that list, while "name" is a custom name you choose and also use in your emotesay local emoteanims = {{name="Dance",anims={"emoteXL_pre_dance0","emoteXL_loop_dance0"}},{name="Kiss",anims={"emoteXL_kiss"}},{name="Bonesaw",anims={"emoteXL_bonesaw"}},{name="Angry",anims={"emoteXL_angry"}},{name="Happy",anims={"emoteXL_happycheer"}},{name="Pose",anims={"emote_strikepose"}},{name="Wave",anims={"emoteXL_waving1","emoteXL_waving2","emoteXL_waving3"}},{name="Facepalm",anims={"emoteXL_facepalm"}},{name="Joy",anims={"research"}},{name="Cry",anims={"emoteXL_sad"}},{name="Annoyed",anims={"emoteXL_annoyed"}},{name="Rude",anims={"emoteXL_waving4"}},{name="Sit",anims={"emote_pre_sit2","emote_loop_sit2","emote_pre_sit4","emote_loop_sit4"}},{name="Squat",anims={"emote_pre_sit1","emote_loop_sit1","emote_pre_sit3","emote_loop_sit3"}}} local emotesay = { wilson = { Dance = "Yay", -- /joy Angry = "Ugh", -- /no }, willow = { Dance = "Fire", -- /joy Angry = "Water", -- /no }, } local function CheckWhichEmote(data) name = false if data then for i,anim in pairs(emoteanims) do if type(data.anim)=="string" and anim.anims[1] == data.anim then -- if data.anim is a string, we only need to check first. name = anim.name elseif type(data.anim)=="table" then -- check also if anim is a table for k,animstringdata in pairs(data.anim) do if type(animstringdata)=="string" then -- if it is now a string for k2,animstring in pairs(anim.anims) do if animstring == animstringdata then name = anim.name end end elseif type(animstringdata)=="table" then -- in case of sit and aquat it is again a table... for q,stringdata in pairs(animstringdata) do for k2,animstring in pairs(anim.anims) do if animstring == stringdata then name = anim.name end end end end end end end end return name -- returns the name of the emotion from your emoteanims table end local function EmoteReact(inst, data) if data then name = CheckWhichEmote(data) if name then local saytable = emotesay[inst.prefab] if saytable then local saying = saytable[name] if saying and inst.components.talker then inst.components.talker:Say(saying) end end end end end AddPlayerPostInit(function(inst) inst:ListenForEvent("emote", EmoteReact) end) this should work, but I did not tested if I made a typo somewhere. So if it crashes, please post error message. Again you add your character prefabs. And also add new emotes, if they are not already in the emoteanims list. Edited May 1, 2017 by Serpens Link to comment Share on other sites More sharing options...
DarkXero Posted April 21, 2017 Share Posted April 21, 2017 12 hours ago, icantevenname said: So if one wanted to do this for a mod character...? Say your character prefab is "walton", then you would go like: local emotesay = { walton = { research = "Yay", -- /joy emoteXL_annoyed = "Ugh", -- /no }, } local function EmoteReact(inst, data) if data then local saytable = emotesay[inst.prefab] if saytable then local saying = saytable[data.anim] if saying and inst.components.talker then inst.components.talker:Say(saying) end end end end AddPlayerPostInit(function(inst) inst:ListenForEvent("emote", EmoteReact) end) 10 hours ago, icantevenname said: I dunno, how Xero has it set up feels like its own thing. Like a script only mod of some sort. Then again, Xero could intend me (and anyone else) to put this in the character's prefab script. I'll try it out tomorrow, it's getting late for me. Since you said "characters" (plural) in your main post, I made it so anybody with data on the table would have the strings. This way not only you can make a table to include many mod characters all in one, you can also include the official characters as well. It's a general solution that you can modify to suit your needs. It goes on modmain, because it makes use of AddPlayerPostInit. Â You can even make "character specific" code for your prefab file like this: local saytable = { research = "Yay", -- /joy emoteXL_annoyed = "Ugh", -- /no } local function EmoteReact(inst, data) if data then local saying = saytable[data.anim] if saying and inst.components.talker then inst.components.talker:Say(saying) end end end -- inside your master_postinit function local function master_postinit(inst) inst:ListenForEvent("emote", EmoteReact) end You skip the prefab checks (since it's just for your character) and just react to the emote animations. Link to comment Share on other sites More sharing options...
icantevenname Posted April 25, 2017 Author Share Posted April 25, 2017 I'll give both a shot. Wish me luck. Link to comment Share on other sites More sharing options...
icantevenname Posted April 26, 2017 Author Share Posted April 26, 2017 Doesn't seem to do anything... Did I do something wrong? Emote react.zip Link to comment Share on other sites More sharing options...
DarkXero Posted May 1, 2017 Share Posted May 1, 2017 On 25/4/2017 at 11:48 PM, icantevenname said: Did I do something wrong? modmian Link to comment Share on other sites More sharing options...
Serpens Posted May 1, 2017 Share Posted May 1, 2017 Not related to your bug, but I adjusted "wave" and "bye" animations in my code above. They were changed to wave and rude with past game update. Link to comment Share on other sites More sharing options...
icantevenname Posted May 1, 2017 Author Share Posted May 1, 2017 14 hours ago, DarkXero said: modmian I keep looking at the code I have in the modmain and what you told me originally. I still don't see what I did wrong. I need some elaboration. Link to comment Share on other sites More sharing options...
Lumina Posted May 1, 2017 Share Posted May 1, 2017 7 minutes ago, icantevenname said: I keep looking at the code I have in the modmain and what you told me originally. I still don't see what I did wrong. I need some elaboration. It was clear, you have a file named "modmian.lua" instead of "modmain.lua". So it can't work. Link to comment Share on other sites More sharing options...
icantevenname Posted May 1, 2017 Author Share Posted May 1, 2017 1 hour ago, Lumina said: It was clear, you have a file named "modmian.lua" instead of "modmain.lua". So it can't work. I always seem to be looking in th' wrong direction... Link to comment Share on other sites More sharing options...
icantevenname Posted May 1, 2017 Author Share Posted May 1, 2017 Now to make everyone say "GET DOWN WITH YOUR BAD SELF!" upon dancing. Link to comment Share on other sites More sharing options...
icantevenname Posted May 1, 2017 Author Share Posted May 1, 2017 (edited) I keep running into this if I have more than three lines on any character. It also doesn't seem to work with emotes that have variations. Edited May 1, 2017 by icantevenname Adding information Link to comment Share on other sites More sharing options...
Serpens Posted May 1, 2017 Share Posted May 1, 2017 (edited) you have all the code you need. Just copy paste it (there might be typos in it so it could still crash, but then we need to know your code + error message) So what is the problem? (the last versin with "modmian" does not contain code that could produce the error you reported) It is not a choice "DarkXero or Serps code" it is both. DarkXero gave the basic and I added code to also be able to deal with more complex emotes. Edited May 1, 2017 by Serpens Link to comment Share on other sites More sharing options...
icantevenname Posted May 1, 2017 Author Share Posted May 1, 2017 5 minutes ago, Serpens said: you have all the code you need. Just copy paste it (there might be typos in it so it could still crash, but then we need to know your code + error message) So what is the problem? (the last versin with "modmian" does not contain code that could produce the error you reported) It is not a choice "DarkXero or Serps code" it is both. DarkXero gave the basic and I added code to also be able to deal with more complex emotes. I see. I figured out what was wrong, but the emotes with variants still don't have a reaction. Which makes me sad, since Dance is one of those emotes... Emote react.zip Link to comment Share on other sites More sharing options...
Serpens Posted May 1, 2017 Share Posted May 1, 2017 the best thing you can do is to add "print()" statements in the code. I did it and noticed that there is no name returned when the dance is done, so obviously my function does something wrong. I will work now to fix it Link to comment Share on other sites More sharing options...
Serpens Posted May 1, 2017 Share Posted May 1, 2017 Fixed my code, it was just two times ".anims" that was missing in the CheckWhichEmote function. So just copy paste the corrected CheckWhichEmote function from my previous post into your mod and it works (tested) Link to comment Share on other sites More sharing options...
icantevenname Posted May 1, 2017 Author Share Posted May 1, 2017 Everythin' works! Thanks for stickin' around to help me! 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