Fixed alt-click not working with stacks (#34396)

* Can disable auto-merge

New argument which lets you stop stacks from automatically merging when picking them up

* Fix 0 stacks

* Updated simple_animal/put_in_hands()
This commit is contained in:
John Ginnane
2018-01-15 04:04:18 +00:00
committed by CitadelStationBot
parent 969a8ac9ef
commit ac1b2f76ef
3 changed files with 17 additions and 13 deletions

View File

@@ -202,7 +202,7 @@
//Puts the item our active hand if possible. Failing that it tries other hands. Returns TRUE on success.
//If both fail it drops it on the floor and returns FALSE.
//This is probably the main one you need to know :)
/mob/proc/put_in_hands(obj/item/I, del_on_fail = FALSE)
/mob/proc/put_in_hands(obj/item/I, del_on_fail = FALSE, merge_stacks = TRUE)
if(!I)
return FALSE
@@ -211,16 +211,20 @@
var/obj/item/stack/I_stack = I
var/obj/item/stack/active_stack = get_active_held_item()
if (istype(active_stack) && istype(I_stack, active_stack.merge_type))
if (I_stack.merge(active_stack))
to_chat(usr, "<span class='notice'>Your [active_stack.name] stack now contains [active_stack.get_amount()] [active_stack.singular_name]\s.</span>")
return TRUE
else
var/obj/item/stack/inactive_stack = get_inactive_held_item()
if (istype(inactive_stack) && istype(I_stack, inactive_stack.merge_type))
if (I_stack.merge(inactive_stack))
to_chat(usr, "<span class='notice'>Your [inactive_stack.name] stack now contains [inactive_stack.get_amount()] [inactive_stack.singular_name]\s.</span>")
if (I_stack.zero_amount())
return FALSE
if (merge_stacks)
if (istype(active_stack) && istype(I_stack, active_stack.merge_type))
if (I_stack.merge(active_stack))
to_chat(usr, "<span class='notice'>Your [active_stack.name] stack now contains [active_stack.get_amount()] [active_stack.singular_name]\s.</span>")
return TRUE
else
var/obj/item/stack/inactive_stack = get_inactive_held_item()
if (istype(inactive_stack) && istype(I_stack, inactive_stack.merge_type))
if (I_stack.merge(inactive_stack))
to_chat(usr, "<span class='notice'>Your [inactive_stack.name] stack now contains [inactive_stack.get_amount()] [inactive_stack.singular_name]\s.</span>")
return TRUE
if(put_in_active_hand(I))
return TRUE

View File

@@ -502,8 +502,8 @@
if(H)
H.update_icon()
/mob/living/simple_animal/put_in_hands(obj/item/I)
..()
/mob/living/simple_animal/put_in_hands(obj/item/I, del_on_fail = FALSE, merge_stacks = TRUE)
..(I, del_on_fail, merge_stacks)
update_inv_hands()
/mob/living/simple_animal/update_inv_hands()