#include "data.h"
int luaMoverGet(
lua_State *L
)
{
if (lua_gettop(L) != 1) {
lua_settop(L, 0);
return 0;
}
Mover *moverPtr = (Mover *)lua_touserdata(L, 1);
lua_settop(L, 0);
lua_pushnumber(L, moverPtr->getX());
lua_pushnumber(L, moverPtr->getY());
lua_pushnumber(L, moverPtr->getExp());
lua_pushnumber(L, moverPtr->getAngle());
return 4;
}
int luaMoverSet(
lua_State *L
)
{
int num = lua_gettop(L);
if (num < 1) {
lua_settop(L, 0);
return 0;
}
Mover *moverPtr = (Mover *)lua_touserdata(L, 1);
lua_pushnumber(L, moverPtr->getX());
if (num >= 2) moverPtr->setX(lua_tonumber(L, 2));
if (num >= 3) moverPtr->setY(lua_tonumber(L, 3));
if (num >= 4) moverPtr->setExp(lua_tonumber(L, 4));
if (num >= 5) moverPtr->setAngle(lua_tonumber(L, 5));
lua_settop(L, 0);
return 0;
}
int luaMoverCalc(
lua_State *L
)
{
int num = lua_gettop(L);
float x, y;
if (num < 1) {
lua_settop(L, 0);
return 0;
}
Mover *moverPtr = (Mover *)lua_touserdata(L, 1);
if (num >= 2) x = moverPtr->calcX(lua_tonumber(L, 2));
if (num >= 3) y = moverPtr->calcY(lua_tonumber(L, 3));
lua_settop(L, 0);
if (num >= 2) lua_pushnumber(L, x);
if (num >= 3) lua_pushnumber(L, y);
return --num;
}
int luaMoverGetTimer(
lua_State *L
)
{
if (lua_gettop(L) != 1) {
lua_settop(L, 0);
return 0;
}
Mover *moverPtr = (Mover *)lua_touserdata(L, 1);
lua_settop(L, 0);
lua_pushnumber(L, moverPtr->getTimer());
return 1;
}
int luaMoverGetX(
lua_State *L
)
{
if (lua_gettop(L) != 1) {
lua_settop(L, 0);
return 0;
}
Mover *moverPtr = (Mover *)lua_touserdata(L, 1);
lua_settop(L, 0);
lua_pushnumber(L, moverPtr->getX());
return 1;
}
int luaMoverSetX(
lua_State *L
)
{
if (lua_gettop(L) != 2) {
lua_settop(L, 0);
return 0;
}
Mover *moverPtr = (Mover *)lua_touserdata(L, 1);
moverPtr->setX(lua_tonumber(L, 2));
lua_settop(L, 0);
return 0;
}
int luaMoverGetY(
lua_State *L
)
{
if (lua_gettop(L) != 1) {
lua_settop(L, 0);
return 0;
}
Mover *moverPtr = (Mover *)lua_touserdata(L, 1);
lua_settop(L, 0);
lua_pushnumber(L, moverPtr->getY());
return 1;
}
int luaMoverSetY(
lua_State *L
)
{
if (lua_gettop(L) != 2) {
lua_settop(L, 0);
return 0;
}
Mover *moverPtr = (Mover *)lua_touserdata(L, 1);
moverPtr->setY(lua_tonumber(L, 2));
lua_settop(L, 0);
return 0;
}
int luaMoverGetExp(
lua_State *L
)
{
if (lua_gettop(L) != 1) {
lua_settop(L, 0);
return 0;
}
Mover *moverPtr = (Mover *)lua_touserdata(L, 1);
lua_settop(L, 0);
lua_pushnumber(L, moverPtr->getExp());
return 1;
}
int luaMoverSetExp(
lua_State *L
)
{
if (lua_gettop(L) != 2) {
lua_settop(L, 0);
return 0;
}
Mover *moverPtr = (Mover *)lua_touserdata(L, 1);
moverPtr->setExp(lua_tonumber(L, 2));
lua_settop(L, 0);
return 0;
}
int luaMoverGetAngle(
lua_State *L
)
{
if (lua_gettop(L) != 1) {
lua_settop(L, 0);
return 0;
}
Mover *moverPtr = (Mover *)lua_touserdata(L, 1);
lua_settop(L, 0);
lua_pushnumber(L, moverPtr->getAngle());
return 1;
}
int luaMoverSetAngle(
lua_State *L
)
{
if (lua_gettop(L) != 2) {
lua_settop(L, 0);
return 0;
}
Mover *moverPtr = (Mover *)lua_touserdata(L, 1);
moverPtr->setAngle(lua_tonumber(L, 2));
lua_settop(L, 0);
return 0;
}
int luaDrawGraph(
lua_State *L
)
{
if (lua_gettop(L) != 7) {
lua_settop(L, 0);
return 0;
}
Data *dataPtr = (Data *)lua_touserdata(L, 1);
MapGraph *mapGraphPtr = &dataPtr->mapGraph;
int x = lua_tonumber(L, 2);
int y = lua_tonumber(L, 3);
float exp = lua_tonumber(L, 4);
float angle = lua_tonumber(L, 5);
string key = lua_tostring(L, 6);
int no = lua_tonumber(L, 7);
int stat = DrawRotaGraph(x, y, exp, angle,
mapGraphPtr->getKeyHandle(key.c_str(), no), TRUE);
lua_settop(L, 0);
lua_pushnumber(L, stat);
return 1;
}
int luaPadIsPressA(
lua_State *L
)
{
if (lua_gettop(L) != 1) {
lua_settop(L, 0);
return 0;
}
Data *dataPtr = (Data *)lua_touserdata(L, 1);
lua_settop(L, 0);
lua_pushboolean(L, dataPtr->pad.isPressA());
return 1;
}
int luaPadIsPushA(
lua_State *L
)
{
if (lua_gettop(L) != 1) {
lua_settop(L, 0);
return 0;
}
Data *dataPtr = (Data *)lua_touserdata(L, 1);
lua_settop(L, 0);
lua_pushboolean(L, dataPtr->pad.isPushA());
return 1;
}
int luaPadIsPressB(
lua_State *L
)
{
if (lua_gettop(L) != 1) {
lua_settop(L, 0);
return 0;
}
Data *dataPtr = (Data *)lua_touserdata(L, 1);
lua_settop(L, 0);
lua_pushboolean(L, dataPtr->pad.isPressB());
return 1;
}
int luaPadIsPushB(
lua_State *L
)
{
if (lua_gettop(L) != 1) {
lua_settop(L, 0);
return 0;
}
Data *dataPtr = (Data *)lua_touserdata(L, 1);
lua_settop(L, 0);
lua_pushboolean(L, dataPtr->pad.isPushB());
return 1;
}
int luaPadIsPressUP(
lua_State *L
)
{
if (lua_gettop(L) != 1) {
lua_settop(L, 0);
return 0;
}
Data *dataPtr = (Data *)lua_touserdata(L, 1);
lua_settop(L, 0);
lua_pushboolean(L, dataPtr->pad.isPressUP());
return 1;
}
int luaPadIsPushUP(
lua_State *L
)
{
if (lua_gettop(L) != 1) {
lua_settop(L, 0);
return 0;
}
Data *dataPtr = (Data *)lua_touserdata(L, 1);
lua_settop(L, 0);
lua_pushboolean(L, dataPtr->pad.isPushUP());
return 1;
}
int luaPadIsPressDOWN(
lua_State *L
)
{
if (lua_gettop(L) != 1) {
lua_settop(L, 0);
return 0;
}
Data *dataPtr = (Data *)lua_touserdata(L, 1);
lua_settop(L, 0);
lua_pushboolean(L, dataPtr->pad.isPressDOWN());
return 1;
}
int luaPadIsPushDOWN(
lua_State *L
)
{
if (lua_gettop(L) != 1) {
lua_settop(L, 0);
return 0;
}
Data *dataPtr = (Data *)lua_touserdata(L, 1);
lua_settop(L, 0);
lua_pushboolean(L, dataPtr->pad.isPushDOWN());
return 1;
}
int luaPadIsPressLEFT(
lua_State *L
)
{
if (lua_gettop(L) != 1) {
lua_settop(L, 0);
return 0;
}
Data *dataPtr = (Data *)lua_touserdata(L, 1);
lua_settop(L, 0);
lua_pushboolean(L, dataPtr->pad.isPressLEFT());
return 1;
}
int luaPadIsPushLEFT(
lua_State *L
)
{
if (lua_gettop(L) != 1) {
lua_settop(L, 0);
return 0;
}
Data *dataPtr = (Data *)lua_touserdata(L, 1);
lua_settop(L, 0);
lua_pushboolean(L, dataPtr->pad.isPushLEFT());
return 1;
}
int luaPadIsPressRIGHT(
lua_State *L
)
{
if (lua_gettop(L) != 1) {
lua_settop(L, 0);
return 0;
}
Data *dataPtr = (Data *)lua_touserdata(L, 1);
lua_settop(L, 0);
lua_pushboolean(L, dataPtr->pad.isPressRIGHT());
return 1;
}
int luaPadIsPushRIGHT(
lua_State *L
)
{
if (lua_gettop(L) != 1) {
lua_settop(L, 0);
return 0;
}
Data *dataPtr = (Data *)lua_touserdata(L, 1);
lua_settop(L, 0);
lua_pushboolean(L, dataPtr->pad.isPushRIGHT());
return 1;
}