Java Code Examples for org.luaj.vm2.LuaValue#checkint()

The following examples show how to use org.luaj.vm2.LuaValue#checkint() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utilities.java    From Lukkit with MIT License 6 votes vote down vote up
/**
 * Gets the Java object from a LuaValue.
 *
 * @param value the LuaValue
 * @return the Java object
 */
public static Object getObjectFromLuavalue(LuaValue value) {
    if (value.istable()) {
        return convertTable(value.checktable());
    } else if (value.isint()) {
        return value.checkint();
    } else if (value.islong()) {
        return value.checklong();
    } else if (value.isnumber()) {
        return value.checkdouble();
    } else if (value.isstring()) {
        return value.checkjstring();
    } else if (value.isboolean()) {
        return value.checkboolean();
    } else if (value.isnil()) {
        return null;
    } else {
        return value.checkuserdata();
    }
}
 
Example 2
Source File: BaseLib.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
public LuaValue call(LuaValue e, LuaValue base) {
    if (base.isnil())
        return e.tonumber();
     int b = base.checkint();
    if (b < 2 || b > 36)
        argerror(2, "base out of range");
    return e.checkstring().tonumber(b);
}
 
Example 3
Source File: LuaMappingWorld.java    From Cubes with MIT License 5 votes vote down vote up
@Override
public LuaValue call(LuaValue arg1, LuaValue arg2, LuaValue arg3) {
  int x = arg1.checkint();
  int y = arg2.checkint();
  int z = arg3.checkint();
  return LuaValue.valueOf(world.getLightRaw(x, y, z));
}
 
Example 4
Source File: BaseLib.java    From XPrivacyLua with GNU General Public License v3.0 5 votes vote down vote up
public LuaValue call(LuaValue e, LuaValue base) {
	if (base.isnil())
		return e.tonumber();
	final int b = base.checkint();
	if ( b < 2 || b > 36 )
		argerror(2, "base out of range");
	return e.checkstring().tonumber(b);
}
 
Example 5
Source File: LuaMappingWorld.java    From Cubes with MIT License 5 votes vote down vote up
@Override
public LuaValue call(LuaValue arg1, LuaValue arg2, LuaValue arg3) {
  int x = arg1.checkint();
  int y = arg2.checkint();
  int z = arg3.checkint();
  return LuaValue.valueOf(world.getSunLight(x, y, z));
}
 
Example 6
Source File: LuaMappingWorld.java    From Cubes with MIT License 5 votes vote down vote up
@Override
public LuaValue call(LuaValue arg1, LuaValue arg2, LuaValue arg3) {
  int x = arg1.checkint();
  int y = arg2.checkint();
  int z = arg3.checkint();
  return LuaValue.valueOf(world.getLight(x, y, z));
}
 
Example 7
Source File: BaseLib.java    From HtmlNative with Apache License 2.0 5 votes vote down vote up
public LuaValue call(LuaValue e, LuaValue base) {
    if (base.isnil()) {
        return e.tonumber();
    }
    final int b = base.checkint();
    if (b < 2 || b > 36) {
        argerror(2, "base out of range");
    }
    return e.checkstring().tonumber(b);
}
 
Example 8
Source File: LuaMappingWorld.java    From Cubes with MIT License 5 votes vote down vote up
@Override
public LuaValue call(LuaValue arg1, LuaValue arg2, LuaValue arg3) {
  int x = arg1.checkint();
  int y = arg2.checkint();
  int z = arg3.checkint();
  return new LuaUserdata(world.getBlock(x, y, z));
}
 
Example 9
Source File: BaseLib.java    From luaj with MIT License 5 votes vote down vote up
public LuaValue call(LuaValue e, LuaValue base) {
	if (base.isnil())
		return e.tonumber();
	final int b = base.checkint();
	if ( b < 2 || b > 36 )
		argerror(2, "base out of range");
	return e.checkstring().tonumber(b);
}
 
Example 10
Source File: MathLib.java    From luaj with MIT License 4 votes vote down vote up
public LuaValue call(LuaValue a) {
	int m = a.checkint();
	if (m<1) argerror(1, "interval is empty");
	return valueOf( 1 + random.nextInt(m) );
}
 
Example 11
Source File: LuaMappingWorld.java    From Cubes with MIT License 4 votes vote down vote up
@Override
public LuaValue call(LuaValue arg) {
  int time = arg.checkint();
  world.setTime(time);
  return NIL;
}
 
Example 12
Source File: MathLib.java    From luaj with MIT License 4 votes vote down vote up
public LuaValue call(LuaValue a, LuaValue b) {
	int m = a.checkint();
	int n = b.checkint();
	if (n<m) argerror(2, "interval is empty");
	return valueOf( m + random.nextInt(n+1-m) );
}
 
Example 13
Source File: MathLib.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public LuaValue call(LuaValue a) {
	int m = a.checkint();
	if (m<1) argerror(1, "interval is empty");
	return valueOf( 1 + random.nextInt(m) );
}
 
Example 14
Source File: MathLib.java    From HtmlNative with Apache License 2.0 4 votes vote down vote up
public LuaValue call(LuaValue a, LuaValue b) {
	int m = a.checkint();
	int n = b.checkint();
	if (n<m) argerror(2, "interval is empty");
	return valueOf( m + random.nextInt(n+1-m) );
}
 
Example 15
Source File: MathLib.java    From HtmlNative with Apache License 2.0 4 votes vote down vote up
public LuaValue call(LuaValue a) {
	int m = a.checkint();
	if (m<1) argerror(1, "interval is empty");
	return valueOf( 1 + random.nextInt(m) );
}
 
Example 16
Source File: MathLib.java    From XPrivacyLua with GNU General Public License v3.0 4 votes vote down vote up
public LuaValue call(LuaValue a, LuaValue b) {
	int m = a.checkint();
	int n = b.checkint();
	if (n<m) argerror(2, "interval is empty");
	return valueOf( m + random.nextInt(n+1-m) );
}
 
Example 17
Source File: MathLib.java    From XPrivacyLua with GNU General Public License v3.0 4 votes vote down vote up
public LuaValue call(LuaValue a) {
	int m = a.checkint();
	if (m<1) argerror(1, "interval is empty");
	return valueOf( 1 + random.nextInt(m) );
}
 
Example 18
Source File: MathLib.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public LuaValue call(LuaValue a, LuaValue b) {
	int m = a.checkint();
	int n = b.checkint();
	if (n<m) argerror(2, "interval is empty");
	return valueOf( m + random.nextInt(n+1-m) );
}