[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Lua Script variables

Lua Script variables

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


Posted by Errigour   USA  (32 posts)  [Biography] bio
Date Mon 18 Jul 2011 03:43 PM (UTC)
Message
I want the following code to use i inside the "" qoute marks instead of i.


for i= 1, 7 do
AddAlias("", "i", "cast '@castingspell' @target", alias_flag.Enabled, alias_flag.eExpandVariables, "")
end
[Go to top] top

Posted by Errigour   USA  (32 posts)  [Biography] bio
Date Reply #1 on Mon 18 Jul 2011 03:49 PM (UTC)
Message
I also want to use AddAlias with more then one flag etc alias_flag.Enabled and alias_flag.eExpandVariables
[Go to top] top

Posted by Errigour   USA  (32 posts)  [Biography] bio
Date Reply #2 on Mon 18 Jul 2011 05:21 PM (UTC)
Message
I also wanna ask one more question here if it's ok.
I want to make an alias
heal *
and if %1 is a number then I want it
to execute a for loop and if %1 is
a word/character then I want it to
execute normaly
[Go to top] top

Posted by Fiendish   USA  (2,514 posts)  [Biography] bio   Global Moderator
Date Reply #3 on Mon 18 Jul 2011 06:28 PM (UTC)

Amended on Mon 18 Jul 2011 06:29 PM (UTC) by Fiendish

Message
In reverse order...


if tonumber("%1") then
  -- do stuff here if %1 is a number
else
  -- do stuff here if %1 is not a number
end


Flags are just magic numbers staggered in such a way that they can be added together. So add them together.

I don't understand your question.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Mon 18 Jul 2011 08:33 PM (UTC)
Message
Errigour said:

I want the following code to use i inside the "" qoute marks instead of i.


Does this help?

http://www.gammon.com.au/scripts/doc.php?lua=string%20literals

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Mon 18 Jul 2011 08:49 PM (UTC)

Amended on Mon 18 Jul 2011 08:50 PM (UTC) by Nick Gammon

Message
Errigour said:

I also want to use AddAlias with more then one flag etc alias_flag.Enabled and alias_flag.eExpandVariables


You might find addxml easier to use:

http://www.gammon.com.au/forum/?id=7123

eg.


require "addxml"
addxml.alias {  
                match = "k", 
                enabled = true,
                expand_variables = true,
                send = "kick @target",
                sequence = 100,
              }


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Errigour   USA  (32 posts)  [Biography] bio
Date Reply #6 on Fri 22 Jul 2011 11:18 AM (UTC)
Message

alias:heal *

if tonumber("%1") then
  if %1 > 0 then
    for i = 1, %1 do
    Send("heal heal")
    end
  end
else
  Note("heal")
end

I used the code above and when I just type heal it would send
heal to to mud instead of sending Note("heal"). and if I typed heal with a space "heal " or "heal " it sends an error
message my way.

[string "Alias: "]:2: unexpected symbol near '>'

I want to send Send("heal %1") if %1 is a space or a character and it seems to me tonumber recognizes that %1 is a number even if its an empty space.

MUSHclient
It ignores the command all together if I type heal without an argument also and it works if its a character but not
when it's a blank space. So I used "heal*" to fix the ignoring script part and now it just gives me an error when I type heal by itself. I removed the if statement if %1 > 0
and i get this error when typing heal by itself.


[string "Alias: "]:2: unexpected symbol near 'do'


So The Above works accept it doesn't work when I just type heal and leave * null. Is there a better way to do what I am trying to do without sending me an error message when I type heal with a null %1 character?
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Fri 22 Jul 2011 11:26 AM (UTC)

Amended on Fri 22 Jul 2011 11:27 AM (UTC) by Nick Gammon

Message
Errigour said:

I used the code above and when I just type heal it would send
heal to to mud instead of sending Note("heal").


I expect that because your alias matches: heal<space><something> and typing "heal" does not have a space.

Errigour said:

... if I typed heal with a space "heal " or "heal " it sends an error message my way.


I expect that too. It replaces %1 by whatever you had after the space. So if there is nothing after the space it will have given you:


 if > 0 then
    for i = 1, do
    Send("heal heal")
    end
  end


You really need to convert %1 to a number while it is in quotes. eg.


local count = tonumber ("%1")

if count then  -- that is, if it is a number
    for i = 1, count do
      Send("heal heal")
    end
else
  Note ("heal")
end -- if


Also:

Template:faq=50 Please read the MUSHclient FAQ - point 50.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Errigour   USA  (32 posts)  [Biography] bio
Date Reply #8 on Fri 22 Jul 2011 12:22 PM (UTC)
Message
Thanks I wanted to intercept Null commands from the mud
itself so that help big time and also regular that regular
expression forum helped some.

Can I ask you if there is a way to configure mush client to not ignore aliases such as "heal *" when I only type "heal"
by itself.
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #9 on Sat 23 Jul 2011 12:15 AM (UTC)
Message
Yes, the FAQ point 50 describes exactly that.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


23,113 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]