--- a/hedgewars/uMisc.pas Mon Aug 23 12:49:58 2010 +0200
+++ b/hedgewars/uMisc.pas Mon Aug 23 12:53:00 2010 +0200
@@ -155,6 +155,7 @@
function EnumToStr(const en : TGearType) : shortstring; overload;
function EnumToStr(const en : TSound) : shortstring; overload;
function EnumToStr(const en : TAmmoType) : shortstring; overload;
+function EnumToStr(const en : THogEffect) : shortstring; overload;
procedure movecursor(dx, dy: LongInt);
function hwSign(r: hwFloat): LongInt;
function Min(a, b: LongInt): LongInt;
@@ -234,6 +235,11 @@
EnumToStr:= GetEnumName(TypeInfo(TAmmoType), ord(en))
end;
+function EnumToStr(const en: THogEffect) : shortstring; overload;
+begin
+ EnumToStr := GetEnumName(TypeInfo(THogEffect), ord(en))
+end;
+
procedure movecursor(dx, dy: LongInt);
var x, y: LongInt;
begin
--- a/hedgewars/uScript.pas Mon Aug 23 12:49:58 2010 +0200
+++ b/hedgewars/uScript.pas Mon Aug 23 12:53:00 2010 +0200
@@ -447,6 +447,19 @@
lc_settimer:= 0
end;
+function lc_seteffect(L : Plua_State) : LongInt; Cdecl;
+var gear: PGear;
+begin
+ if lua_gettop(L) <> 3 then
+ LuaError('Lua: Wrong number of parameters passed to SetEffect!')
+ else begin
+ gear := GearByUID(lua_tointeger(L, 1));
+ if gear <> nil then
+ PHedgehog(gear^.Hedgehog)^.Effects[THogEffect(lua_tointeger(L, 2))]:= lua_tointeger(L, 3) <> 0;
+ end;
+ lc_seteffect := 0;
+end;
+
function lc_setstate(L : Plua_State) : LongInt; Cdecl;
var gear : PGear;
begin
@@ -897,6 +910,7 @@
var at : TGearType;
am : TAmmoType;
st : TSound;
+ he: THogEffect;
begin
// initialize lua
luaState:= lua_open;
@@ -945,6 +959,9 @@
for am:= Low(TAmmoType) to High(TAmmoType) do
ScriptSetInteger(EnumToStr(am), ord(am));
+for he:= Low(THogEffect) to High(THogEffect) do
+ ScriptSetInteger(EnumToStr(he), ord(he));
+
// register functions
lua_register(luaState, 'AddGear', @lc_addgear);
lua_register(luaState, 'SpawnHealthCrate', @lc_spawnhealthcrate);
@@ -964,6 +981,7 @@
lua_register(luaState, 'AddTeam', @lc_addteam);
lua_register(luaState, 'AddHog', @lc_addhog);
lua_register(luaState, 'SetHealth', @lc_sethealth);
+lua_register(luaState, 'SetEffect', @lc_seteffect);
lua_register(luaState, 'GetHogClan', @lc_gethogclan);
lua_register(luaState, 'GetHogName', @lc_gethogname);
lua_register(luaState, 'GetHogLevel', @lc_gethoglevel);