684 lua_pushinteger(L, vg^.Tint); |
671 lua_pushinteger(L, vg^.Tint); |
685 end |
672 end |
686 else |
673 else |
687 begin |
674 begin |
688 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
675 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
689 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L) |
676 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
690 end |
677 end |
|
678 end |
|
679 else |
|
680 begin |
|
681 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
|
682 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
691 end; |
683 end; |
692 lc_getvisualgearvalues:= 10; |
684 lc_getvisualgearvalues:= 10; |
693 end; |
685 end; |
694 |
686 |
695 function lc_setvisualgearvalues(L : Plua_State) : LongInt; Cdecl; |
687 function lc_setvisualgearvalues(L : Plua_State) : LongInt; Cdecl; |
696 var vg : PVisualGear; |
688 var vg : PVisualGear; |
697 begin |
689 begin |
698 if lua_gettop(L) <> 11 then |
690 if CheckLuaParameterCount(L, 11, 'SetVisualGearValues', 'vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint') then |
699 begin |
|
700 LuaParameterCountError('SetVisualGearValues', 'vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint', lua_gettop(L)); |
|
701 lua_pushnil(L); // return value on stack (nil) |
|
702 end |
|
703 else |
|
704 begin |
691 begin |
705 vg:= VisualGearByUID(lua_tointeger(L, 1)); |
692 vg:= VisualGearByUID(lua_tointeger(L, 1)); |
706 if vg <> nil then |
693 if vg <> nil then |
707 begin |
694 begin |
708 vg^.X:= lua_tointeger(L, 2); |
695 vg^.X:= lua_tointeger(L, 2); |
715 vg^.FrameTicks:= lua_tointeger(L, 8); // find a better way to do this. maybe need to break all these up. |
702 vg^.FrameTicks:= lua_tointeger(L, 8); // find a better way to do this. maybe need to break all these up. |
716 vg^.State:= lua_tointeger(L, 9); |
703 vg^.State:= lua_tointeger(L, 9); |
717 vg^.Timer:= lua_tointeger(L, 10); |
704 vg^.Timer:= lua_tointeger(L, 10); |
718 vg^.Tint:= lua_tointeger(L, 11); |
705 vg^.Tint:= lua_tointeger(L, 11); |
719 end |
706 end |
720 end; |
707 end |
|
708 else |
|
709 lua_pushnil(L); // return value on stack (nil) |
721 lc_setvisualgearvalues:= 0; |
710 lc_setvisualgearvalues:= 0; |
722 end; |
711 end; |
723 |
712 |
724 function lc_getfollowgear(L : Plua_State) : LongInt; Cdecl; |
713 function lc_getfollowgear(L : Plua_State) : LongInt; Cdecl; |
725 begin |
714 begin |
726 if lua_gettop(L) <> 0 then |
715 if CheckLuaParameterCount(L, 0, 'GetFollowGear', '') then |
727 begin |
716 begin |
728 LuaParameterCountError('GetFollowGear', '', lua_gettop(L)); |
|
729 lua_pushnil(L); // return value on stack (nil) |
|
730 end |
|
731 else |
|
732 if FollowGear = nil then |
717 if FollowGear = nil then |
733 lua_pushnil(L) |
718 lua_pushnil(L) |
734 else |
719 else |
735 lua_pushinteger(L, FollowGear^.uid); |
720 lua_pushinteger(L, FollowGear^.uid); |
|
721 end |
|
722 else |
|
723 lua_pushnil(L); |
736 lc_getfollowgear:= 1; // 1 return value |
724 lc_getfollowgear:= 1; // 1 return value |
737 end; |
725 end; |
738 |
726 |
739 function lc_getgeartype(L : Plua_State) : LongInt; Cdecl; |
727 function lc_getgeartype(L : Plua_State) : LongInt; Cdecl; |
740 var gear : PGear; |
728 var gear : PGear; |
741 begin |
729 begin |
742 if lua_gettop(L) <> 1 then |
730 if CheckLuaParameterCount(L, 1, 'GetGearType', 'gearUid') then |
743 begin |
731 begin |
744 LuaParameterCountError('GetGearType', 'gearUid', lua_gettop(L)); |
732 gear:= GearByUID(lua_tointeger(L, 1)); |
|
733 if gear <> nil then |
|
734 lua_pushinteger(L, ord(gear^.Kind)) |
|
735 else |
|
736 lua_pushnil(L); |
|
737 end |
|
738 else |
745 lua_pushnil(L); // return value on stack (nil) |
739 lua_pushnil(L); // return value on stack (nil) |
746 end |
740 lc_getgeartype:= 1 |
747 else |
741 end; |
748 begin |
742 |
749 gear:= GearByUID(lua_tointeger(L, 1)); |
743 function lc_getgearmessage(L : Plua_State) : LongInt; Cdecl; |
750 if gear <> nil then |
744 var gear : PGear; |
751 lua_pushinteger(L, ord(gear^.Kind)) |
745 begin |
|
746 if CheckLuaParameterCount(L, 1, 'GetGearMessage', 'gearUid') then |
|
747 begin |
|
748 gear:= GearByUID(lua_tointeger(L, 1)); |
|
749 if gear <> nil then |
|
750 lua_pushinteger(L, gear^.message) |
752 else |
751 else |
753 lua_pushnil(L); |
752 lua_pushnil(L); |
754 end; |
753 end |
755 lc_getgeartype:= 1 |
754 else |
756 end; |
|
757 |
|
758 function lc_getgearmessage(L : Plua_State) : LongInt; Cdecl; |
|
759 var gear : PGear; |
|
760 begin |
|
761 if lua_gettop(L) <> 1 then |
|
762 begin |
|
763 LuaParameterCountError('GetGearMessage', 'gearUid', lua_gettop(L)); |
|
764 lua_pushnil(L); // return value on stack (nil) |
755 lua_pushnil(L); // return value on stack (nil) |
765 end |
756 lc_getgearmessage:= 1 |
766 else |
757 end; |
767 begin |
758 |
768 gear:= GearByUID(lua_tointeger(L, 1)); |
759 function lc_getgearelasticity(L : Plua_State) : LongInt; Cdecl; |
769 if gear <> nil then |
760 var gear : PGear; |
770 lua_pushinteger(L, gear^.message) |
761 begin |
|
762 if CheckLuaParameterCount(L, 1, 'GetGearElasticity', 'gearUid') then |
|
763 begin |
|
764 gear:= GearByUID(lua_tointeger(L, 1)); |
|
765 if gear <> nil then |
|
766 lua_pushinteger(L, hwRound(gear^.elasticity * _10000)) |
771 else |
767 else |
772 lua_pushnil(L); |
768 lua_pushnil(L); |
773 end; |
769 end |
774 lc_getgearmessage:= 1 |
770 else |
775 end; |
|
776 |
|
777 function lc_getgearelasticity(L : Plua_State) : LongInt; Cdecl; |
|
778 var gear : PGear; |
|
779 begin |
|
780 if lua_gettop(L) <> 1 then |
|
781 begin |
|
782 LuaParameterCountError('GetGearElasticity', 'gearUid', lua_gettop(L)); |
|
783 lua_pushnil(L); // return value on stack (nil) |
771 lua_pushnil(L); // return value on stack (nil) |
784 end |
772 lc_getgearelasticity:= 1 |
785 else |
773 end; |
786 begin |
774 |
787 gear:= GearByUID(lua_tointeger(L, 1)); |
775 function lc_setgearmessage(L : Plua_State) : LongInt; Cdecl; |
788 if gear <> nil then |
776 var gear : PGear; |
789 lua_pushinteger(L, hwRound(gear^.elasticity * _10000)) |
777 begin |
|
778 if CheckLuaParameterCount(L, 2, 'SetGearMessage', 'gearUid, message') then |
|
779 else |
|
780 begin |
|
781 gear:= GearByUID(lua_tointeger(L, 1)); |
|
782 if gear <> nil then |
|
783 gear^.message:= lua_tointeger(L, 2); |
|
784 end; |
|
785 lc_setgearmessage:= 0 |
|
786 end; |
|
787 |
|
788 function lc_getgearpos(L : Plua_State) : LongInt; Cdecl; |
|
789 var gear : PGear; |
|
790 begin |
|
791 if CheckLuaParameterCount(L, 1, 'GetGearPos', 'gearUid') then |
|
792 begin |
|
793 gear:= GearByUID(lua_tointeger(L, 1)); |
|
794 if gear <> nil then |
|
795 lua_pushinteger(L, gear^.Pos) |
790 else |
796 else |
791 lua_pushnil(L); |
797 lua_pushnil(L); |
792 end; |
798 end |
793 lc_getgearelasticity:= 1 |
799 else |
794 end; |
|
795 |
|
796 function lc_setgearmessage(L : Plua_State) : LongInt; Cdecl; |
|
797 var gear : PGear; |
|
798 begin |
|
799 if lua_gettop(L) <> 2 then |
|
800 LuaParameterCountError('SetGearMessage', 'gearUid, message', lua_gettop(L)) |
|
801 else |
|
802 begin |
|
803 gear:= GearByUID(lua_tointeger(L, 1)); |
|
804 if gear <> nil then |
|
805 gear^.message:= lua_tointeger(L, 2); |
|
806 end; |
|
807 lc_setgearmessage:= 0 |
|
808 end; |
|
809 |
|
810 function lc_getgearpos(L : Plua_State) : LongInt; Cdecl; |
|
811 var gear : PGear; |
|
812 begin |
|
813 if lua_gettop(L) <> 1 then |
|
814 begin |
|
815 LuaParameterCountError('GetGearPos', 'gearUid', lua_gettop(L)); |
|
816 lua_pushnil(L); // return value on stack (nil) |
800 lua_pushnil(L); // return value on stack (nil) |
817 end |
801 lc_getgearpos:= 1 |
818 else |
802 end; |
819 begin |
803 |
820 gear:= GearByUID(lua_tointeger(L, 1)); |
804 function lc_setgearpos(L : Plua_State) : LongInt; Cdecl; |
821 if gear <> nil then |
805 var gear : PGear; |
822 lua_pushinteger(L, gear^.Pos) |
806 begin |
|
807 if CheckLuaParameterCount(L, 2, 'SetGearPos', 'gearUid, value') then |
|
808 begin |
|
809 gear:= GearByUID(lua_tointeger(L, 1)); |
|
810 if gear <> nil then |
|
811 gear^.Pos:= lua_tointeger(L, 2); |
|
812 end; |
|
813 lc_setgearpos:= 0 |
|
814 end; |
|
815 |
|
816 function lc_getgearcollisionmask(L : Plua_State) : LongInt; Cdecl; |
|
817 var gear : PGear; |
|
818 begin |
|
819 if CheckLuaParameterCount(L, 1, 'GetGearCollisionMask', 'gearUid') then |
|
820 begin |
|
821 gear:= GearByUID(lua_tointeger(L, 1)); |
|
822 if gear <> nil then |
|
823 lua_pushinteger(L, gear^.CollisionMask) |
823 else |
824 else |
824 lua_pushnil(L); |
825 lua_pushnil(L); |
825 end; |
826 end |
826 lc_getgearpos:= 1 |
827 else |
827 end; |
|
828 |
|
829 function lc_setgearpos(L : Plua_State) : LongInt; Cdecl; |
|
830 var gear : PGear; |
|
831 begin |
|
832 if lua_gettop(L) <> 2 then |
|
833 LuaParameterCountError('SetGearPos', 'gearUid, value', lua_gettop(L)) |
|
834 else |
|
835 begin |
|
836 gear:= GearByUID(lua_tointeger(L, 1)); |
|
837 if gear <> nil then |
|
838 gear^.Pos:= lua_tointeger(L, 2); |
|
839 end; |
|
840 lc_setgearpos:= 0 |
|
841 end; |
|
842 |
|
843 function lc_getgearcollisionmask(L : Plua_State) : LongInt; Cdecl; |
|
844 var gear : PGear; |
|
845 begin |
|
846 if lua_gettop(L) <> 1 then |
|
847 begin |
|
848 LuaParameterCountError('GetGearCollisionMask', 'gearUid', lua_gettop(L)); |
|
849 lua_pushnil(L); // return value on stack (nil) |
828 lua_pushnil(L); // return value on stack (nil) |
850 end |
|
851 else |
|
852 begin |
|
853 gear:= GearByUID(lua_tointeger(L, 1)); |
|
854 if gear <> nil then |
|
855 lua_pushinteger(L, gear^.CollisionMask) |
|
856 else |
|
857 lua_pushnil(L); |
|
858 end; |
|
859 lc_getgearcollisionmask:= 1 |
829 lc_getgearcollisionmask:= 1 |
860 end; |
830 end; |
861 |
831 |
862 function lc_setgearcollisionmask(L : Plua_State) : LongInt; Cdecl; |
832 function lc_setgearcollisionmask(L : Plua_State) : LongInt; Cdecl; |
863 var gear : PGear; |
833 var gear : PGear; |
864 begin |
834 begin |
865 if lua_gettop(L) <> 2 then |
835 if CheckLuaParameterCount(L, 2, 'SetGearCollisionMask', 'gearUid, mask') then |
866 LuaParameterCountError('SetGearCollisionMask', 'gearUid, mask', lua_gettop(L)) |
|
867 else |
|
868 begin |
836 begin |
869 gear:= GearByUID(lua_tointeger(L, 1)); |
837 gear:= GearByUID(lua_tointeger(L, 1)); |
870 if gear <> nil then |
838 if gear <> nil then |
871 gear^.CollisionMask:= lua_tointeger(L, 2); |
839 gear^.CollisionMask:= lua_tointeger(L, 2); |
872 end; |
840 end; |
904 end; |
868 end; |
905 |
869 |
906 function lc_gethogclan(L : Plua_State) : LongInt; Cdecl; |
870 function lc_gethogclan(L : Plua_State) : LongInt; Cdecl; |
907 var gear : PGear; |
871 var gear : PGear; |
908 begin |
872 begin |
909 if lua_gettop(L) <> 1 then |
873 if CheckLuaParameterCount(L, 1, 'GetHogClan', 'gearUid') then |
910 begin |
|
911 LuaParameterCountError('GetHogClan', 'gearUid', lua_gettop(L)); |
|
912 lua_pushnil(L); // return value on stack (nil) |
|
913 end |
|
914 else |
|
915 begin |
874 begin |
916 gear:= GearByUID(lua_tointeger(L, 1)); |
875 gear:= GearByUID(lua_tointeger(L, 1)); |
917 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
876 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
918 begin |
877 begin |
919 lua_pushinteger(L, gear^.Hedgehog^.Team^.Clan^.ClanIndex) |
878 lua_pushinteger(L, gear^.Hedgehog^.Team^.Clan^.ClanIndex) |
920 end |
879 end |
921 else |
880 else |
922 lua_pushnil(L); |
881 lua_pushnil(L); |
923 end; |
882 end |
|
883 else |
|
884 lua_pushnil(L); // return value on stack (nil) |
924 lc_gethogclan:= 1 |
885 lc_gethogclan:= 1 |
925 end; |
886 end; |
926 |
887 |
927 function lc_getclancolor(L : Plua_State) : LongInt; Cdecl; |
888 function lc_getclancolor(L : Plua_State) : LongInt; Cdecl; |
928 begin |
889 begin |
929 if lua_gettop(L) <> 1 then |
890 if CheckLuaParameterCount(L, 1, 'GetClanColor', 'clan') then |
930 begin |
891 lua_pushinteger(L, ClansArray[lua_tointeger(L, 1)]^.Color shl 8 or $FF) |
931 LuaParameterCountError('GetClanColor', 'clan', lua_gettop(L)); |
892 else |
932 lua_pushnil(L); // return value on stack (nil) |
893 lua_pushnil(L); // return value on stack (nil) |
933 end |
|
934 else lua_pushinteger(L, ClansArray[lua_tointeger(L, 1)]^.Color shl 8 or $FF); |
|
935 lc_getclancolor:= 1 |
894 lc_getclancolor:= 1 |
936 end; |
895 end; |
937 |
896 |
938 function lc_setclancolor(L : Plua_State) : LongInt; Cdecl; |
897 function lc_setclancolor(L : Plua_State) : LongInt; Cdecl; |
939 var clan : PClan; |
898 var clan : PClan; |
940 team : PTeam; |
899 team : PTeam; |
941 hh : THedgehog; |
900 hh : THedgehog; |
942 i, j : LongInt; |
901 i, j : LongInt; |
943 begin |
902 begin |
944 if lua_gettop(L) <> 2 then |
903 if CheckLuaParameterCount(L, 2, 'SetClanColor', 'clan, color') then |
945 LuaParameterCountError('SetClanColor', 'clan, color', lua_gettop(L)) |
|
946 else |
|
947 begin |
904 begin |
948 clan := ClansArray[lua_tointeger(L, 1)]; |
905 clan := ClansArray[lua_tointeger(L, 1)]; |
949 clan^.Color:= lua_tointeger(L, 2) shr 8; |
906 clan^.Color:= lua_tointeger(L, 2) shr 8; |
950 |
907 |
951 for i:= 0 to Pred(clan^.TeamsNumber) do |
908 for i:= 0 to Pred(clan^.TeamsNumber) do |
972 end; |
929 end; |
973 |
930 |
974 function lc_gethogteamname(L : Plua_State) : LongInt; Cdecl; |
931 function lc_gethogteamname(L : Plua_State) : LongInt; Cdecl; |
975 var gear : PGear; |
932 var gear : PGear; |
976 begin |
933 begin |
977 if lua_gettop(L) <> 1 then |
934 if CheckLuaParameterCount(L, 1, 'GetHogTeamName', 'gearUid') then |
978 begin |
935 begin |
979 LuaParameterCountError('GetHogTeamName', 'gearUid', lua_gettop(L)); |
936 gear:= GearByUID(lua_tointeger(L, 1)); |
|
937 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
|
938 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.TeamName)) |
|
939 else |
|
940 lua_pushnil(L); |
|
941 end |
|
942 else |
980 lua_pushnil(L); // return value on stack (nil) |
943 lua_pushnil(L); // return value on stack (nil) |
981 end |
|
982 else |
|
983 begin |
|
984 gear:= GearByUID(lua_tointeger(L, 1)); |
|
985 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
|
986 begin |
|
987 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.TeamName)) |
|
988 end |
|
989 else |
|
990 lua_pushnil(L); |
|
991 end; |
|
992 lc_gethogteamname:= 1 |
944 lc_gethogteamname:= 1 |
993 end; |
945 end; |
994 |
946 |
995 function lc_sethogteamname(L : Plua_State) : LongInt; Cdecl; |
947 function lc_sethogteamname(L : Plua_State) : LongInt; Cdecl; |
996 var gear : PGear; |
948 var gear : PGear; |
997 begin |
949 begin |
998 if lua_gettop(L) <> 2 then |
950 if CheckLuaParameterCount(L, 2, 'SetHogTeamName', 'gearUid, name') then |
999 begin |
|
1000 LuaParameterCountError('SetHogTeamName', 'gearUid, name', lua_gettop(L)); |
|
1001 lua_pushnil(L); // return value on stack (nil) |
|
1002 end |
|
1003 else |
|
1004 begin |
951 begin |
1005 gear := GearByUID(lua_tointeger(L, 1)); |
952 gear := GearByUID(lua_tointeger(L, 1)); |
1006 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
953 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
1007 begin |
954 begin |
1008 gear^.Hedgehog^.Team^.TeamName := lua_tostring(L, 2); |
955 gear^.Hedgehog^.Team^.TeamName := lua_tostring(L, 2); |
1010 FreeTexture(gear^.Hedgehog^.Team^.NameTagTex); |
957 FreeTexture(gear^.Hedgehog^.Team^.NameTagTex); |
1011 gear^.Hedgehog^.Team^.NameTagTex:= RenderStringTex(ansistring(gear^.Hedgehog^.Team^.TeamName), gear^.Hedgehog^.Team^.Clan^.Color, fnt16); |
958 gear^.Hedgehog^.Team^.NameTagTex:= RenderStringTex(ansistring(gear^.Hedgehog^.Team^.TeamName), gear^.Hedgehog^.Team^.Clan^.Color, fnt16); |
1012 end |
959 end |
1013 else |
960 else |
1014 lua_pushnil(L); |
961 lua_pushnil(L); |
1015 end; |
962 end |
|
963 else |
|
964 lua_pushnil(L); // return value on stack (nil) |
1016 lc_sethogteamname:= 1 |
965 lc_sethogteamname:= 1 |
1017 end; |
966 end; |
1018 |
967 |
1019 function lc_gethogname(L : Plua_State) : LongInt; Cdecl; |
968 function lc_gethogname(L : Plua_State) : LongInt; Cdecl; |
1020 var gear : PGear; |
969 var gear : PGear; |
1021 begin |
970 begin |
1022 if lua_gettop(L) <> 1 then |
971 if CheckLuaParameterCount(L, 1, 'GetHogName', 'gearUid') then |
1023 begin |
|
1024 LuaParameterCountError('GetHogName', 'gearUid', lua_gettop(L)); |
|
1025 lua_pushnil(L); // return value on stack (nil) |
|
1026 end |
|
1027 else |
|
1028 begin |
972 begin |
1029 gear:= GearByUID(lua_tointeger(L, 1)); |
973 gear:= GearByUID(lua_tointeger(L, 1)); |
1030 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
974 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
1031 begin |
975 begin |
1032 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Name)) |
976 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Name)) |
1033 end |
977 end |
1034 else |
978 else |
1035 lua_pushnil(L); |
979 lua_pushnil(L); |
1036 end; |
980 end |
|
981 else |
|
982 lua_pushnil(L); // return value on stack (nil) |
1037 lc_gethogname:= 1 |
983 lc_gethogname:= 1 |
1038 end; |
984 end; |
1039 |
985 |
1040 function lc_sethogname(L : Plua_State) : LongInt; Cdecl; |
986 function lc_sethogname(L : Plua_State) : LongInt; Cdecl; |
1041 var gear : PGear; |
987 var gear : PGear; |
1042 begin |
988 begin |
1043 if lua_gettop(L) <> 2 then |
989 if CheckLuaParameterCount(L, 2, 'SetHogName', 'gearUid, name') then |
1044 begin |
|
1045 LuaParameterCountError('SetHogName', 'gearUid, name', lua_gettop(L)); |
|
1046 lua_pushnil(L) |
|
1047 end |
|
1048 else |
|
1049 begin |
990 begin |
1050 gear:= GearByUID(lua_tointeger(L, 1)); |
991 gear:= GearByUID(lua_tointeger(L, 1)); |
1051 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
992 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1052 begin |
993 begin |
1053 gear^.Hedgehog^.Name:= lua_tostring(L, 2); |
994 gear^.Hedgehog^.Name:= lua_tostring(L, 2); |
1060 end; |
1001 end; |
1061 |
1002 |
1062 function lc_gettimer(L : Plua_State) : LongInt; Cdecl; |
1003 function lc_gettimer(L : Plua_State) : LongInt; Cdecl; |
1063 var gear : PGear; |
1004 var gear : PGear; |
1064 begin |
1005 begin |
1065 if lua_gettop(L) <> 1 then |
1006 if CheckLuaParameterCount(L, 1, 'GetTimer', 'gearUid') then |
1066 begin |
1007 begin |
1067 LuaParameterCountError('GetTimer', 'gearUid', lua_gettop(L)); |
1008 gear:= GearByUID(lua_tointeger(L, 1)); |
|
1009 if gear <> nil then |
|
1010 lua_pushinteger(L, gear^.Timer) |
|
1011 else |
|
1012 lua_pushnil(L); |
|
1013 end |
|
1014 else |
1068 lua_pushnil(L); // return value on stack (nil) |
1015 lua_pushnil(L); // return value on stack (nil) |
1069 end |
1016 lc_gettimer:= 1 |
1070 else |
1017 end; |
1071 begin |
1018 |
1072 gear:= GearByUID(lua_tointeger(L, 1)); |
1019 function lc_gethealth(L : Plua_State) : LongInt; Cdecl; |
1073 if gear <> nil then |
1020 var gear : PGear; |
1074 lua_pushinteger(L, gear^.Timer) |
1021 begin |
|
1022 if CheckLuaParameterCount(L, 1, 'GetHealth', 'gearUid') then |
|
1023 begin |
|
1024 gear:= GearByUID(lua_tointeger(L, 1)); |
|
1025 if gear <> nil then |
|
1026 lua_pushinteger(L, gear^.Health) |
1075 else |
1027 else |
1076 lua_pushnil(L); |
1028 lua_pushnil(L); |
1077 end; |
1029 end |
1078 lc_gettimer:= 1 |
1030 else |
1079 end; |
|
1080 |
|
1081 function lc_gethealth(L : Plua_State) : LongInt; Cdecl; |
|
1082 var gear : PGear; |
|
1083 begin |
|
1084 if lua_gettop(L) <> 1 then |
|
1085 begin |
|
1086 LuaParameterCountError('GetHealth', 'gearUid', lua_gettop(L)); |
|
1087 lua_pushnil(L); // return value on stack (nil) |
1031 lua_pushnil(L); // return value on stack (nil) |
1088 end |
1032 lc_gethealth:= 1 |
1089 else |
1033 end; |
1090 begin |
1034 |
1091 gear:= GearByUID(lua_tointeger(L, 1)); |
1035 function lc_getx(L : Plua_State) : LongInt; Cdecl; |
1092 if gear <> nil then |
1036 var gear : PGear; |
1093 lua_pushinteger(L, gear^.Health) |
1037 begin |
|
1038 if CheckLuaParameterCount(L, 1, 'GetX', 'gearUid') then |
|
1039 begin |
|
1040 gear:= GearByUID(lua_tointeger(L, 1)); |
|
1041 if gear <> nil then |
|
1042 lua_pushinteger(L, hwRound(gear^.X)) |
1094 else |
1043 else |
1095 lua_pushnil(L); |
1044 lua_pushnil(L); |
1096 end; |
1045 end |
1097 lc_gethealth:= 1 |
1046 else |
1098 end; |
|
1099 |
|
1100 function lc_getx(L : Plua_State) : LongInt; Cdecl; |
|
1101 var gear : PGear; |
|
1102 begin |
|
1103 if lua_gettop(L) <> 1 then |
|
1104 begin |
|
1105 LuaParameterCountError('GetX', 'gearUid', lua_gettop(L)); |
|
1106 lua_pushnil(L); // return value on stack (nil) |
1047 lua_pushnil(L); // return value on stack (nil) |
1107 end |
1048 lc_getx:= 1 |
1108 else |
1049 end; |
1109 begin |
1050 |
1110 gear:= GearByUID(lua_tointeger(L, 1)); |
1051 function lc_gety(L : Plua_State) : LongInt; Cdecl; |
1111 if gear <> nil then |
1052 var gear : PGear; |
1112 lua_pushinteger(L, hwRound(gear^.X)) |
1053 begin |
|
1054 if CheckLuaParameterCount(L, 1, 'GetY', 'gearUid') then |
|
1055 begin |
|
1056 gear:= GearByUID(lua_tointeger(L, 1)); |
|
1057 if gear <> nil then |
|
1058 lua_pushinteger(L, hwRound(gear^.Y)) |
1113 else |
1059 else |
1114 lua_pushnil(L); |
1060 lua_pushnil(L); |
1115 end; |
1061 end |
1116 lc_getx:= 1 |
1062 else |
1117 end; |
|
1118 |
|
1119 function lc_gety(L : Plua_State) : LongInt; Cdecl; |
|
1120 var gear : PGear; |
|
1121 begin |
|
1122 if lua_gettop(L) <> 1 then |
|
1123 begin |
|
1124 LuaParameterCountError('GetY', 'gearUid', lua_gettop(L)); |
|
1125 lua_pushnil(L); // return value on stack (nil) |
1063 lua_pushnil(L); // return value on stack (nil) |
1126 end |
|
1127 else |
|
1128 begin |
|
1129 gear:= GearByUID(lua_tointeger(L, 1)); |
|
1130 if gear <> nil then |
|
1131 lua_pushinteger(L, hwRound(gear^.Y)) |
|
1132 else |
|
1133 lua_pushnil(L); |
|
1134 end; |
|
1135 lc_gety:= 1 |
1064 lc_gety:= 1 |
1136 end; |
1065 end; |
1137 |
1066 |
1138 function lc_copypv(L : Plua_State) : LongInt; Cdecl; |
1067 function lc_copypv(L : Plua_State) : LongInt; Cdecl; |
1139 var gears, geard : PGear; |
1068 var gears, geard : PGear; |
1140 begin |
1069 begin |
1141 if lua_gettop(L) <> 2 then |
1070 if CheckLuaParameterCount(L, 2, 'CopyPV', 'fromGearUid, toGearUid') then |
1142 begin |
|
1143 LuaParameterCountError('CopyPV', 'fromGearUid, toGearUid', lua_gettop(L)); |
|
1144 end |
|
1145 else |
|
1146 begin |
1071 begin |
1147 gears:= GearByUID(lua_tointeger(L, 1)); |
1072 gears:= GearByUID(lua_tointeger(L, 1)); |
1148 geard:= GearByUID(lua_tointeger(L, 2)); |
1073 geard:= GearByUID(lua_tointeger(L, 2)); |
1149 if (gears <> nil) and (geard <> nil) then |
1074 if (gears <> nil) and (geard <> nil) then |
1150 begin |
1075 begin |
1241 lc_switchhog:= 0 |
1164 lc_switchhog:= 0 |
1242 end; |
1165 end; |
1243 |
1166 |
1244 function lc_addammo(L : Plua_State) : LongInt; Cdecl; |
1167 function lc_addammo(L : Plua_State) : LongInt; Cdecl; |
1245 var gear : PGear; |
1168 var gear : PGear; |
1246 at : LongInt; |
1169 at, n: LongInt; |
1247 const |
1170 const |
1248 call = 'AddAmmo'; |
1171 call = 'AddAmmo'; |
1249 params = 'gearUid, ammoType [, ammoCount]'; |
1172 params = 'gearUid, ammoType [, ammoCount]'; |
1250 begin |
1173 begin |
1251 if (lua_gettop(L) = 3) or (lua_gettop(L) = 2) then |
1174 if CheckAndFetchLuaParameterCount(L, 2, 3, call, params, n) then |
1252 begin |
1175 begin |
1253 at:= LuaToAmmoTypeOrd(L, 2, call, params); |
1176 at:= LuaToAmmoTypeOrd(L, 2, call, params); |
1254 if at >= 0 then |
1177 if at >= 0 then |
1255 begin |
1178 begin |
1256 gear:= GearByUID(lua_tointeger(L, 1)); |
1179 gear:= GearByUID(lua_tointeger(L, 1)); |
1257 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1180 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1258 if lua_gettop(L) = 2 then |
1181 if n = 2 then |
1259 AddAmmo(gear^.Hedgehog^, TAmmoType(at)) |
1182 AddAmmo(gear^.Hedgehog^, TAmmoType(at)) |
1260 else |
1183 else |
1261 SetAmmo(gear^.Hedgehog^, TAmmoType(at), lua_tointeger(L, 3)) |
1184 SetAmmo(gear^.Hedgehog^, TAmmoType(at), lua_tointeger(L, 3)) |
1262 end; |
1185 end; |
1263 end |
1186 end; |
1264 else LuaParameterCountError(call, params, lua_gettop(L)); |
|
1265 lc_addammo:= 0 |
1187 lc_addammo:= 0 |
1266 end; |
1188 end; |
1267 |
1189 |
1268 function lc_getammocount(L : Plua_State) : LongInt; Cdecl; |
1190 function lc_getammocount(L : Plua_State) : LongInt; Cdecl; |
1269 var gear : PGear; |
1191 var gear : PGear; |
1369 t : LongInt; |
1277 t : LongInt; |
1370 const |
1278 const |
1371 call = 'GetEffect'; |
1279 call = 'GetEffect'; |
1372 params = 'gearUid, effect'; |
1280 params = 'gearUid, effect'; |
1373 begin |
1281 begin |
1374 if lua_gettop(L) <> 2 then |
1282 if CheckLuaParameterCount(L, 2, call, params) then |
1375 begin |
|
1376 LuaParameterCountError(call, params, lua_gettop(L)); |
|
1377 end |
|
1378 else |
|
1379 begin |
1283 begin |
1380 t:= LuaToHogEffectOrd(L, 2, call, params); |
1284 t:= LuaToHogEffectOrd(L, 2, call, params); |
1381 if t >= 0 then |
1285 if t >= 0 then |
1382 begin |
1286 begin |
1383 gear:= GearByUID(lua_tointeger(L, 1)); |
1287 gear:= GearByUID(lua_tointeger(L, 1)); |
1384 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1288 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1385 lua_pushinteger(L, gear^.Hedgehog^.Effects[THogEffect(t)]) |
1289 lua_pushinteger(L, gear^.Hedgehog^.Effects[THogEffect(t)]) |
1386 else |
1290 else |
1387 lua_pushinteger(L, 0) |
1291 lua_pushinteger(L, 0) |
1388 end; |
1292 end; |
1389 end; |
1293 end |
|
1294 else |
|
1295 lua_pushinteger(L, 0); |
1390 lc_geteffect:= 1 |
1296 lc_geteffect:= 1 |
1391 end; |
1297 end; |
1392 |
1298 |
1393 function lc_setstate(L : Plua_State) : LongInt; Cdecl; |
1299 function lc_setstate(L : Plua_State) : LongInt; Cdecl; |
1394 var gear : PGear; |
1300 var gear : PGear; |
1395 begin |
1301 begin |
1396 if lua_gettop(L) <> 2 then |
1302 if CheckLuaParameterCount(L, 2, 'SetState', 'gearUid, state') then |
1397 begin |
|
1398 LuaParameterCountError('SetState', 'gearUid, state', lua_gettop(L)); |
|
1399 end |
|
1400 else |
|
1401 begin |
1303 begin |
1402 gear:= GearByUID(lua_tointeger(L, 1)); |
1304 gear:= GearByUID(lua_tointeger(L, 1)); |
1403 if gear <> nil then |
1305 if gear <> nil then |
1404 begin |
1306 begin |
1405 gear^.State:= lua_tointeger(L, 2); |
1307 gear^.State:= lua_tointeger(L, 2); |
1410 end; |
1312 end; |
1411 |
1313 |
1412 function lc_getstate(L : Plua_State) : LongInt; Cdecl; |
1314 function lc_getstate(L : Plua_State) : LongInt; Cdecl; |
1413 var gear : PGear; |
1315 var gear : PGear; |
1414 begin |
1316 begin |
1415 if lua_gettop(L) <> 1 then |
1317 if CheckLuaParameterCount(L, 1, 'GetState', 'gearUid') then |
1416 begin |
|
1417 LuaParameterCountError('GetState', 'gearUid', lua_gettop(L)); |
|
1418 end |
|
1419 else |
|
1420 begin |
1318 begin |
1421 gear:= GearByUID(lua_tointeger(L, 1)); |
1319 gear:= GearByUID(lua_tointeger(L, 1)); |
1422 if gear <> nil then |
1320 if gear <> nil then |
1423 lua_pushinteger(L, gear^.State) |
1321 lua_pushinteger(L, gear^.State) |
1424 else |
1322 else |
1425 lua_pushnil(L) |
1323 lua_pushnil(L) |
1426 end; |
1324 end |
|
1325 else |
|
1326 lua_pushnil(L); // return value on stack (nil) |
1427 lc_getstate:= 1 |
1327 lc_getstate:= 1 |
1428 end; |
1328 end; |
1429 |
1329 |
1430 function lc_gettag(L : Plua_State) : LongInt; Cdecl; |
1330 function lc_gettag(L : Plua_State) : LongInt; Cdecl; |
1431 var gear : PGear; |
1331 var gear : PGear; |
1432 begin |
1332 begin |
1433 if lua_gettop(L) <> 1 then |
1333 if CheckLuaParameterCount(L, 1, 'GetTag', 'gearUid') then |
1434 begin |
1334 begin |
1435 LuaParameterCountError('GetTag', 'gearUid', lua_gettop(L)); |
1335 gear:= GearByUID(lua_tointeger(L, 1)); |
|
1336 if gear <> nil then |
|
1337 lua_pushinteger(L, gear^.Tag) |
|
1338 else |
|
1339 lua_pushnil(L); |
|
1340 end |
|
1341 else |
1436 lua_pushnil(L); // return value on stack (nil) |
1342 lua_pushnil(L); // return value on stack (nil) |
1437 end |
|
1438 else |
|
1439 begin |
|
1440 gear:= GearByUID(lua_tointeger(L, 1)); |
|
1441 if gear <> nil then |
|
1442 lua_pushinteger(L, gear^.Tag) |
|
1443 else |
|
1444 lua_pushnil(L); |
|
1445 end; |
|
1446 lc_gettag:= 1 |
1343 lc_gettag:= 1 |
1447 end; |
1344 end; |
1448 |
1345 |
1449 function lc_settag(L : Plua_State) : LongInt; Cdecl; |
1346 function lc_settag(L : Plua_State) : LongInt; Cdecl; |
1450 var gear : PGear; |
1347 var gear : PGear; |
1451 begin |
1348 begin |
1452 if lua_gettop(L) <> 2 then |
1349 if CheckLuaParameterCount(L, 2, 'SetTag', 'gearUid, tag') then |
1453 begin |
|
1454 LuaParameterCountError('SetTag', 'gearUid, tag', lua_gettop(L)); |
|
1455 end |
|
1456 else |
|
1457 begin |
1350 begin |
1458 gear:= GearByUID(lua_tointeger(L, 1)); |
1351 gear:= GearByUID(lua_tointeger(L, 1)); |
1459 if gear <> nil then |
1352 if gear <> nil then |
1460 begin |
1353 begin |
1461 gear^.Tag:= lua_tointeger(L, 2); |
1354 gear^.Tag:= lua_tointeger(L, 2); |
1472 lc_endgame:= 0 |
1365 lc_endgame:= 0 |
1473 end; |
1366 end; |
1474 |
1367 |
1475 function lc_sendstat(L : Plua_State) : LongInt; Cdecl; |
1368 function lc_sendstat(L : Plua_State) : LongInt; Cdecl; |
1476 var statInfo : TStatInfoType; |
1369 var statInfo : TStatInfoType; |
1477 i, n : LongInt; |
1370 i, n : LongInt; |
1478 color, tn : shortstring; |
1371 color, tn: shortstring; |
|
1372 needsTn : boolean; |
1479 const |
1373 const |
1480 call = 'SendStat'; |
1374 call = 'SendStat'; |
1481 params2 = 'statInfoType, color'; |
|
1482 params3 = 'siClanHealth, color, teamname'; |
|
1483 params = 'statInfoType, color [, teamname]'; |
1375 params = 'statInfoType, color [, teamname]'; |
1484 begin |
1376 begin |
1485 n:= lua_gettop(L); |
1377 if CheckAndFetchLuaParameterCount(L, 2, 3, call, params, n) then |
1486 if (n < 2) or (n > 3) then |
|
1487 begin |
|
1488 LuaParameterCountError(call, params3, n); |
|
1489 end |
|
1490 else |
|
1491 begin |
1378 begin |
1492 i:= LuaToStatInfoTypeOrd(L, 1, call, params); |
1379 i:= LuaToStatInfoTypeOrd(L, 1, call, params); |
1493 if i >= 0 then |
1380 if i >= 0 then |
1494 begin |
1381 begin |
1495 statInfo := TStatInfoType(i); |
1382 statInfo:= TStatInfoType(i); |
1496 if (n <> 2) and ((statInfo <> siPlayerKills) |
1383 needsTn:= ((statInfo = siPlayerKills) or (statInfo = siClanHealth)); |
1497 and (statInfo <> siClanHealth)) then |
1384 // check if param count is correct for the used statInfo |
|
1385 if (n = 3) <> needsTn then |
1498 begin |
1386 begin |
1499 LuaParameterCountError(call, params2, n); |
1387 if n = 3 then |
|
1388 LuaCallError(EnumToStr(statInfo) + ' does not support the teamname parameter', call, params) |
|
1389 else |
|
1390 LuaCallError(EnumToStr(statInfo) + ' requires the teamname parameter', call, params); |
1500 end |
1391 end |
1501 else if (n <> 3) and ((statInfo = siPlayerKills) |
1392 else // count is correct! |
1502 or (statInfo = siClanHealth)) then |
|
1503 begin |
|
1504 LuaParameterCountError(call, params3, n); |
|
1505 end |
|
1506 else |
|
1507 begin |
1393 begin |
1508 if ((statInfo = siPlayerKills) or (statInfo = siClanHealth)) then |
1394 if ((statInfo = siPlayerKills) or (statInfo = siClanHealth)) then |
1509 begin |
1395 begin |
1510 // 3: team name |
1396 // 3: team name |
1511 for i:= 0 to Pred(TeamsCount) do |
1397 for i:= 0 to Pred(TeamsCount) do |
1551 |
1437 |
1552 function lc_findplace(L : Plua_State) : LongInt; Cdecl; |
1438 function lc_findplace(L : Plua_State) : LongInt; Cdecl; |
1553 var gear: PGear; |
1439 var gear: PGear; |
1554 fall: boolean; |
1440 fall: boolean; |
1555 tryhard: boolean; |
1441 tryhard: boolean; |
1556 left, right: LongInt; |
1442 left, right, n: LongInt; |
1557 begin |
1443 begin |
1558 tryhard:= false; |
1444 if CheckAndFetchLuaParameterCount(L, 4, 5, 'FindPlace', 'gearUid, fall, left, right [, tryHarder]', n) then |
1559 if (lua_gettop(L) <> 4) and (lua_gettop(L) <> 5) then |
|
1560 LuaParameterCountError('FindPlace', 'gearUid, fall, left, right [, tryHarder]', lua_gettop(L)) |
|
1561 else |
|
1562 begin |
1445 begin |
1563 gear:= GearByUID(lua_tointeger(L, 1)); |
1446 gear:= GearByUID(lua_tointeger(L, 1)); |
1564 fall:= lua_toboolean(L, 2); |
1447 fall:= lua_toboolean(L, 2); |
1565 left:= lua_tointeger(L, 3); |
1448 left:= lua_tointeger(L, 3); |
1566 right:= lua_tointeger(L, 4); |
1449 right:= lua_tointeger(L, 4); |
1567 if lua_gettop(L) = 5 then |
1450 if n = 5 then |
1568 tryhard:= lua_toboolean(L, 5); |
1451 tryhard:= lua_toboolean(L, 5); |
1569 if gear <> nil then |
1452 if gear <> nil then |
1570 FindPlace(gear, fall, left, right, tryhard); |
1453 FindPlace(gear, fall, left, right, tryhard); |
1571 if gear <> nil then |
1454 if gear <> nil then |
1572 lua_pushinteger(L, gear^.uid) |
1455 lua_pushinteger(L, gear^.uid) |
1573 else |
1456 else |
1574 lua_pushnil(L); |
1457 lua_pushnil(L); |
1575 end; |
1458 end |
|
1459 else |
|
1460 lua_pushnil(L); // return value on stack (nil) |
1576 lc_findplace:= 1 |
1461 lc_findplace:= 1 |
1577 end; |
1462 end; |
1578 |
1463 |
1579 function lc_playsound(L : Plua_State) : LongInt; Cdecl; |
1464 function lc_playsound(L : Plua_State) : LongInt; Cdecl; |
1580 var gear: PGear; |
1465 var gear: PGear; |
1581 n, s: LongInt; |
1466 n, s: LongInt; |
1582 const |
1467 const |
1583 call = 'PlaySound'; |
1468 call = 'PlaySound'; |
1584 params = 'soundId [, hhGearUid]'; |
1469 params = 'soundId [, hhGearUid]'; |
1585 begin |
1470 begin |
1586 n:= lua_gettop(L); |
1471 if CheckAndFetchLuaParameterCount(L, 1, 2, call, params, n) then |
1587 if (n < 1) or (n > 2) then |
|
1588 LuaParameterCountError(call, params, n) |
|
1589 else |
|
1590 begin |
1472 begin |
1591 s:= LuaToSoundOrd(L, 1, call, params); |
1473 s:= LuaToSoundOrd(L, 1, call, params); |
1592 if s >= 0 then |
1474 if s >= 0 then |
1593 begin |
1475 begin |
1594 // no gear specified |
1476 // no gear specified |
1595 if n = 1 then |
1477 if n = 1 then |
1596 PlaySound(TSound(s)) |
1478 PlaySound(TSound(s)) |
1597 else if lua_gettop(L) = 2 then |
1479 else |
1598 begin |
1480 begin |
1599 gear:= GearByUID(lua_tointeger(L, 2)); |
1481 gear:= GearByUID(lua_tointeger(L, 2)); |
1600 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1482 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1601 AddVoice(TSound(s),gear^.Hedgehog^.Team^.Voicepack) |
1483 AddVoice(TSound(s),gear^.Hedgehog^.Team^.Voicepack) |
1602 end; |
1484 end; |
1606 end; |
1488 end; |
1607 |
1489 |
1608 function lc_addteam(L : Plua_State) : LongInt; Cdecl; |
1490 function lc_addteam(L : Plua_State) : LongInt; Cdecl; |
1609 var np: LongInt; |
1491 var np: LongInt; |
1610 begin |
1492 begin |
1611 np:= lua_gettop(L); |
1493 if CheckAndFetchLuaParameterCount(L, 5, 6, 'AddTeam', 'teamname, color, grave, fort, voicepack [, flag]', np) then |
1612 if (np < 5) or (np > 6) then |
|
1613 begin |
|
1614 LuaParameterCountError('AddTeam', 'teamname, color, grave, fort, voicepack [, flag]', lua_gettop(L)); |
|
1615 //lua_pushnil(L) |
|
1616 end |
|
1617 else |
|
1618 begin |
1494 begin |
1619 ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true, true); |
1495 ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true, true); |
1620 ParseCommand('grave ' + lua_tostring(L, 3), true, true); |
1496 ParseCommand('grave ' + lua_tostring(L, 3), true, true); |
1621 ParseCommand('fort ' + lua_tostring(L, 4), true, true); |
1497 ParseCommand('fort ' + lua_tostring(L, 4), true, true); |
1622 ParseCommand('voicepack ' + lua_tostring(L, 5), true, true); |
1498 ParseCommand('voicepack ' + lua_tostring(L, 5), true, true); |
1623 if (np = 6) then ParseCommand('flag ' + lua_tostring(L, 6), true, true); |
1499 if (np = 6) then ParseCommand('flag ' + lua_tostring(L, 6), true, true); |
1624 CurrentTeam^.Binds:= DefaultBinds |
1500 CurrentTeam^.Binds:= DefaultBinds |
1625 // fails on x64 |
1501 // fails on x64 |
1626 //lua_pushinteger(L, LongInt(CurrentTeam)); |
1502 //lua_pushinteger(L, LongInt(CurrentTeam)); |
1627 end; |
1503 end; |
|
1504 //else |
|
1505 //lua_pushnil(L) |
1628 lc_addteam:= 0;//1; |
1506 lc_addteam:= 0;//1; |
1629 end; |
1507 end; |
1630 |
1508 |
1631 function lc_addhog(L : Plua_State) : LongInt; Cdecl; |
1509 function lc_addhog(L : Plua_State) : LongInt; Cdecl; |
1632 var temp: ShortString; |
1510 var temp: ShortString; |
1633 begin |
1511 begin |
1634 if lua_gettop(L) <> 4 then |
1512 if CheckLuaParameterCount(L, 4, 'AddHog', 'hogname, botlevel, health, hat') then |
1635 begin |
|
1636 LuaParameterCountError('AddHog', 'hogname, botlevel, health, hat', lua_gettop(L)); |
|
1637 lua_pushnil(L) |
|
1638 end |
|
1639 else |
|
1640 begin |
1513 begin |
1641 temp:= lua_tostring(L, 4); |
1514 temp:= lua_tostring(L, 4); |
1642 ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true, true); |
1515 ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true, true); |
1643 ParseCommand('hat ' + temp, true, true); |
1516 ParseCommand('hat ' + temp, true, true); |
1644 lua_pushinteger(L, CurrentHedgehog^.Gear^.uid); |
1517 lua_pushinteger(L, CurrentHedgehog^.Gear^.uid); |
1645 end; |
1518 end |
|
1519 else |
|
1520 lua_pushnil(L); |
1646 lc_addhog:= 1; |
1521 lc_addhog:= 1; |
1647 end; |
1522 end; |
1648 |
1523 |
1649 function lc_hogturnleft(L : Plua_State) : LongInt; Cdecl; |
1524 function lc_hogturnleft(L : Plua_State) : LongInt; Cdecl; |
1650 var gear: PGear; |
1525 var gear: PGear; |
1651 begin |
1526 begin |
1652 if lua_gettop(L) <> 2 then |
1527 if CheckLuaParameterCount(L, 2, 'HogTurnLeft', 'gearUid, boolean') then |
1653 begin |
|
1654 LuaParameterCountError('HogTurnLeft', 'gearUid, boolean', lua_gettop(L)); |
|
1655 end |
|
1656 else |
|
1657 begin |
1528 begin |
1658 gear:= GearByUID(lua_tointeger(L, 1)); |
1529 gear:= GearByUID(lua_tointeger(L, 1)); |
1659 if gear <> nil then |
1530 if gear <> nil then |
1660 gear^.dX.isNegative:= lua_toboolean(L, 2); |
1531 gear^.dX.isNegative:= lua_toboolean(L, 2); |
1661 end; |
1532 end; |
1760 |
1625 |
1761 function lc_getgearvelocity(L : Plua_State) : LongInt; Cdecl; |
1626 function lc_getgearvelocity(L : Plua_State) : LongInt; Cdecl; |
1762 var gear: PGear; |
1627 var gear: PGear; |
1763 var t: LongInt; |
1628 var t: LongInt; |
1764 begin |
1629 begin |
1765 if lua_gettop(L) <> 1 then |
1630 if CheckLuaParameterCount(L, 1, 'GetGearVelocity', 'gearUid') then |
1766 begin |
|
1767 LuaParameterCountError('GetGearVelocity', 'gearUid', lua_gettop(L)); |
|
1768 lua_pushnil(L); |
|
1769 lua_pushnil(L) |
|
1770 end |
|
1771 else |
|
1772 begin |
1631 begin |
1773 gear:= GearByUID(lua_tointeger(L, 1)); |
1632 gear:= GearByUID(lua_tointeger(L, 1)); |
1774 if gear <> nil then |
1633 if gear <> nil then |
1775 begin |
1634 begin |
1776 t:= hwRound(gear^.dX * 1000000); |
1635 t:= hwRound(gear^.dX * 1000000); |
1777 // gear dX determines hog orientation |
1636 // gear dX determines hog orientation |
1778 if (gear^.dX.isNegative) and (t = 0) then t:= -1; |
1637 if (gear^.dX.isNegative) and (t = 0) then t:= -1; |
1779 lua_pushinteger(L, t); |
1638 lua_pushinteger(L, t); |
1780 lua_pushinteger(L, hwRound(gear^.dY * 1000000)) |
1639 lua_pushinteger(L, hwRound(gear^.dY * 1000000)) |
1781 end |
1640 end |
|
1641 end |
|
1642 else |
|
1643 begin |
|
1644 lua_pushnil(L); |
|
1645 lua_pushnil(L); |
1782 end; |
1646 end; |
1783 lc_getgearvelocity:= 2; |
1647 lc_getgearvelocity:= 2; |
1784 end; |
1648 end; |
1785 |
1649 |
1786 function lc_setgearvelocity(L : Plua_State) : LongInt; Cdecl; |
1650 function lc_setgearvelocity(L : Plua_State) : LongInt; Cdecl; |
1787 var gear: PGear; |
1651 var gear: PGear; |
1788 begin |
1652 begin |
1789 if lua_gettop(L) <> 3 then |
1653 if CheckLuaParameterCount(L, 3, 'SetGearVelocity', 'gearUid, dx, dy') then |
1790 LuaParameterCountError('SetGearVelocity', 'gearUid, dx, dy', lua_gettop(L)) |
|
1791 else |
|
1792 begin |
1654 begin |
1793 gear:= GearByUID(lua_tointeger(L, 1)); |
1655 gear:= GearByUID(lua_tointeger(L, 1)); |
1794 if gear <> nil then |
1656 if gear <> nil then |
1795 begin |
1657 begin |
1796 gear^.dX:= int2hwFloat(lua_tointeger(L, 2)) / 1000000; |
1658 gear^.dX:= int2hwFloat(lua_tointeger(L, 2)) / 1000000; |
1850 end; |
1704 end; |
1851 lc_setammo:= 0 |
1705 lc_setammo:= 0 |
1852 end; |
1706 end; |
1853 |
1707 |
1854 function lc_setammodelay(L : Plua_State) : LongInt; Cdecl; |
1708 function lc_setammodelay(L : Plua_State) : LongInt; Cdecl; |
1855 var np: LongInt; |
1709 var at: LongInt; |
1856 const |
1710 const |
1857 call = 'SetAmmoDelay'; |
1711 call = 'SetAmmoDelay'; |
1858 params = 'ammoType, delay'; |
1712 params = 'ammoType, delay'; |
1859 begin |
1713 begin |
1860 np:= lua_gettop(L); |
1714 if CheckLuaParameterCount(L, 2, call, params) then |
1861 if (np <> 2) then |
1715 begin |
1862 LuaParameterCountError(call, params, lua_gettop(L)) |
1716 at:= LuaToAmmoTypeOrd(L, 1, call, params); |
1863 else |
1717 if at >= 0 then |
1864 begin |
1718 ScriptSetAmmoDelay(TAmmoType(at), lua_tointeger(L, 2)); |
1865 np:= LuaToAmmoTypeOrd(L, 1, call, params); |
|
1866 if np >= 0 then |
|
1867 ScriptSetAmmoDelay(TAmmoType(np), lua_tointeger(L, 2)); |
|
1868 end; |
1719 end; |
1869 lc_setammodelay:= 0 |
1720 lc_setammodelay:= 0 |
1870 end; |
1721 end; |
1871 |
1722 |
1872 function lc_setammostore(L : Plua_State) : LongInt; Cdecl; |
1723 function lc_setammostore(L : Plua_State) : LongInt; Cdecl; |
1873 var np: LongInt; |
1724 begin |
1874 begin |
1725 if CheckLuaParameterCount(L, 4, 'SetAmmoStore', 'loadouts, probabilities, delays, reinforments') then |
1875 np:= lua_gettop(L); |
|
1876 if (np <> 4) then |
|
1877 LuaParameterCountError('SetAmmoStore', 'loadouts, probabilities, delays, reinforments', lua_gettop(L)) |
|
1878 else |
|
1879 begin |
1726 begin |
1880 ScriptAmmoLoadout:= lua_tostring(L, 1); |
1727 ScriptAmmoLoadout:= lua_tostring(L, 1); |
1881 ScriptAmmoProbability:= lua_tostring(L, 2); |
1728 ScriptAmmoProbability:= lua_tostring(L, 2); |
1882 ScriptAmmoDelay:= lua_tostring(L, 3); |
1729 ScriptAmmoDelay:= lua_tostring(L, 3); |
1883 ScriptAmmoReinforcement:= lua_tostring(L, 4); |
1730 ScriptAmmoReinforcement:= lua_tostring(L, 4); |
1886 end; |
1733 end; |
1887 |
1734 |
1888 function lc_getrandom(L : Plua_State) : LongInt; Cdecl; |
1735 function lc_getrandom(L : Plua_State) : LongInt; Cdecl; |
1889 var m : LongInt; |
1736 var m : LongInt; |
1890 begin |
1737 begin |
1891 if lua_gettop(L) <> 1 then |
1738 if CheckLuaParameterCount(L, 1, 'GetRandom', 'number') then |
1892 begin |
|
1893 LuaParameterCountError('GetRandom', 'number', lua_gettop(L)); |
|
1894 lua_pushnil(L); // return value on stack (nil) |
|
1895 end |
|
1896 else |
|
1897 begin |
1739 begin |
1898 m:= lua_tointeger(L, 1); |
1740 m:= lua_tointeger(L, 1); |
1899 if (m > 0) then |
1741 if (m > 0) then |
1900 lua_pushinteger(L, GetRandom(m)) |
1742 lua_pushinteger(L, GetRandom(m)) |
1901 else |
1743 else |
1902 begin |
1744 begin |
1903 LuaError('Lua: Tried to pass 0 to GetRandom!'); |
1745 LuaError('Lua: Tried to pass 0 to GetRandom!'); |
1904 lua_pushnil(L); |
1746 lua_pushnil(L); |
1905 end |
1747 end |
1906 end; |
1748 end |
|
1749 else |
|
1750 lua_pushnil(L); // return value on stack (nil) |
1907 lc_getrandom:= 1 |
1751 lc_getrandom:= 1 |
1908 end; |
1752 end; |
1909 |
1753 |
1910 function lc_setwind(L : Plua_State) : LongInt; Cdecl; |
1754 function lc_setwind(L : Plua_State) : LongInt; Cdecl; |
1911 begin |
1755 begin |
1912 if lua_gettop(L) <> 1 then |
1756 if CheckLuaParameterCount(L, 1, 'SetWind', 'windSpeed') then |
1913 LuaParameterCountError('SetWind', 'windSpeed', lua_gettop(L)) |
|
1914 else |
|
1915 begin |
1757 begin |
1916 cWindSpeed:= int2hwfloat(lua_tointeger(L, 1)) / 100 * cMaxWindSpeed; |
1758 cWindSpeed:= int2hwfloat(lua_tointeger(L, 1)) / 100 * cMaxWindSpeed; |
1917 cWindSpeedf:= SignAs(cWindSpeed,cWindSpeed).QWordValue / SignAs(_1,_1).QWordValue; |
1759 cWindSpeedf:= SignAs(cWindSpeed,cWindSpeed).QWordValue / SignAs(_1,_1).QWordValue; |
1918 if cWindSpeed.isNegative then |
1760 if cWindSpeed.isNegative then |
1919 CWindSpeedf := -cWindSpeedf; |
1761 CWindSpeedf := -cWindSpeedf; |
1922 lc_setwind:= 0 |
1764 lc_setwind:= 0 |
1923 end; |
1765 end; |
1924 |
1766 |
1925 function lc_getdatapath(L : Plua_State) : LongInt; Cdecl; |
1767 function lc_getdatapath(L : Plua_State) : LongInt; Cdecl; |
1926 begin |
1768 begin |
1927 if lua_gettop(L) <> 0 then |
1769 if CheckLuaParameterCount(L, 0, 'GetDataPath', '') then |
1928 begin |
1770 lua_pushstring(L, str2pchar(cPathz[ptData])) |
1929 LuaParameterCountError('GetDataPath', '', lua_gettop(L)); |
1771 else |
1930 lua_pushnil(L); |
1772 lua_pushnil(L); |
1931 end |
|
1932 else |
|
1933 lua_pushstring(L, str2pchar(cPathz[ptData])); |
|
1934 lc_getdatapath:= 1 |
1773 lc_getdatapath:= 1 |
1935 end; |
1774 end; |
1936 |
1775 |
1937 function lc_getuserdatapath(L : Plua_State) : LongInt; Cdecl; |
1776 function lc_getuserdatapath(L : Plua_State) : LongInt; Cdecl; |
1938 begin |
1777 begin |
1939 if lua_gettop(L) <> 0 then |
1778 if CheckLuaParameterCount(L, 0, 'GetUserDataPath', '') then |
1940 begin |
1779 lua_pushstring(L, str2pchar(cPathz[ptData])) |
1941 LuaParameterCountError('GetUserDataPath', '', lua_gettop(L)); |
1780 else |
1942 lua_pushnil(L); |
1781 lua_pushnil(L); |
1943 end |
|
1944 else |
|
1945 lua_pushstring(L, str2pchar(cPathz[ptData])); |
|
1946 lc_getuserdatapath:= 1 |
1782 lc_getuserdatapath:= 1 |
1947 end; |
1783 end; |
1948 |
1784 |
1949 function lc_maphasborder(L : Plua_State) : LongInt; Cdecl; |
1785 function lc_maphasborder(L : Plua_State) : LongInt; Cdecl; |
1950 begin |
1786 begin |
1951 if lua_gettop(L) <> 0 then |
1787 if CheckLuaParameterCount(L, 0, 'MapHasBorder', '') then |
1952 begin |
1788 lua_pushboolean(L, hasBorder) |
1953 LuaParameterCountError('MapHasBorder', '', lua_gettop(L)); |
1789 else |
1954 lua_pushnil(L); |
1790 lua_pushnil(L); |
1955 end |
|
1956 else |
|
1957 lua_pushboolean(L, hasBorder); |
|
1958 lc_maphasborder:= 1 |
1791 lc_maphasborder:= 1 |
1959 end; |
1792 end; |
1960 |
1793 |
1961 function lc_getgearradius(L : Plua_State) : LongInt; Cdecl; |
1794 function lc_getgearradius(L : Plua_State) : LongInt; Cdecl; |
1962 var gear : PGear; |
1795 var gear : PGear; |
1963 begin |
1796 begin |
1964 if lua_gettop(L) <> 1 then |
1797 if CheckLuaParameterCount(L, 1, 'GetGearRadius', 'gearUid') then |
1965 begin |
1798 begin |
1966 LuaParameterCountError('GetGearRadius', 'gearUid', lua_gettop(L)); |
1799 gear:= GearByUID(lua_tointeger(L, 1)); |
|
1800 if gear <> nil then |
|
1801 lua_pushinteger(L, gear^.Radius) |
|
1802 else |
|
1803 lua_pushnil(L); |
|
1804 end |
|
1805 else |
1967 lua_pushnil(L); // return value on stack (nil) |
1806 lua_pushnil(L); // return value on stack (nil) |
1968 end |
|
1969 else |
|
1970 begin |
|
1971 gear:= GearByUID(lua_tointeger(L, 1)); |
|
1972 if gear <> nil then |
|
1973 lua_pushinteger(L, gear^.Radius) |
|
1974 else |
|
1975 lua_pushnil(L); |
|
1976 end; |
|
1977 lc_getgearradius:= 1 |
1807 lc_getgearradius:= 1 |
1978 end; |
1808 end; |
1979 |
1809 |
1980 function lc_gethoghat(L : Plua_State): LongInt; Cdecl; |
1810 function lc_gethoghat(L : Plua_State): LongInt; Cdecl; |
1981 var gear : PGear; |
1811 var gear : PGear; |
1982 begin |
1812 begin |
1983 if lua_gettop(L) <> 1 then |
1813 if CheckLuaParameterCount(L, 1, 'GetHogHat', 'gearUid') then |
1984 LuaParameterCountError('GetHogHat', 'gearUid', lua_gettop(L)) |
1814 begin |
1985 else begin |
|
1986 gear := GearByUID(lua_tointeger(L, 1)); |
1815 gear := GearByUID(lua_tointeger(L, 1)); |
1987 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
1816 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
1988 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Hat)) |
1817 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Hat)) |
1989 else |
1818 else |
1990 lua_pushnil(L); |
1819 lua_pushnil(L); |
1991 end; |
1820 end |
|
1821 else |
|
1822 lua_pushnil(L); |
1992 lc_gethoghat := 1; |
1823 lc_gethoghat := 1; |
1993 end; |
1824 end; |
1994 |
1825 |
1995 function lc_sethoghat(L : Plua_State) : LongInt; Cdecl; |
1826 function lc_sethoghat(L : Plua_State) : LongInt; Cdecl; |
1996 var gear : PGear; |
1827 var gear : PGear; |
1997 hat: ShortString; |
1828 hat: ShortString; |
1998 begin |
1829 begin |
1999 if lua_gettop(L) <> 2 then |
1830 if CheckLuaParameterCount(L, 2, 'SetHogHat', 'gearUid, hat') then |
2000 begin |
|
2001 LuaParameterCountError('SetHogHat', 'gearUid, hat', lua_gettop(L)); |
|
2002 lua_pushnil(L) |
|
2003 end |
|
2004 else |
|
2005 begin |
1831 begin |
2006 gear:= GearByUID(lua_tointeger(L, 1)); |
1832 gear:= GearByUID(lua_tointeger(L, 1)); |
2007 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1833 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
2008 begin |
1834 begin |
2009 hat:= lua_tostring(L, 2); |
1835 hat:= lua_tostring(L, 2); |