mirror of
https://github.com/minetest-mods/technic.git
synced 2024-09-24 21:40:19 +02:00
7c4b7046cc
All electrically-powered machines now consistently indicate their tier (supply voltage) in their names. As this implies that they are electrically powered, the furnaces no longer have "Electric" in their names. The fuel-fired equivalents of electric machines, which exist for alloy furnace and furnace, now say "Fuel-Fired" to distinguish them. (The fuel-fired alloy furnace used to say "Coal", which was inaccurate because it uses any fuel. The fuel-fired furnace, from the default mod, used to just be called "Furnace", which is ambiguous.) Electric power generators now consistently indicate their tier and have the word "Generator" in their names. This makes their purpose much clearer, and makes obvious craft guide searches produce useful results. The fuel-fired generators, previously just (ambiguously) called "Generator", are now explicitly "Fuel-Fired".
93 lines
2.9 KiB
Lua
93 lines
2.9 KiB
Lua
-- Tool workshop
|
|
-- This machine repairs tools.
|
|
|
|
minetest.register_alias("tool_workshop", "technic:tool_workshop")
|
|
|
|
local S = technic.getter
|
|
|
|
minetest.register_craft({
|
|
output = 'technic:tool_workshop',
|
|
recipe = {
|
|
{'group:wood', 'group:wood', 'group:wood'},
|
|
{'group:wood', 'default:diamond', 'group:wood'},
|
|
{'default:stone', 'default:copper_ingot', 'default:stone'},
|
|
}
|
|
})
|
|
|
|
local workshop_formspec =
|
|
"invsize[8,9;]"..
|
|
"list[current_name;src;3,1;1,1;]"..
|
|
"label[0,0;"..S("%s Tool Workshop"):format("MV").."]"..
|
|
"list[current_player;main;0,5;8,4;]"
|
|
|
|
minetest.register_node("technic:tool_workshop", {
|
|
description = S("%s Tool Workshop"):format("MV"),
|
|
tiles = {"technic_workshop_top.png", "technic_machine_bottom.png", "technic_workshop_side.png",
|
|
"technic_workshop_side.png", "technic_workshop_side.png", "technic_workshop_side.png"},
|
|
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
|
sounds = default.node_sound_wood_defaults(),
|
|
on_construct = function(pos)
|
|
local meta = minetest.get_meta(pos)
|
|
meta:set_string("infotext", S("%s Tool Workshop"):format("MV"))
|
|
meta:set_string("formspec", workshop_formspec)
|
|
local inv = meta:get_inventory()
|
|
inv:set_size("src", 1)
|
|
end,
|
|
can_dig = technic.machine_can_dig,
|
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
|
})
|
|
|
|
minetest.register_abm({
|
|
nodenames = {"technic:tool_workshop"},
|
|
interval = 1,
|
|
chance = 1,
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
local meta = minetest.get_meta(pos)
|
|
local inv = meta:get_inventory()
|
|
local eu_input = meta:get_int("MV_EU_input")
|
|
local machine_name = S("%s Tool Workshop"):format("MV")
|
|
local machine_node = "technic:tool_workshop"
|
|
local demand = 5000
|
|
|
|
-- Setup meta data if it does not exist.
|
|
if not eu_input then
|
|
meta:set_int("MV_EU_demand", demand)
|
|
meta:set_int("MV_EU_input", 0)
|
|
return
|
|
end
|
|
|
|
-- Power off automatically if no longer connected to a switching station
|
|
technic.switching_station_timeout_count(pos, "MV")
|
|
|
|
local repairable = false
|
|
local srcstack = inv:get_stack("src", 1)
|
|
if not srcstack:is_empty() then
|
|
local itemdef = minetest.registered_items[srcstack:get_name()]
|
|
if itemdef and
|
|
(not itemdef.wear_represents or
|
|
itemdef.wear_represents == "mechanical_wear") and
|
|
srcstack:get_wear() ~= 0 then
|
|
repairable = true
|
|
end
|
|
end
|
|
if not repairable then
|
|
meta:set_string("infotext", S("%s Idle"):format(machine_name))
|
|
meta:set_int("MV_EU_demand", 0)
|
|
return
|
|
end
|
|
|
|
if eu_input < demand then
|
|
meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
|
|
elseif eu_input >= demand then
|
|
meta:set_string("infotext", S("%s Active"):format(machine_name))
|
|
srcstack:add_wear(-1000)
|
|
inv:set_stack("src", 1, srcstack)
|
|
end
|
|
meta:set_int("MV_EU_demand", demand)
|
|
end
|
|
})
|
|
|
|
technic.register_machine("MV", "technic:tool_workshop", technic.receiver)
|
|
|