Files
Polaris/code/game/objects/items/weapons/hydroponics.dm
Neerti 828dacf485 Centralizes weight class definitions
A lot of new defines are now in inventory_sizes.dm, which contains;
All the size identifiers (the thing that tells the game if something is bulky, or w/e).
Storage costs for all the sizes, which are exponents of two, as previously.
A few constants for inventory size.

Also changes all storage item's capacity definitions by basing it off of how many 'normal slots' exist for it.  This allows one to change the definition for all of the defines in the file, and everything will follow along without needing to change 500 files.  In testing, I made all ITEMSIZE_COST_* defines doubled, and nothing had broke.

The benefit of doing all of this is that it makes adding new weight classes in the future much simpler, and makes knowing how much space a container has easier, as seeing ITEMSIZE_COST_NORMAL * 7 means it can hold seven normal items.
2016-09-22 00:51:51 -04: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 = ITEMSIZE_TINY
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)
*/