Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
enscript.c
Go to the documentation of this file.
1
10class Class
11{
23 proto native external bool IsInherited(typename type);
24
37 proto native owned external string ClassName();
38
39 string GetDebugName() { return ClassName(); }
40
52 proto native external typename Type();
53
64 proto external static typename StaticType();
65
73 static typename StaticGetType(typename t)
74 {
75 return t;
76 }
77
78 proto external string ToString();
79
94 proto static Class Cast(Class from);
95
110 proto static bool CastTo(out Class to, Class from);
111
113 private proto static bool SafeCastType(Class type, out Class to, Class from);
114};
115
118{
119};
120
123{
124};
125
127typedef int[] TypeID;
128
131{
132 private void ~ScriptModule();
133
139 proto volatile int Call(Class inst, string function, void parm);
140
146 proto volatile int CallFunction(Class inst, string function, out void returnVal, void parm);
147 proto volatile int CallFunctionParams(Class inst, string function, out void returnVal, Class parms);
148 proto native void Release();
149
160 static proto native ScriptModule LoadScript(ScriptModule parentModule, string scriptFile, bool listing);
161};
162
163//main script module (contains script.c and this file)
164//ScriptModule g_Script;
165
167{
168 private void EnScript() {}
169 private void ~EnScript() {}
170
188 static proto int GetClassVar(Class inst, string varname,int index, out void result);
189
211 static proto int SetClassVar(Class inst, string varname, int index, void input);
212
222 static proto int SetVar(out void var, string value);
223
230 static proto void Watch(void var, int flags);
231};
232
233
234
253proto void Sort(void param_array[], int num);
254proto void reversearray(void param_array);
255proto void copyarray(void destArray, void srcArray);
256
287proto int ParseStringEx(inout string input, string token);
288
307proto int ParseString(string input, out string tokens[]);
308
318proto native int KillThread(Class owner, string name);
319
323proto volatile void Idle();
324
336proto owned string ThreadFunction(Class owner, string name, int backtrace, out int linenumber);
337
339string String(string s)
340{
341 return s;
342}
343
360{
361 string m_Msg;
362 void Obsolete(string msg = "")
363 {
364 m_Msg = msg;
365 }
366}
367
369void PrintString(string s)
372}
373
374class array<Class T>
375{
380 proto native int Count();
385 proto native void Clear();
389 proto void Set(int n, T value);
394 proto int Find(T value);
399 proto T Get(int n);
407 proto int Insert(T value);
418 proto int InsertAt(T value, int index);
449 void InsertAll(notnull array<T> from)
450 {
451 for ( int i = 0; i < from.Count(); i++ )
452 {
453 Insert( from.Get(i) );
454 }
455 }
462 proto native void Remove(int index);
469 proto native void RemoveOrdered(int index);
475 proto native void Resize(int newSize);
476
481 proto native void Reserve(int newSize);
482
487 proto native void Swap(notnull array<T> other);
488
492 proto native void Sort(bool reverse = false);
498 proto int Copy(notnull array<T> from);
499 proto int Init(T init[]);
500
501 void RemoveItem(T value)
502 {
503 int remove_index = Find(value);
504
505 if ( remove_index >= 0 )
506 {
507 RemoveOrdered(remove_index);
508 }
509 }
510
511 void RemoveItemUnOrdered(T value)
512 {
513 int remove_index = Find(value);
514
515 if ( remove_index >= 0 )
516 {
517 Remove(remove_index);
518 }
519 }
520
521 bool IsValidIndex( int index )
522 {
523 return ( index > -1 && index < Count() );
524 }
525
526 /*
527 T GetChecked( int index )
528 {
529 if( IsValidIndex( index ) )
530 return Get( index );
531 else
532 return null;
533 }
534 */
535
547 void Debug()
548 {
549 Print(string.Format("Array count: %1", Count()));
550 for (int i = 0; i < Count(); i++)
551 {
552 T item = Get(i);
553 Print(string.Format("[%1] => %2", i, item));
554 }
555 }
556
566 int GetRandomIndex()
567 {
568 if ( Count() > 0 )
569 {
570 return Math.RandomInt(0, Count());
571 }
572
573 return -1;
574 }
575
585 T GetRandomElement()
586 {
587 return Get(GetRandomIndex());
588 }
589
590 void SwapItems(int item1_index, int item2_index)
591 {
592 T item1 = Get(item1_index);
593 Set(item1_index, Get(item2_index));
594 Set(item2_index, item1);
595 }
596
597 void InsertArray(array<T> other)
598 {
599 for (int i = 0; i < other.Count(); i++)
600 {
601 T item = other.Get(i);
602 Insert(item);
603 }
604 }
605
606 void Invert()
607 {
608 int left = 0;
609 int right = Count() - 1;
610 if (right > 0)
611 {
612 while (left < right)
613 {
614 T temp = Get(left);
615 Set(left++, Get(right));
616 Set(right--, temp);
617 }
618 }
619 }
620
634 int MoveIndex(int curr_index, int move_number)
635 {
636 int count = Count();
637 int new_index = curr_index;
638
639 if ( move_number > 0 )
640 {
641 new_index = curr_index + move_number;
642 }
643
644 if ( move_number < 0 )
645 {
646 new_index = curr_index - move_number;
647
648 if ( new_index < 0 )
649 {
650 if ( new_index <= -count )
651 {
652 new_index = (new_index % count);
653 }
654
655 new_index = new_index + count;
656 }
657 }
658
659 if ( new_index >= count )
660 {
661 new_index = (new_index % count);
662 }
663
664 // move_number is 0
665 return new_index;
666 }
667
668 void ShuffleArray()
669 {
670 for (int i = 0; i < Count(); i++)
671 {
672 SwapItems(i,GetRandomIndex());
673 }
674 }
675
688 int DifferentAtPosition(array<T> pOtherArray)
689 {
690 if (Count() != pOtherArray.Count())
691 {
692 ErrorEx("arrays are not the same size");
693 return -1;
694 }
695
696 for (int i = 0; i < pOtherArray.Count(); ++i)
697 {
698 if (Get(i) != pOtherArray.Get(i))
699 {
700 return i;
701 }
702 }
703
704 return -1;
705 }
707
708//force these to compile so we can link C++ methods to them
718
719class set<Class T>
720{
721 proto native int Count();
722 proto native void Clear();
727 proto int Find(T value);
728 proto T Get(int n);
736 proto int Insert(T value);
747 proto int InsertAt(T value, int index);
753 proto native void Remove(int index);
754 proto int Copy(set<T> from);
755 proto native void Swap(set<T> other);
756 proto int Init(T init[]);
757
758 void InsertSet(set<T> other)
759 {
760 int count = other.Count();
761 for (int i = 0; i < count; i++)
762 {
763 T item = other[i];
764 Insert(item);
765 }
766 }
767
768 void RemoveItem(T value)
769 {
770 int remove_index = Find(value);
771 if (remove_index >= 0)
772 {
773 Remove(remove_index);
774 }
775 }
776
777 void RemoveItems(set<T> other)
778 {
779 int count = other.Count();
780 for (int i = 0; i < count; i++)
781 {
782 T item = other[i];
783 RemoveItem(item);
784 }
785 }
786
787 void Debug()
788 {
789 Print(string.Format("Set count: %1", Count()));
790 for (int i = 0; i < Count(); i++)
791 {
792 T item = Get(i);
793 Print(string.Format("[%1] => %2", i, item));
794 }
795 }
796};
797
798//force these to compile so we can link C++ methods to them
799typedef set<string> TStringSet;
800typedef set<float> TFloatSet;
801typedef set<int> TIntSet;
802typedef set<Class> TClassSet;
803typedef set<Managed> TManagedSet;
804typedef set<ref Managed> TManagedRefSet;
805typedef set<typename> TTypenameSet;
806
807typedef int MapIterator;
824class map<Class TKey,Class TValue>
825{
830 proto native int Count();
831
835 proto native void Clear();
844 proto TValue Get(TKey key);
855 proto bool Find(TKey key, out TValue val);
865 proto TValue GetElement(int index);
875 proto TKey GetKey(int i);
880 proto void Set(TKey key, TValue value);
884 proto void Remove(TKey key);
891 proto void RemoveElement(int i);
895 proto bool Contains(TKey key);
904 proto bool Insert(TKey key, TValue value);
905 proto int Copy(map<TKey,TValue> from);
906
907 array<TKey> GetKeyArray()
908 {
909 array<TKey> keys = new array<TKey>;
910 for (int i = 0; i < Count(); i++)
911 {
912 keys.Insert( GetKey( i ) );
913 }
914 return keys;
915 }
916
917 array<TValue> GetValueArray()
918 {
919 array<TValue> elements = new array<TValue>;
920 for (int i = 0; i < Count(); i++)
921 {
922 elements.Insert( GetElement( i ) );
923 }
924 return elements;
925 }
926
927 bool ReplaceKey(TKey old_key, TKey new_key)
928 {
929 if (Contains(old_key))
930 {
931 Set(new_key, Get(old_key));
932 Remove(old_key);
933 return true;
934 }
935 return false;
936 }
937
938 TKey GetKeyByValue(TValue value)
939 {
940 TKey ret;
941 for (int i = 0; i < Count(); i++)
942 {
943 if (GetElement(i) == value)
944 {
945 ret = GetKey(i);
946 break;
947 }
948 }
949
950 return ret;
951 }
952
953 bool GetKeyByValueChecked(TValue value, out TKey key)
954 {
955 for (int i = 0; i < Count(); i++)
956 {
957 if (GetElement(i) == value)
958 {
959 key = GetKey(i);
960 return true;
961 }
962 }
963 return false;
964 }
965
966 proto native MapIterator Begin();
967 proto native MapIterator End();
968 proto native MapIterator Next(MapIterator it);
969 proto TKey GetIteratorKey(MapIterator it);
970 proto TValue GetIteratorElement(MapIterator it);
971};
972
981
990
999
1008
1017
1026
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Super root of all classes in Enforce script.
Definition enscript.c:11
TODO doc.
Definition enscript.c:118
Definition enmath.c:7
TODO doc.
Definition enscript.c:123
Module containing compiled scripts.
Definition enscript.c:131
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
override Widget Init()
Definition dayzgame.c:127
DisplayElementBase GetElement(eDisplayElements element_id)
void End()
called on surrender end request end
proto void Print(void var)
Prints content of variable to console/log.
enum ShapeType ErrorEx
proto int ParseString(string input, out string tokens[])
Parses string into array of tokens returns number of tokens.
map< Managed, int > TManagedIntMap
Definition enscript.c:1010
map< Managed, Class > TManagedClassMap
Definition enscript.c:1012
map< typename, float > TTypeNameFloatMap
Definition enscript.c:1000
proto int ParseStringEx(inout string input, string token)
Parses one token from input string. Result is put into token string, and type of token is returned....
proto void Sort(void param_array[], int num)
Sorts static array of integers(ascendically) / floats(ascendically) / strings(alphabetically)
set< int > TIntSet
Definition enscript.c:801
array< typename > TTypenameArray
Definition enscript.c:717
array< float > TFloatArray
Definition enscript.c:710
set< Class > TClassSet
Definition enscript.c:802
map< Class, vector > TClassVectorMap
Definition enscript.c:998
map< Class, typename > TClassTypenameMap
Definition enscript.c:997
map< ref Managed, Managed > TManagedRefManagedMap
Definition enscript.c:1022
array< string > TStringArray
Definition enscript.c:709
map< int, Class > TIntClassMap
Definition enscript.c:976
map< Class, float > TClassFloatMap
Definition enscript.c:991
map< string, vector > TStringVectorMap
Definition enscript.c:989
proto native int KillThread(Class owner, string name)
Kills thread.
map< int, string > TIntStringMap
Definition enscript.c:975
map< int, float > TIntFloatMap
Definition enscript.c:973
proto owned string ThreadFunction(Class owner, string name, int backtrace, out int linenumber)
Debug function. Returns current function on stack of the thread.
array< Managed > TManagedArray
Definition enscript.c:714
map< ref Managed, vector > TManagedRefVectorMap
Definition enscript.c:1025
int MapIterator
Definition enscript.c:807
map< ref Managed, float > TManagedRefFloatMap
Definition enscript.c:1018
array< vector > TVectorArray
Definition enscript.c:716
array< ref Managed > TManagedRefArray
Definition enscript.c:715
map< ref Managed, ref Managed > TManagedRefManagedRefMap
Definition enscript.c:1023
array< int > TIntArray
Definition enscript.c:711
map< Class, Class > TClassClassMap
Definition enscript.c:994
array< Class > TClassArray
Definition enscript.c:713
map< Class, int > TClassIntMap
Definition enscript.c:992
proto void copyarray(void destArray, void srcArray)
set< float > TFloatSet
Definition enscript.c:800
string String(string s)
Helper for passing string expression to functions with void parameter. Example: Print(String("Hello "...
Definition enscript.c:339
map< ref Managed, typename > TManagedRefTypenameMap
Definition enscript.c:1024
map< Managed, typename > TManagedTypenameMap
Definition enscript.c:1015
map< string, int > TStringIntMap
Definition enscript.c:983
proto volatile void Idle()
set< ref Managed > TManagedRefSet
Definition enscript.c:804
map< typename, vector > TTypeNameVectorMap
Definition enscript.c:1007
map< ref Managed, string > TManagedRefStringMap
Definition enscript.c:1020
map< int, typename > TIntTypenameMap
Definition enscript.c:979
map< Class, ref Managed > TClassManagedRefMap
Definition enscript.c:996
map< Managed, Managed > TManagedManagedMap
Definition enscript.c:1013
map< typename, Managed > TTypeNameManagedMap
Definition enscript.c:1004
proto void reversearray(void param_array)
map< Managed, ref Managed > TManagedManagedRefMap
Definition enscript.c:1014
map< string, ref Managed > TStringManagedRefMap
Definition enscript.c:987
map< typename, ref Managed > TTypeNameManagedRefMap
Definition enscript.c:1005
map< typename, int > TTypeNameIntMap
Definition enscript.c:1001
map< string, string > TStringStringMap
Definition enscript.c:984
array< bool > TBoolArray
Definition enscript.c:712
map< Class, string > TClassStringMap
Definition enscript.c:993
map< int, int > TIntIntMap
Definition enscript.c:974
map< string, float > TStringFloatMap
Definition enscript.c:982
map< ref Managed, int > TManagedRefIntMap
Definition enscript.c:1019
map< typename, Class > TTypeNameClassMap
Definition enscript.c:1003
map< string, Class > TStringClassMap
Definition enscript.c:985
int[] TypeID
script representation for C++ RTTI types
Definition enscript.c:127
set< typename > TTypenameSet
Definition enscript.c:805
map< typename, string > TTypeNameStringMap
Definition enscript.c:1002
map< int, Managed > TIntManagedMap
Definition enscript.c:977
set< string > TStringSet
Definition enscript.c:799
map< string, typename > TStringTypenameMap
Definition enscript.c:988
map< Managed, float > TManagedFloatMap
Definition enscript.c:1009
string m_Msg
Definition enscript.c:370
class array< Class T > PrintString
map< int, vector > TIntVectorMap
Definition enscript.c:980
set< Managed > TManagedSet
Definition enscript.c:803
map< int, ref Managed > TIntManagedRefMap
Definition enscript.c:978
map< typename, typename > TTypeNameTypenameMap
Definition enscript.c:1006
map< ref Managed, Class > TManagedRefClassMap
Definition enscript.c:1021
map< Managed, string > TManagedStringMap
Definition enscript.c:1011
map< Managed, vector > TManagedVectorMap
Definition enscript.c:1016
map< string, Managed > TStringManagedMap
Definition enscript.c:986
map< Class, Managed > TClassManagedMap
Definition enscript.c:995
enum MagnumStableStateID init
override float Get()
void Set(T value, string system="")
void Clear(bool clearFile=false)