2019-04-28 22:34:21 +03:00
|
|
|
--[[
|
|
|
|
|
2019-05-11 02:21:03 +03:00
|
|
|
TexchAge
|
|
|
|
========
|
2019-04-28 22:34:21 +03:00
|
|
|
|
2019-05-11 02:21:03 +03:00
|
|
|
Copyright (C) 2017-2019 Joachim Stolberg
|
2019-04-28 22:34:21 +03:00
|
|
|
|
|
|
|
LGPLv2.1+
|
|
|
|
See LICENSE.txt for more information
|
|
|
|
|
|
|
|
repairkit.lua:
|
|
|
|
]]--
|
|
|
|
|
|
|
|
-- for lazy programmers
|
|
|
|
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
|
|
|
|
|
2019-06-16 22:06:16 +03:00
|
|
|
--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
|
|
|
|
-- local mem = tubelib2.get_mem(pos)
|
|
|
|
-- mem.techage_aging = 999999
|
|
|
|
-- end
|
|
|
|
-- end
|
|
|
|
--end
|
2019-04-28 22:34:21 +03:00
|
|
|
|
2019-06-16 22:06:16 +03:00
|
|
|
--local function repair_node(itemstack, user, pointed_thing)
|
|
|
|
-- local pos = pointed_thing.under
|
|
|
|
-- if pos then
|
|
|
|
-- if techage.repair_node(pos) then
|
|
|
|
-- minetest.chat_send_player(user:get_player_name(), "[TechAge] Node repaired")
|
|
|
|
-- itemstack:add_wear(13108)
|
|
|
|
-- return itemstack
|
|
|
|
-- end
|
|
|
|
-- end
|
|
|
|
-- return
|
|
|
|
--end
|
2019-04-28 22:34:21 +03:00
|
|
|
|
|
|
|
local function read_state(itemstack, user, pointed_thing)
|
|
|
|
local pos = pointed_thing.under
|
|
|
|
if pos then
|
2019-05-11 02:21:03 +03:00
|
|
|
local number = techage.get_node_number(pos)
|
2019-04-28 22:34:21 +03:00
|
|
|
if number then
|
2019-06-09 18:20:40 +03:00
|
|
|
local state = techage.send_single(number, "state", nil)
|
|
|
|
local counter = techage.send_single(number, "counter", nil)
|
2019-06-16 22:06:16 +03:00
|
|
|
if state and counter then
|
2019-04-28 22:34:21 +03:00
|
|
|
if type(counter) ~= "number" then counter = "unknown" end
|
2019-06-16 22:06:16 +03:00
|
|
|
minetest.chat_send_player(user:get_player_name(), "[TechAge] state ="..state..", counter = "..counter)
|
2019-04-28 22:34:21 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-05-16 23:22:24 +03:00
|
|
|
minetest.register_tool("techage:repairkit", {
|
2019-05-11 02:21:03 +03:00
|
|
|
description = "TechAge Repair Kit",
|
|
|
|
inventory_image = "techage_repairkit.png",
|
|
|
|
wield_image = "techage_repairkit.png^[transformR270",
|
2019-04-28 22:34:21 +03:00
|
|
|
groups = {cracky=1, book=1},
|
2019-06-16 22:06:16 +03:00
|
|
|
on_use = read_state,
|
2019-04-28 22:34:21 +03:00
|
|
|
node_placement_prediction = "",
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2019-05-11 02:21:03 +03:00
|
|
|
minetest.register_node("techage:end_wrench", {
|
|
|
|
description = "TechAge End Wrench (use = read status, place = destroy)",
|
|
|
|
inventory_image = "techage_end_wrench.png",
|
|
|
|
wield_image = "techage_end_wrench.png",
|
2019-04-28 22:34:21 +03:00
|
|
|
groups = {cracky=1, book=1},
|
|
|
|
on_use = read_state,
|
2019-06-16 22:06:16 +03:00
|
|
|
on_place = read_state,
|
2019-04-28 22:34:21 +03:00
|
|
|
node_placement_prediction = "",
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
2019-05-11 02:21:03 +03:00
|
|
|
output = "techage:repairkit",
|
2019-04-28 22:34:21 +03:00
|
|
|
recipe = {
|
|
|
|
{"", "basic_materials:gear_steel", ""},
|
2019-05-11 02:21:03 +03:00
|
|
|
{"", "techage:end_wrench", ""},
|
2019-04-28 22:34:21 +03:00
|
|
|
{"", "basic_materials:oil_extract", ""},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
2019-05-11 02:21:03 +03:00
|
|
|
output = "techage:end_wrench 4",
|
2019-04-28 22:34:21 +03:00
|
|
|
recipe = {
|
|
|
|
{"", "", "default:steel_ingot"},
|
|
|
|
{"", "default:tin_ingot", ""},
|
|
|
|
{"default:steel_ingot", "", ""},
|
|
|
|
},
|
|
|
|
})
|