834 else |
834 else |
835 begin |
835 begin |
836 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
836 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
837 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
837 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
838 end; |
838 end; |
839 lc_getvisualgearvalues:= 10; |
839 lc_getvisualgearvalues:= 10 |
840 end; |
840 end; |
841 |
841 |
842 function lc_setvisualgearvalues(L : Plua_State) : LongInt; Cdecl; |
842 function lc_setvisualgearvalues(L : Plua_State) : LongInt; Cdecl; |
843 var vg : PVisualGear; |
843 var vg : PVisualGear; |
844 begin |
844 begin |
845 if CheckLuaParamCount(L, 11, 'SetVisualGearValues', 'vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint') then |
845 // Param count can be 1-11 at present |
846 begin |
846 // if CheckLuaParamCount(L, 11, 'SetVisualGearValues', 'vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint') then |
|
847 // begin |
847 vg:= VisualGearByUID(lua_tointeger(L, 1)); |
848 vg:= VisualGearByUID(lua_tointeger(L, 1)); |
848 if vg <> nil then |
849 if vg <> nil then |
849 begin |
850 begin |
850 if not lua_isnoneornil(L, 2) then |
851 if not lua_isnoneornil(L, 2) then |
851 vg^.X:= lua_tointeger(L, 2); |
852 vg^.X:= lua_tointeger(L, 2); |
864 if not lua_isnoneornil(L, 9) then |
865 if not lua_isnoneornil(L, 9) then |
865 vg^.State:= lua_tointeger(L, 9); |
866 vg^.State:= lua_tointeger(L, 9); |
866 if not lua_isnoneornil(L, 10) then |
867 if not lua_isnoneornil(L, 10) then |
867 vg^.Timer:= lua_tointeger(L, 10); |
868 vg^.Timer:= lua_tointeger(L, 10); |
868 if not lua_isnoneornil(L, 11) then |
869 if not lua_isnoneornil(L, 11) then |
869 vg^.Tint:= lua_tointeger(L, 11); |
870 vg^.Tint:= lua_tointeger(L, 11) |
|
871 end; |
|
872 // end |
|
873 // else |
|
874 // lua_pushnil(L); // return value on stack (nil) |
|
875 lc_setvisualgearvalues:= 0 |
|
876 end; |
|
877 |
|
878 // so. going to use this to get/set some of the more obscure gear values which weren't already exposed elsewhere |
|
879 // can keep adding things in the future. isnoneornil makes it safe |
|
880 function lc_getgearvalues(L : Plua_State) : LongInt; Cdecl; |
|
881 var gear: PGear; |
|
882 begin |
|
883 if CheckLuaParamCount(L, 1, 'GetGearValues', 'gearUid') then |
|
884 begin |
|
885 gear:= GearByUID(lua_tointeger(L, 1)); |
|
886 if gear <> nil then |
|
887 begin |
|
888 lua_pushinteger(L, gear^.Angle); |
|
889 lua_pushinteger(L, gear^.Power); |
|
890 lua_pushinteger(L, gear^.WDTimer); |
|
891 lua_pushinteger(L, gear^.Radius); |
|
892 lua_pushinteger(L, hwRound(gear^.Density * _10000)); |
|
893 lua_pushinteger(L, gear^.Karma); |
|
894 lua_pushnumber(L, gear^.DirAngle); |
|
895 lua_pushinteger(L, gear^.AdvBounce); |
|
896 lua_pushinteger(L, Integer(gear^.ImpactSound)); |
|
897 lua_pushinteger(L, gear^.nImpactSounds); |
|
898 lua_pushinteger(L, gear^.Tint) |
870 end |
899 end |
871 end |
900 else |
872 else |
901 begin |
873 lua_pushnil(L); // return value on stack (nil) |
902 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
874 lc_setvisualgearvalues:= 0; |
903 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
|
904 lua_pushnil(L) |
|
905 end |
|
906 end |
|
907 else |
|
908 begin |
|
909 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
|
910 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
|
911 lua_pushnil(L) |
|
912 end; |
|
913 lc_getgearvalues:= 11 |
|
914 end; |
|
915 |
|
916 function lc_setgearvalues(L : Plua_State) : LongInt; Cdecl; |
|
917 var gear : PGear; |
|
918 begin |
|
919 // Currently allows 1-12 params |
|
920 // if CheckLuaParamCount(L, 12, 'SetGearValues', 'gearUid, Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, # ImpactSounds, Tint') then |
|
921 // begin |
|
922 gear:= GearByUID(lua_tointeger(L, 1)); |
|
923 if gear <> nil then |
|
924 begin |
|
925 if not lua_isnoneornil(L, 2) then |
|
926 gear^.Angle := lua_tointeger(L, 2); |
|
927 if not lua_isnoneornil(L, 3) then |
|
928 gear^.Power := lua_tointeger(L, 3); |
|
929 if not lua_isnoneornil(L, 4) then |
|
930 gear^.WDTimer := lua_tointeger(L, 4); |
|
931 if not lua_isnoneornil(L, 5) then |
|
932 gear^.Radius := lua_tointeger(L, 5); |
|
933 if not lua_isnoneornil(L, 6) then |
|
934 gear^.Density:= int2hwFloat(lua_tointeger(L, 6)) / 10000; |
|
935 if not lua_isnoneornil(L, 7) then |
|
936 gear^.Karma := lua_tointeger(L, 7); |
|
937 if not lua_isnoneornil(L, 8) then |
|
938 gear^.DirAngle:= lua_tonumber(L, 8); |
|
939 if not lua_isnoneornil(L, 9) then |
|
940 gear^.AdvBounce := lua_tointeger(L, 9); |
|
941 if not lua_isnoneornil(L, 10) then |
|
942 gear^.ImpactSound := TSound(lua_tointeger(L, 10)); |
|
943 if not lua_isnoneornil(L, 11) then |
|
944 gear^.nImpactSounds := lua_tointeger(L, 11); |
|
945 if not lua_isnoneornil(L, 12) then |
|
946 gear^.Tint := lua_tointeger(L, 12) |
|
947 end; |
|
948 // end |
|
949 // else |
|
950 // lua_pushnil(L); // return value on stack (nil) |
|
951 lc_setgearvalues:= 0 |
875 end; |
952 end; |
876 |
953 |
877 function lc_getfollowgear(L : Plua_State) : LongInt; Cdecl; |
954 function lc_getfollowgear(L : Plua_State) : LongInt; Cdecl; |
878 begin |
955 begin |
879 if CheckLuaParamCount(L, 0, 'GetFollowGear', '') then |
956 if CheckLuaParamCount(L, 0, 'GetFollowGear', '') then |
2978 lua_register(luaState, _P'DeleteGear', @lc_deletegear); |
3071 lua_register(luaState, _P'DeleteGear', @lc_deletegear); |
2979 lua_register(luaState, _P'AddVisualGear', @lc_addvisualgear); |
3072 lua_register(luaState, _P'AddVisualGear', @lc_addvisualgear); |
2980 lua_register(luaState, _P'DeleteVisualGear', @lc_deletevisualgear); |
3073 lua_register(luaState, _P'DeleteVisualGear', @lc_deletevisualgear); |
2981 lua_register(luaState, _P'GetVisualGearValues', @lc_getvisualgearvalues); |
3074 lua_register(luaState, _P'GetVisualGearValues', @lc_getvisualgearvalues); |
2982 lua_register(luaState, _P'SetVisualGearValues', @lc_setvisualgearvalues); |
3075 lua_register(luaState, _P'SetVisualGearValues', @lc_setvisualgearvalues); |
|
3076 lua_register(luaState, _P'GetGearValues', @lc_getgearvalues); |
|
3077 lua_register(luaState, _P'SetGearValues', @lc_setgearvalues); |
2983 lua_register(luaState, _P'SpawnHealthCrate', @lc_spawnhealthcrate); |
3078 lua_register(luaState, _P'SpawnHealthCrate', @lc_spawnhealthcrate); |
2984 lua_register(luaState, _P'SpawnAmmoCrate', @lc_spawnammocrate); |
3079 lua_register(luaState, _P'SpawnAmmoCrate', @lc_spawnammocrate); |
2985 lua_register(luaState, _P'SpawnUtilityCrate', @lc_spawnutilitycrate); |
3080 lua_register(luaState, _P'SpawnUtilityCrate', @lc_spawnutilitycrate); |
2986 lua_register(luaState, _P'SpawnFakeHealthCrate', @lc_spawnfakehealthcrate); |
3081 lua_register(luaState, _P'SpawnFakeHealthCrate', @lc_spawnfakehealthcrate); |
2987 lua_register(luaState, _P'SpawnFakeAmmoCrate', @lc_spawnfakeammocrate); |
3082 lua_register(luaState, _P'SpawnFakeAmmoCrate', @lc_spawnfakeammocrate); |
3043 lua_register(luaState, _P'HogTurnLeft', @lc_hogturnleft); |
3138 lua_register(luaState, _P'HogTurnLeft', @lc_hogturnleft); |
3044 lua_register(luaState, _P'CampaignLock', @lc_campaignlock); |
3139 lua_register(luaState, _P'CampaignLock', @lc_campaignlock); |
3045 lua_register(luaState, _P'CampaignUnlock', @lc_campaignunlock); |
3140 lua_register(luaState, _P'CampaignUnlock', @lc_campaignunlock); |
3046 lua_register(luaState, _P'GetGearElasticity', @lc_getgearelasticity); |
3141 lua_register(luaState, _P'GetGearElasticity', @lc_getgearelasticity); |
3047 lua_register(luaState, _P'SetGearElasticity', @lc_setgearelasticity); |
3142 lua_register(luaState, _P'SetGearElasticity', @lc_setgearelasticity); |
|
3143 lua_register(luaState, _P'GetGearFriction', @lc_getgearfriction); |
3048 lua_register(luaState, _P'SetGearFriction', @lc_setgearfriction); |
3144 lua_register(luaState, _P'SetGearFriction', @lc_setgearfriction); |
3049 lua_register(luaState, _P'GetGearRadius', @lc_getgearradius); |
3145 lua_register(luaState, _P'GetGearRadius', @lc_getgearradius); |
3050 lua_register(luaState, _P'GetGearMessage', @lc_getgearmessage); |
3146 lua_register(luaState, _P'GetGearMessage', @lc_getgearmessage); |
3051 lua_register(luaState, _P'SetGearMessage', @lc_setgearmessage); |
3147 lua_register(luaState, _P'SetGearMessage', @lc_setgearmessage); |
3052 lua_register(luaState, _P'GetGearPos', @lc_getgearpos); |
3148 lua_register(luaState, _P'GetGearPos', @lc_getgearpos); |