diff --git a/depends.txt b/depends.txt deleted file mode 100644 index 33e984b..0000000 --- a/depends.txt +++ /dev/null @@ -1,4 +0,0 @@ -moreores? -technic? -basic_machines? -default \ No newline at end of file diff --git a/init.lua b/init.lua index 20d336f..1264ac2 100644 --- a/init.lua +++ b/init.lua @@ -4,20 +4,32 @@ aviation = {} aviator_hud_id = {} local getsetting = tonumber((minetest.settings:get("active_block_range")) or 1) * 32 -local flength = 1800 -- how many seconds you can fly +local flength = tonumber((minetest.settings:get("aviator_flight_length")) or 30) * 60 -- how many seconds you can fly local checktime = 1 -- check interval -local maxdistance = 50 -- maxradius +local maxdistance = tonumber((minetest.settings:get("aviator_flight_radius")) or 50) -- maxradius local timer = 0 -local trans = true -- no permanent forceload block if server shuts down +local trans = true -- no permanent forceload block if server shuts down local force = false -if minetest.get_modpath("mesecons_mvps") then -- pull and push resistant - mesecon.register_mvps_stopper("aviator:aviator") + +if minetest.get_modpath("mesecons_mvps") then -- pull and push resistant to pistons + mesecon.register_mvps_stopper("aviator:aviator") end if maxdistance > getsetting then force = true end + +local function aviator_get_air_pos(pos) + local nodes = minetest.find_nodes_in_area({x=pos.x-1, y=pos.y, z=pos.z-1}, {x=pos.x+1, y=pos.y+1, z=pos.z+1}, {"air"}) + if not nodes or #nodes < 1 then + return nil + else + return nodes[math.random(#nodes)] + end +end + + local function aviator_remove(pos, player, leave) local name = player:get_player_name() if aviation[name] ~= nil then @@ -76,7 +88,7 @@ if minetest.get_modpath("technic") and minetest.get_modpath("moreores") then elseif minetest.get_modpath("basic_machines") then -- do it with constructor ! - basic_machines.craft_recipes["aviator"] = {item = "aviator:aviator", description = "let you fly "..math.floor(flength/60).."min in an area of "..maxdistance.." nodes", craft = {"default:diamondblock 256","basic_machines:power_rod 25", "default:mese 256","basic_machines:keypad"}, tex = "aviator_aviator_side"} + basic_machines.craft_recipes["aviator"] = {item = "aviator:aviator", description = "let you fly "..math.floor(flength/60).."min in an area of "..maxdistance.." nodes", craft = {"default:diamondblock 16","basic_machines:power_rod 25", "default:mese 16","basic_machines:keypad"}, tex = "aviator_aviator_side"} table.insert(basic_machines.craft_recipe_order,"aviator") basic_machines.hardness["aviator:aviator"] = 999999 @@ -104,22 +116,27 @@ minetest.register_node("aviator:aviator", { is_ground_content = false, diggable = true, groups = {oddly_breakable_by_hand=3}, + liquids_pointable = true, light_source = 12, + node_placement_prediction = "", -- important to avoid double placement on_blast = function() end, -- TNT resistant on_place = function(itemstack, placer, pointed_thing) local name = placer:get_player_name() local meta = minetest.deserialize(itemstack:get_metadata()) or {} + local pos = aviator_get_air_pos(pointed_thing.under) + + if not pos then return itemstack end if not aviation[name] then - - local timer = minetest.get_node_timer(pointed_thing.above) - minetest.set_node(pointed_thing.above, {name="aviator:aviator"}) + local nname = itemstack:get_name() + local timer = minetest.get_node_timer(pos) + minetest.set_node(pos, {name=nname}) itemstack:take_item() - aviation[name]=pointed_thing.above + aviation[name]=pos if force then - if core.forceload_block(pointed_thing.above,trans) == false then + if core.forceload_block(pos,trans) == false then -- minetest.chat_send_all("Forceload Error") end end diff --git a/mod.conf b/mod.conf index 06be831..f9bb8df 100644 --- a/mod.conf +++ b/mod.conf @@ -2,7 +2,7 @@ name = aviator title = Aviator author = Gundul description = Adds a craftable node to minetest. You get fly priv 50 nodes around that node -optional_depends = technic,moreores,basic_machines +optional_depends = technic,moreores,basic_machines,mesecons_mvps license = LGPL forum = https://forum.minetest.net/viewtopic.php?f=11&t=16661 -version = 1.4 +version = 1.5 diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..5785ee3 --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,10 @@ +# all settings for client menu or in minetest.conf on servers + +# - +# maximum time an aviator can be used +aviator_flight_length (max flight length in minutes) int 30 + +# maximum radius in which an aviator works +aviator_flight_radius (max radius an aviator grants fly) int 50 + +