Hello all!
I'm entirely new at scripting in Lua but have a little experience programming in other, completely different languages.
I'm trying to write a plugin for MUSHclient that will display whether specific buffs are up or not in a Miniwindow.
Example: When I cast haste upon myself I get the message "You get a hurried look." This should trigger the font/indicator colour to change to green.
When the buff times out or is dispelled, I get the message "The world speeds up around you." This should change the font/indicator to red.
I'm pretty sure I can define triggers and use them to call functions. Properly formatting, displaying text or an indicator and changing their colour in a miniwindow; however, is beyond my ability.
Can anyone help me?
Thank you!
Jarvis
Using the module described there you can simply have gauges, text etc. in a miniwindow.
This describes the basics of setting up a miniwindow:
http://www.gammon.com.au/mushclient/mw_creation.htm
Put those two together and the rest should be a cinch!
Awesome!
Thanks so much.
Jarvis
Well,
Drawing pretty miniwindows now no problem! Now my problem is the opposite.
Is there a tutorial or guide around here that can help me with variables and sending values through triggers?
I want to change my variable called "armor" to darkgreen or darkred, triggered by the respective buff gained/lost messages. I've tried manually putting the line armor="darkgreen" within the trigger and having the trigger send to the variable armor with no success.
Though, I may have just solved my problem by typing this message. If it works, I'll repost in a little while.
Thanks!
Jarvis
Well, I feel like I'm beating my head against a brick wall.
I simply do not know how to retrieve information in a trigger for use in the script. Or maybe my triggers just aren't working, but I've used test trigger and typed in the exact trigger with no results.
Or I just don't know how to properly define variables in Lua.
Not giving up yet!
Jarvis
It works! I am a genius. Or at least those the wrote the code I based most of this on are geniuses.
Here it is if anyone's curious:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Wednesday, June 29, 2011, 1:12 PM -->
<!-- MuClient version 4.73 -->
<!-- Plugin "Buff_Indicator" generated by Plugin Wizard -->
<muclient>
<plugin
name="Buff_Indicator"
author="Jarvis"
id="f2c3153a7cc946c2a56ffe2f"
language="Lua"
purpose="To show nice pretty lights for buffs."
date_written="2011-06-29 13:09:25"
requires="4.73"
version="1.0"
>
</plugin>
<!-- Get our standard constants -->
<include name="constants.lua"/>
<!-- Triggers -->
<triggers>
<trigger
enabled="y"
match="You feel less protected."
regexp="n"
script="no_armor"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="The glow sinks into your skin!"
regexp="n"
script="yes_armor"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="You feel less righteous."
regexp="n"
script="no_bless"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="You feel righteous."
regexp="n"
script="yes_bless"
sequence="100"
>
</trigger>
</triggers>
<!-- Script -->
<script>
<![CDATA[
require "InfoBox"
box = InfoBox:New("ARMOR")
buffs = box:AddBar("Buffs")
box.Bars[1].captionPlacement = 4
box:CaptionPlacement()
box:Update()
function no_armor ()
buffs = box:AddBar("Armor", 100, "darkred")
box.Bars[1].captionPlacement = 4
box:CaptionPlacement()
box:Update()
end
function yes_armor ()
buffs = box:AddBar("Armor", 100, "darkgreen")
box.Bars[1].captionPlacement = 4
box:CaptionPlacement()
box:Update()
end
function no_bless ()
buffs = box:AddBar("Bless", 100, "darkred")
box.Bars[1].captionPlacement = 4
box:CaptionPlacement()
box:Update()
end
function yes_bless ()
buffs = box:AddBar("Bless", 100, "darkgreen")
box.Bars[1].captionPlacement = 4
box:CaptionPlacement()
box:Update()
end
]]>
</script>
</muclient>
I've only put in armor and bless... Only 13 more buffs to add..
It's finished and quite a bit different than the example above, which adds a new bar every time a buff is gained or lost... I fixed that and made the functions much shorter by creating the bars in the script and then using the functions to remove and insert the new colored bar.
Unfortunately, if I lose or gain a bunch of buffs at the same time, the miniwindow goes blank. Presumably because so many triggers are being activated at once? It will return if one of the triggers activates and Updates the window again. I tried adding code that when I typed affect to see which buffs are active, it would update the list, but it often proved too much for it to handle without blanking on me... The code could probably be optimized a lot..
Thanks again!
Jarvis