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 vg^.X:= lua_tointeger(L, 2); |
851 if not lua_isnoneornil(L, 2) then |
851 vg^.Y:= lua_tointeger(L, 3); |
852 vg^.X:= lua_tointeger(L, 2); |
852 vg^.dX:= lua_tonumber(L, 4); |
853 if not lua_isnoneornil(L, 3) then |
853 vg^.dY:= lua_tonumber(L, 5); |
854 vg^.Y:= lua_tointeger(L, 3); |
854 vg^.Angle:= lua_tonumber(L, 6); |
855 if not lua_isnoneornil(L, 4) then |
855 vg^.Frame:= lua_tointeger(L, 7); |
856 vg^.dX:= lua_tonumber(L, 4); |
856 if lua_tointeger(L, 8) <> 0 then |
857 if not lua_isnoneornil(L, 5) then |
857 vg^.FrameTicks:= lua_tointeger(L, 8); // find a better way to do this. maybe need to break all these up. |
858 vg^.dY:= lua_tonumber(L, 5); |
858 vg^.State:= lua_tointeger(L, 9); |
859 if not lua_isnoneornil(L, 6) then |
859 vg^.Timer:= lua_tointeger(L, 10); |
860 vg^.Angle:= lua_tonumber(L, 6); |
860 vg^.Tint:= lua_tointeger(L, 11); |
861 if not lua_isnoneornil(L, 7) then |
|
862 vg^.Frame:= lua_tointeger(L, 7); |
|
863 if not lua_isnoneornil(L, 8) then |
|
864 vg^.FrameTicks:= lua_tointeger(L, 8); |
|
865 if not lua_isnoneornil(L, 9) then |
|
866 vg^.State:= lua_tointeger(L, 9); |
|
867 if not lua_isnoneornil(L, 10) then |
|
868 vg^.Timer:= lua_tointeger(L, 10); |
|
869 if not lua_isnoneornil(L, 11) then |
|
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) |
861 end |
899 end |
862 end |
900 else |
863 else |
901 begin |
864 lua_pushnil(L); // return value on stack (nil) |
902 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
865 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 |
866 end; |
952 end; |
867 |
953 |
868 function lc_getfollowgear(L : Plua_State) : LongInt; Cdecl; |
954 function lc_getfollowgear(L : Plua_State) : LongInt; Cdecl; |
869 begin |
955 begin |
870 if CheckLuaParamCount(L, 0, 'GetFollowGear', '') then |
956 if CheckLuaParamCount(L, 0, 'GetFollowGear', '') then |
2945 lua_register(luaState, _P'DeleteGear', @lc_deletegear); |
3071 lua_register(luaState, _P'DeleteGear', @lc_deletegear); |
2946 lua_register(luaState, _P'AddVisualGear', @lc_addvisualgear); |
3072 lua_register(luaState, _P'AddVisualGear', @lc_addvisualgear); |
2947 lua_register(luaState, _P'DeleteVisualGear', @lc_deletevisualgear); |
3073 lua_register(luaState, _P'DeleteVisualGear', @lc_deletevisualgear); |
2948 lua_register(luaState, _P'GetVisualGearValues', @lc_getvisualgearvalues); |
3074 lua_register(luaState, _P'GetVisualGearValues', @lc_getvisualgearvalues); |
2949 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); |
2950 lua_register(luaState, _P'SpawnHealthCrate', @lc_spawnhealthcrate); |
3078 lua_register(luaState, _P'SpawnHealthCrate', @lc_spawnhealthcrate); |
2951 lua_register(luaState, _P'SpawnAmmoCrate', @lc_spawnammocrate); |
3079 lua_register(luaState, _P'SpawnAmmoCrate', @lc_spawnammocrate); |
2952 lua_register(luaState, _P'SpawnUtilityCrate', @lc_spawnutilitycrate); |
3080 lua_register(luaState, _P'SpawnUtilityCrate', @lc_spawnutilitycrate); |
2953 lua_register(luaState, _P'SpawnFakeHealthCrate', @lc_spawnfakehealthcrate); |
3081 lua_register(luaState, _P'SpawnFakeHealthCrate', @lc_spawnfakehealthcrate); |
2954 lua_register(luaState, _P'SpawnFakeAmmoCrate', @lc_spawnfakeammocrate); |
3082 lua_register(luaState, _P'SpawnFakeAmmoCrate', @lc_spawnfakeammocrate); |
3009 lua_register(luaState, _P'SwitchHog', @lc_switchhog); |
3137 lua_register(luaState, _P'SwitchHog', @lc_switchhog); |
3010 lua_register(luaState, _P'HogTurnLeft', @lc_hogturnleft); |
3138 lua_register(luaState, _P'HogTurnLeft', @lc_hogturnleft); |
3011 lua_register(luaState, _P'CampaignLock', @lc_campaignlock); |
3139 lua_register(luaState, _P'CampaignLock', @lc_campaignlock); |
3012 lua_register(luaState, _P'CampaignUnlock', @lc_campaignunlock); |
3140 lua_register(luaState, _P'CampaignUnlock', @lc_campaignunlock); |
3013 lua_register(luaState, _P'GetGearElasticity', @lc_getgearelasticity); |
3141 lua_register(luaState, _P'GetGearElasticity', @lc_getgearelasticity); |
|
3142 lua_register(luaState, _P'SetGearElasticity', @lc_setgearelasticity); |
|
3143 lua_register(luaState, _P'GetGearFriction', @lc_getgearfriction); |
|
3144 lua_register(luaState, _P'SetGearFriction', @lc_setgearfriction); |
3014 lua_register(luaState, _P'GetGearRadius', @lc_getgearradius); |
3145 lua_register(luaState, _P'GetGearRadius', @lc_getgearradius); |
3015 lua_register(luaState, _P'GetGearMessage', @lc_getgearmessage); |
3146 lua_register(luaState, _P'GetGearMessage', @lc_getgearmessage); |
3016 lua_register(luaState, _P'SetGearMessage', @lc_setgearmessage); |
3147 lua_register(luaState, _P'SetGearMessage', @lc_setgearmessage); |
3017 lua_register(luaState, _P'GetGearPos', @lc_getgearpos); |
3148 lua_register(luaState, _P'GetGearPos', @lc_getgearpos); |
3018 lua_register(luaState, _P'SetGearPos', @lc_setgearpos); |
3149 lua_register(luaState, _P'SetGearPos', @lc_setgearpos); |