27 lines
No EOL
471 B
Lua
27 lines
No EOL
471 B
Lua
function parse(string)
|
|
if (string == nil) then
|
|
return 0
|
|
end
|
|
if (type(string) == "number") then
|
|
return string
|
|
end
|
|
|
|
if (string == "yes" or string == "true") then
|
|
return 1
|
|
end
|
|
|
|
if (string == "no" or string == "false") then
|
|
return 0
|
|
end
|
|
|
|
if (type(string) == "boolean") then
|
|
if (string) then
|
|
return 1
|
|
else
|
|
return 0
|
|
end
|
|
end
|
|
|
|
|
|
return tonumber(string)
|
|
end |