Colored versions of the extenders, for nicer patterns

This commit is contained in:
Ben Deutsch 2015-10-22 23:13:13 +02:00
parent 9fb7dded49
commit 39a1c50c7a
2 changed files with 87 additions and 37 deletions

View File

@ -1,2 +1,3 @@
default default
doors doors
dye?

123
init.lua
View File

@ -36,6 +36,7 @@ telemosaic = {
beacon_range = 20.0, -- max teleport distance beacon_range = 20.0, -- max teleport distance
extender_ranges = { extender_ranges = {
-- note: not adding beacons here, since they don't extend -- note: not adding beacons here, since they don't extend
-- also: base name of colored versions
['telemosaic:extender_one'] = 5.0, ['telemosaic:extender_one'] = 5.0,
['telemosaic:extender_two'] = 20.0, ['telemosaic:extender_two'] = 20.0,
['telemosaic:extender_three'] = 80.0, ['telemosaic:extender_three'] = 80.0,
@ -77,7 +78,10 @@ local function count_extenders(pos)
for z=-3,3 do for z=-3,3 do
for x=-3,3 do for x=-3,3 do
local node = minetest.get_node({ x=pos.x+x, y=pos.y, z=pos.z+z}) local node = minetest.get_node({ x=pos.x+x, y=pos.y, z=pos.z+z})
extended = extended + ( C.extender_ranges[node.name] or 0.0 ) local name = node.name
-- trim color off the back
name = string.gsub(name, '^(telemosaic:extender_%a+)_%a+', '%1')
extended = extended + ( C.extender_ranges[name] or 0.0 )
end end
end end
--print("Total extended: " .. extended) --print("Total extended: " .. extended)
@ -271,36 +275,60 @@ minetest.register_tool('telemosaic:key', {
groups = { not_in_creative_inventory = 1 }, groups = { not_in_creative_inventory = 1 },
}) })
minetest.register_node('telemosaic:extender_one', { -- extenders come in three strengths, and many colors
description = 'Telemosaic extender, tier 1',
tiles = { local strengths = {
'telemosaic_extender_one.png', -- index starts at 1
}, 'one',
paramtype = 'light', 'two',
groups = { cracky = 2 }, 'three',
after_place_node = extender_place, }
after_dig_node = extender_dig, local colors = {
}) -- TODO: localisation
minetest.register_node('telemosaic:extender_two', { -- default: { name= 'grey', value= '#ffffff00'},
description = 'Telemosaic extender, tier 2', { name= 'white', value= '#ffffff80'},
tiles = { { name= 'dark_grey', value= '#000000c0'},
'telemosaic_extender_two.png', { name= 'black', value= '#00000080'},
}, { name= 'violet', value= '#40008080'},
paramtype = 'light', { name= 'blue', value= '#0000ff80'},
groups = { cracky = 2 }, { name= 'cyan', value= '#00ffff80'},
after_place_node = extender_place, { name= 'dark_green', value= '#00800080'},
after_dig_node = extender_dig, { name= 'green', value= '#00ff0080'},
}) { name= 'yellow', value= '#ffff0080'},
minetest.register_node('telemosaic:extender_three', { { name= 'brown', value= '#80400080'},
description = 'Telemosaic extender, tier 3', { name= 'orange', value= '#ff800080'},
tiles = { { name= 'red', value= '#ff000080'},
'telemosaic_extender_three.png', { name= 'magenta', value= '#ff00ff80'},
}, { name= 'pink', value= '#ff808080'},
paramtype = 'light', }
groups = { cracky = 2 },
after_place_node = extender_place, for num, strength in ipairs(strengths) do
after_dig_node = extender_dig, minetest.register_node(string.format('telemosaic:extender_%s', strength), {
}) description = string.format('Telemosaic extender, tier %d', num),
tiles = {
string.format('telemosaic_extender_%s.png', strength)
},
paramtype = 'light',
groups = { cracky = 2, [string.format('telemosaic_extender_%s', strength)] = 1 },
after_place_node = extender_place,
after_dig_node = extender_dig,
})
-- colored versions, not in creative inventory, if dyes available
if minetest.get_modpath('dye') then
for _,c in ipairs(colors) do
minetest.register_node(string.format('telemosaic:extender_%s_%s', strength, c.name), {
description = string.format('Telemosaic extender, tier %d (%s)', num, c.name),
tiles = {
string.format('telemosaic_extender_%s.png^[colorize:%s', strength, c.value),
},
paramtype = 'light',
groups = { cracky = 2, [string.format('telemosaic_extender_%s', strength)] = 1, not_in_creative_inventory = 1 },
after_place_node = extender_place,
after_dig_node = extender_dig,
})
end
end
end
minetest.register_craft({ minetest.register_craft({
output = 'telemosaic:beacon_off', output = 'telemosaic:beacon_off',
@ -318,19 +346,40 @@ minetest.register_craft({
minetest.register_craft({ minetest.register_craft({
output = 'telemosaic:extender_two', output = 'telemosaic:extender_two',
recipe = { recipe = {
{'', 'telemosaic:extender_one',''}, {'', 'group:telemosaic_extender_one',''},
{'telemosaic:extender_one','default:obsidian','telemosaic:extender_one'}, {'group:telemosaic_extender_one','default:obsidian','group:telemosaic_extender_one'},
{'', 'telemosaic:extender_one',''} {'', 'group:telemosaic_extender_one',''}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'telemosaic:extender_three', output = 'telemosaic:extender_three',
recipe = { recipe = {
{'', 'telemosaic:extender_two',''}, {'', 'group:telemosaic_extender_two',''},
{'telemosaic:extender_two','default:obsidian','telemosaic:extender_two'}, {'group:telemosaic_extender_two','default:obsidian','group:telemosaic_extender_two'},
{'', 'telemosaic:extender_two',''} {'', 'group:telemosaic_extender_two',''}
} }
}) })
-- coloring recipes
if minetest.get_modpath('dye') then
for num, strength in ipairs(strengths) do
-- uncolor
minetest.register_craft({
type = "shapeless",
output = string.format('telemosaic:extender_%s', strength),
recipe = { string.format('group:telemosaic_extender_%s', strength), 'dye:grey' },
})
-- color with dye
for _,c in ipairs(colors) do
minetest.register_craft({
type = "shapeless",
output = string.format('telemosaic:extender_%s_%s', strength, c.name),
recipe = { string.format('group:telemosaic_extender_%s', strength), string.format('dye:%s', c.name) },
})
end
end
end
-- how to recycle a key -- how to recycle a key
minetest.register_craft({ minetest.register_craft({
type = 'shapeless', type = 'shapeless',