SCRIPT COMMANDS: Difference between revisions

From AddictHelp
Jump to navigation Jump to search
Kahlan (talk | contribs)
New page: Built-in script commands are commands that are not called the way normal player commds are called. The commands below are valid in all types of scripts: A. Comment ---------- * <text> A...
 
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Built-in script commands are commands that are not called the way normal
Built-in script commands are commands that are not called the way normal player commds are called.  The commands below are valid in all types of scripts:
player commds are called.  The commands below are valid in all types of
scripts:


A. Comment
==Comment==
----------
An '*' at the beginning of a line is a comment.  The rest of the line is ignored.
* <text>


An '*' at the begining of a line is a comment.  The rest of the line is
* <text>
ignored.


B. Global
==Global==
---------
global <variable>


Global changes a local variable into a global variable.
Global changes a local variable into a global variable.


C. Eval
global <variable>
-------
eval <variable> <value>


Eval evaluates the value and sets variable to result.  See section 7 for
==Eval==
details on how expression evaluation works.
Example:  eval foobar 15 - 5
  sets the varable foobar to the value 10


D. If/elseif/else/end
Eval evaluates the value and sets variable to result. See section 7 for details on how expression evaluation works.
---------------------
if (<expression>)
  ...
elseif (<expression>)
  ...
else
  ...
end


An 'if' must occur before the other three. If the expression evaluates to
  eval <variable> <value>
true (see section 7 for expression evaluation), the statments between the
if statement and the next elseif, else, or end are executed.  If it
stopped at a elseif or else, it scans for the next end, and continues
execution at that point.  If the expression evaluated to false, it
searches for the next elseif, else, or end.  If it finds an elseif, it
checks that expression.  If it is true, it executes the statements between
the elseif and the next elseif, else, or end, and then finds the end of
the block.  If it is false, it continues searching in the same pattern,
until a true elseif is found, an else is found, or an end is found.


E. Halt
Example
-------
eval foobar 15 - 5
halt
 
sets the variable foobar to the value 10
 
==If/elseif/else/end==
 
An 'if' must occur before the other three.  If the expression evaluates to true (see section 7 for expression evaluation), the statements between the if statement and the next elseif, else, or end are executed.  If it stopped at a elseif or else, it scans for the next end, and continues execution at that point.  If the expression evaluated to false, it searches for the next elseif, else, or end.  If it finds an elseif, it checks that expression.  If it is true, it executes the statements between the elseif and the next elseif, else, or end, and then finds the end of the block.  If it is false, it continues searching in the same pattern, until a true elseif is found, an else is found, or an end is found.
 
if (<expression>)
    ...
elseif (<expression>)
    ...
else
    ...
end
 
==Halt==


Halt ends the script execution.
Halt ends the script execution.


F. Return
halt
---------
 
return <value>
==Return==
 
Return sets the return value of the script.  Normally, a script will return 1, unless another return value is specified with the return command.  Unlike most computer languages, the return command does not end the script's execution.  The value is returned after all the commands have been executed, or a wait or halt command is called.


Return sets the return value of the script.  Normally, a script will return
  return <value>
1, unless another return value is specified with the return command.  
Unlike most computer langauges, the return command does not end the
script's execution.  The value is returned after all the commands have
been executed, or a wait or halt command is called.


G. Set
==Set==
------
set <variable> <value>


Set sets the variable to value, without evaluating it.
Set sets the variable to value, without evaluating it.
Example:  set foobar 15 - 5
  sets the varable foobar to the string "15 - 5"


set <variable> <value>
Example
set foobar 15 - 5


H. Unset
sets the varable foobar to the string "15 - 5"
--------
 
unset <variable>
==Unset==


Unset elimiates the specified variable if it exists.
Unset elimiates the specified variable if it exists.


I. Wait
unset <variable>
-------
wait <number of seconds>


A 'wait' command causes the script to pause for a certain length of time.
== Wait==
A numerical argument causes the script to pause the given number of
seconds.


wait <number of ticks>t
A 'wait' command causes the script to pause for a certain length of time.  A numerical argument causes the script to pause the given number of seconds.


This causes the script to pause for 75 seconds per number of ticks.
wait <number of seconds>
(This does not cause it to trigger exactly when a tick happens.  This is a
throwback to before ticks were eactly counted with the event system).


H. log
You can also try
--------
 
log <somestring>
wait <number of ticks>t
 
This causes the script to pause for 75 seconds per number of ticks.  (This does not cause it to trigger exactly when a tick happens.  This is a throwback to before ticks were exactly counted with the event system and is now little more than abbreviation for x*75).
 
