summaryrefslogtreecommitdiff
path: root/games/devtest/mods/testentities
diff options
context:
space:
mode:
authorWuzzy <wuzzy2@mail.ru>2020-05-26 00:17:52 +0200
committerGitHub <noreply@github.com>2020-05-26 00:17:52 +0200
commit083b285f4319c470f307f0b52f03a2fb68facd38 (patch)
treebdd02540ad58756a38606f03a995ab837a176709 /games/devtest/mods/testentities
parentb546e8938d41aa9e3101fb9d4d5b02924ed73b60 (diff)
downloadminetest-083b285f4319c470f307f0b52f03a2fb68facd38.tar.gz
minetest-083b285f4319c470f307f0b52f03a2fb68facd38.tar.bz2
minetest-083b285f4319c470f307f0b52f03a2fb68facd38.zip
Rename “Minimal development test” to “Development Test” (#9928)
Diffstat (limited to 'games/devtest/mods/testentities')
-rw-r--r--games/devtest/mods/testentities/armor.lua41
-rw-r--r--games/devtest/mods/testentities/callbacks.lua75
-rw-r--r--games/devtest/mods/testentities/init.lua3
-rw-r--r--games/devtest/mods/testentities/mod.conf2
-rw-r--r--games/devtest/mods/testentities/textures/testentities_armorball.pngbin0 -> 561 bytes
-rw-r--r--games/devtest/mods/testentities/textures/testentities_callback.pngbin0 -> 156 bytes
-rw-r--r--games/devtest/mods/testentities/textures/testentities_callback_step.pngbin0 -> 166 bytes
-rw-r--r--games/devtest/mods/testentities/textures/testentities_cube1.pngbin0 -> 130 bytes
-rw-r--r--games/devtest/mods/testentities/textures/testentities_cube2.pngbin0 -> 128 bytes
-rw-r--r--games/devtest/mods/testentities/textures/testentities_cube3.pngbin0 -> 124 bytes
-rw-r--r--games/devtest/mods/testentities/textures/testentities_cube4.pngbin0 -> 126 bytes
-rw-r--r--games/devtest/mods/testentities/textures/testentities_cube5.pngbin0 -> 126 bytes
-rw-r--r--games/devtest/mods/testentities/textures/testentities_cube6.pngbin0 -> 126 bytes
-rw-r--r--games/devtest/mods/testentities/textures/testentities_dungeon_master.pngbin0 -> 2855 bytes
-rw-r--r--games/devtest/mods/testentities/textures/testentities_sprite.pngbin0 -> 120 bytes
-rw-r--r--games/devtest/mods/testentities/textures/testentities_upright_sprite1.pngbin0 -> 114 bytes
-rw-r--r--games/devtest/mods/testentities/textures/testentities_upright_sprite2.pngbin0 -> 119 bytes
-rw-r--r--games/devtest/mods/testentities/visuals.lua74
18 files changed, 195 insertions, 0 deletions
diff --git a/games/devtest/mods/testentities/armor.lua b/games/devtest/mods/testentities/armor.lua
new file mode 100644
index 000000000..4c30cec8d
--- /dev/null
+++ b/games/devtest/mods/testentities/armor.lua
@@ -0,0 +1,41 @@
+-- Armorball: Test entity for testing armor groups
+-- Rightclick to change armor group
+
+local phasearmor = {
+ [0]={icy=100},
+ [1]={firy=100},
+ [2]={fleshy=100},
+ [3]={immortal=1},
+ [4]={punch_operable=1},
+}
+
+minetest.register_entity("testentities:armorball", {
+ initial_properties = {
+ hp_max = 20,
+ physical = false,
+ collisionbox = {-0.4,-0.4,-0.4, 0.4,0.4,0.4},
+ visual = "sprite",
+ visual_size = {x=1, y=1},
+ textures = {"testentities_armorball.png"},
+ spritediv = {x=1, y=5},
+ initial_sprite_basepos = {x=0, y=0},
+ },
+
+ _phase = 2,
+
+ on_activate = function(self, staticdata)
+ minetest.log("action", "[testentities] armorball.on_activate")
+ self.object:set_armor_groups(phasearmor[self._phase])
+ self.object:set_sprite({x=0, y=self._phase})
+ end,
+
+ on_rightclick = function(self, clicker)
+ -- Change armor group and sprite
+ self._phase = self._phase + 1
+ if self._phase >= 5 then
+ self._phase = 0
+ end
+ self.object:set_sprite({x=0, y=self._phase})
+ self.object:set_armor_groups(phasearmor[self._phase])
+ end,
+})
diff --git a/games/devtest/mods/testentities/callbacks.lua b/games/devtest/mods/testentities/callbacks.lua
new file mode 100644
index 000000000..711079f87
--- /dev/null
+++ b/games/devtest/mods/testentities/callbacks.lua
@@ -0,0 +1,75 @@
+-- Entities that test their callbacks
+
+local message = function(msg)
+ minetest.log("action", msg)
+ minetest.chat_send_all(msg)
+end
+
+local get_object_name = function(obj)
+ local name = "<nil>"
+ if obj then
+ if obj:is_player() then
+ name = obj:get_player_name()
+ else
+ name = "<entity>"
+ end
+ end
+ return name
+end
+
+local spos = function(self)
+ return minetest.pos_to_string(vector.round(self.object:get_pos()))
+end
+
+-- Callback test entity (all callbacks except on_step)
+minetest.register_entity("testentities:callback", {
+ initial_properties = {
+ visual = "upright_sprite",
+ textures = { "testentities_callback.png" },
+ },
+
+ on_activate = function(self, staticdata, dtime_s)
+ message("Callback entity: on_activate! pos="..spos(self).."; dtime_s="..dtime_s)
+ end,
+ on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)
+ local name = get_object_name(puncher)
+ message(
+ "Callback entity: on_punch! "..
+ "pos="..spos(self).."; puncher="..name.."; "..
+ "time_from_last_punch="..time_from_last_punch.."; "..
+ "tool_capabilities="..tostring(dump(tool_capabilities)).."; "..
+ "dir="..tostring(dump(dir)).."; damage="..damage)
+ end,
+ on_rightclick = function(self, clicker)
+ local name = get_object_name(clicker)
+ message("Callback entity: on_rightclick! pos="..spos(self).."; clicker="..name)
+ end,
+ on_death = function(self, killer)
+ local name = get_object_name(killer)
+ message("Callback entity: on_death! pos="..spos(self).."; killer="..name)
+ end,
+ on_attach_child = function(self, child)
+ local name = get_object_name(child)
+ message("Callback entity: on_attach_child! pos="..spos(self).."; child="..name)
+ end,
+ on_detach_child = function(self, child)
+ local name = get_object_name(child)
+ message("Callback entity: on_detach_child! pos="..spos(self).."; child="..name)
+ end,
+ on_detach = function(self, parent)
+ local name = get_object_name(parent)
+ message("Callback entity: on_detach! pos="..spos(self).."; parent="..name)
+ end,
+ get_staticdata = function(self)
+ message("Callback entity: get_staticdata! pos="..spos(self))
+ end,
+})
+
+-- Only test on_step callback
+minetest.register_entity("testentities:callback_step", {
+ visual = "upright_sprite",
+ textures = { "testentities_callback_step.png" },
+ on_step = function(self, dtime)
+ message("on_step callback entity: on_step! pos="..spos(self).."; dtime="..dtime)
+ end,
+})
diff --git a/games/devtest/mods/testentities/init.lua b/games/devtest/mods/testentities/init.lua
new file mode 100644
index 000000000..df8c72ea7
--- /dev/null
+++ b/games/devtest/mods/testentities/init.lua
@@ -0,0 +1,3 @@
+dofile(minetest.get_modpath("testentities").."/visuals.lua")
+dofile(minetest.get_modpath("testentities").."/armor.lua")
+dofile(minetest.get_modpath("testentities").."/callbacks.lua")
diff --git a/games/devtest/mods/testentities/mod.conf b/games/devtest/mods/testentities/mod.conf
new file mode 100644
index 000000000..7a8cb5a3e
--- /dev/null
+++ b/games/devtest/mods/testentities/mod.conf
@@ -0,0 +1,2 @@
+name = testentities
+description = Example entities for testing
diff --git a/games/devtest/mods/testentities/textures/testentities_armorball.png b/games/devtest/mods/testentities/textures/testentities_armorball.png
new file mode 100644
index 000000000..88147bd1f
--- /dev/null
+++ b/games/devtest/mods/testentities/textures/testentities_armorball.png
Binary files differ
diff --git a/games/devtest/mods/testentities/textures/testentities_callback.png b/games/devtest/mods/testentities/textures/testentities_callback.png
new file mode 100644
index 000000000..c4c9066d1
--- /dev/null
+++ b/games/devtest/mods/testentities/textures/testentities_callback.png
Binary files differ
diff --git a/games/devtest/mods/testentities/textures/testentities_callback_step.png b/games/devtest/mods/testentities/textures/testentities_callback_step.png
new file mode 100644
index 000000000..b67506a97
--- /dev/null
+++ b/games/devtest/mods/testentities/textures/testentities_callback_step.png
Binary files differ
diff --git a/games/devtest/mods/testentities/textures/testentities_cube1.png b/games/devtest/mods/testentities/textures/testentities_cube1.png
new file mode 100644
index 000000000..c667e425f
--- /dev/null
+++ b/games/devtest/mods/testentities/textures/testentities_cube1.png
Binary files differ
diff --git a/games/devtest/mods/testentities/textures/testentities_cube2.png b/games/devtest/mods/testentities/textures/testentities_cube2.png
new file mode 100644
index 000000000..481823420
--- /dev/null
+++ b/games/devtest/mods/testentities/textures/testentities_cube2.png
Binary files differ
diff --git a/games/devtest/mods/testentities/textures/testentities_cube3.png b/games/devtest/mods/testentities/textures/testentities_cube3.png
new file mode 100644
index 000000000..03b5daa15
--- /dev/null
+++ b/games/devtest/mods/testentities/textures/testentities_cube3.png
Binary files differ
diff --git a/games/devtest/mods/testentities/textures/testentities_cube4.png b/games/devtest/mods/testentities/textures/testentities_cube4.png
new file mode 100644
index 000000000..639204896
--- /dev/null
+++ b/games/devtest/mods/testentities/textures/testentities_cube4.png
Binary files differ
diff --git a/games/devtest/mods/testentities/textures/testentities_cube5.png b/games/devtest/mods/testentities/textures/testentities_cube5.png
new file mode 100644
index 000000000..d8acdf0b6
--- /dev/null
+++ b/games/devtest/mods/testentities/textures/testentities_cube5.png
Binary files differ
diff --git a/games/devtest/mods/testentities/textures/testentities_cube6.png b/games/devtest/mods/testentities/textures/testentities_cube6.png
new file mode 100644
index 000000000..5f81a64d9
--- /dev/null
+++ b/games/devtest/mods/testentities/textures/testentities_cube6.png
Binary files differ
diff --git a/games/devtest/mods/testentities/textures/testentities_dungeon_master.png b/games/devtest/mods/testentities/textures/testentities_dungeon_master.png
new file mode 100644
index 000000000..1e3107746
--- /dev/null
+++ b/games/devtest/mods/testentities/textures/testentities_dungeon_master.png
Binary files differ
diff --git a/games/devtest/mods/testentities/textures/testentities_sprite.png b/games/devtest/mods/testentities/textures/testentities_sprite.png
new file mode 100644
index 000000000..a4b019699
--- /dev/null
+++ b/games/devtest/mods/testentities/textures/testentities_sprite.png
Binary files differ
diff --git a/games/devtest/mods/testentities/textures/testentities_upright_sprite1.png b/games/devtest/mods/testentities/textures/testentities_upright_sprite1.png
new file mode 100644
index 000000000..6242511df
--- /dev/null
+++ b/games/devtest/mods/testentities/textures/testentities_upright_sprite1.png
Binary files differ
diff --git a/games/devtest/mods/testentities/textures/testentities_upright_sprite2.png b/games/devtest/mods/testentities/textures/testentities_upright_sprite2.png
new file mode 100644
index 000000000..a79a760e3
--- /dev/null
+++ b/games/devtest/mods/testentities/textures/testentities_upright_sprite2.png
Binary files differ
diff --git a/games/devtest/mods/testentities/visuals.lua b/games/devtest/mods/testentities/visuals.lua
new file mode 100644
index 000000000..de346fd68
--- /dev/null
+++ b/games/devtest/mods/testentities/visuals.lua
@@ -0,0 +1,74 @@
+-- Minimal test entities to test visuals
+
+minetest.register_entity("testentities:sprite", {
+ initial_properties = {
+ visual = "sprite",
+ textures = { "testentities_sprite.png" },
+ },
+})
+
+minetest.register_entity("testentities:upright_sprite", {
+ initial_properties = {
+ visual = "upright_sprite",
+ textures = {
+ "testentities_upright_sprite1.png",
+ "testentities_upright_sprite2.png",
+ },
+ },
+})
+
+minetest.register_entity("testentities:cube", {
+ initial_properties = {
+ visual = "cube",
+ textures = {
+ "testentities_cube1.png",
+ "testentities_cube2.png",
+ "testentities_cube3.png",
+ "testentities_cube4.png",
+ "testentities_cube5.png",
+ "testentities_cube6.png",
+ },
+ },
+})
+
+minetest.register_entity("testentities:item", {
+ initial_properties = {
+ visual = "item",
+ wield_item = "testnodes:normal",
+ },
+})
+
+minetest.register_entity("testentities:wielditem", {
+ initial_properties = {
+ visual = "wielditem",
+ wield_item = "testnodes:normal",
+ },
+})
+
+minetest.register_entity("testentities:mesh", {
+ initial_properties = {
+ visual = "mesh",
+ mesh = "testnodes_pyramid.obj",
+ textures = {
+ "testnodes_mesh_stripes2.png"
+ },
+ },
+})
+
+-- Advanced visual tests
+
+-- A test entity for testing animated and yaw-modulated sprites
+minetest.register_entity("testentities:yawsprite", {
+ initial_properties = {
+ selectionbox = {-0.3, -0.5, -0.3, 0.3, 0.3, 0.3},
+ visual = "sprite",
+ visual_size = {x=0.6666, y=1},
+ textures = {"testentities_dungeon_master.png^[makealpha:128,0,0^[makealpha:128,128,0"},
+ spritediv = {x=6, y=5},
+ initial_sprite_basepos = {x=0, y=0},
+ on_activate = function(self, staticdata)
+ self.object:set_sprite({x=0, y=0}, 1, 0, true)
+ end,
+ },
+})
+