use of org.luaj.vm2.Varargs in project love-android by hagish.
the class LuanAudio method InitLib.
public LuaTable InitLib() {
mSoundPool = new SoundPool(kAudioChannels, AudioManager.STREAM_MUSIC, 0);
LuaTable t = LuaValue.tableOf();
LuaValue _G = vm.get_G();
_G.set(sMetaName_LuanSource, LuanObjSource.CreateMetaTable(this));
_G.set(sMetaName_LuanDecoder, LuanObjDecoder.CreateMetaTable(this));
_G.set(sMetaName_LuanSoundData, LuanObjSoundData.CreateMetaTable(this));
// numSources = love.audio.getNumSources( )
t.set("getNumSources", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
vm.NotImplemented("love.audio.getNumSources");
return LuaValue.ZERO;
}
});
// fx, fy, fz, ux, uy, uz = love.audio.getOrientation( )
t.set("getOrientation", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return varargsOf(new LuaValue[] { LuaNumber.valueOf(orientationForward.x), LuaNumber.valueOf(orientationForward.y), LuaNumber.valueOf(orientationForward.z), LuaNumber.valueOf(orientationUp.x), LuaNumber.valueOf(orientationUp.y), LuaNumber.valueOf(orientationUp.z) });
}
});
// x, y, z = love.audio.getPosition( )
t.set("getPosition", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return varargsOf(new LuaValue[] { LuaNumber.valueOf(position.x), LuaNumber.valueOf(position.y), LuaNumber.valueOf(position.z) });
}
});
// x, y, z = love.audio.getVelocity( )
t.set("getVelocity", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return varargsOf(new LuaValue[] { LuaNumber.valueOf(velocity.x), LuaNumber.valueOf(velocity.y), LuaNumber.valueOf(velocity.z) });
}
});
// volume = love.audio.getVolume( )
t.set("getVolume", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return varargsOf(new LuaValue[] { LuaNumber.valueOf(volume) });
}
});
// source = love.audio.newSource( file, type )
t.set("newSource", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
Log("love.audio.newSource params:" + ((args.narg() >= 1) ? getLuaTypeName(args.type(1)) : "notset") + "," + ((args.narg() >= 2) ? getLuaTypeName(args.type(2)) : "notset") + "," + ((args.narg() >= 3) ? getLuaTypeName(args.type(3)) : "notset") + "...");
if (args.isstring(1)) {
Log("love.audio.newSource(string,..)");
String sFileName = args.checkjstring(1);
String sType = IsArgSet(args, 2) ? args.checkjstring(2) : "static";
return LuaValue.userdataOf(new LuanObjSource(LuanAudio.this, sFileName, sType), vm.get_G().get(sMetaName_LuanSource));
}
if (IsArgSet(args, 2) && args.isstring(2)) {
Log("love.audio.newSource(???,string,..)");
LuanObjDecoder decoder = (LuanObjDecoder) args.checkuserdata(1, LuanObjDecoder.class);
String sType = args.checkjstring(2);
return LuaValue.userdataOf(new LuanObjSource(LuanAudio.this, decoder, sType), vm.get_G().get(sMetaName_LuanSource));
}
LuanObjSoundData soundata = (LuanObjSoundData) args.checkuserdata(1, LuanObjSoundData.class);
return LuaValue.userdataOf(new LuanObjSource(LuanAudio.this, soundata), vm.get_G().get(sMetaName_LuanSource));
}
});
// love.audio.pause( )
t.set("pause", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
// TODO
vm.NotImplemented("love.audio.pause");
return LuaValue.NONE;
}
});
// / love.audio.play( source )
// /Plays the specified Source.
t.set("play", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
LuanObjSource src = (LuanObjSource) args.checkuserdata(1, LuanObjSource.class);
src.play();
return LuaValue.NONE;
}
});
// love.audio.resume( )
t.set("resume", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
// TODO
vm.NotImplemented("love.audio.resume");
return LuaValue.NONE;
}
});
// love.audio.rewind( )
t.set("rewind", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
// TODO
vm.NotImplemented("love.audio.rewind");
return LuaValue.NONE;
}
});
// love.audio.setOrientation( fx, fy, fz, ux, uy, uz )
t.set("setOrientation", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
orientationForward.x = args.arg(1).tofloat();
orientationForward.y = args.arg(2).tofloat();
orientationForward.z = args.arg(3).tofloat();
orientationUp.x = args.arg(4).tofloat();
orientationUp.y = args.arg(5).tofloat();
orientationUp.z = args.arg(6).tofloat();
notifySpatialChange();
return LuaValue.NONE;
}
});
// love.audio.setPosition( x, y, z )
t.set("setPosition", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
position.x = args.arg(1).tofloat();
position.y = args.arg(2).tofloat();
position.z = args.arg(3).tofloat();
notifySpatialChange();
return LuaValue.NONE;
}
});
// love.audio.setVelocity( x, y, z )
t.set("setVelocity", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
position.x = args.arg(1).tofloat();
position.y = args.arg(2).tofloat();
position.z = args.arg(3).tofloat();
notifySpatialChange();
return LuaValue.NONE;
}
});
// love.audio.setVolume( volume )
t.set("setVolume", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
volume = args.arg(1).tofloat();
// TODO
vm.NotImplemented("love.audio.setVolume");
return LuaValue.NONE;
}
});
// love.audio.stop( )
t.set("stop", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
// TODO
vm.NotImplemented("love.audio.stop");
return LuaValue.NONE;
}
});
return t;
}
use of org.luaj.vm2.Varargs in project love-android by hagish.
the class LuanJoystick method InitLib.
public LuaTable InitLib() {
LuaTable t = LuaValue.tableOf();
// TODO: not yet implemented
t.set("close", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
vm.NotImplemented("love.joystick." + "close");
return LuaValue.NONE;
}
});
t.set("getAxes", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
vm.NotImplemented("love.joystick." + "getAxes");
return LuaValue.varargsOf(LuaValue.ZERO, LuaValue.ZERO, LuaValue.ZERO);
}
});
t.set("getAxis", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
vm.NotImplemented("love.joystick." + "getAxis");
return LuaValue.ZERO;
}
});
t.set("getBall", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
vm.NotImplemented("love.joystick." + "getBall");
return LuaValue.varargsOf(LuaValue.ZERO, LuaValue.ZERO);
}
});
t.set("getHat", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
vm.NotImplemented("love.joystick." + "getHat");
return LuaValue.ZERO;
}
});
t.set("getName", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
vm.NotImplemented("love.joystick." + "getName");
return LuaValue.NONE;
}
});
t.set("getNumAxes", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
vm.NotImplemented("love.joystick." + "getNumAxes");
return LuaValue.ZERO;
}
});
t.set("getNumBalls", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
vm.NotImplemented("love.joystick." + "getNumBalls");
return LuaValue.ZERO;
}
});
t.set("getNumButtons", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
vm.NotImplemented("love.joystick." + "getNumButtons");
return LuaValue.ZERO;
}
});
t.set("getNumHats", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
vm.NotImplemented("love.joystick." + "getNumHats");
return LuaValue.ZERO;
}
});
t.set("getNumJoysticks", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
vm.NotImplemented("love.joystick." + "getNumJoysticks");
return LuaValue.ZERO;
}
});
t.set("isDown", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
vm.NotImplemented("love.joystick." + "isDown");
return LuaValue.NONE;
}
});
t.set("isOpen", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
vm.NotImplemented("love.joystick." + "isOpen");
return LuaValue.NONE;
}
});
t.set("open", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
vm.NotImplemented("love.joystick." + "open");
return LuaValue.NONE;
}
});
return t;
}
use of org.luaj.vm2.Varargs in project love-android by hagish.
the class LuanMouse method InitLib.
public LuaTable InitLib() {
LuaTable t = LuaValue.tableOf();
// x, y = love.mouse.getPosition( )
t.set("getPosition", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.varargsOf(LuaNumber.valueOf(mouseX_for_vm()), LuaNumber.valueOf(mouseY_for_vm()));
}
});
// x = love.mouse.getX( )
t.set("getX", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaNumber.valueOf(mouseX_for_vm());
}
});
// y = love.mouse.getY( )
t.set("getY", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaNumber.valueOf(mouseY_for_vm());
}
});
// down = love.mouse.isDown( button )
t.set("isDown", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
String button = args.arg1().toString();
if (button.equals(LEFT_BUTTON)) {
return LuaBoolean.valueOf(mouseButtonLeft);
} else if (button.equals(MIDDLE_BUTTON)) {
return LuaBoolean.valueOf(mouseButtonMiddle);
} else if (button.equals(RIGHT_BUTTON)) {
return LuaBoolean.valueOf(mouseButtonRight);
}
return LuaValue.FALSE;
}
});
// grabbed = love.mouse.isGrabbed( )
t.set("isGrabbed", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.FALSE;
}
});
// visible = love.mouse.isVisible( )
t.set("isVisible", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.FALSE;
}
});
// love.mouse.setGrab( grab )
t.set("setGrab", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.NONE;
}
});
// love.mouse.setPosition( x, y )
t.set("setPosition", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
mouseX = args.arg(1).toint();
mouseY = args.arg(2).toint();
return LuaValue.NONE;
}
});
// love.mouse.setVisible( visible )
t.set("setVisible", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.NONE;
}
});
return t;
}
use of org.luaj.vm2.Varargs in project love-android by hagish.
the class LuanPhysics method InitLib.
public LuaTable InitLib() {
LuaTable t = LuaValue.tableOf();
LuaValue _G = vm.get_G();
_G.set(sMetaName_World, LuanObjWorld.CreateMetaTable(this));
_G.set(sMetaName_Body, LuanObjBody.CreateMetaTable(this));
_G.set(sMetaName_Shape, LuanObjShape.CreateMetaTable(this));
_G.set(sMetaName_CircleShape, LuanObjCircleShape.CreateMetaTable(this));
_G.set(sMetaName_PolygonShape, LuanObjPolygonShape.CreateMetaTable(this));
_G.set(sMetaName_Contact, LuanObjContact.CreateMetaTable(this));
_G.set(sMetaName_Joint, LuanObjJoint.CreateMetaTable(this));
t.set("newWorld", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.userdataOf(new LuanObjWorld(LuanPhysics.this), vm.get_G().get(sMetaName_World));
}
});
t.set("newBody", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.userdataOf(new LuanObjBody(LuanPhysics.this), vm.get_G().get(sMetaName_Body));
}
});
t.set("newRectangleShape", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.userdataOf(new LuanObjPolygonShape(LuanPhysics.this), vm.get_G().get(sMetaName_PolygonShape));
}
});
t.set("newCircleShape", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.userdataOf(new LuanObjCircleShape(LuanPhysics.this), vm.get_G().get(sMetaName_CircleShape));
}
});
t.set("newPolygonShape", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.userdataOf(new LuanObjPolygonShape(LuanPhysics.this), vm.get_G().get(sMetaName_PolygonShape));
}
});
t.set("newDistanceJoint", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.userdataOf(new LuanObjJoint(LuanPhysics.this), vm.get_G().get(sMetaName_Joint));
}
});
t.set("newGearJoint", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.userdataOf(new LuanObjJoint(LuanPhysics.this), vm.get_G().get(sMetaName_Joint));
}
});
t.set("newMouseJoint", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.userdataOf(new LuanObjJoint(LuanPhysics.this), vm.get_G().get(sMetaName_Joint));
}
});
t.set("newPrismaticJoint", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.userdataOf(new LuanObjJoint(LuanPhysics.this), vm.get_G().get(sMetaName_Joint));
}
});
t.set("newPulleyJoint", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.userdataOf(new LuanObjJoint(LuanPhysics.this), vm.get_G().get(sMetaName_Joint));
}
});
t.set("newRevoluteJoint", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return LuaValue.userdataOf(new LuanObjJoint(LuanPhysics.this), vm.get_G().get(sMetaName_Joint));
}
});
return t;
}
use of org.luaj.vm2.Varargs in project love-android by hagish.
the class LuanThread method InitLib.
public LuaTable InitLib() {
LuaTable t = LuaValue.tableOf();
LuaValue _G = vm.get_G();
_G.set(sMetaName_LuanThread, LuanObjThreadObj.CreateMetaTable(this));
// / thread = love.thread.newThread( name, filename )
// / thread = love.thread.newThread( name, file ) -- File file : The file to use as source.
// / thread = love.thread.newThread( name, data ) -- Data data : The data to use as source.
// / Creates a new Thread from a File or Data Object.
t.set("newThread", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
String name = args.checkjstring(1);
// TODO: param2 ? can be different things
try {
return LuaValue.userdataOf(new LuanObjThreadObj(LuanThread.this, name), vm.get_G().get(sMetaName_LuanThread));
} catch (Exception e) {
vm.handleError(e);
}
return LuaValue.NONE;
}
});
// / thread = love.thread.getThread( name )
// / Look for a thread and get its object.
// / TODO: not yet implemented
t.set("getThread", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
vm.NotImplemented("love.thread.getThread");
return LuaValue.NONE;
}
});
// / threads = love.thread.getThreads( )
// / Get all threads.
// / TODO: not yet implemented
t.set("getThreads", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
vm.NotImplemented("love.thread.getThreads");
return LuaValue.NONE;
}
});
return t;
}
Aggregations