2014-12-30 19:24:13 +00:00
/**
2010-12-31 12:20:54 +00:00
Pump
2013-05-30 20:11:39 +00:00
Pumps liquids using drain and source pipes . Features include :
+ switch on and off
+ consume / produce a variable amount of power depending on the height of
source and drain
2010-12-31 12:20:54 +00:00
2014-12-30 19:24:13 +00:00
@ author Maikel , ST - DDT , Sven2 , Newton
*/
2010-12-31 12:20:54 +00:00
2012-05-10 19:20:06 +00:00
# include Library_Structure
2012-02-18 21:50:18 +00:00
# include Library_Ownable
2010-12-31 12:20:54 +00:00
# include Library_PowerConsumer
2013-04-28 11:57:25 +00:00
# include Library_PowerProducer
2018-12-27 20:21:53 +00:00
# include Library_LiquidContainer
# include Library_PipeControl
2018-12-25 10:13:01 +00:00
# include Library_ResourceSelection
2010-12-31 12:20:54 +00:00
2016-02-01 17:08:55 +00:00
static const PUMP_Menu_Action_Switch_On = " on " ;
static const PUMP_Menu_Action_Switch_Off = " off " ;
2016-02-04 20:37:33 +00:00
static const PUMP_Menu_Action_Description = " description " ;
2016-02-01 17:08:55 +00:00
2013-05-30 20:11:39 +00:00
local animation ; // animation handle
2013-05-31 20:34:17 +00:00
local switched_on ; // controlled by Interaction. Indicates whether the user wants to pump or not
2013-05-30 20:11:39 +00:00
2013-05-31 20:34:17 +00:00
local powered ; // whether the pump has enough power as a consumer, always true if producing
local power_used ; // the amount of power currently consumed or (if negative) produced
2013-05-30 20:11:39 +00:00
2015-09-05 17:10:19 +00:00
local clog_count ; // increased when the pump doesn't find liquid or can't insert it. When it reaches max_clog_count, it will put the pump into temporary idle mode.
local max_clog_count = 5 ; // note that even when max_clog_count is reached, the pump will search through offsets (but in idle mode)
2016-12-24 11:15:16 +00:00
local accepted_mat ; // currently accepted material.
2016-02-26 22:17:38 +00:00
local stored_material_name ; //contained liquid
local stored_material_amount ;
2013-05-25 15:58:19 +00:00
/** This object is a liquid pump, thus pipes can be connected. */
2010-12-31 12:20:54 +00:00
public func IsLiquidPump ( ) { return true ; }
2016-02-07 18:14:57 +00:00
public func IsLiquidContainer ( ) { return false ; }
2016-02-16 17:41:19 +00:00
2010-12-31 12:20:54 +00:00
2015-11-25 11:05:26 +00:00
// The pump is rather complex for players. If anything happened, tell it to the player via the interaction menu.
local last_status_message ;
2016-12-25 17:53:43 +00:00
public func Construction ( )
2012-04-16 15:31:38 +00:00
{
2013-05-30 20:11:39 +00:00
// Rotate at a 45 degree angle towards viewer and add a litte bit of Random
2014-12-30 19:24:13 +00:00
this . MeshTransformation = Trans_Rotate ( 50 + RandomX ( - 10 , 10 ) , 0 , 1 , 0 ) ;
2018-12-25 10:13:01 +00:00
// Default selection
accepted_mat = nil ;
2015-02-08 12:07:35 +00:00
return _inherited ( . . . ) ;
2013-05-30 20:11:39 +00:00
}
2016-06-18 17:45:45 +00:00
public func IsHammerBuildable ( ) { return true ; }
2018-01-19 16:16:10 +00:00
public func NoConstructionFlip ( ) { return true ; }
2016-06-18 17:45:45 +00:00
2016-12-25 17:53:43 +00:00
public func Initialize ( )
2013-05-30 20:11:39 +00:00
{
switched_on = true ;
2013-05-27 11:24:42 +00:00
var start = 0 ;
var end = GetAnimationLength ( " pump " ) ;
2016-01-29 04:47:53 +00:00
animation = PlayAnimation ( " pump " , 5 , Anim_Linear ( GetAnimationPosition ( animation ) , start , end , 35 , ANIM_Loop ) ) ;
2013-05-30 20:11:39 +00:00
SetState ( " Wait " ) ;
2016-09-23 07:26:06 +00:00
// Let the fast pump rule know it has been created.
for ( var rule in FindObjects ( Find_ID ( Rule_FastPump ) ) )
rule - > ~ OnPumpCreation ( this ) ;
2015-02-04 11:40:29 +00:00
return _inherited ( . . . ) ;
2010-12-31 12:20:54 +00:00
}
2013-12-22 22:47:40 +00:00
2012-03-10 19:45:18 +00:00
/*-- Interaction --*/
2015-09-10 16:23:44 +00:00
public func HasInteractionMenu ( ) { return true ; }
2015-03-01 09:27:29 +00:00
public func GetPumpControlMenuEntries ( object clonk )
{
var menu_entries = [ ] ;
// default design of a control menu item
var custom_entry =
{
2015-09-06 17:02:31 +00:00
Right = " 100% " , Bottom = " 2em " ,
2015-03-01 09:27:29 +00:00
BackgroundColor = { Std = 0 , OnHover = 0x50ff0000 } ,
2015-09-06 17:02:31 +00:00
image = { Right = " 2em " } ,
text = { Left = " 2em " }
2015-03-01 09:27:29 +00:00
} ;
2015-11-25 11:05:26 +00:00
// Add info message about what is going on with the pump.
var status = " $StateOk$ " ;
var lightbulb_graphics = " Green " ;
if ( last_status_message ! = nil )
{
status = last_status_message ;
lightbulb_graphics = " Red " ;
}
2016-02-04 20:37:33 +00:00
PushBack ( menu_entries , { symbol = this , extra_data = PUMP_Menu_Action_Description ,
2015-11-25 11:05:26 +00:00
custom =
{
Prototype = custom_entry ,
Bottom = " 1.2em " ,
Priority = - 1 ,
BackgroundColor = RGB ( 25 , 100 , 100 ) ,
text = { Prototype = custom_entry . text , Text = status } ,
image = { Prototype = custom_entry . image , Symbol = Icon_Lightbulb , GraphicsName = lightbulb_graphics }
} } ) ;
2016-02-04 20:37:33 +00:00
// switch on and off
2015-03-01 09:27:29 +00:00
if ( ! switched_on )
2016-02-04 20:37:33 +00:00
PushBack ( menu_entries , GetPumpMenuEntry ( custom_entry , Icon_Play , " $MsgTurnOn$ " , 1 , PUMP_Menu_Action_Switch_On ) ) ;
2015-03-01 09:27:29 +00:00
else
2016-02-04 20:37:33 +00:00
PushBack ( menu_entries , GetPumpMenuEntry ( custom_entry , Icon_Stop , " $MsgTurnOff$ " , 1 , PUMP_Menu_Action_Switch_Off ) ) ;
2016-02-05 05:31:49 +00:00
2015-03-01 09:27:29 +00:00
return menu_entries ;
}
2016-12-25 17:53:43 +00:00
public func GetPumpMenuEntry ( proplist custom_entry , symbol , string text , int priority , extra_data )
2016-02-04 20:37:33 +00:00
{
return { symbol = symbol , extra_data = extra_data ,
custom =
{
Prototype = custom_entry ,
Priority = priority ,
text = { Prototype = custom_entry . text , Text = text } ,
image = { Prototype = custom_entry . image , Symbol = symbol }
} } ;
}
2015-02-27 10:23:20 +00:00
public func GetInteractionMenus ( object clonk )
2012-03-10 19:45:18 +00:00
{
2016-11-26 17:57:31 +00:00
var menus = _inherited ( clonk , . . . ) ? ? [ ] ;
2016-12-24 14:12:14 +00:00
var control_menu =
2015-03-01 10:20:33 +00:00
{
title = " $Control$ " ,
entries_callback = this . GetPumpControlMenuEntries ,
callback = " OnPumpControl " ,
callback_hover = " OnPumpControlHover " ,
callback_target = this ,
BackgroundColor = RGB ( 0 , 50 , 50 ) ,
Priority = 20
} ;
2016-12-24 14:12:14 +00:00
PushBack ( menus , control_menu ) ;
var materials_menu =
{
title = " $PumpMaterials$ " ,
entries_callback = this . GetPumpMaterialsMenuEntries ,
callback = " OnPumpMaterials " ,
callback_hover = " OnPumpMaterialsHover " ,
callback_target = this ,
BackgroundColor = RGB ( 0 , 50 , 50 ) ,
Priority = 25
} ;
PushBack ( menus , materials_menu ) ;
2015-02-27 10:23:20 +00:00
return menus ;
}
public func OnPumpControlHover ( id symbol , string action , desc_menu_target , menu_id )
{
var text = " " ;
2016-02-01 17:08:55 +00:00
if ( action = = PUMP_Menu_Action_Switch_On ) text = " $DescTurnOn$ " ;
else if ( action = = PUMP_Menu_Action_Switch_Off ) text = " $DescTurnOff$ " ;
2016-02-04 20:37:33 +00:00
else if ( action = = PUMP_Menu_Action_Description ) text = this . Description ;
2015-02-27 10:23:20 +00:00
GuiUpdateText ( text , menu_id , 1 , desc_menu_target ) ;
2014-10-18 17:12:55 +00:00
}
2016-02-04 20:37:33 +00:00
public func OnPumpControl ( symbol_or_object , string action , bool alt )
2014-10-18 17:12:55 +00:00
{
2016-02-01 17:08:55 +00:00
if ( action = = PUMP_Menu_Action_Switch_On | | action = = PUMP_Menu_Action_Switch_Off )
2015-03-01 09:27:29 +00:00
ToggleOnOff ( true ) ;
2016-02-05 21:52:34 +00:00
2015-03-01 09:27:29 +00:00
UpdateInteractionMenus ( this . GetPumpControlMenuEntries ) ;
2012-03-10 19:45:18 +00:00
}
2015-11-25 11:05:26 +00:00
private func SetInfoMessage ( string msg )
{
if ( last_status_message = = msg ) return ;
last_status_message = msg ;
UpdateInteractionMenus ( this . GetPumpControlMenuEntries ) ;
}
2018-01-13 11:09:59 +00:00
static const LIBRARY_TANK_Menu_Action_Cut_AirPipe = " cutairpipe " ;
static const LIBRARY_TANK_Menu_Action_Add_AirPipe = " addairpipe " ;
// Extend liquid tank connection interface to air pipes.
public func GetPipeControlMenuEntries ( object clonk )
{
var menu_entries = inherited ( clonk , . . . ) ;
var drain_pipe = GetDrainPipe ( ) ;
// Modify cut drain pipe menu entry for air pipe.
if ( drain_pipe & & ! drain_pipe - > QueryCutLineConnection ( this ) & & drain_pipe - > IsAirPipe ( ) )
{
for ( var entry in menu_entries )
{
if ( entry . extra_data = = LIBRARY_TANK_Menu_Action_Cut_Drain )
{
entry . extra_data = LIBRARY_TANK_Menu_Action_Cut_AirPipe ;
entry . Priority = 4 ;
entry . custom . image . BackgroundColor = RGB ( 0 , 153 , 255 ) ;
2018-01-25 12:44:57 +00:00
entry . custom . text . Text = GetConnectedPipeMessage ( " $MsgCutAirPipe$ " , GetDrainPipe ( ) ) ;
2018-01-13 11:09:59 +00:00
break ;
}
}
}
// Add attach air pipe menu entry.
var air_pipe = FindAvailablePipe ( clonk , Find_Func ( " IsAirPipe " ) ) ;
if ( ! drain_pipe & & air_pipe )
2018-01-25 12:44:57 +00:00
PushBack ( menu_entries , GetTankMenuEntry ( air_pipe , GetConnectedPipeMessage ( " $MsgConnectAirPipe$ " , air_pipe ) , 4 , LIBRARY_TANK_Menu_Action_Add_AirPipe , RGB ( 0 , 153 , 255 ) ) ) ;
2018-01-13 11:09:59 +00:00
return menu_entries ;
}
2018-01-25 12:44:57 +00:00
public func OnPipeControlHover ( symbol_or_object , string action , desc_menu_target , menu_id )
2018-01-13 11:09:59 +00:00
{
if ( action = = LIBRARY_TANK_Menu_Action_Cut_AirPipe )
{
2018-01-25 12:44:57 +00:00
GuiUpdateText ( GetConnectedPipeDescription ( " $DescCutAirPipe$ " , GetDrainPipe ( ) ) , menu_id , 1 , desc_menu_target ) ;
2018-01-13 11:09:59 +00:00
return ;
}
if ( action = = LIBRARY_TANK_Menu_Action_Add_AirPipe )
{
2018-01-25 12:44:57 +00:00
GuiUpdateText ( GetConnectedPipeDescription ( " $DescConnectAirPipe$ " , symbol_or_object ) , menu_id , 1 , desc_menu_target ) ;
2018-01-13 11:09:59 +00:00
return ;
}
2018-01-25 12:44:57 +00:00
return inherited ( symbol_or_object , action , desc_menu_target , menu_id , . . . ) ;
2018-01-13 11:09:59 +00:00
}
2018-12-25 14:53:51 +00:00
public func OnPipeControl ( symbol_or_object , string action , object clonk )
2018-01-13 11:09:59 +00:00
{
if ( action = = LIBRARY_TANK_Menu_Action_Cut_AirPipe )
{
2018-12-25 14:53:51 +00:00
this - > DoCutPipe ( GetDrainPipe ( ) , clonk ) ;
2018-01-13 11:09:59 +00:00
UpdateInteractionMenus ( this . GetPipeControlMenuEntries ) ;
return ;
}
if ( action = = LIBRARY_TANK_Menu_Action_Add_AirPipe )
{
this - > DoConnectPipe ( symbol_or_object , PIPE_STATE_Air ) ;
UpdateInteractionMenus ( this . GetPipeControlMenuEntries ) ;
return ;
}
2018-12-25 14:53:51 +00:00
return inherited ( symbol_or_object , action , clonk , . . . ) ;
2018-01-13 11:09:59 +00:00
}
2010-12-31 12:20:54 +00:00
2016-12-23 17:08:50 +00:00
/*-- Pipe control --*/
2016-02-05 21:52:34 +00:00
2018-01-13 10:00:41 +00:00
public func QueryConnectPipe ( object pipe , bool do_msg )
2012-10-25 18:14:13 +00:00
{
2016-02-05 21:52:34 +00:00
if ( GetDrainPipe ( ) & & GetSourcePipe ( ) )
{
2018-01-13 10:00:41 +00:00
if ( do_msg ) pipe - > Report ( " $MsgHasPipes$ " ) ;
2016-02-05 21:52:34 +00:00
return true ;
}
2017-07-04 13:19:31 +00:00
else if ( pipe - > IsSourcePipe ( ) & & GetSourcePipe ( ) )
2016-02-05 21:52:34 +00:00
{
2018-01-13 10:00:41 +00:00
if ( do_msg ) pipe - > Report ( " $MsgSourcePipeProhibited$ " ) ;
2016-02-05 21:52:34 +00:00
return true ;
}
2017-07-04 13:19:31 +00:00
else if ( pipe - > IsDrainPipe ( ) & & GetDrainPipe ( ) )
2016-02-05 21:52:34 +00:00
{
2018-01-13 10:00:41 +00:00
if ( do_msg ) pipe - > Report ( " $MsgDrainPipeProhibited$ " ) ;
2016-02-05 21:52:34 +00:00
return true ;
}
2016-08-17 18:23:18 +00:00
else if ( pipe - > IsAirPipe ( ) & & GetDrainPipe ( ) )
{
2018-01-13 10:00:41 +00:00
if ( do_msg ) pipe - > Report ( " $MsgAirPipeProhibited$ " ) ;
2016-08-17 18:23:18 +00:00
return true ;
}
2016-02-05 21:52:34 +00:00
return false ;
2012-10-25 18:14:13 +00:00
}
2016-02-05 05:31:49 +00:00
2016-02-05 21:52:34 +00:00
2016-12-25 17:53:43 +00:00
public func OnPipeConnect ( object pipe , string specific_pipe_state )
2016-02-05 05:31:49 +00:00
{
2016-02-05 21:52:34 +00:00
if ( PIPE_STATE_Source = = specific_pipe_state )
{
2016-02-06 22:12:26 +00:00
SetSourcePipe ( pipe ) ;
2016-02-05 21:52:34 +00:00
pipe - > SetSourcePipe ( ) ;
pipe - > Report ( " $MsgCreatedSource$ " ) ;
}
else if ( PIPE_STATE_Drain = = specific_pipe_state )
{
2016-02-06 22:12:26 +00:00
SetDrainPipe ( pipe ) ;
2016-02-05 21:52:34 +00:00
pipe - > SetDrainPipe ( ) ;
pipe - > Report ( " $MsgCreatedDrain$ " ) ;
}
2016-08-17 18:23:18 +00:00
else if ( PIPE_STATE_Air = = specific_pipe_state )
{
// Air pipes take up the place of the drain
SetDrainPipe ( pipe ) ;
pipe - > Report ( " $MsgCreatedAirDrain$ " ) ;
}
2016-02-05 21:52:34 +00:00
else
{
// add a drain if we already connected a source pipe,
// or if the line is already connected to a container
2016-02-06 22:12:26 +00:00
var line = pipe - > GetConnectedLine ( ) ;
var pump_target = ! line | | line - > GetConnectedObject ( this ) ;
2016-08-17 18:23:18 +00:00
if ( pump_target ) pump_target = pump_target - > ~ IsLiquidContainer ( ) ;
if ( line - > IsAirPipe ( ) )
{
OnPipeConnect ( pipe , PIPE_STATE_Air ) ;
}
else if ( GetSourcePipe ( ) | | pump_target )
2016-02-05 21:52:34 +00:00
{
2016-02-06 22:12:26 +00:00
OnPipeConnect ( pipe , PIPE_STATE_Drain ) ;
2016-02-05 21:52:34 +00:00
}
// otherwise create a source first
else
{
2016-02-06 22:12:26 +00:00
OnPipeConnect ( pipe , PIPE_STATE_Source ) ;
2016-02-05 21:52:34 +00:00
}
}
2016-02-05 05:31:49 +00:00
}
2012-10-25 18:14:13 +00:00
2016-12-25 17:53:43 +00:00
public func OnPipeDisconnect ( object pipe )
2016-02-04 20:37:33 +00:00
{
2016-12-25 17:53:43 +00:00
_inherited ( pipe , . . . ) ;
2018-01-13 10:00:41 +00:00
// Stop pumping to prevent errors from Pumping() function.
if ( pipe - > IsAirPipe ( ) )
2016-08-17 18:23:18 +00:00
CheckState ( ) ;
2016-02-04 20:37:33 +00:00
}
2016-02-05 21:52:34 +00:00
public func SetSourcePipe ( object pipe )
2016-02-04 20:37:33 +00:00
{
2016-12-25 17:53:43 +00:00
_inherited ( pipe , . . . ) ;
2016-02-05 21:52:34 +00:00
CheckState ( ) ;
2016-02-04 20:37:33 +00:00
}
2016-02-05 21:52:34 +00:00
2016-08-17 18:23:18 +00:00
public func IsAirPipeConnected ( )
{
if ( ! GetDrainPipe ( ) )
return false ;
return GetDrainPipe ( ) - > ~ IsAirPipe ( ) ;
}
2016-02-04 20:37:33 +00:00
2013-05-25 15:58:19 +00:00
/*-- Power stuff --*/
2016-12-25 18:04:03 +00:00
public func GetConsumerPriority ( )
{
if ( IsAirPipeConnected ( ) )
return 125 ;
return 25 ;
}
2014-12-19 20:47:08 +00:00
public func GetProducerPriority ( ) { return 100 ; }
2014-12-30 19:24:13 +00:00
public func IsSteadyPowerProducer ( ) { return true ; }
public func OnNotEnoughPower ( )
2012-02-18 21:50:18 +00:00
{
2013-05-30 20:11:39 +00:00
powered = false ;
2013-06-04 18:10:51 +00:00
CheckState ( ) ;
2015-02-01 11:39:02 +00:00
return _inherited ( . . . ) ;
2012-02-18 21:50:18 +00:00
}
2014-12-30 19:24:13 +00:00
public func OnEnoughPower ( )
2012-02-18 21:50:18 +00:00
{
2013-05-30 20:11:39 +00:00
powered = true ;
2013-06-04 18:10:51 +00:00
CheckState ( ) ;
2015-02-01 11:39:02 +00:00
return _inherited ( . . . ) ;
2012-02-18 21:50:18 +00:00
}
2016-02-05 05:31:49 +00:00
// TODO: these functions may be useful in the liquid tank, maybe move it to that library
2013-05-25 15:58:19 +00:00
/** Returns object to which the liquid is pumped */
2013-04-28 11:57:25 +00:00
private func GetDrainObject ( )
{
2016-10-03 16:07:49 +00:00
var drain = GetDrainPipe ( ) ;
if ( drain & & drain - > GetConnectedLine ( ) )
return drain - > GetConnectedLine ( ) - > GetConnectedObject ( this ) ? ? this ;
2013-04-28 11:57:25 +00:00
return this ;
}
2011-10-11 22:32:46 +00:00
2014-10-18 17:12:55 +00:00
/** Returns object from which the liquid is pumped */
2013-05-25 15:58:19 +00:00
private func GetSourceObject ( )
{
2016-10-03 16:07:49 +00:00
var source = GetSourcePipe ( ) ;
if ( source & & source - > GetConnectedLine ( ) )
return source - > GetConnectedLine ( ) - > GetConnectedObject ( this ) ? ? this ;
2013-05-25 15:58:19 +00:00
return this ;
}
/** PhaseCall of Pump: Pump the liquid from the source to the drain pipe */
2010-12-31 12:20:54 +00:00
protected func Pumping ( )
{
2012-10-25 18:14:13 +00:00
// at this point we can assert that we have power
// something went wrong in the meantime?
2013-05-30 20:11:39 +00:00
// let the central function handle that on next check
2016-12-25 17:53:43 +00:00
if ( ! GetSourcePipe ( ) & & ! IsAirPipeConnected ( ) )
2015-02-01 11:39:02 +00:00
return ;
2016-10-01 17:18:23 +00:00
// Get the drain object.
var drain_obj = GetDrainObject ( ) ;
2016-02-05 05:34:50 +00:00
2016-12-25 17:53:43 +00:00
// Don't do anything special if pumping air but inform the drain object.
2016-08-17 18:23:18 +00:00
if ( IsAirPipeConnected ( ) )
{
2016-12-25 17:53:43 +00:00
if ( ! GetAirSourceOk ( ) | | ! GetAirDrainOk ( ) )
return SetState ( " WaitForLiquid " ) ;
2016-08-17 18:23:18 +00:00
if ( drain_obj )
drain_obj - > ~ OnAirPumped ( this ) ;
return ;
}
2013-04-28 11:57:25 +00:00
var pump_ok = true ;
2012-10-25 18:14:13 +00:00
2013-05-30 20:11:39 +00:00
// is empty? -> try to get liquid
2016-02-26 22:17:38 +00:00
if ( ! stored_material_name )
2011-10-11 22:32:46 +00:00
{
2012-10-25 18:14:13 +00:00
// get new materials
2015-05-01 16:04:42 +00:00
var source_obj = GetSourceObject ( ) ;
2016-09-23 07:26:06 +00:00
var mat = this - > ExtractMaterialFromSource ( source_obj , this . PumpSpeed / 10 ) ;
2016-01-25 21:14:30 +00:00
2012-10-25 18:14:13 +00:00
// no material to pump?
2014-12-30 19:24:13 +00:00
if ( mat )
2013-05-30 20:11:39 +00:00
{
2016-02-26 22:17:38 +00:00
stored_material_name = mat [ 0 ] ;
stored_material_amount = mat [ 1 ] ;
2013-05-30 20:11:39 +00:00
}
2013-04-28 12:02:57 +00:00
else
2013-05-30 20:11:39 +00:00
{
2015-09-05 17:10:19 +00:00
source_obj - > ~ CycleApertureOffset ( this ) ; // try different offsets, so we don't stop pumping just because 1px of earth was dropped on the source pipe
2013-05-30 20:11:39 +00:00
pump_ok = false ;
}
2011-10-11 22:32:46 +00:00
}
2013-04-28 11:57:25 +00:00
if ( pump_ok )
{
2016-02-26 22:17:38 +00:00
var i = stored_material_amount ;
2013-05-30 20:11:39 +00:00
while ( i > 0 )
2013-04-28 11:57:25 +00:00
{
2016-02-26 22:17:38 +00:00
if ( this - > InsertMaterialAtDrain ( drain_obj , stored_material_name , 1 ) )
2013-05-30 20:11:39 +00:00
{
i - - ;
}
// Drain is stuck.
else
{
2015-09-05 17:10:19 +00:00
drain_obj - > ~ CycleApertureOffset ( this ) ; // try different offsets, so we don't stop pumping just because 1px of earth was dropped on the drain pipe
2013-05-30 20:11:39 +00:00
pump_ok = false ;
break ;
}
2013-04-28 11:57:25 +00:00
}
2016-02-26 22:17:38 +00:00
stored_material_amount = i ;
if ( stored_material_amount < = 0 )
stored_material_name = nil ;
2013-04-28 11:57:25 +00:00
}
2013-05-30 20:11:39 +00:00
2015-09-05 17:10:19 +00:00
if ( pump_ok )
{
clog_count = 0 ;
}
else
{
2016-08-07 19:26:15 +00:00
// Put into wait state if no liquid could be pumped for a while or if the drain has no aperture, i.e. is a liquid tank.
if ( + + clog_count > = max_clog_count | | ! drain_obj - > ~ HasAperture ( ) )
2015-09-05 17:10:19 +00:00
{
SetState ( " WaitForLiquid " ) ;
}
}
2014-12-30 19:24:13 +00:00
return ;
2013-04-28 11:57:25 +00:00
}
2016-01-25 21:14:30 +00:00
// interface for the extraction logic
func ExtractMaterialFromSource ( object source_obj , int amount )
{
2016-02-04 21:58:06 +00:00
if ( source_obj - > ~ IsLiquidContainer ( ) )
{
2016-12-24 11:15:16 +00:00
return source_obj - > RemoveLiquid ( accepted_mat , amount , this ) ;
2016-02-04 21:58:06 +00:00
}
else
{
var mat = source_obj - > ExtractLiquidAmount ( source_obj . ApertureOffsetX , source_obj . ApertureOffsetY , amount , true ) ;
if ( mat )
return [ MaterialName ( mat [ 0 ] ) , mat [ 1 ] ] ;
}
2016-12-17 16:29:28 +00:00
return nil ;
2016-01-25 21:14:30 +00:00
}
// interface for the insertion logic
2016-12-25 17:53:43 +00:00
public func InsertMaterialAtDrain ( object drain_obj , string material_name , int amount )
2016-01-25 21:14:30 +00:00
{
2016-02-04 21:58:06 +00:00
// insert material into containers, if possible
if ( drain_obj - > ~ IsLiquidContainer ( ) )
{
2016-02-07 18:14:57 +00:00
amount - = drain_obj - > PutLiquid ( material_name , amount , this ) ;
2016-02-04 21:58:06 +00:00
}
2016-02-07 18:14:57 +00:00
else
2016-02-04 21:58:06 +00:00
{
2016-02-07 18:14:57 +00:00
// convert to actual material, and insert remaining
var material_index = Material ( material_name ) ;
2016-12-23 17:08:50 +00:00
if ( material_index = = - 1 & & material_name ! = nil )
material_index = Material ( GetDefinition ( material_name ) - > GetLiquidMaterial ( ) ) ;
2016-02-07 18:14:57 +00:00
if ( material_index ! = - 1 )
{
2016-12-17 16:29:28 +00:00
while ( amount > 0 & & drain_obj - > InsertMaterial ( material_index , drain_obj . ApertureOffsetX , drain_obj . ApertureOffsetY ) )
amount - - ;
2016-02-07 18:14:57 +00:00
}
2016-02-04 21:58:06 +00:00
}
return amount < = 0 ;
2016-01-25 21:14:30 +00:00
}
2013-05-30 20:11:39 +00:00
/** Re check state and change the state if needed */
2016-12-25 17:53:43 +00:00
public func CheckState ( )
2013-04-28 11:57:25 +00:00
{
2013-05-30 20:11:39 +00:00
var is_fullcon = GetCon ( ) > = 100 ;
2016-12-25 17:53:43 +00:00
// The pump can work without source if it needs to supply air.
var can_pump = ( GetSourcePipe ( ) | | IsAirPipeConnected ( ) ) & & is_fullcon & & switched_on ;
2013-05-30 20:11:39 +00:00
2016-12-25 17:53:43 +00:00
// Can't pump at all -> wait.
2013-05-30 20:11:39 +00:00
if ( ! can_pump )
2013-04-28 11:57:25 +00:00
{
2016-02-05 05:34:50 +00:00
if ( ! GetSourcePipe ( ) & & switched_on )
2015-11-25 11:05:26 +00:00
SetInfoMessage ( " $StateNoSource$ " ) ;
2013-05-30 20:11:39 +00:00
SetState ( " Wait " ) ;
}
2016-08-17 18:23:18 +00:00
else if ( IsAirPipeConnected ( ) )
{
if ( ! GetAirSourceOk ( ) )
{
SetInfoMessage ( " $StateNoAir$ " ) ;
SetState ( " WaitForLiquid " ) ;
}
2016-12-25 17:53:43 +00:00
else if ( ! GetAirDrainOk ( ) )
{
SetInfoMessage ( " $StateNoAirNeed$ " ) ;
SetState ( " WaitForLiquid " ) ;
}
2016-08-17 18:23:18 +00:00
else
{
2016-12-25 17:53:43 +00:00
// Can pump, has air but has no power -> wait for power.
2016-08-17 18:23:18 +00:00
if ( ! powered )
{
SetInfoMessage ( " $StateNoPower$ " ) ;
SetState ( " WaitForPower " ) ;
}
else
{
SetInfoMessage ( ) ;
clog_count = 0 ;
SetState ( " Pump " ) ;
}
UpdatePowerUsage ( ) ;
}
}
2013-05-30 20:11:39 +00:00
else
{
2016-08-07 19:26:15 +00:00
// Can pump but has no liquid or can't dispense liquid -> wait.
var source_mat = GetLiquidSourceMaterial ( ) ;
2018-12-25 10:13:01 +00:00
var source_ok = IsInResourceSelection ( source_mat ) ;
2016-12-24 11:15:16 +00:00
var drain_ok = GetLiquidDrainOk ( source_mat ) ;
2015-11-25 11:05:26 +00:00
if ( ! source_ok | | ! drain_ok )
2013-05-25 15:58:19 +00:00
{
2016-12-24 11:15:16 +00:00
accepted_mat = nil ;
2015-11-25 11:05:26 +00:00
if ( ! source_ok )
SetInfoMessage ( " $StateNoInput$ " ) ;
else if ( ! drain_ok )
SetInfoMessage ( " $StateNoOutput$ " ) ;
2013-05-30 20:11:39 +00:00
SetState ( " WaitForLiquid " ) ;
2013-05-25 15:58:19 +00:00
}
2013-05-30 20:11:39 +00:00
else
2013-05-25 15:58:19 +00:00
{
2016-12-24 11:15:16 +00:00
accepted_mat = source_mat ;
2013-05-30 20:11:39 +00:00
// can pump, has liquid but has no power -> wait for power
if ( ! powered )
2013-05-25 15:58:19 +00:00
{
2015-11-25 11:05:26 +00:00
SetInfoMessage ( " $StateNoPower$ " ) ;
2013-05-30 20:11:39 +00:00
SetState ( " WaitForPower " ) ;
2013-05-25 15:58:19 +00:00
}
2013-05-30 20:11:39 +00:00
// otherwise, pump! :-)
else
{
2015-11-25 11:05:26 +00:00
SetInfoMessage ( ) ;
2015-09-05 17:10:19 +00:00
clog_count = 0 ;
2013-05-30 20:11:39 +00:00
SetState ( " Pump " ) ;
}
// regularly update the power usage while pumping or waiting for power
UpdatePowerUsage ( ) ;
2013-05-25 15:58:19 +00:00
}
2013-04-28 11:57:25 +00:00
}
}
2013-05-25 15:58:19 +00:00
/** Get current height the pump has to push liquids upwards (input.y - output.y) */
private func GetPumpHeight ( )
2013-04-28 11:57:25 +00:00
{
2013-05-30 20:11:39 +00:00
// compare each the surfaces of the bodies of liquid pumped
2013-05-25 15:58:19 +00:00
// find Y position of surface of liquid that is pumped to target
2015-05-01 16:04:42 +00:00
var source_obj = GetSourceObject ( ) ;
var source_x = source_obj . ApertureOffsetX ;
var source_y = source_obj . ApertureOffsetY ;
if ( source_obj - > GBackLiquid ( source_x , source_y ) )
2013-05-25 15:58:19 +00:00
{
2015-05-01 16:04:42 +00:00
var src_mat = source_obj - > GetMaterial ( source_x , source_y ) ;
while ( src_mat = = source_obj - > GetMaterial ( source_x , source_y - 1 ) )
2013-05-30 20:11:39 +00:00
- - source_y ;
2013-05-25 15:58:19 +00:00
}
2013-06-04 18:09:09 +00:00
// same for target (use same function as if inserting)
2015-02-01 11:39:02 +00:00
var target_pos = { X = 0 , Y = 0 } ;
2015-05-01 16:04:42 +00:00
var drain_obj = GetDrainObject ( ) ;
drain_obj - > CanInsertMaterial ( Material ( " Water " ) , drain_obj . ApertureOffsetX , drain_obj . ApertureOffsetY , target_pos ) ;
return source_obj - > GetY ( ) + source_y - target_pos . Y ;
2013-04-28 11:57:25 +00:00
}
2013-05-25 15:58:19 +00:00
/** Recheck power usage/production for current pump height
and make the pump a producer / consumer for the power system */
private func UpdatePowerUsage ( )
2013-04-28 11:57:25 +00:00
{
2013-05-25 15:58:19 +00:00
var new_power ;
2014-12-30 19:24:13 +00:00
if ( IsUsingPower ( ) )
2013-05-25 15:58:19 +00:00
new_power = PumpHeight2Power ( GetPumpHeight ( ) ) ;
else
new_power = 0 ;
2013-05-31 20:34:17 +00:00
// do nothing if not necessary
if ( new_power = = power_used )
2015-03-05 19:40:10 +00:00
{
// But still set powered to true if power_used was not positive.
if ( power_used < = 0 )
powered = true ;
2013-05-31 20:34:17 +00:00
return ;
2015-03-05 19:40:10 +00:00
}
2013-05-31 20:34:17 +00:00
2013-05-25 15:58:19 +00:00
// and update energy system
2013-04-28 11:57:25 +00:00
if ( new_power > 0 )
{
2013-05-31 20:34:17 +00:00
if ( power_used < 0 )
{
powered = false ; // needed since the flag was set manually
2014-12-30 19:24:13 +00:00
UnregisterPowerProduction ( ) ;
2013-05-31 20:34:17 +00:00
}
2014-12-30 19:24:13 +00:00
RegisterPowerRequest ( new_power ) ;
2013-04-28 11:57:25 +00:00
}
2013-05-31 20:34:17 +00:00
else if ( new_power < 0 )
2013-04-28 11:57:25 +00:00
{
2013-05-31 20:34:17 +00:00
if ( power_used > 0 )
2014-12-30 19:24:13 +00:00
UnregisterPowerRequest ( ) ;
RegisterPowerProduction ( - new_power ) ;
2013-05-31 20:34:17 +00:00
powered = true ; // when producing, we always have power
2013-05-25 15:58:19 +00:00
}
2013-05-31 20:34:17 +00:00
else // new_power == 0
{
2014-12-30 19:24:13 +00:00
if ( power_used < 0 )
UnregisterPowerProduction ( ) ;
else if ( power_used > 0 )
UnregisterPowerRequest ( ) ;
2013-06-04 18:10:51 +00:00
powered = true ;
2013-05-31 20:34:17 +00:00
}
power_used = new_power ;
2015-02-01 11:39:02 +00:00
return ;
2013-04-28 11:57:25 +00:00
}
2015-02-01 11:39:02 +00:00
// Return whether the pump should be using power in the current state.
2013-05-25 15:58:19 +00:00
private func IsUsingPower ( )
2013-04-28 11:57:25 +00:00
{
2013-05-31 20:34:17 +00:00
return switched_on & & ( GetAction ( ) = = " Pump " | | GetAction ( ) = = " WaitForPower " ) ;
2010-12-31 12:20:54 +00:00
}
2015-02-01 11:39:02 +00:00
// Transform pump height (input.y - output.y) into required power.
2013-05-25 15:58:19 +00:00
private func PumpHeight2Power ( int pump_height )
2012-10-25 18:14:13 +00:00
{
2015-02-01 11:39:02 +00:00
// Pumping upwards will always cost the minimum energy.
// Pumping downwards will only produce energy after an offset.
var power_offset = 10 ;
// Max power consumed / produced.
var max_power = 60 ;
// Calculate the used power in steps of ten, every 60 pixels represents ten units.
var used_power = pump_height / 60 * 10 ;
2015-05-13 19:18:15 +00:00
// If the pump height is positive then add the minimum energy.
if ( pump_height > = 0 )
2015-02-01 11:39:02 +00:00
used_power = Min ( used_power + 10 , max_power ) ;
// Pumping power downwards never costs energy, but only brings something if offset is overcome.
else
2015-05-13 19:18:15 +00:00
used_power = BoundBy ( used_power + power_offset - 10 , - max_power , 0 ) ;
2016-12-25 18:04:03 +00:00
// Pumped air always requires 20 power.
2016-08-17 18:23:18 +00:00
if ( IsAirPipeConnected ( ) )
2016-12-25 18:04:03 +00:00
used_power = 20 ;
2015-02-01 11:39:02 +00:00
return used_power ;
2012-10-25 18:14:13 +00:00
}
2015-05-13 19:18:15 +00:00
// Returns whether there is liquid at the source pipe to pump.
2016-08-07 19:26:15 +00:00
private func GetLiquidSourceMaterial ( )
2010-12-31 12:20:54 +00:00
{
2016-08-07 19:26:15 +00:00
// Get the source object and check whether there is liquid.
2015-05-01 16:04:42 +00:00
var source_obj = GetSourceObject ( ) ;
2016-10-03 16:07:49 +00:00
if ( ! source_obj )
return ;
2016-12-23 17:08:50 +00:00
// The source is a liquid container: check which material will be supplied.
if ( source_obj - > ~ IsLiquidContainer ( ) )
{
2018-12-25 10:13:01 +00:00
var liquid = source_obj - > HasLiquid ( GetResourceSelection ( ) ) ;
2016-12-23 17:08:50 +00:00
if ( liquid )
return liquid - > GetLiquidType ( ) ;
return ;
}
2016-08-07 19:26:15 +00:00
var is_liquid = source_obj - > GBackLiquid ( source_obj . ApertureOffsetX , source_obj . ApertureOffsetY ) ;
var liquid = MaterialName ( source_obj - > GetMaterial ( source_obj . ApertureOffsetX , source_obj . ApertureOffsetY ) ) ;
if ( ! is_liquid )
2015-09-05 17:10:19 +00:00
{
2016-08-07 19:26:15 +00:00
// Try different offsets, so we can resume pumping after clog because 1px of earth was dropped on the source pipe.
source_obj - > ~ CycleApertureOffset ( this ) ;
return ;
2015-09-05 17:10:19 +00:00
}
2016-08-07 19:26:15 +00:00
return liquid ;
2015-11-25 11:05:26 +00:00
}
2016-08-07 19:26:15 +00:00
// Returns whether the drain pipe is free or the liquid container accepts the given material.
private func GetLiquidDrainOk ( string liquid )
2015-11-25 11:05:26 +00:00
{
2016-12-29 17:57:33 +00:00
if ( ! liquid )
return false ;
2015-05-01 16:04:42 +00:00
var drain_obj = GetDrainObject ( ) ;
2016-08-07 19:26:15 +00:00
if ( drain_obj - > ~ HasAperture ( ) )
{
2016-12-23 17:08:50 +00:00
var material_index = Material ( liquid ) ;
if ( material_index = = - 1 & & liquid ! = nil )
material_index = Material ( GetDefinition ( liquid ) - > GetLiquidMaterial ( ) ) ;
if ( ! drain_obj - > CanInsertMaterial ( material_index , drain_obj . ApertureOffsetX , drain_obj . ApertureOffsetY ) )
2016-08-07 19:26:15 +00:00
{
drain_obj - > ~ CycleApertureOffset ( this ) ; // try different offsets, so we can resume pumping after clog because 1px of earth was dropped on the source pipe
return false ;
}
}
else if ( drain_obj - > ~ IsLiquidContainer ( ) )
2015-09-05 17:10:19 +00:00
{
2016-08-07 19:26:15 +00:00
if ( ! drain_obj - > AcceptsLiquid ( liquid , 1 ) )
return false ;
2015-09-05 17:10:19 +00:00
}
2010-12-31 12:20:54 +00:00
return true ;
}
2016-12-25 17:53:43 +00:00
// Returns whether the source (or alternatively the pump itself) is in free air.
public func GetAirSourceOk ( )
2016-08-17 18:23:18 +00:00
{
var source_obj = GetSourceObject ( ) ;
2016-12-25 17:53:43 +00:00
if ( ! source_obj )
return ! GBackSemiSolid ( ) ;
2016-08-17 18:23:18 +00:00
var is_air = ! source_obj - > GBackSemiSolid ( source_obj . ApertureOffsetX , source_obj . ApertureOffsetY ) ;
if ( ! is_air )
source_obj - > ~ CycleApertureOffset ( this ) ;
2016-12-25 17:53:43 +00:00
return is_air ;
}
// Returns whether the other side of air drain is in need of air.
public func GetAirDrainOk ( )
{
var drain_obj = GetDrainObject ( ) ;
if ( ! drain_obj )
2016-08-17 18:23:18 +00:00
return false ;
2016-12-25 17:53:43 +00:00
return drain_obj - > ~ QueryAirNeed ( this ) ;
2016-08-17 18:23:18 +00:00
}
2015-02-01 11:39:02 +00:00
// Set the state of the pump, retaining the animation position and updating the power usage.
private func SetState ( string act )
2012-03-10 17:23:48 +00:00
{
2015-02-01 11:39:02 +00:00
if ( act = = GetAction ( ) )
return ;
2012-03-10 17:23:48 +00:00
2015-02-01 11:39:02 +00:00
// Set animation depending on the current action.
2013-05-30 20:11:39 +00:00
var start = 0 ;
var end = GetAnimationLength ( " pump " ) ;
2013-06-04 18:10:51 +00:00
var anim_pos = GetAnimationPosition ( animation ) ;
2013-05-30 20:11:39 +00:00
if ( act = = " Pump " )
{
2013-06-04 18:10:51 +00:00
SetAnimationPosition ( animation , Anim_Linear ( anim_pos , start , end , 35 , ANIM_Loop ) ) ;
2011-10-11 22:32:46 +00:00
}
2013-05-30 20:11:39 +00:00
else if ( act = = " WaitForLiquid " )
2013-05-27 11:24:42 +00:00
{
2013-06-04 18:10:51 +00:00
SetAnimationPosition ( animation , Anim_Linear ( anim_pos , start , end , 350 , ANIM_Loop ) ) ;
2013-05-30 20:11:39 +00:00
}
else
2013-05-27 11:24:42 +00:00
{
2013-06-04 18:10:51 +00:00
SetAnimationPosition ( animation , Anim_Const ( anim_pos ) ) ;
2013-05-27 11:24:42 +00:00
}
2013-05-30 20:11:39 +00:00
2015-02-01 11:39:02 +00:00
// Deactivate power usage when not pumping.
2013-05-31 20:34:17 +00:00
if ( powered & & ( act = = " Wait " | | act = = " WaitForLiquid " ) )
2013-05-27 11:24:42 +00:00
{
2014-12-30 19:24:13 +00:00
if ( power_used < 0 )
UnregisterPowerProduction ( ) ;
else if ( power_used > 0 )
UnregisterPowerRequest ( ) ;
2013-05-31 20:34:17 +00:00
power_used = 0 ;
powered = false ;
2013-05-30 20:11:39 +00:00
}
2015-02-01 11:39:02 +00:00
// Finally, set the action.
2013-05-30 20:11:39 +00:00
SetAction ( act ) ;
2015-03-01 09:27:29 +00:00
}
/* Deactivates a running pump or vice-versa. */
func ToggleOnOff ( bool no_menu_refresh )
{
switched_on = ! switched_on ;
CheckState ( ) ;
2015-11-25 11:05:26 +00:00
if ( ! switched_on )
SetInfoMessage ( " $StateTurnedOff$ " ) ;
2015-03-01 09:27:29 +00:00
if ( ! no_menu_refresh )
2015-06-03 20:32:36 +00:00
UpdateInteractionMenus ( this . GetPumpControlMenuEntries ) ;
}
2014-12-30 19:24:13 +00:00
2016-12-24 11:15:16 +00:00
/*-- Material Selection --*/
2018-12-25 10:13:01 +00:00
func IsResourceSelectionParent ( id child_resource , id parent_resource )
2016-12-24 11:15:16 +00:00
{
2018-12-25 10:13:01 +00:00
return child_resource - > ~ GetParentLiquidType ( ) = = parent_resource ;
2016-12-24 11:15:16 +00:00
}
2018-12-25 10:13:01 +00:00
func ShowResourceSelectionMenuEntry ( id resource )
2016-12-24 11:15:16 +00:00
{
2018-12-25 10:13:01 +00:00
return resource - > ~ IsLiquid ( ) & & resource ! = Library_Liquid ;
2016-12-24 11:15:16 +00:00
}
2018-12-25 10:13:01 +00:00
func InitResourceSelection ( )
2016-12-24 11:15:16 +00:00
{
2018-12-25 10:13:01 +00:00
// Add all liquids to the list of ones allowed to pump.
var index = 0 , resource ;
while ( resource = GetDefinition ( index + + ) )
if ( ShowResourceSelectionMenuEntry ( resource ) )
AddToResourceSelection ( resource ) ;
return inherited ( ) ;
2016-12-24 11:15:16 +00:00
}
2018-12-25 10:13:01 +00:00
func IsInResourceSelection ( /* any */ mat )
2016-12-24 11:15:16 +00:00
{
if ( GetType ( mat ) = = C4V_Def )
2018-12-25 10:13:01 +00:00
{
return inherited ( mat ) ;
}
for ( var resource in GetResourceSelection ( ) )
{
if ( resource - > GetLiquidType ( ) = = mat )
2016-12-24 11:15:16 +00:00
return true ;
2018-12-25 10:13:01 +00:00
}
2016-12-24 11:15:16 +00:00
return false ;
}
2016-12-24 14:12:14 +00:00
public func GetPumpMaterialsMenuEntries ( object clonk )
{
2018-12-25 10:13:01 +00:00
return GetResourceSelectionMenuEntries ( clonk ) ;
2016-12-24 14:12:14 +00:00
}
public func OnPumpMaterialsHover ( id symbol , string action , desc_menu_target , menu_id )
{
var text = " " ;
2018-12-25 10:13:01 +00:00
if ( action = = RESOURCE_SELECT_Menu_Action_Resource_Enable )
{
text = Format ( " $MsgEnableMaterial$ " , symbol - > GetName ( ) ) ;
}
else if ( action = = RESOURCE_SELECT_Menu_Action_Resource_Disable )
{
text = Format ( " $MsgDisableMaterial$ " , symbol - > GetName ( ) ) ;
}
2016-12-24 14:12:14 +00:00
GuiUpdateText ( text , menu_id , 1 , desc_menu_target ) ;
}
public func OnPumpMaterials ( symbol_or_object , string action , bool alt )
{
2018-12-25 10:13:01 +00:00
if ( action = = RESOURCE_SELECT_Menu_Action_Resource_Enable )
{
AddToResourceSelection ( symbol_or_object ) ;
}
else if ( action = = RESOURCE_SELECT_Menu_Action_Resource_Disable )
{
RemoveFromResourceSelection ( symbol_or_object ) ;
}
2016-12-24 14:12:14 +00:00
UpdateInteractionMenus ( this . GetPumpMaterialsMenuEntries ) ;
}
2016-12-24 11:15:16 +00:00
2014-12-30 19:24:13 +00:00
/*-- Properties --*/
protected func Definition ( def )
{
// for title image
SetProperty ( " PictureTransformation " , Trans_Rotate ( 50 , 0 , 1 , 0 ) , def ) ;
// for building preview
SetProperty ( " MeshTransformation " , Trans_Rotate ( 50 , 0 , 1 , 0 ) , def ) ;
2016-12-27 13:20:35 +00:00
return _inherited ( def , . . . ) ;
2014-12-30 19:24:13 +00:00
}
/*
States
" Wait " : turned off or source pipe not connected
" WaitForPower " : turned on but no power ( does consume power )
" WaitForLiquid " : turned on but no liquid ( does not consume power )
" Pump " : currently working and consuming / producing power
*/
local ActMap = {
Pump = {
Prototype = Action ,
Name = " Pump " ,
Length = 30 ,
Delay = 3 ,
2015-12-13 21:14:55 +00:00
Sound = " Structures::Pumpjack " ,
2014-12-30 19:24:13 +00:00
NextAction = " Pump " ,
StartCall = " CheckState " ,
PhaseCall = " Pumping "
} ,
Wait = {
Prototype = Action ,
Name = " Wait " ,
Delay = 90 ,
NextAction = " Wait " ,
EndCall = " CheckState "
} ,
WaitForPower = {
Prototype = Action ,
Name = " WaitForPower " ,
Delay = 30 ,
NextAction = " WaitForPower " ,
EndCall = " CheckState "
} ,
WaitForLiquid = {
Prototype = Action ,
Name = " WaitForLiquid " ,
Delay = 30 ,
NextAction = " WaitForLiquid " ,
EndCall = " CheckState "
}
} ;
local Name = " $Name$ " ;
local Description = " $Description$ " ;
2017-11-21 17:16:45 +00:00
local BlastIncinerate = 70 ;
2017-08-18 15:59:25 +00:00
local NoBurnDecay = true ;
2014-12-30 19:24:13 +00:00
local HitPoints = 70 ;
2017-11-21 17:16:45 +00:00
local FireproofContainer = true ;
2016-05-01 14:14:56 +00:00
local Components = { Wood = 1 , Metal = 3 } ;
2016-09-23 07:26:06 +00:00
// Pump speed in amount of pixels to pump per 30 frames.
local PumpSpeed = 50 ;