==log==


Sends the string to syslog.  The log saves to file, is logged under  
Sends the string to syslog.  The log saves to file, is logged under  
"syslog normal" at level AVATAR.
"syslog normal" at level AVATAR.
log <somestring>


You can log values.  I.e.
You can log values.  I.e.


log The characters name is %actor.name%.
log The characters name is %actor.name%.


That will syslog "The characters name is John."
That will syslog "The characters name is John."


==switch==


I. switch
A switch/case block is a fairly well known method of programming.
---------
switch <statement>
  case <instance>
    ...
    break
  case <instance>
  case <instance>
    ...
    break
  default
    ...
done


A switch/case block is a fairly well known method of programming.
TODO: more detailed explaination to be added.
TODO: more detailed explaination to be added.


J. while
switch <statement>
--------
  case <instance>
while (%x% < 5)
    ...
  eval x (%x% + 1)
    break
  if (%x% == 2)
  case <instance>
    if (yet something else again)
  case <instance>
      break
    ...
    end
    break
  end
  default
done
    ...
done
 
==while==


A while loop cannot exist in another while loop.  It will just cause
A while loop cannot exist in another while loop (nested loops).  It will just cause
problems, and generally break the script.
problems, and generally break the script.


SEE ALSO:  MOBCMDS, OBJCMDS, ROOMCMDS, VARIABLES
while (%x% < 5)
  eval x (%x% + 1)
  if (%x% == 2)
    if (yet something else again)
      break
    end
  end
done
 
 
SEE ALSO:  [[MOBCMDS]], [[OBJCMDS]], [[ROOMCMDS]], [[VARIABLES]]
 
[[CATEGORY:Scripts]]

Latest revision as of 13:24, 23 September 2011

Built-in script commands are commands that are not called the way normal player commds are called. The commands below are valid in all types of scripts:

Comment

An '*' at the beginning of a line is a comment. The rest of the line is ignored.

* <text>

Global

Global changes a local variable into a global variable.

global <variable>

Eval

Eval evaluates the value and sets variable to result. See section 7 for details on how expression evaluation works.

eval <variable> <value>

Example

eval foobar 15 - 5

sets the variable foobar to the value 10

If/elseif/else/end

An 'if' must occur before the other three. If the expression evaluates to true (see section 7 for expression evaluation), the statements between the if statement and the next elseif, else, or end are executed. If it stopped at a elseif or else, it scans for the next end, and continues execution at that point. If the expression evaluated to false, it searches for the next elseif, else, or end. If it finds an elseif, it checks that expression. If it is true, it executes the statements between the elseif and the next elseif, else, or end, and then finds the end of the block. If it is false, it continues searching in the same pattern, until a true elseif is found, an else is found, or an end is found.

if (<expression>)
   ...
elseif (<expression>)
   ...
else
   ...
end

Halt

Halt ends the script execution.

halt

Return

Return sets the return value of the script. Normally, a script will return 1, unless another return value is specified with the return command. Unlike most computer languages, the return command does not end the script's execution. The value is returned after all the commands have been executed, or a wait or halt command is called.

return <value>

Set

Set sets the variable to value, without evaluating it.

set <variable> <value>

Example

set foobar 15 - 5

sets the varable foobar to the string "15 - 5"

Unset

Unset elimiates the specified variable if it exists.

unset <variable>

Wait

A 'wait' command causes the script to pause for a certain length of time. A numerical argument causes the script to pause the given number of seconds.

wait <number of seconds>

You can also try

wait <number of ticks>t

This causes the script to pause for 75 seconds per number of ticks. (This does not cause it to trigger exactly when a tick happens. This is a throwback to before ticks were exactly counted with the event system and is now little more than abbreviation for x*75).

log

Sends the string to syslog. The log saves to file, is logged under "syslog normal" at level AVATAR.

log <somestring>

You can log values. I.e.

log The characters name is %actor.name%.

That will syslog "The characters name is John."

switch

A switch/case block is a fairly well known method of programming.

TODO: more detailed explaination to be added.

switch <statement>
  case <instance>
    ...
    break
  case <instance>
  case <instance>
    ...
    break
  default
    ...
done

while

A while loop cannot exist in another while loop (nested loops). It will just cause problems, and generally break the script.

while (%x% < 5)
  eval x (%x% + 1)
  if (%x% == 2)
    if (yet something else again)
      break
    end
  end
done


SEE ALSO: MOBCMDS, OBJCMDS, ROOMCMDS, VARIABLES