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)
|
itemstack:set_wear(9999999)
|
||||||
end
|
end
|
||||||
user:get_inventory():remove_item("main", item)
|
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
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -99,7 +99,6 @@ minetest.register_globalstep(function(dtime)
|
|||||||
t.ob:set_acceleration({x=0, y=-10,z=0})
|
t.ob:set_acceleration({x=0, y=-10,z=0})
|
||||||
t.ob:set_velocity({x=0, y=-10, z=0})
|
t.ob:set_velocity({x=0, y=-10, z=0})
|
||||||
table.remove(hook.tmp_throw,i)
|
table.remove(hook.tmp_throw,i)
|
||||||
minetest.sound_play("hook_hard_punch", {pos=ob:get_pos(), gain = 1.0, max_hear_distance = 5,})
|
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -121,7 +120,6 @@ end
|
|||||||
|
|
||||||
minetest.register_tool("hook:hook", {
|
minetest.register_tool("hook:hook", {
|
||||||
description = "Hook with rope (hit a corner to climb)",
|
description = "Hook with rope (hit a corner to climb)",
|
||||||
range = 2,
|
|
||||||
inventory_image = "hook_hook.png",
|
inventory_image = "hook_hook.png",
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
if pointed_thing.type~="node" then return itemstack end
|
if pointed_thing.type~="node" then return itemstack end
|
||||||
@ -155,12 +153,12 @@ minetest.register_tool("hook:hook", {
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool("hook:hook_upgrade", {
|
minetest.register_tool("hook:hook_upgrade", {
|
||||||
description = "Hook with rope (double)",
|
description = "Hook with rope (double)",
|
||||||
range = 5,
|
range = 6,
|
||||||
inventory_image = "hook_hookup.png",
|
inventory_image = "hook_hookup.png",
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
if pointed_thing.type~="node" then return itemstack end
|
if pointed_thing.type~="node" then return itemstack end
|
||||||
@ -193,7 +191,7 @@ minetest.register_tool("hook:hook_upgrade", {
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool("hook:climb_rope", {
|
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")
|
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_velocity({x=d.x*15, y=d.y*15, z=d.z*15})
|
||||||
m:set_acceleration({x=0, y=-5, z=0})
|
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
|
return itemstack
|
||||||
else
|
else
|
||||||
local pos=pointed_thing.under
|
local pos=pointed_thing.under
|
||||||
@ -234,7 +233,7 @@ minetest.register_tool("hook:climb_rope", {
|
|||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
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")
|
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_velocity({x=d.x*15, y=d.y*15, z=d.z*15})
|
||||||
m:set_acceleration({x=0, y=-5, z=0})
|
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
|
return itemstack
|
||||||
else
|
else
|
||||||
local pos=pointed_thing.under
|
local pos=pointed_thing.under
|
||||||
@ -281,7 +281,7 @@ minetest.register_tool("hook:climb_rope_locked", {
|
|||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
end,
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -319,6 +319,7 @@ minetest.register_node("hook:rope", {
|
|||||||
minetest.set_node(pos, {name = "air"})
|
minetest.set_node(pos, {name = "air"})
|
||||||
return false
|
return false
|
||||||
end,
|
end,
|
||||||
|
sounds = {footstep = {name = "hook_rope", gain = 1}}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("hook:rope2", {
|
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
|
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
|
||||||
end,
|
end,
|
||||||
|
sounds = {footstep = {name = "hook_rope", gain = 1}}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("hook:rope3", {
|
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
|
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
|
||||||
end,
|
end,
|
||||||
|
sounds = {footstep = {name = "hook_rope", gain = 1}}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("hook:hooking", {
|
minetest.register_node("hook:hooking", {
|
||||||
description = "Hooking",
|
description = "Hooking",
|
||||||
drawtype = "mesh",
|
drawtype = "mesh",
|
||||||
mesh="hook_hook.obj",
|
mesh="hook_hook.obj",
|
||||||
tiles = {"hook_rope.png"},
|
tiles = {"hook_iron.png"},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
walkable=false,
|
walkable=false,
|
||||||
@ -423,7 +426,7 @@ minetest.register_node("hook:hooking", {
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end,
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
83
pchest.lua
83
pchest.lua
@ -4,7 +4,7 @@ minetest.register_craft({
|
|||||||
output = "hook:pchest",
|
output = "hook:pchest",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"default:stick","default:stick","default:stick"},
|
{"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"},
|
{"default:stick","default:stick","default:stick"},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -34,26 +34,36 @@ minetest.register_tool("hook:pchest", {
|
|||||||
end
|
end
|
||||||
local p=minetest.dir_to_facedir(user:get_look_dir())
|
local p=minetest.dir_to_facedir(user:get_look_dir())
|
||||||
local item=itemstack:to_table()
|
local item=itemstack:to_table()
|
||||||
local meta=minetest.deserialize(item["metadata"])
|
|
||||||
minetest.set_node(pointed_thing.above, {name = "hook:pchest_node",param1="",param2=p})
|
minetest.set_node(pointed_thing.above, {name = "hook:pchest_node",param1="",param2=p})
|
||||||
pchest.setpchest(pointed_thing.above,user)
|
pchest.setpchest(pointed_thing.above,user)
|
||||||
|
|
||||||
minetest.sound_play("default_place_node_hard", {pos=pointed_thing.above, gain = 1.0, max_hear_distance = 5,})
|
minetest.sound_play("default_place_node_hard", {pos=pointed_thing.above, gain = 1.0, max_hear_distance = 5})
|
||||||
if meta==nil then
|
|
||||||
|
if not (item.meta or item.metadata) then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
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
|
minetest.get_meta(pointed_thing.above):get_inventory():set_list("main",items)
|
||||||
local its=meta.stuff.split(meta.stuff,",",",")
|
elseif item.metadata ~= "" then
|
||||||
local nmeta=minetest.get_meta(pointed_thing.above)
|
local meta=minetest.deserialize(item["metadata"])
|
||||||
for i,it in pairs(its) do
|
local s=meta.stuff
|
||||||
if its~="" then
|
local its=meta.stuff.split(meta.stuff,",",",")
|
||||||
nmeta:get_inventory():set_stack("main",i, ItemStack(it))
|
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
|
||||||
end
|
end
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
return itemstack:take_item()
|
return itemstack
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -77,10 +87,16 @@ minetest.register_node("hook:pchest_node", {
|
|||||||
input_inventory = "main",
|
input_inventory = "main",
|
||||||
connect_sides = {left = 1, right = 1, front = 1, back = 1, top = 1, bottom = 1}},
|
connect_sides = {left = 1, right = 1, front = 1, back = 1, top = 1, bottom = 1}},
|
||||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
local owner = minetest.get_meta(pos):get_string("owner")
|
local m = minetest.get_meta(pos)
|
||||||
if owner == player:get_player_name() or owner == "" then
|
local owner = m:get_string("owner")
|
||||||
if minetest.deserialize(stack:get_metadata())~=nil then
|
local inv = m:get_inventory()
|
||||||
minetest.chat_send_player(player:get_player_name(), "Not allowed to put in items with metadata")
|
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
|
return 0
|
||||||
end
|
end
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
@ -102,32 +118,25 @@ minetest.register_node("hook:pchest_node", {
|
|||||||
return 0
|
return 0
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos, player)
|
can_dig = function(pos, player)
|
||||||
local owner = minetest.get_meta(pos):get_string("owner")
|
local m = minetest.get_meta(pos)
|
||||||
return (owner=="" and minetest.get_meta(pos):get_inventory():is_empty("main"))
|
return m:get_string("owner") == "" and m:get_inventory():is_empty("main")
|
||||||
end,
|
end,
|
||||||
on_punch = function(pos, node, player, pointed_thing)
|
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
|
return false
|
||||||
end
|
end
|
||||||
local meta=minetest.get_meta(pos)
|
local inv=meta:get_inventory()
|
||||||
if meta:get_string("owner")==player:get_player_name() then
|
local items = {}
|
||||||
local inv=meta:get_inventory()
|
for i,v in pairs(inv:get_list("main")) do
|
||||||
local items=""
|
table.insert(items,v:to_table())
|
||||||
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,})
|
|
||||||
end
|
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
|
end
|
||||||
})
|
})
|
@ -5,7 +5,7 @@ minetest.register_entity("hook:power",{
|
|||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "hook_hook.obj",
|
mesh = "hook_hook.obj",
|
||||||
visual_size = {x=10, y=10},
|
visual_size = {x=10, y=10},
|
||||||
textures = {"hook_rope.png"},
|
textures = {"hook_iron.png"},
|
||||||
is_visible = true,
|
is_visible = true,
|
||||||
makes_footstep_sound = false,
|
makes_footstep_sound = false,
|
||||||
automatic_rotate = false,
|
automatic_rotate = false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user