hedgewars/uScript.pas
changeset 3756 d42571e2e6c9
parent 3755 02dc9fcb6477
child 3761 f96b99f944e6
equal deleted inserted replaced
3755:02dc9fcb6477 3756:d42571e2e6c9
   443         begin
   443         begin
   444         gear:= GearByUID(lua_tointeger(L, 1));
   444         gear:= GearByUID(lua_tointeger(L, 1));
   445         if gear <> nil then gear^.Timer:= lua_tointeger(L, 2)
   445         if gear <> nil then gear^.Timer:= lua_tointeger(L, 2)
   446         end;
   446         end;
   447     lc_settimer:= 0
   447     lc_settimer:= 0
       
   448 end;
       
   449 
       
   450 function lc_seteffect(L : Plua_State) : LongInt; Cdecl;
       
   451 var gear: PGear;
       
   452 begin
       
   453     if lua_gettop(L) <> 3 then
       
   454         LuaError('Lua: Wrong number of parameters passed to SetEffect!')
       
   455     else begin
       
   456         gear := GearByUID(lua_tointeger(L, 1));
       
   457         if gear <> nil then
       
   458             PHedgehog(gear^.Hedgehog)^.Effects[THogEffect(lua_tointeger(L, 2))]:= lua_tointeger(L, 3) <> 0;
       
   459     end;
       
   460     lc_seteffect := 0;
   448 end;
   461 end;
   449 
   462 
   450 function lc_setstate(L : Plua_State) : LongInt; Cdecl;
   463 function lc_setstate(L : Plua_State) : LongInt; Cdecl;
   451 var gear : PGear;
   464 var gear : PGear;
   452 begin
   465 begin
   895 
   908 
   896 procedure initModule;
   909 procedure initModule;
   897 var at : TGearType;
   910 var at : TGearType;
   898     am : TAmmoType;
   911     am : TAmmoType;
   899     st : TSound;
   912     st : TSound;
       
   913     he: THogEffect;
   900 begin
   914 begin
   901 // initialize lua
   915 // initialize lua
   902 luaState:= lua_open;
   916 luaState:= lua_open;
   903 TryDo(luaState <> nil, 'lua_open failed', true);
   917 TryDo(luaState <> nil, 'lua_open failed', true);
   904 
   918 
   943 
   957 
   944 // register ammo types
   958 // register ammo types
   945 for am:= Low(TAmmoType) to High(TAmmoType) do
   959 for am:= Low(TAmmoType) to High(TAmmoType) do
   946     ScriptSetInteger(EnumToStr(am), ord(am));
   960     ScriptSetInteger(EnumToStr(am), ord(am));
   947 
   961 
       
   962 for he:= Low(THogEffect) to High(THogEffect) do
       
   963     ScriptSetInteger(EnumToStr(he), ord(he));
       
   964 
   948 // register functions
   965 // register functions
   949 lua_register(luaState, 'AddGear', @lc_addgear);
   966 lua_register(luaState, 'AddGear', @lc_addgear);
   950 lua_register(luaState, 'SpawnHealthCrate', @lc_spawnhealthcrate);
   967 lua_register(luaState, 'SpawnHealthCrate', @lc_spawnhealthcrate);
   951 lua_register(luaState, 'SpawnAmmoCrate', @lc_spawnammocrate);
   968 lua_register(luaState, 'SpawnAmmoCrate', @lc_spawnammocrate);
   952 lua_register(luaState, 'SpawnUtilityCrate', @lc_spawnutilitycrate);
   969 lua_register(luaState, 'SpawnUtilityCrate', @lc_spawnutilitycrate);
   962 lua_register(luaState, 'SetAmmo', @lc_setammo);
   979 lua_register(luaState, 'SetAmmo', @lc_setammo);
   963 lua_register(luaState, 'PlaySound', @lc_playsound);
   980 lua_register(luaState, 'PlaySound', @lc_playsound);
   964 lua_register(luaState, 'AddTeam', @lc_addteam);
   981 lua_register(luaState, 'AddTeam', @lc_addteam);
   965 lua_register(luaState, 'AddHog', @lc_addhog);
   982 lua_register(luaState, 'AddHog', @lc_addhog);
   966 lua_register(luaState, 'SetHealth', @lc_sethealth);
   983 lua_register(luaState, 'SetHealth', @lc_sethealth);
       
   984 lua_register(luaState, 'SetEffect', @lc_seteffect);
   967 lua_register(luaState, 'GetHogClan', @lc_gethogclan);
   985 lua_register(luaState, 'GetHogClan', @lc_gethogclan);
   968 lua_register(luaState, 'GetHogName', @lc_gethogname);
   986 lua_register(luaState, 'GetHogName', @lc_gethogname);
   969 lua_register(luaState, 'GetHogLevel', @lc_gethoglevel);
   987 lua_register(luaState, 'GetHogLevel', @lc_gethoglevel);
   970 lua_register(luaState, 'GetX', @lc_getx);
   988 lua_register(luaState, 'GetX', @lc_getx);
   971 lua_register(luaState, 'GetY', @lc_gety);
   989 lua_register(luaState, 'GetY', @lc_gety);