machinery
Machines in the world, such as computers, pipes, and airlocks.
Overview: Used to create objects that need a per step proc call. Default definition of 'Initialize()' stores a reference to src machine in global 'machines list'. Default definition of 'Destroy' removes reference to src machine in global 'machines list'.
Class Variables: use_power (num) current state of auto power use. Possible Values: NO_POWER_USE -- no auto power use IDLE_POWER_USE -- machine is using power at its idle power level ACTIVE_POWER_USE -- machine is using power at its active power level
active_power_usage (num) Value for the amount of power to use when in active power mode
idle_power_usage (num) Value for the amount of power to use when in idle power mode
power_channel (num) What channel to draw from when drawing power for power mode Possible Values: AREA_USAGE_EQUIP:1 -- Equipment Channel AREA_USAGE_LIGHT:2 -- Lighting Channel AREA_USAGE_ENVIRON:3 -- Environment Channel
component_parts (list) A list of component parts of machine used by frame based machines.
stat (bitflag) Machine status bit flags. Possible bit flags: BROKEN -- Machine is broken NOPOWER -- No power is being supplied to machine. MAINT -- machine is currently under going maintenance. EMPED -- temporary broken by EMP pulse
Class Procs: Initialize()
Destroy()
update_mode_power_usage()
updates the static_power_usage var of this machine and makes its static power usage from its area accurate.
called after the idle or active power usage has been changed.
update_power_channel()
updates the static_power_usage var of this machine and makes its static power usage from its area accurate.
called after the power_channel var has been changed or called to change the var itself.
unset_static_power()
completely removes the current static power usage of this machine from its area.
used in the other power updating procs to then readd the correct power usage.
Default definition uses 'use_power', 'power_channel', 'active_power_usage',
'idle_power_usage', 'powered()', and 'use_energy()' implement behavior.
powered(chan = -1) 'modules/power/power.dm' Checks to see if area that contains the object has power available for power channel given in 'chan'. -1 defaults to power_channel
use_energy(amount, chan=-1) 'modules/power/power.dm' Deducts 'amount' from the power channel 'chan' of the area that contains the object.
power_change() 'modules/power/power.dm' Called by the area that contains the object when ever that area under goes a power state change (area runs out of power, or area channel is turned off).
RefreshParts() 'game/machinery/machine.dm' Called to refresh the variables in the machine that are contributed to by parts contained in the component_parts list. (example: glass and material amounts for the autolathe)
Default definition does nothing.
process() 'game/machinery/machine.dm' Called by the 'machinery subsystem' once per machinery tick for each machine that is listed in its 'machines' list.
process_atmos() Called by the 'air subsystem' once per atmos tick for each machine that is listed in its 'atmos_machines' list. Compiled by Aygar
Vars | |
active_power_usage | the amount of static power load this machine adds to its area's power_usage list when use_power = ACTIVE_POWER_USE |
---|---|
always_area_sensitive | Do we want to hook into on_enter_area and on_exit_area? Disables some optimizations |
appearance_power_state | What was our power state the last time we updated its appearance? TRUE for on, FALSE for off, -1 for never checked |
atmos_processing | Is this machine currently in the atmos machinery queue? |
circuit | Circuit to be created and inserted when the machinery is created |
component_parts | list of all the parts used to build it, if made from certain kinds of frames. |
critical_machine | If this machine is critical to station operation and should have the area be excempted from power failures. |
fair_market_price | Used in NAP violation, pay fine |
idle_power_usage | the amount of static power load this machine adds to its area's power_usage list when use_power = IDLE_POWER_USE |
interaction_flags_machine | See code/DEFINES/interaction_flags.dm |
is_operational | A combination of factors such as having power, not being broken and so on. Boolean. |
last_used_time | world.time of last use by /mob/living |
last_user_mobtype | Mobtype of last user. Typecast to /mob/living for initial() usage |
machine_stat | see code/__DEFINES/stat.dm |
occupant | The mob that is sealed inside the machine |
occupant_typecache | if set, turned into typecache in Initialize, other wise, defaults to mob/living typecache |
panel_open | Is the machines maintainence panel open. |
payment_department | The department we are paying to use this machine |
processing_flags | Viable flags to go here are START_PROCESSING_ON_INIT, or START_PROCESSING_MANUALLY. See code__DEFINES\machines.dm for more information on these flags. |
state_open | Is the machine open or closed |
static_power_usage | the current amount of static power usage this machine is taking from its area |
subsystem_type | What subsystem this machine will use, which is generally SSmachines or SSfastprocess. By default all machinery use SSmachines. This fires a machine's process() roughly every 2 seconds. |
use_power | see code/__DEFINES/machines.dm |
Procs | |
AI_notify_hack | Alerts the AI that a hack is in progress. |
add_as_sabotage_target | Called if this machine is supposed to be a sabotage machine objective. |
available_energy | Returns the available energy from the apc's cell and grid that can be used. Args: |
begin_processing | Helper proc for telling a machine to start processing |
charge_cell | Draws power from the apc's powernet and cell to charge a power cell. Args: |
check_nap_violations | Checks for NAP non aggression principle, an anarcho capitalist event triggered by admins where using machines cost money |
clear_components | This should be called before mass qdeling components to make space for replacements. If not done, things will go awry as Exited() destroys the machine when it detects even a single component exiting the atom. |
directly_use_energy | An alternative to 'use_power', this proc directly costs the APC in direct charge, as opposed to prioritising the grid. Args: |
dump_contents | Drop every movable atom in the machine's contents list, including any components and circuit. |
dump_inventory_contents | Drop every movable atom in the machine's contents list that is not a component_part. |
end_processing | Helper proc for telling a machine to stop processing |
get_room_area | Get a valid powered area to reference for power use, mainly for wall-mounted machinery that isn't always mapped directly in a powered location. |
nap_violation | Actions to take in case of NAP violation Arguments |
on_deconstruction | called on deconstruction before the final deletion Arguments |
on_set_is_operational | Called when the value of is_operational changes, so we can react to it. |
on_set_machine_stat | Called when the value of machine_stat changes, so we can react to it. |
on_set_panel_open | Called when the value of panel_open changes, so we can react to it. |
open_machine | Opens the machine. |
post_machine_initialize | Called in LateInitialize meant to be the machine replacement to it This sets up power for the machine and requires parent be called, ensuring power works on all machines unless exempted with NO_POWER_USE. This is the proc to override if you want to do anything in LateInitialize. |
power_change | Called whenever the power settings of the containing area change |
process_early | Early process for machines added to SSmachines.processing_early to prioritize power draw |
process_late | Late process for machines added to SSmachines.processing_late to gather accurate recordings |
remove_area_power_relationship | proc to call when the machine stops requiring power after a duration of requiring power saves memory by removing the power relationship with its area if it exists and loses area sensitivity does not affect power usage itself |
set_is_operational | Called when we want to change the value of the is_operational variable. Boolean. |
set_machine_stat | Called when we want to change the value of the machine_stat variable. Holds bitflags. |
set_panel_open | Called when we want to change the value of the panel_open variable. Boolean. |
setup_area_power_relationship | proc to call when the machine starts to require power after a duration of not requiring power sets up power related connections to its area if it exists and becomes area sensitive does not affect power usage itself |
spawn_frame | Spawns a frame where this machine is. If the machine was not disassmbled, the frame is spawned damaged. If the frame couldn't exist on this turf, it's smashed down to metal sheets. |
toggle_panel_open | Toggles the panel_open var. Defined for convienience |
try_put_in_hand | Puts passed object in to user's hand |
unset_static_power | internal proc that removes all static power usage from the current area |
update_current_power_usage | makes this machine draw power from its area according to which use_power mode it is set to |
update_mode_power_usage | sets the power_usage linked to the specified use_power_mode to new_usage e.g. update_mode_power_usage(ACTIVE_POWER_USE, 10) sets active_power_use = 10 and updates its power draw from the machines area if use_power == ACTIVE_POWER_USE |
update_power_channel | updates the power channel this machine uses. removes the static power usage from the old channel and readds it to the new channel |
update_use_power | updates the use_power var for this machine and updates its static power usage from its area to reflect the new value |
use_energy | Draws energy from the APC. Will use excess energy from the APC's connected grid, then use energy from the APC's cell if there wasn't enough energy from the grid, unless ignore_apc is true. Args: |
use_power_from_net | Attempts to draw power directly from the APC's Powernet rather than the APC's battery. For high-draw machines, like the cell charger |
Var Details
active_power_usage
the amount of static power load this machine adds to its area's power_usage list when use_power = ACTIVE_POWER_USE
always_area_sensitive
Do we want to hook into on_enter_area and on_exit_area? Disables some optimizations
appearance_power_state
What was our power state the last time we updated its appearance? TRUE for on, FALSE for off, -1 for never checked
atmos_processing
Is this machine currently in the atmos machinery queue?
circuit
Circuit to be created and inserted when the machinery is created
component_parts
list of all the parts used to build it, if made from certain kinds of frames.
critical_machine
If this machine is critical to station operation and should have the area be excempted from power failures.
fair_market_price
Used in NAP violation, pay fine
idle_power_usage
the amount of static power load this machine adds to its area's power_usage list when use_power = IDLE_POWER_USE
interaction_flags_machine
See code/DEFINES/interaction_flags.dm
is_operational
A combination of factors such as having power, not being broken and so on. Boolean.
last_used_time
world.time of last use by /mob/living
last_user_mobtype
Mobtype of last user. Typecast to /mob/living for initial() usage
machine_stat
see code/__DEFINES/stat.dm
occupant
The mob that is sealed inside the machine
occupant_typecache
if set, turned into typecache in Initialize, other wise, defaults to mob/living typecache
panel_open
Is the machines maintainence panel open.
payment_department
The department we are paying to use this machine
processing_flags
Viable flags to go here are START_PROCESSING_ON_INIT, or START_PROCESSING_MANUALLY. See code__DEFINES\machines.dm for more information on these flags.
state_open
Is the machine open or closed
static_power_usage
the current amount of static power usage this machine is taking from its area
subsystem_type
What subsystem this machine will use, which is generally SSmachines or SSfastprocess. By default all machinery use SSmachines. This fires a machine's process() roughly every 2 seconds.
use_power
see code/__DEFINES/machines.dm
Proc Details
AI_notify_hack
Alerts the AI that a hack is in progress.
Sends all AIs a message that a hack is occurring. Specifically used for space ninja tampering as this proc was originally in the ninja files. However, the proc may also be used elsewhere.
add_as_sabotage_target
Called if this machine is supposed to be a sabotage machine objective.
available_energy
Returns the available energy from the apc's cell and grid that can be used. Args:
- consider_cell: Whether to count the energy from the APC's cell or not. Returns: The available energy the machine can access from the APC.
begin_processing
Helper proc for telling a machine to start processing
charge_cell
Draws power from the apc's powernet and cell to charge a power cell. Args:
- amount: The amount of energy given to the cell.
- cell: The cell to charge.
- grid_only: If true, only draw from the grid and ignore the APC's cell.
- channel: The power channel to use. Returns: The amount of energy the cell received.
check_nap_violations
Checks for NAP non aggression principle, an anarcho capitalist event triggered by admins where using machines cost money
clear_components
This should be called before mass qdeling components to make space for replacements. If not done, things will go awry as Exited() destroys the machine when it detects even a single component exiting the atom.
directly_use_energy
An alternative to 'use_power', this proc directly costs the APC in direct charge, as opposed to prioritising the grid. Args:
- amount: How much energy the APC's cell is to be costed.
- force: If true, consumes the remaining energy of the cell if there isn't enough energy to supply the demand. Returns: The amount of energy that got used by the cell.
dump_contents
Drop every movable atom in the machine's contents list, including any components and circuit.
dump_inventory_contents
Drop every movable atom in the machine's contents list that is not a component_part.
Proc does not drop components and will skip over anything in the component_parts list. Call dump_contents() to drop all contents including components. Arguments:
- subset - If this is not null, only atoms that are also contained within the subset list will be dropped.
end_processing
Helper proc for telling a machine to stop processing
get_room_area
Get a valid powered area to reference for power use, mainly for wall-mounted machinery that isn't always mapped directly in a powered location.
nap_violation
Actions to take in case of NAP violation Arguments
- mob/violator - the mob who violated the NAP aggrement
on_deconstruction
called on deconstruction before the final deletion Arguments
- disassembled - if TRUE means we used tools to deconstruct it, FALSE means it got destroyed by other means
on_set_is_operational
Called when the value of is_operational
changes, so we can react to it.
on_set_machine_stat
Called when the value of machine_stat
changes, so we can react to it.
on_set_panel_open
Called when the value of panel_open
changes, so we can react to it.
open_machine
Opens the machine.
Will update the machine icon and any user interfaces currently open. Arguments:
- drop - Boolean. Whether to drop any stored items in the machine. Does not include components.
- density - Boolean. Whether to make the object dense when it's open.
post_machine_initialize
Called in LateInitialize meant to be the machine replacement to it This sets up power for the machine and requires parent be called, ensuring power works on all machines unless exempted with NO_POWER_USE. This is the proc to override if you want to do anything in LateInitialize.
power_change
Called whenever the power settings of the containing area change
by default, check equipment channel & set flag, can override if needed
Returns TRUE if the NOPOWER flag was toggled
process_early
Early process for machines added to SSmachines.processing_early to prioritize power draw
process_late
Late process for machines added to SSmachines.processing_late to gather accurate recordings
remove_area_power_relationship
proc to call when the machine stops requiring power after a duration of requiring power saves memory by removing the power relationship with its area if it exists and loses area sensitivity does not affect power usage itself
set_is_operational
Called when we want to change the value of the is_operational
variable. Boolean.
set_machine_stat
Called when we want to change the value of the machine_stat variable. Holds bitflags.
set_panel_open
Called when we want to change the value of the panel_open
variable. Boolean.
setup_area_power_relationship
proc to call when the machine starts to require power after a duration of not requiring power sets up power related connections to its area if it exists and becomes area sensitive does not affect power usage itself
Returns TRUE if it triggered a full registration, FALSE otherwise We do this so machinery that want to sidestep the area sensitiveity optimization can
spawn_frame
Spawns a frame where this machine is. If the machine was not disassmbled, the frame is spawned damaged. If the frame couldn't exist on this turf, it's smashed down to metal sheets.
Arguments:
- disassembled - If FALSE, the machine was destroyed instead of disassembled and the frame spawns at reduced integrity.
toggle_panel_open
Toggles the panel_open var. Defined for convienience
try_put_in_hand
Puts passed object in to user's hand
Puts the passed object in to the users hand if they are adjacent. If the user is not adjacent then place the object on top of the machine.
Vars:
- object (obj) The object to be moved in to the users hand.
- user (mob/living) The user to recive the object
unset_static_power
internal proc that removes all static power usage from the current area
update_current_power_usage
makes this machine draw power from its area according to which use_power mode it is set to
update_mode_power_usage
sets the power_usage linked to the specified use_power_mode to new_usage e.g. update_mode_power_usage(ACTIVE_POWER_USE, 10) sets active_power_use = 10 and updates its power draw from the machines area if use_power == ACTIVE_POWER_USE
Arguments:
- use_power_mode - the use_power power mode to change. if IDLE_POWER_USE changes idle_power_usage, ACTIVE_POWER_USE changes active_power_usage
- new_usage - the new value to set the specified power mode var to
update_power_channel
updates the power channel this machine uses. removes the static power usage from the old channel and readds it to the new channel
update_use_power
updates the use_power var for this machine and updates its static power usage from its area to reflect the new value
use_energy
Draws energy from the APC. Will use excess energy from the APC's connected grid, then use energy from the APC's cell if there wasn't enough energy from the grid, unless ignore_apc is true. Args:
- amount: The amount of energy to use.
- channel: The power channel to use.
- ignore_apc: If true, do not consider the APC's cell when demanding energy.
- force: If true and if there isn't enough energy, consume the remaining energy. Returns 0 if false and there isn't enough energy. Returns: The amount of energy used.
use_power_from_net
Attempts to draw power directly from the APC's Powernet rather than the APC's battery. For high-draw machines, like the cell charger
Checks the surplus power on the APC's powernet, and compares to the requested amount. If the requested amount is available, this proc will add the amount to the APC's usage and return that amount. Otherwise, this proc will return FALSE. If the take_any var arg is set to true, this proc will use and return any surplus that is under the requested amount, assuming that the surplus is above zero. Args:
- amount, the amount of power requested from the powernet. In joules.
- take_any, a bool of whether any amount of power is acceptable, instead of all or nothing. Defaults to FALSE