summaryrefslogtreecommitdiff
path: root/src/luascript.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2012-12-23 14:51:13 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2012-12-23 14:51:13 +0100
commitf4b015398462fff1a64d70b632390b4f06fe3bbe (patch)
treead6c57cfd5eded61ef31e379a8c94b309a298c44 /src/luascript.cc
parentdcecacbf52121d6f8adf076d2cebaeec1e141339 (diff)
LoadPen, setSpeed, setScale and a bunch of cleanups...
Diffstat (limited to 'src/luascript.cc')
-rw-r--r--src/luascript.cc127
1 files changed, 127 insertions, 0 deletions
diff --git a/src/luascript.cc b/src/luascript.cc
index fb6a7db..df607de 100644
--- a/src/luascript.cc
+++ b/src/luascript.cc
@@ -82,6 +82,129 @@ static int _forward(lua_State *L)
return 0;
}
+static int _loadpen(lua_State *L)
+{/*
+ Pracro::checkParameters(L,
+ Pracro::T_STRING,
+ Pracro::T_END);
+ */
+ const char *pen = lua_tostring(L, lua_gettop(L));
+
+ printf("load pen %s\n", pen);
+
+ lua_getglobal(L, GLOBAL_POINTER);
+ LUAScript *lua = (LUAScript*)lua_touserdata(L, lua_gettop(L));
+
+ if(!lua) {
+ lua_pushstring(L, "No LUA pointer!");
+ lua_error(L);
+ return 1;
+ }
+
+ if(lua->lua_stop) {
+ printf("stopping...\n");
+ lua_pushstring(L, "stop");
+ lua_error(L);
+ }
+
+ lua->out->loadPen(pen);
+
+ return 0;
+}
+
+static int _speed(lua_State *L)
+{/*
+ Pracro::checkParameters(L,
+ Pracro::T_STRING,
+ Pracro::T_END);
+ */
+ int x = lua_tonumber(L, lua_gettop(L));
+
+ printf("speed %d\n", x);
+
+ lua_getglobal(L, GLOBAL_POINTER);
+ LUAScript *lua = (LUAScript*)lua_touserdata(L, lua_gettop(L));
+
+ if(!lua) {
+ lua_pushstring(L, "No LUA pointer!");
+ lua_error(L);
+ return 1;
+ }
+
+ if(lua->lua_stop) {
+ printf("stopping...\n");
+ lua_pushstring(L, "stop");
+ lua_error(L);
+ }
+
+ lua->out->setSpeed(x);
+
+ return 0;
+}
+
+static int _scale(lua_State *L)
+{/*
+ Pracro::checkParameters(L,
+ Pracro::T_STRING,
+ Pracro::T_END);
+ */
+ double x = lua_tonumber(L, lua_gettop(L));
+
+ printf("scale %f\n", x);
+
+ lua_getglobal(L, GLOBAL_POINTER);
+ LUAScript *lua = (LUAScript*)lua_touserdata(L, lua_gettop(L));
+
+ if(!lua) {
+ lua_pushstring(L, "No LUA pointer!");
+ lua_error(L);
+ return 1;
+ }
+
+ if(lua->lua_stop) {
+ printf("stopping...\n");
+ lua_pushstring(L, "stop");
+ lua_error(L);
+ }
+
+ lua->out->setScale(x);
+
+ return 0;
+}
+
+static int _colour(lua_State *L)
+{/*
+ Pracro::checkParameters(L,
+ Pracro::T_STRING,
+ Pracro::T_END);
+ */
+ int r = luaL_checknumber(L, 1);
+ int g = luaL_checknumber(L, 2);
+ int b = luaL_checknumber(L, 3);
+ int a = luaL_checknumber(L, 4);
+
+ printf("colour %d %d %d %d\n", r,b,g,a);
+
+ lua_getglobal(L, GLOBAL_POINTER);
+ LUAScript *lua = (LUAScript*)lua_touserdata(L, lua_gettop(L));
+
+ if(!lua) {
+ lua_pushstring(L, "No LUA pointer!");
+ lua_error(L);
+ return 1;
+ }
+
+ if(lua->lua_stop) {
+ printf("stopping...\n");
+ lua_pushstring(L, "stop");
+ lua_error(L);
+ }
+
+ lua->out->setColour(r,g,b,a);
+
+ return 0;
+}
+
static int _turn(lua_State *L)
{/*
Pracro::checkParameters(L,
@@ -177,7 +300,11 @@ void LUAScript::init()
lua_register(L, "debug", _debug);
lua_register(L, "fremad", _forward);
lua_register(L, "drej", _turn);
+ lua_register(L, "speed", _speed);
+ lua_register(L, "scale", _scale);
lua_register(L, "reset", _reset);
+ lua_register(L, "colour", _colour);
+ lua_register(L, "loadpen", _loadpen);
}
void LUAScript::cleanup()