Using <OnGlobalTopologyCreated> Events

This is a moderated forum that collects tutorials, guides, and references for creating Transcendence extensions and scripts.
Post Reply
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1259
Joined: Sat Oct 13, 2007 7:48 pm
Location: By the beach

Thu Aug 28, 2008 9:01 pm

The <OnGlobalTopologyCreated> event is a powerful new event that can be placed in the game. It gets triggered when the game loads a topology and preps it for entering the game. You can use it for a lot more than just to check out the topology or add a link between systems.

One interesting experiment involving <OnGlobalTopologyCreated>:

I built a 'blank' system element in an adventure extension and placed only an event in the system type:

Code: Select all

<SystemType UNID="&ssTopoMaster;">

<Events>
<OnGlobalTopologyCreated>
(block nil

(sysSetData "SE" "GlobalTest" "Event Works!")

)
</OnGlobalTopologyCreated>
</Events>

</SystemType>
This system is not used by the topology nodes, and merely served as a place to put my test <OnGlobalTopologyCreated> event. I thought it wouldn't do anything... but it does!!

The event placed the data on SE, which I looked up in-game and found to be "Event Works!" as it was set.

This shows 2 things of interest- the topology event can be triggered in a blank system (or regular one) that isn't used, and the event can perform code to set data on a system when the game starts.

I will report back with some more experiments with this event. :)


How to add a random link-

Code: Select all

<SystemType UNID="&ssTopoMaster;">

<Events>
<OnGlobalTopologyCreated>
(block (rand)

(setq rand (random 1 2))
(if (eq rand 1)
(sysAddStargateTopology "SE" "RandomB" "C1" "Inbound")
)

(sysSetData "SE" "GlobalTest" "Event Worked!")

)
</OnGlobalTopologyCreated>
</Events>

</SystemType>
Now that I have the event firing in a handy location, I expanded the code to randomly place a gate to a system.

Here's the trick of it- any topology nodeID that is 'floating' around waiting to see if it gets linked must be a rootNode. If a system is not a rootNode, it can get discarded when the topology is created.

In this example, the node that is getting linked to from Eridani looks like this:

Code: Select all

      <Node ID="C1" rootNode="true">
         <System>
		<Table>
            <System name="C1a" chance="50" UNID="&ssEarthSpaceStandard;" attributes="alphaModel, Eridanus, newBeyond" level="1"/>
            <System chance="50" name="C1b" UNID="&ssEarthSpaceAsteroids;" attributes="betaModel, Eridanus, newBeyond" level="3"/>
		</Table>

         </System>

         <StarGates>

	<StarGate name="Inbound" DestID="[Prev]" DestGate="RandomB"/>


         </StarGates>
      </Node>
It had to have a gate, and because it is a lonely disconnected system in the topology, it had to have rootNode="true" in order for the <OnGlobalTopologyCreated> event to link it.
Last edited by Periculi on Thu Aug 28, 2008 9:16 pm, edited 1 time in total.

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

Thu Aug 28, 2008 9:29 pm

Betelgeuse wrote:eep that isn't good :?

anyway I would have to ask for some time in the future that we have a way of telling what order they get called.
Just out of curiosity, what are you trying to do that requires knowing the order?

Post Reply