Would like some help with a plugin

Posted by DanaLea73 on Mon 13 Jun 2011 08:38 PM — 8 posts, 26,226 views.

USA #0
This is my first plugin.. I've gotten some help and that person said the code "looked solid". So now I'm trying to turn my code into an actual plugin. I created a blank plugin with the plugin wizard and added my code. can someone take a look and see if there's anything grossly wrong that I should fix before trying it in the real world? I don't want to break anything...

Thanks in advance..

http://pastebin.com/8DrebMYU
USA Global Moderator #1
Your help alias just won't work. You want


   script="OnHelp"
   match="ConHelp"


Your triggers block isn't terminated properly. You should end it with

</triggers>

Not

<triggers>


All of those "if blah = blah" should actually use == instead of =
= is for assignment
== is for comparison

Those changes will at least get the plugin to load. Though it looks like your trigger patterns are wrong, because they don't fire for me.
USA #2
I got this error after I made the changes and tried to reload it.


Compile error
Plugin: Consider_Replacements (called from world: Aardwolf)
Immediate execution
[string "Plugin"]:196: 'then' expected near '='
Error context in script:
 192 :   if name == "consider_annihilated" then
 193 :    ColourTell(consider_messages[name], "", "50+ levels higher than")
 194 :   elseif name == "consider_begone" then
 195 :     ColourTell(consider_messages[name], "", "41 to 50 levels higher than")
 196*:    elseif name = "consider_dance" then
 197 :     ColourTell(consider_messages[name], "", "is 32 to 41 levels higher than")
 198 :   elseif name == "consider_crush" then
 199 :     ColourTell(consider_messages[name], "", "21 to 32 levels higher than")
 200 :   elseif name == "consider_bravestupid" then
[WARNING] Z:\Applications\MUSHClient r992\worlds\plugins\Aard_Consider_Replacements.xml
Line  192: Error parsing script (Cannot load)



new pastebin for code...
http://pastebin.com/azKB5qFx


ack.. I missed a =... hold on please...
Amended on Mon 13 Jun 2011 09:16 PM by DanaLea73
USA Global Moderator #3
You missed an instance of = that should have become ==
USA Global Moderator #4
Also, you need to add

enabled="y"

to all of the triggers. That will get them to start working.
USA #5
hmmm.. you mean I have to turn the triggers ON.. yes I think that would help...

heh
USA Global Moderator #6
Once you've got all of that done, I find this to be a bit cleaner...


consider_messages = {
	consider_annihilated = {"#FF0000","50+ levels higher than"},
	consider_begone = {"#FF4000","41 to 50 levels higher than"},
	consider_dance = {"#FF8000","32 to 41 levels higher than"},
	consider_crush = {"#FFC000","21 to 32 levels higher than"},
	consider_bravestupid = {"#FFFF00","16 to 21 levels higher than"},
	consider_runaway = {"#80FF00","8 to 16 levels higher than"},
	consider_chuckles = {"#00FF00","3 to 8 levels higher than"},
	consider_snickers = {"#00FFC0","2 to 3 levels higher than"},
	consider_fair = {"#00FF80","within 2 levels of"},
	consider_worried = {"#00C0FF","2 to 6 levels lower than"},
	consider_weak = {"#0080FF","6 to 9 levels lower than"},
	consider_workout = {"#0040FF","9 to 19 levels lower than"},
	consider_stomp = {"#0000FF","more than 19 levels lower than"},
	consider_walkallover = {"#0000FF", "more than 19 levels lower than"}
}


function consider_capture(name, line, wildcards)
    mob={}
    mob.name = wildcards.mob
    mob.auras = wildcards.auras

    if string.find(mob.auras, "%(R%)") or string.find(mob.auras, "%(Red Aura%)") then
        ColourTell("red", "", mob.name)
    elseif string.find(mob.auras, "%(G%)") or string.find(mob.auras, "%(Golden Aura%)") then
        ColourTell("yellow", "", mob.name)
    else
        ColourTell("white", "", mob.name)
    end

    ColourTell("white", "", " is ")
    ColourTell(consider_messages[name][1], "", consider_messages[name][2])
    ColourNote("white", "", " you.")
end
USA #7
I agree that is cleaner, and probably just all around better... but it's working perfectly and I don't want to touch it. :p