function list

This is a moderated forum that collects tutorials, guides, and references for creating Transcendence extensions and scripts.
Post Reply
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Name:
for

Syntax:
(for variable number number function)

Argument List:
variable: The storage for the counter. This will increase by one at the end of the function every time it is run.
number: The number that will be the initial value
number: The last number that the variable will be run as.
function: The function that will be run with all the different values or variable.

Returns:
Whatever the last run function in this returns.

Category:
iteration

Description:
Runs function using variable for every value between and including the two numbers.

Example:

Code: Select all

(block (sum)
	(setq sum 0)
	(for varies 3 8 (setq sum (add varies sum))) 
	)
This returns the number 33.

Comment:
Useful in many ways. From doing a function on only a certain section of a list to calculating math problems.
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

hmm what would be the best way of doing functions that accepts more than one kind of argument? Like geq accepts strings or numbers.
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Name:
geq

Syntax:
(geq expression expression)

Argument List:
expression: The first expression you want to compare.
expression: The second expression you want to compare.

Returns:
If the first number is greater or equal to than the second number returns True. If the first number is less than the second number returns Nil.
If the first string is greater or equal to than the second string returns True. If the first string is less than the second string returns Nil.
If the first list is greater or equal to than the list string returns True. If the first list is less than the second list returns Nil.
Otherwise returns Nil.

Category:
logical operator

Description:
It is greater or equal to. The same as >= in math. A string is greater if it is farther along in the dictionary, case is not taken into account.

Example:

Code: Select all

(geq 7 3)
Returns True.

Code: Select all

(geq "Betel" "Betelgeuse")
Returns Nil.

Code: Select all

(geq '(a a b) '(c d e))
Returns Nil.

Code: Select all

(geq "B" "b")
Returns True.

Comment:
I am not sure how lists are compared but other than that this is your standard comparison function.
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Name:
gr

Syntax:
(gr expression expression)

Argument List:
expression: The first expression you want to compare.
expression: The second expression you want to compare.

Returns:
If the first number is greater than the second number returns True. If the first number is less than or equal to the second number returns Nil.
If the first string is greater than the second string returns True. If the first string is less than or equal to the second string returns Nil.
If the first list is greater than the list string returns True. If the first list is less than or equal to the second list returns Nil.
Otherwise returns Nil.

Category:
logical operator

Description:
It is greater. The same as > in math. A string is greater if it is farther along in the dictionary, case is not taken into account.

Example:

Code: Select all

(gr 7 3)
Returns True.

Code: Select all

(gr "Betel" "Betelgeuse")
Returns Nil.

Code: Select all

(gr '(a a b) '(c d e))
Returns Nil.

Code: Select all

(gr "B" "b")
Returns Nil.

Comment:
I am not sure how lists are compared but other than that this is your standard comparison function. Oh and copy and paste are cool.
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Name:
isAtom

Syntax:
(isAtom expression)

Argument List:
expression: The thing you want to find out if it is an atom or not.

Returns:
True if the expression is an atom Nil otherwise.

Category:
atom, condition query

Description:
Returns True if the expression is an atom. A atom is Nil or anything that is not a list.

Example:

Code: Select all

(isAtom "Betel")
Returns true.

Code: Select all

(isAtom isAtom)
Returns true.

Code: Select all

