diff options
Diffstat (limited to 'src/cat')
| -rw-r--r-- | src/cat/LegacyLuaAPI.cpp | 2 | ||||
| -rw-r--r-- | src/cat/TPTScriptInterface.cpp | 25 |
2 files changed, 20 insertions, 7 deletions
diff --git a/src/cat/LegacyLuaAPI.cpp b/src/cat/LegacyLuaAPI.cpp index 293d45e..9c32ad5 100644 --- a/src/cat/LegacyLuaAPI.cpp +++ b/src/cat/LegacyLuaAPI.cpp @@ -1100,7 +1100,7 @@ int luatpt_reset_spark(lua_State* l) if (luacon_sim->parts[i].ctype >= 0 && luacon_sim->parts[i].ctype < PT_NUM) { luacon_sim->parts[i].type = luacon_sim->parts[i].ctype; - luacon_sim->parts[i].life = 0; + luacon_sim->parts[i].life = luacon_sim->parts[i].ctype = 0; } else luacon_sim->kill_part(i); 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 |
