本文整理匯總了Java中org.luaj.vm2.LuaValue.isnumber方法的典型用法代碼示例。如果您正苦於以下問題:Java LuaValue.isnumber方法的具體用法?Java LuaValue.isnumber怎麽用?Java LuaValue.isnumber使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.luaj.vm2.LuaValue
的用法示例。
在下文中一共展示了LuaValue.isnumber方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@Override
public final LuaValue call(LuaValue arg1) {
if (!arg1.isnumber()) {
return LuaValue.FALSE;
}
// Only sleep if the specified milliseconds to sleep is greater than 0
int ms;
if ((ms = arg1.toint()) > 0 && ClientAPIUtils.sleep(ms)) {
return LuaValue.TRUE;
}
return LuaValue.FALSE;
}
示例2: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@Override
public final LuaValue call(LuaValue text, LuaValue x, LuaValue y, LuaValue color) {
if (!text.isstring() || !x.isnumber() || !y.isnumber() || !color.isnumber())
return NIL;
return LuaInteger.valueOf(mc.fontRenderer.drawString(text.tojstring(), x.tofloat(), y.tofloat(), color.toint(), false));
}
示例3: dpiToPx
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
* convert a value to px,返回給Android係統的必須是整數
*
* @param value
* @return
*/
public static int dpiToPx(LuaValue value) {
if (value != null && value.isnumber()) {
return (int) (value.optdouble(0.0f) * Constants.sScale + 0.5f);//向上取整數
}
return 0;
}
示例4: fromType
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public static Object fromType(LuaValue luaValue) {
if (luaValue.isboolean()) {
return coerce(luaValue, Boolean.class);
}
if (luaValue.isint()) {
return coerce(luaValue, Integer.class);
}
if (luaValue.isnumber()) {
return coerce(luaValue, Double.class);
}
if (luaValue.isstring()) {
return LuaLogger.colorString(luaValue.tojstring());
}
return null;
}
示例5: invoke
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public Varargs invoke(Varargs args) {
int a = 1;
LuaThread thread = args.isthread(a) ? args.checkthread(a++) : globals.running;
LuaValue func = args.arg(a++);
String what = args.optjstring(a++, "flnStu");
DebugLib.CallStack callstack = callstack(thread);
// find the stack info
DebugLib.CallFrame frame;
if (func.isnumber()) {
frame = callstack.getCallFrame(func.toint());
if (frame == null)
return NONE;
func = frame.f;
} else if (func.isfunction()) {
frame = callstack.findCallFrame(func);
} else {
return argerror(a - 2, "function or level");
}
// start a table
DebugInfo ar = callstack.auxgetinfo(what, (LuaFunction) func, frame);
LuaTable info = new LuaTable();
if (what.indexOf('S') >= 0) {
info.set(WHAT, LUA);
info.set(SOURCE, valueOf(ar.source));
info.set(SHORT_SRC, valueOf(ar.short_src));
info.set(LINEDEFINED, valueOf(ar.linedefined));
info.set(LASTLINEDEFINED, valueOf(ar.lastlinedefined));
}
if (what.indexOf('l') >= 0) {
info.set(CURRENTLINE, valueOf(ar.currentline));
}
if (what.indexOf('u') >= 0) {
info.set(NUPS, valueOf(ar.nups));
info.set(NPARAMS, valueOf(ar.nparams));
info.set(ISVARARG, ar.isvararg ? ONE : ZERO);
}
if (what.indexOf('n') >= 0) {
info.set(NAME, LuaValue.valueOf(ar.name != null ? ar.name : "?"));
info.set(NAMEWHAT, LuaValue.valueOf(ar.namewhat));
}
if (what.indexOf('t') >= 0) {
info.set(ISTAILCALL, ZERO);
}
if (what.indexOf('L') >= 0) {
LuaTable lines = new LuaTable();
info.set(ACTIVELINES, lines);
DebugLib.CallFrame cf;
for (int l = 1; (cf = callstack.getCallFrame(l)) != null; ++l)
if (cf.f == func)
lines.insert(-1, valueOf(cf.currentline()));
}
if (what.indexOf('f') >= 0) {
if (func != null)
info.set(FUNC, func);
}
return info;
}
示例6: invoke
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public Varargs invoke(Varargs args) {
int a=1;
LuaThread thread = args.isthread(a)? args.checkthread(a++): globals.running;
LuaValue func = args.arg(a++);
String what = args.optjstring(a++, "flnStu");
DebugLib.CallStack callstack = callstack(thread);
// find the stack info
DebugLib.CallFrame frame;
if ( func.isnumber() ) {
frame = callstack.getCallFrame(func.toint());
if (frame == null)
return NONE;
func = frame.f;
} else if ( func.isfunction() ) {
frame = callstack.findCallFrame(func);
} else {
return argerror(a-2, "function or level");
}
// start a table
DebugInfo ar = callstack.auxgetinfo(what, (LuaFunction) func, frame);
LuaTable info = new LuaTable();
if (what.indexOf('S') >= 0) {
info.set(WHAT, LUA);
info.set(SOURCE, valueOf(ar.source));
info.set(SHORT_SRC, valueOf(ar.short_src));
info.set(LINEDEFINED, valueOf(ar.linedefined));
info.set(LASTLINEDEFINED, valueOf(ar.lastlinedefined));
}
if (what.indexOf('l') >= 0) {
info.set( CURRENTLINE, valueOf(ar.currentline) );
}
if (what.indexOf('u') >= 0) {
info.set(NUPS, valueOf(ar.nups));
info.set(NPARAMS, valueOf(ar.nparams));
info.set(ISVARARG, ar.isvararg? ONE: ZERO);
}
if (what.indexOf('n') >= 0) {
info.set(NAME, LuaValue.valueOf(ar.name!=null? ar.name: "?"));
info.set(NAMEWHAT, LuaValue.valueOf(ar.namewhat));
}
if (what.indexOf('t') >= 0) {
info.set(ISTAILCALL, ZERO);
}
if (what.indexOf('L') >= 0) {
LuaTable lines = new LuaTable();
info.set(ACTIVELINES, lines);
DebugLib.CallFrame cf;
for (int l = 1; (cf=callstack.getCallFrame(l)) != null; ++l)
if (cf.f == func)
lines.insert(-1, valueOf(cf.currentline()));
}
if (what.indexOf('f') >= 0) {
if (func != null)
info.set( FUNC, func );
}
return info;
}