// Copyright (c) Pixel Crushers. All rights reserved.
#if !(USE_NLUA || OVERRIDE_LUA)
using UnityEngine;
using System.Collections.Generic;
using Language.Lua;
namespace PixelCrushers.DialogueSystem
{
///
/// This is a Lua table wrapper for LuaInterpreter. It isolates the
/// underlying LuaInterpreter implementation from the rest of the
/// Dialogue System.
///
public class LuaTableWrapper
{
///
/// The LuaInterpreter Lua table.
///
public Language.Lua.LuaTable luaTable = null;
///
/// Initializes a new instance of the class.
///
/// Lua table.
public LuaTableWrapper(LuaTable luaTable)
{
this.luaTable = luaTable;
}
///
/// Indicates whether the wrapper points to a valid Lua table.
///
/// true if this instance is valid; otherwise, false.
public bool isValid { get { return (luaTable != null); } }
///
/// Gets the number of elements in the table.
///
/// The count.
public int count
{
get
{
return (luaTable != null) ? Mathf.Max(luaTable.Length, luaTable.Count) : 0;
}
}
///
/// Gets the keys as strings.If the table is a one-dimensional
/// array, this returns the indices as strings.
///
/// The keys.
public IEnumerable keys
{
get
{
if ((luaTable != null) && (count > 0))
{
foreach (LuaValue key in luaTable.Keys)
{
yield return key.ToString();
}
}
}
}
///
/// Gets the values. If a value is a table, this returns a
/// LuaTableWrapper around it.
///
/// The values.
public IEnumerable