640 end |
640 end |
641 end; |
641 end; |
642 lc_copypv:= 1 |
642 lc_copypv:= 1 |
643 end; |
643 end; |
644 |
644 |
645 function lc_copypv2(L : Plua_State) : LongInt; Cdecl; |
|
646 var gears, geard : PGear; |
|
647 begin |
|
648 if lua_gettop(L) <> 2 then |
|
649 begin |
|
650 LuaError('Lua: Wrong number of parameters passed to CopyPV2!'); |
|
651 end |
|
652 else |
|
653 begin |
|
654 gears:= GearByUID(lua_tointeger(L, 1)); |
|
655 geard:= GearByUID(lua_tointeger(L, 2)); |
|
656 if (gears <> nil) and (geard <> nil) then |
|
657 begin |
|
658 geard^.X:= gears^.X; |
|
659 geard^.Y:= gears^.Y; |
|
660 geard^.dX:= gears^.dX * 2; |
|
661 geard^.dY:= gears^.dY * 2; |
|
662 end |
|
663 end; |
|
664 lc_copypv2:= 1 |
|
665 end; |
|
666 |
|
667 function lc_followgear(L : Plua_State) : LongInt; Cdecl; |
645 function lc_followgear(L : Plua_State) : LongInt; Cdecl; |
668 var gear : PGear; |
646 var gear : PGear; |
669 begin |
647 begin |
670 if lua_gettop(L) <> 1 then |
648 if lua_gettop(L) <> 1 then |
671 LuaError('Lua: Wrong number of parameters passed to FollowGear!') |
649 LuaError('Lua: Wrong number of parameters passed to FollowGear!') |
862 else LuaError('Lua: Wrong number of parameters passed to PlaySound!'); |
840 else LuaError('Lua: Wrong number of parameters passed to PlaySound!'); |
863 lc_playsound:= 0; |
841 lc_playsound:= 0; |
864 end; |
842 end; |
865 |
843 |
866 function lc_addteam(L : Plua_State) : LongInt; Cdecl; |
844 function lc_addteam(L : Plua_State) : LongInt; Cdecl; |
867 begin |
845 var np: LongInt; |
868 if lua_gettop(L) <> 5 then |
846 begin |
|
847 np:= lua_gettop(L); |
|
848 if (np < 5) or (np > 6) then |
869 begin |
849 begin |
870 LuaError('Lua: Wrong number of parameters passed to AddTeam!'); |
850 LuaError('Lua: Wrong number of parameters passed to AddTeam!'); |
871 //lua_pushnil(L) |
851 //lua_pushnil(L) |
872 end |
852 end |
873 else |
853 else |
874 begin |
854 begin |
875 ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true); |
855 ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true); |
876 ParseCommand('grave ' + lua_tostring(L, 3), true); |
856 ParseCommand('grave ' + lua_tostring(L, 3), true); |
877 ParseCommand('fort ' + lua_tostring(L, 4), true); |
857 ParseCommand('fort ' + lua_tostring(L, 4), true); |
878 ParseCommand('voicepack ' + lua_tostring(L, 5), true); |
858 ParseCommand('voicepack ' + lua_tostring(L, 5), true); |
|
859 if (np = 6) then ParseCommand('flag ' + lua_tostring(L, 6), true); |
879 CurrentTeam^.Binds:= DefaultBinds |
860 CurrentTeam^.Binds:= DefaultBinds |
880 // fails on x64 |
861 // fails on x64 |
881 //lua_pushinteger(L, LongInt(CurrentTeam)); |
862 //lua_pushinteger(L, LongInt(CurrentTeam)); |
882 end; |
863 end; |
883 lc_addteam:= 0;//1; |
864 lc_addteam:= 0;//1; |
955 gear^.Y:= int2hwfloat(y); |
936 gear^.Y:= int2hwfloat(y); |
956 SetAllToActive; |
937 SetAllToActive; |
957 end |
938 end |
958 end; |
939 end; |
959 lc_setgearposition:= 0 |
940 lc_setgearposition:= 0 |
|
941 end; |
|
942 |
|
943 function lc_getgearvelocity(L : Plua_State) : LongInt; Cdecl; |
|
944 var gear: PGear; |
|
945 begin |
|
946 if lua_gettop(L) <> 1 then |
|
947 begin |
|
948 LuaError('Lua: Wrong number of parameters passed to GetGearVelocity!'); |
|
949 lua_pushnil(L); |
|
950 lua_pushnil(L) |
|
951 end |
|
952 else |
|
953 begin |
|
954 gear:= GearByUID(lua_tointeger(L, 1)); |
|
955 if gear <> nil then |
|
956 begin |
|
957 lua_pushnumber(L, hwRound(gear^.dX * 1000) / 1000); |
|
958 lua_pushnumber(L, hwRound(gear^.dY * 1000) / 1000) |
|
959 end |
|
960 end; |
|
961 lc_getgearvelocity:= 2; |
|
962 end; |
|
963 |
|
964 function lc_setgearvelocity(L : Plua_State) : LongInt; Cdecl; |
|
965 var gear: PGear; |
|
966 begin |
|
967 if lua_gettop(L) <> 3 then |
|
968 LuaError('Lua: Wrong number of parameters passed to SetGearVelocity!') |
|
969 else |
|
970 begin |
|
971 gear:= GearByUID(lua_tointeger(L, 1)); |
|
972 if gear <> nil then |
|
973 begin |
|
974 gear^.dX:= int2hwFloat(round(lua_tonumber(L, 2) * 1000)) / 1000; |
|
975 gear^.dY:= int2hwFloat(round(lua_tonumber(L, 3) * 1000)) / 1000; |
|
976 SetAllToActive; |
|
977 end |
|
978 end; |
|
979 lc_setgearvelocity:= 0 |
960 end; |
980 end; |
961 |
981 |
962 function lc_setzoom(L : Plua_State) : LongInt; Cdecl; |
982 function lc_setzoom(L : Plua_State) : LongInt; Cdecl; |
963 begin |
983 begin |
964 if lua_gettop(L) <> 1 then |
984 if lua_gettop(L) <> 1 then |
1410 lua_register(luaState, 'GetGearType', @lc_getgeartype); |
1430 lua_register(luaState, 'GetGearType', @lc_getgeartype); |
1411 lua_register(luaState, 'EndGame', @lc_endgame); |
1431 lua_register(luaState, 'EndGame', @lc_endgame); |
1412 lua_register(luaState, 'FindPlace', @lc_findplace); |
1432 lua_register(luaState, 'FindPlace', @lc_findplace); |
1413 lua_register(luaState, 'SetGearPosition', @lc_setgearposition); |
1433 lua_register(luaState, 'SetGearPosition', @lc_setgearposition); |
1414 lua_register(luaState, 'GetGearPosition', @lc_getgearposition); |
1434 lua_register(luaState, 'GetGearPosition', @lc_getgearposition); |
|
1435 lua_register(luaState, 'SetGearVelocity', @lc_setgearvelocity); |
|
1436 lua_register(luaState, 'GetGearVelocity', @lc_getgearvelocity); |
1415 lua_register(luaState, 'ParseCommand', @lc_parsecommand); |
1437 lua_register(luaState, 'ParseCommand', @lc_parsecommand); |
1416 lua_register(luaState, 'ShowMission', @lc_showmission); |
1438 lua_register(luaState, 'ShowMission', @lc_showmission); |
1417 lua_register(luaState, 'HideMission', @lc_hidemission); |
1439 lua_register(luaState, 'HideMission', @lc_hidemission); |
1418 lua_register(luaState, 'AddCaption', @lc_addcaption); |
1440 lua_register(luaState, 'AddCaption', @lc_addcaption); |
1419 lua_register(luaState, 'SetAmmo', @lc_setammo); |
1441 lua_register(luaState, 'SetAmmo', @lc_setammo); |
1431 lua_register(luaState, 'GetHogLevel', @lc_gethoglevel); |
1453 lua_register(luaState, 'GetHogLevel', @lc_gethoglevel); |
1432 lua_register(luaState, 'SetHogLevel', @lc_sethoglevel); |
1454 lua_register(luaState, 'SetHogLevel', @lc_sethoglevel); |
1433 lua_register(luaState, 'GetX', @lc_getx); |
1455 lua_register(luaState, 'GetX', @lc_getx); |
1434 lua_register(luaState, 'GetY', @lc_gety); |
1456 lua_register(luaState, 'GetY', @lc_gety); |
1435 lua_register(luaState, 'CopyPV', @lc_copypv); |
1457 lua_register(luaState, 'CopyPV', @lc_copypv); |
1436 lua_register(luaState, 'CopyPV2', @lc_copypv2); |
|
1437 lua_register(luaState, 'FollowGear', @lc_followgear); |
1458 lua_register(luaState, 'FollowGear', @lc_followgear); |
1438 lua_register(luaState, 'GetFollowGear', @lc_getfollowgear); |
1459 lua_register(luaState, 'GetFollowGear', @lc_getfollowgear); |
1439 lua_register(luaState, 'SetState', @lc_setstate); |
1460 lua_register(luaState, 'SetState', @lc_setstate); |
1440 lua_register(luaState, 'GetState', @lc_getstate); |
1461 lua_register(luaState, 'GetState', @lc_getstate); |
1441 lua_register(luaState, 'SetTag', @lc_settag); |
1462 lua_register(luaState, 'SetTag', @lc_settag); |