basic syntax

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

This post will explain some basics and fundamentals of the syntax in scripting.

There are 6 basic things in transcendence script.

A functions format is (function argument1 ... argumentN) unlike the c and basic families of languages where it is function(argument1 ... argumentN). A function can have no argument. There are two basic types of functions lambda and primitive.
Lambda functions are functions that are made with the lambda function. They can be called with fewer or extra arguments. Arguments that are not passed in are set to nil.
Primitive functions are built in functions that are picky how many arguments they have. Raising errors if they don't like the number of arguments.

A constant is some word with an agreed upon value. They are nil that is an empty list and True something that is not an empty list.

A string is a series of characters. A strings format is "string"

A number is a number (easy). Numbers come in two formats hex (base 16) and dec (base 10). If there is nothing before the number it will be taken as dec format. If there is a 0x before the number it is a hex number.

A comment is something that is put in code to describe but isn't run. The format for comments in script is
;comment until the end of the line

A variable is a storage reference for data (you store stuff in them). They can be any word that doesn't start with a numeral and isn't a constant or primitive. There are three types of variables.
A global variable is a variable that can be used anywhere. They can be created by setq and an invalid variable (one that doesn't exist yet).
A local variable is a variable that only exists in the function that it was created for. Local variables start with nil in them.
A type variable is a variable on ships, stations, or items that is accessed through the various data functions. All type variables are assumed to be always valid and default to having nil in them.

A list is a ordered set of elements. An element is a number or function or string or list or constant.
New lists are created two ways ether the list function or '(element1 ... elementN)

any questions comments or corrections?
Last edited by Betelgeuse on Fri Sep 26, 2008 8:25 pm, edited 2 times in total.
Crying is not a proper retort!
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

Cool! :D

About the number, transcendence scripts accepts base10 and hex numbers (as said before), you can do math with both of them, even mixing them.

However all the functions returns base10 numbers, I got confused a couple of times for that. :)
Post Reply