I'm trying to find out if my module idea is possible, by having dissapearing and reappearing platforms.
In nwn2 for example, 6 seconds was how fast a heartbeat was and therefore how fast you make this happen.
How fast could I make things dissapear/reappear in this engine however, how precise can it be time wise?
Scripting theory: how fast can a script repeat
Débuté par
Eguintir Eligard
, août 31 2010 08:43
#1
Posté 31 août 2010 - 08:43
#2
Posté 31 août 2010 - 10:12
Use DelayEvent. You can choose the interval.
You could start it going in the area script with a line like this:
HandleEvent(Event(EVENT_TYPE_CUSTOM_EVENT_01), R"<yourscript>.ncs");
Then in <yourscript>.ncs:
event ev = GetCurrentEvent();
float fInterval = <insert interval here>;
if (GetEventType(ev) == EVENT_TYPE_CUSTOM_EVENT_01) {
// put some code here to make it disappear
DelayEvent(fDelay, OBJECT_SELF, EVENT_TYPE_CUSTOM_EVENT_02, "<yourscript>.ncs");
} else {
// put some code here to make it reappear
DelayEvent(fDelay, OBJECT_SELF, EVENT_TYPE_CUSTOM_EVENT_01, "<yourscript>.ncs");
}
So it just alternates between a disappear event and a reappear event every fInterval seconds. I don't know what code you'd use to actually do the stuff... if it's just a matter of setting a placeable active or inactive then you could just use an event integer rather than two separate events...
Hope this helps.
You could start it going in the area script with a line like this:
HandleEvent(Event(EVENT_TYPE_CUSTOM_EVENT_01), R"<yourscript>.ncs");
Then in <yourscript>.ncs:
event ev = GetCurrentEvent();
float fInterval = <insert interval here>;
if (GetEventType(ev) == EVENT_TYPE_CUSTOM_EVENT_01) {
// put some code here to make it disappear
DelayEvent(fDelay, OBJECT_SELF, EVENT_TYPE_CUSTOM_EVENT_02, "<yourscript>.ncs");
} else {
// put some code here to make it reappear
DelayEvent(fDelay, OBJECT_SELF, EVENT_TYPE_CUSTOM_EVENT_01, "<yourscript>.ncs");
}
So it just alternates between a disappear event and a reappear event every fInterval seconds. I don't know what code you'd use to actually do the stuff... if it's just a matter of setting a placeable active or inactive then you could just use an event integer rather than two separate events...
Hope this helps.
#3
Posté 31 août 2010 - 10:17
Any time you like. Using InitHeartbeat(object,decimalTimeInSeconds) or DelayEvent(decimalTimeInSeconds,event,object), you can specify 0.1 seconds, 10.0 seconds, etc. The former will repeat a EVENT_TYPE_HEARTBEAT2 event on the object it is used on, while the latter will fire a single event of whatever type (though you could set up the script handling this to send another delay event, etc.).
#4
Posté 31 août 2010 - 10:31
Hmm not quite sure I understand all of this but I will see when I actually do the script if it comes together. The high precision time is awesome! Arcade style platform sprints there will be!





Retour en haut







