2015-06-29 17:55:56 +00:00
|
|
|
|
-- Count the number of pictures.
|
|
|
|
|
local function get_picture(number)
|
|
|
|
|
local filename = minetest.get_modpath("gemalde").."/textures/gemalde_"..number..".png"
|
|
|
|
|
local file = io.open(filename, "r")
|
|
|
|
|
if file ~= nil then io.close(file) return true else return false end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local N = 1
|
|
|
|
|
|
|
|
|
|
while get_picture(N) == true do
|
|
|
|
|
N = N + 1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
N = N - 1
|
|
|
|
|
|
|
|
|
|
-- register for each picture
|
|
|
|
|
for n=1, N do
|
|
|
|
|
|
2017-03-29 20:58:31 +00:00
|
|
|
|
local groups = {dig_immediate=3, picture=1, not_in_creative_inventory=1, dig_by_piston=1}
|
2015-06-29 17:55:56 +00:00
|
|
|
|
if n == 1 then
|
2017-03-29 20:58:31 +00:00
|
|
|
|
groups = {dig_immediate=3, picture=1, deco_block=1, dig_by_piston=1}
|
2015-06-29 17:55:56 +00:00
|
|
|
|
end
|
|
|
|
|
|
2017-03-02 20:55:25 +00:00
|
|
|
|
local desc, doc, longdesc, usagehelp
|
2017-01-23 11:23:37 +00:00
|
|
|
|
if n == 1 then
|
|
|
|
|
desc = "Painting"
|
2017-03-02 20:55:25 +00:00
|
|
|
|
doc = true
|
|
|
|
|
longdesc = "Paintings are decorations which can be placed on walls and cover a space of 3×3 blocks."
|
|
|
|
|
usagehelp = "Rightclick the painting to change it."
|
2017-01-23 11:23:37 +00:00
|
|
|
|
else
|
|
|
|
|
desc = "Painting ("..n..")"
|
2017-03-02 20:55:25 +00:00
|
|
|
|
doc = false
|
2017-01-23 11:23:37 +00:00
|
|
|
|
end
|
|
|
|
|
|
2015-06-29 17:55:56 +00:00
|
|
|
|
-- inivisible node
|
|
|
|
|
minetest.register_node("gemalde:node_"..n.."", {
|
2017-01-23 11:23:37 +00:00
|
|
|
|
description = desc,
|
2017-03-02 20:55:25 +00:00
|
|
|
|
_doc_items_create_entry = doc,
|
|
|
|
|
_doc_items_longdesc = longdesc,
|
|
|
|
|
_doc_items_usagehelp = usagehelp,
|
2015-06-29 17:55:56 +00:00
|
|
|
|
drawtype = "signlike",
|
2017-02-07 03:00:52 +00:00
|
|
|
|
tiles = {"gemalde_"..n..".png","gemalde_bg.png"},
|
2015-06-29 17:55:56 +00:00
|
|
|
|
visual_scale = 3.0,
|
|
|
|
|
inventory_image = "gemalde_node.png",
|
2017-01-04 21:36:51 +00:00
|
|
|
|
is_ground_content = false,
|
2015-06-29 17:55:56 +00:00
|
|
|
|
wield_image = "gemalde_node.png",
|
|
|
|
|
paramtype = "light",
|
|
|
|
|
paramtype2 = "wallmounted",
|
|
|
|
|
sunlight_propagates = true,
|
|
|
|
|
walkable = false,
|
|
|
|
|
selection_box = {
|
|
|
|
|
type = "wallmounted",
|
2017-02-07 03:39:43 +00:00
|
|
|
|
wall_side = { -0.5, -1.5, -1.5, -0.4, 1.5, 1.5 },
|
2015-06-29 17:55:56 +00:00
|
|
|
|
},
|
2017-01-23 11:23:37 +00:00
|
|
|
|
drop = "gemalde:node_1",
|
2015-06-29 17:55:56 +00:00
|
|
|
|
groups = groups,
|
|
|
|
|
|
|
|
|
|
on_rightclick = function(pos, node, clicker)
|
|
|
|
|
|
|
|
|
|
local length = string.len (node.name)
|
|
|
|
|
local number = string.sub (node.name, 14, length)
|
|
|
|
|
|
|
|
|
|
-- TODO. Reducing currently not working, because sneaking prevents right click.
|
|
|
|
|
local keys=clicker:get_player_control()
|
|
|
|
|
if keys["sneak"]==false then
|
|
|
|
|
if number == tostring(N) then
|
|
|
|
|
number = 1
|
|
|
|
|
else
|
|
|
|
|
number = number + 1
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if number == 1 then
|
|
|
|
|
number = N - 1
|
|
|
|
|
else
|
|
|
|
|
number = number - 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
node.name = "gemalde:node_"..number..""
|
2017-01-11 17:21:46 +00:00
|
|
|
|
minetest.set_node(pos, node)
|
2015-06-29 17:55:56 +00:00
|
|
|
|
end,
|
|
|
|
|
|
|
|
|
|
-- TODO.
|
|
|
|
|
-- on_place = minetest.rotate_node
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- initial craft
|
|
|
|
|
minetest.register_craft({
|
|
|
|
|
output = 'gemalde:node_1',
|
|
|
|
|
recipe = {
|
2017-01-31 22:32:56 +00:00
|
|
|
|
{'mcl_core:stick', 'mcl_core:stick', 'mcl_core:stick'},
|
|
|
|
|
{'mcl_core:stick', 'group:wool', 'mcl_core:stick'},
|
|
|
|
|
{'mcl_core:stick', 'mcl_core:stick', 'mcl_core:stick'},
|
2015-06-29 17:55:56 +00:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|