Aller au contenu

Photo

Scripting theory: how fast can a script repeat


  • Veuillez vous connecter pour répondre
3 réponses à ce sujet

#1
Eguintir Eligard

Eguintir Eligard
  • Members
  • 1 832 messages
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?

#2
Lathaon

Lathaon
  • Members
  • 163 messages
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.

#3
FergusM

FergusM
  • Members
  • 460 messages
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
Eguintir Eligard

Eguintir Eligard
  • Members
  • 1 832 messages
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!