A sneaky fake Get/Set method for items

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

I have to share this little bit of scripting sneakiness-

In the process of developing some of my recent ideas I have come across the need for setting and getting data on items. It has come up a lot, and seemed to be an impossible task to get a way to treat items with some dynamic data.

But I found that there is at least one bit of data that can be changed on an item- the charges.

Let's say we have an item that has a set of 'states' that it can be in- well, we do actually so go look at it- the Jotun deflector. It uses charges to set it's power state and strength.

That was the only crack in the item data wall I could find, and so I have developed it into a working system.

The state of an item can go beyond what the Jotun uses- you could have an item that went through 100's of states! And using the data holder, the charges can be set to indicate the state number, and the state could be an item on a list in the item type data.

Well, fancy as that may be, it doesn't really go far enough.

If the item is a misc device or similar, and doesn't actually use charges, the charges can be used for other things.

Let's say we want to have an item that gets loaded with another item. For example, a Mini-Incubator system for single Terran Eggs. Clearly an important and useful device if Easter is coming up! Now, let's say for the sake of this example that you actually have 5 Mini-Incubators. And you have 5 eggs- one for each incubator.

You can use the charges to distinguish between each of the incubators. You can also use charges to indicate the 'state' of the device. Now, let's say you have the benefit of having the current build of the event manager, which allows you to set an event to occur after a specific time. You can uniquely track the Incubators and relate the events to the specific Incubator's timestamp!

Good enough for what I wanted at least!

I suppose a mod example should be forthcoming for this soon, but I just wanted to share that little insight into ways to set unique data on items. And it also works to 'mark' items that don't use charges.

What to do if an item needs to make use of charges? Probably get another plan and bug George for a way to alter the data (itmSetTypeData).
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

if you don't have too many space obects with those items you can also store a list of (spaceobectID (item1 data1 data2 ...) (item2 ...) ...) on the player ship
you can store and retrieve anything about the items that you stored for that space object (this assumes you have both the item and space object)

I admit this does require some tricky list manipulation but that can be done with some helper functions.
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

How would the list work if I placed 5 identical objects on it? The items all have the same UNID for the same item type- even if you have an item that has 1 charge and an item that has 4 charges- they show up on the list seperate but they have the same name and unid- so there isn't an easy way to mark out a unique item from a list of the same items.

It's easy to use the list or other data stored on gPlayerShip for single items, but what if I had 5 items such as the miniIncubator- each of which can hold 3 items.

Incubator one gets 3 eggs
Incubator two gets 1 egg
Incubator three gets 1 egg
All the rest get 2 eggs.

The incubators are just items, so how does a list on the playership reference which is which and when it's eggs are done and hatched?
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

good question

if that is a concern make a ID for the item so just make a number that no other of the item has. (just store a nextID on the player ship and increment it when it is used)

this way you can have levels of objects inside of each other (eggs within eggs within eggs)

(this does assume you can't loot these things separately)

edit: you can use the charges as the ID then you would solve the selection and display problem 8)
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

Betelgeuse wrote: edit: you can use the charges as the ID then you would solve the selection and display problem 8)
See- sneaky, huh!

The charges will work for a lot of little problems regarding data on items. I really would prefer a method to alter at least the charges and the data="value". If we had a secondary way to set data and could use lists, well that would be like living on a tropical island with coconuts full of beer.
Post Reply