expanding, shrinking and creating lists in transcedence

Freeform discussion about anything related to modding Transcendence.
Post Reply
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

How do I create, expand, and shrink lists in transcendence?

I want to create ships and put pointers to the ships in a list using a for loop.

I also want to take this further. I want to create several lists as above and put them into another list.

Is it just like in the lisp tutorials that I've found on the web?
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

I don't know about the tutorials, none of the tuts I found ever worked well in Transcendence Lisp.

Sounds like you need something like:

Code: Select all

		(block (eventOne)
			(setq eventOne (list (list timeStamp1 "Event Manager is Operating" tmrNada)))
			(objSetData gPlayerShip "activeEventList" eventOne)
			)
which creates a list of lists. The list is called activeEventList, which contains lists holding some data (timeStamp1, message text, functionName)

you can create a list by simply setting up a (setq listName (list item1 item2 item3))

Check out the Functions section on Xelerus for more list functions.

Also this thread: storing lists on gPlayerShip
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

not really, I need something like this:

Code: Select all

(for x 0 4 ; 4 could be changed to 5, 100, or any other integer
    (block Nil
        (setq ship (sysCreateShip &scPhobos; gPlayerShip &svAres;)
        (setq listofships (cons ship listofships)
)
cons is a list function that I found on the tutorials.
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

you found it on the tutorials... I found lots of Lisp functions that George hasn't added into the TransLisp. Remember- it's Lisp-like not Lisp.

So, does 'cons' work in transcendence?

edit- seems like it doesn't.

the working list functions:
append
count
enum
enumwhile
item
list
lnkAppend
lnkRemove
lnkRemoveNil
lnkReplace
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

can you describe what cons does? We might be able to make it in code.
Crying is not a proper retort!
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

The cons function constructs lists; it is the inverse of car and cdr. For example, cons can be used to make a four element list from the three element list, (fir oak maple):

(cons 'pine '(fir oak maple))

After evaluating this list, you will see

(pine fir oak maple)

appear in the echo area. cons puts a new element at the beginning of a list; it attaches or pushes elements onto the list.
From EMacs Lisp intro tutorial

Which makes it similar to the lnkAppend, except it places the item at the beginning of the list.
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

so it would be

Code: Select all

(setq cons (lamba (myatom mylist)
	(append (list myatom) mylist)
))
Crying is not a proper retort!
george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

I think it might be easier than that:

Code: Select all

(setq cons append)
(which probably means that I should rename append...or at least create a synonym)
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

But does append add to the first of the list or the end? cons adds an item to the first of the list. And does it matter, F50?
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

append appends lists together and I guess if one of those lists is not a list it makes it a list then appends it.

(append 'a '(b c d))

has the same result as

(append '(a) '(b c d))

and that is the list (a b c d)
Crying is not a proper retort!
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

no, it doesn't matter whether it places it at the beginning or the end. I should be able to use lnkRemove to shrink lists, so that pretty much answers all my problems.
Last edited by F50 on Sat Mar 29, 2008 5:13 am, edited 1 time in total.
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

after a few more tests I found that append is very powerful and lnkAppend is useless. 8)

(append 'a 'b) gives you the list (a b)

(append '(a b c) 'd) gives you the list (a b c d)
Crying is not a proper retort!
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

And why is lnkAppend useless?
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

well not useless just redundant (append can do anything lnkAppend can do easily but lnkAppend can not do the stuff that append can do easily)
Crying is not a proper retort!
Post Reply