/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: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_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
always_area_sensitiveDo we want to hook into on_enter_area and on_exit_area? Disables some optimizations
appearance_power_stateWhat was our power state the last time we updated its appearance? TRUE for on, FALSE for off, -1 for never checked
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
machine_power_rectifierMultiplier for power consumption.
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.
add_as_sabotage_targetCalled if this machine is supposed to be a sabotage machine objective.
begin_processingHelper proc for telling a machine to start processing with the subsystem type that is located in its subsystem_type var.
clear_componentsThis 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_powerAn alternative to 'use_power', this proc directly costs the APC in direct charge, as opposed to being calculated periodically.
display_partssorting is very important especially because we are breaking out when required part is found in the inner for loop if the rped first picked up a tier 3 part AND THEN a tier 4 part tier 3 would be installed and the loop would break and check for the next required component thus completly ignoring the tier 4 component inside we also ignore stack components inside the RPED cause we dont exchange that
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.
get_room_areaGet a valid powered area to reference for power use, mainly for wall-mounted machinery that isn't always mapped directly in a powered location.
on_deconstructioncalled on deconstruction before the final deletion Arguments
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.
on_set_panel_openCalled when the value of panel_open 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.
set_panel_openCalled when we want to change the value of the panel_open variable. Boolean.
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.
toggle_panel_openToggles the panel_open var. Defined for convienience
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

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?

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

machine_power_rectifier

Multiplier for power consumption.

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.

add_as_sabotage_target

Called if this machine is supposed to be a sabotage machine objective.

begin_processing

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

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_power

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

display_parts

sorting is very important especially because we are breaking out when required part is found in the inner for loop if the rped first picked up a tier 3 part AND THEN a tier 4 part tier 3 would be installed and the loop would break and check for the next required component thus completly ignoring the tier 4 component inside we also ignore stack components inside the RPED cause we dont exchange that

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.

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.

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.

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.

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:

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:

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: