NWNX:EE  8193.37.17
nwnx_util.nss
Go to the documentation of this file.
1 
6 const string NWNX_Util = "NWNX_Util";
7 
13 const int NWNX_UTIL_RESREF_TYPE_NSS = 2009;
14 const int NWNX_UTIL_RESREF_TYPE_NCS = 2010;
16 const int NWNX_UTIL_RESREF_TYPE_TWODA = 2017;
18 const int NWNX_UTIL_RESREF_TYPE_ITEM = 2025;
22 const int NWNX_UTIL_RESREF_TYPE_SOUND = 2035;
24 const int NWNX_UTIL_RESREF_TYPE_DOOR = 2042;
26 const int NWNX_UTIL_RESREF_TYPE_STORE = 2051;
29 
32 {
34  int nTimeOfDay;
35 };
36 
39 {
40  int seconds;
42 };
43 
48 string NWNX_Util_GetCurrentScriptName(int depth = 0);
49 
54 
58 int NWNX_Util_Hash(string str);
59 
63 
67 
71 string NWNX_Util_GetCustomToken(int customTokenNumber);
72 
76 itemproperty NWNX_Util_EffectToItemProperty(effect e);
77 
81 effect NWNX_Util_ItemPropertyToEffect(itemproperty ip);
82 
86 string NWNX_Util_StripColors(string str);
87 
91 string NWNX_Util_GetEnvironmentVariable(string sVarname);
92 
96 
99 void NWNX_Util_SetMinutesPerHour(int minutes);
100 
105 string NWNX_Util_EncodeStringForURL(string str);
106 
114 string NWNX_Util_GetFirstResRef(int nType, string sRegexFilter = "", int bModuleResourcesOnly = TRUE);
115 
118 string NWNX_Util_GetNextResRef();
119 
125 object NWNX_Util_GetLastCreatedObject(int nObjectType, int nNthLast = 1);
126 
134 string NWNX_Util_AddScript(string sFileName, string sScriptData, int bWrapIntoMain = FALSE, string sAlias = "NWNX");
135 
142 int NWNX_Util_AddNSSFile(string sFileName, string sContents, string sAlias = "NWNX");
143 
149 int NWNX_Util_RemoveNWNXResourceFile(string sFileName, int nType, string sAlias = "NWNX");
150 
153 void NWNX_Util_SetInstructionLimit(int nInstructionLimit);
154 
157 
160 void NWNX_Util_SetInstructionsExecuted(int nInstructions);
161 
164 
170 int NWNX_Util_RegisterServerConsoleCommand(string sCommand, string sScriptChunk);
171 
174 void NWNX_Util_UnregisterServerConsoleCommand(string sCommand);
175 
179 
183 
190 object NWNX_Util_CreateDoor(string sResRef, location locLocation, string sNewTag = "", int nAppearanceType = -1);
191 
194 void NWNX_Util_SetItemActivator(object oObject);
195 
201 struct NWNX_Util_WorldTime NWNX_Util_GetWorldTime(float fAdjustment = 0.0f);
202 
207 void NWNX_Util_SetResourceOverride(int nResType, string sOldName, string sNewName);
208 
213 string NWNX_Util_GetResourceOverride(int nResType, string sName);
214 
218 int NWNX_Util_GetScriptParamIsSet(string sParamName);
219 
222 void NWNX_Util_SetDawnHour(int nDawnHour);
223 
227 
230 void NWNX_Util_SetDuskHour(int nDuskHour);
231 
235 
238 
240 string NWNX_Util_GetTTY();
241 
244 void NWNX_Util_SetCurrentlyRunningEvent(int nEventID);
245 
250 int NWNX_Util_GetStringLevenshteinDistance(string sString, string sCompareTo);
251 
255 void NWNX_Util_UpdateClientObject(object oObjectToUpdate, object oPlayer = OBJECT_INVALID);
256 
261 int NWNX_Util_CleanResourceDirectory(string sAlias, int nResType = 0xFFFF);
262 
266 
270 int NWNX_Util_UpdateResourceDirectory(string sAlias);
271 
277 int NWNX_Util_SetStartingLocation(string sResRef, location locLocation, vector vDirection);
278 
281 void NWNX_Util_RawPrint(string sString);
282 
284 
285 string NWNX_Util_GetCurrentScriptName(int depth = 0)
286 {
287  NWNXPushInt(depth);
288  NWNXCall(NWNX_Util, "GetCurrentScriptName");
289  return NWNXPopString();
290 }
291 
293 {
294  NWNXCall(NWNX_Util, "GetAsciiTableString");
295  return NWNXPopString();
296 }
297 
298 int NWNX_Util_Hash(string str)
299 {
300  NWNXPushString(str);
301  NWNXCall(NWNX_Util, "Hash");
302  return NWNXPopInt();
303 }
304 
306 {
307  NWNXCall(NWNX_Util, "GetModuleMtime");
308  return NWNXPopInt();
309 }
310 
312 {
313  NWNXCall(NWNX_Util, "GetModuleFile");
314  return NWNXPopString();
315 }
316 
317 string NWNX_Util_GetCustomToken(int customTokenNumber)
318 {
319  NWNXPushInt(customTokenNumber);
320  NWNXCall(NWNX_Util, "GetCustomToken");
321  return NWNXPopString();
322 }
323 
324 itemproperty NWNX_Util_EffectToItemProperty(effect e)
325 {
326  NWNXPushEffect(e);
327  NWNXCall(NWNX_Util, "EffectTypeCast");
328  return NWNXPopItemProperty();
329 }
330 
331 effect NWNX_Util_ItemPropertyToEffect(itemproperty ip)
332 {
333  NWNXPushItemProperty(ip);
334  NWNXCall(NWNX_Util, "EffectTypeCast");
335  return NWNXPopEffect();
336 }
337 
338 string NWNX_Util_StripColors(string str)
339 {
340  NWNXPushString(str);
341  NWNXCall(NWNX_Util, "StripColors");
342  return NWNXPopString();
343 }
344 
345 string NWNX_Util_GetEnvironmentVariable(string sVarname)
346 {
347  NWNXPushString(sVarname);
348  NWNXCall(NWNX_Util, "GetEnvironmentVariable");
349  return NWNXPopString();
350 }
351 
353 {
354  NWNXCall(NWNX_Util, "GetMinutesPerHour");
355  return NWNXPopInt();
356 }
357 
359 {
360  NWNXPushInt(minutes);
361  NWNXCall(NWNX_Util, "SetMinutesPerHour");
362 }
363 
364 string NWNX_Util_EncodeStringForURL(string sURL)
365 {
366  NWNXPushString(sURL);
367  NWNXCall(NWNX_Util, "EncodeStringForURL");
368  return NWNXPopString();
369 }
370 
371 string NWNX_Util_GetFirstResRef(int nType, string sRegexFilter = "", int bModuleResourcesOnly = TRUE)
372 {
373  NWNXPushInt(bModuleResourcesOnly);
374  NWNXPushString(sRegexFilter);
375  NWNXPushInt(nType);
376  NWNXCall(NWNX_Util, "GetFirstResRef");
377  return NWNXPopString();
378 }
379 
381 {
382  NWNXCall(NWNX_Util, "GetNextResRef");
383  return NWNXPopString();
384 }
385 
386 object NWNX_Util_GetLastCreatedObject(int nObjectType, int nNthLast = 1)
387 {
388  NWNXPushInt(nNthLast);
389  NWNXPushInt(nObjectType);
390  NWNXCall(NWNX_Util, "GetLastCreatedObject");
391  return NWNXPopObject();
392 }
393 
394 string NWNX_Util_AddScript(string sFileName, string sScriptData, int bWrapIntoMain = FALSE, string sAlias = "NWNX")
395 {
396  NWNXPushString(sAlias);
397  NWNXPushInt(bWrapIntoMain);
398  NWNXPushString(sScriptData);
399  NWNXPushString(sFileName);
400  NWNXCall(NWNX_Util, "AddScript");
401  return NWNXPopString();
402 }
403 
404 int NWNX_Util_AddNSSFile(string sFileName, string sContents, string sAlias = "NWNX")
405 {
406  NWNXPushString(sAlias);
407  NWNXPushString(sContents);
408  NWNXPushString(sFileName);
409  NWNXCall(NWNX_Util, "AddNSSFile");
410  return NWNXPopInt();
411 }
412 
413 int NWNX_Util_RemoveNWNXResourceFile(string sFileName, int nType, string sAlias = "NWNX")
414 {
415  NWNXPushString(sAlias);
416  NWNXPushInt(nType);
417  NWNXPushString(sFileName);
418  NWNXCall(NWNX_Util, "RemoveNWNXResourceFile");
419  return NWNXPopInt();
420 }
421 
422 void NWNX_Util_SetInstructionLimit(int nInstructionLimit)
423 {
424  NWNXPushInt(nInstructionLimit);
425  NWNXCall(NWNX_Util, "SetInstructionLimit");
426 }
427 
429 {
430  NWNXCall(NWNX_Util, "GetInstructionLimit");
431  return NWNXPopInt();
432 }
433 
434 void NWNX_Util_SetInstructionsExecuted(int nInstructions)
435 {
436  NWNXPushInt(nInstructions);
437  NWNXCall(NWNX_Util, "SetInstructionsExecuted");
438 }
439 
441 {
442  NWNXCall(NWNX_Util, "GetInstructionsExecuted");
443  return NWNXPopInt();
444 }
445 
446 int NWNX_Util_RegisterServerConsoleCommand(string sCommand, string sScriptChunk)
447 {
448  NWNXPushString(sScriptChunk);
449  NWNXPushString(sCommand);
450  NWNXCall(NWNX_Util, "RegisterServerConsoleCommand");
451  return NWNXPopInt();
452 }
453 
455 {
456  NWNXPushString(sCommand);
457  NWNXCall(NWNX_Util, "UnregisterServerConsoleCommand");
458 }
459 
461 {
462  NWNXCall(NWNX_Util, "GetUserDirectory");
463  return NWNXPopString();
464 }
465 
467 {
468  NWNXCall(NWNX_Util, "GetScriptReturnValue");
469  return NWNXPopInt();
470 }
471 
472 object NWNX_Util_CreateDoor(string sResRef, location locLocation, string sNewTag = "", int nAppearanceType = -1)
473 {
474  NWNXPushInt(nAppearanceType);
475  NWNXPushString(sNewTag);
476  NWNXPushLocation(locLocation);
477  NWNXPushString(sResRef);
478  NWNXCall(NWNX_Util, "CreateDoor");
479  return NWNXPopObject();
480 }
481 
482 void NWNX_Util_SetItemActivator(object oObject)
483 {
484  NWNXPushObject(oObject);
485  NWNXCall(NWNX_Util, "SetItemActivator");
486 }
487 
488 struct NWNX_Util_WorldTime NWNX_Util_GetWorldTime(float fAdjustment = 0.0f)
489 {
490  NWNXPushFloat(fAdjustment);
491  NWNXCall(NWNX_Util, "GetWorldTime");
492  struct NWNX_Util_WorldTime strWorldTime;
493  strWorldTime.nTimeOfDay = NWNXPopInt();
494  strWorldTime.nCalendarDay = NWNXPopInt();
495  return strWorldTime;
496 }
497 
498 void NWNX_Util_SetResourceOverride(int nResType, string sOldName, string sNewName)
499 {
500  NWNXPushString(sNewName);
501  NWNXPushString(sOldName);
502  NWNXPushInt(nResType);
503  NWNXCall(NWNX_Util, "SetResourceOverride");
504 }
505 
506 string NWNX_Util_GetResourceOverride(int nResType, string sName)
507 {
508  NWNXPushString(sName);
509  NWNXPushInt(nResType);
510  NWNXCall(NWNX_Util, "GetResourceOverride");
511  return NWNXPopString();
512 }
513 
514 int NWNX_Util_GetScriptParamIsSet(string sParamName)
515 {
516  NWNXPushString(sParamName);
517  NWNXCall(NWNX_Util, "GetScriptParamIsSet");
518  return NWNXPopInt();
519 }
520 
521 void NWNX_Util_SetDawnHour(int nDawnHour)
522 {
523  NWNXPushInt(nDawnHour);
524  NWNXCall(NWNX_Util, "SetDawnHour");
525 }
526 
528 {
529  NWNXCall(NWNX_Util, "GetDawnHour");
530  return NWNXPopInt();
531 }
532 
533 void NWNX_Util_SetDuskHour(int nDuskHour)
534 {
535  NWNXPushInt(nDuskHour);
536  NWNXCall(NWNX_Util, "SetDuskHour");
537 }
538 
540 {
541  NWNXCall(NWNX_Util, "GetDuskHour");
542  return NWNXPopInt();
543 }
544 
546 {
548  NWNXCall(NWNX_Util, "GetHighResTimeStamp");
549  t.microseconds = NWNXPopInt();
550  t.seconds = NWNXPopInt();
551  return t;
552 }
553 
555 {
556  NWNXCall(NWNX_Util, "GetTTY");
557  return NWNXPopString();
558 }
559 
561 {
562  NWNXPushInt(nEventID);
563  NWNXCall(NWNX_Util, "SetCurrentlyRunningEvent");
564 }
565 
566 int NWNX_Util_GetStringLevenshteinDistance(string sString, string sCompareTo)
567 {
568  NWNXPushString(sCompareTo);
569  NWNXPushString(sString);
570  NWNXCall(NWNX_Util, "GetStringLevenshteinDistance");
571  return NWNXPopInt();
572 }
573 
574 void NWNX_Util_UpdateClientObject(object oObjectToUpdate, object oPlayer = OBJECT_INVALID)
575 {
576  NWNXPushObject(oPlayer);
577  NWNXPushObject(oObjectToUpdate);
578  NWNXCall(NWNX_Util, "UpdateClientObject");
579 }
580 
581 int NWNX_Util_CleanResourceDirectory(string sAlias, int nResType = 0xFFFF)
582 {
583  NWNXPushInt(nResType);
584  NWNXPushString(sAlias);
585  NWNXCall(NWNX_Util, "CleanResourceDirectory");
586  return NWNXPopInt();
587 }
588 
590 {
591  string sFunc = "GetModuleTlkFile";
592  NWNXCall(NWNX_Util, sFunc);
593  return NWNXPopString();
594 }
595 
597 {
598  NWNXPushString(sAlias);
599  NWNXCall(NWNX_Util, "UpdateResourceDirectory");
600  return NWNXPopInt();
601 }
602 
603 int NWNX_Util_SetStartingLocation(string sResRef, location locLocation, vector vDirection)
604 {
605  NWNXPushVector(vDirection);
606  NWNXPushLocation(locLocation);
607  NWNXPushString(sResRef);
608  NWNXCall(NWNX_Util, "SetStartingLocation");
609  return NWNXPopInt();
610 }
611 
612 void NWNX_Util_RawPrint(string sString)
613 {
614  NWNXPushString(sString);
615  NWNXCall(NWNX_Util, "RawPrint");
616 }
const int NWNX_UTIL_RESREF_TYPE_CREATURE
Definition: nwnx_util.nss:19
const int NWNX_UTIL_RESREF_TYPE_ITEM
Definition: nwnx_util.nss:18
string NWNX_Util_GetAsciiTableString()
Gets a string that contains the ascii table.
Definition: nwnx_util.nss:292
void NWNX_Util_UpdateClientObject(object oObjectToUpdate, object oPlayer=OBJECT_INVALID)
Sends a full object update of oObjectToUpdate to all clients.
Definition: nwnx_util.nss:574
string NWNX_Util_GetModuleFile()
Gets the module short file name.
Definition: nwnx_util.nss:311
void NWNX_Util_SetDuskHour(int nDuskHour)
Set the module dusk hour.
Definition: nwnx_util.nss:533
const int NWNX_UTIL_RESREF_TYPE_WAYPOINT
Definition: nwnx_util.nss:27
int NWNX_Util_RegisterServerConsoleCommand(string sCommand, string sScriptChunk)
Register a server console command that will execute a script chunk.
Definition: nwnx_util.nss:446
struct NWNX_Util_WorldTime NWNX_Util_GetWorldTime(float fAdjustment=0.0f)
Get the world time as calendar day and time of day.
Definition: nwnx_util.nss:488
string NWNX_Util_GetModuleTlkFile()
Return the filename of the tlk file.
Definition: nwnx_util.nss:589
string NWNX_Util_GetNextResRef()
Get the next resref.
Definition: nwnx_util.nss:380
const int NWNX_UTIL_RESREF_TYPE_TRIGGER
Definition: nwnx_util.nss:21
const int NWNX_UTIL_RESREF_TYPE_STORE
Definition: nwnx_util.nss:26
const int NWNX_UTIL_RESREF_TYPE_AREA_GIT
Definition: nwnx_util.nss:17
string NWNX_Util_StripColors(string str)
Strip any color codes from a string.
Definition: nwnx_util.nss:338
const int NWNX_UTIL_RESREF_TYPE_NSS
Definition: nwnx_util.nss:13
int NWNX_Util_GetModuleMtime()
Gets the last modified timestamp (mtime) of the module file in seconds.
Definition: nwnx_util.nss:305
object NWNX_Util_GetLastCreatedObject(int nObjectType, int nNthLast=1)
Get the last created object.
Definition: nwnx_util.nss:386
int NWNX_Util_UpdateResourceDirectory(string sAlias)
Update a resource directory by having ResMan reindex it.
Definition: nwnx_util.nss:596
string NWNX_Util_GetCustomToken(int customTokenNumber)
Gets the value of customTokenNumber.
Definition: nwnx_util.nss:317
string NWNX_Util_EncodeStringForURL(string str)
Encodes a string for usage in a URL.
Definition: nwnx_util.nss:364
int NWNX_Util_RemoveNWNXResourceFile(string sFileName, int nType, string sAlias="NWNX")
Remove sFileName of nType from the UserDirectory/nwnx folder, or from the location of sAlias.
Definition: nwnx_util.nss:413
int NWNX_Util_Hash(string str)
Gets an integer hash of a string.
Definition: nwnx_util.nss:298
const int NWNX_UTIL_RESREF_TYPE_AREA_ARE
Definition: nwnx_util.nss:15
int NWNX_Util_GetStringLevenshteinDistance(string sString, string sCompareTo)
Calculate the levenshtein distance of two strings.
Definition: nwnx_util.nss:566
const int NWNX_UTIL_RESREF_TYPE_ENCOUNTER
Definition: nwnx_util.nss:23
int NWNX_Util_GetInstructionsExecuted()
Get the number of NWScript instructions currently executed.
Definition: nwnx_util.nss:440
int NWNX_Util_GetDawnHour()
Get the module dawn hour.
Definition: nwnx_util.nss:527
const int NWNX_UTIL_RESREF_TYPE_DOOR
Definition: nwnx_util.nss:24
const int NWNX_UTIL_RESREF_TYPE_DIALOG
Definition: nwnx_util.nss:20
int NWNX_Util_GetScriptParamIsSet(string sParamName)
Get if a script param is set.
Definition: nwnx_util.nss:514
itemproperty NWNX_Util_EffectToItemProperty(effect e)
Convert an effect type to an itemproperty type.
Definition: nwnx_util.nss:324
object NWNX_Util_CreateDoor(string sResRef, location locLocation, string sNewTag="", int nAppearanceType=-1)
Create a door.
Definition: nwnx_util.nss:472
int NWNX_Util_GetInstructionLimit()
Get the NWScript instruction limit.
Definition: nwnx_util.nss:428
void NWNX_Util_SetResourceOverride(int nResType, string sOldName, string sNewName)
Set a server-side resource override.
Definition: nwnx_util.nss:498
string NWNX_Util_GetCurrentScriptName(int depth=0)
Gets the name of the currently executing script.
Definition: nwnx_util.nss:285
int NWNX_Util_GetScriptReturnValue()
Get the return value of the last run script with a StartingConditional.
Definition: nwnx_util.nss:466
const int NWNX_UTIL_RESREF_TYPE_TWODA
Definition: nwnx_util.nss:16
void NWNX_Util_SetCurrentlyRunningEvent(int nEventID)
Set the currently running script event.
Definition: nwnx_util.nss:560
string NWNX_Util_GetEnvironmentVariable(string sVarname)
Retrieves an environment variable.
Definition: nwnx_util.nss:345
struct NWNX_Util_HighResTimestamp NWNX_Util_GetHighResTimeStamp()
Definition: nwnx_util.nss:545
int NWNX_Util_AddNSSFile(string sFileName, string sContents, string sAlias="NWNX")
Adds a nss file to the UserDirectory/nwnx folder, or to the location of sAlias.
Definition: nwnx_util.nss:404
void NWNX_Util_SetMinutesPerHour(int minutes)
Set module real life minutes per in game hour.
Definition: nwnx_util.nss:358
int NWNX_Util_CleanResourceDirectory(string sAlias, int nResType=0xFFFF)
Clean a resource directory, deleting all files of nResType.
Definition: nwnx_util.nss:581
string NWNX_Util_GetUserDirectory()
Gets the server's current working user folder.
Definition: nwnx_util.nss:460
string NWNX_Util_AddScript(string sFileName, string sScriptData, int bWrapIntoMain=FALSE, string sAlias="NWNX")
Compiles and adds a script to the UserDirectory/nwnx folder, or to the location of sAlias.
Definition: nwnx_util.nss:394
void NWNX_Util_SetDawnHour(int nDawnHour)
Set the module dawn hour.
Definition: nwnx_util.nss:521
int NWNX_Util_GetDuskHour()
Get the module dusk hour.
Definition: nwnx_util.nss:539
const int NWNX_UTIL_RESREF_TYPE_NCS
Definition: nwnx_util.nss:14
int NWNX_Util_SetStartingLocation(string sResRef, location locLocation, vector vDirection)
Set the starting location.
Definition: nwnx_util.nss:603
void NWNX_Util_SetInstructionLimit(int nInstructionLimit)
Set the NWScript instruction limit.
Definition: nwnx_util.nss:422
effect NWNX_Util_ItemPropertyToEffect(itemproperty ip)
Convert an itemproperty type to an effect type.
Definition: nwnx_util.nss:331
void NWNX_Util_SetInstructionsExecuted(int nInstructions)
Set the number of NWScript instructions currently executed.
Definition: nwnx_util.nss:434
string NWNX_Util_GetFirstResRef(int nType, string sRegexFilter="", int bModuleResourcesOnly=TRUE)
Get the first resref of nType.
Definition: nwnx_util.nss:371
string NWNX_Util_GetTTY()
Definition: nwnx_util.nss:554
const int NWNX_UTIL_RESREF_TYPE_SOUND
Definition: nwnx_util.nss:22
void NWNX_Util_UnregisterServerConsoleCommand(string sCommand)
Unregister a server console command that was registered with NWNX_Util_RegisterServerConsoleCommand()...
Definition: nwnx_util.nss:454
string NWNX_Util_GetResourceOverride(int nResType, string sName)
Get a server-side resource override.
Definition: nwnx_util.nss:506
int NWNX_Util_GetMinutesPerHour()
Gets the module real life minutes per in game hour.
Definition: nwnx_util.nss:352
void NWNX_Util_SetItemActivator(object oObject)
Set the object that will be returned by GetItemActivator.
Definition: nwnx_util.nss:482
void NWNX_Util_RawPrint(string sString)
Print a string with no log decorations.
Definition: nwnx_util.nss:612
const int NWNX_UTIL_RESREF_TYPE_PLACEABLE
Definition: nwnx_util.nss:25
A high resolution timestamp.
Definition: nwnx_util.nss:39
int microseconds
Microseconds.
Definition: nwnx_util.nss:41
int seconds
Seconds since epoch.
Definition: nwnx_util.nss:40
A world time struct.
Definition: nwnx_util.nss:32
int nTimeOfDay
The time of day.
Definition: nwnx_util.nss:34
int nCalendarDay
The calendar day.
Definition: nwnx_util.nss:33