Zefram
2014-04-28 99fd5dfee5a70b0656e40787168d2c67ba417738
refs
author Zefram <zefram@fysh.org>
Monday, April 28, 2014 11:44 +0200
committer Zefram <zefram@fysh.org>
Wednesday, April 30, 2014 01:21 +0200
commit99fd5dfee5a70b0656e40787168d2c67ba417738
tree d25ae81f2ca71b7825bb5873ca5dcfb7ec32eec9 tree | zip | gz
parent ca69473664d4212aa787e4dca3cd7a918788c724 view | diff
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.
10 files modified
28 ■■■■ changed files
technic/items.lua 3 ●●●●● diff | view | raw | blame | history
technic/machines/MV/tool_workshop.lua 12 ●●●●● diff | view | raw | blame | history
technic/machines/register/battery_box.lua 1 ●●●● diff | view | raw | blame | history
technic/register.lua 1 ●●●● diff | view | raw | blame | history
technic/tools/cans.lua 2 ●●●●● diff | view | raw | blame | history
technic/tools/chainsaw.lua 1 ●●●● diff | view | raw | blame | history
technic/tools/flashlight.lua 1 ●●●● diff | view | raw | blame | history
technic/tools/mining_drill.lua 5 ●●●●● diff | view | raw | blame | history
technic/tools/mining_lasers.lua 1 ●●●● diff | view | raw | blame | history
technic/tools/sonic_screwdriver.lua 1 ●●●● diff | view | raw | blame | history