diff --git a/src/script/api/script_object.cpp b/src/script/api/script_object.cpp index cf677a43ab..7c201199a5 100644 --- a/src/script/api/script_object.cpp +++ b/src/script/api/script_object.cpp @@ -143,6 +143,16 @@ ScriptObject::ActiveInstance::~ActiveInstance() return GetStorage()->last_cost; } +/* static */ void ScriptObject::SetLastCommandResultData(uint32 last_result) +{ + GetStorage()->last_result = last_result; +} + +/* static */ uint32 ScriptObject::GetLastCommandResultData() +{ + return GetStorage()->last_result; +} + /* static */ void ScriptObject::SetRoadType(RoadType road_type) { GetStorage()->road_type = road_type; @@ -358,6 +368,7 @@ ScriptObject::ActiveInstance::~ActiveInstance() /* Costs of this operation. */ SetLastCost(res.GetCost()); + SetLastCommandResultData(res.GetResultData()); SetLastCommandRes(true); if (_generating_world) { diff --git a/src/script/api/script_object.hpp b/src/script/api/script_object.hpp index b0746f1e50..a5dedd267d 100644 --- a/src/script/api/script_object.hpp +++ b/src/script/api/script_object.hpp @@ -237,6 +237,16 @@ protected: */ static Money GetLastCost(); + /** + * Set the result data of the last command. + */ + static void SetLastCommandResultData(uint32 last_result); + + /** + * Get the result data of the last command. + */ + static uint32 GetLastCommandResultData(); + /** * Set a variable that can be used by callback functions to pass information. */ diff --git a/src/script/script_instance.cpp b/src/script/script_instance.cpp index f645260672..49861e1e36 100644 --- a/src/script/script_instance.cpp +++ b/src/script/script_instance.cpp @@ -737,6 +737,7 @@ bool ScriptInstance::DoCommandCallback(const CommandCost &result, TileIndex tile } else { ScriptObject::IncreaseDoCommandCosts(result.GetCost()); ScriptObject::SetLastCost(result.GetCost()); + ScriptObject::SetLastCommandResultData(result.GetResultData()); } ScriptObject::SetLastCommand(INVALID_TILE, 0, 0, 0, CMD_END); diff --git a/src/script/script_storage.hpp b/src/script/script_storage.hpp index 3fef7bebee..b41b27ce23 100644 --- a/src/script/script_storage.hpp +++ b/src/script/script_storage.hpp @@ -41,6 +41,7 @@ private: CommandCost costs; ///< The costs the script is tracking. Money last_cost; ///< The last cost of the command. + uint32 last_result; ///< The last result data of the command. uint last_error; ///< The last error of the command. bool last_command_res; ///< The last result of the command. @@ -75,6 +76,7 @@ public: allow_do_command (true), /* costs (can't be set) */ last_cost (0), + last_result (0), last_error (STR_NULL), last_command_res (true), last_tile (INVALID_TILE),