Storing Lists on gPlayerShip?

Freeform discussion about anything related to modding Transcendence.
Post Reply
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

Is it possible to create, store and manipulate lists attached to gPlayerShip?

I can't seem to get a list to work in objSetData.

Also, what about storing lists in a list attached to gPlayerShip.

Basically, I want to store some info: a time stamp and a function to perform.
These two items are a list for each event.
The events are on a list together in gPlayership
I want to go through this list and compare the time stamp to the current time.
If the event time is equal to the current time, I want to perform an event (a message in this test case)
But I don't seem to understand how to store a list in a list as a variable in gPlayership.

Code: Select all

	
;this initializes the event list

(block (timeStamp)
(setq timeStamp 3)

		(block (eventOne)
			(setq eventOne (list timeStamp "message"))
			(objSetData gPlayerShip "activeEventList" eventOne)
			)
)


;then this function is performed when the ticker updates from the global timer 

(setq tmrUpdateEventTimer (lambda Nil

;this is the function to see if there is an event for this cycle
	(block (eventList currentTick) 
;get some data from playership
	(setq currentTick (objGetData gPlayerShip "ticker"))
	(setq eventList (objGetData gPlayerShip "activeEventList"))
		(block (event)
			(enum eventList event 
				(block (time)
				(setq time (item event 1)
				(if (leq time currentTick)
					(block (toDo)
					(setq toDo (item event 2))
					(tmrActiveEvent toDo)
					) 
				)
				)
				)	
				
			)			
		)
	


	)

))

(setq tmrActiveEvent (lambda (eventType)
	(block Nil
	(objSendMessage gPlayerShip Nil (cat "Message is: " eventType))
	
	)
))

george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Sounds like you need a list of lists.

Your original code creates a list with two items:

Code: Select all

(setq eventOne (list timeStamp "message"))
I think you want a list that in turn contains a list containing two items:

Code: Select all

(setq eventOne (list (list timeStamp "message")))
At some point you are going to want to append to a list:

Code: Select all

...
(setq eventList (objGetData gPlayerShip "activeEventList"))
(setq eventList (append eventList (list (list timeStamp "message"))))
(objSetData gPlayerShip "activeEventList" eventList)
I haven't tested any of this out, so there might be bugs.

Also, remember not to store any object pointers in these lists. If necessary, store an objectID.

Good luck!
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

Thanks George! The (list (list kinda thing just never would have crossed my mind as the answer there.

Ok, so I have a global timer checking an event list supplied by the playership.

Anything could have script that added to the event.

Now, what do you mean by "pointers"? You mean like '&stStarGate;' ? what about simply changing data in gPlayership that certain items/objects use?
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

pointers are variables that point to other things (objects variables whatever)
you can't store them with that due to they can change when you save and load.

The list of pointers are itmListPointer, spaceObject (there is a different way of storing those), players, the result from objGetArmorType

look here for a previous thread on it

http://neurohack.com/transcendence/foru ... hp?p=10133
Crying is not a proper retort!
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

&stKorolovShipping; is a UNID and thus a number.

If I use sysFindObj in a script to find a particular Korlov station, then that's a pointer.

In general, things that refer to classes of things (UNIDs etc.) are not pointers, things that refer to a *specific* thing are pointers. (note that &stAntartica; or however that's spelled, is in fact a class of thing even though you only see one of it in the game)
Post Reply