Content Patcher

Content Patcher

463k Downloads

[Automate] Any reason why you can't use performObjectDropInAction?

mbattaglia005 opened this issue ยท 3 comments

commented

Hi Pathoschild,

I was wondering why you can't use the game's methods for starting machines' crafting processes.

I was looking at your response in #86 but I am still unsure about my question. Will the game really play the machine sounds for a Farmer instance that is not a real player? What if the fake Farmer's location was elsewhere (or even null if that's possible)? Can't you see what a machine has produced through heldObject.Value before removing it to determine if it should be moved to another place in a machine group?

I ask because I am making a mod that alters the behavior of machines with Harmony, but I would like for it to be compatible with Automate. Since Automate handles the machines' crafting with it's own code, my mod's code will not run unless the player manually drops an item into a machine. I also figured out a way to make my mod with custom machines, but they of course do not not work with Automate either (maybe they would when the Automate API is made?)

I would be willing to try to make this happen in a pull request but I know you are working on some new features and if you think my work will not fit into the plans you have then I suppose there isn't much of a point.

commented

Hi @mbattaglia005. The main issues with calling performObjectDropInAction from Automate are...

  1. A drop-in sound will be played for each machine, for every player in the current location. The fake farmer's location can't be null, but setting it to a location which doesn't contain any players would hide the sound though.
  2. A sprite animation will be broadcast for every machine to all players in multiplayer, which may cause latency.
  3. It would increase the performance cost, since the method would recheck all the conditions Automate already checked and run unneeded code for sounds/animations. That's an issue since Automate can already cause lag in some cases with hundreds of machines.

What changes did you want to make to the method?

commented

Thank you for the explanation.

To answer your question, I want to make a mod where the quality of the ingredient used to make an artisan good effects the stats and sell price of the output artisan good.

So if you used a silver star quality milk in a cheese press, the cheese that is produced would recover more health and stamina, and sell for more than cheese made with regular quality milk. Gold star would produce better stats and price than silver, and iridium would be even more.

The easy way to make this work was to add some extra code to the performObjectDropIn method to check what quality the item dropped in was, and then alter the heldObject of the machine.

There's more details for how the mod works, but that's the gist of it.

commented

That's not possible with the current Automate design (at least not without the disadvantages listed above), but I do want to support integrations like that once it has an API. I'll close this ticket in favor of #119 though.