Add files via upload
This commit is contained in:
parent
9d3c3355a7
commit
8c4e1790ad
23
init.lua
23
init.lua
@ -43,7 +43,7 @@ hook.slingshot_onuse=function(itemstack, user)
|
||||
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,})
|
||||
minetest.sound_play("hook_throw", {pos=pos, gain = 1.0, max_hear_distance = 5})
|
||||
return itemstack
|
||||
end
|
||||
|
||||
@ -99,7 +99,6 @@ minetest.register_globalstep(function(dtime)
|
||||
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)
|
||||
minetest.sound_play("hook_hard_punch", {pos=ob:get_pos(), gain = 1.0, max_hear_distance = 5,})
|
||||
break
|
||||
end
|
||||
end
|
||||
@ -121,7 +120,6 @@ end
|
||||
|
||||
minetest.register_tool("hook:hook", {
|
||||
description = "Hook with rope (hit a corner to climb)",
|
||||
range = 2,
|
||||
inventory_image = "hook_hook.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if pointed_thing.type~="node" then return itemstack end
|
||||
@ -155,12 +153,12 @@ minetest.register_tool("hook:hook", {
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_tool("hook:hook_upgrade", {
|
||||
description = "Hook with rope (double)",
|
||||
range = 5,
|
||||
range = 6,
|
||||
inventory_image = "hook_hookup.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if pointed_thing.type~="node" then return itemstack end
|
||||
@ -193,7 +191,7 @@ minetest.register_tool("hook:hook_upgrade", {
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_tool("hook:climb_rope", {
|
||||
@ -209,6 +207,7 @@ minetest.register_tool("hook:climb_rope", {
|
||||
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
|
||||
@ -234,7 +233,7 @@ minetest.register_tool("hook:climb_rope", {
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
end,
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
@ -251,6 +250,7 @@ minetest.register_tool("hook:climb_rope_locked", {
|
||||
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
|
||||
@ -281,7 +281,7 @@ minetest.register_tool("hook:climb_rope_locked", {
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
end,
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
@ -319,6 +319,7 @@ minetest.register_node("hook:rope", {
|
||||
minetest.set_node(pos, {name = "air"})
|
||||
return false
|
||||
end,
|
||||
sounds = {footstep = {name = "hook_rope", gain = 1}}
|
||||
})
|
||||
|
||||
minetest.register_node("hook:rope2", {
|
||||
@ -357,6 +358,7 @@ minetest.register_node("hook:rope2", {
|
||||
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", {
|
||||
@ -402,13 +404,14 @@ minetest.register_node("hook:rope3", {
|
||||
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_rope.png"},
|
||||
tiles = {"hook_iron.png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable=false,
|
||||
@ -423,7 +426,7 @@ minetest.register_node("hook:hooking", {
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
|
83
pchest.lua
83
pchest.lua
@ -4,7 +4,7 @@ minetest.register_craft({
|
||||
output = "hook:pchest",
|
||||
recipe = {
|
||||
{"default:stick","default:stick","default:stick"},
|
||||
{"default:stick","default:chest_locked", "default:diamondblock"},
|
||||
{"default:stick","default:chest", "default:diamondblock"},
|
||||
{"default:stick","default:stick","default:stick"},
|
||||
}
|
||||
})
|
||||
@ -34,26 +34,36 @@ minetest.register_tool("hook:pchest", {
|
||||
end
|
||||
local p=minetest.dir_to_facedir(user:get_look_dir())
|
||||
local item=itemstack:to_table()
|
||||
local meta=minetest.deserialize(item["metadata"])
|
||||
minetest.set_node(pointed_thing.above, {name = "hook:pchest_node",param1="",param2=p})
|
||||
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 meta==nil then
|
||||
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
|
||||
|
||||
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))
|
||||
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:take_item()
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
@ -77,10 +87,16 @@ minetest.register_node("hook:pchest_node", {
|
||||
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 owner = minetest.get_meta(pos):get_string("owner")
|
||||
if owner == player:get_player_name() or owner == "" then
|
||||
if minetest.deserialize(stack:get_metadata())~=nil then
|
||||
minetest.chat_send_player(player:get_player_name(), "Not allowed to put in items with metadata")
|
||||
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()
|
||||
@ -102,32 +118,25 @@ minetest.register_node("hook:pchest_node", {
|
||||
return 0
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
local owner = minetest.get_meta(pos):get_string("owner")
|
||||
return (owner=="" and minetest.get_meta(pos):get_inventory():is_empty("main"))
|
||||
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)
|
||||
if minetest.is_protected(pos,player:get_player_name()) then
|
||||
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 meta=minetest.get_meta(pos)
|
||||
if meta:get_string("owner")==player:get_player_name() then
|
||||
local inv=meta:get_inventory()
|
||||
local items=""
|
||||
for i=1,32,1 do
|
||||
if inv:get_stack("main",i):get_name()~="" then
|
||||
items=items .. inv:get_stack("main",i):get_name() .." " .. inv:get_stack("main",i):get_count() .. " " .. inv:get_stack("main",i):get_wear() ..","
|
||||
else
|
||||
items=items .. ","
|
||||
end
|
||||
end
|
||||
inv:add_item("trans", ItemStack("hook:pchest"))
|
||||
local item=inv:get_stack("trans",1):to_table()
|
||||
local tmeta={stuff=items}
|
||||
item.metadata=minetest.serialize(tmeta)
|
||||
item.meta=minetest.serialize(tmeta)
|
||||
player:get_inventory():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,})
|
||||
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
|
||||
})
|
@ -5,7 +5,7 @@ minetest.register_entity("hook:power",{
|
||||
visual = "mesh",
|
||||
mesh = "hook_hook.obj",
|
||||
visual_size = {x=10, y=10},
|
||||
textures = {"hook_rope.png"},
|
||||
textures = {"hook_iron.png"},
|
||||
is_visible = true,
|
||||
makes_footstep_sound = false,
|
||||
automatic_rotate = false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user