summaryrefslogtreecommitdiff
path: root/games/devtest/mods
diff options
context:
space:
mode:
Diffstat (limited to 'games/devtest/mods')
-rw-r--r--games/devtest/mods/basenodes/textures/default_dirt.pngbin790 -> 7303 bytes
-rw-r--r--games/devtest/mods/basenodes/textures/dirt_with_grass/info.txt3
-rw-r--r--games/devtest/mods/basenodes/textures/info.txt7
-rw-r--r--games/devtest/mods/chest/init.lua16
-rw-r--r--games/devtest/mods/experimental/commands.lua2
-rw-r--r--games/devtest/mods/testentities/visuals.lua16
-rw-r--r--games/devtest/mods/testformspec/formspec.lua37
-rw-r--r--games/devtest/mods/testtools/README.md21
-rw-r--r--games/devtest/mods/testtools/init.lua196
-rw-r--r--games/devtest/mods/testtools/light.lua31
-rw-r--r--games/devtest/mods/testtools/textures/testtools_children_getter.pngbin0 -> 281 bytes
-rw-r--r--games/devtest/mods/testtools/textures/testtools_node_meta_editor.pngbin0 -> 135 bytes
-rw-r--r--games/devtest/mods/unittests/itemdescription.lua11
-rw-r--r--games/devtest/mods/unittests/mod.conf1
-rw-r--r--games/devtest/mods/unittests/textures/default_dirt.pngbin0 -> 790 bytes
15 files changed, 299 insertions, 42 deletions
diff --git a/games/devtest/mods/basenodes/textures/default_dirt.png b/games/devtest/mods/basenodes/textures/default_dirt.png
index 58670305d..aa75bffb6 100644
--- a/games/devtest/mods/basenodes/textures/default_dirt.png
+++ b/games/devtest/mods/basenodes/textures/default_dirt.png
Binary files differ
diff --git a/games/devtest/mods/basenodes/textures/dirt_with_grass/info.txt b/games/devtest/mods/basenodes/textures/dirt_with_grass/info.txt
deleted file mode 100644
index 8db21ed9c..000000000
--- a/games/devtest/mods/basenodes/textures/dirt_with_grass/info.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-This is for testing loading textures from subfolders.
-If it works correctly, the default_grass_side.png file in this folder is used but
-default_grass.png is not overwritten by the file in this folder.
diff --git a/games/devtest/mods/basenodes/textures/info.txt b/games/devtest/mods/basenodes/textures/info.txt
new file mode 100644
index 000000000..2d4ef7efa
--- /dev/null
+++ b/games/devtest/mods/basenodes/textures/info.txt
@@ -0,0 +1,7 @@
+
+The dirt_with_grass folder is for testing loading textures from subfolders.
+If it works correctly, the default_grass_side.png file in the folder is used but
+default_grass.png is not overwritten by the file in the folder.
+
+default_dirt.png should be overwritten by the default_dirt.png in the unittests
+mod which depends on basenodes.
diff --git a/games/devtest/mods/chest/init.lua b/games/devtest/mods/chest/init.lua
index fc92bfdd1..5798c13e7 100644
--- a/games/devtest/mods/chest/init.lua
+++ b/games/devtest/mods/chest/init.lua
@@ -23,6 +23,18 @@ minetest.register_node("chest:chest", {
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
+ allow_metadata_inventory_put = function(pos, listname, index, stack, player)
+ minetest.chat_send_player(player:get_player_name(), "Allow put: " .. stack:to_string())
+ return stack:get_count()
+ end,
+ allow_metadata_inventory_take = function(pos, listname, index, stack, player)
+ minetest.chat_send_player(player:get_player_name(), "Allow take: " .. stack:to_string())
+ return stack:get_count()
+ end,
+ on_metadata_inventory_put = function(pos, listname, index, stack, player)
+ minetest.chat_send_player(player:get_player_name(), "On put: " .. stack:to_string())
+ end,
+ on_metadata_inventory_take = function(pos, listname, index, stack, player)
+ minetest.chat_send_player(player:get_player_name(), "On take: " .. stack:to_string())
+ end,
})
-
-
diff --git a/games/devtest/mods/experimental/commands.lua b/games/devtest/mods/experimental/commands.lua
index 132b08b0b..8bfa467e1 100644
--- a/games/devtest/mods/experimental/commands.lua
+++ b/games/devtest/mods/experimental/commands.lua
@@ -215,5 +215,5 @@ minetest.register_chatcommand("test_place_nodes", {
})
core.register_on_chatcommand(function(name, command, params)
- minetest.log("caught command '"..command.."', issued by '"..name.."'. Parameters: '"..params.."'")
+ minetest.log("action", "caught command '"..command.."', issued by '"..name.."'. Parameters: '"..params.."'")
end)
diff --git a/games/devtest/mods/testentities/visuals.lua b/games/devtest/mods/testentities/visuals.lua
index e3b758329..e382ec44c 100644
--- a/games/devtest/mods/testentities/visuals.lua
+++ b/games/devtest/mods/testentities/visuals.lua
@@ -103,23 +103,35 @@ minetest.register_entity("testentities:nametag", {
on_activate = function(self, staticdata)
if staticdata ~= "" then
- self.color = minetest.deserialize(staticdata).color
+ local data = minetest.deserialize(staticdata)
+ self.color = data.color
+ self.bgcolor = data.bgcolor
else
self.color = {
r = math.random(0, 255),
g = math.random(0, 255),
b = math.random(0, 255),
}
+
+ if math.random(0, 10) > 5 then
+ self.bgcolor = {
+ r = math.random(0, 255),
+ g = math.random(0, 255),
+ b = math.random(0, 255),
+ a = math.random(0, 255),
+ }
+ end
end
assert(self.color)
self.object:set_properties({
nametag = tostring(math.random(1000, 10000)),
nametag_color = self.color,
+ nametag_bgcolor = self.bgcolor,
})
end,
get_staticdata = function(self)
- return minetest.serialize({ color = self.color })
+ return minetest.serialize({ color = self.color, bgcolor = self.bgcolor })
end,
})
diff --git a/games/devtest/mods/testformspec/formspec.lua b/games/devtest/mods/testformspec/formspec.lua
index 2a2bdad60..501b5e354 100644
--- a/games/devtest/mods/testformspec/formspec.lua
+++ b/games/devtest/mods/testformspec/formspec.lua
@@ -362,20 +362,51 @@ Number]
animated_image[5.5,0.5;5,2;;testformspec_animation.png;4;100]
animated_image[5.5,2.75;5,2;;testformspec_animation.jpg;4;100]
+ ]],
+
+ -- Model
+ [[
+ formspec_version[3]
+ size[12,13]
style[m1;bgcolor=black]
- model[0.5,6;4,4;m1;testformspec_character.b3d;testformspec_character.png]
- model[5,6;4,4;m2;testformspec_chest.obj;default_chest_top.png,default_chest_top.png,default_chest_side.png,default_chest_side.png,default_chest_front.png,default_chest_inside.png;30,1;true;true]
+ style[m2;bgcolor=black]
+ label[5,1;all defaults]
+ label[5,5.1;angle = 0, 180
+continuous = false
+mouse control = false
+frame loop range = 0,30]
+ label[5,9.2;continuous = true
+mouse control = true]
+ model[0.5,0.1;4,4;m1;testformspec_character.b3d;testformspec_character.png]
+ model[0.5,4.2;4,4;m2;testformspec_character.b3d;testformspec_character.png;0,180;false;false;0,30]
+ model[0.5,8.3;4,4;m3;testformspec_chest.obj;default_chest_top.png,default_chest_top.png,default_chest_side.png,default_chest_side.png,default_chest_front.png,default_chest_inside.png;30,1;true;true]
]],
-- Scroll containers
"formspec_version[3]size[12,13]" ..
scroll_fs,
+
+ -- Sound
+ [[
+ formspec_version[3]
+ size[12,13]
+ style[snd_btn;sound=soundstuff_mono]
+ style[snd_ibtn;sound=soundstuff_mono]
+ style[snd_drp;sound=soundstuff_mono]
+ style[snd_chk;sound=soundstuff_mono]
+ style[snd_tab;sound=soundstuff_mono]
+ button[0.5,0.5;2,1;snd_btn;Sound]
+ image_button[0.5,2;2,1;testformspec_item.png;snd_ibtn;Sound]
+ dropdown[0.5,4;4;snd_drp;Sound,Two,Three;]
+ checkbox[0.5,5.5.5;snd_chk;Sound;]
+ tabheader[0.5,7;8,0.65;snd_tab;Soundtab1,Soundtab2,Soundtab3;1;false;false]
+ ]],
}
local function show_test_formspec(pname, page_id)
page_id = page_id or 2
- local fs = pages[page_id] .. "tabheader[0,0;8,0.65;maintabs;Real Coord,Styles,Noclip,Hypertext,Tabs,Invs,Anim,ScrollC;" .. page_id .. ";false;false]"
+ local fs = pages[page_id] .. "tabheader[0,0;8,0.65;maintabs;Real Coord,Styles,Noclip,Hypertext,Tabs,Invs,Anim,Model,ScrollC,Sound;" .. page_id .. ";false;false]"
minetest.show_formspec(pname, "testformspec:formspec", fs)
end
diff --git a/games/devtest/mods/testtools/README.md b/games/devtest/mods/testtools/README.md
index 9cfe29ea4..a1eb95ed7 100644
--- a/games/devtest/mods/testtools/README.md
+++ b/games/devtest/mods/testtools/README.md
@@ -33,6 +33,13 @@ Usage:
* Punch node: Make it fall
* Place: Try to teleport up to 2 units upwards, then make it fall
+## Node Meta Editor
+Edit and view metadata of nodes.
+
+Usage:
+
+* Punch: Open node metadata editor
+
## Entity Rotator
Changes the entity rotation (with `set_rotation`).
@@ -90,6 +97,13 @@ Usage:
* Place: Increase move distance
* Sneak+place: Decrease move distance
+## Children Getter
+Shows list of objects that are attached to an object (aka "children") in chat.
+
+Usage:
+* Punch object: Show children of punched object
+* Punch air: Show your own children
+
## Entity Visual Scaler
Change visual size of entities
@@ -97,3 +111,10 @@ Usage:
* Punch entity to increase visual size
* Sneak+punch entity to decrease visual size
+
+## Light Tool
+Show light level of node.
+
+Usage:
+* Punch: Show light info of node in front of the punched node's side
+* Place: Show light info of the node that you touched
diff --git a/games/devtest/mods/testtools/init.lua b/games/devtest/mods/testtools/init.lua
index d578b264a..1041acdeb 100644
--- a/games/devtest/mods/testtools/init.lua
+++ b/games/devtest/mods/testtools/init.lua
@@ -3,8 +3,6 @@ local F = minetest.formspec_escape
dofile(minetest.get_modpath("testtools") .. "/light.lua")
--- TODO: Add a Node Metadata tool
-
minetest.register_tool("testtools:param2tool", {
description = S("Param2 Tool") .."\n"..
S("Modify param2 value of nodes") .."\n"..
@@ -111,25 +109,6 @@ minetest.register_tool("testtools:node_setter", {
end,
})
-minetest.register_on_player_receive_fields(function(player, formname, fields)
- if formname == "testtools:node_setter" then
- local playername = player:get_player_name()
- local witem = player:get_wielded_item()
- if witem:get_name() == "testtools:node_setter" then
- if fields.nodename and fields.param2 then
- local param2 = tonumber(fields.param2)
- if not param2 then
- return
- end
- local meta = witem:get_meta()
- meta:set_string("node", fields.nodename)
- meta:set_int("node_param2", param2)
- player:set_wielded_item(witem)
- end
- end
- end
-end)
-
minetest.register_tool("testtools:remover", {
description = S("Remover") .."\n"..
S("Punch: Remove pointed node or object"),
@@ -634,6 +613,54 @@ minetest.register_tool("testtools:object_attacher", {
end,
})
+local function print_object(obj)
+ if obj:is_player() then
+ return "player '"..obj:get_player_name().."'"
+ elseif obj:get_luaentity() then
+ return "LuaEntity '"..obj:get_luaentity().name.."'"
+ else
+ return "object"
+ end
+end
+
+minetest.register_tool("testtools:children_getter", {
+ description = S("Children Getter") .."\n"..
+ S("Shows list of objects attached to object") .."\n"..
+ S("Punch object to show its 'children'") .."\n"..
+ S("Punch air to show your own 'children'"),
+ inventory_image = "testtools_children_getter.png",
+ groups = { testtool = 1, disable_repair = 1 },
+ on_use = function(itemstack, user, pointed_thing)
+ if user and user:is_player() then
+ local name = user:get_player_name()
+ local selected_object
+ local self_name
+ if pointed_thing.type == "object" then
+ selected_object = pointed_thing.ref
+ elseif pointed_thing.type == "nothing" then
+ selected_object = user
+ else
+ return
+ end
+ self_name = print_object(selected_object)
+ local children = selected_object:get_children()
+ local ret = ""
+ for c=1, #children do
+ ret = ret .. "* " .. print_object(children[c])
+ if c < #children then
+ ret = ret .. "\n"
+ end
+ end
+ if ret == "" then
+ ret = S("No children attached to @1.", self_name)
+ else
+ ret = S("Children of @1:", self_name) .. "\n" .. ret
+ end
+ minetest.chat_send_player(user:get_player_name(), ret)
+ end
+ end,
+})
+
-- Use loadstring to parse param as a Lua value
local function use_loadstring(param, player)
-- For security reasons, require 'server' priv, just in case
@@ -666,6 +693,68 @@ local function use_loadstring(param, player)
return true, errOrResult
end
+-- Node Meta Editor
+local node_meta_posses = {}
+local node_meta_latest_keylist = {}
+
+local function show_node_meta_formspec(user, pos, key, value, keylist)
+ local textlist
+ if keylist then
+ textlist = "textlist[0,0.5;2.5,6.5;keylist;"..keylist.."]"
+ else
+ textlist = ""
+ end
+ minetest.show_formspec(user:get_player_name(),
+ "testtools:node_meta_editor",
+ "size[15,9]"..
+ "label[0,0;"..F(S("Current keys:")).."]"..
+ textlist..
+ "field[3,0.5;12,1;key;"..F(S("Key"))..";"..F(key).."]"..
+ "textarea[3,1.5;12,6;value;"..F(S("Value (use empty value to delete key)"))..";"..F(value).."]"..
+ "button[0,8;3,1;get;"..F(S("Get value")).."]"..
+ "button[4,8;3,1;set;"..F(S("Set value")).."]"..
+ "label[0,7.2;"..F(S("pos = @1", minetest.pos_to_string(pos))).."]")
+end
+
+local function get_node_meta_keylist(meta, playername, escaped)
+ local keys = {}
+ local ekeys = {}
+ local mtable = meta:to_table()
+ for k,_ in pairs(mtable.fields) do
+ table.insert(keys, k)
+ if escaped then
+ table.insert(ekeys, F(k))
+ else
+ table.insert(ekeys, k)
+ end
+ end
+ if playername then
+ node_meta_latest_keylist[playername] = keys
+ end
+ return table.concat(ekeys, ",")
+end
+
+minetest.register_tool("testtools:node_meta_editor", {
+ description = S("Node Meta Editor") .. "\n" ..
+ S("Place: Edit node metadata"),
+ inventory_image = "testtools_node_meta_editor.png",
+ groups = { testtool = 1, disable_repair = 1 },
+ on_place = function(itemstack, user, pointed_thing)
+ if pointed_thing.type ~= "node" then
+ return itemstack
+ end
+ if not user:is_player() then
+ return itemstack
+ end
+ local pos = pointed_thing.under
+ node_meta_posses[user:get_player_name()] = pos
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ show_node_meta_formspec(user, pos, "", "", get_node_meta_keylist(meta, user:get_player_name(), true))
+ return itemstack
+ end,
+})
+
minetest.register_on_player_receive_fields(function(player, formname, fields)
if not (player and player:is_player()) then
return
@@ -728,5 +817,70 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
editor_formspec(name, selected_objects[name], prop_to_string(props[key]), sel)
return
end
+ elseif formname == "testtools:node_setter" then
+ local playername = player:get_player_name()
+ local witem = player:get_wielded_item()
+ if witem:get_name() == "testtools:node_setter" then
+ if fields.nodename and fields.param2 then
+ local param2 = tonumber(fields.param2)
+ if not param2 then
+ return
+ end
+ local meta = witem:get_meta()
+ meta:set_string("node", fields.nodename)
+ meta:set_int("node_param2", param2)
+ player:set_wielded_item(witem)
+ end
+ end
+ elseif formname == "testtools:node_meta_editor" then
+ local name = player:get_player_name()
+ local pos = node_meta_posses[name]
+ if fields.keylist then
+ local evnt = minetest.explode_textlist_event(fields.keylist)
+ if evnt.type == "DCL" or evnt.type == "CHG" then
+ local keylist_table = node_meta_latest_keylist[name]
+ if not pos then
+ return
+ end
+ local meta = minetest.get_meta(pos)
+ if not keylist_table then
+ return
+ end
+ if #keylist_table == 0 then
+ return
+ end
+ local key = keylist_table[evnt.index]
+ local value = meta:get_string(key)
+ local keylist_escaped = {}
+ for k,v in pairs(keylist_table) do
+ keylist_escaped[k] = F(v)
+ end
+ local keylist = table.concat(keylist_escaped, ",")
+ show_node_meta_formspec(player, pos, key, value, keylist)
+ return
+ end
+ elseif fields.key and fields.key ~= "" and fields.value then
+ if not pos then
+ return
+ end
+ local meta = minetest.get_meta(pos)
+ if fields.get then
+ local value = meta:get_string(fields.key)
+ show_node_meta_formspec(player, pos, fields.key, value,
+ get_node_meta_keylist(meta, name, true))
+ return
+ elseif fields.set then
+ meta:set_string(fields.key, fields.value)
+ show_node_meta_formspec(player, pos, fields.key, fields.value,
+ get_node_meta_keylist(meta, name, true))
+ return
+ end
+ end
end
end)
+
+minetest.register_on_leaveplayer(function(player)
+ local name = player:get_player_name()
+ node_meta_latest_keylist[name] = nil
+ node_meta_posses[name] = nil
+end)
diff --git a/games/devtest/mods/testtools/light.lua b/games/devtest/mods/testtools/light.lua
index a9458ca6b..afca9a489 100644
--- a/games/devtest/mods/testtools/light.lua
+++ b/games/devtest/mods/testtools/light.lua
@@ -1,22 +1,37 @@
local S = minetest.get_translator("testtools")
-minetest.register_tool("testtools:lighttool", {
- description = S("Light tool"),
- inventory_image = "testtools_lighttool.png",
- groups = { testtool = 1, disable_repair = 1 },
- on_use = function(itemstack, user, pointed_thing)
- local pos = pointed_thing.above
+local function get_func(is_place)
+ return function(itemstack, user, pointed_thing)
+ local pos
+ if is_place then
+ pos = pointed_thing.under
+ else
+ pos = pointed_thing.above
+ end
if pointed_thing.type ~= "node" or not pos then
return
end
local node = minetest.get_node(pos)
+ local pstr = minetest.pos_to_string(pos)
local time = minetest.get_timeofday()
local sunlight = minetest.get_natural_light(pos)
local artificial = minetest.get_artificial_light(node.param1)
- local message = ("param1 0x%02x | time %.5f | sunlight %d | artificial %d")
- :format(node.param1, time, sunlight, artificial)
+ local message = ("pos=%s | param1=0x%02x | " ..
+ "sunlight=%d | artificial=%d | timeofday=%.5f" )
+ :format(pstr, node.param1, sunlight, artificial, time)
minetest.chat_send_player(user:get_player_name(), message)
end
+end
+
+minetest.register_tool("testtools:lighttool", {
+ description = S("Light Tool") .. "\n" ..
+ S("Show light values of node") .. "\n" ..
+ S("Punch: Light of node above touched node") .. "\n" ..
+ S("Place: Light of touched node itself"),
+ inventory_image = "testtools_lighttool.png",
+ groups = { testtool = 1, disable_repair = 1 },
+ on_use = get_func(false),
+ on_place = get_func(true),
})
diff --git a/games/devtest/mods/testtools/textures/testtools_children_getter.png b/games/devtest/mods/testtools/textures/testtools_children_getter.png
new file mode 100644
index 000000000..b7fa34025
--- /dev/null
+++ b/games/devtest/mods/testtools/textures/testtools_children_getter.png
Binary files differ
diff --git a/games/devtest/mods/testtools/textures/testtools_node_meta_editor.png b/games/devtest/mods/testtools/textures/testtools_node_meta_editor.png
new file mode 100644
index 000000000..89eafd65c
--- /dev/null
+++ b/games/devtest/mods/testtools/textures/testtools_node_meta_editor.png
Binary files differ
diff --git a/games/devtest/mods/unittests/itemdescription.lua b/games/devtest/mods/unittests/itemdescription.lua
index 1d0826545..d6ee6551a 100644
--- a/games/devtest/mods/unittests/itemdescription.lua
+++ b/games/devtest/mods/unittests/itemdescription.lua
@@ -26,15 +26,22 @@ minetest.register_chatcommand("item_description", {
})
function unittests.test_short_desc()
+ local function get_short_description(item)
+ return ItemStack(item):get_short_description()
+ end
+
local stack = ItemStack("unittests:colorful_pick")
assert(stack:get_short_description() == "Colorful Pickaxe")
- assert(stack:get_short_description() == minetest.registered_items["unittests:colorful_pick"].short_description)
+ assert(get_short_description("unittests:colorful_pick") == "Colorful Pickaxe")
+ assert(minetest.registered_items["unittests:colorful_pick"].short_description == nil)
assert(stack:get_description() == full_description)
assert(stack:get_description() == minetest.registered_items["unittests:colorful_pick"].description)
stack:get_meta():set_string("description", "Hello World")
- assert(stack:get_short_description() == "Colorful Pickaxe")
+ assert(stack:get_short_description() == "Hello World")
assert(stack:get_description() == "Hello World")
+ assert(get_short_description(stack) == "Hello World")
+ assert(get_short_description("unittests:colorful_pick") == "Colorful Pickaxe")
stack:get_meta():set_string("short_description", "Foo Bar")
assert(stack:get_short_description() == "Foo Bar")
diff --git a/games/devtest/mods/unittests/mod.conf b/games/devtest/mods/unittests/mod.conf
index 0d5e3c959..fa94e01a6 100644
--- a/games/devtest/mods/unittests/mod.conf
+++ b/games/devtest/mods/unittests/mod.conf
@@ -1,2 +1,3 @@
name = unittests
description = Adds automated unit tests for the engine
+depends = basenodes
diff --git a/games/devtest/mods/unittests/textures/default_dirt.png b/games/devtest/mods/unittests/textures/default_dirt.png
new file mode 100644
index 000000000..58670305d
--- /dev/null
+++ b/games/devtest/mods/unittests/textures/default_dirt.png
Binary files differ