summaryrefslogtreecommitdiff
path: root/init.lua
blob: ac9f70d329216550d0c26f3920831206494348cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
local function invimg(ontex,offtex)
	--Create inventory images showing the on and off states
	local oncube = "([inventorycube{"..ontex.."{"..ontex.."{"..ontex..")"
	local offcube = "([inventorycube{"..offtex.."{"..offtex.."{"..offtex..")"

	--Rotate them 90° so the orientation will be correct for [lowpart
	oncube = "("..oncube.."^[transformR90)"
	offcube = "("..offcube.."^[transformR90)"

	--Start with the on texture, then copy the off texture over top of half of it
	local tex = oncube
	tex = tex.."^[lowpart:50:"..offcube

	--Rotate the result back to right-side-up
	tex = tex.."^[transformR270"
	return tex
end

local function morelightstones_add(name,base_item,texture_off,texture_on)
	minetest.register_node(":mesecons_lightstone:lightstone_hc_" .. name:lower() .. "_off", {
		inventory_image = invimg(texture_on,texture_off),
		tiles = {texture_off},
		groups = {cracky=2, mesecon_effector_off = 1, mesecon = 2},
		description="High Contrast "..name.." Lightstone",
		sounds = default.node_sound_stone_defaults(),
		mesecons = {effector = {
			action_on = function (pos, node)
				minetest.swap_node(pos, {name = "mesecons_lightstone:lightstone_hc_" .. name:lower() .. "_on", param2 = node.param2})
			end,
		}}
	})
	minetest.register_node(":mesecons_lightstone:lightstone_hc_" .. name:lower() .. "_on", {
	tiles = {texture_on},
	groups = {cracky=2,not_in_creative_inventory=1, mesecon = 2},
	drop = "mesecons_lightstone:lightstone_hc_" .. name:lower() .. "_off",
	light_source = default.LIGHT_MAX-2,
	sounds = default.node_sound_stone_defaults(),
	mesecons = {effector = {
		action_off = function (pos, node)
			minetest.swap_node(pos, {name = "mesecons_lightstone:lightstone_hc_" .. name:lower() .. "_off", param2 = node.param2})
		end,
	}}
	})

	minetest.register_craft({
		output = "mesecons_lightstone:lightstone_hc_" .. name .. "_off",
		recipe = {
			{"",base_item,""},
			{base_item,"mesecons_lamp:lamp_off",base_item},
			{"","group:mesecon_conductor_craftable",""}
		}
	})
end

morelightstones_add("Red", "dye:red", "jeija_lightstone_darkgray_off.png", "jeija_lightstone_red_on.png")
morelightstones_add("Green", "dye:green", "jeija_lightstone_darkgray_off.png", "jeija_lightstone_green_on.png")
morelightstones_add("Blue", "dye:blue", "jeija_lightstone_darkgray_off.png", "jeija_lightstone_blue_on.png")
morelightstones_add("Gray", "dye:grey", "jeija_lightstone_darkgray_off.png", "jeija_lightstone_gray_on.png")
morelightstones_add("Yellow", "dye:yellow", "jeija_lightstone_darkgray_off.png", "jeija_lightstone_yellow_on.png")
morelightstones_add("Cyan", "dye:cyan", "jeija_lightstone_darkgray_off.png", "jeija_lightstone_cyan_on.png")
morelightstones_add("Magenta", "dye:magenta", "jeija_lightstone_darkgray_off.png", "jeija_lightstone_magenta_on.png")
morelightstones_add("Orange", "dye:orange", "jeija_lightstone_darkgray_off.png", "jeija_lightstone_orange_on.png")
morelightstones_add("Pink", "dye:pink", "jeija_lightstone_darkgray_off.png", "jeija_lightstone_pink_on.png")
morelightstones_add("Violet", "dye:violet", "jeija_lightstone_darkgray_off.png", "jeija_lightstone_violet_on.png")
morelightstones_add("White", "dye:white", "jeija_lightstone_darkgray_off.png", "jeija_lightstone_white_on.png")