Send variable to world?

Posted by Grug on Mon 18 Aug 2014 12:45 AM — 9 posts, 34,472 views.

#0
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!
Australia Forum Administrator #1
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.
#2
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. :)
Amended on Mon 18 Aug 2014 09:03 AM by Grug
Australia Forum Administrator #3
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>
#4
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
Amended on Mon 18 Aug 2014 09:10 AM by Grug
Australia Forum Administrator #5
Template:faq=32
Please read the MUSHclient FAQ - point 32.
#6
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?
Amended on Mon 15 Sep 2014 02:54 PM by Grug
Australia Forum Administrator #7
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.
#8
Aha! I understand now and see what you mean.

As always thanks for the reply! You rock.