(isAtom '(a))
Returns Nil.

Comment:
Useful in error checking.
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Name:
isfunction

Syntax:
(isfunction expression)

Argument List:
expression: The thing that that you want to check if it is a function or not.

Returns:
True if it is a function false otherwise.

Category:
function, condition query

Description:
Checks if something is a function or not and returns true if it is.

Example:

Code: Select all

(isfunction "Betel")
Returns Nil

Code: Select all

(isfunction isfunction)
Returns True

Comment:
Useful in error checking.
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Name:
isint

Syntax:
(isInt expression)

Argument List:
expression: The thing you want to check if it is a number.

Returns:
True if expression is a number Nil otherwise.

Category:
condition query

Description:
Checks to see if the expression is a number and if it is returns true otherwise returns Nil.

Example:

Code: Select all

(isInt "Betel")
Returns Nil.

Code: Select all

(isInt 45)
Returns True.

Comment:
Useful in error checking like all the condition query functions.
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Name:
item

Syntax:
(item List number)

Argument List:
List: the list from where you want to get an element from
number: where on the list you want to get the element from starting with 0

Returns:
If number is less than zero returns the first element. If the number is greater or equal than the lists count returns Nil. Otherwise the element at number starting from zero in list.

Category:
list

Description:
A function to return an element from a list. The first elements number is zero.

Example:

Code: Select all

(item '(a (b e) (c d) d) 2)
Returns (c d).

Code: Select all

(item '(a b c d) 0)
Returns a.

Code: Select all

(item '(a b c d) -1)
Returns a.

Code: Select all

(item '(a b c d) 4)
Returns Nil.

Comment:
Very important list function.
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Name:
list

Syntax:
(list [expression]^1)

Argument List:
expression: Something you want to be an element of the list.

Returns:
A list of the expressions.

Category:
list

Description:
Makes a list of the expressions in the order of the arguments.

Example:

Code: Select all

(list 1 2 3 4)
Returns the list (1 2 3 4)

Code: Select all

(block (vari)
	(setq vari 5)
	(list vari "list")
	)
Returns the list (5 list)

Comment:
A nice helpful function for making lists.
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Name:
lnkAppend

Syntax:
(lnkAppend list expression)

Argument List:
list: the list where you want to put the expression in the last element.
expression: The thing that you want to make the last element of the list.

Returns:
A list made up of the elements of the original list with a new element made up of expression last.

Category:
list

Description:
Makes a new list made up of elements of the list then the expression and returns it.

Example:

Code: Select all

(lnkAppend '(a b c) 2)
Returns the list (a b c 2)

Comment:
Very helpful in building lists in iteration functions.
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Name:
lnkRemove

Syntax:
(lnkRemove list number expression)

Argument List:
list: The list where you want to remove something from.
number: where in the list you want to remove from starting at 0.
expression: this has no effect on the function. Can someone find some the use for this?

Returns:
A new list without the element that was at number.

Category:
list

Description:
Removes the element at number and returns the resultant list.

Example:

Code: Select all

(lnkRemove '(a b c d) 2 Nil)
Returns the list (a b d)

Comment:
Another useful list function for the manipulation of lists and there elements. My first thought that was that expression was supposed to be a variable but that isn't the case.
Last edited by Betelgeuse on Fri Dec 14, 2007 1:00 pm, edited 1 time in total.
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Name:
lnkRemoveNil

Syntax:
(lnkRemoveNil list)

Argument List:
list: the list where you want to remove all the Nils.

Returns:
A list with all the elements that equal Nil removed.

Category:
list

Description:
Goes through the list and removes all the Nil elements and returns the result.

Example:

Code: Select all

(lnkRemoveNil '(a Nil (c Nil) Nil d))
Returns the list (a (c Nil) d).

Comment:
A bit of specific function. If you need it use it.
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Name:
lnkReplace

Syntax:
(lnkReplace list number expression)

Argument List:
list: The list in where you want to replace an element.
number: Where in the list you want to replace an element.
expression: What you want to replace the element with.

Returns:
A list with the element at number replaced with the expression.

Category:
list

Description:
Replaces a element at number and returns the resultant list.

Example:

Code: Select all

(lnkReplace '(a b c d) 2 'e)
Returns the list (a b e d)

Comment:
Very useful list function allowing you to change individual elements.
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Name:
itmAtCursor

Syntax:
(itmAtCursor itemListCursor)

Argument List:
itemListCursor: A pointer to the item that you want the itemStruct of. (can someone think of something better to say than pointer.

Returns:
An itemStruct of the item pointed at by the itemListCursor.

Category:
item

Description:
Gets the itemStruct of the item being pointed at by the itemListCursor.

Example:

Code: Select all

(objEnumItems gPlayerShip "sI" itemCursor
	(itmGetName (itmAtCursor itemCursor) 0)
	)
This returns the name of the name of the shield that is equipped by the player.

Comment:
objEnumItems or scrGetItemListCursor is the only way to get the itemListCursor. This limits what you can do with functions that use the itemListCursor greatly.
Most functions can work with itemStructs so you don't have to worry about it much except doing this function in nearly every objEnumItems or scrGetItemListCursor.
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Name:
itmCreate

Syntax:
(itmCreate UNID number)

Argument List:
UNID: The UNID of the item you want to create.
Number: The amount of items you want to create.

Returns:
A itemStruct of the items you created.

Category:
item

Description:
Creates number amount of items with the UNID and returns the itemStruct.

Example:

Code: Select all

(itmGetName (itmCreate 0x4001 1) 0)
Returns the string segment of light titanium armor.

Comment:
Very useful function allowing the creation of any item you feel like in code.
Crying is not a proper retort!
Post Reply