2013-07-14 13:30:03 +04:00
|
|
|
--Minetest 0.4.7 mod: concrete
|
2013-04-04 03:17:39 +04:00
|
|
|
--(c) 2013 by RealBadAngel <mk@realbadangel.pl>
|
|
|
|
|
2015-02-05 11:47:37 +03:00
|
|
|
local technic = rawget(_G, "technic") or {}
|
2013-07-17 23:34:35 +04:00
|
|
|
technic.concrete_posts = {}
|
|
|
|
|
2014-04-16 21:10:00 +04:00
|
|
|
-- Boilerplate to support localized strings if intllib mod is installed.
|
2015-02-05 12:07:38 +03:00
|
|
|
local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
|
2014-04-16 21:10:00 +04:00
|
|
|
|
2013-07-17 23:34:35 +04:00
|
|
|
minetest.register_alias("technic:concrete_post", "technic:concrete_post0")
|
|
|
|
minetest.register_alias("technic:concrete_post32", "technic:concrete_post12")
|
|
|
|
minetest.register_alias("technic:concrete_post33", "technic:concrete_post3")
|
|
|
|
minetest.register_alias("technic:concrete_post34", "technic:concrete_post28")
|
|
|
|
minetest.register_alias("technic:concrete_post35", "technic:concrete_post19")
|
|
|
|
|
split default iron/steel into three metals
Override the default mod's iron/steel substance, replacing it with three
metals: wrought iron (pure iron), carbon steel (iron alloyed with a little
carbon), and cast iron (iron alloyed with lots of carbon). Wrought iron
is easiest to refine, then cast iron, and carbon steel the most difficult,
matching the historical progression. Recipes that used default steel are
changed to use one of the three, the choice of alloy for each application
being both somewhat realistic and also matching up with game progression.
The default:steel{_ingot,block} items are identified specifically with
wrought iron. This makes the default refining recipes work appropriately.
Iron-using recipes defined outside technic are thus necessarily
reinterpreted to use wrought iron, which is mostly appropriate.
Some objects are renamed accordingly.
Rather than use the default steel textures for wrought iron, with technic
providing textures for the other two, technic now provides textures for
all three metals. This avoids problems that would occur with texture
packs that provide default_steel_{ingot,block} textures that are not
intended to support this wrought-iron/carbon-steel/cast-iron distinction.
A texture pack can provide a distinct set of three textures specifically
for the situation where this distinction is required.
Incidentally make grinding and alloy cooking recipes work correctly when
ingredients are specified by alias.
2014-05-17 01:02:49 +04:00
|
|
|
local steel_ingot
|
|
|
|
if minetest.get_modpath("technic_worldgen") then
|
|
|
|
steel_ingot = "technic:carbon_steel_ingot"
|
|
|
|
else
|
|
|
|
steel_ingot = "default:steel_ingot"
|
|
|
|
end
|
|
|
|
|
2013-04-04 03:17:39 +04:00
|
|
|
minetest.register_craft({
|
2013-07-14 13:30:03 +04:00
|
|
|
output = 'technic:rebar 6',
|
2013-04-04 03:17:39 +04:00
|
|
|
recipe = {
|
split default iron/steel into three metals
Override the default mod's iron/steel substance, replacing it with three
metals: wrought iron (pure iron), carbon steel (iron alloyed with a little
carbon), and cast iron (iron alloyed with lots of carbon). Wrought iron
is easiest to refine, then cast iron, and carbon steel the most difficult,
matching the historical progression. Recipes that used default steel are
changed to use one of the three, the choice of alloy for each application
being both somewhat realistic and also matching up with game progression.
The default:steel{_ingot,block} items are identified specifically with
wrought iron. This makes the default refining recipes work appropriately.
Iron-using recipes defined outside technic are thus necessarily
reinterpreted to use wrought iron, which is mostly appropriate.
Some objects are renamed accordingly.
Rather than use the default steel textures for wrought iron, with technic
providing textures for the other two, technic now provides textures for
all three metals. This avoids problems that would occur with texture
packs that provide default_steel_{ingot,block} textures that are not
intended to support this wrought-iron/carbon-steel/cast-iron distinction.
A texture pack can provide a distinct set of three textures specifically
for the situation where this distinction is required.
Incidentally make grinding and alloy cooking recipes work correctly when
ingredients are specified by alias.
2014-05-17 01:02:49 +04:00
|
|
|
{'','', steel_ingot},
|
|
|
|
{'',steel_ingot,''},
|
|
|
|
{steel_ingot, '', ''},
|
2013-04-04 03:17:39 +04:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
2013-07-14 13:30:03 +04:00
|
|
|
output = 'technic:concrete 5',
|
2013-04-04 03:17:39 +04:00
|
|
|
recipe = {
|
|
|
|
{'default:stone','technic:rebar','default:stone'},
|
|
|
|
{'technic:rebar','default:stone','technic:rebar'},
|
|
|
|
{'default:stone','technic:rebar','default:stone'},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
2013-07-14 13:30:03 +04:00
|
|
|
output = 'technic:concrete_post_platform 6',
|
2013-04-04 03:17:39 +04:00
|
|
|
recipe = {
|
2013-07-17 23:34:35 +04:00
|
|
|
{'technic:concrete','technic:concrete_post0','technic:concrete'},
|
2013-04-04 03:17:39 +04:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
2013-07-17 23:34:35 +04:00
|
|
|
output = 'technic:concrete_post0 12',
|
2013-04-04 03:17:39 +04:00
|
|
|
recipe = {
|
|
|
|
{'default:stone','technic:rebar','default:stone'},
|
|
|
|
{'default:stone','technic:rebar','default:stone'},
|
|
|
|
{'default:stone','technic:rebar','default:stone'},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2013-07-14 14:11:56 +04:00
|
|
|
minetest.register_craft({
|
|
|
|
output = 'technic:blast_resistant_concrete 5',
|
|
|
|
recipe = {
|
|
|
|
{'technic:concrete','technic:composite_plate','technic:concrete'},
|
|
|
|
{'technic:composite_plate','technic:concrete','technic:composite_plate'},
|
|
|
|
{'technic:concrete','technic:composite_plate','technic:concrete'},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2013-07-17 23:34:35 +04:00
|
|
|
local box_platform = {-0.5, 0.3, -0.5, 0.5, 0.5, 0.5}
|
|
|
|
local box_center = {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15}
|
|
|
|
local box_x1 = {0, -0.3, -0.1, 0.5, 0.3, 0.1}
|
|
|
|
local box_z1 = {-0.1, -0.3, 0, 0.1, 0.3, 0.5}
|
|
|
|
local box_x2 = {0, -0.3, -0.1, -0.5, 0.3, 0.1}
|
|
|
|
local box_z2 = {-0.1, -0.3, 0, 0.1, 0.3, -0.5}
|
2013-04-04 03:17:39 +04:00
|
|
|
|
|
|
|
minetest.register_craftitem(":technic:rebar", {
|
2014-04-16 21:10:00 +04:00
|
|
|
description = S("Rebar"),
|
2013-04-04 03:17:39 +04:00
|
|
|
inventory_image = "technic_rebar.png",
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node(":technic:concrete", {
|
2014-04-16 21:10:00 +04:00
|
|
|
description = S("Concrete Block"),
|
2015-10-02 20:45:39 +03:00
|
|
|
tiles = {"technic_concrete_block.png",},
|
2013-07-17 23:34:35 +04:00
|
|
|
groups = {cracky=1, level=2, concrete=1},
|
2013-04-04 03:17:39 +04:00
|
|
|
sounds = default.node_sound_stone_defaults(),
|
2013-07-17 23:34:35 +04:00
|
|
|
after_place_node = function(pos, placer, itemstack)
|
|
|
|
technic.update_posts(pos, false)
|
2013-04-04 03:17:39 +04:00
|
|
|
end,
|
|
|
|
after_dig_node = function (pos, oldnode, oldmetadata, digger)
|
2013-07-17 23:34:35 +04:00
|
|
|
technic.update_posts(pos, false)
|
2013-04-04 03:17:39 +04:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
2013-07-14 14:11:56 +04:00
|
|
|
minetest.register_node(":technic:blast_resistant_concrete", {
|
2014-04-16 21:10:00 +04:00
|
|
|
description = S("Blast-resistant Concrete Block"),
|
2015-10-02 20:45:39 +03:00
|
|
|
tiles = {"technic_blast_resistant_concrete_block.png",},
|
2013-07-17 23:34:35 +04:00
|
|
|
groups={cracky=1, level=3, concrete=1},
|
2013-07-14 14:11:56 +04:00
|
|
|
sounds = default.node_sound_stone_defaults(),
|
2013-07-17 23:34:35 +04:00
|
|
|
after_place_node = function(pos, player, itemstack)
|
|
|
|
technic.update_posts(pos, false)
|
2013-07-14 14:11:56 +04:00
|
|
|
end,
|
|
|
|
after_dig_node = function (pos, oldnode, oldmetadata, digger)
|
2013-07-17 23:34:35 +04:00
|
|
|
technic.update_posts(pos, false)
|
2013-07-14 14:11:56 +04:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
2013-04-04 03:17:39 +04:00
|
|
|
minetest.register_node(":technic:concrete_post_platform", {
|
2014-04-16 21:10:00 +04:00
|
|
|
description = S("Concrete Post Platform"),
|
2015-10-02 20:45:39 +03:00
|
|
|
tiles = {"technic_concrete_block.png",},
|
2013-07-17 23:34:35 +04:00
|
|
|
groups={cracky=1, level=2},
|
2013-04-04 03:17:39 +04:00
|
|
|
sounds = default.node_sound_stone_defaults(),
|
|
|
|
paramtype = "light",
|
|
|
|
drawtype = "nodebox",
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
2013-07-17 23:34:35 +04:00
|
|
|
fixed = {box_platform}
|
|
|
|
},
|
|
|
|
on_place = function (itemstack, placer, pointed_thing)
|
|
|
|
local node = minetest.get_node(pointed_thing.under)
|
|
|
|
if not technic.concrete_posts[node.name] then
|
|
|
|
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
|
|
|
end
|
|
|
|
local links = technic.concrete_posts[node.name]
|
2014-08-29 03:26:25 +04:00
|
|
|
if links[6] ~= 0 then -- The post already has a platform
|
2013-07-17 23:34:35 +04:00
|
|
|
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
|
|
|
end
|
2014-08-29 03:26:25 +04:00
|
|
|
local id = technic.get_post_id({links[1], links[2], links[3], links[4], links[5], 1})
|
2013-07-17 23:34:35 +04:00
|
|
|
minetest.set_node(pointed_thing.under, {name="technic:concrete_post"..id})
|
|
|
|
itemstack:take_item()
|
|
|
|
placer:set_wielded_item(itemstack)
|
|
|
|
return itemstack
|
2013-04-04 03:17:39 +04:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
2014-08-29 03:26:25 +04:00
|
|
|
local function gen_post_nodebox(x1, x2, z1, z2, y, platform)
|
|
|
|
local box
|
|
|
|
local xx = x1 + x2
|
|
|
|
local zz = z1 + z2
|
|
|
|
if ((xx == 2 and zz == 0) or (xx == 0 and zz == 2)) and y == 0 then
|
|
|
|
box = {}
|
|
|
|
else
|
|
|
|
box = {box_center}
|
|
|
|
end
|
2013-07-17 23:34:35 +04:00
|
|
|
if x1 ~= 0 then
|
|
|
|
table.insert(box, box_x1)
|
|
|
|
end
|
|
|
|
if x2 ~= 0 then
|
|
|
|
table.insert(box, box_x2)
|
|
|
|
end
|
|
|
|
if z1 ~= 0 then
|
|
|
|
table.insert(box, box_z1)
|
|
|
|
end
|
|
|
|
if z2 ~= 0 then
|
|
|
|
table.insert(box, box_z2)
|
|
|
|
end
|
|
|
|
if platform ~= 0 then
|
|
|
|
table.insert(box, box_platform)
|
|
|
|
end
|
|
|
|
return box
|
|
|
|
end
|
2013-04-04 03:17:39 +04:00
|
|
|
|
2013-07-17 23:34:35 +04:00
|
|
|
local function dig_post_with_platform(pos, oldnode, oldmetadata)
|
|
|
|
oldnode.name = "technic:concrete_post0"
|
|
|
|
minetest.set_node(pos, oldnode)
|
|
|
|
technic.update_posts(pos, true)
|
|
|
|
end
|
2013-04-04 03:17:39 +04:00
|
|
|
|
2013-07-17 23:34:35 +04:00
|
|
|
function technic.posts_should_connect(pos)
|
|
|
|
local node = minetest.get_node(pos)
|
|
|
|
if technic.concrete_posts[node.name] then
|
|
|
|
return "post"
|
|
|
|
elseif minetest.get_item_group(node.name, "concrete") ~= 0 then
|
|
|
|
return "block"
|
|
|
|
end
|
|
|
|
end
|
2013-04-04 03:17:39 +04:00
|
|
|
|
2013-07-17 23:34:35 +04:00
|
|
|
function technic.get_post_id(links)
|
2014-08-29 03:26:25 +04:00
|
|
|
return (links[1] * 1) + (links[2] * 2)
|
|
|
|
+ (links[3] * 4) + (links[4] * 8)
|
|
|
|
+ (links[5] * 16) + (links[6] * 32)
|
2013-07-17 23:34:35 +04:00
|
|
|
end
|
2013-04-04 03:17:39 +04:00
|
|
|
|
2013-07-17 23:34:35 +04:00
|
|
|
function technic.update_posts(pos, set, secondrun)
|
|
|
|
local node = minetest.get_node(pos)
|
|
|
|
local link_positions = {
|
|
|
|
{x=pos.x+1, y=pos.y, z=pos.z},
|
|
|
|
{x=pos.x-1, y=pos.y, z=pos.z},
|
|
|
|
{x=pos.x, y=pos.y, z=pos.z+1},
|
|
|
|
{x=pos.x, y=pos.y, z=pos.z-1},
|
2014-08-29 03:26:25 +04:00
|
|
|
{x=pos.x, y=pos.y-1, z=pos.z},
|
|
|
|
{x=pos.x, y=pos.y+1, z=pos.z},
|
2013-07-17 23:34:35 +04:00
|
|
|
}
|
2013-04-04 03:17:39 +04:00
|
|
|
|
2014-08-29 03:26:25 +04:00
|
|
|
local links = {0, 0, 0, 0, 0, 0}
|
2013-07-17 23:34:35 +04:00
|
|
|
|
|
|
|
for i, link_pos in pairs(link_positions) do
|
|
|
|
local connecttype = technic.posts_should_connect(link_pos)
|
|
|
|
if connecttype then
|
|
|
|
links[i] = 1
|
|
|
|
-- Have posts next to us update theirselves,
|
|
|
|
-- but only once. (We don't want to start an
|
|
|
|
-- infinite loop of updates)
|
|
|
|
if not secondrun and connecttype == "post" then
|
|
|
|
technic.update_posts(link_pos, true, true)
|
|
|
|
end
|
2013-04-04 03:17:39 +04:00
|
|
|
end
|
2013-07-17 23:34:35 +04:00
|
|
|
end
|
2014-08-29 03:26:25 +04:00
|
|
|
|
|
|
|
if links[5] == 1 or links[6] == 1 then
|
|
|
|
links[5] = 1
|
|
|
|
links[6] = 0
|
|
|
|
end
|
|
|
|
|
2013-07-17 23:34:35 +04:00
|
|
|
-- We don't want to set ourselves if we have been removed or we are
|
|
|
|
-- updating a concrete node
|
|
|
|
if set then
|
|
|
|
-- Preserve platform
|
|
|
|
local oldlinks = technic.concrete_posts[node.name]
|
|
|
|
if oldlinks then
|
2014-08-29 03:26:25 +04:00
|
|
|
links[6] = oldlinks[6]
|
2013-04-04 03:17:39 +04:00
|
|
|
end
|
2013-07-17 23:34:35 +04:00
|
|
|
minetest.set_node(pos, {name="technic:concrete_post"
|
|
|
|
..technic.get_post_id(links)})
|
2013-07-14 13:30:03 +04:00
|
|
|
end
|
2013-04-04 03:17:39 +04:00
|
|
|
end
|
|
|
|
|
2013-07-17 23:34:35 +04:00
|
|
|
for x1 = 0, 1 do
|
|
|
|
for x2 = 0, 1 do
|
|
|
|
for z1 = 0, 1 do
|
|
|
|
for z2 = 0, 1 do
|
2014-08-29 03:26:25 +04:00
|
|
|
for y = 0, 1 do
|
2013-07-17 23:34:35 +04:00
|
|
|
for platform = 0, 1 do
|
2014-08-29 03:26:25 +04:00
|
|
|
local links = {x1, x2, z1, z2, y, platform}
|
2013-07-17 23:34:35 +04:00
|
|
|
local id = technic.get_post_id(links)
|
|
|
|
technic.concrete_posts["technic:concrete_post"..id] = links
|
|
|
|
|
|
|
|
local groups = {cracky=1, level=2, concrete_post=1}
|
|
|
|
if id ~= 0 then
|
|
|
|
groups.not_in_creative_inventory = 1
|
2013-04-04 03:17:39 +04:00
|
|
|
end
|
2013-07-17 23:34:35 +04:00
|
|
|
|
|
|
|
local drop = "technic:concrete_post0"
|
|
|
|
local after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
|
|
|
technic.update_posts(pos, false)
|
|
|
|
end
|
|
|
|
if platform ~= 0 then
|
|
|
|
drop = "technic:concrete_post_platform"
|
|
|
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
|
|
|
dig_post_with_platform(pos, oldnode, oldmetadata)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_node(":technic:concrete_post"..id, {
|
2014-04-16 21:10:00 +04:00
|
|
|
description = S("Concrete Post"),
|
2013-07-17 23:34:35 +04:00
|
|
|
tiles = {"technic_concrete_block.png"},
|
|
|
|
groups = groups,
|
|
|
|
sounds = default.node_sound_stone_defaults(),
|
|
|
|
drop = drop,
|
|
|
|
paramtype = "light",
|
|
|
|
sunlight_propagates = true,
|
|
|
|
drawtype = "nodebox",
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
2014-08-29 03:26:25 +04:00
|
|
|
fixed = gen_post_nodebox(x1, x2, z1, z2, y, platform),
|
2013-07-17 23:34:35 +04:00
|
|
|
},
|
|
|
|
after_place_node = function(pos, placer, itemstack)
|
|
|
|
technic.update_posts(pos, true)
|
|
|
|
end,
|
|
|
|
after_dig_node = after_dig_node,
|
|
|
|
})
|
|
|
|
end
|
2013-04-04 03:17:39 +04:00
|
|
|
end
|
2013-07-17 23:34:35 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-08-29 03:26:25 +04:00
|
|
|
end
|
2013-07-17 23:34:35 +04:00
|
|
|
|