function list

This is a moderated forum that collects tutorials, guides, and references for creating Transcendence extensions and scripts.
User avatar
Ttech
Fleet Admiral
Fleet Admiral
Posts: 2767
Joined: Tue Nov 06, 2007 12:03 am
Location: Traveling in the TARDIS
Contact:

Betelgeuse wrote:Name:
apply

Argument List:
Function: The function you want to run.
List: A list of arguments you want the function to be run with.

Returns:
Whatever the function returns.

Category:
Function Operator (can someone think of a better category for this?)

Description:
Runs the function as though it was called normally using the list as its arguments.

Example:

Code: Select all

(block (someArgumentList)
	(setq someArgumentList '(True True Nil))
	(apply and someArgumentList)
	)
This will return Nil.

Code: Select all

(block (someArgumentList) 
	(setq someArgumentList '(1 34))
	(apply add someArgumentList)
	)
This will return 35.
gone a little coding crazy? :)
Image
Image
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

just making sure the project keeps on moving 8)
Crying is not a proper retort!
Apemant
Commonwealth Pilot
Commonwealth Pilot
Posts: 94
Joined: Mon Dec 03, 2007 12:51 pm

Betelgeuse wrote:just making sure the project keeps on moving 8)
Good work 8)

But may I suggest another field right after the 'Name'? That would be 'Syntax' so that you don't need to go down to the example to get a quick reference on the syntax. It would be just 'name' followed by arguments, such as

Name:
objJumpTo

Syntax:
(objJumpTo obj posVector)

and then -
Argument List:
obj:
posVector:

etc.
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Apemant wrote:But may I suggest another field right after the 'Name'? That would be 'Syntax' so that you don't need to go down to the example to get a quick reference on the syntax. It would be just 'name' followed by arguments
Sounds good. I have been adding comments to them because that is how I feel about them what do you think about those?
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Name:
armGetName

Syntax:
(armGetName ArmorType)

Argument List:
ArmorType: The type of the armor you want to get the name from. This is not the UNID.

Returns:
String: The name of the armor

Category:
Armor, Name

Description:
Returns the name of the type of armor you passed to it.

Example:

Code: Select all

(armGetName (objGetArmorType gPlayerShip 0))
This returns your forward armor.

Comment:
I don't really understand what is the point of type. Anyone have any clues on that? Item Create works with UNID but not this.
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Name:
armGetRepairCost

Syntax:
(armGetRepairCost ArmorType)

Argument List:
ArmorType: The type of the armor you want to get the repair cost from. This is not the UNID.

Returns:
number: The cost of repairing one point of damage of this armor.

Category:
Armor

Description:
Returns the repair cost of one point of damage for this armor type.

Example:

Code: Select all

(armGetRepairCost (objGetArmorType gPlayerShip 0))
This returns the cost of repairing one point of damage on your forward armor.

Comment:
More armor type fun. The only way to get this is to install it and do objGetArmorType. :P
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Name:
armGetRepairTech

Syntax:
(armGetRepairTech ArmorType)

Argument List:
ArmorType: The type of the armor you want to get the repair tech from. This is not the UNID.

Returns:
number: The tech level needed for a station to repair this armor.

Category:
Armor, Repair/Damage, Station

Description:
Returns the tech level needed to repair this armor type for a station.

Example:

Code: Select all

(armGetRepairTech (objGetArmorType gPlayerShip 0))
This returns the tech needed to repair this armor.

Comment:
This is not a real limitation it is more of a by convention no station below the tech level can repair the armor.
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Name:
armIsRadiationImmune

Syntax:
(armIsRadiationImmune ArmorType)

Argument List:
ArmorType: The type of the armor you want to get if the armor is radiation immune from. This is not the UNID.

Returns:
Boolean: True if the armor is radiation immune Nil otherwise.

Category:
Armor, Radiation

Description:
Checks to see if the armor is radiation immune and returns the result.

Example:

Code: Select all

(armIsRadiationImmune (objGetArmorType gPlayerShip 0))
Returns True if the armor type of the forward armor is radiation immune false otherwise.

Comment:
Yay no more ArmorType after this.
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

Name:
block

Syntax:
(block List Function^1)

Argument List:
List: A list of temporary variables. Can be Nil.
Function: The function you want to run.
^1

Returns:
Whatever the last function or primitive that runs in it returns.

Category:
Control Structure

Description:
Allows you to run functions one right after the other.

Example:

Code: Select all

(block Nil
	(block (varA varB)
		(dbgOutput "I am in varA varB block. varA and varB are valid here.")
		)
	(dbgOutput "I am outside varA varB block. varA and varB are no longer valid here.")
	)
Displays
I am in varA varB block. varA and varB are valid here.
I am outside varA varB block. varA and varB are no longer valid here.

Comment:
This is a very important function because often you want to run things one right after anouther. It is one of the most if not the most common function in the xml.
Last edited by Betelgeuse on Tue Dec 11, 2007 11:49 am, 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:
cat

Syntax:
(cat String^1)

Argument List:
String: A string that you want to stick together with other strings.
^1

Returns:
String: A new string composed of all the other strings in the order of the argument list.

Category:
String Operator

Description:
Sticks together strings forming larger strings in the order you supply with the argument list.

Example:

Code: Select all

(cat "He" "l" "llo W" "orld")
This returns the string Hello World.

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

Name:
count

Syntax:
(count List)

Argument List:
List: The list where you want to know how many elements are in it.

Returns:
Number: The number of elements in the list.

Category:
List Operator

Description:
Counts how many elements are in the list and returns that number. It doesn't care what the elements are they can even be other lists.

Example:

Code: Select all

(count '(1 1 1 1))
This will return the number four.

Code: Select all

(count '((1 a b) Nil (la Nil)))
This will return the number three (even if two are lists and one is Nil)

Comment:
Basic list function. Very helpful for the function for.
Crying is not a proper retort!
Apemant
Commonwealth Pilot
Commonwealth Pilot
Posts: 94
Joined: Mon Dec 03, 2007 12:51 pm

Betelgeuse wrote:Name:
count
I see you are doing them alphabetically; do you plan on posting them all like that? If I wanted to participate, what should I do, continue with the alphabetical order I do it randomly?
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

whatever you feel the most comfortable with. :D
Crying is not a proper retort!
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

also you may notice I skipped the ones I wasn't sure about so it is already not in alphabetical order.
Crying is not a proper retort!
Apemant
Commonwealth Pilot
Commonwealth Pilot
Posts: 94
Joined: Mon Dec 03, 2007 12:51 pm

Name:
if

Syntax:
(if condition function [function])

Argument List:
Condition: anything that evaluates to Nil or non-Nil
Function: a function that gets invoked if 'condition' evaluates to non-Nil (if it is 'true')
Optional function: a function that gets invoked if 'condition' evaluates to Nil (i.e. is 'false')

Returns:
Whatever 'function' or 'optional function' returns, depending on which one gets evaluated.

Category:
Control Structure

Description:
Basic branching function. Allows executing something only if a certain condition is met. A fundamental thing.

Example:

Code: Select all

(if (eq (sysGetNode) "SE")
    (objSendMessage gPlayerShip Nil "We are still in Eridani system")
    (objSendMessage gPlayerShip Nil "We are on the journey to the core")
)
Comment:
It's hard to imagine a script of more than several functions which wouldn't contain some sort of branching, either with 'if' or 'switch' functions.
Last edited by Apemant on Tue Dec 11, 2007 6:01 pm, edited 1 time in total.
Post Reply