coldmud-0.10.doc.QuickRef.gz
snippets · 3.2 KB · 2010-03-30
ColdMUD 0.10.3 Quick Reference Guide, including ColdMUD to MOO translations (8/31/94).
Download « Back to the snippets list
ColdMUD v0.10.3 Quick Reference Guide
=====================================
Last updated 8/31/94. Comments to jpl3@access.digex.net.
ColdMUD to MOO translations
---------------------------
object method verb (but not callable from command line)
object parameter property
Tokens
------
{ } [ ] #[ %[ ( ) (| |) (> <) .. ; , = !
- + / % == != > >= < <= . || && ? | : @
Reserved words
--------------
var if else while for switch case default break continue return
catch any with handler pass to in *fork *atomic *non_atomic
(* = reserved for future use)
Method Structure
----------------
disallow_overrides;
arg ARG1, ARG2, ..., [REST];
var VAR1, VAR2, ...;
STATEMENT1
STATEMENT2
.
.
.
Statements
----------
Comment // This is a comment.
Simple statment EXPRESSION;
Assignment VARIABLE = EXPRESSION;
Block { STATEMENT1 STATEMENT2 ... }
Return a value return EXPRESSION;
Conditional if (EXPRESSION) STATEMENT
Conditional/Else if (EXPRESSION) TRUE-STATEMENT else FALSE-STATEMENT
Iteration (list) for VARIABLE in (LIST) STATEMENT
Iteration (range) for VARIABLE in [LOWER .. UPPER] STATEMENT
Iteration while true while (EXPRESSION) STATEMENT
Break an iteration break;
To next iteration continue;
Test multiple conditions:
switch (CONTROLLING-EXPRESSION) {
case EXPR-OR-RANGE, EXPR-OR-RANGE, ...:
STATEMENTS
case EXPR-OR-RANGE, EXPR-OR-RANGE, ...:
STATEMENTS
.
.
.
default:
DEFAULT-STATEMENT
}
Error handling:
catch ERROR CODE, ERROR CODE, ...
BODY-STATEMENT
with handler
HANDLER-STATEMENT
Data types
----------
Integer 101
String "This is a string."
Dbref #10
List [1, ["foo", 'bar], #23]
Symbol 'object
Error type ~perm
Frob <#73, [1, 2]>
Dictionary #[["foo", 3], ["bar", 'baz]]
Buffer %[65, 66, 67, 10]
Name $root
Operators by precedence
-----------------------
.
[]
! and unary - Logical not, negation
/ % Division, modulus
+ - Addition, subtraction
== != > >= < <= Logical comparisons
in Find element in a list
&& Logical AND
|| Logical OR
?| Conditional operator (EXPR ? TRUE | FALSE)
(All operators associate from left to right except the `&&', `||',
and `?|' operators, which associate from right to left.)
@ 'Splice' a list
Error-Handling Expressions
--------------------------
(| EXPRESSION |) Ignore errors in EXPRESSION, value equals error code
(> EXPRESSION <) Propagate errors to calling routine (If an unhandled
error occurs in EXPRESSION, it will propagate to
calling routine as itself, instead of as ~methoderr)
Data Functions: Operations on data in general
---------------------------------------------
todbref(number) Convert an integer or string to a dbref
toerr(string) Convert a string to an error code
toint(data) Convert a string or dbref to an integer
toliteral(data) Convert any data to a literal
tostr(data) Convert any data to a string
tosym(string) Convert a string to a symbol
type(data) Retrieve the type of a piece of data:
'integer 'string 'dbref
'list 'symbol 'error
'dictionary 'buffer
valid(data) Check if data is a valid dbref
String Functions: Operations on strings
---------------------------------------
crypt(string, [salt]) Perform one-way encryption on a string
explode(string, [sep, [blanks]]) Get a list of words in a string
lowercase(string) Convert a string to lowercase
match_begin(string, search, [sep]) Match against the beginnings of words
match_pattern(pattern, string) Match against a wildcard pattern
match_regexp(regexp, string, [case]) Match against a regular expression
match_template(template, string) Match against a command template
pad(string, length, [filler]) Pad a string to a given length
strcmp(string1, string2) Case-sensitive comparison of strings
strlen(string) Get the length of a string
strsub(string, search, replace) Substitute text within a string
substr(string, start, [length]) Get a substring of a string
uppercase(string) Convert a string to uppercase
List Functions: Operations on lists
-----------------------------------
delete(list, pos) Delete an element of a list
insert(list, pos, data) Insert an element in a list
listlen(list) Get the length of a list
replace(list, pos, data) Replace an element in a list
setadd(list, data) Add an element to a "set"
setremove(list, data) Remove an element from a "set"
sublist(list, start, [len]) Get a sublist of a list
union(list1, list2) Return union of two lists
Dictionary Functions: Operations on dictionaries
------------------------------------------------
dict_add(dict, key, value) Add an association to a dictionary
dict_add_elem(dict, key, elem) Add an element to a list value
dict_contains(dict, key) Determine if a key is in a dictionary
dict_del(dict, key) Delete an association to a dictionary
dict_del_elem(dict, key, elem) Remove an element from a list value
dict_keys(dict) Get a list of keys in a dictionary
Buffer Functions: Operations on buffers
---------------------------------------
buffer_add(buffer, byte) Add a byte value to the end of a buffer
buffer_append(buffer1, buffer2) Append two buffers together
buffer_from_strings(strings, [term]) Convert a list of strings into a buffer
buffer_len(buffer) Get the length of a buffer
buffer_replace(buffer, pos, value) Replace a byte value in a buffer
buffer_retrieve(buffer, pos) Retrieve a byte value from a buffer
buffer_to_strings(buffer, [sep]) Convert a buffer to a list of strings
buffer_truncate(buffer, length) Truncate a buffer to a length
Method Functions: Information about the current method
------------------------------------------------------
caller() The definer of the calling method
definer() The definer of the current method
sender() The sending object
task_id() ID of the current task
this() The current object
Error Functions: Handling errors
--------------------------------
error() Get the error code, in a handler
error_arg() Get the error argument, in a handler
error_str() Get the error explanation, in a handler
rethrow(code) Continue propagating an error
throw(code, explanation, [arg]) Throw an error in the calling method
traceback() Get the traceback, in a handler
Communication Functions: Communicating with the user
----------------------------------------------------
disconnect() Close connections to the current object
echo(buffer) Echo text to the current object
echo_file(filename) Echo a file to the current object
Object Functions: Operations on the current object
--------------------------------------------------
add_parameter(name) Add a parameter
ancestors() Get a list of ancestors
children() Get a list of children dbrefs
compile(code, name) Compile `C--' code into a method
del_method(name) Remove a method
del_parameter(name) Remove a parameter
find_method(name) Find location of method definition
find_next_method(name, after) Find location of next definition
get_var(name) Get value of a variable
list_method(name,[indent, [paren]]) Decompile method into `C--' code
methods() Get a list of defined method names
parameters() Get a list of parameter names
parents() Get a list of parent dbrefs
set_var(name, data) Assign to a variable
Administrative Functions: Privileged operations (callable from $sys only)
-------------------------------------------------------------------------
binary_dump() Bring binary database up to date
bind(port, receiver) Begin listening on a port
chparents(dbref, parents) Change parents of an object
conn_assign(dbref) Set the current connection's object
connect(addr, port, receiver) Connect to a remote server
create(dbref, parents) Create an object
data(dbref) Getting the data on an object
destroy(dbref) Destroy an object
log(string) Write a string to stderr
run_script(string, args, [bg]) Execute an administrative script
set_heartbeat_freq(seconds) Set the heartbeat frequency
shutdown() Shut down the server
text_dump() Dump a text database image
unbind(port) Stop listening on a port
Miscellaneous Functions: Miscellaneous operations
-------------------------------------------------
abs(number) Take the absolute value of a number
ctime([time]) Convert the time to string format
max(val1, val2, ...) Find the maximum of several values
min(val1, val2, ...) Find the minimum of several values
random(max) Get a random number
time() Get the current time
version() Get the server version number