diff --git a/src/CBot/CBotVar/CBotVar.cpp b/src/CBot/CBotVar/CBotVar.cpp index fc4503ea..4e88cd69 100644 --- a/src/CBot/CBotVar/CBotVar.cpp +++ b/src/CBot/CBotVar/CBotVar.cpp @@ -741,5 +741,39 @@ CBotClass* CBotVar::GetClass() return nullptr; } +CBotVar::operator int() +{ + return GetValInt(); +} + +CBotVar::operator float() +{ + return GetValFloat(); +} + +CBotVar::operator std::string() +{ + return GetValString(); +} + +void CBotVar::operator=(const CBotVar &var) +{ + SetVal(const_cast(&var)); +} + +void CBotVar::operator=(int x) +{ + SetValInt(x); +} + +void CBotVar::operator=(float x) +{ + SetValFloat(x); +} + +void CBotVar::operator=(const std::string &x) +{ + SetValString(x); +} } // namespace CBot diff --git a/src/CBot/CBotVar/CBotVar.h b/src/CBot/CBotVar/CBotVar.h index be171783..7babb7d1 100644 --- a/src/CBot/CBotVar/CBotVar.h +++ b/src/CBot/CBotVar/CBotVar.h @@ -444,6 +444,14 @@ public: */ //@{ + operator int(); + operator float(); + operator std::string(); + void operator=(const CBotVar& var); + void operator=(int x); + void operator=(float x); + void operator=(const std::string &x); + /** * \brief Set the value * \param var Another variable to copy value from