diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/purkle/purkle.c | 20 |
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"; | |||
8 | static int skang, _M; | 8 | static int skang, _M; |
9 | static Widget *entry, *history; | 9 | static Widget *entry, *history; |
10 | static winFang *me; | 10 | static winFang *me; |
11 | static Ecore_Con_Server *server; | ||
11 | 12 | ||
12 | static winFang *purkleAdd(winFang *parent, int w, int h, EPhysics_World *world) | 13 | static 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 | ||
54 | static int say(lua_State *L) | ||
55 | { | ||
56 | char *name = "", *id = NULL, *text = NULL, buf[PATH_MAX]; | ||
57 | int channel; | ||
58 | |||
59 | printf("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); | ||
65 | printf("PURKLE.SAY -%s.%s\n", id, buf); | ||
66 | if (server) sendForth(server, id, buf); | ||
67 | } | ||
68 | return 0; | ||
69 | } | ||
70 | |||
53 | int luaopen_purkle(lua_State *L) | 71 | int 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); |