Attributes in Stations instead of StationTypes

Freeform discussion about anything related to modding Transcendence.
Post Reply
User avatar
Mutos
Militia Lieutenant
Militia Lieutenant
Posts: 218
Joined: Thu Aug 14, 2008 3:31 am
Location: Near Paris, France
Contact:

Hi all,


I thought to make a StationType for a planetary standard orbit and then instanciate that StationType through Station tags, adding attributes to each Station to describe its individual properties.

I tested with adding the attributes="attributeName" to the Station tag itself and using the "t:attribute" seach on sysFindObject. It doesn't seem to work.

Would it be possible to use StaticData instead ? But I didn't find any example in Transcendence source XMLs, StaticData tags always seem to be attached to StationTypes or ShipClasses. So how can you code properties for a specific station ? Or maybe it's not possible and StationTypes must be used ?

EDIT #1 : as an afterthought... This issue may in fact be a part of the one discussed on the How to implement a shared table ? thread. Or not a part of, but closely related as the goal is to store data on objects.

EDIT #2 : I need to study more of the random part of objects generation. Then both issues may find easier solutions.
@+

Benoît 'Mutos' ROBIN
Hoshikaze 2250 Project
User avatar
Mutos
Militia Lieutenant
Militia Lieutenant
Posts: 218
Joined: Thu Aug 14, 2008 3:31 am
Location: Near Paris, France
Contact:

Hi all,


Some experimental results !

I tried to put a testData property in the Station tag and retrieve it with 3 functions : objGetData, objGetGlobalData and objGetObjRefData. To no avail.

What I did to store the data :

Code: Select all

<Station type="&stMarkerDockS;" name="Venus" testData="Test String" />
The stMarkerDockS Station Type is one of my own types, just a marker with docking ports to figure a parking orbit.

And to retrieve it :

Code: Select all

						(setq listStations (sysFindObject sourceSystem "t:parkingOrbit"))
(enum listStations theStation
		(block (testData)
		(setq message (cat "System " (sysGetName) " :   Data on " (objGetName theStation) " : "))
		(dbgLog message)
		(setq message (cat "System " (sysGetName) " :     objGetData       : " (objGetData theStation "testData")))
		(dbgLog message)
		(setq message (cat "System " (sysGetName) " :     objGetGlobalData : " (objGetGlobalData theStation "testData")))
		(dbgLog message)
		(setq message (cat "System " (sysGetName) " :     objGetObjRefData : " (objGetObjRefData theStation "testData")))
		(dbgLog message)
	)
)
I do that in the OnGlobalSystemCreated event and it lists all my parkingOrbits stations with all Nil values.

I hoped to see one of the line turn to non-Nil on the one station I modified, but to no avail...

I'll try the same in the StationType to see what it does, but it doesn't help for customizing a single station instance.
@+

Benoît 'Mutos' ROBIN
Hoshikaze 2250 Project
User avatar
Mutos
Militia Lieutenant
Militia Lieutenant
Posts: 218
Joined: Thu Aug 14, 2008 3:31 am
Location: Near Paris, France
Contact:

Hi all,


Today I tested with <StaticData> tags and objGetStaticData function. It works OK inside <StationType> tags but not for <Station> tags.
@+

Benoît 'Mutos' ROBIN
Hoshikaze 2250 Project
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

if I can understand correctly what are you doing, you want to put arbitrary data on the a station when created (that's why you are tinkering with the <Station> tag)

I think that the only easy way is to create the station with sysCreateStation and then put any data you want into that particular station, because of course if you put staticdata in the <StationType> it will be available to all the stations of that type.

Of course the staticdata can be as complicated as you want with script code and you can run it using the eval function.
User avatar
Mutos
Militia Lieutenant
Militia Lieutenant
Posts: 218
Joined: Thu Aug 14, 2008 3:31 am
Location: Near Paris, France
Contact:

Hi all, hi digdug,


Yes that's the goal. To be able to create a generic station type with standard data filled in and customize it with different data, for instance particular prices or availability on items for a trading system. I would like to avoid creating a custom StationType for each time I have to customize a data on a station...

More generally, I'm trying to know all the ways in which I can store description data in my stellar systems in the XML and retrieve them at runtime from scripts. There are many ways to do that for now and I have no clear view of what can be done and what can't and what way to use or not in each situation and why.

The question is not about what can be stored as with lists and eval it's indeed everything you want, but it's rather where to store it and how to retrieve...

But maybe with scripts in the stellar system's <OnCreate> event...
@+

Benoît 'Mutos' ROBIN
Hoshikaze 2250 Project
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

I think the easiest way to do this is to simply in the stations <OnCreate> event say (objSetData gSource "fooname" foovalue) for whatever values you wish to store. This makes your data easily changable, and certainly not any more difficult to access.
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

prepare a single stationType with all the staticdatas you need like:

Code: Select all

<StaticData>
<Data1>
script 1 here
</Data1>

<Data2>
script 2 here
</Data2>
</StaticData>
then you can run the script you want using:

Code: Select all

(eval (itmGetStaticData StationType "Data1"))
the name string of the staticdata can be dynamically generated in another script, take a look at the string functions on xelerus, they are a bunch of functions for manipulating strings.
User avatar
Mutos
Militia Lieutenant
Militia Lieutenant
Posts: 218
Joined: Thu Aug 14, 2008 3:31 am
Location: Near Paris, France
Contact:

Hi F50, hi digbug, hi all,


F50 : I was thinking about that, I'll test an OnCreate event on a single station.

digdug : OK for that also, it's kind of the same thing I currently do in Global tags.
@+

Benoît 'Mutos' ROBIN
Hoshikaze 2250 Project
Post Reply