int pushvalue(ref var v, object arg) { if (arg == null) { v.type = (int)var_type.NIL; } else { Type t = arg.GetType(); if (t == typeof(int)) { v.type = var_type.INTEGER; v.d = (int)arg; } else if (t == typeof(long)) { v.type = var_type.INTEGER; v.d64 = (long)arg; } else if (t == typeof(float)) { v.type = var_type.REAL; v.f = (float)arg; } else if (t == typeof(double)) { v.type = var_type.REAL; v.f = (double)arg; } else if (t == typeof(bool)) { v.type = var_type.BOOLEAN; v.d = (bool)arg ? 1 : 0; } else if (t == typeof(string)) { v.type = var_type.STRING; return(2); // string } else if (t == typeof(LuaObject)) { v.type = var_type.LUAOBJ; v.d = ((LuaObject)arg).id; } else if (t.IsClass) { v.type = var_type.SHAPEOBJ; v.d = objects.Query(arg); } else { return(0); // error } } return(1); }