forked from mrkubax10/industrialtest
Mesecons compatibility: Rotary Macerator
This commit is contained in:
parent
e3e00e59a1
commit
f561048339
46
compat/mesecons.lua
Normal file
46
compat/mesecons.lua
Normal file
@ -0,0 +1,46 @@
|
||||
-- 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/>.
|
||||
|
||||
-- Rotary Macerator
|
||||
local override={
|
||||
mesecons={
|
||||
effector={
|
||||
action_on=function(pos,node)
|
||||
if node.name~="industrialtest:rotary_macerator" then
|
||||
return
|
||||
end
|
||||
|
||||
local meta=minetest.get_meta(pos)
|
||||
meta:set_int("maintainSpeed",1)
|
||||
|
||||
local def=minetest.registered_nodes[node.name]
|
||||
def._industrialtest_updateFormspec(pos)
|
||||
|
||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
||||
end,
|
||||
action_off=function(pos,node)
|
||||
local meta=minetest.get_meta(pos)
|
||||
meta:set_int("maintainSpeed",0)
|
||||
|
||||
local def=minetest.registered_nodes[node.name]
|
||||
def._industrialtest_updateFormspec(pos)
|
||||
end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
minetest.override_item("industrialtest:rotary_macerator",override)
|
||||
minetest.override_item("industrialtest:rotary_macerator_active",override)
|
@ -46,6 +46,7 @@ elseif industrialtest.mclAvailable then
|
||||
industrialtest.mods.mclRubber=minetest.get_modpath("mcl_rubber")
|
||||
end
|
||||
industrialtest.mods.pipeworks=minetest.get_modpath("pipeworks")
|
||||
industrialtest.mods.mesecons=minetest.get_modpath("mesecons")
|
||||
|
||||
if industrialtest.mtgAvailable and not industrialtest.mods._3dArmor then
|
||||
error("IndustrialTest requires 3D Armor when used with Minetest Game")
|
||||
|
3
init.lua
3
init.lua
@ -83,3 +83,6 @@ dofile(modpath.."/crafts.lua")
|
||||
if industrialtest.mods.pipeworks then
|
||||
dofile(modpath.."/compat/pipeworks.lua")
|
||||
end
|
||||
if industrialtest.mods.mesecons then
|
||||
dofile(modpath.."/compat/mesecons.lua")
|
||||
end
|
||||
|
@ -18,6 +18,7 @@ local S=minetest.get_translator("industrialtest")
|
||||
|
||||
local rotaryMacerator={}
|
||||
rotaryMacerator.opPower=60
|
||||
rotaryMacerator.maintainSpeedOpPower=10
|
||||
|
||||
rotaryMacerator.getFormspec=function(pos)
|
||||
local meta=minetest.get_meta(pos)
|
||||
@ -25,6 +26,7 @@ rotaryMacerator.getFormspec=function(pos)
|
||||
local maxSrcTime=meta:get_float("maxSrcTime")
|
||||
local srcPercent=maxSrcTime>0 and meta:get_float("srcTime")/maxSrcTime*100 or 0
|
||||
local rpm=meta:get_int("rpm")
|
||||
local buttonMaintainSpeedText=meta:get_int("maintainSpeed")==1 and S("Don't maintain speed") or S("Maintain speed")
|
||||
local formspec
|
||||
if industrialtest.mtgAvailable then
|
||||
formspec={
|
||||
@ -38,6 +40,7 @@ rotaryMacerator.getFormspec=function(pos)
|
||||
"list[context;dst;6,2.8;1,1;]",
|
||||
"list[context;upgrades;9,0.9;1,4]",
|
||||
"label[0.5,2.8;"..minetest.formspec_escape(S("Speed: @1",rpm)).."]",
|
||||
"button[0.5,3.4;3,0.8;maintainSpeed;"..minetest.formspec_escape(buttonMaintainSpeedText).."]",
|
||||
"listring[context;src]",
|
||||
"listring[context;modifier]",
|
||||
"listring[context;powerStorage]",
|
||||
@ -61,6 +64,7 @@ rotaryMacerator.getFormspec=function(pos)
|
||||
"list[context;upgrades;9,0.9;1,4]",
|
||||
mcl_formspec.get_itemslot_bg(9,0.9,1,4),
|
||||
"label[0.5,2.8;"..minetest.formspec_escape(S("Speed: @1",rpm)).."]",
|
||||
"button[0.5,3.4;3,0.8;maintainSpeed;"..minetest.formspec_escape(buttonMaintainSpeedText).."]",
|
||||
"listring[context;src]",
|
||||
"listring[context;modifier]",
|
||||
"listring[context;powerStorage]",
|
||||
@ -80,6 +84,7 @@ rotaryMacerator.onConstruct=function(pos,meta,inv)
|
||||
meta:set_int("rpm",0)
|
||||
meta:set_float("srcTime",0)
|
||||
meta:set_float("maxSrcTime",0)
|
||||
meta:set_int("maintainSpeed",0)
|
||||
end
|
||||
|
||||
rotaryMacerator.onTimer=function(pos,elapsed,meta,inv)
|
||||
@ -88,12 +93,21 @@ rotaryMacerator.onTimer=function(pos,elapsed,meta,inv)
|
||||
local srcSlot=inv:get_stack("src",1)
|
||||
local modifierSlot=inv:get_stack("modifier",1)
|
||||
local dstSlot=inv:get_stack("dst",1)
|
||||
local powerAmount=meta:get_int("industrialtest.powerAmount")
|
||||
local rpm=meta:get_int("rpm")
|
||||
local maintainSpeed=meta:get_int("maintainSpeed")
|
||||
|
||||
shouldRerunTimer,shouldUpdateFormspec=industrialtest.internal.chargeFromPowerStorageItem(meta,inv)
|
||||
local powerAmount=meta:get_int("industrialtest.powerAmount")
|
||||
|
||||
if rpm>0 then
|
||||
if maintainSpeed==1 and powerAmount>=rotaryMacerator.maintainSpeedOpPower then
|
||||
local newRpm=math.max(rpm+10*elapsed,0)
|
||||
if newRpm>rpm then
|
||||
meta:set_int("rpm",newRpm)
|
||||
shouldUpdateFormspec=true
|
||||
end
|
||||
industrialtest.api.addPower(meta,-rotaryMacerator.maintainSpeedOpPower)
|
||||
shouldRerunTimer=true
|
||||
elseif rpm>0 then
|
||||
meta:set_int("rpm",math.max(rpm-1000*elapsed,0))
|
||||
shouldRerunTimer=shouldRerunTimer or rpm>0
|
||||
shouldUpdateFormspec=true
|
||||
|
2
mod.conf
2
mod.conf
@ -1,5 +1,5 @@
|
||||
name=industrialtest
|
||||
description=Adds various machinery
|
||||
optional_depends=default,bucket,3d_armor,mcl_core,mcl_copper,mcl_armor,mcl_deepslate,mcl_nether,mcl_buckets,mcl_util,mcl_dye,mcl_rubber,pipeworks
|
||||
optional_depends=default,bucket,3d_armor,mcl_core,mcl_copper,mcl_armor,mcl_deepslate,mcl_nether,mcl_buckets,mcl_util,mcl_dye,mcl_rubber,pipeworks,mesecons
|
||||
author=IndustrialTest Team
|
||||
title=IndustrialTest
|
||||
|
Loading…
Reference in New Issue
Block a user