Each block supporting the "defect" state can now be set to "defect" by means of the Tubelib End Wrench (for Controller program testing purposes)

This commit is contained in:
Joachim Stolberg 2019-01-03 18:50:07 +01:00
parent a865fa1e2f
commit a2049a0b77
2 changed files with 12 additions and 2 deletions

@ -307,7 +307,8 @@ function NodeStates:keep_running(pos, meta, val, num_items)
if self.aging_level1 then
local cnt = meta:get_int("tubelib_aging") + num_items
meta:set_int("tubelib_aging", cnt)
if cnt > (self.aging_level1) and math.random(self.aging_level2/num_items) == 1 then
if (cnt > (self.aging_level1) and math.random(self.aging_level2/num_items) == 1)
or cnt >= 999999 then
self:defect(pos, meta)
end
end

@ -16,6 +16,14 @@ local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
local M = minetest.get_meta
local function destroy_node(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then
local pos = pointed_thing.under
if not minetest.is_protected(pos, placer:get_player_name()) then
M(pos):set_int("tubelib_aging", 999999)
end
end
end
local function repair_node(itemstack, user, pointed_thing)
local pos = pointed_thing.under
@ -55,11 +63,12 @@ minetest.register_craftitem("tubelib:repairkit", {
minetest.register_node("tubelib:end_wrench", {
description = "Tubelib End Wrench",
description = "Tubelib End Wrench (use = read status, place = destroy)",
inventory_image = "tubelib_end_wrench.png",
wield_image = "tubelib_end_wrench.png",
groups = {cracky=1, book=1},
on_use = read_state,
on_place = destroy_node,
node_placement_prediction = "",
})