/tg/ Station 13 - Modules - TypesVar Details - Proc Details

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:0 -- 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_power()' 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_power(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_usagethe amount of static power load this machine adds to its area's power_usage list when use_power = ACTIVE_POWER_USE
atmos_processingIs this machine currently in the atmos machinery queue?
idle_power_usagethe amount of static power load this machine adds to its area's power_usage list when use_power = IDLE_POWER_USE
is_operationalA combination of factors such as having power, not being broken and so on. Boolean.
last_used_timeworld.time of last use by /mob/living
last_user_mobtypeMobtype of last user. Typecast to /mob/living for initial() usage
processing_flagsViable flags to go here are START_PROCESSING_ON_INIT, or START_PROCESSING_MANUALLY. See code__DEFINES\machines.dm for more information on these flags.
static_power_usagethe current amount of static power usage this machine is taking from its area
subsystem_typeWhat 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.

Procs

AI_notify_hackAlerts the AI that a hack is in progress.
begin_processingHelper proc for telling a machine to start processing with the subsystem type that is located in its subsystem_type var.
directly_use_powerAn alternative to 'use_power', this proc directly costs the APC in direct charge, as opposed to being calculated periodically.
dump_contentsDrop every movable atom in the machine's contents list, including any components and circuit.
dump_inventory_contentsDrop every movable atom in the machine's contents list that is not a component_part.
end_processingHelper proc for telling a machine to stop processing with the subsystem type that is located in its subsystem_type var.
on_set_is_operationalCalled when the value of is_operational changes, so we can react to it.
on_set_machine_statCalled when the value of machine_stat changes, so we can react to it.
open_machineOpens the machine.
power_changeCalled whenever the power settings of the containing area change
remove_area_power_relationshipproc 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_operationalCalled when we want to change the value of the is_operational variable. Boolean.
set_machine_statCalled when we want to change the value of the machine_stat variable. Holds bitflags.
setup_area_power_relationshipproc 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_frameSpawns 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.
try_put_in_handPuts passed object in to user's hand
unset_static_powerinternal proc that removes all static power usage from the current area
update_current_power_usagemakes this machine draw power from its area according to which use_power mode it is set to
update_mode_power_usagesets 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_channelupdates the power channel this machine uses. removes the static power usage from the old channel and readds it to the new channel
update_use_powerupdates the use_power var for this machine and updates its static power usage from its area to reflect the new value
use_power_from_netAttempts 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

atmos_processing

Is this machine currently in the atmos machinery queue?

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

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

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.

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.

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.

begin_processing

Helper proc for telling a machine to start processing with the subsystem type that is located in its subsystem_type var.

directly_use_power

An alternative to 'use_power', this proc directly costs the APC in direct charge, as opposed to being calculated periodically.

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:

end_processing

Helper proc for telling a machine to stop processing with the subsystem type that is located in its subsystem_type var.

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.

open_machine

Opens the machine.

Will update the machine icon and any user interfaces currently open. Arguments:

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

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.

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.

Arguments:

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:

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:

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_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: