2013-10-30 18:45:32 +01:00
|
|
|
-- Tool workshop
|
2013-07-17 21:34:35 +02:00
|
|
|
-- This machine repairs tools.
|
|
|
|
|
|
|
|
minetest.register_alias("tool_workshop", "technic:tool_workshop")
|
2013-10-30 18:45:32 +01:00
|
|
|
|
|
|
|
local S = technic.getter
|
|
|
|
|
2013-07-17 21:34:35 +02:00
|
|
|
minetest.register_craft({
|
|
|
|
output = 'technic:tool_workshop',
|
|
|
|
recipe = {
|
2014-07-07 22:48:38 +02:00
|
|
|
{'group:wood', 'default:diamond', 'group:wood'},
|
|
|
|
{'mesecons_pistons:piston_sticky_off', 'technic:machine_casing', 'technic:carbon_cloth'},
|
|
|
|
{'default:obsidian', 'technic:mv_cable0', 'default:obsidian'},
|
2013-07-17 21:34:35 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
local workshop_formspec =
|
|
|
|
"invsize[8,9;]"..
|
|
|
|
"list[current_name;src;3,1;1,1;]"..
|
Rationalise machine terminology
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".
2014-06-20 17:58:52 +02:00
|
|
|
"label[0,0;"..S("%s Tool Workshop"):format("MV").."]"..
|
2013-07-17 21:34:35 +02:00
|
|
|
"list[current_player;main;0,5;8,4;]"
|
|
|
|
|
|
|
|
minetest.register_node("technic:tool_workshop", {
|
Rationalise machine terminology
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".
2014-06-20 17:58:52 +02:00
|
|
|
description = S("%s Tool Workshop"):format("MV"),
|
2013-07-17 21:34:35 +02:00
|
|
|
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)
|
Rationalise machine terminology
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".
2014-06-20 17:58:52 +02:00
|
|
|
meta:set_string("infotext", S("%s Tool Workshop"):format("MV"))
|
2013-07-17 21:34:35 +02:00
|
|
|
meta:set_string("formspec", workshop_formspec)
|
|
|
|
local inv = meta:get_inventory()
|
|
|
|
inv:set_size("src", 1)
|
|
|
|
end,
|
2013-11-27 18:28:56 +01:00
|
|
|
can_dig = technic.machine_can_dig,
|
|
|
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
|
|
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
2013-07-17 21:34:35 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
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")
|
Rationalise machine terminology
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".
2014-06-20 17:58:52 +02:00
|
|
|
local machine_name = S("%s Tool Workshop"):format("MV")
|
2013-07-17 21:34:35 +02:00
|
|
|
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")
|
|
|
|
|
Genericise handling of multiple meanings of wear
The tool workshop is meant to repair mechanical damage to tools, so
is at risk of `repairing' tools that use the wear bar to represent
something other than mechanical wear. It had special-case recognition
of the water and lava cans, which use the wear bar to represent how much
content they're carrying, and wouldn't repair them. But it didn't avoid
`repairing' RE chargeable items, which use the wear bar to represent
how much energy they have stored. It would modify the wear bar without
actually affecting the charge, so the wear bar would jump back to the
correct place when the next charging or discharging event occurred.
To genericise, introduce a new item property, "wear_represents", which
indicates how the wear bar is used for this item. Currently defined
values are "mechanical_wear" (straightforward damage to tools that
start out perfect), "technic_RE_charge" (electrical energy, canonically
represented in the meta rather than the wear bar), and "content_level"
(how full a container is). For backcompat, nil is interpreted as
"mechanical_wear". The tool workshop will only repair "mechanical_wear"
tools. As a bonus, set_RE_wear() will only set the wear bar for
"technic_RE_charge" items: this means developers will notice if they
forget to declare wear_represents, but also means that with no further
changes it's possible to have an RE chargeable item that uses its wear
bar to represent something else.
2014-04-28 11:44:07 +02:00
|
|
|
local repairable = false
|
2013-12-18 01:51:38 +01:00
|
|
|
local srcstack = inv:get_stack("src", 1)
|
2014-05-31 03:00:58 +02:00
|
|
|
if not srcstack:is_empty() then
|
Genericise handling of multiple meanings of wear
The tool workshop is meant to repair mechanical damage to tools, so
is at risk of `repairing' tools that use the wear bar to represent
something other than mechanical wear. It had special-case recognition
of the water and lava cans, which use the wear bar to represent how much
content they're carrying, and wouldn't repair them. But it didn't avoid
`repairing' RE chargeable items, which use the wear bar to represent
how much energy they have stored. It would modify the wear bar without
actually affecting the charge, so the wear bar would jump back to the
correct place when the next charging or discharging event occurred.
To genericise, introduce a new item property, "wear_represents", which
indicates how the wear bar is used for this item. Currently defined
values are "mechanical_wear" (straightforward damage to tools that
start out perfect), "technic_RE_charge" (electrical energy, canonically
represented in the meta rather than the wear bar), and "content_level"
(how full a container is). For backcompat, nil is interpreted as
"mechanical_wear". The tool workshop will only repair "mechanical_wear"
tools. As a bonus, set_RE_wear() will only set the wear bar for
"technic_RE_charge" items: this means developers will notice if they
forget to declare wear_represents, but also means that with no further
changes it's possible to have an RE chargeable item that uses its wear
bar to represent something else.
2014-04-28 11:44:07 +02:00
|
|
|
local itemdef = minetest.registered_items[srcstack:get_name()]
|
2014-05-31 02:58:32 +02:00
|
|
|
if itemdef and
|
2014-05-31 03:13:14 +02:00
|
|
|
(not itemdef.wear_represents or
|
|
|
|
itemdef.wear_represents == "mechanical_wear") and
|
2014-05-31 02:58:32 +02:00
|
|
|
srcstack:get_wear() ~= 0 then
|
Genericise handling of multiple meanings of wear
The tool workshop is meant to repair mechanical damage to tools, so
is at risk of `repairing' tools that use the wear bar to represent
something other than mechanical wear. It had special-case recognition
of the water and lava cans, which use the wear bar to represent how much
content they're carrying, and wouldn't repair them. But it didn't avoid
`repairing' RE chargeable items, which use the wear bar to represent
how much energy they have stored. It would modify the wear bar without
actually affecting the charge, so the wear bar would jump back to the
correct place when the next charging or discharging event occurred.
To genericise, introduce a new item property, "wear_represents", which
indicates how the wear bar is used for this item. Currently defined
values are "mechanical_wear" (straightforward damage to tools that
start out perfect), "technic_RE_charge" (electrical energy, canonically
represented in the meta rather than the wear bar), and "content_level"
(how full a container is). For backcompat, nil is interpreted as
"mechanical_wear". The tool workshop will only repair "mechanical_wear"
tools. As a bonus, set_RE_wear() will only set the wear bar for
"technic_RE_charge" items: this means developers will notice if they
forget to declare wear_represents, but also means that with no further
changes it's possible to have an RE chargeable item that uses its wear
bar to represent something else.
2014-04-28 11:44:07 +02:00
|
|
|
repairable = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if not repairable then
|
2013-10-30 18:45:32 +01:00
|
|
|
meta:set_string("infotext", S("%s Idle"):format(machine_name))
|
2013-07-17 21:34:35 +02:00
|
|
|
meta:set_int("MV_EU_demand", 0)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
if eu_input < demand then
|
2013-10-30 18:45:32 +01:00
|
|
|
meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
|
2013-07-17 21:34:35 +02:00
|
|
|
elseif eu_input >= demand then
|
2013-10-30 18:45:32 +01:00
|
|
|
meta:set_string("infotext", S("%s Active"):format(machine_name))
|
2013-07-17 21:34:35 +02:00
|
|
|
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)
|
|
|
|
|