aboutsummaryrefslogtreecommitdiff
path: root/games/devtest
diff options
context:
space:
mode:
Diffstat (limited to 'games/devtest')
-rw-r--r--games/devtest/menu/background.pngbin152 -> 160 bytes
-rw-r--r--games/devtest/mods/testhud/init.lua81
-rw-r--r--games/devtest/mods/testhud/mod.conf2
-rw-r--r--games/devtest/mods/testnodes/drawtypes.lua30
-rw-r--r--games/devtest/mods/testnodes/textures.lua75
-rw-r--r--games/devtest/mods/testnodes/textures/testnodes_plantlike_rooted_base_side_wallmounted.pngbin0 -> 224 bytes
-rw-r--r--games/devtest/mods/testnodes/textures/testnodes_plantlike_rooted_wallmounted.pngbin0 -> 268 bytes
-rw-r--r--games/devtest/mods/testnodes/textures/testnodes_plantlike_wallmounted.pngbin0 -> 268 bytes
8 files changed, 188 insertions, 0 deletions
diff --git a/games/devtest/menu/background.png b/games/devtest/menu/background.png
index 415bb3d14..89c45fcd5 100644
--- a/games/devtest/menu/background.png
+++ b/games/devtest/menu/background.png
Binary files differ
diff --git a/games/devtest/mods/testhud/init.lua b/games/devtest/mods/testhud/init.lua
new file mode 100644
index 000000000..2fa12fd71
--- /dev/null
+++ b/games/devtest/mods/testhud/init.lua
@@ -0,0 +1,81 @@
+local player_huds = {}
+
+local states = {
+ {0, "Normal font"},
+ {1, "Bold font"},
+ {2, "Italic font"},
+ {3, "Bold and italic font"},
+ {4, "Monospace font"},
+ {5, "Bold and monospace font"},
+ {7, "ZOMG all the font styles"},
+}
+
+
+local default_def = {
+ hud_elem_type = "text",
+ position = {x = 0.5, y = 0.5},
+ scale = {x = 2, y = 2},
+ alignment = { x = 0, y = 0 },
+}
+
+local function add_hud(player, state)
+ local def = table.copy(default_def)
+ local statetbl = states[state]
+ def.offset = {x = 0, y = 32 * state}
+ def.style = statetbl[1]
+ def.text = statetbl[2]
+ return player:hud_add(def)
+end
+
+minetest.register_on_leaveplayer(function(player)
+ player_huds[player:get_player_name()] = nil
+end)
+
+local etime = 0
+local state = 0
+
+minetest.register_globalstep(function(dtime)
+ etime = etime + dtime
+ if etime < 1 then
+ return
+ end
+ etime = 0
+ for _, player in ipairs(minetest.get_connected_players()) do
+ local huds = player_huds[player:get_player_name()]
+ if huds then
+ for i, hud_id in ipairs(huds) do
+ local statetbl = states[(state + i) % #states + 1]
+ player:hud_change(hud_id, "style", statetbl[1])
+ player:hud_change(hud_id, "text", statetbl[2])
+ end
+ end
+ end
+ state = state + 1
+end)
+
+minetest.register_chatcommand("hudfonts", {
+ params = "",
+ description = "Show/Hide some text on the HUD with various font options",
+ func = function(name, param)
+ local player = minetest.get_player_by_name(name)
+ local param = tonumber(param) or 0
+ param = math.min(math.max(param, 1), #states)
+ if player_huds[name] == nil then
+ player_huds[name] = {}
+ for i = 1, param do
+ table.insert(player_huds[name], add_hud(player, i))
+ end
+ minetest.chat_send_player(name, ("%d HUD element(s) added."):format(param))
+ else
+ local huds = player_huds[name]
+ if huds then
+ for _, hud_id in ipairs(huds) do
+ player:hud_remove(hud_id)
+ end
+ minetest.chat_send_player(name, "All HUD elements removed.")
+ end
+ player_huds[name] = nil
+ end
+ return true
+ end,
+})
diff --git a/games/devtest/mods/testhud/mod.conf b/games/devtest/mods/testhud/mod.conf
new file mode 100644
index 000000000..ed9f65c59
--- /dev/null
+++ b/games/devtest/mods/testhud/mod.conf
@@ -0,0 +1,2 @@
+name = testhud
+description = For testing HUD functionality
diff --git a/games/devtest/mods/testnodes/drawtypes.lua b/games/devtest/mods/testnodes/drawtypes.lua
index 2bc7ec2e3..208774f6c 100644
--- a/games/devtest/mods/testnodes/drawtypes.lua
+++ b/games/devtest/mods/testnodes/drawtypes.lua
@@ -208,6 +208,19 @@ minetest.register_node("testnodes:plantlike_waving", {
groups = { dig_immediate = 3 },
})
+minetest.register_node("testnodes:plantlike_wallmounted", {
+ description = S("Wallmounted Plantlike Drawtype Test Node"),
+ drawtype = "plantlike",
+ paramtype = "light",
+ paramtype2 = "wallmounted",
+ tiles = { "testnodes_plantlike_wallmounted.png" },
+ leveled = 1,
+
+
+ walkable = false,
+ sunlight_propagates = true,
+ groups = { dig_immediate = 3 },
+})
-- param2 will rotate
@@ -320,6 +333,20 @@ minetest.register_node("testnodes:plantlike_rooted", {
groups = { dig_immediate = 3 },
})
+minetest.register_node("testnodes:plantlike_rooted_wallmounted", {
+ description = S("Wallmounted Rooted Plantlike Drawtype Test Node"),
+ drawtype = "plantlike_rooted",
+ paramtype = "light",
+ paramtype2 = "wallmounted",
+ tiles = {
+ "testnodes_plantlike_rooted_base.png",
+ "testnodes_plantlike_rooted_base.png",
+ "testnodes_plantlike_rooted_base_side_wallmounted.png" },
+ special_tiles = { "testnodes_plantlike_rooted_wallmounted.png" },
+
+ groups = { dig_immediate = 3 },
+})
+
minetest.register_node("testnodes:plantlike_rooted_waving", {
description = S("Waving Rooted Plantlike Drawtype Test Node"),
drawtype = "plantlike_rooted",
@@ -588,6 +615,9 @@ scale("allfaces_optional_waving",
scale("plantlike",
S("Double-sized Plantlike Drawtype Test Node"),
S("Half-sized Plantlike Drawtype Test Node"))
+scale("plantlike_wallmounted",
+ S("Double-sized Wallmounted Plantlike Drawtype Test Node"),
+ S("Half-sized Wallmounted Plantlike Drawtype Test Node"))
scale("torchlike_wallmounted",
S("Double-sized Wallmounted Torchlike Drawtype Test Node"),
S("Half-sized Wallmounted Torchlike Drawtype Test Node"))
diff --git a/games/devtest/mods/testnodes/textures.lua b/games/devtest/mods/testnodes/textures.lua
index f6e6a0c2a..4652007d9 100644
--- a/games/devtest/mods/testnodes/textures.lua
+++ b/games/devtest/mods/testnodes/textures.lua
@@ -65,3 +65,78 @@ for a=1,#alphas do
})
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 checker = gen_checkers(512, 512, 32)
+
+local floor = math.floor
+local abs = math.abs
+local data_mb = {}
+local data_ck = {}
+for i=1, #fractal do
+ data_mb[i] = {
+ r = floor(fractal[i] * 255),
+ g = floor(abs(fractal[i] * 2 - 1) * 255),
+ b = floor(abs(1 - fractal[i]) * 255),
+ a = 255,
+ }
+ data_ck[i] = checker[i] > 0 and "#F80" or "#000"
+end
+
+local textures_path = minetest.get_modpath( minetest.get_current_modname() ) .. "/textures/"
+minetest.safe_file_write(
+ textures_path .. "testnodes_generated_mb.png",
+ minetest.encode_png(512,512,data_mb)
+)
+minetest.safe_file_write(
+ textures_path .. "testnodes_generated_ck.png",
+ minetest.encode_png(512,512,data_ck)
+)
+
+minetest.register_node("testnodes:generated_png_mb", {
+ description = S("Generated Mandelbrot PNG Test Node"),
+ tiles = { "testnodes_generated_mb.png" },
+
+ groups = { dig_immediate = 2 },
+})
+minetest.register_node("testnodes:generated_png_ck", {
+ description = S("Generated Checker PNG Test Node"),
+ tiles = { "testnodes_generated_ck.png" },
+
+ groups = { dig_immediate = 2 },
+})
diff --git a/games/devtest/mods/testnodes/textures/testnodes_plantlike_rooted_base_side_wallmounted.png b/games/devtest/mods/testnodes/textures/testnodes_plantlike_rooted_base_side_wallmounted.png
new file mode 100644
index 000000000..b0be8d077
--- /dev/null
+++ b/games/devtest/mods/testnodes/textures/testnodes_plantlike_rooted_base_side_wallmounted.png
Binary files differ
diff --git a/games/devtest/mods/testnodes/textures/testnodes_plantlike_rooted_wallmounted.png b/games/devtest/mods/testnodes/textures/testnodes_plantlike_rooted_wallmounted.png
new file mode 100644
index 000000000..421466407
--- /dev/null
+++ b/games/devtest/mods/testnodes/textures/testnodes_plantlike_rooted_wallmounted.png
Binary files differ
diff --git a/games/devtest/mods/testnodes/textures/testnodes_plantlike_wallmounted.png b/games/devtest/mods/testnodes/textures/testnodes_plantlike_wallmounted.png
new file mode 100644
index 000000000..c89b29e30
--- /dev/null
+++ b/games/devtest/mods/testnodes/textures/testnodes_plantlike_wallmounted.png
Binary files differ