From 6dd09016019ddce871e57ad11d28cc8bfac5a45d Mon Sep 17 00:00:00 2001 From: Alexsandro Percy Date: Sat, 22 May 2021 14:22:24 -0300 Subject: [PATCH] creating the base for tug tool --- airutils_papi.lua | 138 ++++++++++++++++++++++++++++++++++++++ airutils_tug.lua | 45 +++++++++++++ init.lua | 136 +------------------------------------ textures/airutils_tug.png | Bin 0 -> 6026 bytes 4 files changed, 185 insertions(+), 134 deletions(-) create mode 100644 airutils_papi.lua create mode 100644 airutils_tug.lua create mode 100644 textures/airutils_tug.png diff --git a/airutils_papi.lua b/airutils_papi.lua new file mode 100644 index 0000000..214b6ae --- /dev/null +++ b/airutils_papi.lua @@ -0,0 +1,138 @@ + + +function airutils.PAPIplace(player,pos) + local dir = minetest.dir_to_facedir(player:get_look_dir()) + local pos1 = vector.new(pos) + core.set_node(pos, {name="airutils:papi", param2=dir}) + local player_name = player:get_player_name() + local meta = core.get_meta(pos) + meta:set_string("infotext", "PAPI\rOwned by: "..player_name) + meta:set_string("owner", player_name) + meta:set_string("dont_destroy", "false") + return true +end + +function airutils.togglePapiSide(pos, node, clicker, itemstack) + local player_name = clicker:get_player_name() + local meta = core.get_meta(pos) + + if player_name ~= meta:get_string("owner") then + return + end + + local dir=node.param2 + if node.name == "airutils:papi_right" then + core.set_node(pos, {name="airutils:papi", param2=dir}) + meta:set_string("infotext", "PAPI - left side\rOwned by: "..player_name) + elseif node.name == "airutils:papi" then + core.set_node(pos, {name="airutils:papi_right", param2=dir}) + meta:set_string("infotext", "PAPI - right side\rOwned by: "..player_name) + end + + meta:set_string("owner", player_name) + meta:set_string("dont_destroy", "false") +end + +airutils.papi_collision_box = { + type = "fixed", + fixed={{-0.5,-0.5,-0.5,0.5,-0.42,0.5},}, +} + +airutils.papi_selection_box = { + type = "fixed", + fixed={{-0.5,-0.5,-0.5,0.5,1.5,0.5},}, +} + +airutils.groups_right = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1} +airutils.groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2} + +-- PAPI node (default left) +minetest.register_node("airutils:papi",{ + description = "PAPI", + inventory_image = "papi.png", + wield_image = "papi.png", + tiles = {"airutils_black.png", "airutils_u_black.png", "airutils_white.png", + "airutils_metal.png", {name = "airutils_red.png", backface_culling = true},}, + groups = airutils.groups, + paramtype2 = "facedir", + paramtype = "light", + drawtype = "mesh", + mesh = "papi.b3d", + visual_scale = 1.0, + light_source = 13, + backface_culling = true, + selection_box = airutils.papi_selection_box, + collision_box = airutils.papi_collision_box, + can_dig = airutils.canDig, + _color = "", + on_destruct = airutils.remove, + on_place = function(itemstack, placer, pointed_thing) + local pos = pointed_thing.above + if airutils.PAPIplace(placer,pos)==true then + itemstack:take_item(1) + return itemstack + else + return + end + end, + on_rightclick=airutils.togglePapiSide, + on_punch = function(pos, node, puncher, pointed_thing) + local player_name = puncher:get_player_name() + local meta = core.get_meta(pos) + if player_name ~= meta:get_string("owner") then + local privs = minetest.get_player_privs(player_name) + if privs.server == false then + return + end + end + + local itmstck=puncher:get_wielded_item() + local item_name = "" + if itmstck then item_name = itmstck:get_name() end + + end, +}) + +-- PAPI right node +minetest.register_node("airutils:papi_right",{ + description = "PAPI_right_side", + tiles = {"airutils_black.png", "airutils_u_black.png", "airutils_white.png", + "airutils_metal.png", {name = "airutils_red.png", backface_culling = true},}, + groups = airutils.groups_right, + paramtype2 = "facedir", + paramtype = "light", + drawtype = "mesh", + mesh = "papi_right.b3d", + visual_scale = 1.0, + light_source = 13, + backface_culling = true, + selection_box = airutils.papi_selection_box, + collision_box = airutils.papi_collision_box, + can_dig = airutils.canDig, + _color = "", + on_destruct = airutils.remove, + on_rightclick=airutils.togglePapiSide, + on_punch = function(pos, node, puncher, pointed_thing) + local player_name = puncher:get_player_name() + local meta = core.get_meta(pos) + if player_name ~= meta:get_string("owner") then + return + end + + local itmstck=puncher:get_wielded_item() + local item_name = "" + if itmstck then item_name = itmstck:get_name() end + + end, +}) + + +-- PAPI craft +minetest.register_craft({ + output = 'airutils:papi', + recipe = { + {'default:glass', 'default:mese_crystal', 'default:glass'}, + {'default:glass', 'default:steel_ingot' , 'default:glass'}, + {'' , 'default:steel_ingot' , ''}, + } +}) diff --git a/airutils_tug.lua b/airutils_tug.lua new file mode 100644 index 0000000..fc2a241 --- /dev/null +++ b/airutils_tug.lua @@ -0,0 +1,45 @@ +local function try_raycast(pos, look_dir) + local raycast = minetest.raycast(pos, look_dir, true, false) + local pointed = raycast:next() + while pointed do + if pointed and pointed.type == "object" and pointed.ref and not pointed.ref:is_player() then + return pointed.ref + end + pointed = raycast:next() + end +end + +minetest.register_tool("airutils:tug", { + description = "Tug tool for airport", + inventory_image = "airutils_tug.png", + stack_max=1, + on_use = function(itemstack, player, pointed_thing) + if not player then + return + end + + --[[local pos = player:get_pos() + local pname = player:get_player_name() + + local look_dir = player:get_look_dir() + local object = try_raycast(pos, look_dir) + if object then + if object:get_attach() then + local dir = player:get_look_dir() + minetest.chat_send_all('detach') + object:set_detach() + object:set_rotation(dir) + else + minetest.chat_send_all('object found') + object:set_attach(player, "", {x=0, y=0, z=20}) + end + end]]-- + end, + + --[[on_secondary_use = function(itemstack, user, pointed_thing) + local object = user:get_attach() + if object then user:set_detach() end + end,]]-- + + sound = {breaks = "default_tool_breaks"}, +}) diff --git a/init.lua b/init.lua index 69e86b9..d82bc2d 100644 --- a/init.lua +++ b/init.lua @@ -2,17 +2,8 @@ airutils = {} -function airutils.PAPIplace(player,pos) - local dir = minetest.dir_to_facedir(player:get_look_dir()) - local pos1 = vector.new(pos) - core.set_node(pos, {name="airutils:papi", param2=dir}) - local player_name = player:get_player_name() - local meta = core.get_meta(pos) - meta:set_string("infotext", "PAPI\rOwned by: "..player_name) - meta:set_string("owner", player_name) - meta:set_string("dont_destroy", "false") - return true -end +dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "airutils_papi.lua") +dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "airutils_tug.lua") function airutils.remove(pos) local meta = core.get_meta(pos) @@ -28,128 +19,5 @@ function airutils.canDig(pos, player) and player:get_player_name() == meta:get_string("owner") end -function airutils.togglePapiSide(pos, node, clicker, itemstack) - local player_name = clicker:get_player_name() - local meta = core.get_meta(pos) - - if player_name ~= meta:get_string("owner") then - return - end - - local dir=node.param2 - if node.name == "airutils:papi_right" then - core.set_node(pos, {name="airutils:papi", param2=dir}) - meta:set_string("infotext", "PAPI - left side\rOwned by: "..player_name) - elseif node.name == "airutils:papi" then - core.set_node(pos, {name="airutils:papi_right", param2=dir}) - meta:set_string("infotext", "PAPI - right side\rOwned by: "..player_name) - end - - meta:set_string("owner", player_name) - meta:set_string("dont_destroy", "false") -end - -airutils.collision_box = { - type = "fixed", - fixed={{-0.5,-0.5,-0.5,0.5,-0.42,0.5},}, -} - -airutils.selection_box = { - type = "fixed", - fixed={{-0.5,-0.5,-0.5,0.5,1.5,0.5},}, -} - -airutils.groups_right = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1} -airutils.groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2} - --- PAPI node (default left) -minetest.register_node("airutils:papi",{ - description = "PAPI", - inventory_image = "papi.png", - wield_image = "papi.png", - tiles = {"airutils_black.png", "airutils_u_black.png", "airutils_white.png", - "airutils_metal.png", {name = "airutils_red.png", backface_culling = true},}, - groups = airutils.groups, - paramtype2 = "facedir", - paramtype = "light", - drawtype = "mesh", - mesh = "papi.b3d", - visual_scale = 1.0, - light_source = 13, - backface_culling = true, - selection_box = airutils.selection_box, - collision_box = airutils.collision_box, - can_dig = airutils.canDig, - _color = "", - on_destruct = airutils.remove, - on_place = function(itemstack, placer, pointed_thing) - local pos = pointed_thing.above - if airutils.PAPIplace(placer,pos)==true then - itemstack:take_item(1) - return itemstack - else - return - end - end, - on_rightclick=airutils.togglePapiSide, - on_punch = function(pos, node, puncher, pointed_thing) - local player_name = puncher:get_player_name() - local meta = core.get_meta(pos) - if player_name ~= meta:get_string("owner") then - local privs = minetest.get_player_privs(player_name) - if privs.server == false then - return - end - end - - local itmstck=puncher:get_wielded_item() - local item_name = "" - if itmstck then item_name = itmstck:get_name() end - - end, -}) - --- PAPI right node -minetest.register_node("airutils:papi_right",{ - description = "PAPI_right_side", - tiles = {"airutils_black.png", "airutils_u_black.png", "airutils_white.png", - "airutils_metal.png", {name = "airutils_red.png", backface_culling = true},}, - groups = airutils.groups_right, - paramtype2 = "facedir", - paramtype = "light", - drawtype = "mesh", - mesh = "papi_right.b3d", - visual_scale = 1.0, - light_source = 13, - backface_culling = true, - selection_box = airutils.selection_box, - collision_box = airutils.collision_box, - can_dig = airutils.canDig, - _color = "", - on_destruct = airutils.remove, - on_rightclick=airutils.togglePapiSide, - on_punch = function(pos, node, puncher, pointed_thing) - local player_name = puncher:get_player_name() - local meta = core.get_meta(pos) - if player_name ~= meta:get_string("owner") then - return - end - - local itmstck=puncher:get_wielded_item() - local item_name = "" - if itmstck then item_name = itmstck:get_name() end - - end, -}) --- PAPI craft -minetest.register_craft({ - output = 'airutils:papi', - recipe = { - {'default:glass', 'default:mese_crystal', 'default:glass'}, - {'default:glass', 'default:steel_ingot' , 'default:glass'}, - {'' , 'default:steel_ingot' , ''}, - } -}) - diff --git a/textures/airutils_tug.png b/textures/airutils_tug.png new file mode 100644 index 0000000000000000000000000000000000000000..d77b0cc51045736288605569e07c8f31ff4dbb61 GIT binary patch literal 6026 zcmeHKX;>3k7L6c_tU**j1Y^L3B_x%EY!J2tAxZ=R5s}48RVAd!MiL;Rpe!N?Dk9oq z)7ZGuh&nE z*qk79lZhr6491)n%ne8XaoWw;5Z$ZN)1P55h6d@8(duw84X04bg<=VUQ!iE^I7A~B zVlbMHN6~R5f6g#l+B7A_KzUy&DZxg{^4Iilg+w{Dv~ z+}gcn!0cY;iNq}lrJ9Zw%e+fjXS~V8Q{t-fycrK|-ciHoHBKAchp-);_l_3deXB~H za-)^#w6ppEQR^FBl@uKKvj2MvU%d@m2;zFd+OrDtcpd+tjE79*Vc4C zeq;08a(h_EbBpm?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