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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Send variable to world?

Send variable to world?

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


Posted by Grug   (15 posts)  [Biography] bio
Date Mon 18 Aug 2014 12:45 AM (UTC)
Message
Hey!

I really need an alias to send a variable to the world.

For example "varname" contains "1234". You type "var" and it sends to the world "say 1234" using the value from said variable.

Thanks!
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Mon 18 Aug 2014 04:14 AM (UTC)
Message
Check "expand variables" and put a "@" in front of the variable name, eg.


<aliases>
  <alias
   match="var"
   enabled="y"
   expand_variables="y"
   sequence="100"
  >
  <send>say @varname</send>
  </alias>
</aliases>


Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.

- Nick Gammon

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

Posted by Grug   (15 posts)  [Biography] bio
Date Reply #2 on Mon 18 Aug 2014 06:45 AM (UTC)

Amended on Mon 18 Aug 2014 09:03 AM (UTC) by Grug

Message
Oooh, thank you for the reply. That is easy.

Now what if I want to add two zeroes at the end of the value? As in, if the variable is 1234, it says 123400.

Right now I'm achieving this by adding another variable that is set to 00 in the end.

So that it does "say @varname@varname2"

I'm sure there's a cleaner way. :)
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Mon 18 Aug 2014 08:29 AM (UTC)
Message
This is a job for scripting ...


<aliases>
  <alias
   match="var"
   enabled="y"
   expand_variables="y"
   send_to="12"
   sequence="100"
  >
  <send>Send ("say @varname" .. "00")</send>
  </alias>
</aliases>

- Nick Gammon

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

Posted by Grug   (15 posts)  [Biography] bio
Date Reply #4 on Mon 18 Aug 2014 09:09 AM (UTC)

Amended on Mon 18 Aug 2014 09:10 AM (UTC) by Grug

Message
Thanks again.

However in the meantime I've come across another thing.

I have this alias for editing variables:

SetVariable ("%1", (%2))
SetChanged (true)
Save("")


It works perfectly for numeric variables, but it doesn't let me set them as text. For example...

It lets me set the variable as 123.

It does not let me set the variable as abc, saying:

Quote:
[string "Alias: "]:1: bad argument #2 to 'SetVariable' (string expected, got nil)
stack traceback:
[C]: in function 'SetVariable'
[string "Alias: "]:1: in main chunk
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Mon 18 Aug 2014 07:47 PM (UTC)
Message
Template:faq=32 Please read the MUSHclient FAQ - point 32.

- Nick Gammon

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

Posted by Grug   (15 posts)  [Biography] bio
Date Reply #6 on Mon 15 Sep 2014 02:53 PM (UTC)

Amended on Mon 15 Sep 2014 02:54 PM (UTC) by Grug

Message
Alright, well everything works great now, thank you.

I have other questions though, so I'll just keep using this thread, that way there is less clutter.

A long time ago when I used to mud a lot, I made this alias for toggling individual triggers on/off:


<aliases>
  <alias
   name="ToggleTrigger"
   match="tt *"
   enabled="y"
   group="Scriptery"
   send_to="12"
   ignore_case="y"
   sequence="100"
  >
  <send>
EnableTrigger ("%1", (GetTriggerOption("%1", "enabled")+1)%%2)
ColourNote ("sienna", "black", "%1 trigger is enabled: " .. tostring(GetTriggerOption("%1", "enabled") == 1))
</send>
  </alias>
</aliases>



Unfortunately I forgot some of the scripting things I used to know, so I have a the following question...

Can the same be done to toggle groups on/off?
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Mon 15 Sep 2014 07:49 PM (UTC)
Message
I seem to recall this question from ages ago. The simple answer is "no", because a group is just a collection of things. If you disable a group, possibly one item in the group might become enabled later, so now some are disabled and some not.

However you can always make your own variable, eg. "tank_group_enabled". Check that (and toggle it) and then disable or enable the "tank_group" depending on the new setting of the variable.

- Nick Gammon

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

Posted by Grug   (15 posts)  [Biography] bio
Date Reply #8 on Wed 17 Sep 2014 09:32 PM (UTC)
Message
Aha! I understand now and see what you mean.

As always thanks for the reply! You rock.
[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.


21,931 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]