private static Dictionary<string, Double> luaOrderTable2DictionaryDouble(LuaTable lTable) { Dictionary<string, Double> ht = new Dictionary<string, Double>(); //probably any mod can do its custom format for the order config file //but the standard seems to be to return two tables ("order" and "data"); //CA uses a dedicated order file returning the order table directly (like in older spring) LuaTable orderTab = (LuaTable)lTable.GetValue("order"); LuaTable dataTab = (LuaTable)lTable.GetValue("data"); if (orderTab != null && dataTab != null) { //we have standard format IDictionaryEnumerator ienum = (IDictionaryEnumerator)orderTab.GetEnumerator(); while (ienum.MoveNext()) { ht.Add((String)ienum.Key, (Double)ienum.Value); } } else { //we have CA-format: dedicated order file IDictionaryEnumerator ienum = (IDictionaryEnumerator)lTable.GetEnumerator(); while (ienum.MoveNext()) { ht.Add((String)ienum.Key, (Double)ienum.Value); } } return ht; }
private static Dictionary<String, Object> luaTable2DictionaryObject(LuaTable lTable) { var ht = new Dictionary<string, Object>(); IDictionaryEnumerator ienum = (IDictionaryEnumerator)lTable.GetEnumerator(); while (ienum.MoveNext()) { ht.Add((String)ienum.Key, ienum.Value); } return ht; }