public static void Tests_GlobalFunctions() { var module_ = ScriptEngine.GetModule("test", asEGMFlags.asGM_ALWAYS_CREATE); module_.AddScriptSection("GlobalFunctions", @" int One() { return 1; } bool SomeTest(int i) { return i % 2 == 0; } float Square(float x) { return x * x; } int RefFunc(string& s) { return s.length(); } int HandleFunc(string@ s) { return s.length(); } shared interface IFoo { int get_Prop(); } class CFoo : IFoo { CFoo(int i) { this.i = i; } int i; int get_Prop() { return i; } } IFoo@ GetAsInterface(int i) { return CFoo(i); } CFoo@ GetNull() { return null; } "); module_.Build(); dynamic module = module_ as dynamic; assert(module.One() == 1, "Calling parameterless function"); assert(module.SomeTest(2), "Calling func returning true"); assert(!module.SomeTest(3), "Calling func returning false"); assert(module.Square(1.2f) == 1.44f, "Calling float function"); var s = new ScriptString("hello"); assert(module.RefFunc(s) == 5, "Calling byref function"); assert(module.HandleFunc(s) == 5, "Calling handle function"); assert(module.GetAsInterface(2) != null, "Calling function returning script object"); assert(module.GetNull() == null, "Caling null returning function"); }
public virtual void PlaySound(string sound_name, ushort hx, ushort hy, uint radius) { var ss = new ScriptString(sound_name); Map_PlaySoundRadius(thisptr, ss.ThisPtr, hx, hy, radius); }
public virtual void PlaySound(string sound_name) { var ss = new ScriptString(sound_name); Map_PlaySound(thisptr, ss.ThisPtr); }
public virtual void SetTextMsgLex(ushort hx, ushort hy, uint color, ushort text_msg, uint str_num, string lexems) { var ss = new ScriptString(lexems); Map_SetTextMsgLex(thisptr, hx, hy, color, text_msg, str_num, ss.ThisPtr); }
public virtual bool SetScript(string script) { var ss = new ScriptString(script); return(Map_SetScript(thisptr, ss.ThisPtr)); }
public virtual void SetText(ushort hx, ushort hy, uint color, string text) { var ss = new ScriptString(text); Map_SetText(thisptr, hx, hy, color, ss.ThisPtr); }
public bool Get(string name, UIntArray data) { var ss = new ScriptString(name); return(Global_GetAnyData(ss.ThisPtr, data.ThisPtr)); }
public void Erase(string name) { var ss = new ScriptString(name); Global_EraseAnyData(ss.ThisPtr); }
public void RadioMessageMsg(ushort channel, ushort text_msg, uint str_num, string lexems) { var ss = new ScriptString(lexems); Global_RadioMessageMsgLex(channel, text_msg, str_num, ss.ThisPtr); }
public bool IsAnyData(string name) { var ss = new ScriptString(name); return(Global_IsAnyData(ss.ThisPtr)); }
public void RadioMessage(ushort channel, string text) { var ss = new ScriptString(text); Global_RadioMessage(channel, ss.ThisPtr); }
public void Log(string s, params object[] args) { var ss = new ScriptString(string.Format(s + Environment.NewLine, args)); Global_Log(ss.ThisPtr); }
public void Log(string s) { var ss = new ScriptString(s + Environment.NewLine); Global_Log(ss.ThisPtr); }
public virtual void SetLexems(string lexems) { var ss = new ScriptString(lexems); Item_SetLexems(thisptr, ss.ThisPtr); }
public bool Set(string name, int[] data) { var ss = new ScriptString(name); return(Global_SetAnyData(ss.ThisPtr, new IntArray(data).ThisPtr)); }
public virtual bool Misc_SetScript(string func_name) { var ss = new ScriptString(func_name); return(NpcPlane_Misc_SetScript(thisptr, ss.ThisPtr)); }
public static void asAssert(bool cond, IntPtr msg) { var ss = new ScriptString(msg); Assert(cond, ss.ToString()); }