Example #1
0
        public (string, bool) ToStringX(int idx)
        {
            var val = stack.get(idx);

            switch (val.GetType().Name)
            {
            case "String": return(LuaValue.toString(val), true);

            case "Int64":
            case "Double":
                var s = val;
                stack.set(idx, s);
                return(Convert.ToString(s), true);

            default: return("", false);
            }
        }
Example #2
0
        public void Len(int idx)
        {
            var val = stack.get(idx);

            if (LuaValue.isString(val))
            {
                var s = LuaValue.toString(val);
                stack.push((long)s.Length);
            }
            else if (LuaValue.isLuaTable(val))
            {
                var t = LuaValue.toLuaTable(val);
                stack.push((long)t.len());
            }
            else
            {
                throw new Exception("length error!");
            }
        }