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