diff --git a/src/lua/TPTSTypes.cpp b/src/lua/TPTSTypes.cpp index 466a7eeca..6df68515a 100644 --- a/src/lua/TPTSTypes.cpp +++ b/src/lua/TPTSTypes.cpp @@ -86,12 +86,12 @@ AnyType::~AnyType() //Number Type -NumberType::NumberType(int number): AnyType(TypeNumber, ValueValue()) +NumberType::NumberType(float number): AnyType(TypeNumber, ValueValue()) { value.num = number; } -int NumberType::Value() +float NumberType::Value() { return value.num; } diff --git a/src/lua/TPTSTypes.h b/src/lua/TPTSTypes.h index 00dfbb695..688e0dc59 100644 --- a/src/lua/TPTSTypes.h +++ b/src/lua/TPTSTypes.h @@ -6,7 +6,7 @@ #include "gui/interface/Point.h" enum ValueType { TypeNumber, TypePoint, TypeString, TypeNull, TypeFunction }; -typedef union { int num; std::string* str; ui::Point* pt; } ValueValue; +typedef union { float num; std::string* str; ui::Point* pt; } ValueValue; class GeneralException { @@ -91,8 +91,8 @@ public: class NumberType: public AnyType { public: - NumberType(int number); - int Value(); + NumberType(float number); + float Value(); }; class StringType: public AnyType diff --git a/src/lua/TPTScriptInterface.cpp b/src/lua/TPTScriptInterface.cpp index 544747a66..e9d5c4ec2 100644 --- a/src/lua/TPTScriptInterface.cpp +++ b/src/lua/TPTScriptInterface.cpp @@ -117,7 +117,7 @@ ValueType TPTScriptInterface::testType(std::string word) return TypeString; } -int TPTScriptInterface::parseNumber(char * stringData) +float TPTScriptInterface::parseNumber(char * stringData) { char cc; int base = 10; @@ -257,7 +257,7 @@ AnyType TPTScriptInterface::tptS_set(std::deque * words) throw GeneralException("Invalid property"); //Selector - int newValue; + float newValue; if(value.GetType() == TypeNumber) { newValue = ((NumberType)value).Value(); @@ -268,9 +268,9 @@ AnyType TPTScriptInterface::tptS_set(std::deque * words) { std::string newString = ((StringType)value).Value(); if (newString.at(newString.length()-1) == 'C') - newValue = atoi(newString.substr(0, newString.length()-1).c_str())+273; + newValue = atof(newString.substr(0, newString.length()-1).c_str())+273.15; else if (newString.at(newString.length()-1) == 'F') - newValue = (int)((atoi(newString.substr(0, newString.length()-1).c_str())-32.0f)*5/9+273.15f); + newValue = (atof(newString.substr(0, newString.length()-1).c_str())-32.0f)*5/9+273.15f; } else { diff --git a/src/lua/TPTScriptInterface.h b/src/lua/TPTScriptInterface.h index dea284e73..d0144075d 100644 --- a/src/lua/TPTScriptInterface.h +++ b/src/lua/TPTScriptInterface.h @@ -7,7 +7,7 @@ class TPTScriptInterface: public CommandInterface { protected: AnyType eval(std::deque * words); - int parseNumber(char * stringData); + float parseNumber(char * stringData); AnyType tptS_set(std::deque * words); AnyType tptS_create(std::deque * words); AnyType tptS_delete(std::deque * words);