techage/move_controller/doorblock.lua

109 lines
3.3 KiB
Lua
Raw Normal View History

2019-08-25 22:16:42 +03:00
--[[
TechAge
=======
Copyright (C) 2019 Joachim Stolberg
2020-10-19 20:09:17 +03:00
AGPL v3
2019-08-25 22:16:42 +03:00
See LICENSE.txt for more information
Door block
2022-01-03 23:40:31 +03:00
2019-08-25 22:16:42 +03:00
]]--
2020-03-22 21:07:04 +03:00
local M = minetest.get_meta
2019-08-25 22:16:42 +03:00
local S = techage.S
-- See also gateblock!!!
2020-07-02 22:26:18 +03:00
local NUM_TEXTURES = 22
2019-08-25 22:16:42 +03:00
local sTextures = "Wood,Aspen Wood,Jungle Wood,Pine Wood,"..
"Cobblestone,Sandstone,Stone,Desert Sandstone,"..
2022-01-03 23:40:31 +03:00
"Desert Stone,Silver Sandstone,Mossy Cobble,Desert Cobble,"..
2019-08-25 22:16:42 +03:00
"Copper,Steel,Tin,Coral,"..
2020-07-02 22:26:18 +03:00
"Glas,Obsidian Glas,Basalt Glass,Basalt Glass 2,"..
2022-01-03 23:40:31 +03:00
"Ice,Gate Wood"
2019-08-25 22:16:42 +03:00
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,
2022-01-03 23:40:31 +03:00
["Glas"]=17, ["Obsidian Glas"]=18, ["Basalt Glass"]=19, ["Basalt Glass 2"]=20,
2020-07-02 22:26:18 +03:00
["Ice"]=21, ["Gate Wood"]=22,
2019-08-25 22:16:42 +03:00
}
2022-01-03 23:40:31 +03:00
2019-08-25 22:16:42 +03:00
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",
2020-07-02 22:26:18 +03:00
"default_glass.png", "default_obsidian_glass.png", "techage_basalt_glass.png", "techage_basalt_glass2.png",
"default_ice.png", "techage_gate.png"}
2019-08-25 22:16:42 +03:00
for idx,pgn in ipairs(tPgns) do
minetest.register_node("techage:doorblock"..idx, {
description = S("TechAge Door Block"),
2019-08-25 22:16:42 +03:00
tiles = {
pgn.."^[transformR90",
pgn,
pgn.."^[transformR90",
pgn.."^[transformR90",
pgn,
pgn.."^[transformFX",
},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
2020-03-22 21:07:04 +03:00
{ -8/16, -8/16, -1/16, 8/16, 8/16, 1/16},
2019-08-25 22:16:42 +03:00
},
},
after_place_node = function(pos, placer)
2020-03-22 21:07:04 +03:00
M(pos):set_string("formspec", "size[3,2]"..
2019-08-25 22:16:42 +03:00
"label[0,0;Select texture]"..
2022-01-03 23:40:31 +03:00
"dropdown[0,0.5;3;type;"..sTextures..";"..NUM_TEXTURES.."]"..
2019-08-25 22:16:42 +03:00
"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:doorblock"..tTextures[fields.type]
minetest.swap_node(pos, node)
end
if fields.exit then
meta:set_string("formspec", "")
2020-03-22 21:07:04 +03:00
local number = techage.add_node(pos, node.name)
meta:set_string("infotext", S("TechAge Door Block").." "..number)
2019-08-25 22:16:42 +03:00
end
end,
2022-01-03 23:40:31 +03:00
2020-06-14 00:32:00 +03:00
after_dig_node = function(pos, oldnode, oldmetadata)
techage.remove_node(pos, oldnode, oldmetadata)
2019-08-25 22:16:42 +03:00
end,
paramtype = "light",
paramtype2 = "facedir",
use_texture_alpha = techage.BLEND,
2019-08-25 22:16:42 +03:00
sunlight_propagates = true,
sounds = default.node_sound_stone_defaults(),
2022-01-03 23:40:31 +03:00
groups = {cracky=2, choppy=2, crumbly=2, techage_door = 1,
not_in_creative_inventory = idx==NUM_TEXTURES and 0 or 1},
2019-08-25 22:16:42 +03:00
is_ground_content = false,
drop = "techage:doorblock"..NUM_TEXTURES,
2020-03-22 21:07:04 +03:00
},
techage.register_node({"techage:doorblock"..idx}, {}))
2019-08-25 22:16:42 +03:00
end
minetest.register_craft({
output = "techage:doorblock"..NUM_TEXTURES,
recipe = {
2020-03-22 21:07:04 +03:00
{"techage:basalt_glass_thin", "", ""},
2019-08-25 22:16:42 +03:00
{"default:mese_crystal_fragment", "",""},
{"group:wood", "", ""},
},
})