Plugin stops prematurely

Posted by Terry on Thu 19 Jun 2008 11:52 PM — 3 posts, 14,761 views.

USA #0
I was trying to write a plugin to extend/retract my wings, but it keeps saying "Your wings are currently retracted." and stops there, no matter what I do. Could someone help me?
Here's the plugin:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Thursday, June 19, 2008, 7:39 PM -->
<!-- MuClient version 4.27 -->

<!-- Plugin "wings" generated by Plugin Wizard -->

<muclient>
<plugin
   name="wings"
   author="Terry"
   id="40cd49ff725c2a26ba6e80cb"
   language="Lua"
   purpose="To extend or retract my wings."
   date_written="2008-06-19 19:38:58"
   requires="3.18"
   version="1.0"
   >

</plugin>


<!--  Get our standard constants -->

<include name="constants.lua"/>

<!--  Aliases  -->

<aliases>
  <alias
   match="^wings(| in| out)(| .*?)$"
   enabled="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>
--[[ Set wingPos ]]--
if wingPos == nil then
  wingPos = "retracted"
end -- if
-- No Argument
if "%1" == "" then
Note("Your wings are currently ", wingPos, ".")

--[[ Extend Wings ]]--
elseif "%1" == " out" then 
  if wingPos == "extended" then
    Note("Your wings are already extended!")
  else
    Send("demonset wings wings covered by a coat of silvery feathers. Though they only take up about three quarters of her back, it is obviously unnatural for a Human to have such")
    if "%2" == "" then
      Send("emote closes her eyes and tenses slightly. Leaning forward, her body trembles slightly, and two small wings emerge from her back.")
    else
      Send("emote%2")
    end -- if
  end -- if

--[[ Retract Wings ]]--
else
  if wingPos == "retracted" then
    Note("You wings are already retracted!")
  else
    Send("demonset wings retracted and well-hidden")
    if "%2" == "" then
        Send("emote clenches her back, bending forward. After a few seconds, her wings begin to fold and retract. A few seconds later, they are completely hidden.")
    else
        Send("emote%2")
    end -- if
  end -- if
end -- if</send>
  </alias>
</aliases>

</muclient>


Thanks for the help!
P.S. I know I don't need to write 1-line comments how I did it, but I just think it looks more symmetrical this way xD


Edit:
I just noticed, that it didn't indent with the [code][/code] tags even though it was indented correctly in the message box. Did I do something wrong?
Amended on Fri 20 Jun 2008 01:55 AM by Nick Gammon
Australia Forum Administrator #1
You started with [/code] not [code] - I fixed it.
Australia Forum Administrator #2
You need to rework your regular expression. I added this line:


print ("%%1 = '%1'")


It always showed "%1 = ''" even if I typed: wings out

See, with this:


^wings(| in| out)(| .*?)$


Your first alternative is to match nothing, which it does, and then moves on to take a space and the rest of the line.

Try this:


^wings( in| out|)(| .*?)$


A neater way might be:


^wings( in| out)?( .*)?$


That is, zero or one instances of " in" or " out".