<OnCreate> for ships?

Freeform discussion about anything related to modding Transcendence.
Post Reply
schilcote
Militia Captain
Militia Captain
Posts: 726
Joined: Sat Feb 02, 2008 7:22 pm

Is it possible to have an OnCreate in a ship's <Events>? I put one in and it worked without errors, but it didn't execute. It was stock code, the invoke for an auton, so the code is not a problem. How can I get code executed at startup?
[schilcote] It doesn't have to be good, it just has to not be "wow is that the only thing you could think of" bad
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

I'm pretty sure it should work. No, actually I *know* it works, code please?
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 use a simple test to start building event code:

Code: Select all

<Events>

<OnCreate>

(block nil

;now here I can use a variety of things.  
;A player message is one easy line

(objSendMessage gPlayer nil "Oncreate triggered")

;sometimes messages can't be sent when the object is created
;so you can instead create a piece of data to retrieve later

(objSetData gSource "createMessage" "Oncreate triggered")

;or if I want to test a function in a separate file I can call the function

(modTestFunction)

;or I can set a timer to call another event

(sysAddObjTimerEvent 100 gSource "TestTimerEvent")

)
</Oncreate>

<TestTimerEvent>
(block nil

(objSendMessage gPlayerShip nil "Timer event triggered")

)
</TestTimerEvent>
</Events>

schilcote
Militia Captain
Militia Captain
Posts: 726
Joined: Sat Feb 02, 2008 7:22 pm

I just tried again to have OnCreate work

Code: Select all

<OnCreate>
			(ObjSendMessage gsource nil "Hello world!")
			</Oncreate>
And guess what?
"Welcome to transcendence!"
No hello world.
I might put an OnCreate caller in my mod of the ship computer mod...

The code for my other OnCreate is just the invoke for the mule auton in Transcendence.xml

As for code for the whole mod, you really don't want it. This mod is HUGE. It takes about five minutes for it to load (I have a custom TranscendenceMarch.mp3 and I have syncronised bugs (and therefore mods) with the music. The beat changes around the Ss) and it is very complex. I don't understand some of it.

And OnDestroy dosn't work either. I don't think any of the OnX routines workl.
Last edited by schilcote on Sun Jul 27, 2008 3:03 pm, edited 1 time in total.
[schilcote] It doesn't have to be good, it just has to not be "wow is that the only thing you could think of" bad
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

And guess what?
"Welcome to transcendence!"
No hello world.
I might put an OnCreate caller in my mod of the ship computer mod...
if I remember correctly, you have to put a delay when the OnCreate is on the playership (so when the game is launched), otherwise it doesn't work.
So use the timer as explained by Periculi.
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

;sometimes messages can't be sent when the object is created
Post Reply