kitten-science / kitten-scientists

Home of Kitten Scientists v2
https://kitten-science.com/
MIT License
34 stars 14 forks source link

Workshop "Limited" Crafting Not Working? #499

Open theqmann opened 7 months ago

theqmann commented 7 months ago

Version Check

What browser are you using?

Firefox

How are you loading Kitten Scientists?

Bookmarklet

Describe the Bug

Per the documentation, the Limited button works as follows:

For a limited item to be crafted, we first look at all the materials that are required for the item to be crafted, and at our current stock for the item. We then calculate how much of our materials would be required to build all the items we already have in stock. If we have more materials than that, then we allow the additional materials to be crafted into more of the craftable item.

Let's assume you want to craft Beams. A beam costs 175 Wood, and you have 1 beam in stock. KS would then craft the next beam when you have 350 wood available.

In my game, I have 1 million beams in stock, and have 5 million wood max capacity. Based on the description, it shouldn't craft any more beams until I have 175 million wood (enough to meet the current stock). When setting Workshop threshold to any value (tried at 0.0, 0.1, and 0.995) it will craft beams immediately when the workshop threshold is met (at 0 threshold, it crafts immediately when wood > 175), without respecting the Limited flag.

Your Savegame

No response

To Reproduce

No response

Screenshots

No response

oliversalzburg commented 6 months ago

Can you maybe provide a savegame, just so there are no misunderstandings about the situation? I can't really wrap my head around it without walking through it in the debugger, I fear :(

dpatti commented 6 months ago

I ran into the same thing and I get the sense that this is explicitly how it was meant to work based on my reading of this comment and the surrounding code. The comment below it applies to crafted materials as well, but only under the condition that they're at their own "max". I think a similar condition for capped resources would make sense where you can exceed the limit only once the required resource is capped. This would make setting a lower workshop trigger a much more viable option, without which you can get into some resource starvation issues.

oliversalzburg commented 5 months ago

@dpatti Thanks for looking into it. There haven't been any recent changes to how the script works at its core. At this point, it's always highly likely that the script is working as intended. If the intention is the right one, is always up for debate :) So, your analysis is likely to be correct.

Resource crafting just has a lot of edge cases that are hard to all get right, while still keeping the rules simple enough so you always know why things are happening (hopefully). At the very least, I'm always open to further clarify how things should behave.

oliversalzburg commented 1 week ago

Possibly related to #451