lua fixes
This commit is contained in:
parent
3c62ce97db
commit
5d0d1432ed
|
@ -27,12 +27,7 @@ function Settings.remove(key)
|
|||
end
|
||||
|
||||
function Settings.set(key, value)
|
||||
local valuestr = convertSettingValue(value)
|
||||
if valuestr == '' then
|
||||
g_configs.remove(key)
|
||||
else
|
||||
g_configs.set(key, convertSettingValue(value))
|
||||
end
|
||||
end
|
||||
|
||||
function Settings.setDefault(key, value)
|
||||
|
|
|
@ -76,3 +76,10 @@ function toboolean(str)
|
|||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local oldtonumber = tonumber
|
||||
function tonumber(v)
|
||||
local v = oldtonumber(v)
|
||||
if not v then return 0 end
|
||||
return v
|
||||
end
|
||||
|
|
|
@ -49,30 +49,11 @@ bool ConfigManager::save()
|
|||
{
|
||||
OTMLDocumentPtr doc = OTMLDocument::create();
|
||||
for(auto it : m_confsMap) {
|
||||
if(it.second == "")
|
||||
continue;
|
||||
OTMLNodePtr node = OTMLNode::create(it.first, it.second);
|
||||
doc->addChild(node);
|
||||
}
|
||||
return doc->save(m_fileName);
|
||||
}
|
||||
|
||||
bool ConfigManager::exists(const std::string& key)
|
||||
{
|
||||
return m_confsMap.find(key) != m_confsMap.end();
|
||||
}
|
||||
|
||||
void ConfigManager::set(const std::string& key, const std::string& value)
|
||||
{
|
||||
m_confsMap[key] = value;
|
||||
}
|
||||
|
||||
std::string ConfigManager::get(const std::string& key)
|
||||
{
|
||||
return m_confsMap[key];
|
||||
}
|
||||
|
||||
void ConfigManager::remove(const std::string& key)
|
||||
{
|
||||
auto it = m_confsMap.find(key);
|
||||
if(it != m_confsMap.end())
|
||||
m_confsMap.erase(it);
|
||||
}
|
||||
|
|
|
@ -31,10 +31,10 @@ public:
|
|||
bool load(const std::string& file);
|
||||
bool save();
|
||||
|
||||
bool exists(const std::string& key);
|
||||
void set(const std::string& key, const std::string& value);
|
||||
std::string get(const std::string& key);
|
||||
void remove(const std::string& key);
|
||||
bool exists(const std::string& key) { return m_confsMap.find(key) != m_confsMap.end(); }
|
||||
void set(const std::string& key, const std::string& value) { m_confsMap[key] = value; }
|
||||
std::string get(const std::string& key) { return m_confsMap[key]; }
|
||||
void remove(const std::string& key) { m_confsMap[key] = ""; }
|
||||
|
||||
private:
|
||||
std::string m_fileName;
|
||||
|
|
|
@ -45,8 +45,8 @@ void push_luavalue(int i)
|
|||
bool luavalue_cast(int index, int& i)
|
||||
{
|
||||
i = g_lua.toInteger(index);
|
||||
if(i == 0 && !g_lua.isNumber(index))
|
||||
return false;
|
||||
//if(i == 0 && !g_lua.isNumber(index))
|
||||
// return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -59,8 +59,8 @@ void push_luavalue(double d)
|
|||
bool luavalue_cast(int index, double& d)
|
||||
{
|
||||
d = g_lua.toNumber(index);
|
||||
if(d == 0 && !g_lua.isNumber(index))
|
||||
return false;
|
||||
//if(d == 0 && !g_lua.isNumber(index))
|
||||
// return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue