Functions in 0.99

Freeform discussion about anything related to modding Transcendence.
Post Reply
george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

This post contains a list of the new functions that I've already implemented in 0.99. I'll update this as more are implemented:

(filter list var exp) -> list
This function iterates over an input list and evaluates the given expression (binding the given variable to each list item). The resulting list omits items for which the expression evaluates to Nil.

Example:

Code: Select all

(filter '(1 2 3) i True) -> (1 2 3)
(filter '(1 2 3) i Nil) -> Nil [empty list]
(filter '(1 2 3) i (eq i 2)) -> (2)
(filter '(1 2 3) i (leq i 2)) -> (1 2)
(find source target) -> index of target in source (0-based)
If 'source' is a list, then we look for an item in the list that is equal to 'target' and return the item position. Otherwise, we assume that 'source' is a string and look for the substring 'target' in 'source' and return the character position. In either case, if we do not find anything, the function returns Nil.

Example:

Code: Select all

(find '(17 20 6 31) 6) -> 2
(find '(17 20 6 31) 571) -> Nil
(find "Sphinx of black quartz" "black") -> 10
(find '("red" "green" "blue" "yellow") "green") -> 1
(max x1 x2 ... xn) -> z
Return the highest number of a list of numbers.

Example:

Code: Select all

(max 4 70) -> 70
(max 10 17 81 7) -> 81
(max '(10 17 81 7)) -> 81
(min x1 x2 ... xn) -> z
Same as (max) but returns the smallest number in the list.

(objGetObjByID objID) -> obj
This is the reverse of (objGetID). To recap: an objID is a not the same as an object pointer. An objID is a globally unique identifier that is valid across systems and game saves. This new function converts from an objID to an object pointer (so that you can call other functions).

If the object is not in the current system or has been destroyed, (objGetObjByID) returns Nil.

(objGetID) is somewhat expensive (it does a linear search of all objects in the system).

(shuffle list) -> list
This function randomly shuffles the elements in the input list.

Example:

Code: Select all

(shuffle '(1 2 3 4 5 6 7)) -> (2 5 6 1 3 4 7)
(shuffle '(1 2 3 4 5 6 7)) -> (3 6 5 4 7 1 2)
(shuffle '(1 2 3 4 5 6 7)) -> (4 1 5 7 2 6 3)
Last edited by george moromisato on Thu May 29, 2008 4:30 am, edited 1 time in total.
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

filter looks very cool can be used to filter items by various static data and other functions.

also can you post in this thread when you update the first post?
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

eer not to bug you about this but do you plan on updating this or should we just wait for .99 to come out?
Crying is not a proper retort!
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

george moromisato wrote:This post contains a list of the new functions that I've already implemented in 0.99. I'll update this as more are implemented:
I think so, betel.
george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Added:

(find) to look for an item in the list
(min) and (max) to return the smallest and largest number in a list
(add) and (multiply) now take more than 2 parameters.
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

sounds cool thanks for the update :D
Crying is not a proper retort!
Post Reply