-
-
September 17, 2015 at 5:52 am #26933
So I’ve never used lua besides the hacking together of scripts for Mushclient, etc… and that has been a pretty limited experience consisting of direct copy paste and clumsy reverse engineering. For the most part I’d given up on trying to figure all this stuff out, but tonight I got a hankering for some learning and also I had basic vision for what sort of plugin I was trying to create and it didn’t seem very complex…
Race_Emotes:
The purpose of this plugin is to give a character subconscious body language/movement according to their species/body type. It has a predefined list of socials and emotes that is selects from randomly at a random interval between 43-86 seconds. (pretty simple right?) It consists of two small aliases. Alias #1 is working as intended though there is a bit of code in it I don’t quite understand. Alias #2 does not seem to work no matter what I have tried but I am pretty sure it is from a lack of understanding on my part about how alias #1 and alias #2 interact.
Any help/feedback would be greatly appreciated!
(some words have been changed to disguise my current race)
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE muclient> <!-- Saved on Thursday, September 17, 2015, 5:38 AM --> <!-- MuClient version 4.94 --> <!-- Plugin "Race_Emotes" generated by Plugin Wizard --> <!-- Get better at life Bagz! --> <muclient> <plugin name="Race_Emotes" author="Mostly Nick Gammon w Bagz Hacks" id="19df337f76ec93929842f9c3" language="Lua" purpose="To give unconcious movement to characters based on race/body type" date_written="2015-09-17 05:34:23" requires="1.00" version="1.0" > <description trim="y"> <![CDATA[ This makes an alias that uses a list of emotes or socials you define in the "speech" table. (would like to figure out how to change this on the fly in game and not have to hard code it. Would eventually like to add support for various races.) It picks one emote or social from the list ever 43 to 86 seconds (also defined in the script in the line with: wait.time (43 + math.random (43)) -- 43 to 86 seconds start with: raceemotes on stop with: raceemotes off ]]> </description> </plugin> <!-- Get our standard constants --> <include name="constants.lua"/> <!-- Aliases --> <aliases> <alias match="raceemotes on" enabled="y" send_to="12" sequence="100" > <send>ColourNote ("red", "blue", "Race Emotes Enabled") require "wait" wait.make (function () --- coroutine below here speech = { "emote does a racially and culturally ambiguous performance, hard to say if it was a dance or a ceremonial marriage ritual", "emote pulls off their garment of non-descript shape, size, fabric, color, style and cultural significance", "emote checks their txt msgs for lulz", "emote cries at the end of Titanic", "emote has a moment of clarity and proceeds to go out and buy the newest IPhone", "emote can't decide if their grandparents made up reality as a practical joke", "emote pretends to be a cat pretending to be a sandwich" -- more here } -- end of speech table while not GetVariable ("stop_raceemotes") do wait.time (43 + math.random (77)) -- 43 to 120 seconds Send (speech [ math.random (1, #speech) ]) end -- while DeleteVariable ("stop_raceemotes") ColourNote ("red", "blue", "Race Emotes Disabled") end) -- end of coroutine </send> </alias> <alias match="raceemotes off" enabled="y" variable="stop_raceemotes" send_to="9" sequence="100" > <send>stop</send> </alias> </aliases> <!-- Plugin help --> <aliases> <alias script="OnHelp" match="Race_Emotes:help" enabled="y" > </alias> </aliases> <script> <![CDATA[ function OnHelp () world.Note (world.GetPluginInfo (world.GetPluginID (), 3)) end ]]> </script> </muclient>
Ideally it would also know not to use the item from the list that it JUST used, however, that is beyond my scope presently and I’d be happy just to get it to switch off without a hard disable of the plugin.
-
September 17, 2015 at 10:09 am #26934
This will prevent your script from using the same emote again:
last_random = 1 --Initialize to prevent errors while not GetVariable ("stop_raceemotes") do wait.time (43 + math.random (77)) -- 43 to 120 seconds current_random = math.random(1, #speech) if current_random == last_random then --If our random variable is the same as the last one.. current_random = current_random + 1 end --if Send (speech [ current_random ]) last_random = current_random --Our last array item used.. end -- while
This will make your turn off alias actually work:
</send> </alias> <alias match="raceemotes off" enabled="y" variable="stop_raceemotes" send_to="12" <------- CHANGE TO 12 sequence="100" > <send>SetVariable("stop_raceemotes", "1")</send> <---- ACTUALLY SET THE VARIABLE YOU ARE CHECKING FOR </alias> </aliases>
Make sure to delete my arrow messages, they are there for explanation. I tested this script with those changes, and it works for me.
-
September 17, 2015 at 10:32 am #26936
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE muclient> <!-- Saved on Thursday, September 17, 2015, 5:38 AM --> <!-- MuClient version 4.94 --> <!-- Plugin "Race_Emotes" generated by Plugin Wizard --> <!-- Get better at life Bagz! --> <muclient> <plugin name="Race_Emotes" author="Mostly Nick Gammon w Bagz Hacks" id="19df337f76ec93929842f9c3" language="Lua" purpose="To give unconcious movement to characters based on race/body type" date_written="2015-09-17 05:34:23" requires="1.00" version="1.0" > <description trim="y"> <![CDATA[ This makes an alias that uses a list of emotes or socials you define in the "speech" table. (would like to figure out how to change this on the fly in game and not have to hard code it. Would eventually like to add support for various races.) It picks one emote or social from the list ever 43 to 86 seconds (also defined in the script in the line with: wait.time (43 + math.random (43)) -- 43 to 86 seconds start with: raceemotes on stop with: raceemotes off ]]> </description> </plugin> <!-- Get our standard constants --> <include name="constants.lua"/> <!-- Aliases --> <aliases> <alias match="raceemotes on" enabled="y" send_to="12" sequence="100" > <send>ColourNote ("red", "blue", "Race Emotes Enabled") require "wait" wait.make (function () --- coroutine below here speech = { "emote does a racially and culturally ambiguous performance, hard to say if it was a dance or a ceremonial marriage ritual", "emote pulls off their garment of non-descript shape, size, fabric, color, style and cultural significance", "emote checks their txt msgs for lulz", "emote cries at the end of Titanic", "emote has a moment of clarity and proceeds to go out and buy the newest IPhone", "emote can't decide if their grandparents made up reality as a practical joke", "emote pretends to be a cat pretending to be a sandwich" -- more here } -- end of speech table last_random = 1 --Initialize to prevent errors while not GetVariable ("stop_raceemotes") do --wait.time (43 + math.random (77)) -- 43 to 120 seconds wait.time (10) -- 10 seconds for testing current_random = math.random(1, #speech) if current_random == last_random then --If our random variable is the same as the last one.. current_random = current_random + 1 end --if Send (speech [ current_random ]) last_random = current_random --Our last array item used.. end -- while DeleteVariable ("stop_raceemotes") ColourNote ("red", "blue", "Race Emotes Disabled") end) -- end of coroutine </send> </alias> <alias match="raceemotes off" enabled="y" variable="stop_raceemotes" send_to="12" sequence="100" > <send>SetVariable("stop_raceemotes", "1")</send> </alias> </aliases> <!-- Plugin help --> <aliases> <alias script="OnHelp" match="Race_Emotes:help" enabled="y" > </alias> </aliases> <script> <![CDATA[ function OnHelp () world.Note (world.GetPluginInfo (world.GetPluginID (), 3)) end ]]> </script> </muclient>
-
This topic has 2 replies, 2 voices, and was last updated 8 years, 6 months ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.