Move configuration to in-game settings
This commit is contained in:
parent
63960f3de1
commit
9b57098fca
@ -94,7 +94,7 @@ function industrialtest.api.powerFlow(pos,sides,flowOverride)
|
|||||||
def._industrialtest_self:triggerIfNeeded(endpoint.position)
|
def._industrialtest_self:triggerIfNeeded(endpoint.position)
|
||||||
else
|
else
|
||||||
-- Support for bare definitions that don't use industrialtest pseudo-OOP
|
-- Support for bare definitions that don't use industrialtest pseudo-OOP
|
||||||
minetest.get_node_timer(endpoint.position):start(industrialtest.updateDelay)
|
minetest.get_node_timer(endpoint.position):start(industrialtest.config.updateDelay)
|
||||||
end
|
end
|
||||||
if not industrialtest.api.isFullyCharged(endpointMeta) then
|
if not industrialtest.api.isFullyCharged(endpointMeta) then
|
||||||
roomAvailable=true
|
roomAvailable=true
|
||||||
|
@ -316,7 +316,8 @@ override={
|
|||||||
local meta=minetest.get_meta(pos)
|
local meta=minetest.get_meta(pos)
|
||||||
local inv=meta:get_inventory()
|
local inv=meta:get_inventory()
|
||||||
local result=inv:add_item(listname,stack)
|
local result=inv:add_item(listname,stack)
|
||||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
local nodeDef=minetest.registered_nodes[node.name]
|
||||||
|
nodeDef._industrialtest_self:triggerIfNeeded(pos)
|
||||||
return result
|
return result
|
||||||
end,
|
end,
|
||||||
can_insert=function(pos,node,stack,direction)
|
can_insert=function(pos,node,stack,direction)
|
||||||
|
10
init.lua
10
init.lua
@ -19,9 +19,11 @@ local modpath=minetest.get_modpath("industrialtest")
|
|||||||
-- table with global functions, variables etc
|
-- table with global functions, variables etc
|
||||||
industrialtest={}
|
industrialtest={}
|
||||||
|
|
||||||
-- Initial constants
|
-- Settings
|
||||||
industrialtest.updateDelay=1 -- Note: Make this value smaller to make machines update more frequently (it may make server more laggy)
|
industrialtest.config={
|
||||||
industrialtest.developerMode=true -- Enables additional utils useful when developing mod
|
updateDelay=minetest.settings:get("industrialtest.updateDelay") or 1,
|
||||||
|
developerMode=minetest.settings:get_bool("industrialtest.developerMode",false)
|
||||||
|
}
|
||||||
|
|
||||||
-- Others
|
-- Others
|
||||||
industrialtest.random=PseudoRandom(os.time())
|
industrialtest.random=PseudoRandom(os.time())
|
||||||
@ -92,7 +94,7 @@ dofile(modpath.."/tools/wrench.lua")
|
|||||||
dofile(modpath.."/upgrades.lua")
|
dofile(modpath.."/upgrades.lua")
|
||||||
dofile(modpath.."/craftitems.lua")
|
dofile(modpath.."/craftitems.lua")
|
||||||
dofile(modpath.."/nodes.lua")
|
dofile(modpath.."/nodes.lua")
|
||||||
if industrialtest.developerMode then
|
if industrialtest.config.developerMode then
|
||||||
dofile(modpath.."/utils.lua")
|
dofile(modpath.."/utils.lua")
|
||||||
end
|
end
|
||||||
dofile(modpath.."/cables.lua")
|
dofile(modpath.."/cables.lua")
|
||||||
|
@ -66,7 +66,7 @@ function industrialtest.ActivatedMachine.activate(self,pos)
|
|||||||
param2=minetest.get_node(pos).param2
|
param2=minetest.get_node(pos).param2
|
||||||
})
|
})
|
||||||
self:afterActivation(pos)
|
self:afterActivation(pos)
|
||||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
minetest.get_node_timer(pos):start(industrialtest.config.updateDelay)
|
||||||
end
|
end
|
||||||
|
|
||||||
function industrialtest.ActivatedMachine.deactivate(self,pos)
|
function industrialtest.ActivatedMachine.deactivate(self,pos)
|
||||||
@ -75,7 +75,7 @@ function industrialtest.ActivatedMachine.deactivate(self,pos)
|
|||||||
param2=minetest.get_node(pos).param2
|
param2=minetest.get_node(pos).param2
|
||||||
})
|
})
|
||||||
self:afterDeactivation(pos)
|
self:afterDeactivation(pos)
|
||||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
minetest.get_node_timer(pos):start(industrialtest.config.updateDelay)
|
||||||
end
|
end
|
||||||
|
|
||||||
function industrialtest.ActivatedMachine.shouldActivate(self,pos)
|
function industrialtest.ActivatedMachine.shouldActivate(self,pos)
|
||||||
|
@ -140,7 +140,7 @@ function industrialtest.CanningMachine.allowMetadataInventoryTake(self,pos,listn
|
|||||||
local targetSlot=inv:get_stack("dst",1)
|
local targetSlot=inv:get_stack("dst",1)
|
||||||
if ((listname=="src" and stack:get_count()==fuelSlot:get_count()) or (listname=="dst" and stack:get_count()==targetSlot:get_count())) and meta:get_float("srcTime")>0 then
|
if ((listname=="src" and stack:get_count()==fuelSlot:get_count()) or (listname=="dst" and stack:get_count()==targetSlot:get_count())) and meta:get_float("srcTime")>0 then
|
||||||
meta:set_float("srcTime",0)
|
meta:set_float("srcTime",0)
|
||||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
self:updateFormspec(pos)
|
||||||
end
|
end
|
||||||
return industrialtest.ActivatedElectricMachine.allowMetadataInventoryTake(self,pos,listname,index,stack,player)
|
return industrialtest.ActivatedElectricMachine.allowMetadataInventoryTake(self,pos,listname,index,stack,player)
|
||||||
end
|
end
|
||||||
@ -153,12 +153,12 @@ function industrialtest.CanningMachine.onMetadataInventoryMove(self,pos,fromList
|
|||||||
local targetSlot=inv:get_stack("dst",1)
|
local targetSlot=inv:get_stack("dst",1)
|
||||||
if ((fromList=="src" and count==fuelSlot:get_count()) or (fromList=="dst" and count==targetSlot:get_count())) and meta:get_float("srcTime")>0 then
|
if ((fromList=="src" and count==fuelSlot:get_count()) or (fromList=="dst" and count==targetSlot:get_count())) and meta:get_float("srcTime")>0 then
|
||||||
meta:set_float("srcTime",0)
|
meta:set_float("srcTime",0)
|
||||||
meta:set_string("formspec",canningMachine.getFormspec(pos))
|
self:updateFormspec(pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function industrialtest.CanningMachine.onMetadataInventoryPut(self,pos,listname,index,stack)
|
function industrialtest.CanningMachine.onMetadataInventoryPut(self,pos,listname,index,stack)
|
||||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
self:triggerIfNeeded(pos)
|
||||||
industrialtest.ActivatedElectricMachine.onMetadataInventoryPut(self,pos,listname,index,stack)
|
industrialtest.ActivatedElectricMachine.onMetadataInventoryPut(self,pos,listname,index,stack)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ industrialtest.MFSUChargepad:register()
|
|||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
label="Chargepad updating",
|
label="Chargepad updating",
|
||||||
nodenames=industrialtest.internal.chargepads,
|
nodenames=industrialtest.internal.chargepads,
|
||||||
interval=industrialtest.updateDelay,
|
interval=industrialtest.config.updateDelay,
|
||||||
chance=1,
|
chance=1,
|
||||||
action=function(pos,node)
|
action=function(pos,node)
|
||||||
local def=minetest.registered_nodes[node.name]
|
local def=minetest.registered_nodes[node.name]
|
||||||
|
@ -32,7 +32,7 @@ function industrialtest.ElectricMachine.onConstruct(self,pos)
|
|||||||
def._industrialtest_self:flowPower(conn)
|
def._industrialtest_self:flowPower(conn)
|
||||||
else
|
else
|
||||||
-- Support for bare definitions that don't use industrialtest pseudo-OOP
|
-- Support for bare definitions that don't use industrialtest pseudo-OOP
|
||||||
minetest.get_node_timer(conn):start(industrialtest.updateDelay)
|
minetest.get_node_timer(conn):start(industrialtest.config.updateDelay)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local def=minetest.registered_nodes[minetest.get_node(conn).name]
|
local def=minetest.registered_nodes[minetest.get_node(conn).name]
|
||||||
@ -46,7 +46,7 @@ function industrialtest.ElectricMachine.onConstruct(self,pos)
|
|||||||
def._industrialtest_self:flowPower(network)
|
def._industrialtest_self:flowPower(network)
|
||||||
else
|
else
|
||||||
-- Support for bare definitions that don't use industrialtest pseudo-OOP
|
-- Support for bare definitions that don't use industrialtest pseudo-OOP
|
||||||
minetest.get_node_timer(network):start(industrialtest.updateDelay)
|
minetest.get_node_timer(network):start(industrialtest.config.updateDelay)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -177,7 +177,7 @@ function industrialtest.ElectricMachine.requestPower(self,pos)
|
|||||||
def._industrialtest_self:flowPower(network)
|
def._industrialtest_self:flowPower(network)
|
||||||
else
|
else
|
||||||
-- Support for bare definitions that don't use industrialtest pseudo-OOP
|
-- Support for bare definitions that don't use industrialtest pseudo-OOP
|
||||||
minetest.get_node_timer(network):start(industrialtest.updateDelay)
|
minetest.get_node_timer(network):start(industrialtest.config.updateDelay)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -366,7 +366,7 @@ minetest.register_abm({
|
|||||||
label="Water Mill generating",
|
label="Water Mill generating",
|
||||||
nodenames={"industrialtest:water_mill"},
|
nodenames={"industrialtest:water_mill"},
|
||||||
neighbors=neighbors,
|
neighbors=neighbors,
|
||||||
interval=industrialtest.updateDelay,
|
interval=industrialtest.config.updateDelay,
|
||||||
chance=1,
|
chance=1,
|
||||||
action=function(pos)
|
action=function(pos)
|
||||||
industrialtest.WaterMill:action(pos)
|
industrialtest.WaterMill:action(pos)
|
||||||
|
@ -19,7 +19,7 @@ industrialtest.Generator=table.copy(industrialtest.ActivatedElectricMachine)
|
|||||||
industrialtest.internal.unpackTableInto(industrialtest.Generator,{
|
industrialtest.internal.unpackTableInto(industrialtest.Generator,{
|
||||||
name="industrialtest:generator",
|
name="industrialtest:generator",
|
||||||
description=S("Generator"),
|
description=S("Generator"),
|
||||||
tiles={
|
tiles={
|
||||||
"industrialtest_machine_block.png",
|
"industrialtest_machine_block.png",
|
||||||
"industrialtest_machine_block.png",
|
"industrialtest_machine_block.png",
|
||||||
"industrialtest_machine_block.png",
|
"industrialtest_machine_block.png",
|
||||||
@ -85,7 +85,7 @@ function industrialtest.Generator.getFormspec(self,pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function industrialtest.Generator.onMetadataInventoryPut(self,pos,listname,index,stack)
|
function industrialtest.Generator.onMetadataInventoryPut(self,pos,listname,index,stack)
|
||||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
self:triggerIfNeeded(pos)
|
||||||
industrialtest.ActivatedElectricMachine.onMetadataInventoryPut(self,pos,listname,index,stack)
|
industrialtest.ActivatedElectricMachine.onMetadataInventoryPut(self,pos,listname,index,stack)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ function industrialtest.IronFurnace.allowMetadataInventoryTake(self,pos,listname
|
|||||||
self:updateFormspec(pos)
|
self:updateFormspec(pos)
|
||||||
end
|
end
|
||||||
elseif listname=="dst" and dstSlot:get_free_space()==0 then
|
elseif listname=="dst" and dstSlot:get_free_space()==0 then
|
||||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
self:triggerIfNeeded(pos)
|
||||||
end
|
end
|
||||||
return industrialtest.ActivatedMachine.allowMetadataInventoryTake(self,pos,listname,index,stack)
|
return industrialtest.ActivatedMachine.allowMetadataInventoryTake(self,pos,listname,index,stack)
|
||||||
end
|
end
|
||||||
@ -148,13 +148,13 @@ function industrialtest.IronFurnace.onMetadataInventoryMove(self,pos,fromList,fr
|
|||||||
self:updateFormspec(pos)
|
self:updateFormspec(pos)
|
||||||
end
|
end
|
||||||
elseif fromList=="dst" and dstSlot:get_free_space()==0 then
|
elseif fromList=="dst" and dstSlot:get_free_space()==0 then
|
||||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
self:triggerIfNeeded(pos)
|
||||||
end
|
end
|
||||||
industrialtest.ActivatedMachine.onMetadataInventoryMove(self,pos,fromList,fromIndex,toList,toIndex,count)
|
industrialtest.ActivatedMachine.onMetadataInventoryMove(self,pos,fromList,fromIndex,toList,toIndex,count)
|
||||||
end
|
end
|
||||||
|
|
||||||
function industrialtest.IronFurnace.onMetadataInventoryPut(self,pos,listname,index,stack)
|
function industrialtest.IronFurnace.onMetadataInventoryPut(self,pos,listname,index,stack)
|
||||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
self:triggerIfNeeded(pos)
|
||||||
industrialtest.ActivatedMachine.onMetadataInventoryPut(self,pos,listname,index,stack)
|
industrialtest.ActivatedMachine.onMetadataInventoryPut(self,pos,listname,index,stack)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ end
|
|||||||
function industrialtest.Machine.trigger(self,pos)
|
function industrialtest.Machine.trigger(self,pos)
|
||||||
local timer=minetest.get_node_timer(pos)
|
local timer=minetest.get_node_timer(pos)
|
||||||
if not timer:is_started() then
|
if not timer:is_started() then
|
||||||
timer:start(industrialtest.updateDelay)
|
timer:start(industrialtest.config.updateDelay)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ function industrialtest.Machine.createDefinitionTable(self)
|
|||||||
return inv, "src", mcl_util.select_stack(hop_inv, hop_list, inv, "src")
|
return inv, "src", mcl_util.select_stack(hop_inv, hop_list, inv, "src")
|
||||||
end
|
end
|
||||||
def._mcl_hoppers_on_after_push=function(pos)
|
def._mcl_hoppers_on_after_push=function(pos)
|
||||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
self:triggerIfNeeded(pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ minetest.register_craft({
|
|||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
name="Solar panel updating",
|
name="Solar panel updating",
|
||||||
nodenames=solarPanels,
|
nodenames=solarPanels,
|
||||||
interval=industrialtest.updateDelay,
|
interval=industrialtest.config.updateDelay,
|
||||||
chance=1,
|
chance=1,
|
||||||
action=function(pos,node)
|
action=function(pos,node)
|
||||||
local def=minetest.registered_nodes[node.name]
|
local def=minetest.registered_nodes[node.name]
|
||||||
|
@ -122,7 +122,7 @@ minetest.register_craft({
|
|||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
name="Wind mill updating",
|
name="Wind mill updating",
|
||||||
nodenames={"industrialtest:wind_mill"},
|
nodenames={"industrialtest:wind_mill"},
|
||||||
interval=industrialtest.updateDelay,
|
interval=industrialtest.config.updateDelay,
|
||||||
chance=1,
|
chance=1,
|
||||||
action=function(pos)
|
action=function(pos)
|
||||||
industrialtest.WindMill:action(pos)
|
industrialtest.WindMill:action(pos)
|
||||||
|
5
settingtypes.txt
Normal file
5
settingtypes.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# This determines value how frequently machines update
|
||||||
|
industrialtest.updateDelay (Update delay) float 1.0
|
||||||
|
|
||||||
|
# Enables additional utils useful when developing mod
|
||||||
|
industrialtest.developerMode (Developer mode) bool false
|
@ -23,7 +23,7 @@ industrialtest.internal.unpackTableInto(industrialtest.BatPackBase,{
|
|||||||
local updateDelta=0
|
local updateDelta=0
|
||||||
function industrialtest.BatPackBase.update(self,player,inv,itemstack,dtime)
|
function industrialtest.BatPackBase.update(self,player,inv,itemstack,dtime)
|
||||||
updateDelta=updateDelta+dtime
|
updateDelta=updateDelta+dtime
|
||||||
if updateDelta<industrialtest.updateDelay then
|
if updateDelta<industrialtest.config.updateDelay then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
updateDelta=0
|
updateDelta=0
|
||||||
|
@ -45,7 +45,7 @@ industrialtest.internal.unpackTableInto(industrialtest.QuantumHelmet,{
|
|||||||
local quantumHelmetUpdateDelta=0
|
local quantumHelmetUpdateDelta=0
|
||||||
function industrialtest.QuantumHelmet.update(self,player,inv,itemstack,dtime)
|
function industrialtest.QuantumHelmet.update(self,player,inv,itemstack,dtime)
|
||||||
quantumHelmetUpdateDelta=quantumHelmetUpdateDelta+dtime
|
quantumHelmetUpdateDelta=quantumHelmetUpdateDelta+dtime
|
||||||
if quantumHelmetUpdateDelta<industrialtest.updateDelay then
|
if quantumHelmetUpdateDelta<industrialtest.config.updateDelay then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
quantumHelmetUpdateDelta=0
|
quantumHelmetUpdateDelta=0
|
||||||
|
@ -27,7 +27,7 @@ industrialtest.internal.unpackTableInto(industrialtest.SolarHelmet,{
|
|||||||
local updateDelta=0
|
local updateDelta=0
|
||||||
function industrialtest.SolarHelmet.update(self,player,inv,itemstack,dtime)
|
function industrialtest.SolarHelmet.update(self,player,inv,itemstack,dtime)
|
||||||
updateDelta=updateDelta+dtime
|
updateDelta=updateDelta+dtime
|
||||||
if updateDelta<industrialtest.updateDelay then
|
if updateDelta<industrialtest.config.updateDelay then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
updateDelta=0
|
updateDelta=0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user