Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ Lua ➜ Plugin stops prematurely

Plugin stops prematurely

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Terry   USA  (87 posts)  Bio
Date Thu 19 Jun 2008 11:52 PM (UTC)

Amended on Fri 20 Jun 2008 01:55 AM (UTC) by Nick Gammon

Message
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?
Top

Posted by Nick Gammon   Australia  (23,102 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 20 Jun 2008 01:55 AM (UTC)
Message
You started with [/code] not [code] - I fixed it.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,102 posts)  Bio   Forum Administrator
Date Reply #2 on Fri 20 Jun 2008 02:04 AM (UTC)
Message
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".

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


10,764 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.