hedgewars/uScript.pas
branchhedgeroid
changeset 5495 272ed78e59a7
parent 5410 8e7787065e2d
parent 5489 f7ec6e5ad054
child 5530 25d4118056e1
--- a/hedgewars/uScript.pas	Thu Aug 04 17:41:07 2011 +0200
+++ b/hedgewars/uScript.pas	Thu Aug 04 17:44:55 2011 +0200
@@ -986,11 +986,28 @@
         LuaError('Lua: Wrong number of parameters passed to SetEffect!')
     else begin
         gear := GearByUID(lua_tointeger(L, 1));
-        if gear <> nil then
+        if (gear <> nil) and (gear^.Hedgehog <> nil) then
             gear^.Hedgehog^.Effects[THogEffect(lua_tointeger(L, 2))]:= lua_toboolean(L, 3);
     end;
     lc_seteffect := 0;
 end;
+function lc_geteffect(L : Plua_State) : LongInt; Cdecl;
+var gear : PGear;
+begin
+    if lua_gettop(L) <> 2 then
+        begin
+        LuaError('Lua: Wrong number of parameters passed to GetEffect!');
+        end
+    else
+        begin
+        gear:= GearByUID(lua_tointeger(L, 1));
+        if (gear <> nil) and (gear^.Hedgehog <> nil) then
+            lua_pushboolean(L, gear^.Hedgehog^.Effects[THogEffect(lua_tointeger(L, 2))])
+        else
+            lua_pushboolean(L, false)
+        end;
+    lc_geteffect:= 1
+end;
 
 function lc_setstate(L : Plua_State) : LongInt; Cdecl;
 var gear : PGear;
@@ -1840,6 +1857,7 @@
 lua_register(luaState, 'SetHealth', @lc_sethealth);
 lua_register(luaState, 'GetHealth', @lc_gethealth);
 lua_register(luaState, 'SetEffect', @lc_seteffect);
+lua_register(luaState, 'GetEffect', @lc_geteffect);
 lua_register(luaState, 'GetHogClan', @lc_gethogclan);
 lua_register(luaState, 'GetClanColor', @lc_getclancolor);
 lua_register(luaState, 'SetClanColor', @lc_setclancolor);