hedgewars/uScript.pas
changeset 4869 7a720b5d2247
parent 4851 3ba1ecc06dc6
child 4875 2a37a0e0892d
--- a/hedgewars/uScript.pas	Sat Jan 22 22:39:35 2011 +0300
+++ b/hedgewars/uScript.pas	Sat Jan 22 22:31:05 2011 +0100
@@ -1164,6 +1164,25 @@
         lua_pushboolean(L, hasBorder);
     lc_maphasborder:= 1
 end;
+
+function lc_getgearradius(L : Plua_State) : LongInt; Cdecl;
+var gear : PGear;
+begin
+    if lua_gettop(L) <> 1 then
+        begin
+        LuaError('Lua: Wrong number of parameters passed to GetGearRadius!');
+        lua_pushnil(L); // return value on stack (nil)
+        end
+    else
+        begin
+        gear:= GearByUID(lua_tointeger(L, 1));
+        if gear <> nil then
+            lua_pushinteger(L, gear^.Radius)
+        else
+            lua_pushnil(L);
+        end;
+    lc_getgearradius:= 1
+end;
 ///////////////////
 
 procedure ScriptPrintStack;
@@ -1571,6 +1590,7 @@
 lua_register(luaState, 'CampaignLock', @lc_campaignlock);
 lua_register(luaState, 'CampaignUnlock', @lc_campaignunlock);
 lua_register(luaState, 'GetGearElasticity', @lc_getgearelasticity);
+lua_register(luaState, 'GetGearRadius', @lc_getgearradius);
 lua_register(luaState, 'GetGearMessage', @lc_getgearmessage);
 lua_register(luaState, 'SetGearMessage', @lc_setgearmessage);
 lua_register(luaState, 'GetRandom', @lc_getrandom);