348 // use as return value the number of variables pushed back to the lua script |
348 // use as return value the number of variables pushed back to the lua script |
349 |
349 |
350 function lc_band(L: PLua_State): LongInt; Cdecl; |
350 function lc_band(L: PLua_State): LongInt; Cdecl; |
351 begin |
351 begin |
352 if CheckLuaParamCount(L, 2, 'band', 'value1, value2') then |
352 if CheckLuaParamCount(L, 2, 'band', 'value1, value2') then |
353 lua_pushinteger(L, lua_tointeger(L, 2) and lua_tointeger(L, 1)) |
353 lua_pushnumber(L, Trunc(lua_tonumber(L, 2)) and Trunc(lua_tonumber(L, 1))) |
354 else |
354 else |
355 lua_pushnil(L); |
355 lua_pushnil(L); |
356 lc_band := 1; |
356 lc_band := 1; |
357 end; |
357 end; |
358 |
358 |
359 function lc_bor(L: PLua_State): LongInt; Cdecl; |
359 function lc_bor(L: PLua_State): LongInt; Cdecl; |
360 begin |
360 begin |
361 if CheckLuaParamCount(L, 2, 'bor', 'value1, value2') then |
361 if CheckLuaParamCount(L, 2, 'bor', 'value1, value2') then |
362 lua_pushinteger(L, lua_tointeger(L, 2) or lua_tointeger(L, 1)) |
362 lua_pushnumber(L, Trunc(lua_tonumber(L, 2)) or Trunc(lua_tonumber(L, 1))) |
363 else |
363 else |
364 lua_pushnil(L); |
364 lua_pushnil(L); |
365 lc_bor := 1; |
365 lc_bor := 1; |
366 end; |
366 end; |
367 |
367 |
368 function lc_bnot(L: PLua_State): LongInt; Cdecl; |
368 function lc_bnot(L: PLua_State): LongInt; Cdecl; |
369 begin |
369 begin |
370 if CheckLuaParamCount(L, 1, 'bnot', 'value') then |
370 if CheckLuaParamCount(L, 1, 'bnot', 'value') then |
371 lua_pushinteger(L, (not lua_tointeger(L, 1))) |
371 lua_pushnumber(L, (not Trunc(lua_tonumber(L, 1)))) |
372 else |
372 else |
373 lua_pushnil(L); |
373 lua_pushnil(L); |
374 lc_bnot := 1; |
374 lc_bnot := 1; |
375 end; |
375 end; |
376 |
376 |
377 function lc_div(L: PLua_State): LongInt; Cdecl; |
377 function lc_div(L: PLua_State): LongInt; Cdecl; |
378 begin |
378 begin |
379 if CheckLuaParamCount(L, 2, 'div', 'dividend, divisor') then |
379 if CheckLuaParamCount(L, 2, 'div', 'dividend, divisor') then |
380 lua_pushinteger(L, lua_tointeger(L, 1) div lua_tointeger(L, 2)) |
380 lua_pushnumber(L, Trunc(lua_tonumber(L, 1)) div Trunc(lua_tonumber(L, 2))) |
381 else |
381 else |
382 lua_pushnil(L); |
382 lua_pushnil(L); |
383 lc_div := 1; |
383 lc_div := 1; |
384 end; |
384 end; |
385 |
385 |
386 function lc_getinputmask(L : Plua_State) : LongInt; Cdecl; |
386 function lc_getinputmask(L : Plua_State) : LongInt; Cdecl; |
387 begin |
387 begin |
388 if CheckLuaParamCount(L, 0, 'GetInputMask', '') then |
388 if CheckLuaParamCount(L, 0, 'GetInputMask', '') then |
389 lua_pushinteger(L, InputMask); |
389 lua_pushnumber(L, InputMask); |
390 lc_getinputmask:= 1 |
390 lc_getinputmask:= 1 |
391 end; |
391 end; |
392 |
392 |
393 function lc_setinputmask(L : Plua_State) : LongInt; Cdecl; |
393 function lc_setinputmask(L : Plua_State) : LongInt; Cdecl; |
394 begin |
394 begin |
395 if CheckLuaParamCount(L, 1, 'SetInputMask', 'mask') then |
395 if CheckLuaParamCount(L, 1, 'SetInputMask', 'mask') then |
396 InputMask:= lua_tointeger(L, 1); |
396 InputMask:= Trunc(lua_tonumber(L, 1)); |
397 lc_setinputmask:= 0 |
397 lc_setinputmask:= 0 |
398 end; |
398 end; |
399 |
399 |
400 function lc_writelntoconsole(L : Plua_State) : LongInt; Cdecl; |
400 function lc_writelntoconsole(L : Plua_State) : LongInt; Cdecl; |
401 begin |
401 begin |
537 end; |
537 end; |
538 |
538 |
539 function lc_showmission(L : Plua_State) : LongInt; Cdecl; |
539 function lc_showmission(L : Plua_State) : LongInt; Cdecl; |
540 begin |
540 begin |
541 if CheckLuaParamCount(L, 5, 'ShowMission', 'caption, subcaption, text, icon, time') then |
541 if CheckLuaParamCount(L, 5, 'ShowMission', 'caption, subcaption, text, icon, time') then |
542 ShowMission(lua_tostringA(L, 1), lua_tostringA(L, 2), lua_tostringA(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5)); |
542 ShowMission(lua_tostringA(L, 1), lua_tostringA(L, 2), lua_tostringA(L, 3), Trunc(lua_tonumber(L, 4)), Trunc(lua_tonumber(L, 5))); |
543 lc_showmission:= 0; |
543 lc_showmission:= 0; |
544 end; |
544 end; |
545 |
545 |
546 function lc_hidemission(L : Plua_State) : LongInt; Cdecl; |
546 function lc_hidemission(L : Plua_State) : LongInt; Cdecl; |
547 begin |
547 begin |
663 function lc_spawnfakehealthcrate(L: Plua_State) : LongInt; Cdecl; |
663 function lc_spawnfakehealthcrate(L: Plua_State) : LongInt; Cdecl; |
664 var gear: PGear; |
664 var gear: PGear; |
665 begin |
665 begin |
666 if CheckLuaParamCount(L, 4,'SpawnFakeHealthCrate', 'x, y, explode, poison') then |
666 if CheckLuaParamCount(L, 4,'SpawnFakeHealthCrate', 'x, y, explode, poison') then |
667 begin |
667 begin |
668 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
668 gear := SpawnFakeCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), |
669 HealthCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
669 HealthCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
670 if gear <> nil then |
670 if gear <> nil then |
671 lua_pushinteger(L, gear^.uid) |
671 lua_pushnumber(L, gear^.uid) |
672 else lua_pushnil(L) |
672 else lua_pushnil(L) |
673 end |
673 end |
674 else |
674 else |
675 lua_pushnil(L); |
675 lua_pushnil(L); |
676 lc_spawnfakehealthcrate := 1; |
676 lc_spawnfakehealthcrate := 1; |
679 function lc_spawnfakeammocrate(L: PLua_State): LongInt; Cdecl; |
679 function lc_spawnfakeammocrate(L: PLua_State): LongInt; Cdecl; |
680 var gear: PGear; |
680 var gear: PGear; |
681 begin |
681 begin |
682 if CheckLuaParamCount(L, 4,'SpawnFakeAmmoCrate', 'x, y, explode, poison') then |
682 if CheckLuaParamCount(L, 4,'SpawnFakeAmmoCrate', 'x, y, explode, poison') then |
683 begin |
683 begin |
684 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
684 gear := SpawnFakeCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), |
685 AmmoCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
685 AmmoCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
686 if gear <> nil then |
686 if gear <> nil then |
687 lua_pushinteger(L, gear^.uid) |
687 lua_pushnumber(L, gear^.uid) |
688 else lua_pushnil(L) |
688 else lua_pushnil(L) |
689 end |
689 end |
690 else |
690 else |
691 lua_pushnil(L); |
691 lua_pushnil(L); |
692 lc_spawnfakeammocrate := 1; |
692 lc_spawnfakeammocrate := 1; |
695 function lc_spawnfakeutilitycrate(L: PLua_State): LongInt; Cdecl; |
695 function lc_spawnfakeutilitycrate(L: PLua_State): LongInt; Cdecl; |
696 var gear: PGear; |
696 var gear: PGear; |
697 begin |
697 begin |
698 if CheckLuaParamCount(L, 4,'SpawnFakeUtilityCrate', 'x, y, explode, poison') then |
698 if CheckLuaParamCount(L, 4,'SpawnFakeUtilityCrate', 'x, y, explode, poison') then |
699 begin |
699 begin |
700 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
700 gear := SpawnFakeCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), |
701 UtilityCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
701 UtilityCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
702 if gear <> nil then |
702 if gear <> nil then |
703 lua_pushinteger(L, gear^.uid) |
703 lua_pushnumber(L, gear^.uid) |
704 else lua_pushnil(L) |
704 else lua_pushnil(L) |
705 end |
705 end |
706 else |
706 else |
707 lua_pushnil(L); |
707 lua_pushnil(L); |
708 lc_spawnfakeutilitycrate := 1; |
708 lc_spawnfakeutilitycrate := 1; |
713 var health, n: LongInt; |
713 var health, n: LongInt; |
714 begin |
714 begin |
715 if CheckAndFetchParamCount(L, 2, 3, 'SpawnHealthCrate', 'x, y [, health]', n) then |
715 if CheckAndFetchParamCount(L, 2, 3, 'SpawnHealthCrate', 'x, y [, health]', n) then |
716 begin |
716 begin |
717 if n = 3 then |
717 if n = 3 then |
718 health:= lua_tointeger(L, 3) |
718 health:= Trunc(lua_tonumber(L, 3)) |
719 else |
719 else |
720 health:= cHealthCaseAmount; |
720 health:= cHealthCaseAmount; |
721 gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), HealthCrate, health, 0); |
721 gear := SpawnCustomCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), HealthCrate, health, 0); |
722 if gear <> nil then |
722 if gear <> nil then |
723 lua_pushinteger(L, gear^.uid) |
723 lua_pushnumber(L, gear^.uid) |
724 else lua_pushnil(L); |
724 else lua_pushnil(L); |
725 end |
725 end |
726 else |
726 else |
727 lua_pushnil(L); |
727 lua_pushnil(L); |
728 lc_spawnhealthcrate := 1; |
728 lc_spawnhealthcrate := 1; |
733 n : LongInt; |
733 n : LongInt; |
734 begin |
734 begin |
735 if CheckAndFetchParamCount(L, 3, 4, 'SpawnAmmoCrate', 'x, y, content [, amount]', n) then |
735 if CheckAndFetchParamCount(L, 3, 4, 'SpawnAmmoCrate', 'x, y, content [, amount]', n) then |
736 begin |
736 begin |
737 if n = 3 then |
737 if n = 3 then |
738 gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), 0) |
738 gear := SpawnCustomCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), AmmoCrate, Trunc(lua_tonumber(L, 3)), 0) |
739 else gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), lua_tointeger(L, 4)); |
739 else gear := SpawnCustomCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), AmmoCrate, Trunc(lua_tonumber(L, 3)), Trunc(lua_tonumber(L, 4))); |
740 if gear <> nil then |
740 if gear <> nil then |
741 lua_pushinteger(L, gear^.uid) |
741 lua_pushnumber(L, gear^.uid) |
742 else lua_pushnil(L); |
742 else lua_pushnil(L); |
743 end |
743 end |
744 else |
744 else |
745 lua_pushnil(L); |
745 lua_pushnil(L); |
746 lc_spawnammocrate := 1; |
746 lc_spawnammocrate := 1; |
751 n : LongInt; |
751 n : LongInt; |
752 begin |
752 begin |
753 if CheckAndFetchParamCount(L, 3, 4, 'SpawnUtilityCrate', 'x, y, content [, amount]', n) then |
753 if CheckAndFetchParamCount(L, 3, 4, 'SpawnUtilityCrate', 'x, y, content [, amount]', n) then |
754 begin |
754 begin |
755 if n = 3 then |
755 if n = 3 then |
756 gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), UtilityCrate, lua_tointeger(L, 3), 0) |
756 gear := SpawnCustomCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), UtilityCrate, Trunc(lua_tonumber(L, 3)), 0) |
757 else gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), UtilityCrate, lua_tointeger(L, 3), lua_tointeger(L, 4)); |
757 else gear := SpawnCustomCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), UtilityCrate, Trunc(lua_tonumber(L, 3)), Trunc(lua_tonumber(L, 4))); |
758 if gear <> nil then |
758 if gear <> nil then |
759 lua_pushinteger(L, gear^.uid) |
759 lua_pushnumber(L, gear^.uid) |
760 else lua_pushnil(L); |
760 else lua_pushnil(L); |
761 end |
761 end |
762 else |
762 else |
763 lua_pushnil(L); |
763 lua_pushnil(L); |
764 lc_spawnutilitycrate := 1; |
764 lc_spawnutilitycrate := 1; |
777 begin |
777 begin |
778 t:= LuaToGearTypeOrd(L, 3, call, params); |
778 t:= LuaToGearTypeOrd(L, 3, call, params); |
779 if t >= 0 then |
779 if t >= 0 then |
780 begin |
780 begin |
781 gt:= TGearType(t); |
781 gt:= TGearType(t); |
782 x:= lua_tointeger(L, 1); |
782 x:= Trunc(lua_tonumber(L, 1)); |
783 y:= lua_tointeger(L, 2); |
783 y:= Trunc(lua_tonumber(L, 2)); |
784 s:= lua_tointeger(L, 4); |
784 s:= Trunc(lua_tonumber(L, 4)); |
785 dx:= int2hwFloat(lua_tointeger(L, 5)) / 1000000; |
785 dx:= int2hwFloat(Trunc(lua_tonumber(L, 5))) / 1000000; |
786 dy:= int2hwFloat(lua_tointeger(L, 6)) / 1000000; |
786 dy:= int2hwFloat(Trunc(lua_tonumber(L, 6))) / 1000000; |
787 t:= lua_tointeger(L, 7); |
787 t:= Trunc(lua_tonumber(L, 7)); |
788 |
788 |
789 gear:= AddGear(x, y, gt, s, dx, dy, t); |
789 gear:= AddGear(x, y, gt, s, dx, dy, t); |
790 lastGearByUID:= gear; |
790 lastGearByUID:= gear; |
791 lua_pushinteger(L, gear^.uid) |
791 lua_pushnumber(L, gear^.uid) |
792 end |
792 end |
793 else |
793 else |
794 lua_pushnil(L); |
794 lua_pushnil(L); |
795 end |
795 end |
796 else |
796 else |
825 begin |
825 begin |
826 s:= LuaToVisualGearTypeOrd(L, 3, call, params); |
826 s:= LuaToVisualGearTypeOrd(L, 3, call, params); |
827 if s >= 0 then |
827 if s >= 0 then |
828 begin |
828 begin |
829 vgt:= TVisualGearType(s); |
829 vgt:= TVisualGearType(s); |
830 x:= lua_tointeger(L, 1); |
830 x:= Trunc(lua_tonumber(L, 1)); |
831 y:= lua_tointeger(L, 2); |
831 y:= Trunc(lua_tonumber(L, 2)); |
832 s:= lua_tointeger(L, 4); |
832 s:= Trunc(lua_tonumber(L, 4)); |
833 c:= lua_toboolean(L, 5); |
833 c:= lua_toboolean(L, 5); |
834 |
834 |
835 if n = 6 then |
835 if n = 6 then |
836 begin |
836 begin |
837 layer:= lua_tointeger(L, 6); |
837 layer:= Trunc(lua_tonumber(L, 6)); |
838 vg:= AddVisualGear(x, y, vgt, s, c, layer); |
838 vg:= AddVisualGear(x, y, vgt, s, c, layer); |
839 end |
839 end |
840 else |
840 else |
841 vg:= AddVisualGear(x, y, vgt, s, c); |
841 vg:= AddVisualGear(x, y, vgt, s, c); |
842 |
842 |
843 if vg <> nil then |
843 if vg <> nil then |
844 begin |
844 begin |
845 lastVisualGearByUID:= vg; |
845 lastVisualGearByUID:= vg; |
846 uid:= vg^.uid; |
846 uid:= vg^.uid; |
847 lua_pushinteger(L, uid); |
847 lua_pushnumber(L, uid); |
848 end; |
848 end; |
849 end |
849 end |
850 else |
850 else |
851 lua_pushnil(L); |
851 lua_pushnil(L); |
852 end |
852 end |
890 function lc_getvisualgearvalues(L : Plua_State) : LongInt; Cdecl; |
890 function lc_getvisualgearvalues(L : Plua_State) : LongInt; Cdecl; |
891 var vg: PVisualGear; |
891 var vg: PVisualGear; |
892 begin |
892 begin |
893 if CheckLuaParamCount(L, 1, 'GetVisualGearValues', 'vgUid') then |
893 if CheckLuaParamCount(L, 1, 'GetVisualGearValues', 'vgUid') then |
894 begin |
894 begin |
895 vg:= VisualGearByUID(lua_tointeger(L, 1)); |
895 vg:= VisualGearByUID(Trunc(lua_tonumber(L, 1))); |
896 if vg <> nil then |
896 if vg <> nil then |
897 begin |
897 begin |
898 lua_pushinteger(L, round(vg^.X)); |
898 lua_pushnumber(L, round(vg^.X)); |
899 lua_pushinteger(L, round(vg^.Y)); |
899 lua_pushnumber(L, round(vg^.Y)); |
900 lua_pushnumber(L, vg^.dX); |
900 lua_pushnumber(L, vg^.dX); |
901 lua_pushnumber(L, vg^.dY); |
901 lua_pushnumber(L, vg^.dY); |
902 lua_pushnumber(L, vg^.Angle); |
902 lua_pushnumber(L, vg^.Angle); |
903 lua_pushinteger(L, vg^.Frame); |
903 lua_pushnumber(L, vg^.Frame); |
904 lua_pushinteger(L, vg^.FrameTicks); |
904 lua_pushnumber(L, vg^.FrameTicks); |
905 lua_pushinteger(L, vg^.State); |
905 lua_pushnumber(L, vg^.State); |
906 lua_pushinteger(L, vg^.Timer); |
906 lua_pushnumber(L, vg^.Timer); |
907 lua_pushinteger(L, vg^.Tint); |
907 lua_pushnumber(L, vg^.Tint); |
908 end |
908 end |
909 else |
909 else |
910 begin |
910 begin |
911 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
911 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
912 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
912 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
924 var vg : PVisualGear; |
924 var vg : PVisualGear; |
925 begin |
925 begin |
926 // Param count can be 1-11 at present |
926 // Param count can be 1-11 at present |
927 // if CheckLuaParamCount(L, 11, 'SetVisualGearValues', 'vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint') then |
927 // if CheckLuaParamCount(L, 11, 'SetVisualGearValues', 'vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint') then |
928 // begin |
928 // begin |
929 vg:= VisualGearByUID(lua_tointeger(L, 1)); |
929 vg:= VisualGearByUID(Trunc(lua_tonumber(L, 1))); |
930 if vg <> nil then |
930 if vg <> nil then |
931 begin |
931 begin |
932 if not lua_isnoneornil(L, 2) then |
932 if not lua_isnoneornil(L, 2) then |
933 vg^.X:= lua_tointeger(L, 2); |
933 vg^.X:= Trunc(lua_tonumber(L, 2)); |
934 if not lua_isnoneornil(L, 3) then |
934 if not lua_isnoneornil(L, 3) then |
935 vg^.Y:= lua_tointeger(L, 3); |
935 vg^.Y:= Trunc(lua_tonumber(L, 3)); |
936 if not lua_isnoneornil(L, 4) then |
936 if not lua_isnoneornil(L, 4) then |
937 vg^.dX:= lua_tonumber(L, 4); |
937 vg^.dX:= lua_tonumber(L, 4); |
938 if not lua_isnoneornil(L, 5) then |
938 if not lua_isnoneornil(L, 5) then |
939 vg^.dY:= lua_tonumber(L, 5); |
939 vg^.dY:= lua_tonumber(L, 5); |
940 if not lua_isnoneornil(L, 6) then |
940 if not lua_isnoneornil(L, 6) then |
941 vg^.Angle:= lua_tonumber(L, 6); |
941 vg^.Angle:= lua_tonumber(L, 6); |
942 if not lua_isnoneornil(L, 7) then |
942 if not lua_isnoneornil(L, 7) then |
943 vg^.Frame:= lua_tointeger(L, 7); |
943 vg^.Frame:= Trunc(lua_tonumber(L, 7)); |
944 if not lua_isnoneornil(L, 8) then |
944 if not lua_isnoneornil(L, 8) then |
945 vg^.FrameTicks:= lua_tointeger(L, 8); |
945 vg^.FrameTicks:= Trunc(lua_tonumber(L, 8)); |
946 if not lua_isnoneornil(L, 9) then |
946 if not lua_isnoneornil(L, 9) then |
947 vg^.State:= lua_tointeger(L, 9); |
947 vg^.State:= Trunc(lua_tonumber(L, 9)); |
948 if not lua_isnoneornil(L, 10) then |
948 if not lua_isnoneornil(L, 10) then |
949 vg^.Timer:= lua_tointeger(L, 10); |
949 vg^.Timer:= Trunc(lua_tonumber(L, 10)); |
950 if not lua_isnoneornil(L, 11) then |
950 if not lua_isnoneornil(L, 11) then |
951 vg^.Tint:= lua_tointeger(L, 11) |
951 vg^.Tint:= Trunc(lua_tonumber(L, 11)) |
952 end; |
952 end; |
953 // end |
953 // end |
954 // else |
954 // else |
955 // lua_pushnil(L); // return value on stack (nil) |
955 // lua_pushnil(L); // return value on stack (nil) |
956 lc_setvisualgearvalues:= 0 |
956 lc_setvisualgearvalues:= 0 |
961 function lc_getgearvalues(L : Plua_State) : LongInt; Cdecl; |
961 function lc_getgearvalues(L : Plua_State) : LongInt; Cdecl; |
962 var gear: PGear; |
962 var gear: PGear; |
963 begin |
963 begin |
964 if CheckLuaParamCount(L, 1, 'GetGearValues', 'gearUid') then |
964 if CheckLuaParamCount(L, 1, 'GetGearValues', 'gearUid') then |
965 begin |
965 begin |
966 gear:= GearByUID(lua_tointeger(L, 1)); |
966 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
967 if gear <> nil then |
967 if gear <> nil then |
968 begin |
968 begin |
969 lua_pushinteger(L, gear^.Angle); |
969 lua_pushnumber(L, gear^.Angle); |
970 lua_pushinteger(L, gear^.Power); |
970 lua_pushnumber(L, gear^.Power); |
971 lua_pushinteger(L, gear^.WDTimer); |
971 lua_pushnumber(L, gear^.WDTimer); |
972 lua_pushinteger(L, gear^.Radius); |
972 lua_pushnumber(L, gear^.Radius); |
973 lua_pushinteger(L, hwRound(gear^.Density * _10000)); |
973 lua_pushnumber(L, hwRound(gear^.Density * _10000)); |
974 lua_pushinteger(L, gear^.Karma); |
974 lua_pushnumber(L, gear^.Karma); |
975 lua_pushnumber(L, gear^.DirAngle); |
975 lua_pushnumber(L, gear^.DirAngle); |
976 lua_pushinteger(L, gear^.AdvBounce); |
976 lua_pushnumber(L, gear^.AdvBounce); |
977 lua_pushinteger(L, Integer(gear^.ImpactSound)); |
977 lua_pushnumber(L, Integer(gear^.ImpactSound)); |
978 lua_pushinteger(L, gear^.nImpactSounds); |
978 lua_pushnumber(L, gear^.nImpactSounds); |
979 lua_pushinteger(L, gear^.Tint); |
979 lua_pushnumber(L, gear^.Tint); |
980 lua_pushinteger(L, gear^.Damage); |
980 lua_pushnumber(L, gear^.Damage); |
981 lua_pushinteger(L, gear^.Boom) |
981 lua_pushnumber(L, gear^.Boom) |
982 end |
982 end |
983 else |
983 else |
984 begin |
984 begin |
985 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
985 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
986 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
986 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
1000 var gear : PGear; |
1000 var gear : PGear; |
1001 begin |
1001 begin |
1002 // Currently allows 1-14 params |
1002 // Currently allows 1-14 params |
1003 // if CheckLuaParamCount(L, 14, 'SetGearValues', 'gearUid, Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, # ImpactSounds, Tint, Damage, Boom') then |
1003 // if CheckLuaParamCount(L, 14, 'SetGearValues', 'gearUid, Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, # ImpactSounds, Tint, Damage, Boom') then |
1004 // begin |
1004 // begin |
1005 gear:= GearByUID(lua_tointeger(L, 1)); |
1005 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1006 if gear <> nil then |
1006 if gear <> nil then |
1007 begin |
1007 begin |
1008 if not lua_isnoneornil(L, 2) then |
1008 if not lua_isnoneornil(L, 2) then |
1009 gear^.Angle := lua_tointeger(L, 2); |
1009 gear^.Angle := Trunc(lua_tonumber(L, 2)); |
1010 if not lua_isnoneornil(L, 3) then |
1010 if not lua_isnoneornil(L, 3) then |
1011 gear^.Power := lua_tointeger(L, 3); |
1011 gear^.Power := Trunc(lua_tonumber(L, 3)); |
1012 if not lua_isnoneornil(L, 4) then |
1012 if not lua_isnoneornil(L, 4) then |
1013 gear^.WDTimer := lua_tointeger(L, 4); |
1013 gear^.WDTimer := Trunc(lua_tonumber(L, 4)); |
1014 if not lua_isnoneornil(L, 5) then |
1014 if not lua_isnoneornil(L, 5) then |
1015 gear^.Radius := lua_tointeger(L, 5); |
1015 gear^.Radius := Trunc(lua_tonumber(L, 5)); |
1016 if not lua_isnoneornil(L, 6) then |
1016 if not lua_isnoneornil(L, 6) then |
1017 gear^.Density:= int2hwFloat(lua_tointeger(L, 6)) / 10000; |
1017 gear^.Density:= int2hwFloat(Trunc(lua_tonumber(L, 6))) / 10000; |
1018 if not lua_isnoneornil(L, 7) then |
1018 if not lua_isnoneornil(L, 7) then |
1019 gear^.Karma := lua_tointeger(L, 7); |
1019 gear^.Karma := Trunc(lua_tonumber(L, 7)); |
1020 if not lua_isnoneornil(L, 8) then |
1020 if not lua_isnoneornil(L, 8) then |
1021 gear^.DirAngle:= lua_tonumber(L, 8); |
1021 gear^.DirAngle:= lua_tonumber(L, 8); |
1022 if not lua_isnoneornil(L, 9) then |
1022 if not lua_isnoneornil(L, 9) then |
1023 gear^.AdvBounce := lua_tointeger(L, 9); |
1023 gear^.AdvBounce := Trunc(lua_tonumber(L, 9)); |
1024 if not lua_isnoneornil(L, 10) then |
1024 if not lua_isnoneornil(L, 10) then |
1025 gear^.ImpactSound := TSound(lua_tointeger(L, 10)); |
1025 gear^.ImpactSound := TSound(Trunc(lua_tonumber(L, 10))); |
1026 if not lua_isnoneornil(L, 11) then |
1026 if not lua_isnoneornil(L, 11) then |
1027 gear^.nImpactSounds := lua_tointeger(L, 11); |
1027 gear^.nImpactSounds := Trunc(lua_tonumber(L, 11)); |
1028 if not lua_isnoneornil(L, 12) then |
1028 if not lua_isnoneornil(L, 12) then |
1029 gear^.Tint := lua_tointeger(L, 12); |
1029 gear^.Tint := Trunc(lua_tonumber(L, 12)); |
1030 if not lua_isnoneornil(L, 13) then |
1030 if not lua_isnoneornil(L, 13) then |
1031 gear^.Damage := lua_tointeger(L, 13); |
1031 gear^.Damage := Trunc(lua_tonumber(L, 13)); |
1032 if not lua_isnoneornil(L, 14) then |
1032 if not lua_isnoneornil(L, 14) then |
1033 gear^.Boom := lua_tointeger(L, 14); |
1033 gear^.Boom := Trunc(lua_tonumber(L, 14)); |
1034 end; |
1034 end; |
1035 // end |
1035 // end |
1036 // else |
1036 // else |
1037 // lua_pushnil(L); // return value on stack (nil) |
1037 // lua_pushnil(L); // return value on stack (nil) |
1038 lc_setgearvalues:= 0 |
1038 lc_setgearvalues:= 0 |
1103 function lc_setgearelasticity(L : Plua_State) : LongInt; Cdecl; |
1103 function lc_setgearelasticity(L : Plua_State) : LongInt; Cdecl; |
1104 var gear: PGear; |
1104 var gear: PGear; |
1105 begin |
1105 begin |
1106 if CheckLuaParamCount(L, 2, 'SetGearElasticity', 'gearUid, Elasticity') then |
1106 if CheckLuaParamCount(L, 2, 'SetGearElasticity', 'gearUid, Elasticity') then |
1107 begin |
1107 begin |
1108 gear:= GearByUID(lua_tointeger(L, 1)); |
1108 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1109 if gear <> nil then |
1109 if gear <> nil then |
1110 gear^.Elasticity:= int2hwFloat(lua_tointeger(L, 2)) / 10000 |
1110 gear^.Elasticity:= int2hwFloat(Trunc(lua_tonumber(L, 2))) / 10000 |
1111 end; |
1111 end; |
1112 lc_setgearelasticity:= 0 |
1112 lc_setgearelasticity:= 0 |
1113 end; |
1113 end; |
1114 |
1114 |
1115 function lc_getgearfriction(L : Plua_State) : LongInt; Cdecl; |
1115 function lc_getgearfriction(L : Plua_State) : LongInt; Cdecl; |
1116 var gear : PGear; |
1116 var gear : PGear; |
1117 begin |
1117 begin |
1118 if CheckLuaParamCount(L, 1, 'GetGearFriction', 'gearUid') then |
1118 if CheckLuaParamCount(L, 1, 'GetGearFriction', 'gearUid') then |
1119 begin |
1119 begin |
1120 gear:= GearByUID(lua_tointeger(L, 1)); |
1120 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1121 if gear <> nil then |
1121 if gear <> nil then |
1122 lua_pushinteger(L, hwRound(gear^.friction * _10000)) |
1122 lua_pushnumber(L, hwRound(gear^.friction * _10000)) |
1123 else |
1123 else |
1124 lua_pushnil(L); |
1124 lua_pushnil(L); |
1125 end |
1125 end |
1126 else |
1126 else |
1127 lua_pushnil(L); // return value on stack (nil) |
1127 lua_pushnil(L); // return value on stack (nil) |
1131 function lc_setgearfriction(L : Plua_State) : LongInt; Cdecl; |
1131 function lc_setgearfriction(L : Plua_State) : LongInt; Cdecl; |
1132 var gear: PGear; |
1132 var gear: PGear; |
1133 begin |
1133 begin |
1134 if CheckLuaParamCount(L, 2, 'SetGearFriction', 'gearUid, Friction') then |
1134 if CheckLuaParamCount(L, 2, 'SetGearFriction', 'gearUid, Friction') then |
1135 begin |
1135 begin |
1136 gear:= GearByUID(lua_tointeger(L, 1)); |
1136 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1137 if gear <> nil then |
1137 if gear <> nil then |
1138 gear^.Friction:= int2hwFloat(lua_tointeger(L, 2)) / 10000 |
1138 gear^.Friction:= int2hwFloat(Trunc(lua_tonumber(L, 2))) / 10000 |
1139 end; |
1139 end; |
1140 lc_setgearfriction:= 0 |
1140 lc_setgearfriction:= 0 |
1141 end; |
1141 end; |
1142 |
1142 |
1143 function lc_setgearmessage(L : Plua_State) : LongInt; Cdecl; |
1143 function lc_setgearmessage(L : Plua_State) : LongInt; Cdecl; |
1144 var gear : PGear; |
1144 var gear : PGear; |
1145 begin |
1145 begin |
1146 if CheckLuaParamCount(L, 2, 'SetGearMessage', 'gearUid, message') then |
1146 if CheckLuaParamCount(L, 2, 'SetGearMessage', 'gearUid, message') then |
1147 begin |
1147 begin |
1148 gear:= GearByUID(lua_tointeger(L, 1)); |
1148 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1149 if gear <> nil then |
1149 if gear <> nil then |
1150 gear^.message:= lua_tointeger(L, 2); |
1150 gear^.message:= Trunc(lua_tonumber(L, 2)); |
1151 end; |
1151 end; |
1152 lc_setgearmessage:= 0 |
1152 lc_setgearmessage:= 0 |
1153 end; |
1153 end; |
1154 |
1154 |
1155 function lc_getgearpos(L : Plua_State) : LongInt; Cdecl; |
1155 function lc_getgearpos(L : Plua_State) : LongInt; Cdecl; |
1156 var gear : PGear; |
1156 var gear : PGear; |
1157 begin |
1157 begin |
1158 if CheckLuaParamCount(L, 1, 'GetGearPos', 'gearUid') then |
1158 if CheckLuaParamCount(L, 1, 'GetGearPos', 'gearUid') then |
1159 begin |
1159 begin |
1160 gear:= GearByUID(lua_tointeger(L, 1)); |
1160 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1161 if gear <> nil then |
1161 if gear <> nil then |
1162 lua_pushinteger(L, gear^.Pos) |
1162 lua_pushnumber(L, gear^.Pos) |
1163 else |
1163 else |
1164 lua_pushnil(L); |
1164 lua_pushnil(L); |
1165 end |
1165 end |
1166 else |
1166 else |
1167 lua_pushnil(L); // return value on stack (nil) |
1167 lua_pushnil(L); // return value on stack (nil) |
1171 function lc_setgearpos(L : Plua_State) : LongInt; Cdecl; |
1171 function lc_setgearpos(L : Plua_State) : LongInt; Cdecl; |
1172 var gear : PGear; |
1172 var gear : PGear; |
1173 begin |
1173 begin |
1174 if CheckLuaParamCount(L, 2, 'SetGearPos', 'gearUid, value') then |
1174 if CheckLuaParamCount(L, 2, 'SetGearPos', 'gearUid, value') then |
1175 begin |
1175 begin |
1176 gear:= GearByUID(lua_tointeger(L, 1)); |
1176 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1177 if gear <> nil then |
1177 if gear <> nil then |
1178 gear^.Pos:= lua_tointeger(L, 2); |
1178 gear^.Pos:= Trunc(lua_tonumber(L, 2)); |
1179 end; |
1179 end; |
1180 lc_setgearpos:= 0 |
1180 lc_setgearpos:= 0 |
1181 end; |
1181 end; |
1182 |
1182 |
1183 function lc_getgearcollisionmask(L : Plua_State) : LongInt; Cdecl; |
1183 function lc_getgearcollisionmask(L : Plua_State) : LongInt; Cdecl; |
1184 var gear : PGear; |
1184 var gear : PGear; |
1185 begin |
1185 begin |
1186 if CheckLuaParamCount(L, 1, 'GetGearCollisionMask', 'gearUid') then |
1186 if CheckLuaParamCount(L, 1, 'GetGearCollisionMask', 'gearUid') then |
1187 begin |
1187 begin |
1188 gear:= GearByUID(lua_tointeger(L, 1)); |
1188 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1189 if gear <> nil then |
1189 if gear <> nil then |
1190 lua_pushinteger(L, gear^.CollisionMask) |
1190 lua_pushnumber(L, gear^.CollisionMask) |
1191 else |
1191 else |
1192 lua_pushnil(L); |
1192 lua_pushnil(L); |
1193 end |
1193 end |
1194 else |
1194 else |
1195 lua_pushnil(L); // return value on stack (nil) |
1195 lua_pushnil(L); // return value on stack (nil) |
1199 function lc_setgearcollisionmask(L : Plua_State) : LongInt; Cdecl; |
1199 function lc_setgearcollisionmask(L : Plua_State) : LongInt; Cdecl; |
1200 var gear : PGear; |
1200 var gear : PGear; |
1201 begin |
1201 begin |
1202 if CheckLuaParamCount(L, 2, 'SetGearCollisionMask', 'gearUid, mask') then |
1202 if CheckLuaParamCount(L, 2, 'SetGearCollisionMask', 'gearUid, mask') then |
1203 begin |
1203 begin |
1204 gear:= GearByUID(lua_tointeger(L, 1)); |
1204 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1205 if gear <> nil then |
1205 if gear <> nil then |
1206 gear^.CollisionMask:= lua_tointeger(L, 2); |
1206 gear^.CollisionMask:= Trunc(lua_tonumber(L, 2)); |
1207 end; |
1207 end; |
1208 lc_setgearcollisionmask:= 0 |
1208 lc_setgearcollisionmask:= 0 |
1209 end; |
1209 end; |
1210 |
1210 |
1211 function lc_gethoglevel(L : Plua_State): LongInt; Cdecl; |
1211 function lc_gethoglevel(L : Plua_State): LongInt; Cdecl; |
1212 var gear : PGear; |
1212 var gear : PGear; |
1213 begin |
1213 begin |
1214 if CheckLuaParamCount(L, 1, 'GetHogLevel', 'gearUid') then |
1214 if CheckLuaParamCount(L, 1, 'GetHogLevel', 'gearUid') then |
1215 begin |
1215 begin |
1216 gear := GearByUID(lua_tointeger(L, 1)); |
1216 gear := GearByUID(Trunc(lua_tonumber(L, 1))); |
1217 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
1217 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
1218 lua_pushinteger(L, gear^.Hedgehog^.BotLevel) |
1218 lua_pushnumber(L, gear^.Hedgehog^.BotLevel) |
1219 else |
1219 else |
1220 lua_pushnil(L); |
1220 lua_pushnil(L); |
1221 end; |
1221 end; |
1222 lc_gethoglevel := 1; |
1222 lc_gethoglevel := 1; |
1223 end; |
1223 end; |
1225 function lc_sethoglevel(L : Plua_State) : LongInt; Cdecl; |
1225 function lc_sethoglevel(L : Plua_State) : LongInt; Cdecl; |
1226 var gear : PGear; |
1226 var gear : PGear; |
1227 begin |
1227 begin |
1228 if CheckLuaParamCount(L, 2, 'SetHogLevel', 'gearUid, level') then |
1228 if CheckLuaParamCount(L, 2, 'SetHogLevel', 'gearUid, level') then |
1229 begin |
1229 begin |
1230 gear:= GearByUID(lua_tointeger(L, 1)); |
1230 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1231 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1231 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1232 gear^.Hedgehog^.BotLevel:= lua_tointeger(L, 2); |
1232 gear^.Hedgehog^.BotLevel:= Trunc(lua_tonumber(L, 2)); |
1233 end; |
1233 end; |
1234 lc_sethoglevel:= 0 |
1234 lc_sethoglevel:= 0 |
1235 end; |
1235 end; |
1236 |
1236 |
1237 function lc_gethogclan(L : Plua_State) : LongInt; Cdecl; |
1237 function lc_gethogclan(L : Plua_State) : LongInt; Cdecl; |
1238 var gear : PGear; |
1238 var gear : PGear; |
1239 begin |
1239 begin |
1240 if CheckLuaParamCount(L, 1, 'GetHogClan', 'gearUid') then |
1240 if CheckLuaParamCount(L, 1, 'GetHogClan', 'gearUid') then |
1241 begin |
1241 begin |
1242 gear:= GearByUID(lua_tointeger(L, 1)); |
1242 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1243 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
1243 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
1244 begin |
1244 begin |
1245 lua_pushinteger(L, gear^.Hedgehog^.Team^.Clan^.ClanIndex) |
1245 lua_pushnumber(L, gear^.Hedgehog^.Team^.Clan^.ClanIndex) |
1246 end |
1246 end |
1247 else |
1247 else |
1248 lua_pushnil(L); |
1248 lua_pushnil(L); |
1249 end |
1249 end |
1250 else |
1250 else |
1552 function lc_copypv(L : Plua_State) : LongInt; Cdecl; |
1552 function lc_copypv(L : Plua_State) : LongInt; Cdecl; |
1553 var gears, geard : PGear; |
1553 var gears, geard : PGear; |
1554 begin |
1554 begin |
1555 if CheckLuaParamCount(L, 2, 'CopyPV', 'fromGearUid, toGearUid') then |
1555 if CheckLuaParamCount(L, 2, 'CopyPV', 'fromGearUid, toGearUid') then |
1556 begin |
1556 begin |
1557 gears:= GearByUID(lua_tointeger(L, 1)); |
1557 gears:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1558 geard:= GearByUID(lua_tointeger(L, 2)); |
1558 geard:= GearByUID(Trunc(lua_tonumber(L, 2))); |
1559 if (gears <> nil) and (geard <> nil) then |
1559 if (gears <> nil) and (geard <> nil) then |
1560 begin |
1560 begin |
1561 geard^.X:= gears^.X; |
1561 geard^.X:= gears^.X; |
1562 geard^.Y:= gears^.Y; |
1562 geard^.Y:= gears^.Y; |
1563 geard^.dX:= gears^.dX; |
1563 geard^.dX:= gears^.dX; |
1584 s : LongWord; |
1584 s : LongWord; |
1585 n : LongInt; |
1585 n : LongInt; |
1586 begin |
1586 begin |
1587 if CheckAndFetchParamCount(L, 3, 4, 'HogSay', 'gearUid, text, manner [, vgState]', n) then |
1587 if CheckAndFetchParamCount(L, 3, 4, 'HogSay', 'gearUid, text, manner [, vgState]', n) then |
1588 begin |
1588 begin |
1589 gear:= GearByUID(lua_tointeger(L, 1)); |
1589 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1590 if gear <> nil then |
1590 if gear <> nil then |
1591 begin |
1591 begin |
1592 // state defaults to 0 if state param is given |
1592 // state defaults to 0 if state param is given |
1593 if n = 4 then |
1593 if n = 4 then |
1594 s:= lua_tointeger(L, 4) |
1594 s:= Trunc(lua_tonumber(L, 4)) |
1595 else |
1595 else |
1596 s:= 0; |
1596 s:= 0; |
1597 vgear:= AddVisualGear(0, 0, vgtSpeechBubble, s, true); |
1597 vgear:= AddVisualGear(0, 0, vgtSpeechBubble, s, true); |
1598 if vgear <> nil then |
1598 if vgear <> nil then |
1599 begin |
1599 begin |
1622 function lc_switchhog(L : Plua_State) : LongInt; Cdecl; |
1622 function lc_switchhog(L : Plua_State) : LongInt; Cdecl; |
1623 var gear, prevgear : PGear; |
1623 var gear, prevgear : PGear; |
1624 begin |
1624 begin |
1625 if CheckLuaParamCount(L, 1, 'SwitchHog', 'gearUid') then |
1625 if CheckLuaParamCount(L, 1, 'SwitchHog', 'gearUid') then |
1626 begin |
1626 begin |
1627 gear:= GearByUID(lua_tointeger(L, 1)); |
1627 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1628 // should we allow this when there is no current hedgehog? might do some odd(er) things to turn sequence. |
1628 // should we allow this when there is no current hedgehog? might do some odd(er) things to turn sequence. |
1629 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) and (CurrentHedgehog <> nil) then |
1629 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) and (CurrentHedgehog <> nil) then |
1630 begin |
1630 begin |
1631 prevgear := CurrentHedgehog^.Gear; |
1631 prevgear := CurrentHedgehog^.Gear; |
1632 if prevgear <> nil then |
1632 if prevgear <> nil then |
1659 if CheckAndFetchParamCount(L, 2, 3, call, params, n) then |
1659 if CheckAndFetchParamCount(L, 2, 3, call, params, n) then |
1660 begin |
1660 begin |
1661 at:= LuaToAmmoTypeOrd(L, 2, call, params); |
1661 at:= LuaToAmmoTypeOrd(L, 2, call, params); |
1662 if at >= 0 then |
1662 if at >= 0 then |
1663 begin |
1663 begin |
1664 gear:= GearByUID(lua_tointeger(L, 1)); |
1664 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1665 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1665 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1666 if n = 2 then |
1666 if n = 2 then |
1667 AddAmmo(gear^.Hedgehog^, TAmmoType(at)) |
1667 AddAmmo(gear^.Hedgehog^, TAmmoType(at)) |
1668 else |
1668 else |
1669 SetAmmo(gear^.Hedgehog^, TAmmoType(at), lua_tointeger(L, 3)) |
1669 SetAmmo(gear^.Hedgehog^, TAmmoType(at), Trunc(lua_tonumber(L, 3))) |
1670 end; |
1670 end; |
1671 end; |
1671 end; |
1672 lc_addammo:= 0 |
1672 lc_addammo:= 0 |
1673 end; |
1673 end; |
1674 |
1674 |
1680 call = 'GetAmmoCount'; |
1680 call = 'GetAmmoCount'; |
1681 params = 'gearUid, ammoType'; |
1681 params = 'gearUid, ammoType'; |
1682 begin |
1682 begin |
1683 if CheckLuaParamCount(L, 2, call, params) then |
1683 if CheckLuaParamCount(L, 2, call, params) then |
1684 begin |
1684 begin |
1685 gear:= GearByUID(lua_tointeger(L, 1)); |
1685 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1686 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1686 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1687 begin |
1687 begin |
1688 at:= LuaToAmmoTypeOrd(L, 2, call, params); |
1688 at:= LuaToAmmoTypeOrd(L, 2, call, params); |
1689 if at >= 0 then |
1689 if at >= 0 then |
1690 begin |
1690 begin |
1691 ammo:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(at)); |
1691 ammo:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(at)); |
1692 if ammo^.AmmoType = amNothing then |
1692 if ammo^.AmmoType = amNothing then |
1693 lua_pushinteger(L, 0) |
1693 lua_pushnumber(L, 0) |
1694 else |
1694 else |
1695 lua_pushinteger(L, ammo^.Count); |
1695 lua_pushnumber(L, ammo^.Count); |
1696 end; |
1696 end; |
1697 end |
1697 end |
1698 else lua_pushinteger(L, 0); |
1698 else lua_pushnumber(L, 0); |
1699 end |
1699 end |
1700 else |
1700 else |
1701 lua_pushnil(L); |
1701 lua_pushnil(L); |
1702 lc_getammocount:= 1 |
1702 lc_getammocount:= 1 |
1703 end; |
1703 end; |
1729 function lc_settimer(L : Plua_State) : LongInt; Cdecl; |
1729 function lc_settimer(L : Plua_State) : LongInt; Cdecl; |
1730 var gear : PGear; |
1730 var gear : PGear; |
1731 begin |
1731 begin |
1732 if CheckLuaParamCount(L, 2, 'SetTimer', 'gearUid, timer') then |
1732 if CheckLuaParamCount(L, 2, 'SetTimer', 'gearUid, timer') then |
1733 begin |
1733 begin |
1734 gear:= GearByUID(lua_tointeger(L, 1)); |
1734 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1735 if gear <> nil then gear^.Timer:= lua_tointeger(L, 2) |
1735 if gear <> nil then gear^.Timer:= Trunc(lua_tonumber(L, 2)) |
1736 end; |
1736 end; |
1737 lc_settimer:= 0 |
1737 lc_settimer:= 0 |
1738 end; |
1738 end; |
1739 |
1739 |
1740 function lc_setflighttime(L : Plua_State) : LongInt; Cdecl; |
1740 function lc_setflighttime(L : Plua_State) : LongInt; Cdecl; |
1741 var gear : PGear; |
1741 var gear : PGear; |
1742 begin |
1742 begin |
1743 if CheckLuaParamCount(L, 2, 'SetFlightTime', 'gearUid, flighttime') then |
1743 if CheckLuaParamCount(L, 2, 'SetFlightTime', 'gearUid, flighttime') then |
1744 begin |
1744 begin |
1745 gear:= GearByUID(lua_tointeger(L, 1)); |
1745 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1746 if gear <> nil then gear^.FlightTime:= lua_tointeger(L, 2) |
1746 if gear <> nil then gear^.FlightTime:= Trunc(lua_tonumber(L, 2)) |
1747 end; |
1747 end; |
1748 lc_setflighttime:= 0 |
1748 lc_setflighttime:= 0 |
1749 end; |
1749 end; |
1750 |
1750 |
1751 function lc_seteffect(L : Plua_State) : LongInt; Cdecl; |
1751 function lc_seteffect(L : Plua_State) : LongInt; Cdecl; |
1778 if CheckLuaParamCount(L, 2, call, params) then |
1778 if CheckLuaParamCount(L, 2, call, params) then |
1779 begin |
1779 begin |
1780 t:= LuaToHogEffectOrd(L, 2, call, params); |
1780 t:= LuaToHogEffectOrd(L, 2, call, params); |
1781 if t >= 0 then |
1781 if t >= 0 then |
1782 begin |
1782 begin |
1783 gear:= GearByUID(lua_tointeger(L, 1)); |
1783 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1784 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1784 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1785 lua_pushinteger(L, gear^.Hedgehog^.Effects[THogEffect(t)]) |
1785 lua_pushnumber(L, gear^.Hedgehog^.Effects[THogEffect(t)]) |
1786 else |
1786 else |
1787 lua_pushinteger(L, 0) |
1787 lua_pushnumber(L, 0) |
1788 end; |
1788 end; |
1789 end |
1789 end |
1790 else |
1790 else |
1791 lua_pushinteger(L, 0); |
1791 lua_pushnumber(L, 0); |
1792 lc_geteffect:= 1 |
1792 lc_geteffect:= 1 |
1793 end; |
1793 end; |
1794 |
1794 |
1795 function lc_setstate(L : Plua_State) : LongInt; Cdecl; |
1795 function lc_setstate(L : Plua_State) : LongInt; Cdecl; |
1796 var gear : PGear; |
1796 var gear : PGear; |
1797 begin |
1797 begin |
1798 if CheckLuaParamCount(L, 2, 'SetState', 'gearUid, state') then |
1798 if CheckLuaParamCount(L, 2, 'SetState', 'gearUid, state') then |
1799 begin |
1799 begin |
1800 gear:= GearByUID(lua_tointeger(L, 1)); |
1800 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1801 if gear <> nil then |
1801 if gear <> nil then |
1802 begin |
1802 begin |
1803 gear^.State:= lua_tointeger(L, 2); |
1803 gear^.State:= Trunc(lua_tonumber(L, 2)); |
1804 SetAllToActive; |
1804 SetAllToActive; |
1805 end |
1805 end |
1806 end; |
1806 end; |
1807 lc_setstate:= 0 |
1807 lc_setstate:= 0 |
1808 end; |
1808 end; |
1950 tryhard: boolean; |
1950 tryhard: boolean; |
1951 left, right, n: LongInt; |
1951 left, right, n: LongInt; |
1952 begin |
1952 begin |
1953 if CheckAndFetchParamCount(L, 4, 5, 'FindPlace', 'gearUid, fall, left, right [, tryHarder]', n) then |
1953 if CheckAndFetchParamCount(L, 4, 5, 'FindPlace', 'gearUid, fall, left, right [, tryHarder]', n) then |
1954 begin |
1954 begin |
1955 gear:= GearByUID(lua_tointeger(L, 1)); |
1955 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1956 fall:= lua_toboolean(L, 2); |
1956 fall:= lua_toboolean(L, 2); |
1957 left:= lua_tointeger(L, 3); |
1957 left:= Trunc(lua_tonumber(L, 3)); |
1958 right:= lua_tointeger(L, 4); |
1958 right:= Trunc(lua_tonumber(L, 4)); |
1959 if n = 5 then |
1959 if n = 5 then |
1960 tryhard:= lua_toboolean(L, 5) |
1960 tryhard:= lua_toboolean(L, 5) |
1961 else |
1961 else |
1962 tryhard:= false; |
1962 tryhard:= false; |
1963 if gear <> nil then |
1963 if gear <> nil then |
1964 FindPlace(gear, fall, left, right, tryhard); |
1964 FindPlace(gear, fall, left, right, tryhard); |
1965 if gear <> nil then |
1965 if gear <> nil then |
1966 lua_pushinteger(L, gear^.uid) |
1966 lua_pushnumber(L, gear^.uid) |
1967 else |
1967 else |
1968 lua_pushnil(L); |
1968 lua_pushnil(L); |
1969 end |
1969 end |
1970 else |
1970 else |
1971 lua_pushnil(L); // return value on stack (nil) |
1971 lua_pushnil(L); // return value on stack (nil) |
2066 if CheckLuaParamCount(L, 4, 'AddHog', 'hogname, botlevel, health, hat') then |
2066 if CheckLuaParamCount(L, 4, 'AddHog', 'hogname, botlevel, health, hat') then |
2067 begin |
2067 begin |
2068 temp:= lua_tostring(L, 4); |
2068 temp:= lua_tostring(L, 4); |
2069 ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true, true); |
2069 ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true, true); |
2070 ParseCommand('hat ' + temp, true, true); |
2070 ParseCommand('hat ' + temp, true, true); |
2071 lua_pushinteger(L, CurrentHedgehog^.Gear^.uid); |
2071 lua_pushnumber(L, CurrentHedgehog^.Gear^.uid); |
2072 end |
2072 end |
2073 else |
2073 else |
2074 lua_pushnil(L); |
2074 lua_pushnil(L); |
2075 lc_addhog:= 1; |
2075 lc_addhog:= 1; |
2076 end; |
2076 end; |
2249 begin |
2249 begin |
2250 at:= LuaToAmmoTypeOrd(L, 1, call, params); |
2250 at:= LuaToAmmoTypeOrd(L, 1, call, params); |
2251 if at >= 0 then |
2251 if at >= 0 then |
2252 begin |
2252 begin |
2253 if np = 4 then |
2253 if np = 4 then |
2254 ScriptSetAmmo(TAmmoType(at), lua_tointeger(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4), 1) |
2254 ScriptSetAmmo(TAmmoType(at), Trunc(lua_tonumber(L, 2)), Trunc(lua_tonumber(L, 3)), Trunc(lua_tonumber(L, 4)), 1) |
2255 else |
2255 else |
2256 ScriptSetAmmo(TAmmoType(at), lua_tointeger(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5)); |
2256 ScriptSetAmmo(TAmmoType(at), Trunc(lua_tonumber(L, 2)), Trunc(lua_tonumber(L, 3)), Trunc(lua_tonumber(L, 4)), Trunc(lua_tonumber(L, 5))); |
2257 end; |
2257 end; |
2258 end; |
2258 end; |
2259 lc_setammo:= 0 |
2259 lc_setammo:= 0 |
2260 end; |
2260 end; |
2261 |
2261 |
2267 begin |
2267 begin |
2268 if CheckLuaParamCount(L, 2, call, params) then |
2268 if CheckLuaParamCount(L, 2, call, params) then |
2269 begin |
2269 begin |
2270 at:= LuaToAmmoTypeOrd(L, 1, call, params); |
2270 at:= LuaToAmmoTypeOrd(L, 1, call, params); |
2271 if at >= 0 then |
2271 if at >= 0 then |
2272 ScriptSetAmmoDelay(TAmmoType(at), lua_tointeger(L, 2)); |
2272 ScriptSetAmmoDelay(TAmmoType(at), Trunc(lua_tonumber(L, 2))); |
2273 end; |
2273 end; |
2274 lc_setammodelay:= 0 |
2274 lc_setammodelay:= 0 |
2275 end; |
2275 end; |
2276 |
2276 |
2277 function lc_getrandom(L : Plua_State) : LongInt; Cdecl; |
2277 function lc_getrandom(L : Plua_State) : LongInt; Cdecl; |
2278 var m : LongInt; |
2278 var m : LongInt; |
2279 begin |
2279 begin |
2280 if CheckLuaParamCount(L, 1, 'GetRandom', 'number') then |
2280 if CheckLuaParamCount(L, 1, 'GetRandom', 'number') then |
2281 begin |
2281 begin |
2282 m:= lua_tointeger(L, 1); |
2282 m:= Trunc(lua_tonumber(L, 1)); |
2283 if (m > 0) then |
2283 if (m > 0) then |
2284 lua_pushinteger(L, GetRandom(m)) |
2284 lua_pushnumber(L, GetRandom(m)) |
2285 else |
2285 else |
2286 begin |
2286 begin |
2287 LuaError('Lua: Tried to pass 0 to GetRandom!'); |
2287 LuaError('Lua: Tried to pass 0 to GetRandom!'); |
2288 lua_pushnil(L); |
2288 lua_pushnil(L); |
2289 end |
2289 end |
2295 |
2295 |
2296 function lc_setwind(L : Plua_State) : LongInt; Cdecl; |
2296 function lc_setwind(L : Plua_State) : LongInt; Cdecl; |
2297 begin |
2297 begin |
2298 if CheckLuaParamCount(L, 1, 'SetWind', 'windSpeed') then |
2298 if CheckLuaParamCount(L, 1, 'SetWind', 'windSpeed') then |
2299 begin |
2299 begin |
2300 cWindSpeed:= int2hwfloat(lua_tointeger(L, 1)) / 100 * cMaxWindSpeed; |
2300 cWindSpeed:= int2hwfloat(Trunc(lua_tonumber(L, 1))) / 100 * cMaxWindSpeed; |
2301 cWindSpeedf:= SignAs(cWindSpeed,cWindSpeed).QWordValue / SignAs(_1,_1).QWordValue; |
2301 cWindSpeedf:= SignAs(cWindSpeed,cWindSpeed).QWordValue / SignAs(_1,_1).QWordValue; |
2302 if cWindSpeed.isNegative then |
2302 if cWindSpeed.isNegative then |
2303 CWindSpeedf := -cWindSpeedf; |
2303 CWindSpeedf := -cWindSpeedf; |
2304 AddVisualGear(0, 0, vgtSmoothWindBar); |
2304 AddVisualGear(0, 0, vgtSmoothWindBar); |
2305 end; |
2305 end; |
2380 begin |
2380 begin |
2381 placed:= false; |
2381 placed:= false; |
2382 if CheckAndFetchLuaParamMinCount(L, 4, call, params, n) then |
2382 if CheckAndFetchLuaParamMinCount(L, 4, call, params, n) then |
2383 begin |
2383 begin |
2384 if not lua_isnoneornil(L, 5) then |
2384 if not lua_isnoneornil(L, 5) then |
2385 tint := lua_tointeger(L, 5) |
2385 tint := Trunc(lua_tonumber(L, 5)) |
2386 else tint := $FFFFFFFF; |
2386 else tint := $FFFFFFFF; |
2387 if not lua_isnoneornil(L, 6) then |
2387 if not lua_isnoneornil(L, 6) then |
2388 behind := lua_toboolean(L, 6) |
2388 behind := lua_toboolean(L, 6) |
2389 else behind := false; |
2389 else behind := false; |
2390 if not lua_isnoneornil(L, 7) then |
2390 if not lua_isnoneornil(L, 7) then |
2395 else flipVert := false; |
2395 else flipVert := false; |
2396 lf:= 0; |
2396 lf:= 0; |
2397 |
2397 |
2398 // accept any amount of landflags, loop is never executed if n<9 |
2398 // accept any amount of landflags, loop is never executed if n<9 |
2399 for i:= 9 to n do |
2399 for i:= 9 to n do |
2400 lf:= lf or lua_tointeger(L, i); |
2400 lf:= lf or Trunc(lua_tonumber(L, i)); |
2401 |
2401 |
2402 n:= LuaToSpriteOrd(L, 3, call, params); |
2402 n:= LuaToSpriteOrd(L, 3, call, params); |
2403 if n >= 0 then |
2403 if n >= 0 then |
2404 begin |
2404 begin |
2405 spr:= TSprite(n); |
2405 spr:= TSprite(n); |
2406 if SpritesData[spr].Surface = nil then |
2406 if SpritesData[spr].Surface = nil then |
2407 LuaError(call + ': ' + EnumToStr(spr) + ' cannot be placed! (required information not loaded)' ) |
2407 LuaError(call + ': ' + EnumToStr(spr) + ' cannot be placed! (required information not loaded)' ) |
2408 else |
2408 else |
2409 placed:= ForcePlaceOnLand( |
2409 placed:= ForcePlaceOnLand( |
2410 lua_tointeger(L, 1) - SpritesData[spr].Width div 2, |
2410 Trunc(lua_tonumber(L, 1)) - SpritesData[spr].Width div 2, |
2411 lua_tointeger(L, 2) - SpritesData[spr].Height div 2, |
2411 Trunc(lua_tonumber(L, 2)) - SpritesData[spr].Height div 2, |
2412 spr, lua_tointeger(L, 4), lf, tint, behind, flipHoriz, flipVert); |
2412 spr, Trunc(lua_tonumber(L, 4)), lf, tint, behind, flipHoriz, flipVert); |
2413 end; |
2413 end; |
2414 end; |
2414 end; |
2415 |
2415 |
2416 lua_pushboolean(L, placed); |
2416 lua_pushboolean(L, placed); |
2417 lc_placesprite:= 1 |
2417 lc_placesprite:= 1 |
2442 else flipVert := false; |
2442 else flipVert := false; |
2443 lf:= 0; |
2443 lf:= 0; |
2444 |
2444 |
2445 // accept any amount of landflags, loop is never executed if n<9 |
2445 // accept any amount of landflags, loop is never executed if n<9 |
2446 for i:= 9 to n do |
2446 for i:= 9 to n do |
2447 lf:= lf or lua_tointeger(L, i); |
2447 lf:= lf or Trunc(lua_tonumber(L, i)); |
2448 |
2448 |
2449 n:= LuaToSpriteOrd(L, 3, call, params); |
2449 n:= LuaToSpriteOrd(L, 3, call, params); |
2450 if n >= 0 then |
2450 if n >= 0 then |
2451 begin |
2451 begin |
2452 spr:= TSprite(n); |
2452 spr:= TSprite(n); |
2453 if SpritesData[spr].Surface = nil then |
2453 if SpritesData[spr].Surface = nil then |
2454 LuaError(call + ': ' + EnumToStr(spr) + ' cannot be placed! (required information not loaded)' ) |
2454 LuaError(call + ': ' + EnumToStr(spr) + ' cannot be placed! (required information not loaded)' ) |
2455 else |
2455 else |
2456 EraseLand( |
2456 EraseLand( |
2457 lua_tointeger(L, 1) - SpritesData[spr].Width div 2, |
2457 Trunc(lua_tonumber(L, 1)) - SpritesData[spr].Width div 2, |
2458 lua_tointeger(L, 2) - SpritesData[spr].Height div 2, |
2458 Trunc(lua_tonumber(L, 2)) - SpritesData[spr].Height div 2, |
2459 spr, lua_tointeger(L, 4), lf, eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert); |
2459 spr, Trunc(lua_tonumber(L, 4)), lf, eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert); |
2460 end; |
2460 end; |
2461 end; |
2461 end; |
2462 lc_erasesprite:= 0 |
2462 lc_erasesprite:= 0 |
2463 end; |
2463 end; |
2464 |
2464 |
2466 var placed: boolean; |
2466 var placed: boolean; |
2467 begin |
2467 begin |
2468 placed:= false; |
2468 placed:= false; |
2469 if CheckLuaParamCount(L, 3, 'PlaceGirder', 'x, y, frameIdx') then |
2469 if CheckLuaParamCount(L, 3, 'PlaceGirder', 'x, y, frameIdx') then |
2470 placed:= TryPlaceOnLandSimple( |
2470 placed:= TryPlaceOnLandSimple( |
2471 lua_tointeger(L, 1) - SpritesData[sprAmGirder].Width div 2, |
2471 Trunc(lua_tonumber(L, 1)) - SpritesData[sprAmGirder].Width div 2, |
2472 lua_tointeger(L, 2) - SpritesData[sprAmGirder].Height div 2, |
2472 Trunc(lua_tonumber(L, 2)) - SpritesData[sprAmGirder].Height div 2, |
2473 sprAmGirder, lua_tointeger(L, 3), true, false); |
2473 sprAmGirder, Trunc(lua_tonumber(L, 3)), true, false); |
2474 |
2474 |
2475 lua_pushboolean(L, placed); |
2475 lua_pushboolean(L, placed); |
2476 lc_placegirder:= 1 |
2476 lc_placegirder:= 1 |
2477 end; |
2477 end; |
2478 |
2478 |
2480 var placed: boolean; |
2480 var placed: boolean; |
2481 begin |
2481 begin |
2482 placed:= false; |
2482 placed:= false; |
2483 if CheckLuaParamCount(L, 3, 'PlaceRubber', 'x, y, frameIdx') then |
2483 if CheckLuaParamCount(L, 3, 'PlaceRubber', 'x, y, frameIdx') then |
2484 placed:= TryPlaceOnLand( |
2484 placed:= TryPlaceOnLand( |
2485 lua_tointeger(L, 1) - SpritesData[sprAmRubber].Width div 2, |
2485 Trunc(lua_tonumber(L, 1)) - SpritesData[sprAmRubber].Width div 2, |
2486 lua_tointeger(L, 2) - SpritesData[sprAmRubber].Height div 2, |
2486 Trunc(lua_tonumber(L, 2)) - SpritesData[sprAmRubber].Height div 2, |
2487 sprAmRubber, lua_tointeger(L, 3), true, lfBouncy); |
2487 sprAmRubber, Trunc(lua_tonumber(L, 3)), true, lfBouncy); |
2488 |
2488 |
2489 lua_pushboolean(L, placed); |
2489 lua_pushboolean(L, placed); |
2490 lc_placerubber:= 1 |
2490 lc_placerubber:= 1 |
2491 end; |
2491 end; |
2492 |
2492 |
2493 function lc_getcurammotype(L : Plua_State): LongInt; Cdecl; |
2493 function lc_getcurammotype(L : Plua_State): LongInt; Cdecl; |
2494 begin |
2494 begin |
2495 if (CurrentHedgehog <> nil) and (CheckLuaParamCount(L, 0, 'GetCurAmmoType', '')) then |
2495 if (CurrentHedgehog <> nil) and (CheckLuaParamCount(L, 0, 'GetCurAmmoType', '')) then |
2496 lua_pushinteger(L, ord(CurrentHedgehog^.CurAmmoType)) |
2496 lua_pushnumber(L, ord(CurrentHedgehog^.CurAmmoType)) |
2497 else |
2497 else |
2498 lua_pushinteger(L, ord(amNothing)); |
2498 lua_pushnumber(L, ord(amNothing)); |
2499 lc_getcurammotype := 1; |
2499 lc_getcurammotype := 1; |
2500 end; |
2500 end; |
2501 |
2501 |
2502 function lc_savecampaignvar(L : Plua_State): LongInt; Cdecl; |
2502 function lc_savecampaignvar(L : Plua_State): LongInt; Cdecl; |
2503 begin |
2503 begin |
2549 var rtn: Boolean; |
2549 var rtn: Boolean; |
2550 begin |
2550 begin |
2551 if CheckLuaParamCount(L, 5, 'TestRectForObstacle', 'x1, y1, x2, y2, landOnly') then |
2551 if CheckLuaParamCount(L, 5, 'TestRectForObstacle', 'x1, y1, x2, y2, landOnly') then |
2552 begin |
2552 begin |
2553 rtn:= TestRectangleForObstacle( |
2553 rtn:= TestRectangleForObstacle( |
2554 lua_tointeger(L, 1), |
2554 Trunc(lua_tonumber(L, 1)), |
2555 lua_tointeger(L, 2), |
2555 Trunc(lua_tonumber(L, 2)), |
2556 lua_tointeger(L, 3), |
2556 Trunc(lua_tonumber(L, 3)), |
2557 lua_tointeger(L, 4), |
2557 Trunc(lua_tonumber(L, 4)), |
2558 lua_toboolean(L, 5) |
2558 lua_toboolean(L, 5) |
2559 ); |
2559 ); |
2560 lua_pushboolean(L, rtn); |
2560 lua_pushboolean(L, rtn); |
2561 end |
2561 end |
2562 else |
2562 else |
2566 |
2566 |
2567 |
2567 |
2568 function lc_getgravity(L : Plua_State) : LongInt; Cdecl; |
2568 function lc_getgravity(L : Plua_State) : LongInt; Cdecl; |
2569 begin |
2569 begin |
2570 if CheckLuaParamCount(L, 0, 'GetGravity', '') then |
2570 if CheckLuaParamCount(L, 0, 'GetGravity', '') then |
2571 lua_pushinteger(L, hwRound(SignAs(_0_5, cGravity) + (cGravity * 50 / cMaxWindSpeed))); |
2571 lua_pushnumber(L, hwRound(SignAs(_0_5, cGravity) + (cGravity * 50 / cMaxWindSpeed))); |
2572 lc_getgravity:= 1 |
2572 lc_getgravity:= 1 |
2573 end; |
2573 end; |
2574 |
2574 |
2575 function lc_setgravity(L : Plua_State) : LongInt; Cdecl; |
2575 function lc_setgravity(L : Plua_State) : LongInt; Cdecl; |
2576 begin |
2576 begin |
2577 if CheckLuaParamCount(L, 1, 'SetGravity', 'percent') then |
2577 if CheckLuaParamCount(L, 1, 'SetGravity', 'percent') then |
2578 begin |
2578 begin |
2579 cGravity:= _0_02 * lua_tointeger(L, 1) * cMaxWindSpeed; |
2579 cGravity:= _0_02 * Trunc(lua_tonumber(L, 1)) * cMaxWindSpeed; |
2580 cGravityf:= 0.00025 * lua_tointeger(L, 1) * 0.02 |
2580 cGravityf:= 0.00025 * Trunc(lua_tonumber(L, 1)) * 0.02 |
2581 end; |
2581 end; |
2582 lc_setgravity:= 0 |
2582 lc_setgravity:= 0 |
2583 end; |
2583 end; |
2584 |
2584 |
2585 function lc_setwaterline(L : Plua_State) : LongInt; Cdecl; |
2585 function lc_setwaterline(L : Plua_State) : LongInt; Cdecl; |
2586 var iterator: PGear; |
2586 var iterator: PGear; |
2587 begin |
2587 begin |
2588 if CheckLuaParamCount(L, 1, 'SetWaterLine', 'waterline') then |
2588 if CheckLuaParamCount(L, 1, 'SetWaterLine', 'waterline') then |
2589 begin |
2589 begin |
2590 cWaterLine:= lua_tointeger(L,1); |
2590 cWaterLine:= Trunc(lua_tonumber(L,1)); |
2591 AllInactive:= false; |
2591 AllInactive:= false; |
2592 iterator:= GearsList; |
2592 iterator:= GearsList; |
2593 while iterator <> nil do |
2593 while iterator <> nil do |
2594 begin |
2594 begin |
2595 if not (iterator^.Kind in [gtPortal, gtAirAttack]) and (iterator^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0) then |
2595 if not (iterator^.Kind in [gtPortal, gtAirAttack]) and (iterator^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0) then |
2629 |
2629 |
2630 |
2630 |
2631 function lc_declareachievement(L : Plua_State) : LongInt; Cdecl; |
2631 function lc_declareachievement(L : Plua_State) : LongInt; Cdecl; |
2632 begin |
2632 begin |
2633 if CheckLuaParamCount(L, 4, 'DeclareAchievement', 'achievementId, teamname, location, value') then |
2633 if CheckLuaParamCount(L, 4, 'DeclareAchievement', 'achievementId, teamname, location, value') then |
2634 declareAchievement(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4)); |
2634 declareAchievement(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), Trunc(lua_tonumber(L, 4))); |
2635 lc_declareachievement:= 0 |
2635 lc_declareachievement:= 0 |
2636 end; |
2636 end; |
2637 |
2637 |
2638 function lc_getammoname(L : Plua_state) : LongInt; Cdecl; |
2638 function lc_getammoname(L : Plua_state) : LongInt; Cdecl; |
2639 var np, at: LongInt; |
2639 var np, at: LongInt; |
2659 end; |
2659 end; |
2660 |
2660 |
2661 function lc_startghostpoints(L : Plua_State) : LongInt; Cdecl; |
2661 function lc_startghostpoints(L : Plua_State) : LongInt; Cdecl; |
2662 begin |
2662 begin |
2663 if CheckLuaParamCount(L, 1, 'StartGhostPoints', 'count') then |
2663 if CheckLuaParamCount(L, 1, 'StartGhostPoints', 'count') then |
2664 startGhostPoints(lua_tointeger(L, 1)); |
2664 startGhostPoints(Trunc(lua_tonumber(L, 1))); |
2665 lc_startghostpoints:= 0 |
2665 lc_startghostpoints:= 0 |
2666 end; |
2666 end; |
2667 |
2667 |
2668 function lc_dumppoint(L : Plua_State) : LongInt; Cdecl; |
2668 function lc_dumppoint(L : Plua_State) : LongInt; Cdecl; |
2669 begin |
2669 begin |
2670 if CheckLuaParamCount(L, 2, 'DumpPoint', 'x, y') then |
2670 if CheckLuaParamCount(L, 2, 'DumpPoint', 'x, y') then |
2671 dumpPoint(lua_tointeger(L, 1), lua_tointeger(L, 2)); |
2671 dumpPoint(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2))); |
2672 lc_dumppoint:= 0 |
2672 lc_dumppoint:= 0 |
2673 end; |
2673 end; |
2674 |
2674 |
2675 |
2675 |
2676 procedure ScriptFlushPoints(); |
2676 procedure ScriptFlushPoints(); |
2684 var np, param: LongInt; |
2684 var np, param: LongInt; |
2685 begin |
2685 begin |
2686 if CheckAndFetchParamCountRange(L, 2, 4, 'AddPoint', 'x, y [, width [, erase] ]', np) then |
2686 if CheckAndFetchParamCountRange(L, 2, 4, 'AddPoint', 'x, y [, width [, erase] ]', np) then |
2687 begin |
2687 begin |
2688 // x |
2688 // x |
2689 param:= LongInt(lua_tointeger(L,1)); |
2689 param:= LongInt(Trunc(lua_tonumber(L,1))); |
2690 PointsBuffer:= PointsBuffer + char((param shr 8) and $FF); |
2690 PointsBuffer:= PointsBuffer + char((param shr 8) and $FF); |
2691 PointsBuffer:= PointsBuffer + char((param and $FF)); |
2691 PointsBuffer:= PointsBuffer + char((param and $FF)); |
2692 // y |
2692 // y |
2693 param:= LongInt(lua_tointeger(L,2)); |
2693 param:= LongInt(Trunc(lua_tonumber(L,2))); |
2694 PointsBuffer:= PointsBuffer + char((param shr 8) and $FF); |
2694 PointsBuffer:= PointsBuffer + char((param shr 8) and $FF); |
2695 PointsBuffer:= PointsBuffer + char((param and $FF)); |
2695 PointsBuffer:= PointsBuffer + char((param and $FF)); |
2696 // width |
2696 // width |
2697 if np > 2 then |
2697 if np > 2 then |
2698 begin |
2698 begin |
2699 param:= lua_tointeger(L,3); |
2699 param:= Trunc(lua_tonumber(L,3)); |
2700 param:= (param or $80); |
2700 param:= (param or $80); |
2701 // erase |
2701 // erase |
2702 if (np > 3) and lua_toboolean(L, 4) then |
2702 if (np > 3) and lua_toboolean(L, 4) then |
2703 param:= (param or $40); |
2703 param:= (param or $40); |
2704 PointsBuffer:= PointsBuffer + char(param); |
2704 PointsBuffer:= PointsBuffer + char(param); |
3103 begin |
3103 begin |
3104 if (not ScriptLoaded) or (not ScriptExists(fname)) then |
3104 if (not ScriptLoaded) or (not ScriptExists(fname)) then |
3105 exit(0); |
3105 exit(0); |
3106 SetGlobals; |
3106 SetGlobals; |
3107 lua_getglobal(luaState, Str2PChar(fname)); |
3107 lua_getglobal(luaState, Str2PChar(fname)); |
3108 lua_pushinteger(luaState, par1); |
3108 lua_pushnumber(luaState, par1); |
3109 lua_pushinteger(luaState, par2); |
3109 lua_pushnumber(luaState, par2); |
3110 lua_pushinteger(luaState, par3); |
3110 lua_pushnumber(luaState, par3); |
3111 lua_pushinteger(luaState, par4); |
3111 lua_pushnumber(luaState, par4); |
3112 ScriptCall:= 0; |
3112 ScriptCall:= 0; |
3113 if lua_pcall(luaState, 4, 1, 0) <> 0 then |
3113 if lua_pcall(luaState, 4, 1, 0) <> 0 then |
3114 begin |
3114 begin |
3115 LuaError('Error while calling ' + fname + ': ' + lua_tostring(luaState, -1)); |
3115 LuaError('Error while calling ' + fname + ': ' + lua_tostring(luaState, -1)); |
3116 lua_pop(luaState, 1) |
3116 lua_pop(luaState, 1) |
3117 end |
3117 end |
3118 else |
3118 else |
3119 begin |
3119 begin |
3120 ScriptCall:= lua_tointeger(luaState, -1); |
3120 ScriptCall:= Trunc(lua_tonumber(luaState, -1)); |
3121 lua_pop(luaState, 1) |
3121 lua_pop(luaState, 1) |
3122 end; |
3122 end; |
3123 GetGlobals; |
3123 GetGlobals; |
3124 end; |
3124 end; |
3125 |
3125 |