aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_itemstackmeta.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/lua_api/l_itemstackmeta.h')
0 files changed, 0 insertions, 0 deletions
#n71'>71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
-- Node texture tests

local S = minetest.get_translator("testnodes")

minetest.register_node("testnodes:6sides", {
	description = S("Six Textures Test Node"),
	tiles = {
		"testnodes_normal1.png",
		"testnodes_normal2.png",
		"testnodes_normal3.png",
		"testnodes_normal4.png",
		"testnodes_normal5.png",
		"testnodes_normal6.png",
	},

	groups = { dig_immediate = 2 },
})

minetest.register_node("testnodes:anim", {
	description = S("Animated Test Node"),
	tiles = {
		{ name = "testnodes_anim.png",
		animation = {
			type = "vertical_frames",
			aspect_w = 16,
			aspect_h = 16,
			length = 4.0,
		}, },
	},

	groups = { dig_immediate = 2 },
})

-- Node texture transparency test

local alphas = { 64, 128, 191 }

for a=1,#alphas do
	local alpha = alphas[a]

	-- Transparency taken from texture
	minetest.register_node("testnodes:alpha_texture_"..alpha, {
		description = S("Texture Alpha Test Node (@1)", alpha),
		drawtype = "glasslike",
		paramtype = "light",
		tiles = {
			"testnodes_alpha"..alpha..".png",
		},
		use_texture_alpha = "blend",

		groups = { dig_immediate = 3 },
	})

	-- Transparency set via texture modifier
	minetest.register_node("testnodes:alpha_"..alpha, {
		description = S("Alpha Test Node (@1)", alpha),
		drawtype = "glasslike",
		paramtype = "light",
		tiles = {
			"testnodes_alpha.png^[opacity:" .. alpha,
		},
		use_texture_alpha = "blend",

		groups = { dig_immediate = 3 },
	})
end

-- Generate PNG textures

local function mandelbrot(w, h, iterations)
	local r = {}
	for y=0, h-1 do
		for x=0, w-1 do
			local re = (x - w/2) * 4/w
			local im = (y - h/2) * 4/h
			-- zoom in on a nice view
			re = re / 128 - 0.23
			im = im / 128 - 0.82

			local px, py = 0, 0
			local i = 0
			while px*px + py*py <= 4 and i < iterations do
				px, py = px*px - py*py + re, 2 * px * py + im
				i = i + 1
			end
			r[w*y+x+1] = i / iterations
		end
	end
	return r
end

local function gen_checkers(w, h, tile)
	local r = {}
	for y=0, h-1 do
		for x=0, w-1 do
			local hori = math.floor(x / tile) % 2 == 0
			local vert = math.floor(y / tile) % 2 == 0
			r[w*y+x+1] = hori ~= vert and 1 or 0
		end
	end
	return r
end

local fractal = mandelbrot(512, 512, 128)
local frac_emb = mandelbrot(64, 64, 64)
local checker = gen_checkers(512, 512, 32)

local floor = math.floor
local abs = math.abs