typGetXML not working for Corporate Command or mod UNIDs

Freeform discussion about anything related to modding Transcendence.
Post Reply
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

Does (typGetXML unid) only work for UNIDs in vanilla Transcedence?

I can't seem to pull up XML for any UNIDs in Corporate Command or installed mods - not even the UNIDs in the same mod that I'm calling typGetXML from.

Is there a way to make this work? Is there an alternative function I can use to get XML for non-vanilla UNIDs?

EDIT: I have since verified this in the debug console by typing the hexadecimal UNIDs directly into the code below. The UNIDs for vanilla Transcedence work, but the ones for Corporate Command and mods don't.

Code: Select all

----[ Console dump ]----------------
(block Nil
(setq itemXML
(typGetXML
0x00004168
))

)

itemXML
------------------------------------
User avatar
AssumedPseudonym
Fleet Officer
Fleet Officer
Posts: 1190
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

 I can’t remember for certain, but I’m almost positive I remember reading somewhere that a mod has to specifically specify to keep its XML formatting after it’s been parsed by the engine, because otherwise it dumps the XML formatting for memory reasons. I may go digging and see if I can find the relevant post or link or whatnot.

EDIT: http://multiverse.kronosaur.com/news.hexm?id=1063
Image

Mod prefixes: 0xA010 (registered) and 0xDCC8 (miscellaneous)

My mods on Xelerus: Click here!

Of all the things I’ve lost in life, I miss my mind the least. (I’m having a lot more fun without it!)
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

AssumedPseudonym is right, you need usesXML="true".
XML Manipulation & Override

Another major feature in 1.5 is the ability to modify the XML for a given type. This is a feature based on suggestions from this forum thread.

The basic recipe looks like this:

In the root element of your extension (<TranscendenceExtension>), add usesXML="true". This tells the engine that you need the XML for all the types to be kept around for you.
In <OnGlobalTypesInit>, you may use a new function, typGetXML to get the XML for a type that you wish to override.
There are new functions that manipulate the XML returned by typGetXML. For example, you can set attributes or add elements.
Once you've manipulated the XML, you may call typCreate to dynamically create a new type or override an existing type.
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

You both are right. Thanks very much for your help!

Here's what I found in testing:

Adding usesXML="true" in the manner below makes the XML of all mods available to all other mods. Only a single instance in a single mod is required.

That is, if a single mod uses usesXML= "true", any of the installed mods can call typGetXML and pull up the XML for any other installed mod or extension.

That means that my mod can see the XML for Corporate Command and Drake Technologies, and vice versa, although no mod exists that I am aware of that currently uses typGetXML other than my own.

This is going to be the beginning of a lot of fun. Thanks again for your help!

Code: Select all

<TranscendenceExtension
	UNID=           "&unid064Launcher;"
	apiVersion=     "27"
	name=           "Reprogrammed Launchers"
	release=        "1"
	version=        "v0.10"
	credits=		"gunship256 (code), George Moromisato (game art)"
	
	usesXML=		"true"
	>
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

Adding usesXML="true" in the manner below makes the XML of all mods available to all other mods. Only a single instance in a single mod is required.
o.O what ? I don't think that it's supposed to work like that.
I'm happy that it worked for you, but this looks like a case of bleeding code into other mods ?
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

digdug wrote:
Adding usesXML="true" in the manner below makes the XML of all mods available to all other mods. Only a single instance in a single mod is required.
o.O what ? I don't think that it's supposed to work like that.
I'm happy that it worked for you, but this looks like a case of bleeding code into other mods ?
I've been playing with typGetXML and typCreate for a couple of weeks, and I think I understand why it was necessary.

For example, I could make a mod that used typGetXML to assemble a list of missiles that can be fired by launchers by either checking for the <Missile> element or searching for type="missile". Some missiles aren't fireable because of the lack of type="missile" and will generate an error if added to launcher code; examples include SmartCannon rounds and the Nandao bolt.

If another mod overwrites the NAMI launcher to make it a non-launcher weapon and overwrites Longbows to remove type="missile", what happens if my mod isn't aware of the change because it can't pull up the XML for the overwritten Longbow? It will try to add the Longbow to a missile launcher during runtime based on no-longer-valid vanilla code, generating an error.

If an item's characteristics are available to the game in C but the corresponding XML isn't updated, other errors can creep in if another mod uses typCreate to overwrite those items during the course of the game. From this perspective, it makes sense that if one mod needs typGetXML, the XML of all items must become available.
Post Reply