/** Return argument i as a LuaNumber, or throw an error if not a number or string that can be converted to a number. * @param i the index of the argument to test, 1 is the first argument * @return LuaNumber if argument i is number or can be converted to a number * @exception LuaError if the argument is not a number * */ public LuaNumber checknumber(int i) { return arg(i).checknumber(); }
/** Return argument i as a LuaNumber, or throw an error if not a number or string that can be converted to a number. * @param i the index of the argument to test, 1 is the first argument * @return LuaNumber if argument i is number or can be converted to a number * @exception LuaError if the argument is not a number * */ public LuaNumber checknumber(int i) { return arg(i).checknumber(); }
/** Return argument i as a LuaNumber, or throw an error if not a number or string that can be converted to a number. * @param i the index of the argument to test, 1 is the first argument * @return LuaNumber if argument i is number or can be converted to a number * @exception LuaError if the argument is not a number * */ public LuaNumber checknumber(int i) { return arg(i).checknumber(); }
/** Return argument i as a double, or throw an error if it cannot be converted to one. * @param i the index of the argument to test, 1 is the first argument * @return java double value if argument i is a number or string that converts to a number * @exception LuaError if the argument is not a number * */ public double checkdouble(int i) { return arg(i).checknumber().todouble(); }
/** Return argument i as a java int value, discarding any fractional part, or throw an error if not a number. * @param i the index of the argument to test, 1 is the first argument * @return int value with fraction discarded and truncated if necessary if argument i is number * @exception LuaError if the argument is not a number * */ public int checkint(int i) { return arg(i).checknumber().toint(); }
/** Return argument i as a java int value, discarding any fractional part, or throw an error if not a number. * @param i the index of the argument to test, 1 is the first argument * @return int value with fraction discarded and truncated if necessary if argument i is number * @exception LuaError if the argument is not a number * */ public int checkint(int i) { return arg(i).checknumber().toint(); }
/** Return argument i as a double, or throw an error if it cannot be converted to one. * @param i the index of the argument to test, 1 is the first argument * @return java double value if argument i is a number or string that converts to a number * @exception LuaError if the argument is not a number * */ public double checkdouble(int i) { return arg(i).checknumber().todouble(); }
/** Return argument i as a java long value, discarding any fractional part, or throw an error if not a number. * @param i the index of the argument to test, 1 is the first argument * @return long value with fraction discarded and truncated if necessary if argument i is number * @exception LuaError if the argument is not a number * */ public long checklong(int i) { return arg(i).checknumber().tolong(); }
/** Return argument i as a java long value, discarding any fractional part, or throw an error if not a number. * @param i the index of the argument to test, 1 is the first argument * @return long value with fraction discarded and truncated if necessary if argument i is number * @exception LuaError if the argument is not a number * */ public long checklong(int i) { return arg(i).checknumber().tolong(); }
/** Return argument i as a java int value, discarding any fractional part, or throw an error if not a number. * @param i the index of the argument to test, 1 is the first argument * @return int value with fraction discarded and truncated if necessary if argument i is number * @exception LuaError if the argument is not a number * */ public int checkint(int i) { return arg(i).checknumber().toint(); }
@Override public LuaValue call(LuaValue value) { item.setDurability(value.checknumber().toshort()); return NIL; } });
/** Return argument i as a double, or throw an error if it cannot be converted to one. * @param i the index of the argument to test, 1 is the first argument * @return java double value if argument i is a number or string that converts to a number * @exception LuaError if the argument is not a number * */ public double checkdouble(int i) { return arg(i).checknumber().todouble(); }
/** Return argument i as a java long value, discarding any fractional part, or throw an error if not a number. * @param i the index of the argument to test, 1 is the first argument * @return long value with fraction discarded and truncated if necessary if argument i is number * @exception LuaError if the argument is not a number * */ public long checklong(int i) { return arg(i).checknumber().tolong(); }
private String replace(String msg, LuaTable params) { for (int i=1; i<params.length()+1; i++) { LuaValue param = params.get(i); String actualParam; if (param.istable()) { if (!param.get("raw").isnil()) { actualParam = param.get("raw").checkjstring(); } else if (!param.get("num").isnil()) { if (param.get("num").isnumber()) { LuaNumber number = param.get("num").checknumber(); NumberFormat nf = NumberFormat.getInstance(Locale.forLanguageTag(lang)); actualParam = nf.format(number.todouble()); } else { actualParam = param.get("num").tojstring(); } } else { actualParam = "unknown"; } } else { actualParam = param.checkjstring(); } msg = msg.replace("$"+i, actualParam); } return msg; } }
LuaValue init = stack[a].checknumber("'for' initial value must be a number"); LuaValue limit = stack[a + 1].checknumber("'for' limit must be a number"); LuaValue step = stack[a + 2].checknumber("'for' step must be a number"); stack[a] = init.sub(step); stack[a + 1] = limit;
LuaValue init = stack[a].checknumber("'for' initial value must be a number"); LuaValue limit = stack[a + 1].checknumber("'for' limit must be a number"); LuaValue step = stack[a + 2].checknumber("'for' step must be a number"); stack[a] = init.sub(step); stack[a + 1] = limit;
LuaValue init = stack[a].checknumber("'for' initial value must be a number"); LuaValue limit = stack[a + 1].checknumber("'for' limit must be a number"); LuaValue step = stack[a + 2].checknumber("'for' step must be a number"); stack[a] = init.sub(step); stack[a + 1] = limit;