51 lines
1.8 KiB
Lua
51 lines
1.8 KiB
Lua
|
-- IndustrialTest
|
||
|
-- Copyright (C) 2023 mrkubax10
|
||
|
|
||
|
-- This program is free software: you can redistribute it and/or modify
|
||
|
-- it under the terms of the GNU General Public License as published by
|
||
|
-- the Free Software Foundation, either version 3 of the License, or
|
||
|
-- (at your option) any later version.
|
||
|
|
||
|
-- This program is distributed in the hope that it will be useful,
|
||
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
-- GNU General Public License for more details.
|
||
|
|
||
|
-- You should have received a copy of the GNU General Public License
|
||
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
|
||
|
local S=minetest.get_translator("industrialtest")
|
||
|
|
||
|
industrialtest.internal.applyUpgrade=function(meta,stack)
|
||
|
local def=minetest.registered_items[stack:get_name()]
|
||
|
if def.groups._industrialtest_upgradeSpeed then
|
||
|
local speed=meta:contains("industrialtest.speed") and meta:get_int("industrialtest.speed") or 1
|
||
|
meta:set_int("industrialtest.speed",math.min(4,speed+def.groups._industrialtest_upgradeSpeed))
|
||
|
end
|
||
|
end
|
||
|
|
||
|
industrialtest.internal.removeUpgrade=function(meta,stack)
|
||
|
local def=minetest.registered_items[stack:get_name()]
|
||
|
if def.groups._industrialtest_upgradeSpeed and meta:contains("industrialtest.speed") then
|
||
|
local speed=meta:get_int("industrialtest.speed")
|
||
|
meta:set_int("industrialtest.speed",math.max(1,speed-def.groups._industrialtest_upgradeSpeed))
|
||
|
end
|
||
|
end
|
||
|
|
||
|
local function registerMachineUpgrade(config)
|
||
|
minetest.register_craftitem("industrialtest:"..config.name,{
|
||
|
description=config.displayName,
|
||
|
inventory_image="industrialtest_"..config.name..".png",
|
||
|
groups={
|
||
|
_industrialtest_machineUpgrade=1,
|
||
|
_industrialtest_upgradeSpeed=config.speed or 0
|
||
|
}
|
||
|
})
|
||
|
end
|
||
|
|
||
|
registerMachineUpgrade({
|
||
|
name="overclocker_upgrade",
|
||
|
displayName=S("Overclocker Upgrade"),
|
||
|
speed=1
|
||
|
})
|