use of org.luaj.vm2.Varargs in project love-android by hagish.
the class LuanObjImage method CreateMetaTable.
public static LuaTable CreateMetaTable(final LuanGraphics g) {
LuaTable mt = LuaValue.tableOf();
LuaTable t = LuaValue.tableOf();
mt.set("__index", t);
// / min, mag = Image:getFilter( ) "linear" , "nearest"
t.set("getFilter", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.varargsOf(LuaValue.valueOf(Filter2Str(self(args).mFilterMin)), LuaValue.valueOf(Filter2Str(self(args).mFilterMag)));
}
});
// / Image:setFilter( min, mag ) "linear" , "nearest"
t.set("setFilter", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).setFilter(Str2Filter(args.checkjstring(2)), Str2Filter(args.checkjstring(3)));
return LuaValue.NONE;
}
});
// / horiz, vert = Image:getWrap( ) "repeat" , "clamp"
t.set("getWrap", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.varargsOf(LuaValue.valueOf(Wrap2Str(self(args).mWrapH)), LuaValue.valueOf(Wrap2Str(self(args).mWrapV)));
}
});
// / Image:setWrap( horiz, vert ) "repeat" , "clamp"
t.set("setWrap", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).setWrap(Str2Wrap(args.checkjstring(2)), Str2Wrap(args.checkjstring(3)));
return LuaValue.NONE;
}
});
// / w = Image:getWidth( )
t.set("getWidth", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.valueOf(self(args).mWidth);
}
});
// / h = Image:getHeight( )
t.set("getHeight", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.valueOf(self(args).mHeight);
}
});
// / type = Object:type() , e.g. "Image" or audio:"Source"
t.set("type", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.valueOf("Image");
}
});
// / b = Object:typeOf( name )
t.set("typeOf", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
String s = args.checkjstring(2);
return LuaValue.valueOf(s.equals("Object") || s.equals("Drawable") || s.equals("Image"));
}
});
return mt;
}
use of org.luaj.vm2.Varargs in project love-android by hagish.
the class LuanObjParticleSystem method CreateMetaTable.
public static LuaTable CreateMetaTable(final LuanGraphics g) {
LuaTable mt = LuaValue.tableOf();
LuaTable t = LuaValue.tableOf();
mt.set("__index", t);
// TODO: not yet implemented
t.set("setSpinVariation", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
g.vm.NotImplemented("ParticleSystem:" + "setSpinVariation");
return LuaValue.NONE;
}
});
// TODO: not yet implemented
t.set("setSizeVariation", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
g.vm.NotImplemented("ParticleSystem:" + "setSizeVariation");
return LuaValue.NONE;
}
});
// TODO: not yet implemented
t.set("setBufferSize", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
g.vm.NotImplemented("ParticleSystem:" + "setBufferSize");
return LuaValue.NONE;
}
});
// TODO: not yet implemented
t.set("setSprite", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
g.vm.NotImplemented("ParticleSystem:" + "setSprite");
return LuaValue.NONE;
}
});
// TODO: not yet implemented
t.set("count", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.valueOf(self(args).miParticlesAlive);
}
});
t.set("getDirection", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.valueOf(self(args).fDirection);
}
});
t.set("getOffsetX", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.valueOf(self(args).fOX);
}
});
t.set("getOffsetY", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.valueOf(self(args).fOY);
}
});
t.set("getSpread", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.valueOf(self(args).fSpread);
}
});
t.set("isActive", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.valueOf(self(args).bEmitterActive);
}
});
t.set("isEmpty", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.valueOf(self(args).miParticlesAlive == 0);
}
});
t.set("isFull", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.valueOf(self(args).miParticlesAlive >= self(args).iMaxParticles);
}
});
t.set("setOffset", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).fOX = (float) args.checkdouble(2);
self(args).fOY = (float) args.checkdouble(3);
return LuaValue.NONE;
}
});
t.set("setColor", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).col_start = new LuanColor(args, 2);
self(args).col_end = new LuanColor(args, 6);
return LuaValue.NONE;
}
});
t.set("setGravity", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).fGravityX = (float) args.checkdouble(2);
self(args).fGravityY = LuanBase.IsArgSet(args, 3) ? (float) args.checkdouble(3) : self(args).fGravityX;
return LuaValue.NONE;
}
});
t.set("setRotation", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).fRotationMin = (float) args.checkdouble(2);
self(args).fRotationMax = LuanBase.IsArgSet(args, 3) ? (float) args.checkdouble(3) : self(args).fRotationMin;
return LuaValue.NONE;
}
});
t.set("setSpin", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).fSpinStart = (float) args.checkdouble(2);
self(args).fSpinEnd = LuanBase.IsArgSet(args, 3) ? (float) args.checkdouble(3) : self(args).fSpinStart;
self(args).fSpinVar = LuanBase.IsArgSet(args, 4) ? (float) args.checkdouble(4) : 1f;
return LuaValue.NONE;
}
});
t.set("setRadialAcceleration", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).fRadialAccelerationMin = (float) args.checkdouble(2);
self(args).fRadialAccelerationMax = LuanBase.IsArgSet(args, 3) ? (float) args.checkdouble(3) : self(args).fRadialAccelerationMin;
return LuaValue.NONE;
}
});
t.set("setTangentialAcceleration", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).fTangentialAccelerationMin = (float) args.checkdouble(2);
self(args).fTangentialAccelerationMax = LuanBase.IsArgSet(args, 3) ? (float) args.checkdouble(3) : self(args).fTangentialAccelerationMin;
return LuaValue.NONE;
}
});
t.set("setDirection", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).fDirection = (float) args.checkdouble(2);
return LuaValue.NONE;
}
});
t.set("setSpread", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).fSpread = (float) args.checkdouble(2);
return LuaValue.NONE;
}
});
t.set("setSpeed", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).fSpeed_Min = (float) args.checkdouble(2);
self(args).fSpeed_Max = LuanBase.IsArgSet(args, 3) ? (float) args.checkdouble(3) : self(args).fSpeed_Min;
return LuaValue.NONE;
}
});
t.set("setEmissionRate", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).setEmissionRate((float) args.checkdouble(2));
return LuaValue.NONE;
}
});
t.set("setParticleLife", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
float fMin = (float) args.checkdouble(2);
float fMax = LuanBase.IsArgSet(args, 3) ? (float) args.checkdouble(3) : fMin;
self(args).setParticleLife(fMin, fMax);
return LuaValue.NONE;
}
});
t.set("setSize", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
float fStart = (float) args.checkdouble(2);
float fEnd = LuanBase.IsArgSet(args, 3) ? (float) args.checkdouble(3) : fStart;
float fVar = LuanBase.IsArgSet(args, 4) ? (float) args.checkdouble(4) : 1f;
self(args).setSize(fStart, fEnd, fVar);
return LuaValue.NONE;
}
});
t.set("setLifetime", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).setLifetime((float) args.checkdouble(2));
return LuaValue.NONE;
}
});
t.set("setPosition", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).setPosition((float) args.checkdouble(2), (float) args.checkdouble(3));
return LuaValue.NONE;
}
});
t.set("getX", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.valueOf(self(args).x_emit);
}
});
t.set("getY", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.valueOf(self(args).y_emit);
}
});
t.set("pause", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).pause();
return LuaValue.NONE;
}
});
t.set("reset", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).reset();
return LuaValue.NONE;
}
});
t.set("start", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).start();
return LuaValue.NONE;
}
});
t.set("stop", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).stop();
return LuaValue.NONE;
}
});
// / ParticleSystem:update( dt )
// / Updates the particle system; moving, creating and killing particles.
// TODO: not yet implemented
t.set("update", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).update((float) args.checkdouble(2));
return LuaValue.NONE;
}
});
// / b = Object:typeOf( name )
t.set("typeOf", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
String s = args.checkjstring(2);
return LuaValue.valueOf(s.equals("Object") || s.equals("Drawable") || s.equals("ParticleSystem"));
}
});
return mt;
}
use of org.luaj.vm2.Varargs in project love-android by hagish.
the class LuanObjQuad method CreateMetaTable.
public static LuaTable CreateMetaTable(final LuanGraphics g) {
LuaTable mt = LuaValue.tableOf();
LuaTable t = LuaValue.tableOf();
mt.set("__index", t);
// / Quad:flip( x, y ) booleans which axis should be flipped
t.set("flip", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).flip(args.checkboolean(2), args.checkboolean(3));
return LuaValue.NONE;
}
});
// / x, y, w, h = Quad:getViewport( )
// / Gets the current viewport of this Quad.
// / @x The top-left corner along the x-axis.
// / @y The top-right corner along the y-axis.
// / @w The width of the viewport.
// / @h The height of the viewport.
t.set("getViewport", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
LuanObjQuad me = self(args);
return LuaValue.varargsOf(LuaValue.valueOf(me.x), LuaValue.valueOf(me.y), LuaValue.varargsOf(LuaValue.valueOf(me.w), LuaValue.valueOf(me.h)));
}
});
// / Quad:setViewport( x, y, w, h )
// / Sets the texture coordinates according to a viewport.
// / @x The top-left corner along the x-axis.
// / @y The top-right corner along the y-axis.
// / @w The width of the viewport.
// / @h The height of the viewport.
t.set("setViewport", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
self(args).setViewport((float) args.checkdouble(2), (float) args.checkdouble(3), (float) args.checkdouble(4), (float) args.checkdouble(5));
return LuaValue.NONE;
}
});
// / type = Object:type() , e.g. "Image" or audio:"Source"
t.set("type", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.valueOf("Quad");
}
});
// / b = Object:typeOf( name )
t.set("typeOf", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
String s = args.checkjstring(2);
return LuaValue.valueOf(s.equals("Object") || s.equals("Quad"));
}
});
return mt;
}
use of org.luaj.vm2.Varargs in project love-android by hagish.
the class LoveVM method setupCoreFunctions.
// ***** ***** ***** ***** ***** lua api
private void setupCoreFunctions() {
_G.set("print", new VarArgFunction() {
@Override
public LuaValue invoke(Varargs args) {
args.narg();
StringBuffer s = new StringBuffer();
for (int i = 1; i <= args.narg(); ++i) {
if (i > 1) {
s.append(", ");
}
s.append(args.arg(i).toString());
}
LoveLog(TAG, s.toString());
return LuaValue.NONE;
}
});
_G.set("toast", new VarArgFunction() {
@Override
public LuaValue invoke(Varargs args) {
args.narg();
StringBuffer s = new StringBuffer();
for (int i = 1; i <= args.narg(); ++i) {
if (i > 1) {
s.append(", ");
}
s.append(args.arg(i).toString());
}
toast(s.toString());
return LuaValue.NONE;
}
});
}
use of org.luaj.vm2.Varargs in project LuaViewSDK by alibaba.
the class StringLib method byte_.
/**
* string.byte (s [, i [, j]])
*
* Returns the internal numerical codes of the
* characters s[i], s[i+1], ..., s[j]. The default value for i is 1; the
* default value for j is i.
*
* Note that numerical codes are not necessarily portable across platforms.
*
* @param args the calling args
*/
static Varargs byte_(Varargs args) {
LuaString s = args.checkstring(1);
int l = s.m_length;
int posi = posrelat(args.optint(2, 1), l);
int pose = posrelat(args.optint(3, posi), l);
int n, i;
if (posi <= 0)
posi = 1;
if (pose > l)
pose = l;
if (posi > pose)
return NONE;
/* empty interval; return no values */
n = (int) (pose - posi + 1);
if (posi + n <= pose)
/* overflow? */
error("string slice too long");
LuaValue[] v = new LuaValue[n];
for (i = 0; i < n; i++) v[i] = valueOf(s.luaByte(posi + i - 1));
return varargsOf(v);
}
Aggregations