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 
280 
281 string NWNX_Util_GetCurrentScriptName(int depth = 0)
282 {
283  NWNXPushInt(depth);
284  NWNXCall(NWNX_Util, "GetCurrentScriptName");
285  return NWNXPopString();
286 }
287 
289 {
290  NWNXCall(NWNX_Util, "GetAsciiTableString");
291  return NWNXPopString();
292 }
293 
294 int NWNX_Util_Hash(string str)
295 {
296  NWNXPushString(str);
297  NWNXCall(NWNX_Util, "Hash");
298  return NWNXPopInt();
299 }
300 
302 {
303  NWNXCall(NWNX_Util, "GetModuleMtime");
304  return NWNXPopInt();
305 }
306 
308 {
309  NWNXCall(NWNX_Util, "GetModuleFile");
310  return NWNXPopString();
311 }
312 
313 string NWNX_Util_GetCustomToken(int customTokenNumber)
314 {
315  NWNXPushInt(customTokenNumber);
316  NWNXCall(NWNX_Util, "GetCustomToken");
317  return NWNXPopString();
318 }
319 
320 itemproperty NWNX_Util_EffectToItemProperty(effect e)
321 {
322  NWNXPushEffect(e);
323  NWNXCall(NWNX_Util, "EffectTypeCast");
324  return NWNXPopItemProperty();
325 }
326 
327 effect NWNX_Util_ItemPropertyToEffect(itemproperty ip)
328 {
329  NWNXPushItemProperty(ip);
330  NWNXCall(NWNX_Util, "EffectTypeCast");
331  return NWNXPopEffect();
332 }
333 
334 string NWNX_Util_StripColors(string str)
335 {
336  NWNXPushString(str);
337  NWNXCall(NWNX_Util, "StripColors");
338  return NWNXPopString();
339 }
340 
341 string NWNX_Util_GetEnvironmentVariable(string sVarname)
342 {
343  NWNXPushString(sVarname);
344  NWNXCall(NWNX_Util, "GetEnvironmentVariable");
345  return NWNXPopString();
346 }
347 
349 {
350  NWNXCall(NWNX_Util, "GetMinutesPerHour");
351  return NWNXPopInt();
352 }
353 
355 {
356  NWNXPushInt(minutes);
357  NWNXCall(NWNX_Util, "SetMinutesPerHour");
358 }
359 
360 string NWNX_Util_EncodeStringForURL(string sURL)
361 {
362  NWNXPushString(sURL);
363  NWNXCall(NWNX_Util, "EncodeStringForURL");
364  return NWNXPopString();
365 }
366 
367 string NWNX_Util_GetFirstResRef(int nType, string sRegexFilter = "", int bModuleResourcesOnly = TRUE)
368 {
369  NWNXPushInt(bModuleResourcesOnly);
370  NWNXPushString(sRegexFilter);
371  NWNXPushInt(nType);
372  NWNXCall(NWNX_Util, "GetFirstResRef");
373  return NWNXPopString();
374 }
375 
377 {
378  NWNXCall(NWNX_Util, "GetNextResRef");
379  return NWNXPopString();
380 }
381 
382 object NWNX_Util_GetLastCreatedObject(int nObjectType, int nNthLast = 1)
383 {
384  NWNXPushInt(nNthLast);
385  NWNXPushInt(nObjectType);
386  NWNXCall(NWNX_Util, "GetLastCreatedObject");
387  return NWNXPopObject();
388 }
389 
390 string NWNX_Util_AddScript(string sFileName, string sScriptData, int bWrapIntoMain = FALSE, string sAlias = "NWNX")
391 {
392  NWNXPushString(sAlias);
393  NWNXPushInt(bWrapIntoMain);
394  NWNXPushString(sScriptData);
395  NWNXPushString(sFileName);
396  NWNXCall(NWNX_Util, "AddScript");
397  return NWNXPopString();
398 }
399 
400 int NWNX_Util_AddNSSFile(string sFileName, string sContents, string sAlias = "NWNX")
401 {
402  NWNXPushString(sAlias);
403  NWNXPushString(sContents);
404  NWNXPushString(sFileName);
405  NWNXCall(NWNX_Util, "AddNSSFile");
406  return NWNXPopInt();
407 }
408 
409 int NWNX_Util_RemoveNWNXResourceFile(string sFileName, int nType, string sAlias = "NWNX")
410 {
411  NWNXPushString(sAlias);
412  NWNXPushInt(nType);
413  NWNXPushString(sFileName);
414  NWNXCall(NWNX_Util, "RemoveNWNXResourceFile");
415  return NWNXPopInt();
416 }
417 
418 void NWNX_Util_SetInstructionLimit(int nInstructionLimit)
419 {
420  NWNXPushInt(nInstructionLimit);
421  NWNXCall(NWNX_Util, "SetInstructionLimit");
422 }
423 
425 {
426  NWNXCall(NWNX_Util, "GetInstructionLimit");
427  return NWNXPopInt();
428 }
429 
430 void NWNX_Util_SetInstructionsExecuted(int nInstructions)
431 {
432  NWNXPushInt(nInstructions);
433  NWNXCall(NWNX_Util, "SetInstructionsExecuted");
434 }
435 
437 {
438  NWNXCall(NWNX_Util, "GetInstructionsExecuted");
439  return NWNXPopInt();
440 }
441 
442 int NWNX_Util_RegisterServerConsoleCommand(string sCommand, string sScriptChunk)
443 {
444  NWNXPushString(sScriptChunk);
445  NWNXPushString(sCommand);
446  NWNXCall(NWNX_Util, "RegisterServerConsoleCommand");
447  return NWNXPopInt();
448 }
449 
451 {
452  NWNXPushString(sCommand);
453  NWNXCall(NWNX_Util, "UnregisterServerConsoleCommand");
454 }
455 
457 {
458  NWNXCall(NWNX_Util, "GetUserDirectory");
459  return NWNXPopString();
460 }
461 
463 {
464  NWNXCall(NWNX_Util, "GetScriptReturnValue");
465  return NWNXPopInt();
466 }
467 
468 object NWNX_Util_CreateDoor(string sResRef, location locLocation, string sNewTag = "", int nAppearanceType = -1)
469 {
470  NWNXPushInt(nAppearanceType);
471  NWNXPushString(sNewTag);
472  NWNXPushLocation(locLocation);
473  NWNXPushString(sResRef);
474  NWNXCall(NWNX_Util, "CreateDoor");
475  return NWNXPopObject();
476 }
477 
478 void NWNX_Util_SetItemActivator(object oObject)
479 {
480  NWNXPushObject(oObject);
481  NWNXCall(NWNX_Util, "SetItemActivator");
482 }
483 
484 struct NWNX_Util_WorldTime NWNX_Util_GetWorldTime(float fAdjustment = 0.0f)
485 {
486  NWNXPushFloat(fAdjustment);
487  NWNXCall(NWNX_Util, "GetWorldTime");
488  struct NWNX_Util_WorldTime strWorldTime;
489  strWorldTime.nTimeOfDay = NWNXPopInt();
490  strWorldTime.nCalendarDay = NWNXPopInt();
491  return strWorldTime;
492 }
493 
494 void NWNX_Util_SetResourceOverride(int nResType, string sOldName, string sNewName)
495 {
496  NWNXPushString(sNewName);
497  NWNXPushString(sOldName);
498  NWNXPushInt(nResType);
499  NWNXCall(NWNX_Util, "SetResourceOverride");
500 }
501 
502 string NWNX_Util_GetResourceOverride(int nResType, string sName)
503 {
504  NWNXPushString(sName);
505  NWNXPushInt(nResType);
506  NWNXCall(NWNX_Util, "GetResourceOverride");
507  return NWNXPopString();
508 }
509 
510 int NWNX_Util_GetScriptParamIsSet(string sParamName)
511 {
512  NWNXPushString(sParamName);
513  NWNXCall(NWNX_Util, "GetScriptParamIsSet");
514  return NWNXPopInt();
515 }
516 
517 void NWNX_Util_SetDawnHour(int nDawnHour)
518 {
519  NWNXPushInt(nDawnHour);
520  NWNXCall(NWNX_Util, "SetDawnHour");
521 }
522 
524 {
525  NWNXCall(NWNX_Util, "GetDawnHour");
526  return NWNXPopInt();
527 }
528 
529 void NWNX_Util_SetDuskHour(int nDuskHour)
530 {
531  NWNXPushInt(nDuskHour);
532  NWNXCall(NWNX_Util, "SetDuskHour");
533 }
534 
536 {
537  NWNXCall(NWNX_Util, "GetDuskHour");
538  return NWNXPopInt();
539 }
540 
542 {
544  NWNXCall(NWNX_Util, "GetHighResTimeStamp");
545  t.microseconds = NWNXPopInt();
546  t.seconds = NWNXPopInt();
547  return t;
548 }
549 
551 {
552  NWNXCall(NWNX_Util, "GetTTY");
553  return NWNXPopString();
554 }
555 
557 {
558  NWNXPushInt(nEventID);
559  NWNXCall(NWNX_Util, "SetCurrentlyRunningEvent");
560 }
561 
562 int NWNX_Util_GetStringLevenshteinDistance(string sString, string sCompareTo)
563 {
564  NWNXPushString(sCompareTo);
565  NWNXPushString(sString);
566  NWNXCall(NWNX_Util, "GetStringLevenshteinDistance");
567  return NWNXPopInt();
568 }
569 
570 void NWNX_Util_UpdateClientObject(object oObjectToUpdate, object oPlayer = OBJECT_INVALID)
571 {
572  NWNXPushObject(oPlayer);
573  NWNXPushObject(oObjectToUpdate);
574  NWNXCall(NWNX_Util, "UpdateClientObject");
575 }
576 
577 int NWNX_Util_CleanResourceDirectory(string sAlias, int nResType = 0xFFFF)
578 {
579  NWNXPushInt(nResType);
580  NWNXPushString(sAlias);
581  NWNXCall(NWNX_Util, "CleanResourceDirectory");
582  return NWNXPopInt();
583 }
584 
586 {
587  string sFunc = "GetModuleTlkFile";
588  NWNXCall(NWNX_Util, sFunc);
589  return NWNXPopString();
590 }
591 
593 {
594  NWNXPushString(sAlias);
595  NWNXCall(NWNX_Util, "UpdateResourceDirectory");
596  return NWNXPopInt();
597 }
598 
599 int NWNX_Util_SetStartingLocation(string sResRef, location locLocation, vector vDirection)
600 {
601  NWNXPushVector(vDirection);
602  NWNXPushLocation(locLocation);
603  NWNXPushString(sResRef);
604  NWNXCall(NWNX_Util, "SetStartingLocation");
605  return NWNXPopInt();
606 }
607 
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:288
void NWNX_Util_UpdateClientObject(object oObjectToUpdate, object oPlayer=OBJECT_INVALID)
Sends a full object update of oObjectToUpdate to all clients.
Definition: nwnx_util.nss:570
string NWNX_Util_GetModuleFile()
Gets the module short file name.
Definition: nwnx_util.nss:307
void NWNX_Util_SetDuskHour(int nDuskHour)
Set the module dusk hour.
Definition: nwnx_util.nss:529
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:442
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:484
string NWNX_Util_GetModuleTlkFile()
Return the filename of the tlk file.
Definition: nwnx_util.nss:585
string NWNX_Util_GetNextResRef()
Get the next resref.
Definition: nwnx_util.nss:376
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:334
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:301
object NWNX_Util_GetLastCreatedObject(int nObjectType, int nNthLast=1)
Get the last created object.
Definition: nwnx_util.nss:382
int NWNX_Util_UpdateResourceDirectory(string sAlias)
Update a resource directory by having ResMan reindex it.
Definition: nwnx_util.nss:592
string NWNX_Util_GetCustomToken(int customTokenNumber)
Gets the value of customTokenNumber.
Definition: nwnx_util.nss:313
string NWNX_Util_EncodeStringForURL(string str)
Encodes a string for usage in a URL.
Definition: nwnx_util.nss:360
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:409
int NWNX_Util_Hash(string str)
Gets an integer hash of a string.
Definition: nwnx_util.nss:294
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:562
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:436
int NWNX_Util_GetDawnHour()
Get the module dawn hour.
Definition: nwnx_util.nss:523
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:510
itemproperty NWNX_Util_EffectToItemProperty(effect e)
Convert an effect type to an itemproperty type.
Definition: nwnx_util.nss:320
object NWNX_Util_CreateDoor(string sResRef, location locLocation, string sNewTag="", int nAppearanceType=-1)
Create a door.
Definition: nwnx_util.nss:468
int NWNX_Util_GetInstructionLimit()
Get the NWScript instruction limit.
Definition: nwnx_util.nss:424
void NWNX_Util_SetResourceOverride(int nResType, string sOldName, string sNewName)
Set a server-side resource override.
Definition: nwnx_util.nss:494
string NWNX_Util_GetCurrentScriptName(int depth=0)
Gets the name of the currently executing script.
Definition: nwnx_util.nss:281
int NWNX_Util_GetScriptReturnValue()
Get the return value of the last run script with a StartingConditional.
Definition: nwnx_util.nss:462
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:556
string NWNX_Util_GetEnvironmentVariable(string sVarname)
Retrieves an environment variable.
Definition: nwnx_util.nss:341
struct NWNX_Util_HighResTimestamp NWNX_Util_GetHighResTimeStamp()
Definition: nwnx_util.nss:541
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:400
void NWNX_Util_SetMinutesPerHour(int minutes)
Set module real life minutes per in game hour.
Definition: nwnx_util.nss:354
int NWNX_Util_CleanResourceDirectory(string sAlias, int nResType=0xFFFF)
Clean a resource directory, deleting all files of nResType.
Definition: nwnx_util.nss:577
string NWNX_Util_GetUserDirectory()
Gets the server's current working user folder.
Definition: nwnx_util.nss:456
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:390
void NWNX_Util_SetDawnHour(int nDawnHour)
Set the module dawn hour.
Definition: nwnx_util.nss:517
int NWNX_Util_GetDuskHour()
Get the module dusk hour.
Definition: nwnx_util.nss:535
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:599
void NWNX_Util_SetInstructionLimit(int nInstructionLimit)
Set the NWScript instruction limit.
Definition: nwnx_util.nss:418
effect NWNX_Util_ItemPropertyToEffect(itemproperty ip)
Convert an itemproperty type to an effect type.
Definition: nwnx_util.nss:327
void NWNX_Util_SetInstructionsExecuted(int nInstructions)
Set the number of NWScript instructions currently executed.
Definition: nwnx_util.nss:430
string NWNX_Util_GetFirstResRef(int nType, string sRegexFilter="", int bModuleResourcesOnly=TRUE)
Get the first resref of nType.
Definition: nwnx_util.nss:367
string NWNX_Util_GetTTY()
Definition: nwnx_util.nss:550
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:450
string NWNX_Util_GetResourceOverride(int nResType, string sName)
Get a server-side resource override.
Definition: nwnx_util.nss:502
int NWNX_Util_GetMinutesPerHour()
Gets the module real life minutes per in game hour.
Definition: nwnx_util.nss:348
void NWNX_Util_SetItemActivator(object oObject)
Set the object that will be returned by GetItemActivator.
Definition: nwnx_util.nss:478
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