Additions to Standard Lua
We have added a lot of useful classes to the stock Lua interpreter. The following is just a summary - the actual documentation for these functions, classes, and methods can be found in the API reference, which can be found inside the development environment.
Improvements to Math Library
We have added the following functions to the Lua math library:
- dcos - like cos, but the parameter is in degrees, not radians
- dsin - like sin, but the parameter is in degrees, not radians
- dsincos - returns both a sin and cos of an angle in degrees
- dtan - like tan, but the parameter is in degrees, not radians
- near - returns true if two numbers are almost exactly equal
- round - rounds a number naturally
Improvements to the String Library
We have added the following functions to the Lua string library:
- countlines - returns the number of lines in the string
- endswith - returns true if string ends with specified suffix
- explode - splits a string with a delimiter
- implode - merges an array of strings with a delimiter
- lstrip - strip whitespace from left end of string
- pad - pads a string out to a desired length
- partition - split a string at a given separator
- replace - search-and-replace a substring with a different substring
- reverse - reverses a string
- rstrip - strip whitespace from right end of string
- startswith - returns true if string starts with specified prefix
- splitlines - splits a string into multiple lines
- strip - strip whitespace from both ends of string
- tokenize - tokenizes a string
Improvements to the Table Library
We have added the following functions to the Lua table library:
- append - appends multiple arrays
- clear - clears out a table
- copy - makes a shallow copy of the table
- copyelts - copies selected fields from one table to another
- count - searches table for value and returns number of occurrences
- fill - fills an array with a specified initialization value
- makearray - creates a multidimensional array
- replace - searches and replaces in a table
- reverse - reverses the elements of an array
- search - searches the array for a given value
- sortedkeys - returns an array containing the keys in sorted order
- subrange - returns a subrange of an array
3D Math
We have added classes designed to help record positional and rotational data. These include:
- Vector is used for representing both Cartesian coordinates and directional vectors. It consists of three numbers usually called (X,Y,Z). It is also sometimes used to represent scaling factors.
- Rotation is used to record orientations and rotations. Since there are so many different ways to express the idea of rotation, there are a large number of different constructors for class Rotation.
- Transform is a small class with room to store one position-vector, one rotation, and one scale-vector. Together, these three things completely describe the location of an object.
Finally, there is a class Matrix which we ask that you not use - basically, we feel that if you need to use math which is that complex, then we're doing something wrong. However, we've included it just in case somebody needs it for something we didn't expect.
Coroutine Handling
Lua has a built-in class coroutine which does not include any sort of scheduling support. We have replaced this class with our own version, Coroutines, which is integrated with the system timer module.
The Module System
We have added a module system that allows you to load script files from the Wild Pockets file server. This is described in a previous chapter.
Class Definitions
We have added a module system that allows you to define your own classes. If you wish, you can still use Lua metamethods to create your own class system.
Abstract Data Types
Most modern programming languages provide a full library of abstract data types like hash tables, binary trees, stacks, queues, priority queues, and the like. Lua is one of the few languages in which the library is missing these fundamental structures (only hash tables and stacks are provided). This is one of the larger flaws in Lua.
We plan to remedy this by supplementing Lua with these core types. Currently, we have only implemented one: the double-ended queue (Deque). This can efficiently mimic a stack or a queue as well.
Things we Removed
We have removed a few things from the Lua interpreter, mostly for safety. These include:
- The io module is gone. A web-game shouldn't be able to delete your files.
- The lua module system is gone, replaced with one that downloads modules from the Wild Pockets file server.
- Printer-friendly version
- Login or register to post comments
-



