Expand api method coverage#18037
Conversation
* Implement scenariosetsetting API call
Example call (changes ParkChargeMethod, which is 14, to 1, which is Free park entry, pay for ride):
`context.executeAction("scenariosetsetting", { "setting": 14, "value": 1 })`
* Implement StaffSetCostume API call
Example usage (changes costume of first entertainer):
`context.executeAction("staffsetcostume", { "staff": map.getAllEntities("staff").filter(function(staff) { return staff.staffType == "entertainer" })[0].id, "costume": 0 })`
* Implement parksetparameter API method
Example usages (note that the value doesn't matter for close/open park):
```
context.executeAction("parksetparameter", { "parameter": 0, "value": 0 }) // close the park
context.executeAction("parksetparameter", { "parameter": 1, "value": 0 }) // open the park
context.executeAction("parksetparameter", { "parameter": 2, "value": 12345 }) // set the flags (uint64_t) for "Same price for item across park"
```
* Implement parksetresearchfunding API method
Example usage (maximum funding on rollercoasters and thrill rides):
```
context.executeAction("parksetresearchfunding", { "priorities": 12, "fundingAmount": 3 })
```
* Implement staffsetcolour API method
Example usage (set handyman uniforms to orange):
`context.executeAction("staffsetcolour", { "staffType": 0, "colour": 20 })`
* Implement staffsetname API method
Example usage: `context.executeAction("staffsetname", { "staff": map.getAllEntities("staff")[0].id, "name": "Foo Bar" })`
* Implement staffsetorders API method
Example usage (assuming that the first staff member is a handyman: water gardens, empty trash bins):
`context.executeAction("staffsetorders", { "staff": map.getAllEntities("staff")[0].id, "orders": 6 })`
* add myself to contributors.md
|
Hopefully this fixes the commit message check |
|
Could you add helper enums and such to the ts file so that callers don't need to know what the constants mean. Also you should bump the plug-in api number. |
|
Sure thing, I'll need a day or two. Sorry I didn't see this sooner, I didn't get a GitHub notification for some reason. |
|
In the future, you can rewrite the git history and force-push to your branch to update the PR. No need to close one and open the next one. Opening multiple of the same PRs is annoying for reviewers. |
I apologize for the trouble. I tried to fix the commit history but I kept goofing up Will look into making the changes requested by @duncanspumpkin soon, thanks for your patience |
|
We should really update the .d.ts to include the action args types for all actions. |
Thanks for the reminder -- I was trying to work on this but was struggling a bit with time/finding examples of how to do it/time to do that. I wouldn't mind a bit of help doing that; otherwise I'll try to get that done sometime next week when I get home from visiting my brother. |
I already have the documentation for all place and remove actions - I use them in Scenery Manager. |
https://github.com/Sadret/openrct2-scenery-manager/blob/master/src/definitions/Actions.d.ts |
|
Still struggling to work out what to put for those exactly, so I've just been trying to create types/enums based on the different parameters in the added methods. I'll make a commit soon and see if I'm on the right track. One of the things I'm struggling with is testing the bitmask operations for different parameters to actually verify that I have things correct, such as staff orders or "same price throughout park" item types in the park. That's partially why I've been hesitant to make a commit, but I guess I'll just do it anyway so this doesn't sit in limbo longer. |
|
Is this sorta what is needed? $ git --no-pager diff
diff --git a/distribution/openrct2.d.ts b/distribution/openrct2.d.ts
index ceb687adf..93c3d39cb 100644
--- a/distribution/openrct2.d.ts
+++ b/distribution/openrct2.d.ts
@@ -510,6 +510,86 @@ declare global {
"waterraise" |
"watersetheight";
+ enum EntertainerCostume {
+ "panda",
+ "tiger",
+ "elephant",
+ "roman",
+ "gorilla",
+ "snowman",
+ "knight",
+ "astronaut",
+ "bandit",
+ "sheriff",
+ "pirate"
+ }
+
+ enum StaffOrders {
+ "sweeping",
+ "water_flowers",
+ "empty_bins",
+ "mowing",
+ "inspect_rides",
+ "fix_rides"
+ }
+
+ type ColourType =
+ "black" |
+ "grey" |
+ "white" |
+ "dark_purple" |
+ "light_purple" |
+ "bright_purple" |
+ "dark_blue" |
+ "light_blue" |
+ "icy_blue" |
+ "teal" |
+ "aquamarine" |
+ "saturated_green" |
+ "dark_green" |
+ "moss_green" |
+ "bright_green" |
+ "olive_green" |
+ "dark_olive_green" |
+ "bright_yellow" |
+ "yellow" |
+ "dark_yellow" |
+ "light_orange" |
+ "dark_orange" |
+ "light_brown" |
+ "saturated_brown" |
+ "dark_brown" |
+ "salmon_pink" |
+ "bordeaux_red" |
+ "saturated_red" |
+ "bright_red" |
+ "dark_pink" |
+ "bright_pink" |
+ "light_pink";
+
+ enum ResearchPriorities {
+ "new_transport_rides",
+ "new_gentle_rides",
+ "new_roller_coasters",
+ "new_thrill_rides",
+ "new_water_rides",
+ "new_shops_and_stalls",
+ "new_scenery_and_theming"
+ }
+
+ type ResearchFunding =
+ "none" |
+ "minimum" |
+ "normal" |
+ "maximum";
+
+ type ParkParameterType =
+ "close" |
+ "open" |
+ "same_price_in_park";
+
+
+
interface GameActionEventArgs {
readonly player: number;
readonly type: number;
diff --git a/src/openrct2/scripting/ScriptEngine.h b/src/openrct2/scripting/ScriptEngine.h
index b11cabd1b..1c7bec8c5 100644
--- a/src/openrct2/scripting/ScriptEngine.h
+++ b/src/openrct2/scripting/ScriptEngine.h
@@ -46,7 +46,7 @@ namespace OpenRCT2
namespace OpenRCT2::Scripting
{
- static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 60;
+ static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 61;
// Versions marking breaking changes.
static constexpr int32_t API_VERSION_33_PEEP_DEPRECATION = 33;I'm not entirely sure if this is what you're asking for. I might switch from enum/type, I guess I'm not sure if I'm putting it in the right spot or anything, but I figured enum would be good since some keys have specific values not in the same order and are used for bitmask logic |
|
For e.g. the costumes, I would prefer You should use the same approach for the others: The string union type is not helpful at all because the GameAction expects integers and not strings. Also, you must be careful here, because e.g. the research priorities are given by flags. So the enum should be sth like: |
I got stuck with testing and writing the enums because I was struggling to test setting flags on certain things -- I wanted to be able to calculate the correct int for bitmask operations from the enums I was trying to write and not getting the expected results. Since I was working on this, I haven't had a lot of time. I would appreciate it if someone were able to help with that part of it, but otherwise, I'll keep working on it when I have a sec. Thanks for the bump! |
|
This pull request is stale and will be closed in 14 days if no action is taken. To keep it open, leave a comment or remove the |
|
Superseded by #18826. |
Foreword
This is my first contribution. Please scrutinize it, especially for api param names. I tried to follow existing convention as much as I could.
This PR adds support to the API for a variety of methods. I would've added more, but I was struggling to figure out the correct syntax for some of them -- I'll keep working on them if/when this gets accepted.
staffsetordersExample usage (assuming that the first staff member is a handyman) water gardens, empty trash bins:
staffsetnameExample: Set first staff member's name to Foo Bar
staffsetcolourExample: Set handyman uniforms to orange
parksetresearchfundingExample usage (maximum funding on rollercoasters and thrill rides):
parksetparameterExample usages (note that the value doesn't matter for close/open park):
staffsetcostumeExample usage (changes costume of first entertainer):
scenariosetsettingExample call (changes ParkChargeMethod to "Free park entry, pay for ride":