tubbo / openrct2-benchwarmer

An OpenRCT2 plugin that adds alternating benches and bins to your park's footpaths with a single click.
MIT License
37 stars 9 forks source link

Suggestion: Add Bin/Bench while placing paths. #14

Closed RundesBalli closed 1 year ago

RundesBalli commented 3 years ago

Currently, you have to use the Map-Menu => Benchwarmer => Add-Button to place Bins and Benches.

It would be very nice, if B&B's would placed automatically while placing paths. I don't know, if the API has a "trigger" for this "placing-event". If not, then this could be done via the interval.day-"Event" like in this plugin from @RGBrewer: https://github.com/RGBrewer/OpenRCT2-Mow-Grass/blob/master/mow_grass_daily.js#L13-L15

Sorry, I don't know JavaScript and I don't know the correct terms. I hope you understand my suggestion.

tubbo commented 3 years ago

This would be great, but I'm not sure if OpenRCT's APIs will allow for it. There's actually no documentation for any of this (yet), I'm reading the TypeScript definitions to get an idea of what APIs are made available to me. OpenRCT has a concept of "subscriptions" in which you can subscribe to various events that occur in the game, so this might be technically possible. Here's a list of them.

I would assume that the action.execute event is most likely the one that Benchwarmer would want to subscribe to in order to receive information about when paths were placed. It could listen to this event and whenever a path was placed, the plugin could add a bench or bin to that path depending on what was selected in the UI. It looks like we would have access to the information for where a given path was placed, but I'm not sure how accurate it would be at determining whether it was a path or just some scenery that was placed.

If anyone's looking to contribute, this would be a great place to start!

RundesBalli commented 3 years ago

but I'm not sure if OpenRCT's APIs will allow for it.

That's why I linked the other project with the daily subscription. In my opinion the daily execution of the script is absolutely sufficient. In this case there is no need to study the API documentation again or find out which api endpoints are responsible for that.

Reading English is so much easier than writing it :-D Sorry if anything makes no sense.

tubbo commented 3 years ago

That wouldn't be sufficient in my opinion. You can build paths faster than a single day can pass, and it would be really strange to build paths and then out of nowhere bins/benches just get placed on them at some point in the future, depending on how fast you're running the game. Also this code would be running every (game) day regardless of whether you need it or not, which is going to add more lag to your game. I would much rather subscribe to a more relevant event and sense whether something was built.

RundesBalli commented 3 years ago

I don't had this in my mind. You are right. I was just brainstorming :-)

tubbo commented 3 years ago

It seems that OpenRCT2 now has an action.execute subscription that we can listen on. This should be able to tell us whenever a footpath has been placed, and we can add bench/bin additions "as you go".

To get this actually working, a number of changes will need to be made, especially to the UI of this plugin:

  1. The normal workflow for adding bins/benches will change from "build when I click OK" to "build all the time". This will be accomplished in #24.
  2. The dialog will have to retain its settings (#17), because we'll need to know what bench/bin you selected as new footpaths are being constructed.
  3. The "OK" button will be renamed to "Build on All Paths", which will cause bins/benches to be placed everywhere

I think this will warrant a major version (breaking change) upgrade, now that we know how it can be done. In that major version, I'd also like to implement @ZehMatt's suggestion of using game actions rather than manipulating data points directly. I believe if we go this route, we'll be able to remove a lot of the ad-hoc "validation" code that exists in this plugin, such as making sure you have enough cash, making sure footpaths are within construction boundaries, etc.

tubbo commented 2 years ago

@RundesBalli I made a build for this feature as well if you want to check it out. benchwarmer.js.zip

RundesBalli commented 2 years ago

Of course, thank you!

grafik

Works as intended!

The financial overview (as in #20) updates as well in realtime!

RundesBalli commented 2 years ago

I've found a bug:

Lets assume this scenario: grafik

When you place a path in the center of the brown paths, it throws an error, because it is - of course - not possible to place benches/bins anywhere in there: grafik

Other Scenario: grafik

RundesBalli commented 2 years ago

Found another one! While placing queue: grafik

RundesBalli commented 2 years ago

Another comment: When building pre planned coasters from the templates that include scenario elements, benches/bins are not automatically added to the path.

tubbo commented 2 years ago

Yeah I've been noticing that queue lines throw an error if queue line TVs aren't available in the scenario (like if you're using RCT1 scenarios). That's my next task. :)

tubbo commented 2 years ago

When building pre planned coasters from the templates that include scenario elements, benches/bins are not automatically added to the path.

I don't think the game considers prebuilds to be "executing the action" of placing a footpath. It's like an all-or-nothing thing, which is supported by the fact that you get a flat price deducted from your financial total. So I don't think prebuilds will include this feature. I can make a comment in the README that makes this more clear, but yeah I don't think I can/should touch prebuilds.

RundesBalli commented 2 years ago

Yeah I've been noticing that queue lines throw an error if queue line TVs aren't available in the scenario (like if you're using RCT1 scenarios). That's my next task. :)

But the queue TVs are available in the scenario. I can place them by hand or with click on "build on all paths". I've just tried it on different maps (RCT1 & RCT2) and the error happens every time.

I don't think the game considers prebuilds to be "executing the action" of placing a footpath. It's like an all-or-nothing thing, which is supported by the fact that you get a flat price deducted from your financial total. So I don't think prebuilds will include this feature. I can make a comment in the README that makes this more clear, but yeah I don't think I can/should touch prebuilds.

Maybe the game provides a "I've just built a prebuild-coaster"-action and you can execute the "build on all paths" function after that. Just a thought.

tubbo commented 2 years ago

:tada: This issue has been resolved in version 1.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

tubbo commented 1 year ago

@RundesBalli

Maybe the game provides a "I've just built a prebuild-coaster"-action

Unfortunately, it does not, so far as I've seen.

RundesBalli commented 1 year ago

@RundesBalli

Maybe the game provides a "I've just built a prebuild-coaster"-action

Unfortunately, it does not, so far as I've seen.

Maybe the game could execute the "place on all paths" function every 10 days? Or once a month?