| | | 1 | | using MoonSharp.Interpreter; |
| | | 2 | | |
| | | 3 | | namespace Itinero.Profiles.Lua; |
| | | 4 | | |
| | | 5 | | internal static class LuaTableExtensions |
| | | 6 | | { |
| | | 7 | | internal static double? GetDouble(this Table table, string key) |
| | 7168 | 8 | | { |
| | 7168 | 9 | | var val = table.Get(key); |
| | 7168 | 10 | | if (val.IsNil() || val.IsVoid()) |
| | 2356 | 11 | | { |
| | 2356 | 12 | | return null; |
| | | 13 | | } |
| | | 14 | | |
| | 4812 | 15 | | return val.CastToNumber(); |
| | 7168 | 16 | | } |
| | | 17 | | |
| | | 18 | | internal static bool? GetBoolean(this Table table, string key) |
| | 1785 | 19 | | { |
| | 1785 | 20 | | var val = table.Get(key); |
| | 1785 | 21 | | if (val.IsNil() || val.IsVoid()) |
| | 1195 | 22 | | { |
| | 1195 | 23 | | return null; |
| | | 24 | | } |
| | | 25 | | |
| | 590 | 26 | | if (val.Type == DataType.Boolean) |
| | 590 | 27 | | { |
| | 590 | 28 | | return val.Boolean; |
| | | 29 | | } |
| | | 30 | | |
| | 0 | 31 | | return val.CastToBool(); |
| | 1785 | 32 | | } |
| | | 33 | | } |