- In preparation of fixing issue 585, which extends far further than just the things listed there, as well as to standardize the many incarnations of satchel-type code (pill boxes, mining satchels, hydroponics satchels, etc.) I have added some functions to storage type items:

New variables:
var/use_to_pickup = if 1, the storage item also works like satchels, which means you can use it on something else to pick it up.
var/display_contents_with_number = if 1, the items in the storage item are grouped by type with the number of items being displayed. See the screenshot.
var/allow_quick_empty = if 1 on creation, it adds a verb that allows you to empty the item with one click
var/allow_quick_gather = if 1 on creation, it adds a verb which allows you to switch between pick-up methods. one-per-click or all-on-tile. Same as satchels worked. use_to_pickup must be 1 for any of that to matter.
var/collection_mode = 1;  //0 = pick one at a time, 1 = pick all on tile

New procs:
/obj/item/weapon/storage/proc/can_be_inserted(obj/item/W as obj, stop_messages = 0)
- Returns 0 or 1, depending on whether the item W can be inserted
/obj/item/weapon/storage/proc/handle_item_insertion(obj/item/W as obj)
- Inserts the item into the storage item and calls all the procs it needs to. Doesn't check whether the item can fit tho, tha'ts what can_be_inserted() is for.
/obj/item/weapon/storage/proc/remove_from_storage(obj/item/W as obj, atom/new_location)
- Removes item W from the storage object and sets it's loc to new_location or get_turf(src) if one is not provided.
/obj/item/proc/on_exit_storage(obj/item/weapon/storage/S as obj)
- Called after the object has been removed from the storage item S. The object's loc is already set to the new one.
/obj/item/proc/on_enter_storage(obj/item/weapon/storage/S as obj)
- Called after the object has been inserted into the storage item S. The object's loc is already set to S.

I made satchels work on this new code. The rest will be added to it soon. See the screenshot.

Screenshot:
http://www.kamletos.si/new%20satchels.png

This is yet another big change and it is very possible that bugs will come from it. Please report them to me or on the tracker.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4451 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
baloh.matevz
2012-08-16 23:35:53 +00:00
parent be76c3afcc
commit cac628a640
11 changed files with 247 additions and 155 deletions

View File

@@ -31,7 +31,7 @@
new /obj/item/clothing/gloves/black(src)
new /obj/item/clothing/shoes/black(src)
new /obj/item/device/analyzer(src)
new /obj/item/weapon/satchel(src)
new /obj/item/weapon/storage/satchel(src)
new /obj/item/device/flashlight/lantern(src)
new /obj/item/weapon/shovel(src)
new /obj/item/weapon/pickaxe(src)

View File

@@ -380,9 +380,9 @@
user << "\blue You dug a hole."
gets_dug()
if(istype(W,/obj/item/weapon/satchel))
var/obj/item/weapon/satchel/S = W
if(S.mode)
if(istype(W,/obj/item/weapon/storage/satchel))
var/obj/item/weapon/storage/satchel/S = W
if(S.collection_mode)
for(var/obj/item/weapon/ore/O in src.contents)
O.attackby(W,user)
return
@@ -451,11 +451,11 @@
if(istype(M,/mob/living/silicon/robot))
var/mob/living/silicon/robot/R = M
if(istype(R.module, /obj/item/weapon/robot_module/miner))
if(istype(R.module_state_1,/obj/item/weapon/satchel/borg))
if(istype(R.module_state_1,/obj/item/weapon/storage/satchel))
src.attackby(R.module_state_1,R)
else if(istype(R.module_state_2,/obj/item/weapon/satchel/borg))
else if(istype(R.module_state_2,/obj/item/weapon/storage/satchel))
src.attackby(R.module_state_2,R)
else if(istype(R.module_state_3,/obj/item/weapon/satchel/borg))
else if(istype(R.module_state_3,/obj/item/weapon/storage/satchel))
src.attackby(R.module_state_3,R)
else
return

View File

@@ -5,25 +5,6 @@
icon = 'icons/obj/mining.dmi'
icon_state = "ore"
/obj/item/weapon/ore/attackby(obj/item/weapon/W as obj, mob/user as mob)
..()
if (istype(W, /obj/item/weapon/satchel))
var/obj/item/weapon/satchel/S = W
if (S.mode == 1)
for (var/obj/item/weapon/ore/O in locate(src.x,src.y,src.z))
if (S.contents.len < S.capacity)
S.contents += O;
else
user << "\blue The satchel is full."
return
user << "\blue You pick up all the ores."
else
if (S.contents.len < S.capacity)
S.contents += src;
else
user << "\blue The satchel is full."
return
/obj/item/weapon/ore/uranium
name = "Uranium ore"

View File

@@ -1,46 +1,3 @@
/**********************Satchel**************************/
/obj/item/weapon/satchel
icon = 'icons/obj/mining.dmi'
icon_state = "satchel"
name = "Mining Satchel"
var/mode = 1; //0 = pick one at a time, 1 = pick all on tile
var/capacity = 50; //the number of ore pieces it can carry.
flags = FPRINT | TABLEPASS
slot_flags = SLOT_BELT
w_class = 1
/obj/item/weapon/satchel/attack_self(mob/user as mob)
for (var/obj/item/weapon/ore/O in contents)
contents -= O
O.loc = user.loc
user << "\blue You empty the satchel."
return
/obj/item/weapon/satchel/attackby(obj/item/weapon/W as obj, mob/user as mob)
..()
if (istype(W, /obj/item/weapon/ore))
var/obj/item/weapon/ore/O = W
src.contents += O;
return
/obj/item/weapon/satchel/verb/toggle_mode()
set name = "Switch Satchel Method"
set category = "Object"
mode = !mode
switch (mode)
if(1)
usr << "The satchel now picks up all ore in a tile at once."
if(0)
usr << "The satchel now picks up one ore at a time."
/obj/item/weapon/satchel/borg
icon = 'icons/obj/mining.dmi'
icon_state = "satchel"
name = "Cyborg Mining Satchel"
mode = 1; //0 = pick one at a time, 1 = pick all on tile
capacity = 200; //the number of ore pieces it can carry.
/**********************Ore box**************************/
@@ -54,8 +11,10 @@
/obj/structure/ore_box/attackby(obj/item/weapon/W as obj, mob/user as mob)
if (istype(W, /obj/item/weapon/ore))
src.contents += W;
if (istype(W, /obj/item/weapon/satchel))
src.contents += W.contents
if (istype(W, /obj/item/weapon/storage))
var/obj/item/weapon/storage/S = W
for(var/obj/item/weapon/ore/O in S.contents)
S.remove_from_storage(W,src) //This will move the item to this item's contents
user << "\blue You empty the satchel into the box."
return