fix tpt.set_property setting integers above 255, fix fs.isDir/File, add "Color" as valid property for elements api, fix tpt.display_mode to match tpt, other minor changes
This commit is contained in:
parent
9fb3e75f93
commit
392271a269
@ -1010,7 +1010,7 @@ int luatpt_set_property(lua_State* l)
|
|||||||
} else {
|
} else {
|
||||||
t = luaL_optint(l, 2, 0);
|
t = luaL_optint(l, 2, 0);
|
||||||
}
|
}
|
||||||
if (format == CommandInterface::FormatInt && (t<0 || t>=PT_NUM || !luacon_sim->elements[t].Enabled))
|
if (!strcmp(prop,"type") && (t<0 || t>=PT_NUM || !luacon_sim->elements[t].Enabled))
|
||||||
return luaL_error(l, "Unrecognised element number '%d'", t);
|
return luaL_error(l, "Unrecognised element number '%d'", t);
|
||||||
} else {
|
} else {
|
||||||
name = (char*)luaL_optstring(l, 2, "dust");
|
name = (char*)luaL_optstring(l, 2, "dust");
|
||||||
@ -1702,7 +1702,7 @@ int luatpt_heat(lua_State* l)
|
|||||||
|
|
||||||
int luatpt_cmode_set(lua_State* l)
|
int luatpt_cmode_set(lua_State* l)
|
||||||
{
|
{
|
||||||
int cmode = luaL_optint(l, 1, 0);
|
int cmode = luaL_optint(l, 1, 0)+1;
|
||||||
if (cmode >= 0 && cmode <= 10)
|
if (cmode >= 0 && cmode <= 10)
|
||||||
luacon_controller->LoadRenderPreset(cmode);
|
luacon_controller->LoadRenderPreset(cmode);
|
||||||
else
|
else
|
||||||
|
@ -714,7 +714,7 @@ void LuaScriptInterface::initRendererAPI()
|
|||||||
{"renderModes", renderer_renderModes},
|
{"renderModes", renderer_renderModes},
|
||||||
{"displayModes", renderer_displayModes},
|
{"displayModes", renderer_displayModes},
|
||||||
{"colourMode", renderer_colourMode},
|
{"colourMode", renderer_colourMode},
|
||||||
{"colorMode", renderer_colourMode}, //Duplicate of above to make americans happy
|
{"colorMode", renderer_colourMode}, //Duplicate of above to make Americans happy
|
||||||
{"decorations", renderer_decorations},
|
{"decorations", renderer_decorations},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
@ -1175,7 +1175,7 @@ int LuaScriptInterface::elements_element(lua_State * l)
|
|||||||
|
|
||||||
luacon_model->BuildMenus();
|
luacon_model->BuildMenus();
|
||||||
luacon_sim->init_can_move();
|
luacon_sim->init_can_move();
|
||||||
std::fill(luacon_ren->graphicscache, luacon_ren->graphicscache+PT_NUM, gcache_item());
|
luacon_ren->graphicscache[id].isready = 0;
|
||||||
|
|
||||||
lua_pop(l, 1);
|
lua_pop(l, 1);
|
||||||
return 0;
|
return 0;
|
||||||
@ -1238,8 +1238,6 @@ int LuaScriptInterface::elements_property(lua_State * l)
|
|||||||
if(id < 0 || id >= PT_NUM || !luacon_sim->elements[id].Enabled)
|
if(id < 0 || id >= PT_NUM || !luacon_sim->elements[id].Enabled)
|
||||||
return luaL_error(l, "Invalid element");
|
return luaL_error(l, "Invalid element");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(args > 2)
|
if(args > 2)
|
||||||
{
|
{
|
||||||
StructProperty property;
|
StructProperty property;
|
||||||
@ -1294,7 +1292,7 @@ int LuaScriptInterface::elements_property(lua_State * l)
|
|||||||
|
|
||||||
luacon_model->BuildMenus();
|
luacon_model->BuildMenus();
|
||||||
luacon_sim->init_can_move();
|
luacon_sim->init_can_move();
|
||||||
std::fill(luacon_ren->graphicscache, luacon_ren->graphicscache+PT_NUM, gcache_item());
|
luacon_ren->graphicscache[id].isready = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1341,7 +1339,7 @@ int LuaScriptInterface::elements_property(lua_State * l)
|
|||||||
lua_gr_func[id] = 0;
|
lua_gr_func[id] = 0;
|
||||||
luacon_sim->elements[id].Graphics = NULL;
|
luacon_sim->elements[id].Graphics = NULL;
|
||||||
}
|
}
|
||||||
std::fill(luacon_ren->graphicscache, luacon_ren->graphicscache+PT_NUM, gcache_item());
|
luacon_ren->graphicscache[id].isready = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return luaL_error(l, "Invalid element property");
|
return luaL_error(l, "Invalid element property");
|
||||||
@ -1700,7 +1698,7 @@ int LuaScriptInterface::fileSystem_isFile(lua_State * l)
|
|||||||
{
|
{
|
||||||
const char * filename = lua_tostring(l, 1);
|
const char * filename = lua_tostring(l, 1);
|
||||||
|
|
||||||
bool exists = false;
|
bool isFile = false;
|
||||||
#ifdef WIN
|
#ifdef WIN
|
||||||
struct _stat s;
|
struct _stat s;
|
||||||
if(_stat(filename, &s) == 0)
|
if(_stat(filename, &s) == 0)
|
||||||
@ -1709,25 +1707,21 @@ int LuaScriptInterface::fileSystem_isFile(lua_State * l)
|
|||||||
if(stat(filename, &s) == 0)
|
if(stat(filename, &s) == 0)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if(s.st_mode & S_IFDIR)
|
if(s.st_mode & S_IFREG)
|
||||||
{
|
{
|
||||||
exists = true;
|
isFile = true; //Is file
|
||||||
}
|
|
||||||
else if(s.st_mode & S_IFREG)
|
|
||||||
{
|
|
||||||
exists = false;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
exists = false;
|
isFile = false; //Is directory or something else
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
exists = false;
|
isFile = false; //Doesn't exist
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushboolean(l, exists);
|
lua_pushboolean(l, isFile);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1735,7 +1729,7 @@ int LuaScriptInterface::fileSystem_isDirectory(lua_State * l)
|
|||||||
{
|
{
|
||||||
const char * filename = lua_tostring(l, 1);
|
const char * filename = lua_tostring(l, 1);
|
||||||
|
|
||||||
bool exists = false;
|
bool isDir = false;
|
||||||
#ifdef WIN
|
#ifdef WIN
|
||||||
struct _stat s;
|
struct _stat s;
|
||||||
if(_stat(filename, &s) == 0)
|
if(_stat(filename, &s) == 0)
|
||||||
@ -1746,23 +1740,19 @@ int LuaScriptInterface::fileSystem_isDirectory(lua_State * l)
|
|||||||
{
|
{
|
||||||
if(s.st_mode & S_IFDIR)
|
if(s.st_mode & S_IFDIR)
|
||||||
{
|
{
|
||||||
exists = false;
|
isDir = true; //Is directory
|
||||||
}
|
|
||||||
else if(s.st_mode & S_IFREG)
|
|
||||||
{
|
|
||||||
exists = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
exists = false;
|
isDir = false; //Is file or something else
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
exists = false;
|
isDir = false; //Doesn't exist
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_pushboolean(l, exists);
|
lua_pushboolean(l, isDir);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ std::vector<StructProperty> Element::GetProperties()
|
|||||||
std::vector<StructProperty> properties;
|
std::vector<StructProperty> properties;
|
||||||
properties.push_back(StructProperty("Name", StructProperty::String, offsetof(Element, Name)));
|
properties.push_back(StructProperty("Name", StructProperty::String, offsetof(Element, Name)));
|
||||||
properties.push_back(StructProperty("Colour", StructProperty::Colour, offsetof(Element, Colour)));
|
properties.push_back(StructProperty("Colour", StructProperty::Colour, offsetof(Element, Colour)));
|
||||||
|
properties.push_back(StructProperty("Color", StructProperty::Colour, offsetof(Element, Colour)));
|
||||||
properties.push_back(StructProperty("MenuVisible", StructProperty::Integer, offsetof(Element, MenuVisible)));
|
properties.push_back(StructProperty("MenuVisible", StructProperty::Integer, offsetof(Element, MenuVisible)));
|
||||||
properties.push_back(StructProperty("MenuSection", StructProperty::Integer, offsetof(Element, MenuSection)));
|
properties.push_back(StructProperty("MenuSection", StructProperty::Integer, offsetof(Element, MenuSection)));
|
||||||
properties.push_back(StructProperty("Advection", StructProperty::Float, offsetof(Element, Advection)));
|
properties.push_back(StructProperty("Advection", StructProperty::Float, offsetof(Element, Advection)));
|
||||||
|
Loading…
Reference in New Issue
Block a user