industrialtest/tools/common.lua

64 lines
2.9 KiB
Lua
Raw Normal View History

2024-01-06 21:55:06 +01:00
-- IndustrialTest
-- Copyright (C) 2024 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/>.
industrialtest.internal.registeredElectricChainsaws={}
industrialtest.internal.registeredElectricDrills={}
industrialtest.internal.registeredElectricHoes={}
industrialtest.internal.registeredElectricSabers={}
minetest.register_on_punchnode(function(pos,node,user,pointed)
if user then
local itemstack=user:get_wielded_item()
if industrialtest.internal.registeredElectricChainsaws[itemstack:get_name()] then
local meta=itemstack:get_meta()
if meta:get_int("industrialtest.powerAmount")>=20 then
local def=minetest.registered_nodes[node.name]
if (industrialtest.mtgAvailable and def.groups and def.groups.choppy) or (industrialtest.mclAvailable and def.groups and def.groups.axey) then
itemstack:set_name(itemstack:get_name().."_active")
user:set_wielded_item(itemstack)
end
end
elseif industrialtest.mclAvailable and industrialtest.internal.registeredElectricHoes[itemstack:get_name()] then
local meta=itemstack:get_meta()
if meta:get_int("industrialtest.powerAmount")>=20 then
local def=minetest.registered_nodes[node.name]
if def.groups and def.groups.hoey then
itemstack:set_name(itemstack:get_name().."_active")
user:set_wielded_item(itemstack)
end
end
elseif industrialtest.internal.registeredElectricDrills[itemstack:get_name()] then
local meta=itemstack:get_meta()
if meta:get_int("industrialtest.powerAmount")>=20 then
local def=minetest.registered_nodes[node.name]
if (industrialtest.mtgAvailable and def.groups and (def.groups.cracky or def.groups.crumbly)) or (industrialtest.mclAvailable and def.groups and (def.groups.pickaxey or def.groups.shovely)) then
itemstack:set_name(itemstack:get_name().."_active")
user:set_wielded_item(itemstack)
end
end
elseif industrialtest.internal.registeredElectricSabers[itemstack:get_name()] then
local meta=itemstack:get_meta()
if meta:get_int("industrialtest.powerAmount")>=20 then
local def=minetest.registered_nodes[node.name]
if (industrialtest.mtgAvailable and def.groups and def.groups.snappy) or (industrialtest.mclAvailable and def.groups and (def.groups.swordy or def.groups.swordy_cobweb)) then
itemstack:set_name(itemstack:get_name().."_active")
user:set_wielded_item(itemstack)
end
end
end
end
end)