hedgewars/uScript.pas
changeset 3003 0afdba08a858
parent 2999 30c4d62cd0c3
child 3004 e9b3613cc3fb
--- a/hedgewars/uScript.pas	Tue Mar 16 04:46:29 2010 +0000
+++ b/hedgewars/uScript.pas	Tue Mar 16 19:28:15 2010 +0000
@@ -351,6 +351,12 @@
 lua_settop(luaState, 0)
 end;
 
+procedure ScriptSetNil(name : shortstring);
+begin
+lua_pushnil(luaState);
+lua_setglobal(luaState, Str2PChar(name));
+end;
+
 procedure ScriptSetInteger(name : shortstring; value : LongInt);
 begin
 lua_pushinteger(luaState, value);
@@ -443,6 +449,10 @@
 procedure SetGlobals;
 begin
 ScriptSetInteger('TurnTimeLeft', TurnTimeLeft);
+if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) then
+    ScriptSetInteger('CurrentHedgehog', CurrentHedgehog^.Gear^.UID)
+else
+    ScriptSetNil('CurrentHedgehog');
 end;
 
 procedure GetGlobals;