mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-09-03 04:52:35 +02:00
ability to use Celcius and Farenheit in console
This commit is contained in:
@@ -255,16 +255,29 @@ AnyType TPTScriptInterface::tptS_set(std::deque<std::string> * words)
|
|||||||
//Selector
|
//Selector
|
||||||
int newValue;
|
int newValue;
|
||||||
if(value.GetType() == TypeNumber)
|
if(value.GetType() == TypeNumber)
|
||||||
|
{
|
||||||
newValue = ((NumberType)value).Value();
|
newValue = ((NumberType)value).Value();
|
||||||
|
}
|
||||||
else if(value.GetType() == TypeString)
|
else if(value.GetType() == TypeString)
|
||||||
{
|
{
|
||||||
newValue = GetParticleType(((StringType)value).Value());
|
if (property.Value() == "temp")
|
||||||
if (newValue < 0 || newValue >= PT_NUM)
|
|
||||||
{
|
{
|
||||||
// TODO: add element CAKE to invalidate this
|
std::string newString = ((StringType)value).Value();
|
||||||
if (!strcasecmp(((StringType)value).Value().c_str(),"cake"))
|
if (newString.at(newString.length()-1) == 'C')
|
||||||
throw GeneralException("Cake is a lie, not an element");
|
newValue = atoi(newString.substr(0, newString.length()-1).c_str())+273;
|
||||||
throw GeneralException("Invalid element");
|
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
|
else
|
||||||
|
Reference in New Issue
Block a user