Skip to content

Commit

Permalink
Cleaned up seed_extractor.dm, added functionality for storage contain…
Browse files Browse the repository at this point in the history
…er mass processing.
  • Loading branch information
doganesi committed Jul 30, 2024
1 parent 2521048 commit b6e0edc
Showing 1 changed file with 43 additions and 14 deletions.
57 changes: 43 additions & 14 deletions code/game/machinery/seed_extractor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,61 @@
density = TRUE
anchored = TRUE

/obj/structure/machinery/seed_extractor/attackby(obj/item/O as obj, mob/user as mob)
/obj/structure/machinery/seed_extractor/attackby(obj/item/object as obj, mob/user as mob)

// Plant bag and other storage containers.
if(istype(object,/obj/item/storage))
var/obj/item/storage/container = object
if(length(container.contents) == 0)
to_chat(user, SPAN_NOTICE("[container] is empty."))
return

to_chat(user, SPAN_NOTICE("You start dumping the contents of [container] into [src]."))
if(!do_after(user, 1.5 SECONDS, INTERRUPT_ALL, BUSY_ICON_GENERIC))
return

for(var/obj/item/item as anything in container)
if(extract(item, user))
// Bandaid to update the container contents and delete "ghosts" of items after they're been processed
container.remove_from_storage(item)
item.moveToNullspace()

playsound(user.loc, "rustle", 15, 1, 6)
else
extract(object, user)



/obj/structure/machinery/seed_extractor/proc/extract(obj/item/object as obj, mob/user as mob)
// Fruits and vegetables.
if(istype(O, /obj/item/reagent_container/food/snacks/grown) || istype(O, /obj/item/grown))
if(user.temp_drop_inv_item(O))
if(istype(object, /obj/item/reagent_container/food/snacks/grown) || istype(object, /obj/item/grown))
if(user.temp_drop_inv_item(object))
var/datum/seed/new_seed_type
if(istype(O, /obj/item/grown))
var/obj/item/grown/F = O
new_seed_type = GLOB.seed_types[F.plantname]
if(istype(object, /obj/item/grown))
var/obj/item/grown/plant = object
new_seed_type = GLOB.seed_types[plant.plantname]
else
var/obj/item/reagent_container/food/snacks/grown/F = O
new_seed_type = GLOB.seed_types[F.plantname]
var/obj/item/reagent_container/food/snacks/grown/plant = object
new_seed_type = GLOB.seed_types[plant.plantname]

if(new_seed_type)
to_chat(user, SPAN_NOTICE("You extract some seeds from [O]."))
to_chat(user, SPAN_NOTICE("You extract some seeds from [object]."))
var/produce = rand(1,4)
for(var/i = 0;i<=produce;i++)
var/obj/item/seeds/seeds = new(get_turf(src))
seeds.seed_type = new_seed_type.name
seeds.update_seed()
else
to_chat(user, "[O] doesn't seem to have any usable seeds inside it.")
qdel(O)
to_chat(user, "[object] doesn't seem to have any usable seeds inside it.")
qdel(object)
return TRUE
//Grass.
else if(istype(O, /obj/item/stack/tile/grass))
var/obj/item/stack/tile/grass/S = O
if (S.use(1))
else if(istype(object, /obj/item/stack/tile/grass))
var/obj/item/stack/tile/grass/grass = object
if (grass.use(1))
to_chat(user, SPAN_NOTICE("You extract some seeds from the grass tile."))
new /obj/item/seeds/grassseed(loc)
return TRUE
else
to_chat(user, SPAN_WARNING("Cannot get seeds from [object]."))
return FALSE

0 comments on commit b6e0edc

Please sign in to comment.