diff options
| author | jacob1 <jfu614@gmail.com> | 2013-08-30 03:37:57 (GMT) |
|---|---|---|
| committer | jacob1 <jfu614@gmail.com> | 2013-08-30 03:37:57 (GMT) |
| commit | b2957dc1c9b2f025727a57063f2e252647918fc2 (patch) | |
| tree | 9749929979814ca81d5cdad05b87d4bda0b51fcf /src/cat/TPTScriptInterface.cpp | |
| parent | a5cee8c393eb89440d78e2cd766653381a630ba4 (diff) | |
| download | powder-b2957dc1c9b2f025727a57063f2e252647918fc2.zip powder-b2957dc1c9b2f025727a57063f2e252647918fc2.tar.gz | |
ability to use Celcius and Farenheit in console
Diffstat (limited to 'src/cat/TPTScriptInterface.cpp')
| -rw-r--r-- | src/cat/TPTScriptInterface.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/cat/TPTScriptInterface.cpp b/src/cat/TPTScriptInterface.cpp index 21e93ab..e821559 100644 --- a/src/cat/TPTScriptInterface.cpp +++ b/src/cat/TPTScriptInterface.cpp @@ -255,16 +255,29 @@ AnyType TPTScriptInterface::tptS_set(std::deque<std::string> * words) //Selector int newValue; if(value.GetType() == TypeNumber) + { newValue = ((NumberType)value).Value(); + } else if(value.GetType() == TypeString) { - newValue = GetParticleType(((StringType)value).Value()); - if (newValue < 0 || newValue >= PT_NUM) + if (property.Value() == "temp") { - // TODO: add element CAKE to invalidate this - if (!strcasecmp(((StringType)value).Value().c_str(),"cake")) - throw GeneralException("Cake is a lie, not an element"); - throw GeneralException("Invalid element"); + std::string newString = ((StringType)value).Value(); + if (newString.at(newString.length()-1) == 'C') + newValue = atoi(newString.substr(0, newString.length()-1).c_str())+273; + 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); + } + else + { + newValue = GetParticleType(((StringType)value).Value()); + if (newValue < 0 || newValue >= PT_NUM) + { + // TODO: add element CAKE to invalidate this + if (!strcasecmp(((StringType)value).Value().c_str(),"cake")) + throw GeneralException("Cake is a lie, not an element"); + throw GeneralException("Invalid element"); + } } } else |
