storage
Datumized Storage Eliminates the need for custom signals specifically for the storage component, and attaches a storage variable (atom_storage) to every atom. The parent and real_location variables are both weakrefs, so they must be resolved before they can be used. If you're looking to create custom storage type behaviors, check ../subtypes
Vars | |
allow_big_nesting | Whether we allow storage objects of the same size inside. |
---|---|
allow_quick_empty | If TRUE, we can use-in-hand the storage object to dump all of its contents. |
allow_quick_gather | If TRUE, we can click on items with the storage object to pick them up and insert them. |
animated | Determines whether we play a rustle animation when inserting/removing items. |
attack_hand_interact | Whether we open when attack_handed (clicked on with an empty hand). |
can_hold | Typecache of items that can be inserted into this storage. By default, all item types can be inserted (assuming other conditions are met). Do not set directly, use set_holdable |
can_hold_description | An additional description shown on double-examine. Is autogenerated to the can_hold list if not set. |
cant_hold | Typecache of items that cannot be inserted into this storage. By default, no item types are barred from insertion. Do not set directly, use set_holdable |
click_alt_open | Switch this off if you want to handle click_alt in the parent atom |
collection_mode | The mode for collection when allow_quick_gather is enabled. See [code/__DEFINES/storage.dm] |
display_contents | If TRUE, shows the contents of the storage in open_storage |
do_rustle | Determines whether we play a rustle sound when inserting/removing items. |
exception_hold | Typecache of items that can always be inserted into this storage, regardless of size. |
exception_max | For use with an exception typecache: The maximum amount of items of the exception type that can be inserted into this storage. |
insert_on_attack | do we insert items when clicked by them? |
insert_preposition | The preposition used when inserting items into this storage. IE: You put things in a bag, but on a plate. |
is_using | List of all the mobs currently viewing the contents of this storage. |
locked | Whether the storage is currently locked (inaccessible). See [code/__DEFINES/storage.dm] |
max_slots | The maximum amount of items that can be inserted into this storage. |
max_specific_storage | The largest weight class that can be inserted into this storage, inclusive. |
max_total_storage | Determines the maximum amount of weight that can be inserted into this storage. Weight is calculated by the sum of all of our content's weight classes. |
modeswitch_action | Ref to the item action that toggles collectmode. |
numerical_stacking | Instead of displaying multiple items of the same type, display them as numbered contents. |
open_sound | The sound to play when we open/access the storage |
parent | A reference to the atom linked to this storage object If the parent goes, we go. Will never be null. |
quickdraw | if TRUE, alt-click takes an item out instantly rather than opening up storage. |
real_location | A reference to the atom where the items are actually stored. By default this is parent. Should generally never be null. Sometimes it's not the parent, that's what is called "dissassociated storage". |
remove_rustle_sound | Path for the item's rustle sound when removing items. |
rustle_sound | Path for the item's rustle sound. |
screen_max_columns | Maximum amount of columns a storage object can have |
screen_max_rows | Maximum amount of rows a storage object can have |
screen_pixel_x | X-pixel location of the boxes and close button |
screen_pixel_y | Y-pixel location of the boxes and close button |
screen_start_x | Where storage starts being rendered, x-screen_loc wise |
screen_start_y | Where storage starts being rendered, y-screen_loc wise |
silent | If TRUE, chat messages for inserting/removing items will not be shown. |
silent_for_user | Same as above but only for the user. Useful to cut on chat spam without removing feedback for other players. |
storage_interfaces | Associated list that keeps track of all storage UI datums per person. |
supports_smart_equip | If we support smartly removing/inserting things from ourselves |
Procs | |
animate_parent | Gives a spiffy animation to our parent to represent opening and closing. |
attempt_insert | Attempts to insert an item into the storage |
attempt_remove | Attempts to remove an item from the storage Ignores removal do_afters. Only use this if you're doing it as part of a dumping action |
can_insert | Checks if an item is capable of being inserted into the storage. |
can_see_contents | Checks who is currently capable of viewing our storage (and is.) |
close_all | Close the storage UI for everyone viewing us. |
close_distance | Signal handler for whenever a mob walks away with us, close if they can't reach us. |
collect_on_turf | Collects every item of a type on a turf. |
contents_changed_w_class | Signal proc for COMSIG_ATOM_CONTENTS_WEIGHT_CLASS_CHANGED to drop items out of our storage if they're suddenly too heavy. |
dump_content_at | Dumps all of our contents at a specific location. |
generate_hold_desc | Generates a description, primarily for clothing storage. |
get_exception_count | Returns a count of how many items held due to exception_hold we have |
get_total_weight | Returns a sum of all of our content's weight classes |
handle_enter | Automatically ran on all object insertions: flag marking and view refreshing. |
handle_exit | Automatically ran on all object removals: flag marking and view refreshing. |
handle_mass_pickup | Inserts every item in a given list, with a progress bar |
hide_contents | Hide our storage from a mob. |
item_insertion_feedback | Provides visual feedback in chat for an item insertion |
item_interact_insert | Called directly from the attack chain if [insert_on_attack] is TRUE. Handles inserting an item into the storage when clicked. |
mass_empty | Signal handler for remove_all() |
mousedrop_receive | Since items inside storages ignore transparency for QOL reasons, we're tracking when things are dropped onto them instead of our UI elements |
on_attack | Signal handler for whenever we're attacked by a mob. |
on_click_alt | Alt click on the storage item. Default: Open the storage. |
on_emp_act | Signal handler for emp_act to emp all contents |
on_mousedrop_onto | Signal handler for whenever we drag the storage somewhere. |
on_mousedropped_onto | Signal handler for whenever something gets mouse-dropped onto us. |
on_preattack | Signal handler for preattack from an object. |
open_storage | Opens the storage to the mob, showing them the contents to their UI. |
open_storage_on_signal | Signal handler to open up the storage when we receive a signal. |
orient_storage | Updates views of all objects in storage and stretches UI to appropriate size |
process_numerical_display | Generates the numbers on an item in storage to show stacking. |
put_in_hands_async | Async version of putting something into a mobs hand. |
real_location_deleted | Signal handler for when the real location is deleted. |
refresh_views | Refresh the views of everyone currently viewing the storage. |
remove_all | Removes everything inside of our storage |
remove_and_refresh | Resets an object, removes it from our screen, and refreshes the view. |
remove_single | Allows a mob to attempt to remove a single item from the storage Allows for hooks into things like removal delays |
remove_type | Removes only a specific type of item from our storage |
reset_item | Refreshes and item to be put back into the real world, out of storage. |
return_inv | Recursive proc to get absolutely EVERYTHING inside a storage item, including the contents of inner items. |
set_parent | Set the passed atom as the parent |
set_real_location | Sets where items are physically being stored in the case it shouldn't be on the parent. |
show_contents | Show our storage to a mob. |
toggle_collection_mode | Toggles the collectmode of our storage. |
update_actions | Updates the action button for toggling collectmode. |
Var Details
allow_big_nesting
Whether we allow storage objects of the same size inside.
allow_quick_empty
If TRUE, we can use-in-hand the storage object to dump all of its contents.
allow_quick_gather
If TRUE, we can click on items with the storage object to pick them up and insert them.
animated
Determines whether we play a rustle animation when inserting/removing items.
attack_hand_interact
Whether we open when attack_handed (clicked on with an empty hand).
can_hold
Typecache of items that can be inserted into this storage. By default, all item types can be inserted (assuming other conditions are met). Do not set directly, use set_holdable
can_hold_description
An additional description shown on double-examine. Is autogenerated to the can_hold list if not set.
cant_hold
Typecache of items that cannot be inserted into this storage. By default, no item types are barred from insertion. Do not set directly, use set_holdable
click_alt_open
Switch this off if you want to handle click_alt in the parent atom
collection_mode
The mode for collection when allow_quick_gather is enabled. See [code/__DEFINES/storage.dm]
display_contents
If TRUE, shows the contents of the storage in open_storage
do_rustle
Determines whether we play a rustle sound when inserting/removing items.
exception_hold
Typecache of items that can always be inserted into this storage, regardless of size.
exception_max
For use with an exception typecache: The maximum amount of items of the exception type that can be inserted into this storage.
insert_on_attack
do we insert items when clicked by them?
insert_preposition
The preposition used when inserting items into this storage. IE: You put things in a bag, but on a plate.
is_using
List of all the mobs currently viewing the contents of this storage.
locked
Whether the storage is currently locked (inaccessible). See [code/__DEFINES/storage.dm]
max_slots
The maximum amount of items that can be inserted into this storage.
max_specific_storage
The largest weight class that can be inserted into this storage, inclusive.
max_total_storage
Determines the maximum amount of weight that can be inserted into this storage. Weight is calculated by the sum of all of our content's weight classes.
modeswitch_action
Ref to the item action that toggles collectmode.
numerical_stacking
Instead of displaying multiple items of the same type, display them as numbered contents.
open_sound
The sound to play when we open/access the storage
parent
A reference to the atom linked to this storage object If the parent goes, we go. Will never be null.
quickdraw
if TRUE, alt-click takes an item out instantly rather than opening up storage.
real_location
A reference to the atom where the items are actually stored. By default this is parent. Should generally never be null. Sometimes it's not the parent, that's what is called "dissassociated storage".
Do NOT set this directly, use set_real_location.
remove_rustle_sound
Path for the item's rustle sound when removing items.
rustle_sound
Path for the item's rustle sound.
screen_max_columns
Maximum amount of columns a storage object can have
screen_max_rows
Maximum amount of rows a storage object can have
screen_pixel_x
X-pixel location of the boxes and close button
screen_pixel_y
Y-pixel location of the boxes and close button
screen_start_x
Where storage starts being rendered, x-screen_loc wise
screen_start_y
Where storage starts being rendered, y-screen_loc wise
silent
If TRUE, chat messages for inserting/removing items will not be shown.
silent_for_user
Same as above but only for the user. Useful to cut on chat spam without removing feedback for other players.
storage_interfaces
Associated list that keeps track of all storage UI datums per person.
supports_smart_equip
If we support smartly removing/inserting things from ourselves
Proc Details
animate_parent
Gives a spiffy animation to our parent to represent opening and closing.
attempt_insert
Attempts to insert an item into the storage
Arguments
- obj/item/to_insert - the item we're inserting
- mob/user - (optional) the user who is inserting the item.
- override - see item_insertion_feedback()
- force - bypass locked storage up to a certain level. See [code/__DEFINES/storage.dm]
- messages - if TRUE, we will create balloon alerts for the user.
attempt_remove
Attempts to remove an item from the storage Ignores removal do_afters. Only use this if you're doing it as part of a dumping action
Arguments
- obj/item/thing - the object we're removing
- atom/remove_to_loc - where we're placing the item
- silent - if TRUE, we won't play any exit sounds
can_insert
Checks if an item is capable of being inserted into the storage.
Arguments
- obj/item/to_insert - the item we're checking
- messages - if TRUE, will print out a message if the item is not valid
- force - bypass locked storage up to a certain level. See [code/__DEFINES/storage.dm]
can_see_contents
Checks who is currently capable of viewing our storage (and is.)
close_all
Close the storage UI for everyone viewing us.
close_distance
Signal handler for whenever a mob walks away with us, close if they can't reach us.
collect_on_turf
Collects every item of a type on a turf.
@param obj/item/thing the initial object to pick up @param mob/user the user who is picking up the items
contents_changed_w_class
Signal proc for COMSIG_ATOM_CONTENTS_WEIGHT_CLASS_CHANGED to drop items out of our storage if they're suddenly too heavy.
dump_content_at
Dumps all of our contents at a specific location.
@param atom/dest_object where to dump to @param mob/user the user who is dumping the contents
generate_hold_desc
Generates a description, primarily for clothing storage.
get_exception_count
Returns a count of how many items held due to exception_hold we have
get_total_weight
Returns a sum of all of our content's weight classes
handle_enter
Automatically ran on all object insertions: flag marking and view refreshing.
handle_exit
Automatically ran on all object removals: flag marking and view refreshing.
handle_mass_pickup
Inserts every item in a given list, with a progress bar
Arguments
- mob/user - the user who is inserting the items
- list/things - the list of items to insert
- atom/thing_loc - the location of the items (used to make sure an item hasn't moved during pickup)
- list/rejections - a list used to make sure we only complain once about an invalid insertion
- datum/progressbar/progress - the progressbar used to show the progress of the insertion
hide_contents
Hide our storage from a mob.
Arguments
- mob/to_hide - the mob to hide the storage from
item_insertion_feedback
Provides visual feedback in chat for an item insertion
Arguments
- mob/user - the user who is inserting the item
- obj/item/thing - the item we're inserting
- override - skip feedback, only do animation check
item_interact_insert
Called directly from the attack chain if [insert_on_attack] is TRUE. Handles inserting an item into the storage when clicked.
mass_empty
Signal handler for remove_all()
mousedrop_receive
Since items inside storages ignore transparency for QOL reasons, we're tracking when things are dropped onto them instead of our UI elements
on_attack
Signal handler for whenever we're attacked by a mob.
on_click_alt
Alt click on the storage item. Default: Open the storage.
on_emp_act
Signal handler for emp_act to emp all contents
on_mousedrop_onto
Signal handler for whenever we drag the storage somewhere.
on_mousedropped_onto
Signal handler for whenever something gets mouse-dropped onto us.
on_preattack
Signal handler for preattack from an object.
open_storage
Opens the storage to the mob, showing them the contents to their UI.
open_storage_on_signal
Signal handler to open up the storage when we receive a signal.
orient_storage
Updates views of all objects in storage and stretches UI to appropriate size
process_numerical_display
Generates the numbers on an item in storage to show stacking.
put_in_hands_async
Async version of putting something into a mobs hand.
real_location_deleted
Signal handler for when the real location is deleted.
refresh_views
Refresh the views of everyone currently viewing the storage.
remove_all
Removes everything inside of our storage
Arguments
- atom/drop_loc - where we're placing the item
remove_and_refresh
Resets an object, removes it from our screen, and refreshes the view.
@param atom/movable/gone the object leaving our storage
remove_single
Allows a mob to attempt to remove a single item from the storage Allows for hooks into things like removal delays
Arguments
- mob/removing - the mob doing the removing
- obj/item/thing - the object we're removing
- atom/remove_to_loc - where we're placing the item
- silent - if TRUE, we won't play any exit sounds
remove_type
Removes only a specific type of item from our storage
Arguments
- type - the type of item to remove
- amount - how many we should attempt to pick up at one time
- check_adjacent - if TRUE, we'll check adjacent locations for the item type
- force - if TRUE, we'll bypass the check_adjacent check all together
- mob/user - the user who is removing the items
- list/inserted - (optional) allows consumers to pass a list to be filled with all removed items.
reset_item
Refreshes and item to be put back into the real world, out of storage.
return_inv
Recursive proc to get absolutely EVERYTHING inside a storage item, including the contents of inner items.
Arguments
- recursive - whether or not we're checking inside of inner items
set_parent
Set the passed atom as the parent
set_real_location
Sets where items are physically being stored in the case it shouldn't be on the parent.
Does not handle moving any existing items, that must be done manually.
Arguments
- atom/new_real_location - the new real location of the datum
- should_drop - if TRUE, all the items in the old real location will be dropped.
show_contents
Show our storage to a mob.
Arguments
- mob/to_show - the mob to show the storage to
Returns
- FALSE if the show failed
- TRUE otherwise
toggle_collection_mode
Toggles the collectmode of our storage.
@param mob/to_show the mob toggling us
update_actions
Updates the action button for toggling collectmode.