diff --git a/.test/testblock.lua b/.test/testblock.lua new file mode 100644 index 0000000..7a78cf6 --- /dev/null +++ b/.test/testblock.lua @@ -0,0 +1,43 @@ +local M = minetest.get_meta + +minetest.register_node("techage:testblock", { + description = "Testblock", + tiles = { + "techage_top_ta4.png", + "techage_filling_ta4.png^techage_frame_ta4.png", + }, + paramtype2 = "facedir", + groups = {cracky=2, crumbly=2, choppy=2}, + is_ground_content = false, + + after_place_node = function(pos, placer) + local nvm = techage.get_nvm(pos) + nvm.test_val = 1 + M(pos):set_int("test_val", 1) + M(pos):set_string("infotext", "Value = " .. 1) + end, +}) + +minetest.register_lbm({ + label = "Update testblock", + name = "techage:update_testblock", + + nodenames = { + "techage:testblock", + }, + + run_at_every_load = true, + + action = function(pos, node) + local nvm = techage.get_nvm(pos) + if M(pos):get_int("test_val") == nvm.test_val then + nvm.test_val = nvm.test_val + 1 + M(pos):set_int("test_val", nvm.test_val) + M(pos):set_string("infotext", "Value = " .. nvm.test_val) + else + minetest.log("error", "[techage] Memory error at " .. minetest.pos_to_string(pos)) + M(pos):set_string("infotext", "Error") + end + end, +}) + diff --git a/init.lua b/init.lua index 4037477..3863a85 100644 --- a/init.lua +++ b/init.lua @@ -315,6 +315,7 @@ if techage.recipe_checker_enabled then dofile(MP.."/recipe_checker.lua") end dofile(MP.."/.test/sink.lua") +dofile(MP.."/.test/testblock.lua") -- Solar dofile(MP.."/solar/minicell.lua")