gate and door blocks added

This commit is contained in:
Joachim Stolberg 2019-08-25 21:16:42 +02:00
parent 2721fc72cd
commit 5561798818
7 changed files with 263 additions and 6 deletions

View File

@ -16,7 +16,7 @@ local S = techage.S
techage.register_category_page("ta", "Further nodes and tools", techage.register_category_page("ta", "Further nodes and tools",
S("This is a collection of further nodes and tools which do not fit to the stages 1 to 4."), S("This is a collection of further nodes and tools which do not fit to the stages 1 to 4."),
"techage:end_wrench", {"end_wrench", "powerswitch", "trowel", "blackhole", "forceload"} "techage:end_wrench", {"end_wrench", "powerswitch", "trowel", "blackhole", "forceload", "doorblock", "gateblock"}
) )
techage.register_entry_page("ta", "powerswitch", techage.register_entry_page("ta", "powerswitch",

View File

@ -147,6 +147,8 @@ else
if techage.basalt_stone_enabled then if techage.basalt_stone_enabled then
dofile(MP.."/nodes/basalt.lua") dofile(MP.."/nodes/basalt.lua")
end end
dofile(MP.."/nodes/gateblock.lua")
dofile(MP.."/nodes/doorblock.lua")
-- Logic -- Logic
dofile(MP.."/logic/lib.lua") dofile(MP.."/logic/lib.lua")

View File

@ -32,6 +32,11 @@ end
local function switch_off(pos) local function switch_off(pos)
logic.swap_node(pos, "techage:ta3_button_off") logic.swap_node(pos, "techage:ta3_button_off")
logic.send_off(pos, M(pos)) logic.send_off(pos, M(pos))
minetest.sound_play("techage_button", {
pos = pos,
gain = 0.5,
max_hear_distance = 5,
})
end end
local function formspec(meta) local function formspec(meta)
@ -70,12 +75,11 @@ minetest.register_node("techage:ta3_button_off", {
if minetest.is_protected(pos, player:get_player_name()) then if minetest.is_protected(pos, player:get_player_name()) then
return return
end end
print(dump(fields))
local meta = M(pos) local meta = M(pos)
if not techage.check_numbers(fields.numbers, player:get_player_name()) then if not techage.check_numbers(fields.numbers, player:get_player_name()) then
return return
end end
print(dump(fields))
meta:set_string("numbers", fields.numbers) meta:set_string("numbers", fields.numbers)
if fields.public then if fields.public then
meta:set_string("public", fields.public) meta:set_string("public", fields.public)
@ -106,6 +110,7 @@ minetest.register_node("techage:ta3_button_off", {
logic.infotext(meta, S("TA3 Button/Switch")) logic.infotext(meta, S("TA3 Button/Switch"))
if fields.exit then if fields.exit then
meta:set_string("formspec", nil) meta:set_string("formspec", nil)
meta:set_string("fixed" , "true")
else else
meta:set_string("formspec", formspec(meta)) meta:set_string("formspec", formspec(meta))
end end
@ -113,8 +118,8 @@ minetest.register_node("techage:ta3_button_off", {
on_rightclick = function(pos, node, clicker) on_rightclick = function(pos, node, clicker)
local meta = M(pos) local meta = M(pos)
local numbers = meta:get_string("numbers") local fixed = meta:get_string("fixed")
if numbers ~= "" and numbers ~= nil then if fixed == "true" then
if meta:get_string("public") == "true" or if meta:get_string("public") == "true" or
clicker:get_player_name() == meta:get_string("owner") then clicker:get_player_name() == meta:get_string("owner") then
switch_on(pos) switch_on(pos)

View File

@ -18,7 +18,7 @@ local S = techage.S
local logic = techage.logic local logic = techage.logic
local COLORED = minetest.get_modpath("unifieddyes") and unifieddyes local COLORED = minetest.get_modpath("unifieddyes") and minetest.global_exists("unifieddyes")
local function switch_on(pos, node) local function switch_on(pos, node)

134
nodes/doorblock.lua Normal file
View File

@ -0,0 +1,134 @@
--[[
TechAge
=======
Copyright (C) 2019 Joachim Stolberg
GPL v3
See LICENSE.txt for more information
Door block
]]--
local S = techage.S
-- See also gateblock!!!
local NUM_TEXTURES = 20
local sTextures = "Wood,Aspen Wood,Jungle Wood,Pine Wood,"..
"Cobblestone,Sandstone,Stone,Desert Sandstone,"..
"Desert Stone,Silver Sandstone,Mossy Cobble,Desert Cobble,"..
"Copper,Steel,Tin,Coral,"..
"Glas,Obsidian Glas,Ice,Gate Wood"
local tTextures = {
["Wood"]=1, ["Aspen Wood"]=2, ["Jungle Wood"]=3, ["Pine Wood"]=4,
["Cobblestone"]=5, ["Sandstone"]=6, ["Stone"]=7, ["Desert Sandstone"]=8,
["Desert Stone"]=9, ["Silver Sandstone"]=10, ["Mossy Cobble"]=11, ["Desert Cobble"]=12,
["Copper"]=13, ["Steel"]=14, ["Tin"]=15, ["Coral"]=16,
["Glas"]=17, ["Obsidian Glas"]=18, ["Ice"]=19, ["Gate Wood"]=20,
}
local tPgns = {"default_wood.png", "default_aspen_wood.png", "default_junglewood.png", "default_pine_wood.png",
"default_cobble.png", "default_sandstone.png", "default_stone.png", "default_desert_sandstone.png",
"default_desert_stone_block.png", "default_silver_sandstone.png", "default_mossycobble.png", "default_desert_cobble.png",
"default_copper_block.png", "default_steel_block.png", "default_tin_block.png", "default_coral_skeleton.png",
"default_glass.png", "default_obsidian_glass.png", "default_ice.png", "techage_gate.png"}
for idx,pgn in ipairs(tPgns) do
minetest.register_node("techage:doorblock"..idx, {
description = S("Techage Door Block"),
tiles = {
pgn.."^[transformR90",
pgn,
pgn.."^[transformR90",
pgn.."^[transformR90",
pgn,
pgn.."^[transformFX",
},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{ -8/16, -8/16, -2/16, 8/16, 8/16, 2/16},
},
},
after_place_node = function(pos, placer)
local mem = tubelib2.init_mem(pos)
local meta = minetest.get_meta(pos)
local node = minetest.get_node(pos)
local number = techage.add_node(pos, "techage:doorblock"..idx)
mem.facedir = node.param2
meta:set_string("node_number", number)
meta:set_string("infotext", S("Techage Door Block").." "..number)
meta:set_string("formspec", "size[3,2]"..
"label[0,0;Select texture]"..
"dropdown[0,0.5;3;type;"..sTextures..";"..NUM_TEXTURES.."]"..
"button_exit[0.5,1.5;2,1;exit;Save]")
end,
on_receive_fields = function(pos, formname, fields, player)
local meta = minetest.get_meta(pos)
local node = minetest.get_node(pos)
local mem = tubelib2.get_mem(pos)
if fields.type then
node.name = "techage:doorblock"..tTextures[fields.type]
minetest.swap_node(pos, node)
mem.name = node.name
end
if fields.exit then
meta:set_string("formspec", nil)
end
end,
after_dig_node = function(pos, oldnode, oldmetadata)
techage.remove_node(pos)
tubelib2.del_mem(pos)
end,
--drawtype = "glasslike",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
sounds = default.node_sound_stone_defaults(),
groups = {cracky=2, choppy=2, crumbly=2, not_in_creative_inventory = idx==NUM_TEXTURES and 0 or 1},
is_ground_content = false,
drop = "techage:doorblock"..NUM_TEXTURES,
})
techage.register_node({"techage:doorblock"..idx}, {
on_recv_message = function(pos, src, topic, payload)
if topic == "on" then
minetest.remove_node(pos)
elseif topic == "off" then
local mem = tubelib2.get_mem(pos)
mem.facedir = mem.facedir or 0
mem.name = mem.texture or "techage:doorblock"..NUM_TEXTURES
minetest.add_node(pos, {name = mem.name, paramtype2 = "facedir", param2 = mem.facedir})
end
end,
})
end
minetest.register_craft({
output = "techage:doorblock"..NUM_TEXTURES,
recipe = {
{"default:mese_crystal_fragment", "",""},
{"techage:vacuum_tube", "", ""},
{"group:wood", "", ""},
},
})
techage.register_entry_page("ta", "doorblock",
S("Techage Door Block"),
S("The Door Block can disappear by means of commands from a button or switch.@n"..
"It is commonly used to build larger gates. All Door Blocks@n"..
"obtain a unique number which is shown as block infotext.@n"..
"This number is used as destination address for commands.@n"..
"The texture of the Door Block can be configured after@n"..
"placement with the right mouse button."),
"techage:doorblock"..NUM_TEXTURES)

116
nodes/gateblock.lua Normal file
View File

@ -0,0 +1,116 @@
--[[
TechAge
=======
Copyright (C) 2019 Joachim Stolberg
GPL v3
See LICENSE.txt for more information
Gate Block to disappear
]]--
local S = techage.S
-- See also doorblock!!!
local NUM_TEXTURES = 20
local sTextures = "Wood,Aspen Wood,Jungle Wood,Pine Wood,"..
"Cobblestone,Sandstone,Stone,Desert Sandstone,"..
"Desert Stone,Silver Sandstone,Mossy Cobble,Desert Cobble,"..
"Copper,Steel,Tin,Coral,"..
"Glas,Obsidian Glas,Ice,Gate Wood"
local tTextures = {
["Wood"]=1, ["Aspen Wood"]=2, ["Jungle Wood"]=3, ["Pine Wood"]=4,
["Cobblestone"]=5, ["Sandstone"]=6, ["Stone"]=7, ["Desert Sandstone"]=8,
["Desert Stone"]=9, ["Silver Sandstone"]=10, ["Mossy Cobble"]=11, ["Desert Cobble"]=12,
["Copper"]=13, ["Steel"]=14, ["Tin"]=15, ["Coral"]=16,
["Glas"]=17, ["Obsidian Glas"]=18, ["Ice"]=19, ["Gate Wood"]=20,
}
local tPgns = {"default_wood.png", "default_aspen_wood.png", "default_junglewood.png", "default_pine_wood.png",
"default_cobble.png", "default_sandstone.png", "default_stone.png", "default_desert_sandstone.png",
"default_desert_stone_block.png", "default_silver_sandstone.png", "default_mossycobble.png", "default_desert_cobble.png",
"default_copper_block.png", "default_steel_block.png", "default_tin_block.png", "default_coral_skeleton.png",
"default_glass.png", "default_obsidian_glass.png", "default_ice.png", "techage_gate.png"}
for idx,pgn in ipairs(tPgns) do
minetest.register_node("techage:gateblock"..idx, {
description = "Techage Gate Block",
tiles = {pgn},
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
local node = minetest.get_node(pos)
local number = techage.add_node(pos, "techage:gateblock"..idx)
meta:set_string("node_number", number)
meta:set_string("infotext", "Tubelib Gate Block "..number)
meta:set_string("formspec", "size[3,2]"..
"label[0,0;Select texture]"..
"dropdown[0,0.5;3;type;"..sTextures..";"..NUM_TEXTURES.."]"..
"button_exit[0.5,1.5;2,1;exit;Save]")
end,
on_receive_fields = function(pos, formname, fields, player)
local meta = minetest.get_meta(pos)
local node = minetest.get_node(pos)
if fields.type then
node.name = "techage:gateblock"..tTextures[fields.type]
minetest.swap_node(pos, node)
techage.add_node(pos, node.name)
end
if fields.exit then
meta:set_string("formspec", nil)
end
end,
after_dig_node = function(pos)
techage.remove_node(pos)
tubelib2.del_mem(pos)
end,
drawtype = "glasslike",
paramtype2 = "facedir",
sounds = default.node_sound_stone_defaults(),
groups = {cracky=2, choppy=2, crumbly=2, not_in_creative_inventory = idx==NUM_TEXTURES and 0 or 1},
is_ground_content = false,
drop = "techage:gateblock"..NUM_TEXTURES,
})
techage.register_node({"techage:gateblock"..idx}, {
on_recv_message = function(pos, src, topic, payload)
local node = minetest.get_node(pos)
if topic == "on" then
minetest.remove_node(pos)
elseif topic == "off" then
local num = techage.get_node_number(pos)
local info = techage.get_node_info(num)
if info then
minetest.add_node(pos, {name=info.name})
end
end
end,
})
end
minetest.register_craft({
output = "techage:gateblock"..NUM_TEXTURES,
recipe = {
{"group:wood", "", ""},
{"techage:vacuum_tube", "", ""},
{"default:mese_crystal_fragment", "",""},
},
})
techage.register_entry_page("ta", "gateblock",
S("Techage Gate Block"),
S("The Gate Block can disappear by means of commands from a button or switch.@n"..
"It is commonly used to build larger gates. All Gate Blocks@n"..
"obtain a unique number which is shown as block infotext.@n"..
"This number is used as destination address for commands.@n"..
"The texture of the Gate Block can be configured after@n"..
"placement with the right mouse button."),
"techage:gateblock"..NUM_TEXTURES)

BIN
textures/techage_gate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB