equal
deleted
inserted
replaced
39 |
39 |
40 implementation |
40 implementation |
41 {$IFNDEF LUA_DISABLED} |
41 {$IFNDEF LUA_DISABLED} |
42 uses LuaPas in 'LuaPas.pas', |
42 uses LuaPas in 'LuaPas.pas', |
43 uConsole, |
43 uConsole, |
44 uMisc, |
|
45 uConsts, |
44 uConsts, |
46 uVisualGears, |
45 uVisualGears, |
47 uGears, |
46 uGears, |
48 uFloat, |
47 uFloat, |
49 uWorld, |
48 uWorld, |
50 uAmmos, |
49 uAmmos, |
51 uSound, |
50 uSound, |
52 uTeams, |
|
53 uKeys, |
|
54 uChat, |
51 uChat, |
55 uStats, |
52 uStats, |
56 uRandom; |
53 uRandom, |
|
54 uTypes, |
|
55 uVariables, |
|
56 uCommands, |
|
57 uUtils, |
|
58 uKeys, |
|
59 uCaptions, |
|
60 uDebug; |
57 |
61 |
58 var luaState : Plua_State; |
62 var luaState : Plua_State; |
59 ScriptAmmoLoadout : shortstring; |
63 ScriptAmmoLoadout : shortstring; |
60 ScriptAmmoProbability : shortstring; |
64 ScriptAmmoProbability : shortstring; |
61 ScriptAmmoDelay : shortstring; |
65 ScriptAmmoDelay : shortstring; |
297 if lua_gettop(L) <> 1 then |
301 if lua_gettop(L) <> 1 then |
298 LuaError('Lua: Wrong number of parameters passed to GetHogLevel!') |
302 LuaError('Lua: Wrong number of parameters passed to GetHogLevel!') |
299 else begin |
303 else begin |
300 gear := GearByUID(lua_tointeger(L, 1)); |
304 gear := GearByUID(lua_tointeger(L, 1)); |
301 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
305 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
302 lua_pushinteger(L, PHedgehog(gear^.Hedgehog)^.BotLevel) |
306 lua_pushinteger(L, gear^.Hedgehog^.BotLevel) |
303 else |
307 else |
304 lua_pushnil(L); |
308 lua_pushnil(L); |
305 end; |
309 end; |
306 lc_gethoglevel := 1; |
310 lc_gethoglevel := 1; |
307 end; |
311 end; |
317 else |
321 else |
318 begin |
322 begin |
319 gear:= GearByUID(lua_tointeger(L, 1)); |
323 gear:= GearByUID(lua_tointeger(L, 1)); |
320 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
324 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
321 begin |
325 begin |
322 lua_pushinteger(L, PHedgehog(gear^.Hedgehog)^.Team^.Clan^.ClanIndex) |
326 lua_pushinteger(L, gear^.Hedgehog^.Team^.Clan^.ClanIndex) |
323 end |
327 end |
324 else |
328 else |
325 lua_pushnil(L); |
329 lua_pushnil(L); |
326 end; |
330 end; |
327 lc_gethogclan:= 1 |
331 lc_gethogclan:= 1 |
338 else |
342 else |
339 begin |
343 begin |
340 gear:= GearByUID(lua_tointeger(L, 1)); |
344 gear:= GearByUID(lua_tointeger(L, 1)); |
341 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
345 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
342 begin |
346 begin |
343 lua_pushstring(L, str2pchar(PHedgehog(gear^.Hedgehog)^.Team^.TeamName)) |
347 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.TeamName)) |
344 end |
348 end |
345 else |
349 else |
346 lua_pushnil(L); |
350 lua_pushnil(L); |
347 end; |
351 end; |
348 lc_gethogteamname:= 1 |
352 lc_gethogteamname:= 1 |
359 else |
363 else |
360 begin |
364 begin |
361 gear:= GearByUID(lua_tointeger(L, 1)); |
365 gear:= GearByUID(lua_tointeger(L, 1)); |
362 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
366 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
363 begin |
367 begin |
364 lua_pushstring(L, str2pchar(PHedgehog(gear^.Hedgehog)^.Name)) |
368 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Name)) |
365 end |
369 end |
366 else |
370 else |
367 lua_pushnil(L); |
371 lua_pushnil(L); |
368 end; |
372 end; |
369 lc_gethogname:= 1 |
373 lc_gethogname:= 1 |
568 if lua_gettop(L) <> 3 then |
572 if lua_gettop(L) <> 3 then |
569 LuaError('Lua: Wrong number of parameters passed to SetEffect!') |
573 LuaError('Lua: Wrong number of parameters passed to SetEffect!') |
570 else begin |
574 else begin |
571 gear := GearByUID(lua_tointeger(L, 1)); |
575 gear := GearByUID(lua_tointeger(L, 1)); |
572 if gear <> nil then |
576 if gear <> nil then |
573 PHedgehog(gear^.Hedgehog)^.Effects[THogEffect(lua_tointeger(L, 2))]:= lua_tointeger(L, 3) <> 0; |
577 gear^.Hedgehog^.Effects[THogEffect(lua_tointeger(L, 2))]:= lua_toboolean(L, 3); |
574 end; |
578 end; |
575 lc_seteffect := 0; |
579 lc_seteffect := 0; |
576 end; |
580 end; |
577 |
581 |
578 function lc_setstate(L : Plua_State) : LongInt; Cdecl; |
582 function lc_setstate(L : Plua_State) : LongInt; Cdecl; |
818 LuaError('Lua: Tried to pass 0 to GetRandom!'); |
822 LuaError('Lua: Tried to pass 0 to GetRandom!'); |
819 lua_pushnil(L); |
823 lua_pushnil(L); |
820 end |
824 end |
821 end; |
825 end; |
822 lc_getrandom:= 1 |
826 lc_getrandom:= 1 |
|
827 end; |
|
828 |
|
829 function lc_setwind(L : Plua_State) : LongInt; Cdecl; |
|
830 begin |
|
831 if lua_gettop(L) <> 1 then |
|
832 LuaError('Lua: Wrong number of parameters passed to SetWind!') |
|
833 else |
|
834 begin |
|
835 cWindSpeed:= int2hwfloat(lua_tointeger(L, 1)) / 100 * cMaxWindSpeed; |
|
836 cWindSpeedf:= SignAs(cWindSpeed,cWindSpeed).QWordValue / SignAs(_1,_1).QWordValue; |
|
837 if cWindSpeed.isNegative then |
|
838 CWindSpeedf := -cWindSpeedf; |
|
839 AddGear(0, 0, gtATSmoothWindCh, 0, _0, _0, 1)^.Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed); |
|
840 end; |
|
841 lc_setwind:= 0 |
823 end; |
842 end; |
824 /////////////////// |
843 /////////////////// |
825 |
844 |
826 procedure ScriptPrintStack; |
845 procedure ScriptPrintStack; |
827 var n, i : LongInt; |
846 var n, i : LongInt; |
1209 lua_register(luaState, 'CampaignLock', @lc_campaignlock); |
1228 lua_register(luaState, 'CampaignLock', @lc_campaignlock); |
1210 lua_register(luaState, 'CampaignUnlock', @lc_campaignunlock); |
1229 lua_register(luaState, 'CampaignUnlock', @lc_campaignunlock); |
1211 lua_register(luaState, 'GetGearMessage', @lc_getgearmessage); |
1230 lua_register(luaState, 'GetGearMessage', @lc_getgearmessage); |
1212 lua_register(luaState, 'SetGearMessage', @lc_setgearmessage); |
1231 lua_register(luaState, 'SetGearMessage', @lc_setgearmessage); |
1213 lua_register(luaState, 'GetRandom', @lc_getrandom); |
1232 lua_register(luaState, 'GetRandom', @lc_getrandom); |
|
1233 lua_register(luaState, 'SetWind', @lc_setwind); |
1214 |
1234 |
1215 |
1235 |
1216 ScriptClearStack; // just to be sure stack is empty |
1236 ScriptClearStack; // just to be sure stack is empty |
1217 ScriptLoaded:= false; |
1237 ScriptLoaded:= false; |
1218 end; |
1238 end; |