-
Notifications
You must be signed in to change notification settings - Fork 566
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
Conversation
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++) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.)
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
container contents.
c465c2d
to
1cab350
Compare
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. |
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 |
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: