Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Containers can be dumped into seed extractor #6328

Closed
wants to merge 2 commits into from

Conversation

doganesi
Copy link
Contributor

@doganesi doganesi commented May 24, 2024

About the pull request

Allows you to dump storage containers into the seed extractor.

Explain why it's good for the game

Some nice QOL so you don't have to individually place in 40 different plants one by one into the seed extractor.

Testing Photographs and Procedure

Screenshots & Videos

https://streamable.com/6ter1w

Changelog

🆑 Asmocard
qol: Can now dump containers into the seed extractor
/:cl:

@github-actions github-actions bot added the Quality of Life Make the game harder to play label May 24, 2024
if(new_seed_type)
to_chat(user, SPAN_NOTICE("You extract some seeds from [item]."))
var/produce = rand(1,4)
for(var/i = 0;i<=produce;i++)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for(var/i in 0 to produce)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

faster

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 in container)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you're typechecking below, you can add "as anything" to scik the typecheck for loop does.

so essentially this
for(var/obj/item/item as anything in container)

I could be wrong but it seems very logical no?

if(user.temp_drop_inv_item(item))
var/datum/seed/new_seed_type
if(istype(item, /obj/item/grown))
var/obj/item/grown/F = item
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maints will get mad at one letter var

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kill the person who wrote the original seed extractor code, but I'll fix it

// Plant bag and other storage containers.
if(istype(O,/obj/item/storage))
var/obj/item/storage/container = O
if(container.contents.len > 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

length(container.contents) over .len since its nullsafe (and tiny bit faster too, at least I was told so.)

@vero5123
Copy link
Contributor

You should use early returns where possible.

// Plant bag and other storage containers.
if(istype(O,/obj/item/storage))
var/obj/item/storage/container = O
if(length(container.contents) > 0)
Copy link
Contributor

@kiVts kiVts May 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vero got a point, this code nests with if statements that could be early returned pretty deep, you can early return this. Essentially make the if statement opposite and then return in it with a message that you failed for whatever reason.

so essenially this

if(!correct)
     to_world("you failed")
     return
code here

instead of

if(correct)
   code here
else
    to_world("you failed")

or in this case swap the > with = or wrap the whole statement in brackets() and put ! infront of them to flip the result.

if(!(result == 0))

var/obj/item/reagent_container/food/snacks/grown/plant = item
new_seed_type = GLOB.seed_types[plant.plantname]

if(new_seed_type)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, just put ! infront like the usual and sort that stuff there. also remove the else clause from this if and put that there.

@doganesi
Copy link
Contributor Author

doganesi commented May 26, 2024

Did a pretty stupid workaround with the /storage proc I added to fix item backgrounds remaining in the container after processing, let me know if there's a better way of doing that please.

@doganesi doganesi marked this pull request as draft May 28, 2024 05:54
Copy link
Contributor

github-actions bot commented Jun 5, 2024

This PR has been inactive for long enough to be automatically marked as stale. This means it is at risk of being auto closed in ~ 7 days, please address any outstanding review items and ensure your PR is finished, if these are all true and you are auto-staled anyway, you need to actively ask maintainers if your PR will be merged. Once you have done any of the previous actions then you should request a maintainer remove the stale label on your PR, to reset the stale timer. If you feel no maintainer will respond in that time, you may wish to close this PR youself, while you seek maintainer comment, as you will then be able to reopen the PR yourself

@github-actions github-actions bot added the Stale beg a maintainer to review your PR label Jun 5, 2024
@github-actions github-actions bot closed this Jun 15, 2024
@doganesi doganesi deleted the seed-extractor-boxes branch August 7, 2024 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Quality of Life Make the game harder to play Stale beg a maintainer to review your PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants