jump fix, added check for rocket teleportation if mod is not installed.

This commit is contained in:
Vitaliy Olkhin 2024-09-24 15:44:11 +05:00
parent d71e318230
commit 46061ed9a2
3 changed files with 221 additions and 158 deletions

View File

@ -493,7 +493,7 @@ minetest.register_craft({
})
--Space Drive recipes
if minetest.get_modpath("rocket") then
minetest.register_craft({
output = 'space_travel:space_drive_engine',
recipe = {
@ -574,3 +574,4 @@ minetest.register_craft({
{'space_travel:dark_matter_crystal', 'default:gold_ingot', 'space_travel:dark_matter_crystal'},
}
})
end

60
sky.lua
View File

@ -316,6 +316,18 @@ minetest.register_on_joinplayer(function(player)
sky_defaults.col, sky_defaults.tp, sky_defaults.tex, sky_defaults.cl = player:get_sky()
end)
local player_weightlessness = {}
local function set_weightlessness(name, par)
player_weightlessness[name] = par
end
local function get_weightlessness(name)
if type(player_weightlessness[name]) ~= 'nil' then
return player_weightlessness[name]
end
return false
end
minetest.register_globalstep(function(dtime)
time = time + dtime
if time > 1 then
@ -347,39 +359,51 @@ minetest.register_globalstep(function(dtime)
thickness = 16,
speed ={x=0, z=-2},
})
if get_weightlessness(name) == true then
player:set_physics_override(1, 1, 1) -- speed, jump, gravity
set_weightlessness(name, false)
end
return
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.yarth and pos.y < space_travel.yarth_orbit then --Earth orbit
player:set_sky({r = 0, g = 0, b = 0}, "skybox", earth_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.yarth_orbit and pos.y < space_travel.luna then --Moon sky
player:set_sky({r = 0, g = 0, b = 0}, "skybox", moon_sky)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.luna and pos.y < space_travel.luna_orbit then --Moon orbit
player:set_sky({r = 0, g = 0, b = 0}, "skybox", moon_sky)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.luna_orbit and pos.y < space_travel.mars and day_time then --Mars sky at day
player:set_sky({r=219, g=168, b=117}, "plain", {})
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.luna_orbit and pos.y < space_travel.mars and (not day_time) then --Mars sky at night
player:set_sky({r = 0, g = 0, b = 0}, "skybox", mars_night)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.mars and pos.y < space_travel.mars_orbit then --Mars orbit
player:set_sky({r = 0, g = 0, b = 0}, "skybox", mars_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.mars_orbit and pos.y < space_travel.mercury then --Mercury sky
player:set_sky({r = 0, g = 0, b = 0}, "skybox", mercury_sky)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.mercury and pos.y < space_travel.mercury_orbit then --Mercury orbit
player:set_sky({r = 0, g = 0, b = 0}, "skybox", mercury_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.mercury and pos.y < space_travel.venus and day_time then --Venus sky at day
player:set_sky({r=208, g=177, b=11}, "plain", {})
player:set_clouds({
@ -391,6 +415,7 @@ minetest.register_globalstep(function(dtime)
speed ={x=0, z=10},
})
player:set_physics_override(1, 1, 1) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.mercury and pos.y < space_travel.venus and (not day_time) then --Venus sky at night
player:set_sky({r=102, g=87, b=5}, "plain", {})
player:set_clouds({
@ -402,6 +427,7 @@ minetest.register_globalstep(function(dtime)
speed ={x=0, z=10},
})
player:set_physics_override(1, 1, 1) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.venus and pos.y < space_travel.venus_orbit then --Venus orbit
player:set_sky({r = 0, g = 0, b = 0}, "skybox", venus_space)
player:set_clouds({density = 0})
@ -410,34 +436,42 @@ minetest.register_globalstep(function(dtime)
player:set_sky({r = 0, g = 0, b = 0}, "skybox", jupiter_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.ganymede and pos.y < space_travel.ganymede_orbit then --Ganymede orbit
player:set_sky({r = 0, g = 0, b = 0}, "skybox", ganymede_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.ganymede_orbit and pos.y < space_travel.callisto then --Callisto sky
player:set_sky({r = 0, g = 0, b = 0}, "skybox", jupiter_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.callisto and pos.y < space_travel.callisto_orbit then --Callisto orbit
player:set_sky({r = 0, g = 0, b = 0}, "skybox", callisto_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.callisto_orbit and pos.y < space_travel.io then --Io sky
player:set_sky({r = 0, g = 0, b = 0}, "skybox", jupiter_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.io and pos.y < space_travel.io_orbit then --Io orbit
player:set_sky({r = 0, g = 0, b = 0}, "skybox", io_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.io_orbit and pos.y < space_travel.europa then --Europa sky
player:set_sky({r = 0, g = 0, b = 0}, "skybox", jupiter_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.europa and pos.y < space_travel.europa_orbit then --Europa orbit
player:set_sky({r = 0, g = 0, b = 0}, "skybox", europa_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.europa_orbit and pos.y < space_travel.titan and day_time then --Titan sky at day
player:set_sky({r = 239, g = 194, b = 109}, "skybox", titan_sky)
player:set_clouds({
@ -449,6 +483,7 @@ minetest.register_globalstep(function(dtime)
speed ={x=0, z=-6},
})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.europa_orbit and pos.y < space_travel.titan and (not day_time) then --Titan sky at night
player:set_sky({r = 128, g = 103, b = 58}, "plain", {})
player:set_clouds({
@ -460,54 +495,67 @@ minetest.register_globalstep(function(dtime)
speed ={x=0, z=-6},
})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.titan and pos.y < space_travel.titan_orbit then --Titan orbit
player:set_sky({r = 0, g = 0, b = 0}, "skybox", saturn_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.titan_orbit and pos.y < space_travel.oberon then --Oberon sky
player:set_sky({r = 0, g = 0, b = 0}, "skybox", uranus_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.oberon and pos.y < space_travel.oberon_orbit then --Oberon orbit
player:set_sky({r = 0, g = 0, b = 0}, "skybox", uranus_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.oberon_orbit and pos.y < space_travel.triton then --Triton sky
player:set_sky({r = 0, g = 0, b = 0}, "skybox", neptune_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.triton and pos.y < space_travel.triton_orbit then --Triton orbit
player:set_sky({r = 0, g = 0, b = 0}, "skybox", neptune_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.triton_orbit and pos.y < space_travel.pluto then --Pluto sky
player:set_sky({r = 0, g = 0, b = 0}, "skybox", pluto_sky)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.pluto and pos.y < space_travel.pluto_orbit then --Pluto orbit
player:set_sky({r = 0, g = 0, b = 0}, "skybox", pluto_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.pluto_orbit and pos.y < space_travel.charon then --Charon sky
player:set_sky({r = 0, g = 0, b = 0}, "skybox", charon_sky)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.charon and pos.y < space_travel.charon_orbit then --Charon orbit
player:set_sky({r = 0, g = 0, b = 0}, "skybox", charon_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.charon_orbit and pos.y < space_travel.sedna then --Sedna sky
player:set_sky({r = 118, g = 84, b = 84}, "skybox", sedna_sky)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.sedna and pos.y < space_travel.sedna_orbit then --Sedna orbit
player:set_sky({r = 118, g = 84, b = 84}, "skybox", sedna_sky)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.sedna_orbit and pos.y < space_travel.asteriod_belt then --Asteriod belt sky
player:set_sky({r = 0, g = 0, b = 0}, "skybox", cosmos_sky)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.asteriod_belt and pos.y < space_travel.asteriod_belt_orbit and day_time then --Minerva sky at day
player:set_sky({r=249, g=139, b=139}, "plain", {})
player:set_clouds({
@ -519,6 +567,7 @@ minetest.register_globalstep(function(dtime)
speed ={x=0, z=-2},
})
player:set_physics_override(1, 1, 1) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.asteriod_belt and pos.y < space_travel.asteriod_belt_orbit and (not day_time) then --Minerva sky at night
player:set_sky({r = 0, g = 0, b = 0}, "skybox", minerva_night)
player:set_clouds({
@ -530,6 +579,7 @@ minetest.register_globalstep(function(dtime)
speed ={x=0, z=-2},
})
player:set_physics_override(1, 1, 1) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.minerva and pos.y < space_travel.minerva_orbit then --Minerva orbit
player:set_sky({r = 0, g = 0, b = 0}, "skybox", minerva_space)
player:set_clouds({density = 0})
@ -545,6 +595,7 @@ minetest.register_globalstep(function(dtime)
speed ={x=0, z=-2},
})
player:set_physics_override(1, 1, 1) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.minerva_orbit and pos.y < space_travel.bacchus and (not day_time) then --Bacchus sky at night
player:set_sky({r = 0, g = 0, b = 0}, "skybox", minerva_night)
player:set_clouds({
@ -556,22 +607,27 @@ minetest.register_globalstep(function(dtime)
speed ={x=0, z=-2},
})
player:set_physics_override(1, 1, 1) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.bacchus and pos.y < space_travel.bacchus_orbit then --Bacchus orbit
player:set_sky({r = 0, g = 0, b = 0}, "skybox", bacchus_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.bacchus_orbit and pos.y < space_travel.ourea and day_time then --Ourea sky at day
player:set_sky({r = 0, g = 0, b = 0}, "skybox", ourea_sky)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.bacchus_orbit and pos.y < space_travel.ourea and (not day_time) then --Ourea night at day
player:set_sky({r = 0, g = 0, b = 0}, "skybox", caelus_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.ourea and pos.y < space_travel.ourea_orbit then --Ourea orbit
player:set_sky({r = 0, g = 0, b = 0}, "skybox", caelus_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.ourea_orbit and pos.y < space_travel.osiris and day_time then --Osiris sky at day
player:set_sky({r=247, g=180, b=138}, "plain", {})
player:set_clouds({
@ -583,6 +639,7 @@ minetest.register_globalstep(function(dtime)
speed ={x=0, z=-2},
})
player:set_physics_override(1, 1, 1) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.ourea_orbit and pos.y < space_travel.osiris and (not day_time) then --Osiris sky at night
player:set_sky({r = 0, g = 0, b = 0}, "skybox", osiris_night)
player:set_clouds({
@ -594,6 +651,7 @@ minetest.register_globalstep(function(dtime)
speed ={x=0, z=-2},
})
player:set_physics_override(1, 1, 1) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.osiris and pos.y < space_travel.osiris_orbit then --Osiris orbit
player:set_sky({r = 0, g = 0, b = 0}, "skybox", osiris_space)
player:set_clouds({density = 0})
@ -602,6 +660,7 @@ minetest.register_globalstep(function(dtime)
player:set_sky({r=117, g=219, b=170}, "plain", {})
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
elseif minetest.get_player_by_name(name) and pos.y >= space_travel.osiris_orbit and pos.y < space_travel.minthe and (not day_time) then --Minthe sky at night
player:set_sky({r = 0, g = 0, b = 0}, "skybox", minthe_night)
player:set_clouds({density = 0})
@ -610,6 +669,7 @@ minetest.register_globalstep(function(dtime)
player:set_sky({r = 0, g = 0, b = 0}, "skybox", minthe_space)
player:set_clouds({density = 0})
player:set_physics_override(1, 0.6, 0.2) -- speed, jump, gravity
set_weightlessness(name, true)
end
--End of important code
end

View File

@ -632,6 +632,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end
end)
if minetest.get_modpath("rocket") then
minetest.register_tool("space_travel:space_drive_1", {
description = "Tier I Basic Space Drive\n\nCan fly to the Moon.",
inventory_image = "space_travel_space_drive_1.png",
@ -729,3 +730,4 @@ minetest.register_tool("space_travel:space_drive_7", {
end
end
})
end