From 2276f1547935b91f820997e17ca82e951dbe18c2 Mon Sep 17 00:00:00 2001 From: wuniversales <48658161+wuniversales@users.noreply.github.com> Date: Sat, 21 Mar 2020 00:46:20 +0100 Subject: [PATCH 01/10] Add files via upload --- depends.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 depends.txt diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..7595d17 --- /dev/null +++ b/depends.txt @@ -0,0 +1,4 @@ +default? +mcl_core? +loot? +doc? From 37fb5a09304ca0361e37a4a0760cc7a50049d158 Mon Sep 17 00:00:00 2001 From: wuniversales <48658161+wuniversales@users.noreply.github.com> Date: Sat, 21 Mar 2020 00:47:15 +0100 Subject: [PATCH 02/10] Update init.lua --- init.lua | 557 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 556 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 7ffd179..2d5db64 100644 --- a/init.lua +++ b/init.lua @@ -47,6 +47,89 @@ hook.slingshot_onuse=function(itemstack, user) return itemstack end +minetest.register_tool("hook:slingshot", { + description = "Slingshot", + range = 4, + inventory_image = "hook_slingshot.png", + on_use=function(itemstack, user, pointed_thing) + local ref = pointed_thing.ref + if ref and not (ref:get_luaentity() and ref:get_luaentity().name == "__builtin:item") then + hook.punch(user,ref,4) + return itemstack + end + hook.slingshot_onuse(itemstack, user) + return itemstack + end, + on_place=function(itemstack, user, pointed_thing) + local item=itemstack:to_table() + local meta=minetest.deserialize(item["metadata"]) + local mode=0 + if meta==nil then meta={} mode=1 end + if meta.mode==nil then meta.mode=1 end + mode=(meta.mode) + if mode==1 then + mode=-1 + minetest.chat_send_player(user:get_player_name(), "Use stack to left") + else + mode=1 + minetest.chat_send_player(user:get_player_name(), "Use stack to right ") + end + meta.mode=mode + item.metadata=minetest.serialize(meta) + item.meta=minetest.serialize(meta) + itemstack:replace(item) + return itemstack + end +}) +hook={ + tmp_throw={}, + tmp_throw_timer=0, + tmp_time= tonumber(minetest.settings:get("item_entity_ttl")), + pvp = minetest.settings:get_bool("enable_pvp") == true, +} + +dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/project.lua") +dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/pchest.lua") + +if hook.tmp_time=="" or hook.tmp_time==nil then + hook.tmp_time=890 +else + hook.tmp_time=hook.tmp_time-10 +end + +hook.punch=function(ob1,ob2,hp) + ob2:punch(ob1,1,{full_punch_interval=1,damage_groups={fleshy=hp}}) +end + +hook.slingshot_def=function(pos,n) + local nn=minetest.get_node(pos).name + return (minetest.registered_nodes[nn] and minetest.registered_nodes[nn][n]) +end + +hook.slingshot_onuse=function(itemstack, user) + local veloc=15 + local pos = user:get_pos() + local upos={x=pos.x,y=pos.y+2,z=pos.z} + local dir = user:get_look_dir() + local item=itemstack:to_table() + local mode=minetest.deserialize(item["metadata"]) + if mode==nil then mode=1 else mode=mode.mode end + + local item=user:get_inventory():get_stack("main", user:get_wield_index()+mode):get_name() + if item=="" then return itemstack end + local e=minetest.add_item({x=pos.x,y=pos.y+2,z=pos.z},item) + e:set_velocity({x=dir.x*veloc, y=dir.y*veloc, z=dir.z*veloc}) + e:set_acceleration({x=dir.x*-3, y=-5, z=dir.z*-3}) + e:get_luaentity().age=hook.tmp_time + table.insert(hook.tmp_throw,{ob=e,timer=2,user=user:get_player_name()}) + if item=="hook:slingshot" then + itemstack:set_wear(9999999) + end + user:get_inventory():remove_item("main", item) + minetest.sound_play("hook_throw", {pos=pos, gain = 1.0, max_hear_distance = 5}) + return itemstack +end + minetest.register_tool("hook:slingshot", { description = "Slingshot", range = 4, @@ -450,6 +533,478 @@ minetest.register_tool("hook:mba", { end }) + + + +if minetest.get_modpath("mcl_core") then + minetest.register_craft({ + output = "hook:mba", + recipe = { + {"", "mcl_core:iron_ingot",""}, + {"mcl_core:iron_ingot", "mcl_core:iron_ingot","mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot", "mcl_core:iron_ingot","mcl_core:iron_ingot"} + }, + }) + + minetest.register_craft({ + output = "hook:hook", + recipe = { + {"", "mcl_core:iron_ingot",""}, + {"", "mcl_core:iron_ingot","mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot", "",""} + }, + }) + minetest.register_craft({ + output = "hook:hook_upgrade", + recipe = { + {"", "hook:hook",""}, + {"", "hook:hook",""}, + {"", "mcl_core:iron_ingot",""} + }, + }) + minetest.register_craft({ + output = "hook:climb_rope", + recipe = { + {"","mcl_core:iron_ingot",""}, + {"","mcl_core:iron",""}, + {"","mcl_core:iron_ingot",""} + }, + }) + minetest.register_craft({ + output = "hook:climb_rope_locked", + recipe = { + {"hook:climb_rope","mcl_core:iron_ingot",""} + }, + }) + minetest.register_craft({ + output = "hook:slingshot", + recipe = { + {"mcl_core:iron_ingot","","mcl_core:iron_ingot"}, + {"","mcl_core:iron",""}, + {"","mcl_core:iron_ingot",""} + }, + }) +else + minetest.register_craft({ + output = "hook:mba", + recipe = { + {"","default:steel_ingot",""}, + {"default:steel_ingot","default:steel_ingot","default:steel_ingot"}, + {"default:steel_ingot","","default:steel_ingot"}, + } + }) + + minetest.register_craft({ + output = "hook:hook", + recipe = { + {"","default:steel_ingot",""}, + {"","default:steel_ingot","default:steel_ingot"}, + {"default:steel_ingot","",""}, + } + }) + minetest.register_craft({ + output = "hook:hook_upgrade", + recipe = { + {"","hook:hook",""}, + {"","hook:hook",""}, + {"","default:steel_ingot",""}, + } + }) + + minetest.register_craft({ + output = "hook:climb_rope", + recipe = { + {"","default:steel_ingot",""}, + {"","default:steelblock",""}, + {"","default:steel_ingot",""}, + } + }) + minetest.register_craft({ + output = "hook:climb_rope_locked", + recipe = { + {"hook:climb_rope","default:steel_ingot",""}, + } + }) + + minetest.register_craft({ + output = "hook:slingshot", + recipe = { + {"default:steel_ingot","","default:steel_ingot"}, + {"","default:steelblock",""}, + {"","default:steel_ingot",""}, + } + }) +end + + +minetest.register_globalstep(function(dtime) + hook.tmp_throw_timer=hook.tmp_throw_timer+dtime + if hook.tmp_throw_timer<0.1 then return end + hook.tmp_throw_timer=0 + for i, t in pairs(hook.tmp_throw) do + t.timer=t.timer-0.25 + if t.timer<=0 or t.ob==nil or t.ob:get_pos()==nil then table.remove(hook.tmp_throw,i) return end + for ii, ob in pairs(minetest.get_objects_inside_radius(t.ob:get_pos(), 1.5)) do + if (not ob:get_luaentity()) or (ob:get_luaentity() and (ob:get_luaentity().name~="__builtin:item")) then + if (not ob:is_player()) or (ob:is_player() and ob:get_player_name(ob)~=t.user and hook.pvp) then + ob:set_hp(ob:get_hp()-5) + hook.punch(ob,ob,4) + t.ob:set_velocity({x=0, y=0, z=0}) + if ob:get_hp()<=0 and ob:is_player()==false then ob:remove() end + t.ob:set_acceleration({x=0, y=-10,z=0}) + t.ob:set_velocity({x=0, y=-10, z=0}) + table.remove(hook.tmp_throw,i) + break + end + end + end + end +end) + +hook.is_hook=function(pos,name) + if not (name and minetest.is_protected(pos,name)) then + local def = minetest.registered_nodes[minetest.get_node(pos).name] + if def and def.name == "hook:hooking" or (def.buildable_to and not (def.liquidtype == "source" and def.paramtype2 == "none")) then + if not (def.name == "hook:hooking" and minetest.get_meta(pos):get_int("a") ~= 0) then + return true + end + end + end + return false +end + +minetest.register_tool("hook:hook", { + description = "Hook with rope (hit a corner to climb)", + inventory_image = "hook_hook.png", + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type~="node" then return itemstack end + local d=minetest.dir_to_facedir(user:get_look_dir()) + local pos=pointed_thing.above + local pos2=pointed_thing.under + local name=user:get_player_name() + + if hook.slingshot_def(pos2,"walkable") and + hook.slingshot_def({x=pos.x,y=pos.y-1,z=pos.z},"walkable")==false + and (hook.slingshot_def({x=pos2.x,y=pos2.y+1,z=pos2.z},"walkable")==false or minetest.get_node({x=pos2.x,y=pos2.y+1,z=pos2.z}).name=="default:snow") and + hook.is_hook(pos,name) and + hook.slingshot_def({x=pos.x,y=pos.y+1,z=pos.z},"walkable")==false then + if d==3 then d=1 + elseif d==1 then d=3 + elseif d==2 then d=0 + elseif d==0 then d=2 + end + if hook.is_hook({x=pos.x,y=pos.y+1,z=pos.z},name) then + minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name = "hook:hooking",param2=d}) + minetest.get_node_timer({x=pos.x,y=pos.y+1,z=pos.z}):start(3) + else + return itemstack + end + for i=0,-4, -1 do + if hook.is_hook({x=pos.x,y=pos.y+i,z=pos.z},name) then + minetest.set_node({x=pos.x,y=pos.y+i,z=pos.z}, {name = "hook:rope",param2=d}) + else + return itemstack + end + end + end + return itemstack + end +}) + +minetest.register_tool("hook:hook_upgrade", { + description = "Hook with rope (double)", + range = 6, + inventory_image = "hook_hookup.png", + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type~="node" then return itemstack end + local d=minetest.dir_to_facedir(user:get_look_dir()) + local pos=pointed_thing.above + local pos2=pointed_thing.under + local name=user:get_player_name() + if hook.slingshot_def(pos2,"walkable") and + hook.slingshot_def({x=pos.x,y=pos.y-1,z=pos.z},"walkable")==false and + (hook.slingshot_def({x=pos2.x,y=pos2.y+1,z=pos2.z},"walkable")==false or minetest.get_node({x=pos2.x,y=pos2.y+1,z=pos2.z}).name=="default:snow") and + hook.is_hook(pos,name) and + hook.slingshot_def({x=pos.x,y=pos.y+1,z=pos.z},"walkable")==false then + if d==3 then d=1 + elseif d==1 then d=3 + elseif d==2 then d=0 + elseif d==0 then d=2 + end + if hook.is_hook({x=pos.x,y=pos.y+1,z=pos.z},name) then + minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name = "hook:hooking",param2=d}) + minetest.get_node_timer({x=pos.x,y=pos.y+1,z=pos.z}):start(3) + else + return itemstack + end + for i=0,-8, -1 do + if hook.is_hook({x=pos.x,y=pos.y+i,z=pos.z},name) then + minetest.set_node({x=pos.x,y=pos.y+i,z=pos.z}, {name = "hook:rope",param2=d}) + else + return itemstack + end + end + end + return itemstack + end +}) + +minetest.register_tool("hook:climb_rope", { + description = "Climb rope", + range = 2, + inventory_image = "hook_rope2.png", + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type~="node" then + hook.user=user + hook.locked=false + local pos=user:get_pos() + local d=user:get_look_dir() + local m=minetest.add_entity({x=pos.x,y=pos.y+1.5,z=pos.z}, "hook:power") + m:set_velocity({x=d.x*15, y=d.y*15, z=d.z*15}) + m:set_acceleration({x=0, y=-5, z=0}) + minetest.sound_play("hook_throw", {pos=pos, gain = 1.0, max_hear_distance = 5,}) + return itemstack + else + local pos=pointed_thing.under + local d=minetest.dir_to_facedir(user:get_look_dir()) + local z=0 + local x=0 + local name=user:get_player_name() + if hook.slingshot_def(pos,"walkable") then + if d==0 then z=1 end + if d==2 then z=-1 end + if d==1 then x=1 end + if d==3 then x=-1 end + if hook.is_hook({x=pos.x+x,y=pos.y,z=pos.z+z},name) and hook.is_hook({x=pos.x+x,y=pos.y+1,z=pos.z+z},name) then + minetest.set_node({x=pos.x+x,y=pos.y+1,z=pos.z+z},{name = "hook:hooking",param2=d}) + minetest.get_meta({x=pos.x+x,y=pos.y+1,z=pos.z+z}):set_int("a",1) + else + return itemstack + end + itemstack:take_item() + for i=0,20,1 do + if hook.is_hook({x=pos.x+x,y=pos.y-i,z=pos.z+z},name) then minetest.set_node({x=pos.x+x,y=pos.y-i,z=pos.z+z},{name = "hook:rope2",param2=d}) else return itemstack end + end + end + return itemstack + end + end +}) + + +minetest.register_tool("hook:climb_rope_locked", { + description = "Climb rope (Locked)", + range = 2, + inventory_image = "hook_rope_locked.png", + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type~="node" then + hook.user=user + hook.locked=true + local pos=user:get_pos() + local d=user:get_look_dir() + local m=minetest.add_entity({x=pos.x,y=pos.y+1.5,z=pos.z}, "hook:power") + m:set_velocity({x=d.x*15, y=d.y*15, z=d.z*15}) + m:set_acceleration({x=0, y=-5, z=0}) + minetest.sound_play("hook_throw", {pos=pos, gain = 1.0, max_hear_distance = 5,}) + return itemstack + else + local pos=pointed_thing.under + local d=minetest.dir_to_facedir(user:get_look_dir()) + local z=0 + local x=0 + local name=user:get_player_name() + if hook.slingshot_def(pos,"walkable") then + if d==0 then z=1 end + if d==2 then z=-1 end + if d==1 then x=1 end + if d==3 then x=-1 end + if hook.is_hook({x=pos.x+x,y=pos.y,z=pos.z+z},name) and hook.is_hook({x=pos.x+x,y=pos.y+1,z=pos.z+z},name) then + minetest.set_node({x=pos.x+x,y=pos.y+1,z=pos.z+z},{name = "hook:hooking",param2=d}) + minetest.get_meta({x=pos.x+x,y=pos.y+1,z=pos.z+z}):set_int("a",1) + else + return itemstack + end + itemstack:take_item() + for i=0,20,1 do + if hook.is_hook({x=pos.x+x,y=pos.y-i,z=pos.z+z},name) then + minetest.set_node({x=pos.x+x,y=pos.y-i,z=pos.z+z},{name = "hook:rope3",param2=d}) + minetest.get_meta({x=pos.x+x,y=pos.y-i,z=pos.z+z}):set_string("owner",user:get_player_name()) + else + return itemstack + end + end + end + return itemstack + end + end +}) + + +minetest.register_node("hook:rope", { + description = "Rope (tempoary)", + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.0625, -0.5, -0.5, 0.0625, 0.5, -0.375} + } + }, + tiles = {"hook_rope.png"}, + paramtype = "light", + paramtype2 = "facedir", + buildable_to = true, + drop = "", + liquid_viscosity = 1, + liquidtype = "source", + liquid_alternative_flowing="hook:rope", + liquid_alternative_source="hook:rope", + liquid_renewable = false, + liquid_range = 0, + sunlight_propagates = false, + walkable = false, + is_ground_content = false, + groups = {not_in_creative_inventory=1,fleshy = 3, dig_immediate = 3,}, + on_construct = function(pos) + minetest.get_node_timer(pos):start(3) + end, + on_timer = function (pos, elapsed) + for i, ob in pairs(minetest.get_objects_inside_radius(pos, 3)) do + if ob:is_player() then return true end + end + minetest.set_node(pos, {name = "air"}) + return false + end, + sounds = {footstep = {name = "hook_rope", gain = 1}} +}) + +minetest.register_node("hook:rope2", { + description = "Rope", + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.0625, -0.5, -0.5, 0.0625, 0.5, -0.375} + } + }, + tiles = {"hook_rope.png"}, + paramtype = "light", + paramtype2 = "facedir", + drop = "", + liquid_viscosity = 1, + liquidtype = "source", + liquid_alternative_flowing="hook:rope2", + liquid_alternative_source="hook:rope2", + liquid_renewable = false, + liquid_range = 0, + sunlight_propagates = false, + walkable = false, + is_ground_content = false, + groups = {not_in_creative_inventory=1,fleshy = 3, dig_immediate = 3,}, + on_punch = function(pos, node, puncher, pointed_thing) + if minetest.is_protected(pos,puncher:get_player_name()) then + return false + end + puncher:get_inventory():add_item("main", ItemStack("hook:climb_rope")) + local name=puncher:get_player_name() + for i=0,20,1 do + if minetest.get_node({x=pos.x,y=pos.y-i,z=pos.z}).name=="hook:rope2" or minetest.get_node({x=pos.x,y=pos.y-i,z=pos.z}).name=="air" then minetest.set_node({x=pos.x,y=pos.y-i,z=pos.z},{name = "air"}) else break end + end + for i=0,20,1 do + if minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="hook:rope2" or minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="hook:hooking" or minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="air" then minetest.set_node({x=pos.x,y=pos.y+i,z=pos.z},{name = "air"}) else return false end + end + end, + sounds = {footstep = {name = "hook_rope", gain = 1}} +}) + +minetest.register_node("hook:rope3", { + description = "Rope (locked)", + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.0625, -0.5, -0.5, 0.0625, 0.5, -0.375} + } + }, + tiles = {"hook_rope.png"}, + paramtype = "light", + paramtype2 = "facedir", + drop = "", + liquid_viscosity = 1, + liquidtype = "source", + liquid_alternative_flowing="hook:rope3", + liquid_alternative_source="hook:rope3", + liquid_renewable = false, + liquid_range = 0, + sunlight_propagates = false, + walkable = false, + is_ground_content = false, + can_dig = function(pos, player) + if minetest.get_meta(pos):get_string("owner")~=player:get_player_name() then + minetest.chat_send_player(player:get_player_name(), "This rope is owned by: ".. minetest.get_meta(pos):get_string("owner")) + return false + end + return true + end, + groups = {not_in_creative_inventory=1,fleshy = 3, dig_immediate = 3,}, + on_punch = function(pos, node, puncher, pointed_thing) + if minetest.get_meta(pos):get_string("owner")~=puncher:get_player_name() then + minetest.chat_send_player(puncher:get_player_name(), "This rope is owned by: ".. minetest.get_meta(pos):get_string("owner")) + return false + end + puncher:get_inventory():add_item("main", ItemStack("hook:climb_rope_locked")) + for i=0,20,1 do + if minetest.get_node({x=pos.x,y=pos.y-i,z=pos.z}).name=="hook:rope3" or minetest.get_node({x=pos.x,y=pos.y-i,z=pos.z}).name=="air" then minetest.set_node({x=pos.x,y=pos.y-i,z=pos.z},{name = "air"}) else break end + end + for i=0,20,1 do + if minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="hook:rope3" or minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="hook:hooking" or minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="air" then minetest.set_node({x=pos.x,y=pos.y+i,z=pos.z},{name = "air"}) else return false end + end + end, + sounds = {footstep = {name = "hook_rope", gain = 1}} +}) + +minetest.register_node("hook:hooking", { + description = "Hooking", + drawtype = "mesh", + mesh="hook_hook.obj", + tiles = {"hook_iron.png"}, + paramtype = "light", + paramtype2 = "facedir", + walkable=false, + pointable=false, + drop = "", + sunlight_propagates = false, + groups = {not_in_creative_inventory=1}, + on_timer = function (pos, elapsed) + local r=minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name + if r~="hook:rope" then + minetest.remove_node(pos) + return false + end + return true + end +}) + + +minetest.register_tool("hook:mba", { + description = "Mouth breather assembly", + range = 1, + inventory_image = "hook_mba.png", + on_use=function(itemstack, user, pointed_thing) + local pos=user:get_pos() + pos.y=pos.y+1.5 + if hook.slingshot_def(pos,"drowning")==0 then + itemstack:set_wear(1) + else + local use=itemstack:get_wear()+(65536/10) + if use<65536 then + itemstack:set_wear(use) + user:set_breath(11) + end + end + return itemstack + end +}) + minetest.register_craft({ output = "hook:mba", recipe = { @@ -498,4 +1053,4 @@ minetest.register_craft({ {"","default:steelblock",""}, {"","default:steel_ingot",""}, } -}) \ No newline at end of file +}) From 46190a6f110209e2efe66a5457af1303bc359c3a Mon Sep 17 00:00:00 2001 From: wuniversales <48658161+wuniversales@users.noreply.github.com> Date: Sat, 21 Mar 2020 01:02:04 +0100 Subject: [PATCH 03/10] Update init.lua --- init.lua | 555 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 555 insertions(+) diff --git a/init.lua b/init.lua index 2d5db64..0cfe594 100644 --- a/init.lua +++ b/init.lua @@ -985,6 +985,450 @@ minetest.register_node("hook:hooking", { }) +minetest.register_tool("hook:mba", { + description = "Mouth breather assembly", + range = 1, + inventory_image = "hook_mba.png", + on_use=function(itemstack, user, pointed_thing) + local pos=user:get_pos() + pos.y=pos.y+1.5 + if hook.slingshot_def(pos,"drowning")==0 then + itemstack:set_wear(1) + else + local use=itemstack:get_wear()+(65536/10) + if use<65536 then + itemstack:set_wear(use)hook={ + tmp_throw={}, + tmp_throw_timer=0, + tmp_time= tonumber(minetest.settings:get("item_entity_ttl")), + pvp = minetest.settings:get_bool("enable_pvp") == true, +} + +dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/project.lua") +dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/pchest.lua") + +if hook.tmp_time=="" or hook.tmp_time==nil then + hook.tmp_time=890 +else + hook.tmp_time=hook.tmp_time-10 +end + +hook.punch=function(ob1,ob2,hp) + ob2:punch(ob1,1,{full_punch_interval=1,damage_groups={fleshy=hp}}) +end + +hook.slingshot_def=function(pos,n) + local nn=minetest.get_node(pos).name + return (minetest.registered_nodes[nn] and minetest.registered_nodes[nn][n]) +end + +hook.slingshot_onuse=function(itemstack, user) + local veloc=15 + local pos = user:get_pos() + local upos={x=pos.x,y=pos.y+2,z=pos.z} + local dir = user:get_look_dir() + local item=itemstack:to_table() + local mode=minetest.deserialize(item["metadata"]) + if mode==nil then mode=1 else mode=mode.mode end + + local item=user:get_inventory():get_stack("main", user:get_wield_index()+mode):get_name() + if item=="" then return itemstack end + local e=minetest.add_item({x=pos.x,y=pos.y+2,z=pos.z},item) + e:set_velocity({x=dir.x*veloc, y=dir.y*veloc, z=dir.z*veloc}) + e:set_acceleration({x=dir.x*-3, y=-5, z=dir.z*-3}) + e:get_luaentity().age=hook.tmp_time + table.insert(hook.tmp_throw,{ob=e,timer=2,user=user:get_player_name()}) + if item=="hook:slingshot" then + itemstack:set_wear(9999999) + end + user:get_inventory():remove_item("main", item) + minetest.sound_play("hook_throw", {pos=pos, gain = 1.0, max_hear_distance = 5}) + return itemstack +end + +minetest.register_tool("hook:slingshot", { + description = "Slingshot", + range = 4, + inventory_image = "hook_slingshot.png", + on_use=function(itemstack, user, pointed_thing) + local ref = pointed_thing.ref + if ref and not (ref:get_luaentity() and ref:get_luaentity().name == "__builtin:item") then + hook.punch(user,ref,4) + return itemstack + end + hook.slingshot_onuse(itemstack, user) + return itemstack + end, + on_place=function(itemstack, user, pointed_thing) + local item=itemstack:to_table() + local meta=minetest.deserialize(item["metadata"]) + local mode=0 + if meta==nil then meta={} mode=1 end + if meta.mode==nil then meta.mode=1 end + mode=(meta.mode) + if mode==1 then + mode=-1 + minetest.chat_send_player(user:get_player_name(), "Use stack to left") + else + mode=1 + minetest.chat_send_player(user:get_player_name(), "Use stack to right ") + end + meta.mode=mode + item.metadata=minetest.serialize(meta) + item.meta=minetest.serialize(meta) + itemstack:replace(item) + return itemstack + end +}) + +minetest.register_globalstep(function(dtime) + hook.tmp_throw_timer=hook.tmp_throw_timer+dtime + if hook.tmp_throw_timer<0.1 then return end + hook.tmp_throw_timer=0 + for i, t in pairs(hook.tmp_throw) do + t.timer=t.timer-0.25 + if t.timer<=0 or t.ob==nil or t.ob:get_pos()==nil then table.remove(hook.tmp_throw,i) return end + for ii, ob in pairs(minetest.get_objects_inside_radius(t.ob:get_pos(), 1.5)) do + if (not ob:get_luaentity()) or (ob:get_luaentity() and (ob:get_luaentity().name~="__builtin:item")) then + if (not ob:is_player()) or (ob:is_player() and ob:get_player_name(ob)~=t.user and hook.pvp) then + ob:set_hp(ob:get_hp()-5) + hook.punch(ob,ob,4) + t.ob:set_velocity({x=0, y=0, z=0}) + if ob:get_hp()<=0 and ob:is_player()==false then ob:remove() end + t.ob:set_acceleration({x=0, y=-10,z=0}) + t.ob:set_velocity({x=0, y=-10, z=0}) + table.remove(hook.tmp_throw,i) + break + end + end + end + end +end) + +hook.is_hook=function(pos,name) + if not (name and minetest.is_protected(pos,name)) then + local def = minetest.registered_nodes[minetest.get_node(pos).name] + if def and def.name == "hook:hooking" or (def.buildable_to and not (def.liquidtype == "source" and def.paramtype2 == "none")) then + if not (def.name == "hook:hooking" and minetest.get_meta(pos):get_int("a") ~= 0) then + return true + end + end + end + return false +end + +minetest.register_tool("hook:hook", { + description = "Hook with rope (hit a corner to climb)", + inventory_image = "hook_hook.png", + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type~="node" then return itemstack end + local d=minetest.dir_to_facedir(user:get_look_dir()) + local pos=pointed_thing.above + local pos2=pointed_thing.under + local name=user:get_player_name() + + if hook.slingshot_def(pos2,"walkable") and + hook.slingshot_def({x=pos.x,y=pos.y-1,z=pos.z},"walkable")==false + and (hook.slingshot_def({x=pos2.x,y=pos2.y+1,z=pos2.z},"walkable")==false or minetest.get_node({x=pos2.x,y=pos2.y+1,z=pos2.z}).name=="default:snow") and + hook.is_hook(pos,name) and + hook.slingshot_def({x=pos.x,y=pos.y+1,z=pos.z},"walkable")==false then + if d==3 then d=1 + elseif d==1 then d=3 + elseif d==2 then d=0 + elseif d==0 then d=2 + end + if hook.is_hook({x=pos.x,y=pos.y+1,z=pos.z},name) then + minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name = "hook:hooking",param2=d}) + minetest.get_node_timer({x=pos.x,y=pos.y+1,z=pos.z}):start(3) + else + return itemstack + end + for i=0,-4, -1 do + if hook.is_hook({x=pos.x,y=pos.y+i,z=pos.z},name) then + minetest.set_node({x=pos.x,y=pos.y+i,z=pos.z}, {name = "hook:rope",param2=d}) + else + return itemstack + end + end + end + return itemstack + end +}) + +minetest.register_tool("hook:hook_upgrade", { + description = "Hook with rope (double)", + range = 6, + inventory_image = "hook_hookup.png", + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type~="node" then return itemstack end + local d=minetest.dir_to_facedir(user:get_look_dir()) + local pos=pointed_thing.above + local pos2=pointed_thing.under + local name=user:get_player_name() + if hook.slingshot_def(pos2,"walkable") and + hook.slingshot_def({x=pos.x,y=pos.y-1,z=pos.z},"walkable")==false and + (hook.slingshot_def({x=pos2.x,y=pos2.y+1,z=pos2.z},"walkable")==false or minetest.get_node({x=pos2.x,y=pos2.y+1,z=pos2.z}).name=="default:snow") and + hook.is_hook(pos,name) and + hook.slingshot_def({x=pos.x,y=pos.y+1,z=pos.z},"walkable")==false then + if d==3 then d=1 + elseif d==1 then d=3 + elseif d==2 then d=0 + elseif d==0 then d=2 + end + if hook.is_hook({x=pos.x,y=pos.y+1,z=pos.z},name) then + minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name = "hook:hooking",param2=d}) + minetest.get_node_timer({x=pos.x,y=pos.y+1,z=pos.z}):start(3) + else + return itemstack + end + for i=0,-8, -1 do + if hook.is_hook({x=pos.x,y=pos.y+i,z=pos.z},name) then + minetest.set_node({x=pos.x,y=pos.y+i,z=pos.z}, {name = "hook:rope",param2=d}) + else + return itemstack + end + end + end + return itemstack + end +}) + +minetest.register_tool("hook:climb_rope", { + description = "Climb rope", + range = 2, + inventory_image = "hook_rope2.png", + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type~="node" then + hook.user=user + hook.locked=false + local pos=user:get_pos() + local d=user:get_look_dir() + local m=minetest.add_entity({x=pos.x,y=pos.y+1.5,z=pos.z}, "hook:power") + m:set_velocity({x=d.x*15, y=d.y*15, z=d.z*15}) + m:set_acceleration({x=0, y=-5, z=0}) + minetest.sound_play("hook_throw", {pos=pos, gain = 1.0, max_hear_distance = 5,}) + return itemstack + else + local pos=pointed_thing.under + local d=minetest.dir_to_facedir(user:get_look_dir()) + local z=0 + local x=0 + local name=user:get_player_name() + if hook.slingshot_def(pos,"walkable") then + if d==0 then z=1 end + if d==2 then z=-1 end + if d==1 then x=1 end + if d==3 then x=-1 end + if hook.is_hook({x=pos.x+x,y=pos.y,z=pos.z+z},name) and hook.is_hook({x=pos.x+x,y=pos.y+1,z=pos.z+z},name) then + minetest.set_node({x=pos.x+x,y=pos.y+1,z=pos.z+z},{name = "hook:hooking",param2=d}) + minetest.get_meta({x=pos.x+x,y=pos.y+1,z=pos.z+z}):set_int("a",1) + else + return itemstack + end + itemstack:take_item() + for i=0,20,1 do + if hook.is_hook({x=pos.x+x,y=pos.y-i,z=pos.z+z},name) then minetest.set_node({x=pos.x+x,y=pos.y-i,z=pos.z+z},{name = "hook:rope2",param2=d}) else return itemstack end + end + end + return itemstack + end + end +}) + + +minetest.register_tool("hook:climb_rope_locked", { + description = "Climb rope (Locked)", + range = 2, + inventory_image = "hook_rope_locked.png", + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type~="node" then + hook.user=user + hook.locked=true + local pos=user:get_pos() + local d=user:get_look_dir() + local m=minetest.add_entity({x=pos.x,y=pos.y+1.5,z=pos.z}, "hook:power") + m:set_velocity({x=d.x*15, y=d.y*15, z=d.z*15}) + m:set_acceleration({x=0, y=-5, z=0}) + minetest.sound_play("hook_throw", {pos=pos, gain = 1.0, max_hear_distance = 5,}) + return itemstack + else + local pos=pointed_thing.under + local d=minetest.dir_to_facedir(user:get_look_dir()) + local z=0 + local x=0 + local name=user:get_player_name() + if hook.slingshot_def(pos,"walkable") then + if d==0 then z=1 end + if d==2 then z=-1 end + if d==1 then x=1 end + if d==3 then x=-1 end + if hook.is_hook({x=pos.x+x,y=pos.y,z=pos.z+z},name) and hook.is_hook({x=pos.x+x,y=pos.y+1,z=pos.z+z},name) then + minetest.set_node({x=pos.x+x,y=pos.y+1,z=pos.z+z},{name = "hook:hooking",param2=d}) + minetest.get_meta({x=pos.x+x,y=pos.y+1,z=pos.z+z}):set_int("a",1) + else + return itemstack + end + itemstack:take_item() + for i=0,20,1 do + if hook.is_hook({x=pos.x+x,y=pos.y-i,z=pos.z+z},name) then + minetest.set_node({x=pos.x+x,y=pos.y-i,z=pos.z+z},{name = "hook:rope3",param2=d}) + minetest.get_meta({x=pos.x+x,y=pos.y-i,z=pos.z+z}):set_string("owner",user:get_player_name()) + else + return itemstack + end + end + end + return itemstack + end + end +}) + + +minetest.register_node("hook:rope", { + description = "Rope (tempoary)", + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.0625, -0.5, -0.5, 0.0625, 0.5, -0.375} + } + }, + tiles = {"hook_rope.png"}, + paramtype = "light", + paramtype2 = "facedir", + buildable_to = true, + drop = "", + liquid_viscosity = 1, + liquidtype = "source", + liquid_alternative_flowing="hook:rope", + liquid_alternative_source="hook:rope", + liquid_renewable = false, + liquid_range = 0, + sunlight_propagates = false, + walkable = false, + is_ground_content = false, + groups = {not_in_creative_inventory=1,fleshy = 3, dig_immediate = 3,}, + on_construct = function(pos) + minetest.get_node_timer(pos):start(3) + end, + on_timer = function (pos, elapsed) + for i, ob in pairs(minetest.get_objects_inside_radius(pos, 3)) do + if ob:is_player() then return true end + end + minetest.set_node(pos, {name = "air"}) + return false + end, + sounds = {footstep = {name = "hook_rope", gain = 1}} +}) + +minetest.register_node("hook:rope2", { + description = "Rope", + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.0625, -0.5, -0.5, 0.0625, 0.5, -0.375} + } + }, + tiles = {"hook_rope.png"}, + paramtype = "light", + paramtype2 = "facedir", + drop = "", + liquid_viscosity = 1, + liquidtype = "source", + liquid_alternative_flowing="hook:rope2", + liquid_alternative_source="hook:rope2", + liquid_renewable = false, + liquid_range = 0, + sunlight_propagates = false, + walkable = false, + is_ground_content = false, + groups = {not_in_creative_inventory=1,fleshy = 3, dig_immediate = 3,}, + on_punch = function(pos, node, puncher, pointed_thing) + if minetest.is_protected(pos,puncher:get_player_name()) then + return false + end + puncher:get_inventory():add_item("main", ItemStack("hook:climb_rope")) + local name=puncher:get_player_name() + for i=0,20,1 do + if minetest.get_node({x=pos.x,y=pos.y-i,z=pos.z}).name=="hook:rope2" or minetest.get_node({x=pos.x,y=pos.y-i,z=pos.z}).name=="air" then minetest.set_node({x=pos.x,y=pos.y-i,z=pos.z},{name = "air"}) else break end + end + for i=0,20,1 do + if minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="hook:rope2" or minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="hook:hooking" or minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="air" then minetest.set_node({x=pos.x,y=pos.y+i,z=pos.z},{name = "air"}) else return false end + end + end, + sounds = {footstep = {name = "hook_rope", gain = 1}} +}) + +minetest.register_node("hook:rope3", { + description = "Rope (locked)", + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.0625, -0.5, -0.5, 0.0625, 0.5, -0.375} + } + }, + tiles = {"hook_rope.png"}, + paramtype = "light", + paramtype2 = "facedir", + drop = "", + liquid_viscosity = 1, + liquidtype = "source", + liquid_alternative_flowing="hook:rope3", + liquid_alternative_source="hook:rope3", + liquid_renewable = false, + liquid_range = 0, + sunlight_propagates = false, + walkable = false, + is_ground_content = false, + can_dig = function(pos, player) + if minetest.get_meta(pos):get_string("owner")~=player:get_player_name() then + minetest.chat_send_player(player:get_player_name(), "This rope is owned by: ".. minetest.get_meta(pos):get_string("owner")) + return false + end + return true + end, + groups = {not_in_creative_inventory=1,fleshy = 3, dig_immediate = 3,}, + on_punch = function(pos, node, puncher, pointed_thing) + if minetest.get_meta(pos):get_string("owner")~=puncher:get_player_name() then + minetest.chat_send_player(puncher:get_player_name(), "This rope is owned by: ".. minetest.get_meta(pos):get_string("owner")) + return false + end + puncher:get_inventory():add_item("main", ItemStack("hook:climb_rope_locked")) + for i=0,20,1 do + if minetest.get_node({x=pos.x,y=pos.y-i,z=pos.z}).name=="hook:rope3" or minetest.get_node({x=pos.x,y=pos.y-i,z=pos.z}).name=="air" then minetest.set_node({x=pos.x,y=pos.y-i,z=pos.z},{name = "air"}) else break end + end + for i=0,20,1 do + if minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="hook:rope3" or minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="hook:hooking" or minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="air" then minetest.set_node({x=pos.x,y=pos.y+i,z=pos.z},{name = "air"}) else return false end + end + end, + sounds = {footstep = {name = "hook_rope", gain = 1}} +}) + +minetest.register_node("hook:hooking", { + description = "Hooking", + drawtype = "mesh", + mesh="hook_hook.obj", + tiles = {"hook_iron.png"}, + paramtype = "light", + paramtype2 = "facedir", + walkable=false, + pointable=false, + drop = "", + sunlight_propagates = false, + groups = {not_in_creative_inventory=1}, + on_timer = function (pos, elapsed) + local r=minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name + if r~="hook:rope" then + minetest.remove_node(pos) + return false + end + return true + end +}) + + minetest.register_tool("hook:mba", { description = "Mouth breather assembly", range = 1, @@ -1005,6 +1449,117 @@ minetest.register_tool("hook:mba", { end }) + + + +if minetest.get_modpath("mcl_core") then + minetest.register_craft({ + output = "hook:mba", + recipe = { + {"", "mcl_core:iron_ingot",""}, + {"mcl_core:iron_ingot", "mcl_core:iron_ingot","mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot", "mcl_core:iron_ingot","mcl_core:iron_ingot"} + }, + }) + + minetest.register_craft({ + output = "hook:hook", + recipe = { + {"", "mcl_core:iron_ingot",""}, + {"", "mcl_core:iron_ingot","mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot", "",""} + }, + }) + minetest.register_craft({ + output = "hook:hook_upgrade", + recipe = { + {"", "hook:hook",""}, + {"", "hook:hook",""}, + {"", "mcl_core:iron_ingot",""} + }, + }) + minetest.register_craft({ + output = "hook:climb_rope", + recipe = { + {"","mcl_core:iron_ingot",""}, + {"","mcl_core:ironblock",""}, + {"","mcl_core:iron_ingot",""} + }, + }) + minetest.register_craft({ + output = "hook:climb_rope_locked", + recipe = { + {"hook:climb_rope","mcl_core:iron_ingot",""} + }, + }) + minetest.register_craft({ + output = "hook:slingshot", + recipe = { + {"mcl_core:iron_ingot","","mcl_core:iron_ingot"}, + {"","mcl_core:ironblock",""}, + {"","mcl_core:iron_ingot",""} + }, + }) +else + minetest.register_craft({ + output = "hook:mba", + recipe = { + {"","default:steel_ingot",""}, + {"default:steel_ingot","default:steel_ingot","default:steel_ingot"}, + {"default:steel_ingot","","default:steel_ingot"}, + } + }) + + minetest.register_craft({ + output = "hook:hook", + recipe = { + {"","default:steel_ingot",""}, + {"","default:steel_ingot","default:steel_ingot"}, + {"default:steel_ingot","",""}, + } + }) + minetest.register_craft({ + output = "hook:hook_upgrade", + recipe = { + {"","hook:hook",""}, + {"","hook:hook",""}, + {"","default:steel_ingot",""}, + } + }) + + minetest.register_craft({ + output = "hook:climb_rope", + recipe = { + {"","default:steel_ingot",""}, + {"","default:steelblock",""}, + {"","default:steel_ingot",""}, + } + }) + minetest.register_craft({ + output = "hook:climb_rope_locked", + recipe = { + {"hook:climb_rope","default:steel_ingot",""}, + } + }) + + minetest.register_craft({ + output = "hook:slingshot", + recipe = { + {"default:steel_ingot","","default:steel_ingot"}, + {"","default:steelblock",""}, + {"","default:steel_ingot",""}, + } + }) +end + + + user:set_breath(11) + end + end + return itemstack + end +}) + minetest.register_craft({ output = "hook:mba", recipe = { From 8877312933fdd8a7ef93dbcad1abe77bdf8c6697 Mon Sep 17 00:00:00 2001 From: wuniversales <48658161+wuniversales@users.noreply.github.com> Date: Sat, 21 Mar 2020 01:27:03 +0100 Subject: [PATCH 04/10] Update pchest.lua --- pchest.lua | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 154 insertions(+), 1 deletion(-) diff --git a/pchest.lua b/pchest.lua index 2db4e06..158a4a7 100644 --- a/pchest.lua +++ b/pchest.lua @@ -25,6 +25,53 @@ pchest.setpchest=function(pos,user) meta:set_string("infotext", "PChest by: " .. user:get_player_name()) end +minetest.register_tool("hook:pchest", { + description = "Portable locked chest", + inventory_image = "hook_extras_chest3.png", + on_place = function(itemstack, user, pointed_thing) + if minetest.is_protected(pointed_thing.above,user:get_player_name()) or hook.slingshot_def(pointed_thing.above,"walkable") then + return itemstack + end + local p=minetest.dir_to_facedir(user:get_look_dir()) + local item=itemstack:to_table() + minetest.set_node(pointed_thing.above, {name = "hook:pchest_node",param1="",param2=p})pchest={} + +if minetest.get_modpath("mcl_core") then + minetest.register_craft({ + output = "hook:pchest", + recipe = { + {"mcl_core:stick", "mcl_core:stick","mcl_core:stick"}, + {"mcl_core:stick", "mcl_chests:chest","mcl_core:diamondblock"}, + {"mcl_core:stick", "mcl_core:stick","mcl_core:stick"} + }, + }) +else + minetest.register_craft({ + output = "hook:pchest", + recipe = { + {"default:stick","default:stick","default:stick"}, + {"default:stick","default:chest", "default:diamondblock"}, + {"default:stick","default:stick","default:stick"}, + } +}) +end + +pchest.setpchest=function(pos,user) + local meta = minetest.get_meta(pos) + meta:set_string("owner", user:get_player_name()) + meta:set_int("state", 0) + meta:get_inventory():set_size("main", 32) + meta:get_inventory():set_size("trans", 1) + meta:set_string("formspec", + "size[8,8]" .. + "list[context;main;0,0;8,4;]" .. + "list[context;trans;0,0;0,0;]" .. + "list[current_player;main;0,4.3;8,4;]" .. + "listring[current_player;main]" .. + "listring[current_name;main]") + meta:set_string("infotext", "PChest by: " .. user:get_player_name()) +end + minetest.register_tool("hook:pchest", { description = "Portable locked chest", inventory_image = "hook_extras_chest3.png", @@ -139,4 +186,110 @@ minetest.register_node("hook:pchest_node", { minetest.set_node(pos, {name = "air"}) minetest.sound_play("default_dig_dig_immediate", {pos=pos, gain = 1.0, max_hear_distance = 5,}) end -}) \ No newline at end of file +}) + + pchest.setpchest(pointed_thing.above,user) + + minetest.sound_play("default_place_node_hard", {pos=pointed_thing.above, gain = 1.0, max_hear_distance = 5}) + + if not (item.meta or item.metadata) then + itemstack:take_item() + return itemstack + end + if item.meta.items then + local its = minetest.deserialize(item.meta.items or "") or {} + local items = {} + for i,it in pairs(its) do + table.insert(items,ItemStack(it)) + end + + minetest.get_meta(pointed_thing.above):get_inventory():set_list("main",items) + elseif item.metadata ~= "" then + local meta=minetest.deserialize(item["metadata"]) + local s=meta.stuff + local its=meta.stuff.split(meta.stuff,",",",") + local nmeta=minetest.get_meta(pointed_thing.above) + for i,it in pairs(its) do + if its~="" then + nmeta:get_inventory():set_stack("main",i, ItemStack(it)) + end + end + end + itemstack:take_item() + return itemstack + end +}) + +minetest.register_node("hook:pchest_node", { + description = "Portable locked chest", + tiles = {"hook_extras_chest2.png","hook_extras_chest2.png","hook_extras_chest1.png","hook_extras_chest1.png","hook_extras_chest1.png","hook_extras_chest3.png"}, + groups = {dig_immediate = 2, not_in_creative_inventory=1,tubedevice = 1, tubedevice_receiver = 1}, + drop="hook:pchest", + paramtype2 = "facedir", + tube = {insert_object = function(pos, node, stack, direction) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local added = inv:add_item("main", stack) + return added + end, + can_insert = function(pos, node, stack, direction) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return inv:room_for_item("main", stack) + end, + input_inventory = "main", + connect_sides = {left = 1, right = 1, front = 1, back = 1, top = 1, bottom = 1}}, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + local m = minetest.get_meta(pos) + local owner = m:get_string("owner") + local inv = m:get_inventory() + local name = player:get_player_name() + if owner == name or owner == "" then + if stack:get_name() == "hook:pchest" then + minetest.chat_send_player(name, "Not allowed to put in it") + return 0 + elseif not inv:room_for_item("main",stack) then + minetest.chat_send_player(name, "Full") + return 0 + end + return stack:get_count() + end + return 0 + end, + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + local owner = minetest.get_meta(pos):get_string("owner") + if owner==player:get_player_name() or owner=="" then + return stack:get_count() + end + return 0 + end, + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + local owner = minetest.get_meta(pos):get_string("owner") + if owner==player:get_player_name() or owner=="" then + return count + end + return 0 + end, + can_dig = function(pos, player) + local m = minetest.get_meta(pos) + return m:get_string("owner") == "" and m:get_inventory():is_empty("main") + end, + on_punch = function(pos, node, player, pointed_thing) + local meta=minetest.get_meta(pos) + local name = player:get_player_name() + local pinv = player:get_inventory() + if minetest.is_protected(pos,name) or meta:get_string("owner") ~= name or not pinv:room_for_item("main",ItemStack("hook:pchest")) then + return false + end + local inv=meta:get_inventory() + local items = {} + for i,v in pairs(inv:get_list("main")) do + table.insert(items,v:to_table()) + end + local item = ItemStack("hook:pchest"):to_table() + item.meta={items=minetest.serialize(items)} + pinv:add_item("main", ItemStack(item)) + minetest.set_node(pos, {name = "air"}) + minetest.sound_play("default_dig_dig_immediate", {pos=pos, gain = 1.0, max_hear_distance = 5,}) + end +}) From cff1ff00ede59799051bee18cd60c2a2082191c4 Mon Sep 17 00:00:00 2001 From: wuniversales <48658161+wuniversales@users.noreply.github.com> Date: Sat, 21 Mar 2020 01:45:04 +0100 Subject: [PATCH 05/10] Update pchest.lua --- pchest.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pchest.lua b/pchest.lua index 158a4a7..0f0f52d 100644 --- a/pchest.lua +++ b/pchest.lua @@ -1,6 +1,16 @@ pchest={} -minetest.register_craft({ +if minetest.get_modpath("mcl_core") then + minetest.register_craft({ + output = "hook:pchest", + recipe = { + {"mcl_core:stick", "mcl_core:stick","mcl_core:stick"}, + {"mcl_core:stick", "mcl_chests:chest","mcl_core:diamondblock"}, + {"mcl_core:stick", "mcl_core:stick","mcl_core:stick"} + }, + }) +else + minetest.register_craft({ output = "hook:pchest", recipe = { {"default:stick","default:stick","default:stick"}, @@ -8,6 +18,7 @@ minetest.register_craft({ {"default:stick","default:stick","default:stick"}, } }) +end pchest.setpchest=function(pos,user) local meta = minetest.get_meta(pos) From 9953f833a804e85be46d6f1b63ad98cbf4a8fb0a Mon Sep 17 00:00:00 2001 From: wuniversales <48658161+wuniversales@users.noreply.github.com> Date: Sat, 21 Mar 2020 01:45:53 +0100 Subject: [PATCH 06/10] Update depends.txt --- depends.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/depends.txt b/depends.txt index 7595d17..fc09243 100644 --- a/depends.txt +++ b/depends.txt @@ -1,4 +1,5 @@ default? mcl_core? +mcl_chests? loot? doc? From 36dd287bd5ba9ebd4227fdae5eaa04ae37166b1a Mon Sep 17 00:00:00 2001 From: wuniversales <48658161+wuniversales@users.noreply.github.com> Date: Sat, 21 Mar 2020 01:47:56 +0100 Subject: [PATCH 07/10] Update init.lua --- init.lua | 1056 ------------------------------------------------------ 1 file changed, 1056 deletions(-) diff --git a/init.lua b/init.lua index 0cfe594..4945fc3 100644 --- a/init.lua +++ b/init.lua @@ -5,1005 +5,6 @@ hook={ pvp = minetest.settings:get_bool("enable_pvp") == true, } -dofile(minetest.get_modpath("hook") .. "/project.lua") -dofile(minetest.get_modpath("hook") .. "/pchest.lua") - -if hook.tmp_time=="" or hook.tmp_time==nil then - hook.tmp_time=890 -else - hook.tmp_time=hook.tmp_time-10 -end - -hook.punch=function(ob1,ob2,hp) - ob2:punch(ob1,1,{full_punch_interval=1,damage_groups={fleshy=hp}}) -end - -hook.slingshot_def=function(pos,n) - local nn=minetest.get_node(pos).name - return (minetest.registered_nodes[nn] and minetest.registered_nodes[nn][n]) -end - -hook.slingshot_onuse=function(itemstack, user) - local veloc=15 - local pos = user:get_pos() - local upos={x=pos.x,y=pos.y+2,z=pos.z} - local dir = user:get_look_dir() - local item=itemstack:to_table() - local mode=minetest.deserialize(item["metadata"]) - if mode==nil then mode=1 else mode=mode.mode end - - local item=user:get_inventory():get_stack("main", user:get_wield_index()+mode):get_name() - if item=="" then return itemstack end - local e=minetest.add_item({x=pos.x,y=pos.y+2,z=pos.z},item) - e:set_velocity({x=dir.x*veloc, y=dir.y*veloc, z=dir.z*veloc}) - e:set_acceleration({x=dir.x*-3, y=-5, z=dir.z*-3}) - e:get_luaentity().age=hook.tmp_time - table.insert(hook.tmp_throw,{ob=e,timer=2,user=user:get_player_name()}) - if item=="hook:slingshot" then - itemstack:set_wear(9999999) - end - user:get_inventory():remove_item("main", item) - minetest.sound_play("hook_throw", {pos=pos, gain = 1.0, max_hear_distance = 5}) - return itemstack -end - -minetest.register_tool("hook:slingshot", { - description = "Slingshot", - range = 4, - inventory_image = "hook_slingshot.png", - on_use=function(itemstack, user, pointed_thing) - local ref = pointed_thing.ref - if ref and not (ref:get_luaentity() and ref:get_luaentity().name == "__builtin:item") then - hook.punch(user,ref,4) - return itemstack - end - hook.slingshot_onuse(itemstack, user) - return itemstack - end, - on_place=function(itemstack, user, pointed_thing) - local item=itemstack:to_table() - local meta=minetest.deserialize(item["metadata"]) - local mode=0 - if meta==nil then meta={} mode=1 end - if meta.mode==nil then meta.mode=1 end - mode=(meta.mode) - if mode==1 then - mode=-1 - minetest.chat_send_player(user:get_player_name(), "Use stack to left") - else - mode=1 - minetest.chat_send_player(user:get_player_name(), "Use stack to right ") - end - meta.mode=mode - item.metadata=minetest.serialize(meta) - item.meta=minetest.serialize(meta) - itemstack:replace(item) - return itemstack - end -}) -hook={ - tmp_throw={}, - tmp_throw_timer=0, - tmp_time= tonumber(minetest.settings:get("item_entity_ttl")), - pvp = minetest.settings:get_bool("enable_pvp") == true, -} - -dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/project.lua") -dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/pchest.lua") - -if hook.tmp_time=="" or hook.tmp_time==nil then - hook.tmp_time=890 -else - hook.tmp_time=hook.tmp_time-10 -end - -hook.punch=function(ob1,ob2,hp) - ob2:punch(ob1,1,{full_punch_interval=1,damage_groups={fleshy=hp}}) -end - -hook.slingshot_def=function(pos,n) - local nn=minetest.get_node(pos).name - return (minetest.registered_nodes[nn] and minetest.registered_nodes[nn][n]) -end - -hook.slingshot_onuse=function(itemstack, user) - local veloc=15 - local pos = user:get_pos() - local upos={x=pos.x,y=pos.y+2,z=pos.z} - local dir = user:get_look_dir() - local item=itemstack:to_table() - local mode=minetest.deserialize(item["metadata"]) - if mode==nil then mode=1 else mode=mode.mode end - - local item=user:get_inventory():get_stack("main", user:get_wield_index()+mode):get_name() - if item=="" then return itemstack end - local e=minetest.add_item({x=pos.x,y=pos.y+2,z=pos.z},item) - e:set_velocity({x=dir.x*veloc, y=dir.y*veloc, z=dir.z*veloc}) - e:set_acceleration({x=dir.x*-3, y=-5, z=dir.z*-3}) - e:get_luaentity().age=hook.tmp_time - table.insert(hook.tmp_throw,{ob=e,timer=2,user=user:get_player_name()}) - if item=="hook:slingshot" then - itemstack:set_wear(9999999) - end - user:get_inventory():remove_item("main", item) - minetest.sound_play("hook_throw", {pos=pos, gain = 1.0, max_hear_distance = 5}) - return itemstack -end - -minetest.register_tool("hook:slingshot", { - description = "Slingshot", - range = 4, - inventory_image = "hook_slingshot.png", - on_use=function(itemstack, user, pointed_thing) - local ref = pointed_thing.ref - if ref and not (ref:get_luaentity() and ref:get_luaentity().name == "__builtin:item") then - hook.punch(user,ref,4) - return itemstack - end - hook.slingshot_onuse(itemstack, user) - return itemstack - end, - on_place=function(itemstack, user, pointed_thing) - local item=itemstack:to_table() - local meta=minetest.deserialize(item["metadata"]) - local mode=0 - if meta==nil then meta={} mode=1 end - if meta.mode==nil then meta.mode=1 end - mode=(meta.mode) - if mode==1 then - mode=-1 - minetest.chat_send_player(user:get_player_name(), "Use stack to left") - else - mode=1 - minetest.chat_send_player(user:get_player_name(), "Use stack to right ") - end - meta.mode=mode - item.metadata=minetest.serialize(meta) - item.meta=minetest.serialize(meta) - itemstack:replace(item) - return itemstack - end -}) - -minetest.register_globalstep(function(dtime) - hook.tmp_throw_timer=hook.tmp_throw_timer+dtime - if hook.tmp_throw_timer<0.1 then return end - hook.tmp_throw_timer=0 - for i, t in pairs(hook.tmp_throw) do - t.timer=t.timer-0.25 - if t.timer<=0 or t.ob==nil or t.ob:get_pos()==nil then table.remove(hook.tmp_throw,i) return end - for ii, ob in pairs(minetest.get_objects_inside_radius(t.ob:get_pos(), 1.5)) do - if (not ob:get_luaentity()) or (ob:get_luaentity() and (ob:get_luaentity().name~="__builtin:item")) then - if (not ob:is_player()) or (ob:is_player() and ob:get_player_name(ob)~=t.user and hook.pvp) then - ob:set_hp(ob:get_hp()-5) - hook.punch(ob,ob,4) - t.ob:set_velocity({x=0, y=0, z=0}) - if ob:get_hp()<=0 and ob:is_player()==false then ob:remove() end - t.ob:set_acceleration({x=0, y=-10,z=0}) - t.ob:set_velocity({x=0, y=-10, z=0}) - table.remove(hook.tmp_throw,i) - break - end - end - end - end -end) - -hook.is_hook=function(pos,name) - if not (name and minetest.is_protected(pos,name)) then - local def = minetest.registered_nodes[minetest.get_node(pos).name] - if def and def.name == "hook:hooking" or (def.buildable_to and not (def.liquidtype == "source" and def.paramtype2 == "none")) then - if not (def.name == "hook:hooking" and minetest.get_meta(pos):get_int("a") ~= 0) then - return true - end - end - end - return false -end - -minetest.register_tool("hook:hook", { - description = "Hook with rope (hit a corner to climb)", - inventory_image = "hook_hook.png", - on_use = function(itemstack, user, pointed_thing) - if pointed_thing.type~="node" then return itemstack end - local d=minetest.dir_to_facedir(user:get_look_dir()) - local pos=pointed_thing.above - local pos2=pointed_thing.under - local name=user:get_player_name() - - if hook.slingshot_def(pos2,"walkable") and - hook.slingshot_def({x=pos.x,y=pos.y-1,z=pos.z},"walkable")==false - and (hook.slingshot_def({x=pos2.x,y=pos2.y+1,z=pos2.z},"walkable")==false or minetest.get_node({x=pos2.x,y=pos2.y+1,z=pos2.z}).name=="default:snow") and - hook.is_hook(pos,name) and - hook.slingshot_def({x=pos.x,y=pos.y+1,z=pos.z},"walkable")==false then - if d==3 then d=1 - elseif d==1 then d=3 - elseif d==2 then d=0 - elseif d==0 then d=2 - end - if hook.is_hook({x=pos.x,y=pos.y+1,z=pos.z},name) then - minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name = "hook:hooking",param2=d}) - minetest.get_node_timer({x=pos.x,y=pos.y+1,z=pos.z}):start(3) - else - return itemstack - end - for i=0,-4, -1 do - if hook.is_hook({x=pos.x,y=pos.y+i,z=pos.z},name) then - minetest.set_node({x=pos.x,y=pos.y+i,z=pos.z}, {name = "hook:rope",param2=d}) - else - return itemstack - end - end - end - return itemstack - end -}) - -minetest.register_tool("hook:hook_upgrade", { - description = "Hook with rope (double)", - range = 6, - inventory_image = "hook_hookup.png", - on_use = function(itemstack, user, pointed_thing) - if pointed_thing.type~="node" then return itemstack end - local d=minetest.dir_to_facedir(user:get_look_dir()) - local pos=pointed_thing.above - local pos2=pointed_thing.under - local name=user:get_player_name() - if hook.slingshot_def(pos2,"walkable") and - hook.slingshot_def({x=pos.x,y=pos.y-1,z=pos.z},"walkable")==false and - (hook.slingshot_def({x=pos2.x,y=pos2.y+1,z=pos2.z},"walkable")==false or minetest.get_node({x=pos2.x,y=pos2.y+1,z=pos2.z}).name=="default:snow") and - hook.is_hook(pos,name) and - hook.slingshot_def({x=pos.x,y=pos.y+1,z=pos.z},"walkable")==false then - if d==3 then d=1 - elseif d==1 then d=3 - elseif d==2 then d=0 - elseif d==0 then d=2 - end - if hook.is_hook({x=pos.x,y=pos.y+1,z=pos.z},name) then - minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name = "hook:hooking",param2=d}) - minetest.get_node_timer({x=pos.x,y=pos.y+1,z=pos.z}):start(3) - else - return itemstack - end - for i=0,-8, -1 do - if hook.is_hook({x=pos.x,y=pos.y+i,z=pos.z},name) then - minetest.set_node({x=pos.x,y=pos.y+i,z=pos.z}, {name = "hook:rope",param2=d}) - else - return itemstack - end - end - end - return itemstack - end -}) - -minetest.register_tool("hook:climb_rope", { - description = "Climb rope", - range = 2, - inventory_image = "hook_rope2.png", - on_use = function(itemstack, user, pointed_thing) - if pointed_thing.type~="node" then - hook.user=user - hook.locked=false - local pos=user:get_pos() - local d=user:get_look_dir() - local m=minetest.add_entity({x=pos.x,y=pos.y+1.5,z=pos.z}, "hook:power") - m:set_velocity({x=d.x*15, y=d.y*15, z=d.z*15}) - m:set_acceleration({x=0, y=-5, z=0}) - minetest.sound_play("hook_throw", {pos=pos, gain = 1.0, max_hear_distance = 5,}) - return itemstack - else - local pos=pointed_thing.under - local d=minetest.dir_to_facedir(user:get_look_dir()) - local z=0 - local x=0 - local name=user:get_player_name() - if hook.slingshot_def(pos,"walkable") then - if d==0 then z=1 end - if d==2 then z=-1 end - if d==1 then x=1 end - if d==3 then x=-1 end - if hook.is_hook({x=pos.x+x,y=pos.y,z=pos.z+z},name) and hook.is_hook({x=pos.x+x,y=pos.y+1,z=pos.z+z},name) then - minetest.set_node({x=pos.x+x,y=pos.y+1,z=pos.z+z},{name = "hook:hooking",param2=d}) - minetest.get_meta({x=pos.x+x,y=pos.y+1,z=pos.z+z}):set_int("a",1) - else - return itemstack - end - itemstack:take_item() - for i=0,20,1 do - if hook.is_hook({x=pos.x+x,y=pos.y-i,z=pos.z+z},name) then minetest.set_node({x=pos.x+x,y=pos.y-i,z=pos.z+z},{name = "hook:rope2",param2=d}) else return itemstack end - end - end - return itemstack - end - end -}) - - -minetest.register_tool("hook:climb_rope_locked", { - description = "Climb rope (Locked)", - range = 2, - inventory_image = "hook_rope_locked.png", - on_use = function(itemstack, user, pointed_thing) - if pointed_thing.type~="node" then - hook.user=user - hook.locked=true - local pos=user:get_pos() - local d=user:get_look_dir() - local m=minetest.add_entity({x=pos.x,y=pos.y+1.5,z=pos.z}, "hook:power") - m:set_velocity({x=d.x*15, y=d.y*15, z=d.z*15}) - m:set_acceleration({x=0, y=-5, z=0}) - minetest.sound_play("hook_throw", {pos=pos, gain = 1.0, max_hear_distance = 5,}) - return itemstack - else - local pos=pointed_thing.under - local d=minetest.dir_to_facedir(user:get_look_dir()) - local z=0 - local x=0 - local name=user:get_player_name() - if hook.slingshot_def(pos,"walkable") then - if d==0 then z=1 end - if d==2 then z=-1 end - if d==1 then x=1 end - if d==3 then x=-1 end - if hook.is_hook({x=pos.x+x,y=pos.y,z=pos.z+z},name) and hook.is_hook({x=pos.x+x,y=pos.y+1,z=pos.z+z},name) then - minetest.set_node({x=pos.x+x,y=pos.y+1,z=pos.z+z},{name = "hook:hooking",param2=d}) - minetest.get_meta({x=pos.x+x,y=pos.y+1,z=pos.z+z}):set_int("a",1) - else - return itemstack - end - itemstack:take_item() - for i=0,20,1 do - if hook.is_hook({x=pos.x+x,y=pos.y-i,z=pos.z+z},name) then - minetest.set_node({x=pos.x+x,y=pos.y-i,z=pos.z+z},{name = "hook:rope3",param2=d}) - minetest.get_meta({x=pos.x+x,y=pos.y-i,z=pos.z+z}):set_string("owner",user:get_player_name()) - else - return itemstack - end - end - end - return itemstack - end - end -}) - - -minetest.register_node("hook:rope", { - description = "Rope (tempoary)", - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = { - {-0.0625, -0.5, -0.5, 0.0625, 0.5, -0.375} - } - }, - tiles = {"hook_rope.png"}, - paramtype = "light", - paramtype2 = "facedir", - buildable_to = true, - drop = "", - liquid_viscosity = 1, - liquidtype = "source", - liquid_alternative_flowing="hook:rope", - liquid_alternative_source="hook:rope", - liquid_renewable = false, - liquid_range = 0, - sunlight_propagates = false, - walkable = false, - is_ground_content = false, - groups = {not_in_creative_inventory=1,fleshy = 3, dig_immediate = 3,}, - on_construct = function(pos) - minetest.get_node_timer(pos):start(3) - end, - on_timer = function (pos, elapsed) - for i, ob in pairs(minetest.get_objects_inside_radius(pos, 3)) do - if ob:is_player() then return true end - end - minetest.set_node(pos, {name = "air"}) - return false - end, - sounds = {footstep = {name = "hook_rope", gain = 1}} -}) - -minetest.register_node("hook:rope2", { - description = "Rope", - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = { - {-0.0625, -0.5, -0.5, 0.0625, 0.5, -0.375} - } - }, - tiles = {"hook_rope.png"}, - paramtype = "light", - paramtype2 = "facedir", - drop = "", - liquid_viscosity = 1, - liquidtype = "source", - liquid_alternative_flowing="hook:rope2", - liquid_alternative_source="hook:rope2", - liquid_renewable = false, - liquid_range = 0, - sunlight_propagates = false, - walkable = false, - is_ground_content = false, - groups = {not_in_creative_inventory=1,fleshy = 3, dig_immediate = 3,}, - on_punch = function(pos, node, puncher, pointed_thing) - if minetest.is_protected(pos,puncher:get_player_name()) then - return false - end - puncher:get_inventory():add_item("main", ItemStack("hook:climb_rope")) - local name=puncher:get_player_name() - for i=0,20,1 do - if minetest.get_node({x=pos.x,y=pos.y-i,z=pos.z}).name=="hook:rope2" or minetest.get_node({x=pos.x,y=pos.y-i,z=pos.z}).name=="air" then minetest.set_node({x=pos.x,y=pos.y-i,z=pos.z},{name = "air"}) else break end - end - for i=0,20,1 do - if minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="hook:rope2" or minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="hook:hooking" or minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="air" then minetest.set_node({x=pos.x,y=pos.y+i,z=pos.z},{name = "air"}) else return false end - end - end, - sounds = {footstep = {name = "hook_rope", gain = 1}} -}) - -minetest.register_node("hook:rope3", { - description = "Rope (locked)", - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = { - {-0.0625, -0.5, -0.5, 0.0625, 0.5, -0.375} - } - }, - tiles = {"hook_rope.png"}, - paramtype = "light", - paramtype2 = "facedir", - drop = "", - liquid_viscosity = 1, - liquidtype = "source", - liquid_alternative_flowing="hook:rope3", - liquid_alternative_source="hook:rope3", - liquid_renewable = false, - liquid_range = 0, - sunlight_propagates = false, - walkable = false, - is_ground_content = false, - can_dig = function(pos, player) - if minetest.get_meta(pos):get_string("owner")~=player:get_player_name() then - minetest.chat_send_player(player:get_player_name(), "This rope is owned by: ".. minetest.get_meta(pos):get_string("owner")) - return false - end - return true - end, - groups = {not_in_creative_inventory=1,fleshy = 3, dig_immediate = 3,}, - on_punch = function(pos, node, puncher, pointed_thing) - if minetest.get_meta(pos):get_string("owner")~=puncher:get_player_name() then - minetest.chat_send_player(puncher:get_player_name(), "This rope is owned by: ".. minetest.get_meta(pos):get_string("owner")) - return false - end - puncher:get_inventory():add_item("main", ItemStack("hook:climb_rope_locked")) - for i=0,20,1 do - if minetest.get_node({x=pos.x,y=pos.y-i,z=pos.z}).name=="hook:rope3" or minetest.get_node({x=pos.x,y=pos.y-i,z=pos.z}).name=="air" then minetest.set_node({x=pos.x,y=pos.y-i,z=pos.z},{name = "air"}) else break end - end - for i=0,20,1 do - if minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="hook:rope3" or minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="hook:hooking" or minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="air" then minetest.set_node({x=pos.x,y=pos.y+i,z=pos.z},{name = "air"}) else return false end - end - end, - sounds = {footstep = {name = "hook_rope", gain = 1}} -}) - -minetest.register_node("hook:hooking", { - description = "Hooking", - drawtype = "mesh", - mesh="hook_hook.obj", - tiles = {"hook_iron.png"}, - paramtype = "light", - paramtype2 = "facedir", - walkable=false, - pointable=false, - drop = "", - sunlight_propagates = false, - groups = {not_in_creative_inventory=1}, - on_timer = function (pos, elapsed) - local r=minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name - if r~="hook:rope" then - minetest.remove_node(pos) - return false - end - return true - end -}) - - -minetest.register_tool("hook:mba", { - description = "Mouth breather assembly", - range = 1, - inventory_image = "hook_mba.png", - on_use=function(itemstack, user, pointed_thing) - local pos=user:get_pos() - pos.y=pos.y+1.5 - if hook.slingshot_def(pos,"drowning")==0 then - itemstack:set_wear(1) - else - local use=itemstack:get_wear()+(65536/10) - if use<65536 then - itemstack:set_wear(use) - user:set_breath(11) - end - end - return itemstack - end -}) - - - - -if minetest.get_modpath("mcl_core") then - minetest.register_craft({ - output = "hook:mba", - recipe = { - {"", "mcl_core:iron_ingot",""}, - {"mcl_core:iron_ingot", "mcl_core:iron_ingot","mcl_core:iron_ingot"}, - {"mcl_core:iron_ingot", "mcl_core:iron_ingot","mcl_core:iron_ingot"} - }, - }) - - minetest.register_craft({ - output = "hook:hook", - recipe = { - {"", "mcl_core:iron_ingot",""}, - {"", "mcl_core:iron_ingot","mcl_core:iron_ingot"}, - {"mcl_core:iron_ingot", "",""} - }, - }) - minetest.register_craft({ - output = "hook:hook_upgrade", - recipe = { - {"", "hook:hook",""}, - {"", "hook:hook",""}, - {"", "mcl_core:iron_ingot",""} - }, - }) - minetest.register_craft({ - output = "hook:climb_rope", - recipe = { - {"","mcl_core:iron_ingot",""}, - {"","mcl_core:iron",""}, - {"","mcl_core:iron_ingot",""} - }, - }) - minetest.register_craft({ - output = "hook:climb_rope_locked", - recipe = { - {"hook:climb_rope","mcl_core:iron_ingot",""} - }, - }) - minetest.register_craft({ - output = "hook:slingshot", - recipe = { - {"mcl_core:iron_ingot","","mcl_core:iron_ingot"}, - {"","mcl_core:iron",""}, - {"","mcl_core:iron_ingot",""} - }, - }) -else - minetest.register_craft({ - output = "hook:mba", - recipe = { - {"","default:steel_ingot",""}, - {"default:steel_ingot","default:steel_ingot","default:steel_ingot"}, - {"default:steel_ingot","","default:steel_ingot"}, - } - }) - - minetest.register_craft({ - output = "hook:hook", - recipe = { - {"","default:steel_ingot",""}, - {"","default:steel_ingot","default:steel_ingot"}, - {"default:steel_ingot","",""}, - } - }) - minetest.register_craft({ - output = "hook:hook_upgrade", - recipe = { - {"","hook:hook",""}, - {"","hook:hook",""}, - {"","default:steel_ingot",""}, - } - }) - - minetest.register_craft({ - output = "hook:climb_rope", - recipe = { - {"","default:steel_ingot",""}, - {"","default:steelblock",""}, - {"","default:steel_ingot",""}, - } - }) - minetest.register_craft({ - output = "hook:climb_rope_locked", - recipe = { - {"hook:climb_rope","default:steel_ingot",""}, - } - }) - - minetest.register_craft({ - output = "hook:slingshot", - recipe = { - {"default:steel_ingot","","default:steel_ingot"}, - {"","default:steelblock",""}, - {"","default:steel_ingot",""}, - } - }) -end - - -minetest.register_globalstep(function(dtime) - hook.tmp_throw_timer=hook.tmp_throw_timer+dtime - if hook.tmp_throw_timer<0.1 then return end - hook.tmp_throw_timer=0 - for i, t in pairs(hook.tmp_throw) do - t.timer=t.timer-0.25 - if t.timer<=0 or t.ob==nil or t.ob:get_pos()==nil then table.remove(hook.tmp_throw,i) return end - for ii, ob in pairs(minetest.get_objects_inside_radius(t.ob:get_pos(), 1.5)) do - if (not ob:get_luaentity()) or (ob:get_luaentity() and (ob:get_luaentity().name~="__builtin:item")) then - if (not ob:is_player()) or (ob:is_player() and ob:get_player_name(ob)~=t.user and hook.pvp) then - ob:set_hp(ob:get_hp()-5) - hook.punch(ob,ob,4) - t.ob:set_velocity({x=0, y=0, z=0}) - if ob:get_hp()<=0 and ob:is_player()==false then ob:remove() end - t.ob:set_acceleration({x=0, y=-10,z=0}) - t.ob:set_velocity({x=0, y=-10, z=0}) - table.remove(hook.tmp_throw,i) - break - end - end - end - end -end) - -hook.is_hook=function(pos,name) - if not (name and minetest.is_protected(pos,name)) then - local def = minetest.registered_nodes[minetest.get_node(pos).name] - if def and def.name == "hook:hooking" or (def.buildable_to and not (def.liquidtype == "source" and def.paramtype2 == "none")) then - if not (def.name == "hook:hooking" and minetest.get_meta(pos):get_int("a") ~= 0) then - return true - end - end - end - return false -end - -minetest.register_tool("hook:hook", { - description = "Hook with rope (hit a corner to climb)", - inventory_image = "hook_hook.png", - on_use = function(itemstack, user, pointed_thing) - if pointed_thing.type~="node" then return itemstack end - local d=minetest.dir_to_facedir(user:get_look_dir()) - local pos=pointed_thing.above - local pos2=pointed_thing.under - local name=user:get_player_name() - - if hook.slingshot_def(pos2,"walkable") and - hook.slingshot_def({x=pos.x,y=pos.y-1,z=pos.z},"walkable")==false - and (hook.slingshot_def({x=pos2.x,y=pos2.y+1,z=pos2.z},"walkable")==false or minetest.get_node({x=pos2.x,y=pos2.y+1,z=pos2.z}).name=="default:snow") and - hook.is_hook(pos,name) and - hook.slingshot_def({x=pos.x,y=pos.y+1,z=pos.z},"walkable")==false then - if d==3 then d=1 - elseif d==1 then d=3 - elseif d==2 then d=0 - elseif d==0 then d=2 - end - if hook.is_hook({x=pos.x,y=pos.y+1,z=pos.z},name) then - minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name = "hook:hooking",param2=d}) - minetest.get_node_timer({x=pos.x,y=pos.y+1,z=pos.z}):start(3) - else - return itemstack - end - for i=0,-4, -1 do - if hook.is_hook({x=pos.x,y=pos.y+i,z=pos.z},name) then - minetest.set_node({x=pos.x,y=pos.y+i,z=pos.z}, {name = "hook:rope",param2=d}) - else - return itemstack - end - end - end - return itemstack - end -}) - -minetest.register_tool("hook:hook_upgrade", { - description = "Hook with rope (double)", - range = 6, - inventory_image = "hook_hookup.png", - on_use = function(itemstack, user, pointed_thing) - if pointed_thing.type~="node" then return itemstack end - local d=minetest.dir_to_facedir(user:get_look_dir()) - local pos=pointed_thing.above - local pos2=pointed_thing.under - local name=user:get_player_name() - if hook.slingshot_def(pos2,"walkable") and - hook.slingshot_def({x=pos.x,y=pos.y-1,z=pos.z},"walkable")==false and - (hook.slingshot_def({x=pos2.x,y=pos2.y+1,z=pos2.z},"walkable")==false or minetest.get_node({x=pos2.x,y=pos2.y+1,z=pos2.z}).name=="default:snow") and - hook.is_hook(pos,name) and - hook.slingshot_def({x=pos.x,y=pos.y+1,z=pos.z},"walkable")==false then - if d==3 then d=1 - elseif d==1 then d=3 - elseif d==2 then d=0 - elseif d==0 then d=2 - end - if hook.is_hook({x=pos.x,y=pos.y+1,z=pos.z},name) then - minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name = "hook:hooking",param2=d}) - minetest.get_node_timer({x=pos.x,y=pos.y+1,z=pos.z}):start(3) - else - return itemstack - end - for i=0,-8, -1 do - if hook.is_hook({x=pos.x,y=pos.y+i,z=pos.z},name) then - minetest.set_node({x=pos.x,y=pos.y+i,z=pos.z}, {name = "hook:rope",param2=d}) - else - return itemstack - end - end - end - return itemstack - end -}) - -minetest.register_tool("hook:climb_rope", { - description = "Climb rope", - range = 2, - inventory_image = "hook_rope2.png", - on_use = function(itemstack, user, pointed_thing) - if pointed_thing.type~="node" then - hook.user=user - hook.locked=false - local pos=user:get_pos() - local d=user:get_look_dir() - local m=minetest.add_entity({x=pos.x,y=pos.y+1.5,z=pos.z}, "hook:power") - m:set_velocity({x=d.x*15, y=d.y*15, z=d.z*15}) - m:set_acceleration({x=0, y=-5, z=0}) - minetest.sound_play("hook_throw", {pos=pos, gain = 1.0, max_hear_distance = 5,}) - return itemstack - else - local pos=pointed_thing.under - local d=minetest.dir_to_facedir(user:get_look_dir()) - local z=0 - local x=0 - local name=user:get_player_name() - if hook.slingshot_def(pos,"walkable") then - if d==0 then z=1 end - if d==2 then z=-1 end - if d==1 then x=1 end - if d==3 then x=-1 end - if hook.is_hook({x=pos.x+x,y=pos.y,z=pos.z+z},name) and hook.is_hook({x=pos.x+x,y=pos.y+1,z=pos.z+z},name) then - minetest.set_node({x=pos.x+x,y=pos.y+1,z=pos.z+z},{name = "hook:hooking",param2=d}) - minetest.get_meta({x=pos.x+x,y=pos.y+1,z=pos.z+z}):set_int("a",1) - else - return itemstack - end - itemstack:take_item() - for i=0,20,1 do - if hook.is_hook({x=pos.x+x,y=pos.y-i,z=pos.z+z},name) then minetest.set_node({x=pos.x+x,y=pos.y-i,z=pos.z+z},{name = "hook:rope2",param2=d}) else return itemstack end - end - end - return itemstack - end - end -}) - - -minetest.register_tool("hook:climb_rope_locked", { - description = "Climb rope (Locked)", - range = 2, - inventory_image = "hook_rope_locked.png", - on_use = function(itemstack, user, pointed_thing) - if pointed_thing.type~="node" then - hook.user=user - hook.locked=true - local pos=user:get_pos() - local d=user:get_look_dir() - local m=minetest.add_entity({x=pos.x,y=pos.y+1.5,z=pos.z}, "hook:power") - m:set_velocity({x=d.x*15, y=d.y*15, z=d.z*15}) - m:set_acceleration({x=0, y=-5, z=0}) - minetest.sound_play("hook_throw", {pos=pos, gain = 1.0, max_hear_distance = 5,}) - return itemstack - else - local pos=pointed_thing.under - local d=minetest.dir_to_facedir(user:get_look_dir()) - local z=0 - local x=0 - local name=user:get_player_name() - if hook.slingshot_def(pos,"walkable") then - if d==0 then z=1 end - if d==2 then z=-1 end - if d==1 then x=1 end - if d==3 then x=-1 end - if hook.is_hook({x=pos.x+x,y=pos.y,z=pos.z+z},name) and hook.is_hook({x=pos.x+x,y=pos.y+1,z=pos.z+z},name) then - minetest.set_node({x=pos.x+x,y=pos.y+1,z=pos.z+z},{name = "hook:hooking",param2=d}) - minetest.get_meta({x=pos.x+x,y=pos.y+1,z=pos.z+z}):set_int("a",1) - else - return itemstack - end - itemstack:take_item() - for i=0,20,1 do - if hook.is_hook({x=pos.x+x,y=pos.y-i,z=pos.z+z},name) then - minetest.set_node({x=pos.x+x,y=pos.y-i,z=pos.z+z},{name = "hook:rope3",param2=d}) - minetest.get_meta({x=pos.x+x,y=pos.y-i,z=pos.z+z}):set_string("owner",user:get_player_name()) - else - return itemstack - end - end - end - return itemstack - end - end -}) - - -minetest.register_node("hook:rope", { - description = "Rope (tempoary)", - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = { - {-0.0625, -0.5, -0.5, 0.0625, 0.5, -0.375} - } - }, - tiles = {"hook_rope.png"}, - paramtype = "light", - paramtype2 = "facedir", - buildable_to = true, - drop = "", - liquid_viscosity = 1, - liquidtype = "source", - liquid_alternative_flowing="hook:rope", - liquid_alternative_source="hook:rope", - liquid_renewable = false, - liquid_range = 0, - sunlight_propagates = false, - walkable = false, - is_ground_content = false, - groups = {not_in_creative_inventory=1,fleshy = 3, dig_immediate = 3,}, - on_construct = function(pos) - minetest.get_node_timer(pos):start(3) - end, - on_timer = function (pos, elapsed) - for i, ob in pairs(minetest.get_objects_inside_radius(pos, 3)) do - if ob:is_player() then return true end - end - minetest.set_node(pos, {name = "air"}) - return false - end, - sounds = {footstep = {name = "hook_rope", gain = 1}} -}) - -minetest.register_node("hook:rope2", { - description = "Rope", - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = { - {-0.0625, -0.5, -0.5, 0.0625, 0.5, -0.375} - } - }, - tiles = {"hook_rope.png"}, - paramtype = "light", - paramtype2 = "facedir", - drop = "", - liquid_viscosity = 1, - liquidtype = "source", - liquid_alternative_flowing="hook:rope2", - liquid_alternative_source="hook:rope2", - liquid_renewable = false, - liquid_range = 0, - sunlight_propagates = false, - walkable = false, - is_ground_content = false, - groups = {not_in_creative_inventory=1,fleshy = 3, dig_immediate = 3,}, - on_punch = function(pos, node, puncher, pointed_thing) - if minetest.is_protected(pos,puncher:get_player_name()) then - return false - end - puncher:get_inventory():add_item("main", ItemStack("hook:climb_rope")) - local name=puncher:get_player_name() - for i=0,20,1 do - if minetest.get_node({x=pos.x,y=pos.y-i,z=pos.z}).name=="hook:rope2" or minetest.get_node({x=pos.x,y=pos.y-i,z=pos.z}).name=="air" then minetest.set_node({x=pos.x,y=pos.y-i,z=pos.z},{name = "air"}) else break end - end - for i=0,20,1 do - if minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="hook:rope2" or minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="hook:hooking" or minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="air" then minetest.set_node({x=pos.x,y=pos.y+i,z=pos.z},{name = "air"}) else return false end - end - end, - sounds = {footstep = {name = "hook_rope", gain = 1}} -}) - -minetest.register_node("hook:rope3", { - description = "Rope (locked)", - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = { - {-0.0625, -0.5, -0.5, 0.0625, 0.5, -0.375} - } - }, - tiles = {"hook_rope.png"}, - paramtype = "light", - paramtype2 = "facedir", - drop = "", - liquid_viscosity = 1, - liquidtype = "source", - liquid_alternative_flowing="hook:rope3", - liquid_alternative_source="hook:rope3", - liquid_renewable = false, - liquid_range = 0, - sunlight_propagates = false, - walkable = false, - is_ground_content = false, - can_dig = function(pos, player) - if minetest.get_meta(pos):get_string("owner")~=player:get_player_name() then - minetest.chat_send_player(player:get_player_name(), "This rope is owned by: ".. minetest.get_meta(pos):get_string("owner")) - return false - end - return true - end, - groups = {not_in_creative_inventory=1,fleshy = 3, dig_immediate = 3,}, - on_punch = function(pos, node, puncher, pointed_thing) - if minetest.get_meta(pos):get_string("owner")~=puncher:get_player_name() then - minetest.chat_send_player(puncher:get_player_name(), "This rope is owned by: ".. minetest.get_meta(pos):get_string("owner")) - return false - end - puncher:get_inventory():add_item("main", ItemStack("hook:climb_rope_locked")) - for i=0,20,1 do - if minetest.get_node({x=pos.x,y=pos.y-i,z=pos.z}).name=="hook:rope3" or minetest.get_node({x=pos.x,y=pos.y-i,z=pos.z}).name=="air" then minetest.set_node({x=pos.x,y=pos.y-i,z=pos.z},{name = "air"}) else break end - end - for i=0,20,1 do - if minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="hook:rope3" or minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="hook:hooking" or minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name=="air" then minetest.set_node({x=pos.x,y=pos.y+i,z=pos.z},{name = "air"}) else return false end - end - end, - sounds = {footstep = {name = "hook_rope", gain = 1}} -}) - -minetest.register_node("hook:hooking", { - description = "Hooking", - drawtype = "mesh", - mesh="hook_hook.obj", - tiles = {"hook_iron.png"}, - paramtype = "light", - paramtype2 = "facedir", - walkable=false, - pointable=false, - drop = "", - sunlight_propagates = false, - groups = {not_in_creative_inventory=1}, - on_timer = function (pos, elapsed) - local r=minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name - if r~="hook:rope" then - minetest.remove_node(pos) - return false - end - return true - end -}) - - -minetest.register_tool("hook:mba", { - description = "Mouth breather assembly", - range = 1, - inventory_image = "hook_mba.png", - on_use=function(itemstack, user, pointed_thing) - local pos=user:get_pos() - pos.y=pos.y+1.5 - if hook.slingshot_def(pos,"drowning")==0 then - itemstack:set_wear(1) - else - local use=itemstack:get_wear()+(65536/10) - if use<65536 then - itemstack:set_wear(use)hook={ - tmp_throw={}, - tmp_throw_timer=0, - tmp_time= tonumber(minetest.settings:get("item_entity_ttl")), - pvp = minetest.settings:get_bool("enable_pvp") == true, -} - dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/project.lua") dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/pchest.lua") @@ -1552,60 +553,3 @@ else }) end - - user:set_breath(11) - end - end - return itemstack - end -}) - -minetest.register_craft({ - output = "hook:mba", - recipe = { - {"","default:steel_ingot",""}, - {"default:steel_ingot","default:steel_ingot","default:steel_ingot"}, - {"default:steel_ingot","","default:steel_ingot"}, - } -}) - -minetest.register_craft({ - output = "hook:hook", - recipe = { - {"","default:steel_ingot",""}, - {"","default:steel_ingot","default:steel_ingot"}, - {"default:steel_ingot","",""}, - } -}) -minetest.register_craft({ - output = "hook:hook_upgrade", - recipe = { - {"","hook:hook",""}, - {"","hook:hook",""}, - {"","default:steel_ingot",""}, - } -}) - -minetest.register_craft({ - output = "hook:climb_rope", - recipe = { - {"","default:steel_ingot",""}, - {"","default:steelblock",""}, - {"","default:steel_ingot",""}, - } -}) -minetest.register_craft({ - output = "hook:climb_rope_locked", - recipe = { - {"hook:climb_rope","default:steel_ingot",""}, - } -}) - -minetest.register_craft({ - output = "hook:slingshot", - recipe = { - {"default:steel_ingot","","default:steel_ingot"}, - {"","default:steelblock",""}, - {"","default:steel_ingot",""}, - } -}) From fe458655475192f45981f291598d548cefc18197 Mon Sep 17 00:00:00 2001 From: wuniversales <48658161+wuniversales@users.noreply.github.com> Date: Sat, 21 Mar 2020 01:48:47 +0100 Subject: [PATCH 08/10] Update pchest.lua --- pchest.lua | 153 ----------------------------------------------------- 1 file changed, 153 deletions(-) diff --git a/pchest.lua b/pchest.lua index 0f0f52d..9ec95f2 100644 --- a/pchest.lua +++ b/pchest.lua @@ -36,53 +36,6 @@ pchest.setpchest=function(pos,user) meta:set_string("infotext", "PChest by: " .. user:get_player_name()) end -minetest.register_tool("hook:pchest", { - description = "Portable locked chest", - inventory_image = "hook_extras_chest3.png", - on_place = function(itemstack, user, pointed_thing) - if minetest.is_protected(pointed_thing.above,user:get_player_name()) or hook.slingshot_def(pointed_thing.above,"walkable") then - return itemstack - end - local p=minetest.dir_to_facedir(user:get_look_dir()) - local item=itemstack:to_table() - minetest.set_node(pointed_thing.above, {name = "hook:pchest_node",param1="",param2=p})pchest={} - -if minetest.get_modpath("mcl_core") then - minetest.register_craft({ - output = "hook:pchest", - recipe = { - {"mcl_core:stick", "mcl_core:stick","mcl_core:stick"}, - {"mcl_core:stick", "mcl_chests:chest","mcl_core:diamondblock"}, - {"mcl_core:stick", "mcl_core:stick","mcl_core:stick"} - }, - }) -else - minetest.register_craft({ - output = "hook:pchest", - recipe = { - {"default:stick","default:stick","default:stick"}, - {"default:stick","default:chest", "default:diamondblock"}, - {"default:stick","default:stick","default:stick"}, - } -}) -end - -pchest.setpchest=function(pos,user) - local meta = minetest.get_meta(pos) - meta:set_string("owner", user:get_player_name()) - meta:set_int("state", 0) - meta:get_inventory():set_size("main", 32) - meta:get_inventory():set_size("trans", 1) - meta:set_string("formspec", - "size[8,8]" .. - "list[context;main;0,0;8,4;]" .. - "list[context;trans;0,0;0,0;]" .. - "list[current_player;main;0,4.3;8,4;]" .. - "listring[current_player;main]" .. - "listring[current_name;main]") - meta:set_string("infotext", "PChest by: " .. user:get_player_name()) -end - minetest.register_tool("hook:pchest", { description = "Portable locked chest", inventory_image = "hook_extras_chest3.png", @@ -125,112 +78,6 @@ minetest.register_tool("hook:pchest", { end }) -minetest.register_node("hook:pchest_node", { - description = "Portable locked chest", - tiles = {"hook_extras_chest2.png","hook_extras_chest2.png","hook_extras_chest1.png","hook_extras_chest1.png","hook_extras_chest1.png","hook_extras_chest3.png"}, - groups = {dig_immediate = 2, not_in_creative_inventory=1,tubedevice = 1, tubedevice_receiver = 1}, - drop="hook:pchest", - paramtype2 = "facedir", - tube = {insert_object = function(pos, node, stack, direction) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - local added = inv:add_item("main", stack) - return added - end, - can_insert = function(pos, node, stack, direction) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - return inv:room_for_item("main", stack) - end, - input_inventory = "main", - connect_sides = {left = 1, right = 1, front = 1, back = 1, top = 1, bottom = 1}}, - allow_metadata_inventory_put = function(pos, listname, index, stack, player) - local m = minetest.get_meta(pos) - local owner = m:get_string("owner") - local inv = m:get_inventory() - local name = player:get_player_name() - if owner == name or owner == "" then - if stack:get_name() == "hook:pchest" then - minetest.chat_send_player(name, "Not allowed to put in it") - return 0 - elseif not inv:room_for_item("main",stack) then - minetest.chat_send_player(name, "Full") - return 0 - end - return stack:get_count() - end - return 0 - end, - allow_metadata_inventory_take = function(pos, listname, index, stack, player) - local owner = minetest.get_meta(pos):get_string("owner") - if owner==player:get_player_name() or owner=="" then - return stack:get_count() - end - return 0 - end, - allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) - local owner = minetest.get_meta(pos):get_string("owner") - if owner==player:get_player_name() or owner=="" then - return count - end - return 0 - end, - can_dig = function(pos, player) - local m = minetest.get_meta(pos) - return m:get_string("owner") == "" and m:get_inventory():is_empty("main") - end, - on_punch = function(pos, node, player, pointed_thing) - local meta=minetest.get_meta(pos) - local name = player:get_player_name() - local pinv = player:get_inventory() - if minetest.is_protected(pos,name) or meta:get_string("owner") ~= name or not pinv:room_for_item("main",ItemStack("hook:pchest")) then - return false - end - local inv=meta:get_inventory() - local items = {} - for i,v in pairs(inv:get_list("main")) do - table.insert(items,v:to_table()) - end - local item = ItemStack("hook:pchest"):to_table() - item.meta={items=minetest.serialize(items)} - pinv:add_item("main", ItemStack(item)) - minetest.set_node(pos, {name = "air"}) - minetest.sound_play("default_dig_dig_immediate", {pos=pos, gain = 1.0, max_hear_distance = 5,}) - end -}) - - pchest.setpchest(pointed_thing.above,user) - - minetest.sound_play("default_place_node_hard", {pos=pointed_thing.above, gain = 1.0, max_hear_distance = 5}) - - if not (item.meta or item.metadata) then - itemstack:take_item() - return itemstack - end - if item.meta.items then - local its = minetest.deserialize(item.meta.items or "") or {} - local items = {} - for i,it in pairs(its) do - table.insert(items,ItemStack(it)) - end - - minetest.get_meta(pointed_thing.above):get_inventory():set_list("main",items) - elseif item.metadata ~= "" then - local meta=minetest.deserialize(item["metadata"]) - local s=meta.stuff - local its=meta.stuff.split(meta.stuff,",",",") - local nmeta=minetest.get_meta(pointed_thing.above) - for i,it in pairs(its) do - if its~="" then - nmeta:get_inventory():set_stack("main",i, ItemStack(it)) - end - end - end - itemstack:take_item() - return itemstack - end -}) - minetest.register_node("hook:pchest_node", { description = "Portable locked chest", tiles = {"hook_extras_chest2.png","hook_extras_chest2.png","hook_extras_chest1.png","hook_extras_chest1.png","hook_extras_chest1.png","hook_extras_chest3.png"}, From 7eddb628389836edfe01712bf457217369a7eb31 Mon Sep 17 00:00:00 2001 From: wuniversales <48658161+wuniversales@users.noreply.github.com> Date: Fri, 10 Apr 2020 20:53:23 +0200 Subject: [PATCH 09/10] Update mod.conf --- mod.conf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mod.conf b/mod.conf index a6a54e8..b35812e 100644 --- a/mod.conf +++ b/mod.conf @@ -1,2 +1,3 @@ -name = hook -description = Survive & climbing tools \ No newline at end of file +name = hook +description = Survive & climbing tools +optional_depends = default, mcl_core, loot, doc From 6bd0d18e28813b8722c7d75ac26e4a542a3b61ef Mon Sep 17 00:00:00 2001 From: wuniversales <48658161+wuniversales@users.noreply.github.com> Date: Fri, 10 Apr 2020 20:53:35 +0200 Subject: [PATCH 10/10] Delete depends.txt --- depends.txt | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 depends.txt diff --git a/depends.txt b/depends.txt deleted file mode 100644 index fc09243..0000000 --- a/depends.txt +++ /dev/null @@ -1,5 +0,0 @@ -default? -mcl_core? -mcl_chests? -loot? -doc?