hedgewars/uScript.pas
changeset 5118 9cfdb9bc6140
parent 5075 59b13b38a827
child 5120 c4d5ddf939fc
equal deleted inserted replaced
5117:71f94af9d1a4 5118:9cfdb9bc6140
   178 end;
   178 end;
   179 
   179 
   180 function lc_addcaption(L : Plua_State) : LongInt; Cdecl;
   180 function lc_addcaption(L : Plua_State) : LongInt; Cdecl;
   181 begin
   181 begin
   182     if lua_gettop(L) = 1 then
   182     if lua_gettop(L) = 1 then
   183         begin
   183         AddCaption(lua_tostring(L, 1), cWhiteColor, capgrpMessage)
   184         AddCaption(lua_tostring(L, 1), cWhiteColor, capgrpMessage);
   184     else if lua_gettop(L) = 3 then
       
   185         begin
       
   186         AddCaption(lua_tostring(L, 1), lua_tointeger(L, 2) shr 8, TCapGroup(lua_tointeger(L, 3)));
   185         end
   187         end
   186     else
   188     else
   187         LuaError('Lua: Wrong number of parameters passed to AddCaption!');
   189         LuaError('Lua: Wrong number of parameters passed to AddCaption!');
   188     lc_addcaption:= 0;
   190     lc_addcaption:= 0;
   189 end;
   191 end;
  1553 procedure initModule;
  1555 procedure initModule;
  1554 var at : TGearType;
  1556 var at : TGearType;
  1555     vgt: TVisualGearType;
  1557     vgt: TVisualGearType;
  1556     am : TAmmoType;
  1558     am : TAmmoType;
  1557     st : TSound;
  1559     st : TSound;
  1558     he: THogEffect;
  1560     he : THogEffect;
       
  1561     cg : TCapGroup;
  1559     s, t : ansistring;
  1562     s, t : ansistring;
  1560 begin
  1563 begin
  1561 // initialize lua
  1564 // initialize lua
  1562 luaState:= lua_open;
  1565 luaState:= lua_open;
  1563 TryDo(luaState <> nil, 'lua_open failed', true);
  1566 TryDo(luaState <> nil, 'lua_open failed', true);
  1642 for am:= Low(TAmmoType) to High(TAmmoType) do
  1645 for am:= Low(TAmmoType) to High(TAmmoType) do
  1643     ScriptSetInteger(EnumToStr(am), ord(am));
  1646     ScriptSetInteger(EnumToStr(am), ord(am));
  1644 
  1647 
  1645 for he:= Low(THogEffect) to High(THogEffect) do
  1648 for he:= Low(THogEffect) to High(THogEffect) do
  1646     ScriptSetInteger(EnumToStr(he), ord(he));
  1649     ScriptSetInteger(EnumToStr(he), ord(he));
       
  1650 
       
  1651 for cg:= Low(TCapGroup) to High(TCapGroup) do
       
  1652     ScriptSetInteger(EnumToStr(cg), ord(cg));
  1647 
  1653 
  1648 // register functions
  1654 // register functions
  1649 lua_register(luaState, 'band', @lc_band);
  1655 lua_register(luaState, 'band', @lc_band);
  1650 lua_register(luaState, 'bor', @lc_bor);
  1656 lua_register(luaState, 'bor', @lc_bor);
  1651 lua_register(luaState, 'bnot', @lc_bnot);
  1657 lua_register(luaState, 'bnot', @lc_bnot);