English
Chinese
  yTin Online Help  

  Home (english) | Home (chinese) | Downloads | Sample scripts | Online help | Utilities | FAQs | Discussions/Messages | Mud&links | My Progs | Mirrors |
var

format:            #variable {} {}

There are a few kind of variables for your convenience:
default variable _: it is used to hold some return values of function like
      commands. Example: #strlen {abcd}, after that, $_ is 4.
local variables:   regular variables that does not begin with _. (exception:
      default variable _ is local variable.)   example: $v1, $v2{$u}, ${Tom Clap}
global variables: variables that begin with _ and longer than 1.
      Example: _id is shared by all sessions in the same yTin window. It is
      useful to pass variables between sessions and/or keep variable when one
      session died.
pseudo/system variables:
      _random: a random number from 0-MAXRANDOM.
      _clock:   time in seconds since Jan 1, 1970.
      _time/time:   time in seconds, since this copy of yTin started running.
      _msec:   time in milli-seconds, since this copy of yTin started running.
      HOME:      the $HOME environment under Unix/Windows
   The reason call it pseudo variable is: #variable command does not show it correctly, and you cannot overwrite the value. Whenever this variable get parsed, it will be the system value. For example, "#var HOME" does not show there is a variable "HOME", while "#showme $HOME" will show the correct value.

Since these are completely new to tintin, and act differently
than anything else, I feel should spend some time on them.
These variables differ from the %0-9 in the fact that you could
specify a full word as a variable name, and they stay in memory for
the full session, unless they are changed, and they can be saved in
the coms file, and can be set to different values if you have 2 or
more sessions running at the same time.   One of the best uses for
variables I think is for spellcasters.

Currently, you would set up a bunch of aliases like the following.

#alias {flame} {cast 'flame strike' %0}
#alias {flash} {cast 'call lightning' %0}
#alias {harm} {cast 'harm' %0}

With the new variables you can do the following:

#alias {targ} {#var target %0}
#alias {flamet} {flame $target}
#alias {flasht} {flash $target}
#alias {harmt} {harm $target}

these aliases will be   defined just as they are written, the variables
are not substituted   for until the   alias is found   in your input   and
executed.

so, if before a battle, you do a:
targ donjonkeeper
then $target is set to donjonkeeper, and any alias you set up with
$target in it will substitute donjonkeeper for every instance of
$target.   Let's say your leader has the following alias set up.

#alias {setttarg} {#var {target} {%0};gt target=%0}

if he did a settarg lich, it would set his $target to lich, and
would send a:

tells your group 'target=lich'

you could then set an action like so.

#action {^%0 tells your group 'target=%1'} {targ %1}

then when your leader executed his alias, it would also set your
variable to the target.

Another use for variables would be to set a variable $buffer to
whoever the current buffer is.   This would be useful in fights
where the mob switches, or where many rescues are needed.   You
could set up healing aliases with $buffer in them, and set the
$buffer variable in an action that is triggered by each switch,
and each rescue, or just rescues, or whatever.   Then in a
confusing battle, you will have a better shot at healing the
right person.

See also: #math, #var2alias, #unvariable