aboutsummaryrefslogtreecommitdiff
path: root/games/minimal/mods/experimental/items.lua
diff options
context:
space:
mode:
authorWuzzy <wuzzy2@mail.ru>2020-05-24 15:46:26 +0200
committerGitHub <noreply@github.com>2020-05-24 14:46:26 +0100
commit6456aba73f0ef3f2fa7fd2b2a69cfdf8624afe23 (patch)
treef2bada583c6f4d3032f28b2627bf052174f0a847 /games/minimal/mods/experimental/items.lua
parenta9b74f4c3966ad38c2f9a97364d3fdda0e514c93 (diff)
downloadminetest-6456aba73f0ef3f2fa7fd2b2a69cfdf8624afe23.tar.gz
minetest-6456aba73f0ef3f2fa7fd2b2a69cfdf8624afe23.tar.bz2
minetest-6456aba73f0ef3f2fa7fd2b2a69cfdf8624afe23.zip
Replacement for Minimal Development Test (PR) (#9450)
Diffstat (limited to 'games/minimal/mods/experimental/items.lua')
-rw-r--r--games/minimal/mods/experimental/items.lua103
1 files changed, 103 insertions, 0 deletions
diff --git a/games/minimal/mods/experimental/items.lua b/games/minimal/mods/experimental/items.lua
new file mode 100644
index 000000000..51b063ba2
--- /dev/null
+++ b/games/minimal/mods/experimental/items.lua
@@ -0,0 +1,103 @@
+minetest.register_node("experimental:callback_node", {
+ description = "Callback Test Node (construct/destruct/timer)",
+ tiles = {"experimental_callback_node.png"},
+ groups = {dig_immediate=3},
+ -- This was known to cause a bug in minetest.item_place_node() when used
+ -- via minetest.place_node(), causing a placer with no position
+ paramtype2 = "facedir",
+ drop = "",
+
+ on_construct = function(pos)
+ experimental.print_to_everything("experimental:callback_node:on_construct("..minetest.pos_to_string(pos)..")")
+ local meta = minetest.get_meta(pos)
+ meta:set_string("mine", "test")
+ local timer = minetest.get_node_timer(pos)
+ timer:start(4, 3)
+ end,
+
+ after_place_node = function(pos, placer)
+ experimental.print_to_everything("experimental:callback_node:after_place_node("..minetest.pos_to_string(pos)..")")
+ local meta = minetest.get_meta(pos)
+ if meta:get_string("mine") == "test" then
+ experimental.print_to_everything("correct metadata found")
+ else
+ experimental.print_to_everything("incorrect metadata found")
+ end
+ end,
+
+ on_destruct = function(pos)
+ experimental.print_to_everything("experimental:callback_node:on_destruct("..minetest.pos_to_string(pos)..")")
+ end,
+
+ after_destruct = function(pos)
+ experimental.print_to_everything("experimental:callback_node:after_destruct("..minetest.pos_to_string(pos)..")")
+ end,
+
+ after_dig_node = function(pos, oldnode, oldmetadata, digger)
+ experimental.print_to_everything("experimental:callback_node:after_dig_node("..minetest.pos_to_string(pos)..")")
+ end,
+
+ on_timer = function(pos, elapsed)
+ experimental.print_to_everything("on_timer(): elapsed="..dump(elapsed))
+ return true
+ end,
+})
+
+minetest.register_tool("experimental:privatizer", {
+ description = "Node Meta Privatizer",
+ inventory_image = "experimental_tester_tool_1.png",
+ groups = { testtool = 1, disable_repair = 1 },
+ on_use = function(itemstack, user, pointed_thing)
+ if pointed_thing.type == "node" then
+ local node = minetest.get_node(pointed_thing.under)
+ if node.name == "chest:chest" then
+ local p = pointed_thing.under
+ minetest.log("action", "Privatizer used at "..minetest.pos_to_string(p))
+ minetest.get_meta(p):mark_as_private({"infotext", "formspec"})
+ if user and user:is_player() then
+ minetest.chat_send_player(user:get_player_name(), "Chest metadata (infotext, formspec) set private!")
+ end
+ return
+ end
+ end
+ if user and user:is_player() then
+ minetest.chat_send_player(user:get_player_name(), "Privatizer can only be used on chest!")
+ end
+ end,
+})
+
+minetest.register_tool("experimental:particle_spawner", {
+ description = "Particle Spawner",
+ inventory_image = "experimental_tester_tool_1.png^[invert:g",
+ groups = { testtool = 1, disable_repair = 1 },
+ on_use = function(itemstack, user, pointed_thing)
+ local pos = minetest.get_pointed_thing_position(pointed_thing, true)
+ if pos == nil then
+ if user then
+ pos = user:get_pos()
+ end
+ end
+ pos = vector.add(pos, {x=0, y=0.5, z=0})
+ local tex, anim
+ if math.random(0, 1) == 0 then
+ tex = "experimental_particle_sheet.png"
+ anim = {type="sheet_2d", frames_w=3, frames_h=2, frame_length=0.5}
+ else
+ tex = "experimental_particle_vertical.png"
+ anim = {type="vertical_frames", aspect_w=16, aspect_h=16, length=3.3}
+ end
+
+ minetest.add_particle({
+ pos = pos,
+ velocity = {x=0, y=0, z=0},
+ acceleration = {x=0, y=0.04, z=0},
+ expirationtime = 6,
+ collisiondetection = true,
+ texture = tex,
+ animation = anim,
+ size = 4,
+ glow = math.random(0, 5),
+ })
+ end,
+})
+