public static DynValue sub(ScriptExecutionContext executionContext, CallbackArguments args) { var arg_s = args.AsType(0, "sub", DataType.String); var arg_i = args.AsType(1, "sub", DataType.Number, true); var arg_j = args.AsType(2, "sub", DataType.Number, true); var range = StringRange.FromLuaRange(arg_i, arg_j, -1); string s = range.ApplyToString(arg_s.String); return(DynValue.NewString(s)); }
private static DynValue PerformByteLike(DynValue vs, DynValue vi, DynValue vj, Func <int, int> filter) { var range = StringRange.FromLuaRange(vi, vj); string s = range.ApplyToString(vs.String); int length = s.Length; var rets = new DynValue[length]; for (int i = 0; i < length; ++i) { rets[i] = DynValue.NewNumber(filter(s[i])); } return(DynValue.NewTuple(rets)); }