-mover:
can filter what objects to teleport ( by default doesnt move sign letters or itemframe objects ) updated texture, -detector, distributor: updated texture, enviro: optional space management
This commit is contained in:
parent
55e85a8c0e
commit
32064cb34d
52
enviro.lua
52
enviro.lua
@ -6,9 +6,10 @@
|
||||
local enviro = {};
|
||||
enviro.skyboxes = {
|
||||
["default"]={type = "regular", tex = {}},
|
||||
["space"]={type="skybox", tex={"sky_pos_y.png","sky_neg_y.png","sky_pos_z.png","sky_neg_z.png","sky_neg_x.png","sky_pos_x.png",}},
|
||||
["space"]={type="skybox", tex={"sky_pos_y.png","sky_neg_y.png","sky_pos_z.png","sky_neg_z.png","sky_neg_x.png","sky_pos_x.png",}}, -- need textures installed!
|
||||
["caves"]={type = "cavebox", tex = {"black.png","black.png","black.png","black.png","black.png","black.png",}}};
|
||||
|
||||
local space_start = 1500;
|
||||
|
||||
|
||||
local enviro_update_form = function (pos)
|
||||
@ -150,13 +151,12 @@ minetest.register_node("basic_machines:enviro", {
|
||||
})
|
||||
|
||||
|
||||
|
||||
-- DEFAULT (SPAWN) PHYSICS VALUE/SKYBOX
|
||||
|
||||
local reset_player_physics = function(player)
|
||||
if player then
|
||||
player:set_physics_override({speed=1,jump=0.6,gravity=0.2,sneak=true}) -- value set for extreme test space spawn
|
||||
local skybox = enviro.skyboxes["space"]; -- default skybox is "default"
|
||||
player:set_physics_override({speed=1,jump=1,gravity=1,sneak=true}) -- value set for extreme test space spawn
|
||||
local skybox = enviro.skyboxes["default"]; -- default skybox is "default"
|
||||
player:set_sky(0,skybox["type"],skybox["tex"]);
|
||||
end
|
||||
end
|
||||
@ -166,7 +166,7 @@ enviro_adjust_physics = function(player) -- adjust players physics/skybox 1 seco
|
||||
minetest.after(1, function()
|
||||
if player then
|
||||
local pos = player:getpos(); if not pos then return end
|
||||
if pos.y > 9000 then -- is player in space or not?
|
||||
if pos.y > space_start then -- is player in space or not?
|
||||
player:set_physics_override({speed=1,jump=0.6,gravity=0.2,sneak=true}) -- value set for extreme test space spawn
|
||||
local skybox = enviro.skyboxes["space"];
|
||||
player:set_sky(0,skybox["type"],skybox["tex"]);
|
||||
@ -180,10 +180,6 @@ enviro_adjust_physics = function(player) -- adjust players physics/skybox 1 seco
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- restore default values/skybox on respawn of player
|
||||
minetest.register_on_respawnplayer(reset_player_physics)
|
||||
|
||||
@ -191,7 +187,43 @@ minetest.register_on_respawnplayer(reset_player_physics)
|
||||
minetest.register_on_joinplayer(enviro_adjust_physics)
|
||||
|
||||
|
||||
-- INSERT SIMILIAR CODE IN ALL EVENTS THAT CHANGE POSITIONS LIKE /spawn
|
||||
-- SERVER GLOBAL SPACE CODE: uncomment to enable it
|
||||
|
||||
local stimer = 0
|
||||
local enviro_space = {};
|
||||
minetest.register_globalstep(function(dtime)
|
||||
stimer = stimer + dtime;
|
||||
if stimer >= 5 then
|
||||
stimer = 0;
|
||||
local players = minetest.get_connected_players();
|
||||
for _,player in pairs(players) do
|
||||
local name = player:get_player_name();
|
||||
local pos = player:getpos();
|
||||
local inspace=0; if pos.y>space_start then inspace = 1 end
|
||||
local inspace0=enviro_space[name];
|
||||
if inspace~=inspace0 then -- only adjust player enviroment ONLY if change occured ( earth->space or space->earth !)
|
||||
enviro_space[name] = inspace;
|
||||
enviro_adjust_physics(player);
|
||||
end
|
||||
|
||||
if inspace==1 then -- special space code
|
||||
local dist = math.abs(pos.x)+math.abs(pos.z);
|
||||
if dist > 50 then -- close to spawn normal
|
||||
local populated = minetest.find_node_near(pos, 5, "protector:protect");
|
||||
if not populated then -- do damage if player found not close to protectors
|
||||
local hp = player:get_hp();
|
||||
if hp>0 then
|
||||
player:set_hp(hp-10); -- dead in 20/10 = 2 events
|
||||
minetest.chat_send_player(name,"WARNING: in space you must stay close to spawn or protected areas");
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- END OF SPACE CODE
|
||||
|
||||
|
||||
-- RECIPE: extremely expensive
|
||||
|
4
init.lua
4
init.lua
@ -20,12 +20,12 @@ basic_machines = {};
|
||||
|
||||
|
||||
dofile(minetest.get_modpath("basic_machines").."/mark.lua") -- used for markings, borrowed and adapted from worldedit mod
|
||||
dofile(minetest.get_modpath("basic_machines").."/mover.lua")
|
||||
dofile(minetest.get_modpath("basic_machines").."/mover.lua") -- mover, detector, keypad, distributor
|
||||
dofile(minetest.get_modpath("basic_machines").."/technic_power.lua") -- technic power for mover
|
||||
dofile(minetest.get_modpath("basic_machines").."/recycler.lua")
|
||||
dofile(minetest.get_modpath("basic_machines").."/grinder.lua")
|
||||
dofile(minetest.get_modpath("basic_machines").."/autocrafter.lua") -- borrowed and adapted from pipeworks mod
|
||||
--dofile(minetest.get_modpath("basic_machines").."/enviro.lua") -- uncomment this to make it work
|
||||
dofile(minetest.get_modpath("basic_machines").."/enviro.lua") -- uncomment spawn/join code to change global physics, disabled by default
|
||||
|
||||
|
||||
--dofile(minetest.get_modpath("basic_machines").."/cpu.lua") -- experimental
|
||||
|
27
mover.lua
27
mover.lua
@ -48,8 +48,11 @@ basic_machines.plant_table = {["farming:seed_barley"]="farming:barley_1",["farm
|
||||
["farming:raspberries"]="farming:raspberry_1",["farming:rhubarb"]="farming:rhubarb_1",["farming:tomato"]="farming:tomato_1",
|
||||
["farming:seed_wheat"]="farming:wheat_1"}
|
||||
|
||||
--DEPRECATED: fuels used to power mover, now battery is used
|
||||
basic_machines.fuels = {["default:coal_lump"]=30,["default:cactus"]=5,["default:tree"]=10,["default:jungletree"]=12,["default:pinetree"]=12,["default:acacia_tree"]=10,["default:coalblock"]=500,["default:lava_source"]=5000,["basic_machines:charcoal"]=20}
|
||||
-- list of object that cant be teleported with mover
|
||||
basic_machines.no_teleport_table = {
|
||||
["itemframes:item"] = true,
|
||||
["signs:text"] = true
|
||||
}
|
||||
|
||||
-- *** END OF SETTINGS *** --
|
||||
|
||||
@ -67,7 +70,7 @@ end)
|
||||
-- MOVER --
|
||||
minetest.register_node("basic_machines:mover", {
|
||||
description = "Mover - universal digging/harvesting/teleporting/transporting machine, its upgradeable.",
|
||||
tiles = {"compass_top.png","default_furnace_top.png", "basic_machine_side.png","basic_machine_side.png","basic_machine_side.png","basic_machine_side.png"},
|
||||
tiles = {"compass_top.png","default_furnace_top.png", "basic_machine_mover_side.png","basic_machine_mover_side.png","basic_machine_mover_side.png","basic_machine_mover_side.png"},
|
||||
groups = {oddly_breakable_by_hand=2,mesecon_effector_on = 1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
after_place_node = function(pos, placer)
|
||||
@ -346,13 +349,16 @@ minetest.register_node("basic_machines:mover", {
|
||||
for _,obj in pairs(minetest.get_objects_inside_radius({x=x0+pos.x,y=y0+pos.y,z=z0+pos.z}, r)) do
|
||||
local lua_entity = obj:get_luaentity()
|
||||
if not obj:is_player() and lua_entity and lua_entity.itemstring ~= "" then
|
||||
-- put item in chest
|
||||
local stack = ItemStack(lua_entity.itemstring)
|
||||
if inv:room_for_item("main", stack) then
|
||||
teleport_any = true;
|
||||
inv:add_item("main", stack);
|
||||
local detected_obj = lua_entity.name or ""
|
||||
if not basic_machines.no_teleport_table[detected_obj] then -- object on no teleport list
|
||||
-- put item in chest
|
||||
local stack = ItemStack(lua_entity.itemstring)
|
||||
if inv:room_for_item("main", stack) then
|
||||
teleport_any = true;
|
||||
inv:add_item("main", stack);
|
||||
end
|
||||
obj:remove();
|
||||
end
|
||||
obj:remove();
|
||||
end
|
||||
end
|
||||
if teleport_any then
|
||||
@ -455,7 +461,7 @@ minetest.register_node("basic_machines:mover", {
|
||||
local size = inv1:get_size(invName1);
|
||||
|
||||
local found = false;
|
||||
for i = 1, size do -- xxx find item to move in inventory
|
||||
for i = 1, size do -- find item to move in inventory
|
||||
stack = inv1:get_stack(invName1, i);
|
||||
if not stack:is_empty() then found = true break end
|
||||
end
|
||||
@ -594,7 +600,6 @@ minetest.register_node("basic_machines:mover", {
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
minetest.sound_play("transporter", {pos=pos2,gain=1.0,max_hear_distance = 8,})
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB |
Loading…
x
Reference in New Issue
Block a user