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 M = minetest.get_meta
|
2019-07-02 22:33:12 +03:00
|
|
|
local S = techage.S
|
2019-04-28 22:34:21 +03:00
|
|
|
|
|
|
|
local function read_state(itemstack, user, pointed_thing)
|
|
|
|
local pos = pointed_thing.under
|
2019-06-29 00:46:44 +03:00
|
|
|
if pos and user then
|
2019-08-21 22:52:11 +03:00
|
|
|
local data = minetest.get_biome_data(pos)
|
|
|
|
if data then
|
2019-08-22 21:22:52 +03:00
|
|
|
minetest.chat_send_player(user:get_player_name(), S("Position temperature")..": "..math.floor(data.heat).." ")
|
2019-08-21 22:52:11 +03:00
|
|
|
end
|
2019-05-11 02:21:03 +03:00
|
|
|
local number = techage.get_node_number(pos)
|
2019-07-02 22:33:12 +03:00
|
|
|
local ndef = minetest.registered_nodes[minetest.get_node(pos).name]
|
2019-04-28 22:34:21 +03:00
|
|
|
if number then
|
2019-06-29 00:46:44 +03:00
|
|
|
if ndef and ndef.description then
|
2019-08-07 23:26:38 +03:00
|
|
|
local info = techage.send_single(number, "info", nil)
|
|
|
|
if info and info ~= "" and info ~= "unsupported" then
|
|
|
|
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": Supported Commands:\n"..info.." ")
|
|
|
|
end
|
2019-06-29 00:46:44 +03:00
|
|
|
local state = techage.send_single(number, "state", nil)
|
|
|
|
if state and state ~= "" and state ~= "unsupported" then
|
|
|
|
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": state = "..state.." ")
|
|
|
|
end
|
|
|
|
local fuel = techage.send_single(number, "fuel", nil)
|
|
|
|
if fuel and fuel ~= "" and fuel ~= "unsupported" then
|
|
|
|
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": fuel = "..fuel.." ")
|
|
|
|
end
|
|
|
|
local counter = techage.send_single(number, "counter", nil)
|
|
|
|
if counter and counter ~= "" and counter ~= "unsupported" then
|
|
|
|
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": counter = "..counter.." ")
|
|
|
|
end
|
|
|
|
local load = techage.send_single(number, "load", nil)
|
|
|
|
if load and load ~= "" and load ~= "unsupported" then
|
|
|
|
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": load = "..load.." % ")
|
|
|
|
end
|
2019-07-02 22:33:12 +03:00
|
|
|
local power = techage.send_single(number, "power", nil)
|
|
|
|
if power and power ~= "" and power ~= "unsupported" then
|
|
|
|
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": power = "..power.." % ")
|
|
|
|
end
|
2019-06-29 00:46:44 +03:00
|
|
|
itemstack:add_wear(65636/200)
|
|
|
|
return itemstack
|
2019-04-28 22:34:21 +03:00
|
|
|
end
|
2019-07-02 22:33:12 +03:00
|
|
|
elseif ndef and ndef.description then
|
|
|
|
if ndef.is_power_available then
|
|
|
|
local power = ndef.is_power_available(pos)
|
2019-08-17 00:44:11 +03:00
|
|
|
if power and power.prim_available then
|
2019-08-18 19:02:14 +03:00
|
|
|
local text = "\nGenerators: "..power.prim_available.." ku\nAkkus: "..power.sec_available.." ku\nMachines: "..power.prim_needed.." ku\nNum Nodes: "..power.num_nodes.."\n"
|
|
|
|
minetest.chat_send_player(user:get_player_name(), ndef.description..":"..text)
|
2019-08-17 00:44:11 +03:00
|
|
|
end
|
2019-07-02 22:33:12 +03:00
|
|
|
end
|
|
|
|
itemstack:add_wear(65636/200)
|
|
|
|
return itemstack
|
2019-04-28 22:34:21 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-05-16 23:22:24 +03:00
|
|
|
minetest.register_tool("techage:repairkit", {
|
2019-07-02 22:33:12 +03:00
|
|
|
description = S("TechAge Repair Kit"),
|
2019-05-11 02:21:03 +03:00
|
|
|
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-06-29 00:46:44 +03:00
|
|
|
stack_max = 1,
|
2019-04-28 22:34:21 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
|
2019-06-29 00:46:44 +03:00
|
|
|
minetest.register_tool("techage:end_wrench", {
|
2019-08-22 21:22:52 +03:00
|
|
|
description = S("TechAge Info Tool (use = read status info)"),
|
2019-05-11 02:21:03 +03:00
|
|
|
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 = "",
|
2019-06-29 00:46:44 +03:00
|
|
|
stack_max = 1,
|
2019-04-28 22:34:21 +03:00
|
|
|
})
|
|
|
|
|
2019-08-22 21:22:52 +03:00
|
|
|
--minetest.register_craft({
|
|
|
|
-- output = "techage:repairkit",
|
|
|
|
-- recipe = {
|
|
|
|
-- {"", "basic_materials:gear_steel", ""},
|
|
|
|
-- {"", "techage:end_wrench", ""},
|
|
|
|
-- {"", "basic_materials:oil_extract", ""},
|
|
|
|
-- },
|
|
|
|
--})
|
2019-04-28 22:34:21 +03:00
|
|
|
|
|
|
|
minetest.register_craft({
|
2019-06-29 00:46:44 +03:00
|
|
|
output = "techage:end_wrench",
|
2019-04-28 22:34:21 +03:00
|
|
|
recipe = {
|
|
|
|
{"", "", "default:steel_ingot"},
|
2019-06-29 00:46:44 +03:00
|
|
|
{"", "techage:iron_ingot", ""},
|
2019-04-28 22:34:21 +03:00
|
|
|
{"default:steel_ingot", "", ""},
|
|
|
|
},
|
|
|
|
})
|
2019-07-02 22:33:12 +03:00
|
|
|
|
|
|
|
techage.register_entry_page("ta", "end_wrench",
|
2019-08-22 21:22:52 +03:00
|
|
|
S("TechAge Info Tool"),
|
|
|
|
S("The TechAge Info Tool is a tool to read any kind of status information from nodes providing a command interface.@n"..
|
|
|
|
"Click on the node to read the status"),
|
2019-07-02 22:33:12 +03:00
|
|
|
"techage:end_wrench")
|
|
|
|
|