1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-26 00:04:43 +01:00

Make error message on console set command more descriptive

Previously when using `set variable something` you would always get the non-helpful message: "set variable command failed, likely due to permissions."

Since all of these are going through game actions, we can use the GameActionResult to return something more meaningful. For example, trying to do `set game_speed 5`:
Before:
![image](https://github.com/user-attachments/assets/7e52143b-ca5d-461c-8475-408ba6346350)

After:
![image](https://github.com/user-attachments/assets/44160ceb-954b-41f6-80e3-fe581403b404)
This commit is contained in:
Tulio Leao
2025-05-23 10:44:16 -03:00
committed by GitHub
parent cd63cd34d1
commit b04348c56b
2 changed files with 3 additions and 1 deletions

View File

@@ -741,7 +741,8 @@ static void ConsoleSetVariableAction(InteractiveConsole& console, std::string va
auto action = TAction(std::forward<TArgs>(args)...);
action.SetCallback([&console, var](const GameAction*, const GameActions::Result* res) {
if (res->Error != GameActions::Status::Ok)
console.WriteLineError(String::stdFormat("set %s command failed, likely due to permissions.", var.c_str()));
console.WriteLineError(String::stdFormat(
"set %s command failed: %s - %s.", var.c_str(), res->GetErrorTitle().c_str(), res->GetErrorMessage().c_str()));
else
console.Execute(String::stdFormat("get %s", var.c_str()));
console.EndAsyncExecution();