diff options
-rw-r--r-- | lib/LSLGuiMess.lua | 39 | ||||
-rw-r--r-- | src/extantz/extantz.c | 20 |
2 files changed, 45 insertions, 14 deletions
diff --git a/lib/LSLGuiMess.lua b/lib/LSLGuiMess.lua index bc781ce..ff7538e 100644 --- a/lib/LSLGuiMess.lua +++ b/lib/LSLGuiMess.lua | |||
@@ -6,11 +6,10 @@ do | |||
6 | local skang = require 'skang' | 6 | local skang = require 'skang' |
7 | -- This module has no default skin, it creates windows as needed. | 7 | -- This module has no default skin, it creates windows as needed. |
8 | local _M = skang.moduleBegin('LSLGuiMess', nil, 'Copyright 2014 David Seikel', '0.1', '2014-05-16 11:07:00') | 8 | local _M = skang.moduleBegin('LSLGuiMess', nil, 'Copyright 2014 David Seikel', '0.1', '2014-05-16 11:07:00') |
9 | local purkle = require 'purkle' | ||
9 | 10 | ||
10 | --[[ TODO - | ||
11 | 11 | ||
12 | llDialog(key id, string message, list buttons, integer chat_channel) | 12 | --[[ TODO - |
13 | http://lslwiki.net/lslwiki/wakka.php?wakka=llDialog | ||
14 | 13 | ||
15 | llTextBox() | 14 | llTextBox() |
16 | http://wiki.secondlife.com/wiki/LlTextBox | 15 | http://wiki.secondlife.com/wiki/LlTextBox |
@@ -26,6 +25,38 @@ llSetTouchText(string text) | |||
26 | 25 | ||
27 | ]] | 26 | ]] |
28 | 27 | ||
29 | skang.moduleEnd(_M) | 28 | |
29 | |||
30 | --[[ llDialog(key id, string message, list buttons, integer chat_channel) | ||
31 | http://lslwiki.net/lslwiki/wakka.php?wakka=llDialog | ||
32 | ]] | ||
33 | llDialog = function (id, message, buttons, channel) | ||
34 | local win = skang.window(200, 25 + 25 * #buttons, message, 'llDialogWindow') | ||
35 | |||
36 | print('llDialog(' .. id .. ', ' .. message .. ', , ' .. channel .. ')') | ||
37 | skang.printTableStart(buttons, '', 'buttons') | ||
38 | |||
39 | for i, v in ipairs(buttons) do | ||
40 | skang.thingasm{win, 'button' .. i, 'Selects button ' .. i, types = 'widget', widget='"button", "' .. v .. '", 10, ' .. (25 * i) .. ', 60, 25'} | ||
41 | win.W['button' .. i].action = 'purkle.say(' .. channel .. ', "onefang Rejected", "' .. id .. '", "' .. v .. '")' | ||
42 | end | ||
43 | |||
30 | end | 44 | end |
31 | 45 | ||
46 | |||
47 | local doLua = function (command) | ||
48 | -- Yes I know, it hurt my brain just writing this. lol | ||
49 | -- It just swaps square brackets for curly ones, coz LSL uses [] to surround lists, and Lua uses {} to surround tables. | ||
50 | local c, err = loadstring(string.gsub(command, '[%[%]]', {['['] = '{', [']'] = '}'})) | ||
51 | if c then | ||
52 | setfenv(c, _M) | ||
53 | c() | ||
54 | else | ||
55 | print("ERROR - " .. err) | ||
56 | end | ||
57 | |||
58 | end | ||
59 | skang.thingasm('doLua', 'Run a Lua command.', doLua, 'string') | ||
60 | |||
61 | skang.moduleEnd(_M) | ||
62 | end | ||
diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c index 5122f42..c980b3e 100644 --- a/src/extantz/extantz.c +++ b/src/extantz/extantz.c | |||
@@ -46,27 +46,27 @@ static Eina_Bool _data(void *data, int type, Ecore_Con_Event_Server_Data *ev) | |||
46 | || (0 == strncmp(command, "llSay(", 6)) | 46 | || (0 == strncmp(command, "llSay(", 6)) |
47 | || (0 == strncmp(command, "llShout(", 8))) | 47 | || (0 == strncmp(command, "llShout(", 8))) |
48 | { | 48 | { |
49 | int _M; | 49 | int _P; |
50 | char *name = "that's me"; | ||
50 | 51 | ||
51 | sprintf(buf, "%s: %s", SID, command); | ||
52 | lua_getfield(ourGlobals->purkle->L, LUA_REGISTRYINDEX, ourGlobals->purkle->name); | 52 | lua_getfield(ourGlobals->purkle->L, LUA_REGISTRYINDEX, ourGlobals->purkle->name); |
53 | _M = lua_gettop(ourGlobals->purkle->L); | 53 | _P = lua_gettop(ourGlobals->purkle->L); |
54 | push_lua(ourGlobals->purkle->L, "@ ( $ )", _M, "append", buf, 0); | 54 | |
55 | sprintf(buf, "%s: %s", SID, command); | ||
56 | push_lua(ourGlobals->purkle->L, "@ ( $ )", _P, "append", buf, 0); | ||
57 | // push_lua(ourGlobals->purkle->L, "@ ( $ %a $b $c $d )", _P, "say", _P, name, SID, buf, 0); | ||
55 | } | 58 | } |
56 | else if (0 == strncmp(command, "llDialog(", 9)) | 59 | else if (0 == strncmp(command, "llDialog(", 9)) |
57 | { | 60 | { |
58 | int _M; | 61 | int _M; |
59 | 62 | ||
60 | sprintf(buf, "%s: %s", SID, command); | ||
61 | lua_getfield(ourGlobals->purkle->L, LUA_REGISTRYINDEX, ourGlobals->purkle->name); | ||
62 | _M = lua_gettop(ourGlobals->purkle->L); | ||
63 | push_lua(ourGlobals->purkle->L, "@ ( $ )", _M, "append", buf, 0); | ||
64 | |||
65 | lua_getfield(ourGlobals->LSLGuiMess->L, LUA_REGISTRYINDEX, ourGlobals->LSLGuiMess->name); | 63 | lua_getfield(ourGlobals->LSLGuiMess->L, LUA_REGISTRYINDEX, ourGlobals->LSLGuiMess->name); |
66 | _M = lua_gettop(ourGlobals->LSLGuiMess->L); | 64 | _M = lua_gettop(ourGlobals->LSLGuiMess->L); |
67 | 65 | ||
68 | PI("Dialog from %s - %s", SID, command); | ||
69 | // TODO - Somewhere in the chain the new lines that MLP likes to put into llDialog's message munge things. Fix that. | 66 | // TODO - Somewhere in the chain the new lines that MLP likes to put into llDialog's message munge things. Fix that. |
67 | sprintf(buf, "%s: %s", SID, command); | ||
68 | push_lua(ourGlobals->LSLGuiMess->L, "@ ( $ )", _M, "doLua", command, 0); | ||
69 | |||
70 | } | 70 | } |
71 | else | 71 | else |
72 | { | 72 | { |