Files
Polaris/code/game/objects/items/weapons/hydroponics.dm
2015-06-02 20:18:45 +01:00

114 lines
3.0 KiB
Plaintext

/*
* SeedBag
*/
//uncomment when this is updated to match storage update
/*
/obj/item/weapon/seedbag
icon = 'icons/obj/hydroponics_machines.dmi'
icon_state = "seedbag"
name = "Seed Bag"
desc = "A small satchel made for organizing seeds."
var/mode = 1; //0 = pick one at a time, 1 = pick all on tile
var/capacity = 500; //the number of seeds it can carry.
slot_flags = SLOT_BELT
w_class = 1
var/list/item_quants = list()
/obj/item/weapon/seedbag/attack_self(mob/user as mob)
user.machine = src
interact(user)
/obj/item/weapon/seedbag/verb/toggle_mode()
set name = "Switch Bagging Method"
set category = "Object"
mode = !mode
switch (mode)
if(1)
usr << "The bag now picks up all seeds in a tile at once."
if(0)
usr << "The bag now picks up one seed pouch at a time."
/obj/item/seeds/attackby(var/obj/item/O as obj, var/mob/user as mob)
..()
if (istype(O, /obj/item/weapon/seedbag))
var/obj/item/weapon/seedbag/S = O
if (S.mode == 1)
for (var/obj/item/seeds/G in locate(src.x,src.y,src.z))
if (S.contents.len < S.capacity)
S.contents += G;
if(S.item_quants[G.name])
S.item_quants[G.name]++
else
S.item_quants[G.name] = 1
else
user << "<span class='warning'>The seed bag is full.</span>"
S.updateUsrDialog()
return
user << "<span class='notice'>You pick up all the seeds.</span>"
else
if (S.contents.len < S.capacity)
S.contents += src;
if(S.item_quants[name])
S.item_quants[name]++
else
S.item_quants[name] = 1
else
user << "<span class='warning'>The seed bag is full.</span>"
S.updateUsrDialog()
return
/obj/item/weapon/seedbag/interact(mob/user as mob)
var/dat = "<TT><b>Select an item:</b><br>"
if (contents.len == 0)
dat += "<font color = 'red'>No seeds loaded!</font>"
else
for (var/O in item_quants)
if(item_quants[O] > 0)
var/N = item_quants[O]
dat += "<FONT color = 'blue'><B>[capitalize(O)]</B>:"
dat += " [N] </font>"
dat += "<a href='byond://?src=\ref[src];vend=[O]'>Vend</A>"
dat += "<br>"
dat += "<br><a href='byond://?src=\ref[src];unload=1'>Unload All</A>"
dat += "</TT>"
user << browse("<HEAD><TITLE>Seedbag Supplies</TITLE></HEAD><TT>[dat]</TT>", "window=seedbag")
onclose(user, "seedbag")
return
/obj/item/weapon/seedbag/Topic(href, href_list)
if(..())
return
usr.machine = src
if ( href_list["vend"] )
var/N = href_list["vend"]
if(item_quants[N] <= 0) // Sanity check, there are probably ways to press the button when it shouldn't be possible.
return
item_quants[N] -= 1
for(var/obj/O in contents)
if(O.name == N)
O.loc = get_turf(src)
usr.put_in_hands(O)
break
else if ( href_list["unload"] )
item_quants.Cut()
for(var/obj/O in contents )
O.loc = get_turf(src)
src.updateUsrDialog()
return
/obj/item/weapon/seedbag/updateUsrDialog()
var/list/nearby = range(1, src)
for(var/mob/M in nearby)
if ((M.client && M.machine == src))
src.attack_self(M)
*/