Storing more than one piece of data in Items
-
- Developer
- Posts: 2998
- Joined: Thu Jul 24, 2003 9:53 pm
- Contact:
I haven't actually tried this, but after looking at the code, you should be able to do this:
data="(1 2 3)"
and get back a list with the numbers 1, 2, and 3. In other words, you can enter normal script syntax in the data field and get it back with itmGetTypeData.
Remember that this data is associated with the type, not the instance (in other words, all items of that type will have the same data).
data="(1 2 3)"
and get back a list with the numbers 1, 2, and 3. In other words, you can enter normal script syntax in the data field and get it back with itmGetTypeData.
Remember that this data is associated with the type, not the instance (in other words, all items of that type will have the same data).
That's cool, I'll code what I am working on that way and find out. For referrence, I was asking because I am working on a set of objects like the barrels, and I am trying to move some of the logic into the itemtype to reduce the amount of switch logic required. For example
data ="("sarin" "deadly sarin gas swirls out of the canister" "deadly" 1 &itGasMask "but you manage to get your gas mask on in time")"
where it is in the format (type openText effect countermeasureCount countermeasure1Item countermeasure1Text ...)
data ="("sarin" "deadly sarin gas swirls out of the canister" "deadly" 1 &itGasMask "but you manage to get your gas mask on in time")"
where it is in the format (type openText effect countermeasureCount countermeasure1Item countermeasure1Text ...)
-
- Developer
- Posts: 2998
- Joined: Thu Jul 24, 2003 9:53 pm
- Contact:
Nice--I'd love to see it when it's done.
Since the data field is an XML attribute (not element content) you won't be able to use double-quotes inside. Use these techniques:
For single words, prepend with single-quote:
'sarin
That's the script way of saying the following is a literal (string) as opposed to a function.
For phrases, use the " escape character (which converts to double-quote):
"deadly sarin gas swirls out of the canister"
Good luck and let me know how it works.
p.s.: In the next version (hopefully) I will add a <StaticData> element to item types so you can have more flexibility.
Since the data field is an XML attribute (not element content) you won't be able to use double-quotes inside. Use these techniques:
For single words, prepend with single-quote:
'sarin
That's the script way of saying the following is a literal (string) as opposed to a function.
For phrases, use the " escape character (which converts to double-quote):
"deadly sarin gas swirls out of the canister"
Good luck and let me know how it works.
p.s.: In the next version (hopefully) I will add a <StaticData> element to item types so you can have more flexibility.
- Betelgeuse
- Fleet Officer
- Posts: 1920
- Joined: Sun Mar 05, 2006 6:31 am
hmm a question can you add staticdata to items?
Crying is not a proper retort!