Reference - all global ARC functions, all ARC concepts
- Definitions
- Global functions
- Per-category list
- int abs(int n)
- void add(mixed[] list, mixed element)
- void addFine(string player, int amount, string reason)
- int atoi(string s)
- string capitalize(string s)
- bool chance(int percent)
- string charAt(string s, int n)
- string chr(int n)
- string comma(int n)
- bool contains (mixed[] list, mixed element)
- int dice(int count, int size)
- die(string s)
- int direction_lookup(string dirname)
- string direction_name(int direction)
- string direction_pretty_name(int direction)
- int direction_reverse(int direction)
- string direction_reverse_name(int direction)
- string drunkString(string text)
- bool endsWith(string a, string b)
- string estimateNumber(int number,int error)
- string format(...)
- string indefinite(string noun)
- int indexOf(string a, string b)
- bool isBlacklisted(string name)
- bool isName(string word, string wordlist)
- bool isFullName(string word, string wordlist)
- bool isNameMultiple(string wanted, string given)
- bool isSoundexName(string word, string wordlist)
- string legalName(string name, bool relaxed)
- int len(string s)
- int len(mixed[] list)
- lenNoColor(string s)
- void makeNote(string board_name, string sender, string to_list, string subject, int expire_days, string text)
- int max(...)
- int min(...)
- string numberToMagicName(int n)
- string numberToWord(int n)
- string numberToWordOnce(int n)
- string one_argument(string s, string ref arg)
- int ord(string s)
- strings percentColor(int current, int max)
- int pow(int n, int m)
- int random(int min,int max)
- string randomName()
- int range(int min, int num, int max)
- bool replace(string ref s, string from, string to)
- bool regreplace(string ref s, string from, string to)
- int regreplace(string s, string search)
- string repeatString(string rep, int count)
- bool remove(mixed[] list, mixed element)
- mixed[] slice(mixed[] list, int start, int len)
- string[] split(string s, string delimeter)
- string[] splitOnce(string s, string delimeter)
- string[] splitWords(string s)
- string soundex(string s)
- bool startsWith(string a, string b)
- string substring(string s,int start,int len)
- int sqrt(int n)
- string toLowerCase(string s)
- string toUpperCase(string s)
- void trimSpaces(string ref s)
- string wordAt(string s, int n)
- int words(string s)
- string wordWrap(string s, int n)
- string wordWrapIndent(string s, int n, int indent, int offset)
- void writeBug(string s)
- void writeLog(string s)
- void writeOtherLog(string logfile, string s)
- Language concepts
Most of the builtin functions can be called as normal functions, e.g. len which takes a string
parameter can be called as len(somestring).
However, if somestring is a variable it is preferred to call the function as a member function. As a rule, you can
instead of typing function(variable) write variable.function() - if the variable is really a variable and
not a constant string (e.g. you cannot say "42".len()).
Returns the absolute value of the integer n. I.e. if n is positive, it is returned as is. If it was negative, the
sign is removed
int n = abs(-4); // n = 4
int m = abs(0); // n = 0
int o = abs(666); // n = 666
|
Adds a new element to the list list, at the very end of it. The type of element must match the type of list.
string[] list;
list.add("foobar"); // OK, list now contains "foobar"
list.add(1); // error, it's a string list!
|
Adds a fine to player specified by name (player). If the player is online, the money is deducted from their bank
account immediately. If not, a note is sent to them, saying that the money has been deducted. Note that you should
terminate the reason with a newline.
addFine("Drylock", 5000, "5000 gold has been deducted from your account because I felt like it.
");
|
Converts the string s into a number. Returns 0 in case of an error. This function also understands the "advanced"
numbers (i.e. 200k for 200000).
string s = "666";
int n = atoi(s); // n has now the value 666
|
Makes the first non-color letter into a capital letter and returns the modified string. The rest of the string
is unaffected.
string s = "&rgem of fire&*";
string t = s.capitalize(); // t now contains "&rGem of fire&*"
|
Has a percent chance of returning true.
if (chance(50)) // do something 50% of the time
|
Returns the n-th character of string s. If n is beyond the length of the string, an empty string ("") is
returned. The first character in the string has number 0.
If n is negative, the abs(n)th character is returned (i.e. if n is -1, the last character is returned).
string s = "123456";
string t = s.charAt(1); // t contains "2"
string q = s.charAt(-2); // t contains "5"
|
Returns a string containing a single character, the value of which is the letter with the ASCII number n. The letter
'b' for example has the ASCII value 98:
string s = chr(98); // s contains "b"
|
Commatizes(!) the number (i.e. inserts a , between every 3 digits of the number). The same effect can be gained by using
the , formatting character.
Returns true if the list contains the specified element. Please note that this compares every element in turn,
and will be slow if there are many elements: if you need to search for things in a list a lot, you should use a map.
Rolls count dice, each with size eyes.
int strength = dice(3,6); // rols 3 6-sided dice, for a result of 3 to 18
|
Exits the current thread of execution (i.e. not only the current function, but all the functions below it until
control is returned to C++ code). Typically used if your code has detected some abnormal condition which just shouldn't
hapen and that you cannot handle. It is preferrable to throw an exception instead.
die ("This shouldn't happen");
|
Returns the direction number for this direction, or -1 if this direction does not exist. North is 0.
Returns the direction name (i.e. "north", "south" etc.) for this direction. North is 0.
Returns e.g. "to the south" given integer direction.
Returns the reverse direction (i.e. if given north(0) returns south(2)).
Returns the reverse direction name (i.e. if given north(0) returns "south").
Drunkifies the text.
Returns true if string a ends with string b. This is a case insensitive comparison.
string s = "Hello world";
bool b1 = s.endsWith("world"); // b1 is true
bool b2 = s.endsWith("Hello"); // b2 is false
|
Estimate the number with the given error. Nemon knows the exact meaning of error. Returns e.g.
"about 20".
Do not use. For internal ARC use only. This is the function called to format a string containg variables.
Returns the indefinite article which fits noun (which is assumed to be singular(?)).
string s = indefinite("sword"); // "a"
string t = indefinite("elf"); // "an"
|
Finds the position of string b within string a. Returns offset from the beginning of string, starting at 0. If
string b was not found, returns -1.
string a = "Hello world";
string b = "world";
int n = a.indexOf(b); // n now equals 6
|
Returns true if name is on the list of blacklisted names (using the BLIST command).
Returns true if word is one of the keywords in the wordlist. This uses abbreviations, so that e.g. "a"
will be one of hte keyword in the list of "anvil heavy iron".
Returns true if word is one of the keywords in the wordlist. Unlink isName, it does not allow
for abbreviations
Checks if the name list wanted has all of its keyword inside the namelist given. E.g. matching
"sword steel" with "steel sword blue" would work, but "sword red" would not.
As isFullName, but translates both words and wordlist into soundex names first.
Returns why this name would be illegal, or an empty string otherwise. If relaxed is true, it will relax a bit.
The relaxed setting is used for OOC character names.
Calculates the length of string s.
string s = "foobar";
int n = len(s); // n has the value 6
int m = s.len(); // n has the value 6
|
Finds the number of elements inside the list list.
string[] list;
list.add("test");
int n = list.len(); // n has the value 1
|
Calculates the length of the string s, but does not include the color codes in calculation.
string s = "&rred&*";
int n = s.lenNoColor(); // s = 3
|
Sends a noote to to_list on board board_name. From is set to sender and the body of the message contains text.
The note expires in expire_days days. Remember to put a newline at the end of the text (but not any of the other
fields).
makeNote("Personal", "Birthday Daemon", "$BirthdayBoyOrGirl",
"Happy Birthday!", 14, "Happy Birthday, $BirthdayBoyOrGirl!");
|
Returns the largest of any amount of integers.
int n = max(1,5,2,-6,5); // n is 5
int m = max(1,-99); // n is 1
|
Returns the smaller of any number of integers.
int n = min(1,5,2,-6,5); // n is -6
int m = min(1,-99); // n is -99
|
Converts integer n to a string of nonsense, but pronouncable characters. This string is built from a certain set
of rules and will be longer the higher the number n is. This is useful for e.g. automatically generating passwords.
The same number will always result in the same string. The number will have log16 2-character syllables (i.e. magic
numbers 0-15 have two letters, 16-256 4, 257-4096 6 etc.)
string s = numberToMagicName(random(1000,10000)); // Come up with some fairly long name
|
Converts number to the word representing that number (i.e. 12 becomes "twelfe").
Converts e.g. 12 to "twelve times", 1 to "once".
Finds the first argument (word delimtered by spaces or multiple words surrounded by quotes) in s. This argument is
then put into arg - note that this string is passed by reference so it will be modified by the function.
What is left in the original string is returned.
This function is central to processing arguments entered by users.
string s = "put sword bag";
string arg;
// Typically, one assigns the changed string back to the argument list
s = one_argument(s, arg);
// arg now contains "put"
// one_argument returned (and we assigned to s) "sword bag"
s = one_argument(s, arg);
// arg now contains "sword"
// s contains "bag"
|
Returns the ordinal value of the first character in the string s. This is the ASCII value of the character; for example
space has the value 32.
int n = ord("a"); // n has the value 97
|
Returns a color code which is used usually for colorizing hitpoints. It calculates (current/max) * 100 - if
this value is really low, the color is red, etc.
Returns the integer n lifted to the m-th power, i.e. multipled by itsemf m times.
int n = pow(2,10); // n = 1024
|
Returns a random number within this range (both numbers included)
int n = random(1,100); // n can be anywhere from 1 to 100
|
Returns a random name. This words like the admin command makename.
Normalize num within the range min to max. In other words, if num was smaller than min, it will
become min. If it was larger than max, it will become max. Otherwise it is unaffected. The modified result
is returned.
int n = 600; // Something entered by the player
int x = range(100,n,200); // We only want numbers between 100 and 200
// x is now 200
|
Replaces all occurrances of from with to within the string s. Note that s is modified by this! Returns
true if anything was replaced. This is case insensitive.
string s = "Be Good";
s.replace("Good", "Bad"); // s = "Be Bad"
bool ok = s.replace("Good", "Bad"); // returns false since the string no longer is there
|
Replaces all occurrances of from with to within the string s. Note that s is modified by this! Returns
true if anything was replaced. This is case insensitive. This uses regular expressions and is much slower
than regular replace - use it only if you actually need the regular expression power
string s = "Testing";
s.regreplace("[ns]", "qq"); // s is now "Teqqtiqqg"
|
Does a regular expression search for the string search within s. Returns number of subexpressions
found, or 1 if no subexpression were supplied and the string was found. Returns 0 on failure.
Repeats string rep count times after each other.
Removes the object element from the list list. Returns true if the object was found and removed, and
false otherwise.
string[] list;
list.add("one"); list.add("two"); list.add("three");
bool b = list.contains("three"); // true
|
Takes a slice of length len starting at position start (first position is 0) out of the list given. Returned
is a new list with those elements.
Splits string s into strings that do not contain delimeter characters, and returns a list of those strings. Note
that unlike splitOnce, this function will condence multiple delimeter characters into one.
string s = "This is\na test\n"; // two lines, "This is" and "a test" - delimetered by \n
string[] lines = split(s, "\n"); // two elements in the array now, "This is" and "a test"
|
This works exactly as split, but in this case, multiple delimeters are NOT merged.
string s = "This is\n\na test\n"; // three lines, "This is", an empty line and "a test" - delimetered by \n
string[] lines = split(s, "\n"); // two elements in the array now, "This is" and "a test"
string[] lines2 = splitOnce(s, "\n"); // THREE elements in the array, "This is", "" and "a test"
|
Splits string into words. A word is non-whitespace delimetered by whitespace. However, you can put quotes around
a string of space/whitespace to force it to stick together.
Returns the soundex representation of string s. To see what soundex strings look like, try using the soundex
command on the MUD. The help system uses this to search for help topics that sound similar.
Returns true if string a starts with string b. This is a case insensitive comparison.
string s = "Hello world";
bool b1 = s.startsWith("world"); // b1 is false
bool b2 = s.startsWith("Hello"); // b2 is true
|
Extracts the substring starting at the character start and continuing for len characters from the string s.
If start is beyond the string's length, en empty string ("") is returned. If len is higher than the number of
characters beyond start, as many character as possible are returned. The first character in the string has position 0.
If start is negative, the count starts from the end of the string.
string s = "We are the world";
string t = s.substring(3,3); // t contains "are"
string q = s.substring(11,99); // q contains "world"
string u = s.substring(-2,2); // u contains "ld"
|
Calculates the square root of integer n. Since this does not deal with floating point, the result will not be very
precise.
int n = 100;
int m = sqrt(n); // m now holds the value 10
|
Changes all letters inside string s to lower case and returns the modified string. Note that color codes are not
affected.
string s = "&rSword of Truth&*";
string t = s.toLowerCase(); // t contains "&rsword of truth&*";
|
Changes all letters inside string s to UPPER case and returns the modified string. Note that color codes are not
affected.
string s = "&rSword of Fire&*";
string t = s.toUpperCase(); // t contains "&rSWORD OF FIRE&*";
|
Removes all leading and trailing spaces from the string s, modifying it.
string s = " just a test ";
s.trimSpaces(); // s is now "just a test"
|
Returns the n-th word of the string s. The first word has number 0. If there aren't that many words, an
empty string ("") is returned.
string s = "This is a test ";
string t = s.wordAt(1); // t contains "is"
|
Count the number of words (i.e. non-spaces delimetered by spaces) in string s. Several words inside "quotes" count
as a single word.
string s = "Count this 'long string'";
int n = s.words(); // n equals 3
|
Wordwrap string s to n columns.
Wordwrap string s to n columns. However, indent the first line by indent columns, and indent
the following lines by offset columns. Please note that this function uses a somewhat different algorithm
than wordWrap.
Write this message to the system log, but also send it over wiznet bug channel. Not for normal use.
Write this message to the system log. Not for normal use.
Write this message to auxiliary logfile logfile. This file is located in data/other-logs/. Not for normal use.
Return to the main page