aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/purkle/purkle.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-16 19:01:32 +1000
committerDavid Walter Seikel2014-05-16 19:01:32 +1000
commitc58c32068aa8b071e5fefc472a49e13a705cd34d (patch)
treed46d7a693b0bd82ea030ab22593900826c25b2e5 /src/purkle/purkle.c
parentOnly open one purkle window. (diff)
downloadSledjHamr-c58c32068aa8b071e5fefc472a49e13a705cd34d.zip
SledjHamr-c58c32068aa8b071e5fefc472a49e13a705cd34d.tar.gz
SledjHamr-c58c32068aa8b071e5fefc472a49e13a705cd34d.tar.bz2
SledjHamr-c58c32068aa8b071e5fefc472a49e13a705cd34d.tar.xz
Add the purkle say() command.
Diffstat (limited to 'src/purkle/purkle.c')
-rw-r--r--src/purkle/purkle.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/purkle/purkle.c b/src/purkle/purkle.c
index 3ad776b..01053fe 100644
--- a/src/purkle/purkle.c
+++ b/src/purkle/purkle.c
@@ -8,6 +8,7 @@ static const char *ourName = "purkle";
8static int skang, _M; 8static int skang, _M;
9static Widget *entry, *history; 9static Widget *entry, *history;
10static winFang *me; 10static winFang *me;
11static Ecore_Con_Server *server;
11 12
12static winFang *purkleAdd(winFang *parent, int w, int h, EPhysics_World *world) 13static winFang *purkleAdd(winFang *parent, int w, int h, EPhysics_World *world)
13{ 14{
@@ -50,6 +51,23 @@ static int append(lua_State *L)
50 return 0; 51 return 0;
51} 52}
52 53
54static int say(lua_State *L)
55{
56 char *name = "", *id = NULL, *text = NULL, buf[PATH_MAX];
57 int channel;
58
59printf("PURKLE.SAY .....\n");
60 // TODO - Should include origin and distance?
61 pull_lua(L, 1, "%channel $name $id $text", &channel, &name, &id, &text);
62 if (id && text)
63 {
64 snprintf(buf, sizeof(buf), "events.listen(%d, %s, %s, %s)", channel, name, id, text);
65printf("PURKLE.SAY -%s.%s\n", id, buf);
66 if (server) sendForth(server, id, buf);
67 }
68 return 0;
69}
70
53int luaopen_purkle(lua_State *L) 71int luaopen_purkle(lua_State *L)
54{ 72{
55 GuiLua *gl; 73 GuiLua *gl;
@@ -69,6 +87,7 @@ int luaopen_purkle(lua_State *L)
69 _M = lua_gettop(L); 87 _M = lua_gettop(L);
70 88
71 push_lua(L, "@ ( = $ $ & $ )", skang, THINGASM, _M, "append", "Append text to the history box.", append, "string", 0); 89 push_lua(L, "@ ( = $ $ & $ )", skang, THINGASM, _M, "append", "Append text to the history box.", append, "string", 0);
90 push_lua(L, "@ ( = $ $ & $ )", skang, THINGASM, _M, "say", "Send chat to a channel.", say, "number,string,string,string", 0);
72 91
73 lua_getfield(L, LUA_REGISTRYINDEX, glName); 92 lua_getfield(L, LUA_REGISTRYINDEX, glName);
74 gl = lua_touserdata(L, -1); 93 gl = lua_touserdata(L, -1);
@@ -77,6 +96,7 @@ int luaopen_purkle(lua_State *L)
77 { 96 {
78 parent = gl->parent; 97 parent = gl->parent;
79 world = gl->world; 98 world = gl->world;
99 server = gl->server;
80 } 100 }
81 101
82 if (!me) me = purkleAdd(parent, 500, 420, world); 102 if (!me) me = purkleAdd(parent, 500, 420, world);