mirror of
https://github.com/minetest-mods/ropes.git
synced 2024-11-24 08:23:47 +01:00
parent
922cc1b6aa
commit
cc543689d0
11
bridge.lua
11
bridge.lua
@ -9,10 +9,10 @@ local bridge_on_place = function(itemstack, placer, pointed_thing)
|
|||||||
if placer == nil then
|
if placer == nil then
|
||||||
return minetest.item_place(itemstack, placer, pointed_thing)
|
return minetest.item_place(itemstack, placer, pointed_thing)
|
||||||
end
|
end
|
||||||
|
|
||||||
local above = pointed_thing.above
|
local above = pointed_thing.above
|
||||||
local under = pointed_thing.under
|
local under = pointed_thing.under
|
||||||
|
|
||||||
if above.x == under.x and above.z == under.z and above.y > under.y then
|
if above.x == under.x and above.z == under.z and above.y > under.y then
|
||||||
-- we're aimed downward at a buildable node from above.
|
-- we're aimed downward at a buildable node from above.
|
||||||
-- determine the direction the placer lies relative to this node.
|
-- determine the direction the placer lies relative to this node.
|
||||||
@ -26,21 +26,21 @@ local bridge_on_place = function(itemstack, placer, pointed_thing)
|
|||||||
new_under.x = under.x - 1
|
new_under.x = under.x - 1
|
||||||
else
|
else
|
||||||
new_under.x = under.x + 1
|
new_under.x = under.x + 1
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- placer is displaced along the Z axis relative to the target
|
-- placer is displaced along the Z axis relative to the target
|
||||||
if diff_z > 0 then
|
if diff_z > 0 then
|
||||||
new_under.z = under.z - 1
|
new_under.z = under.z - 1
|
||||||
else
|
else
|
||||||
new_under.z = under.z + 1
|
new_under.z = under.z + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if minetest.registered_nodes[minetest.get_node(new_under).name].buildable_to then
|
if minetest.registered_nodes[minetest.get_node(new_under).name].buildable_to then
|
||||||
local new_pointed_thing = {type="node", under=new_under, above={x=new_under.x, y=new_under.y+1, z=new_under.z}}
|
local new_pointed_thing = {type="node", under=new_under, above={x=new_under.x, y=new_under.y+1, z=new_under.z}}
|
||||||
return minetest.item_place(itemstack, placer, new_pointed_thing)
|
return minetest.item_place(itemstack, placer, new_pointed_thing)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return minetest.item_place(itemstack, placer, pointed_thing)
|
return minetest.item_place(itemstack, placer, pointed_thing)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -56,6 +56,7 @@ minetest.register_node("ropes:wood_bridge", {
|
|||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
|
is_ground_content = false,
|
||||||
groups = {choppy = 2, flammable = 2, oddly_breakable_by_hand = 1, flow_through = 1, fence = 1, wall = 1},
|
groups = {choppy = 2, flammable = 2, oddly_breakable_by_hand = 1, flow_through = 1, fence = 1, wall = 1},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
node_box = {
|
node_box = {
|
||||||
|
@ -24,7 +24,7 @@ local rope_box_data = {
|
|||||||
--selection = {-0.1875, -0.5, -0.25, 0.1875, 0.25, 0.25}, -- selection
|
--selection = {-0.1875, -0.5, -0.25, 0.1875, 0.25, 0.25}, -- selection
|
||||||
tiles = 1,
|
tiles = 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
node={
|
node={
|
||||||
{-0.1875, -0.125, -0.25, 0.1875, 0.125, 0.25}, -- pulley
|
{-0.1875, -0.125, -0.25, 0.1875, 0.125, 0.25}, -- pulley
|
||||||
{-0.1875, -0.25, -0.125, 0.1875, 0.25, 0.125}, -- pulley
|
{-0.1875, -0.25, -0.125, 0.1875, 0.25, 0.125}, -- pulley
|
||||||
@ -35,7 +35,7 @@ local rope_box_data = {
|
|||||||
--selection = {-0.1875, -0.5, -0.25, 0.1875, 0.25, 0.25}, -- selection
|
--selection = {-0.1875, -0.5, -0.25, 0.1875, 0.25, 0.25}, -- selection
|
||||||
tiles = 2,
|
tiles = 2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
node={
|
node={
|
||||||
{-0.25, -0.125, -0.25, 0.25, 0.125, 0.25}, -- pulley
|
{-0.25, -0.125, -0.25, 0.25, 0.125, 0.25}, -- pulley
|
||||||
{-0.25, -0.25, -0.125, 0.25, 0.25, 0.125}, -- pulley
|
{-0.25, -0.25, -0.125, 0.25, 0.25, 0.125}, -- pulley
|
||||||
@ -46,7 +46,7 @@ local rope_box_data = {
|
|||||||
--selection = {-0.3125, -0.5, -0.25, 0.3125, 0.25, 0.25}, -- selection
|
--selection = {-0.3125, -0.5, -0.25, 0.3125, 0.25, 0.25}, -- selection
|
||||||
tiles = 3,
|
tiles = 3,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
node={
|
node={
|
||||||
{-0.3125, -0.125, -0.25, 0.3125, 0.125, 0.25}, -- pulley
|
{-0.3125, -0.125, -0.25, 0.3125, 0.125, 0.25}, -- pulley
|
||||||
{-0.3125, -0.25, -0.125, 0.3125, 0.25, 0.125}, -- pulley
|
{-0.3125, -0.25, -0.125, 0.3125, 0.25, 0.125}, -- pulley
|
||||||
@ -57,7 +57,7 @@ local rope_box_data = {
|
|||||||
--selection = {-0.375, -0.5, -0.25, 0.375, 0.25, 0.25}, -- selection
|
--selection = {-0.375, -0.5, -0.25, 0.375, 0.25, 0.25}, -- selection
|
||||||
tiles = 4,
|
tiles = 4,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
node={
|
node={
|
||||||
{-0.375, -0.125, -0.25, 0.375, 0.125, 0.25}, -- pulley
|
{-0.375, -0.125, -0.25, 0.375, 0.125, 0.25}, -- pulley
|
||||||
{-0.375, -0.25, -0.125, 0.375, 0.25, 0.125}, -- pulley
|
{-0.375, -0.25, -0.125, 0.375, 0.25, 0.125}, -- pulley
|
||||||
@ -79,7 +79,7 @@ local rope_box_data = {
|
|||||||
--selection = {-0.1875, -0.5, -0.3125, 0.1875, 0.3125, 0.3125}, -- selection
|
--selection = {-0.1875, -0.5, -0.3125, 0.1875, 0.3125, 0.3125}, -- selection
|
||||||
tiles = 2,
|
tiles = 2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
node={
|
node={
|
||||||
{-0.25, -0.1875, -0.3125, 0.25, 0.1875, 0.3125}, -- pulley
|
{-0.25, -0.1875, -0.3125, 0.25, 0.1875, 0.3125}, -- pulley
|
||||||
{-0.25, -0.3125, -0.1875, 0.25, 0.3125, 0.1875}, -- pulley
|
{-0.25, -0.3125, -0.1875, 0.25, 0.3125, 0.1875}, -- pulley
|
||||||
@ -90,7 +90,7 @@ local rope_box_data = {
|
|||||||
--selection = {-0.3125, -0.5, -0.3125, 0.3125, 0.3125, 0.3125}, -- selection
|
--selection = {-0.3125, -0.5, -0.3125, 0.3125, 0.3125, 0.3125}, -- selection
|
||||||
tiles = 3,
|
tiles = 3,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
node={
|
node={
|
||||||
{-0.3125, -0.1875, -0.3125, 0.3125, 0.1875, 0.3125}, -- pulley
|
{-0.3125, -0.1875, -0.3125, 0.3125, 0.1875, 0.3125}, -- pulley
|
||||||
{-0.3125, -0.3125, -0.1875, 0.3125, 0.3125, 0.1875}, -- pulley
|
{-0.3125, -0.3125, -0.1875, 0.3125, 0.3125, 0.1875}, -- pulley
|
||||||
@ -101,7 +101,7 @@ local rope_box_data = {
|
|||||||
--selection = {-0.375, -0.5, -0.3125, 0.375, 0.3125, 0.3125}, -- selection
|
--selection = {-0.375, -0.5, -0.3125, 0.375, 0.3125, 0.3125}, -- selection
|
||||||
tiles = 4,
|
tiles = 4,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
node={
|
node={
|
||||||
{-0.375, -0.1875, -0.3125, 0.375, 0.1875, 0.3125}, -- pulley
|
{-0.375, -0.1875, -0.3125, 0.375, 0.1875, 0.3125}, -- pulley
|
||||||
{-0.375, -0.3125, -0.1875, 0.375, 0.3125, 0.1875}, -- pulley
|
{-0.375, -0.3125, -0.1875, 0.375, 0.3125, 0.1875}, -- pulley
|
||||||
@ -127,6 +127,7 @@ local function register_rope_block(multiple, max_multiple, name_prefix, node_pre
|
|||||||
climbable = true,
|
climbable = true,
|
||||||
tiles = rope_box_tiles(rope_box_data[multiple].tiles, tint),
|
tiles = rope_box_tiles(rope_box_data[multiple].tiles, tint),
|
||||||
use_texture_alpha = "clip",
|
use_texture_alpha = "clip",
|
||||||
|
is_ground_content = false,
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = rope_box_data[multiple].node
|
fixed = rope_box_data[multiple].node
|
||||||
@ -134,7 +135,7 @@ local function register_rope_block(multiple, max_multiple, name_prefix, node_pre
|
|||||||
selection_box = {type="regular"},
|
selection_box = {type="regular"},
|
||||||
collision_box = {type="regular"},
|
collision_box = {type="regular"},
|
||||||
groups = {attached_node = 1, choppy=2, oddly_breakable_by_hand=1, rope_block = 1},
|
groups = {attached_node = 1, choppy=2, oddly_breakable_by_hand=1, rope_block = 1},
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
if pointed_thing.type == "node" then
|
if pointed_thing.type == "node" then
|
||||||
local target_node = minetest.get_node(pointed_thing.under)
|
local target_node = minetest.get_node(pointed_thing.under)
|
||||||
@ -145,15 +146,15 @@ local function register_rope_block(multiple, max_multiple, name_prefix, node_pre
|
|||||||
end
|
end
|
||||||
return minetest.item_place(itemstack, placer, pointed_thing)
|
return minetest.item_place(itemstack, placer, pointed_thing)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
local pos_below = {x=pos.x, y=pos.y-1, z=pos.z}
|
local pos_below = {x=pos.x, y=pos.y-1, z=pos.z}
|
||||||
local placer_name = placer:get_player_name()
|
local placer_name = placer:get_player_name()
|
||||||
|
|
||||||
if minetest.is_protected(pos_below, placer_name) and not minetest.check_player_privs(placer, "protection_bypass") then
|
if minetest.is_protected(pos_below, placer_name) and not minetest.check_player_privs(placer, "protection_bypass") then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local node_below = minetest.get_node(pos_below)
|
local node_below = minetest.get_node(pos_below)
|
||||||
if ropes.can_place_rope_in_node(node_below.name) then
|
if ropes.can_place_rope_in_node(node_below.name) then
|
||||||
minetest.add_node(pos_below, {name="ropes:rope_bottom"})
|
minetest.add_node(pos_below, {name="ropes:rope_bottom"})
|
||||||
@ -162,13 +163,13 @@ local function register_rope_block(multiple, max_multiple, name_prefix, node_pre
|
|||||||
meta:set_string("placer", placer:get_player_name())
|
meta:set_string("placer", placer:get_player_name())
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
after_destruct = function(pos)
|
after_destruct = function(pos)
|
||||||
local pos_below = {x=pos.x, y=pos.y-1, z=pos.z}
|
local pos_below = {x=pos.x, y=pos.y-1, z=pos.z}
|
||||||
ropes.destroy_rope(pos_below, {'ropes:rope', 'ropes:rope_bottom'})
|
ropes.destroy_rope(pos_below, {'ropes:rope', 'ropes:rope_bottom'})
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
-- If this number is higher than permitted, we still want to register the block (in case
|
-- If this number is higher than permitted, we still want to register the block (in case
|
||||||
-- some were already placed in-world) but we want to hide it from creative inventory
|
-- some were already placed in-world) but we want to hide it from creative inventory
|
||||||
-- and if someone digs it we want to disintegrate it into its component parts to prevent
|
-- and if someone digs it we want to disintegrate it into its component parts to prevent
|
||||||
@ -177,19 +178,19 @@ local function register_rope_block(multiple, max_multiple, name_prefix, node_pre
|
|||||||
rope_block_def.groups.not_in_creative_inventory = 1
|
rope_block_def.groups.not_in_creative_inventory = 1
|
||||||
rope_block_def.drop = string.format("ropes:%s1rope_block %i", node_prefix, multiple)
|
rope_block_def.drop = string.format("ropes:%s1rope_block %i", node_prefix, multiple)
|
||||||
end
|
end
|
||||||
|
|
||||||
if flammable then
|
if flammable then
|
||||||
rope_block_def.groups.flammable = flammable
|
rope_block_def.groups.flammable = flammable
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "fuel",
|
type = "fuel",
|
||||||
recipe = node_name,
|
recipe = node_name,
|
||||||
burntime = ropes.rope_burn_time * multiple + ropes.wood_burn_time,
|
burntime = ropes.rope_burn_time * multiple + ropes.wood_burn_time,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node(node_name, rope_block_def)
|
minetest.register_node(node_name, rope_block_def)
|
||||||
|
|
||||||
if (multiple ~= 1) then
|
if (multiple ~= 1) then
|
||||||
-- Only register a recipe to craft this if it's within the permitted multiple range
|
-- Only register a recipe to craft this if it's within the permitted multiple range
|
||||||
if multiple <= max_multiple then
|
if multiple <= max_multiple then
|
||||||
@ -205,7 +206,7 @@ local function register_rope_block(multiple, max_multiple, name_prefix, node_pre
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Always allow players to disintegrate this into component parts, in case
|
-- Always allow players to disintegrate this into component parts, in case
|
||||||
-- there were some in inventory and the setting was changed.
|
-- there were some in inventory and the setting was changed.
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
@ -219,7 +220,7 @@ local function register_rope_block(multiple, max_multiple, name_prefix, node_pre
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("doc") then
|
if minetest.get_modpath("doc") then
|
||||||
doc.add_entry_alias("nodes", "ropes:rope", "nodes", node_name)
|
doc.add_entry_alias("nodes", "ropes:rope", "nodes", node_name)
|
||||||
end
|
end
|
||||||
@ -236,6 +237,7 @@ local rope_def = {
|
|||||||
drop = "",
|
drop = "",
|
||||||
tiles = { "ropes_3.png", "ropes_3.png", "ropes_3.png", "ropes_3.png", "ropes_5.png", "ropes_5.png" },
|
tiles = { "ropes_3.png", "ropes_3.png", "ropes_3.png", "ropes_3.png", "ropes_5.png", "ropes_5.png" },
|
||||||
use_texture_alpha = "clip",
|
use_texture_alpha = "clip",
|
||||||
|
is_ground_content = false,
|
||||||
groups = {choppy=2, flammable=2, not_in_creative_inventory=1},
|
groups = {choppy=2, flammable=2, not_in_creative_inventory=1},
|
||||||
sounds = {
|
sounds = {
|
||||||
footstep = {name = "ropes_creak", gain = 0.8, max_hear_distance = 6},
|
footstep = {name = "ropes_creak", gain = 0.8, max_hear_distance = 6},
|
||||||
@ -271,6 +273,7 @@ local rope_bottom_def = {
|
|||||||
drop = "",
|
drop = "",
|
||||||
tiles = { "ropes_3.png", "ropes_3.png", "ropes_3.png", "ropes_3.png", "ropes_5.png", "ropes_5.png" },
|
tiles = { "ropes_3.png", "ropes_3.png", "ropes_3.png", "ropes_3.png", "ropes_5.png", "ropes_5.png" },
|
||||||
use_texture_alpha = "clip",
|
use_texture_alpha = "clip",
|
||||||
|
is_ground_content = false,
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
groups = {choppy=2, flammable=2, not_in_creative_inventory=1},
|
groups = {choppy=2, flammable=2, not_in_creative_inventory=1},
|
||||||
sounds = {
|
sounds = {
|
||||||
@ -292,14 +295,14 @@ local rope_bottom_def = {
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-1/8, -1/2, -1/8, 1/8, 1/2, 1/8},
|
fixed = {-1/8, -1/2, -1/8, 1/8, 1/2, 1/8},
|
||||||
},
|
},
|
||||||
|
|
||||||
on_construct = function( pos )
|
on_construct = function( pos )
|
||||||
local timer = minetest.get_node_timer( pos )
|
local timer = minetest.get_node_timer( pos )
|
||||||
timer:start( 1 )
|
timer:start( 1 )
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_timer = rope_extension_timer,
|
on_timer = rope_extension_timer,
|
||||||
|
|
||||||
after_destruct = function(pos)
|
after_destruct = function(pos)
|
||||||
ropes.hanging_after_destruct(pos, "ropes:rope_top", "ropes:rope", "ropes:rope_bottom")
|
ropes.hanging_after_destruct(pos, "ropes:rope_top", "ropes:rope", "ropes:rope_bottom")
|
||||||
end,
|
end,
|
||||||
|
Loading…
Reference in New Issue
Block a user