Say one wants to make an event that is always in effect (say, one that constantly increments or decrements a value), but you don't want to have to write it in *all* playerships. Is there a way to do that?
If not, I suggest there be a way to create such a structure.
Global recurring timer
i recently placed a recurring event on the g type star that affected the player, if you put your event on every star with an oncreate to start it, you will have an event that works in any system. it would probably be best to store any data required on a global on the player ship.
- Periculi
- Fleet Officer
- Posts: 1282
- Joined: Sat Oct 13, 2007 7:48 pm
- Location: Necroposting in a forum near you
LoL! I did that just the other day to see if a timer could be picked up from the playership and continued system to system easily. I am thinking that an Event Manager could be run from a single timer- something that would allow many things that wanted timers to all be run from one update system that was as small as possible in regards to processing during game ticks.i recently placed a recurring event on the g type star that affected the player, if you put your event on every star with an oncreate to start it, you will have an event that works in any system. it would probably be best to store any data required on a global on the player ship.
- Periculi
- Fleet Officer
- Posts: 1282
- Joined: Sat Oct 13, 2007 7:48 pm
- Location: Necroposting in a forum near you
I put a version of this in the Playerships and it crashed the game:
I then switched the line in the OnCreate to read: (sysAddObjRecurringTimerEvent 30 gPlayerShip "OnCheckEntry") to try to attach the timer to the playership, and placed the Event block into the Eridani System description. It didn't do anything for me.
I then placed the same block of code into the Star station as mentioned in posts above, with a few alterations to initialize it and was able to get the timer to increment successfully across several systems- carrying the "ticker" forward using a recurring timer event in each system to add to the data "ticker" found in the playership.
I don't think you can attach the timer to the playership, to even begin with. The timer attached to the Stars worked out great, but you would run into trouble with a binary system without checking for duplicate timers.
Code: Select all
<Events>
<OnCreate>
(block Nil
(objSetData gPlayerShip "ticker" 0)
(sysAddObjRecurringTimerEvent 30 gSource "OnCheckEntry")
)
</OnCreate>
<OnCheckEntry>
(block Nil
(objIncData gPlayerShip "ticker" 1)
(objSendMessage gPlayerShip Nil (cat "Tick: " (objGetData gPlayerShip "ticker")))
)
</OnCheckEntry>
</Events>
I then placed the same block of code into the Star station as mentioned in posts above, with a few alterations to initialize it and was able to get the timer to increment successfully across several systems- carrying the "ticker" forward using a recurring timer event in each system to add to the data "ticker" found in the playership.
I don't think you can attach the timer to the playership, to even begin with. The timer attached to the Stars worked out great, but you would run into trouble with a binary system without checking for duplicate timers.
That's odd Periculi, this works
The script never modified any of the gPlayerShip's data, but it worked.
As soon as I look up how to access creds and rins I will see if the actual modification of data is creating the problem.
Code: Select all
<Events>
<OnCreate>
(block Nil
;code trimmed
(sysAddObjRecurringTimerEvent 40 gSource "nopirateencounters")
(objSendMessage gSource gSource "A pirate's life for you, eh?")
)
</OnCreate>
<nopirateencounters>
(block Nil
;code trimmed
)
</nopirateencounters>
</Events>
As soon as I look up how to access creds and rins I will see if the actual modification of data is creating the problem.
- Periculi
- Fleet Officer
- Posts: 1282
- Joined: Sat Oct 13, 2007 7:48 pm
- Location: Necroposting in a forum near you
hmm... but guess what else- I placed the message down into the code event, so every 40 ticks it tells me about my pirate's life, then I flew out of Eridani... No more timer, it's only for that one system- so even an event attached to the playership cancels when you leave a system.
- Betelgeuse
- Fleet Officer
- Posts: 1920
- Joined: Sun Mar 05, 2006 6:31 am
gPlayerShip and gplayer is not set when the player ship is created that is why your code wasn't working Periculi try this
Code: Select all
<Events>
<OnCreate>
(block Nil
(sysAddObjTimerEvent 100 gSource "delayEvent")
)
</OnCreate>
<delayEvent>
(block Nil
(objSetData gPlayerShip "ticker" 0)
(sysAddObjRecurringTimerEvent 30 gSource "OnCheckEntry")
)
</delayEvent>
<OnCheckEntry>
(block Nil
(objIncData gPlayerShip "ticker" 1)
(objSendMessage gPlayerShip Nil (cat "Tick: " (objGetData gPlayerShip "ticker")))
)
</OnCheckEntry>
</Events>
Crying is not a proper retort!
- Periculi
- Fleet Officer
- Posts: 1282
- Joined: Sat Oct 13, 2007 7:48 pm
- Location: Necroposting in a forum near you
Wrong, Betel!
I moved the <Events> tag above the <PlayerSettings> tag and it worked like a charm! Except that the ticker was NOT continued to the next system. The delay isn't needed, but thanks for the code.
So, events should be placed inside the normal ship tag areas, before the player information for some reason. Which seems odd to me, as it is all inside the <ShipClass>, but I might have actually placed my event script in the Playersettings now that I look at the code again, I thought the tag closed earlier than it did..
I moved the <Events> tag above the <PlayerSettings> tag and it worked like a charm! Except that the ticker was NOT continued to the next system. The delay isn't needed, but thanks for the code.

So, events should be placed inside the normal ship tag areas, before the player information for some reason. Which seems odd to me, as it is all inside the <ShipClass>, but I might have actually placed my event script in the Playersettings now that I look at the code again, I thought the tag closed earlier than it did..
Last edited by Periculi on Sat Mar 08, 2008 5:45 am, edited 1 time in total.
- Betelgeuse
- Fleet Officer
- Posts: 1920
- Joined: Sun Mar 05, 2006 6:31 am
that is odd behavior
can you check if gplayer is set in the on create of the OnCreate (such as giving the player credits)
it used to not work and I am wondering if it comes from that.

can you check if gplayer is set in the on create of the OnCreate (such as giving the player credits)
it used to not work and I am wondering if it comes from that.
Crying is not a proper retort!
- Betelgeuse
- Fleet Officer
- Posts: 1920
- Joined: Sun Mar 05, 2006 6:31 am
I still would like you to test if gplayer is set 8)
that was one of the biggest reasons why we needed the delay in the first place (iirc gplayership wasn't set ether but if is it working for you then that is not a problem).
that was one of the biggest reasons why we needed the delay in the first place (iirc gplayership wasn't set ether but if is it working for you then that is not a problem).
Crying is not a proper retort!
- Periculi
- Fleet Officer
- Posts: 1282
- Joined: Sat Oct 13, 2007 7:48 pm
- Location: Necroposting in a forum near you
Code: Select all
<OnCreate>
(block Nil
(objSetData gPlayerShip "ticker" 0)
(plyCredit gPlayer 50000)
(sysAddObjRecurringTimerEvent 30 gSource "OnCheckEntry")
)
</OnCreate>

- Betelgeuse
- Fleet Officer
- Posts: 1920
- Joined: Sun Mar 05, 2006 6:31 am
hmm a different test and I find that gplayership isn't set either.
and when you later get tick from the playership it gives you 45. This isn't a hard problem to solve you can set gplayership yourself inside the onCreate
Code: Select all
<Events>
<OnCreate>
(block Nil
(objSetData gSource "tick" 45)
(objSetData gPlayerShip "tick" 50)
)
</OnCreate>
</Events>
Crying is not a proper retort!