hedgewars/uScript.pas
changeset 4875 2a37a0e0892d
parent 4869 7a720b5d2247
child 4882 b4c84db92d8f
equal deleted inserted replaced
4874:f508adb769b8 4875:2a37a0e0892d
    48     uWorld,
    48     uWorld,
    49     uAmmos,
    49     uAmmos,
    50     uSound,
    50     uSound,
    51     uChat,
    51     uChat,
    52     uStats,
    52     uStats,
       
    53     uStore,
    53     uRandom,
    54     uRandom,
    54     uTypes,
    55     uTypes,
    55     uVariables,
    56     uVariables,
    56     uCommands,
    57     uCommands,
    57     uUtils,
    58     uUtils,
  1180             lua_pushinteger(L, gear^.Radius)
  1181             lua_pushinteger(L, gear^.Radius)
  1181         else
  1182         else
  1182             lua_pushnil(L);
  1183             lua_pushnil(L);
  1183         end;
  1184         end;
  1184     lc_getgearradius:= 1
  1185     lc_getgearradius:= 1
       
  1186 end;
       
  1187 
       
  1188 function lc_gethoghat(L : Plua_State): LongInt; Cdecl;
       
  1189 var gear : PGear;
       
  1190 begin
       
  1191     if lua_gettop(L) <> 1 then
       
  1192         LuaError('Lua: Wrong number of parameters passed to GetHogHat!')
       
  1193     else begin
       
  1194         gear := GearByUID(lua_tointeger(L, 1));
       
  1195         if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
       
  1196             lua_pushstring(L, str2pchar(gear^.Hedgehog^.Hat))
       
  1197         else
       
  1198             lua_pushnil(L);
       
  1199     end;
       
  1200     lc_gethoghat := 1;
       
  1201 end;
       
  1202 
       
  1203 function lc_sethoghat(L : Plua_State) : LongInt; Cdecl;
       
  1204 var gear : PGear;
       
  1205     hat: ShortString;
       
  1206 begin
       
  1207     if lua_gettop(L) <> 2 then
       
  1208         begin
       
  1209         LuaError('Lua: Wrong number of parameters passed to SetHogHat!');
       
  1210         lua_pushnil(L)
       
  1211         end
       
  1212     else
       
  1213         begin
       
  1214         gear:= GearByUID(lua_tointeger(L, 1));
       
  1215         if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
       
  1216             hat:= lua_tostring(L, 2);
       
  1217             gear^.Hedgehog^.Hat:= hat;
       
  1218             LoadHedgehogHat(gear, hat);
       
  1219         end;
       
  1220     lc_sethoghat:= 0;
  1185 end;
  1221 end;
  1186 ///////////////////
  1222 ///////////////////
  1187 
  1223 
  1188 procedure ScriptPrintStack;
  1224 procedure ScriptPrintStack;
  1189 var n, i : LongInt;
  1225 var n, i : LongInt;
  1595 lua_register(luaState, 'SetGearMessage', @lc_setgearmessage);
  1631 lua_register(luaState, 'SetGearMessage', @lc_setgearmessage);
  1596 lua_register(luaState, 'GetRandom', @lc_getrandom);
  1632 lua_register(luaState, 'GetRandom', @lc_getrandom);
  1597 lua_register(luaState, 'SetWind', @lc_setwind);
  1633 lua_register(luaState, 'SetWind', @lc_setwind);
  1598 lua_register(luaState, 'GetDataPath', @lc_getdatapath);
  1634 lua_register(luaState, 'GetDataPath', @lc_getdatapath);
  1599 lua_register(luaState, 'MapHasBorder', @lc_maphasborder);
  1635 lua_register(luaState, 'MapHasBorder', @lc_maphasborder);
       
  1636 lua_register(luaState, 'GetHogHat', @lc_gethoghat);
       
  1637 lua_register(luaState, 'SetHogHat', @lc_sethoghat);
  1600 
  1638 
  1601 
  1639 
  1602 ScriptClearStack; // just to be sure stack is empty
  1640 ScriptClearStack; // just to be sure stack is empty
  1603 ScriptLoaded:= false;
  1641 ScriptLoaded:= false;
  1604 end;
  1642 end;