本文整理汇总了C#中LuaInterface.LuaTable类的典型用法代码示例。如果您正苦于以下问题:C# LuaTable类的具体用法?C# LuaTable怎么用?C# LuaTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LuaTable类属于LuaInterface命名空间,在下文中一共展示了LuaTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Export
public static string Export(LuaTable table, int indent)
{
StringBuilder sb = new StringBuilder();
List<DictionaryEntry> items = new List<DictionaryEntry>();
int maxlen = 0;
bool allNumber = true;
int cnt = 1;
foreach (DictionaryEntry de in table) {
items.Add(de);
int len = de.Key.ToString().Length;
if (len > maxlen) maxlen = len;
if (!(de.Key is Double) || (int)(double)de.Key != cnt) allNumber = false;
cnt++;
}
items.Sort(SortCompare);
sb.Append("{\r\n");
string ind = GetIndentString(indent + 2);
foreach (DictionaryEntry de in items) {
if (de.Value is LuaTable) sb.AppendLine();
sb.Append(ind);
FormatEntry(sb, maxlen, allNumber, indent, de);
sb.Append(",\r\n");
if (de.Value is LuaTable) sb.AppendLine();
}
ind = GetIndentString(indent);
sb.Append(ind + "}");
return sb.ToString();
}
示例2: Reload
public void Reload()
{
initialized = false;
string script = resourcePath+ScriptName+".lua";
// will throw an exception on error...
object[] res = L.DoFile (script);
LuaTable env = (LuaTable)res[0];
// Poor man's OOP! These are all called on self
//Debug.Log ("here");
if (env["Update"] != null || env["Start"] != null)
AssignMethods (env);
// the script may have an Init method,
// which expects the object as an argument
// and returns a table, otherwise we make
// a new table with a 'this' field
LuaFunction init = (LuaFunction)env["Init"];
if (init != null) {
self = (LuaTable)(init.Call(this)[0]);
} else {
L.NewTable(ScriptName);
self = (LuaTable)L[ScriptName];
self["this"] = this;
}
if (! initialized)
AssignMethods(self);
//Debug.Log ("here " + self.ToString ());
objects[gameObject] = self;
}
示例3: GetDataTableRow
/// <summary>
/// 获取数据行
/// </summary>
/// <param name="tablename">数据表名</param>
/// <param name="keys">数据表主键</param>
/// <param name="ltReturn">结果数据表</param>
/// <returns>是否获取成功</returns>
public bool GetDataTableRow(string tablename, LuaTable keys, ref LuaTable ltReturn)
{
string sql = string.Format("SELECT * FROM {0}", tablename);
DataTable tbl = Helper.GetDataTable(sql, Conn);
if (tbl.PrimaryKey.Length != keys.Keys.Count)
{
MessageBox.Show(string.Format("{0} —— 函数GetDataTableRow断言:{1}\r\n", DateTime.Now, "输入参数keys长度错误。"));
}
object[] KEYS = new object[tbl.PrimaryKey.Length];
for (int i = 0; i < KEYS.Length; i++)
{
KEYS[i] = ((LuaTable)keys)[i];
}
DataRow row = tbl.Rows.Find(KEYS);
if (row == null)
{
return false;
}
foreach (DataColumn col in tbl.Columns)
{
ltReturn[col.ColumnName] = (row[col.ColumnName] == DBNull.Value ? null : row[col.ColumnName]);
}
return true;
}
示例4: LoadAsset
public static Sprite3D LoadAsset(LuaTable el, ContentManager content)
{
var texture = content.Load<Texture2D>((string) el["assetName"]);
var pos = el["pos"] as LuaTable;
var ypr = el["yawpitchroll"] as LuaTable;
var scale = el["scale"] as LuaTable;
if (pos == null || ypr == null || scale == null)
{
throw new ContentLoadException();
}
var asset = new Sprite3D(
texture,
null,
TableToVector(pos),
Quaternion.CreateFromYawPitchRoll((float) (double) ypr[1], (float) (double) ypr[2],
(float) (double) ypr[3]),
TableToVector(scale)
);
var normalMap = el["normalMap"];
if (normalMap != null)
asset.NormalMap = content.Load<Texture2D>((string) normalMap);
return asset;
}
示例5: CreateDelegate
public static Delegate CreateDelegate(Type t, LuaFunction func, LuaTable self)
{
DelegateValue Create = null;
if (!dict.TryGetValue(t, out Create))
{
throw new LuaException(string.Format("Delegate {0} not register", LuaMisc.GetTypeName(t)));
}
if (func != null)
{
LuaState state = func.GetLuaState();
LuaDelegate target = state.GetLuaDelegate(func, self);
if (target != null)
{
return Delegate.CreateDelegate(t, target, target.method);
}
else
{
Delegate d = Create(func, self, true);
target = d.Target as LuaDelegate;
state.AddLuaDelegate(target, func, self);
return d;
}
}
return Create(func, self, true);
}
示例6: storeRectInTable
public LuaTable storeRectInTable(System.Drawing.Rectangle r, LuaTable table)
{
table["x"] = r.X;
table["y"] = r.Y;
table["width"] = r.Width;
table["height"] = r.Height;
return table;
}
示例7: SafeRelease
private void SafeRelease(ref LuaTable table)
{
if (table != null)
{
table.Dispose();
table = null;
}
}
示例8: getTableFunction
public static LuaFunction getTableFunction(LuaTable luaTable, string name)
{
object obj2 = luaTable.rawget(name);
if (obj2 is LuaFunction)
{
return (LuaFunction) obj2;
}
return null;
}
示例9: Show
public uint Show(uint oldvalue, LuaTable nums, LuaTable texts)
{
Form1 frm = new Form1(oldvalue, nums, texts);
DialogResult result = frm.ShowDialog();
if (result == DialogResult.OK)
return frm.ret;
else // cancel
return oldvalue;
}
示例10: LoadLuaTable
public void LoadLuaTable(LuaTable reqs)
{
System.Collections.IEnumerator luatb = reqs.Values.GetEnumerator();
while (luatb.MoveNext())
{
AddReqToQueue((CRequest)luatb.Current);
}
BeginQueue();
}
示例11: GetUIPrefab
public void GetUIPrefab(string assetName, Transform parent, LuaTable luaTable, LuaFunction luaCallBack)
{
if (mResManager == null) return;
string tmpAssetName = assetName;
if (GameSetting.DevelopMode)
{
tmpAssetName = "UIPrefab/" + assetName;
}
mResManager.LoadPrefab(assetName + GameSetting.ExtName, tmpAssetName, delegate(UnityEngine.Object[] objs)
{
if (objs.Length == 0) return;
GameObject prefab = objs[0] as GameObject;
if (prefab == null)
{
return;
}
GameObject go = UnityEngine.GameObject.Instantiate(prefab) as GameObject;
go.name = assetName;
go.layer = LayerMask.NameToLayer("UI");
Vector3 anchorPos = Vector3.zero;
Vector2 sizeDel = Vector2.zero;
Vector3 scale = Vector3.one;
RectTransform rtTr = go.GetComponent<RectTransform>();
if (rtTr != null)
{
anchorPos = rtTr.anchoredPosition;
sizeDel = rtTr.sizeDelta;
scale = rtTr.localScale;
}
go.transform.SetParent(parent, false);
if (rtTr != null)
{
rtTr.anchoredPosition = anchorPos;
rtTr.sizeDelta = sizeDel;
rtTr.localScale = scale;
}
LuaBehaviour tmpBehaviour = go.AddComponent<LuaBehaviour>();
tmpBehaviour.Init(luaTable);
if (luaCallBack != null)
{
luaCallBack.BeginPCall();
luaCallBack.Push(go);
luaCallBack.PCall();
luaCallBack.EndPCall();
}
Debug.Log("CreatePanel::>> " + assetName + " " + prefab);
//mUIList.Add(go);
});
}
示例12: LuaCSBridgeByteBuffer
protected LuaTable m_luaTable; // LuaTable
public LuaCSBridgeByteBuffer() :
base ("NetMsgData")
//base("ByteBuffer")
{
string path = "LuaScript/DataStruct/NetMsgData.lua";
Ctx.m_instance.m_luaScriptMgr.DoFile(path);
m_luaTable = Ctx.m_instance.m_luaScriptMgr.GetLuaTable(m_tableName);
// 设置系统字节序
setSysEndian((int)SystemEndian.m_sEndian);
}
示例13: LuaEvent
//LuaFunction _call = null;
public LuaEvent(LuaTable table)
{
self = table;
luaState = table.GetLuaState();
self.AddRef();
_add = self.RawGetLuaFunction("Add");
_remove = self.RawGetLuaFunction("Remove");
//_call = self.RawGetLuaFunction("__call");
}
示例14: ValidateAndStore
protected override void ValidateAndStore(LuaTable data)
{
try
{
gravity = (float) (double) data["gravity"];
}
catch
{
throw new ArgumentException("Invalid unit description.");
}
}
示例15: CreateDelegate
public static Delegate CreateDelegate(Type t, LuaFunction func, LuaTable self)
{
DelegateValue create = null;
if (!dict.TryGetValue(t, out create))
{
throw new LuaException(string.Format("Delegate {0} not register", LuaMisc.GetTypeName(t)));
}
return create(func, self, true);
}