MCPcopy Create free account
hub / github.com/MaxBittker/rs-sdk / executeScript

Method executeScript

server/engine/src/engine/entity/Npc.ts:217–240  ·  view source on GitHub ↗
(script: ScriptState)

Source from the content-addressed store, hash-verified

215 }
216
217 executeScript(script: ScriptState) {
218 const state = ScriptRunner.execute(script);
219 if (state !== ScriptState.FINISHED && state !== ScriptState.ABORTED) {
220 if (state === ScriptState.WORLD_SUSPENDED) {
221 World.enqueueScript(script, script.popInt());
222 } else if (state === ScriptState.NPC_SUSPENDED) {
223 script.activeNpc.activeScript = script;
224 } else {
225 script.activePlayer.activeScript = script;
226 }
227 } else if (script === this.activeScript) {
228 this.activeScript = null;
229 }
230
231 if (script.pointerGet(ScriptPointer.ProtectedActivePlayer) && script._activePlayer) {
232 script._activePlayer.protect = false;
233 script.pointerRemove(ScriptPointer.ProtectedActivePlayer);
234 }
235
236 if (script.pointerGet(ScriptPointer.ProtectedActivePlayer2) && script._activePlayer2) {
237 script._activePlayer2.protect = false;
238 script.pointerRemove(ScriptPointer.ProtectedActivePlayer2);
239 }
240 }
241
242 enqueueScript(queueId: number, delay = 0, arg: number = 0) {
243 const request = new NpcQueueRequest(queueId, [], delay);

Callers 15

turnMethod · 0.95
processTimersMethod · 0.95
processQueueMethod · 0.95
tryInteractMethod · 0.95
handleMethod · 0.45
handleMethod · 0.45
handleMethod · 0.45
handleMethod · 0.45
handleMethod · 0.45
handleMethod · 0.45
handleMethod · 0.45
handleMethod · 0.45

Calls 5

popIntMethod · 0.80
pointerGetMethod · 0.80
pointerRemoveMethod · 0.80
executeMethod · 0.45
enqueueScriptMethod · 0.45

Tested by

no test coverage detected