1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
--[[ LSLGuiMess - replicates the horrid and barely usable LSL user interface crap.
]]
do
local skang = require 'skang'
-- This module has no default skin, it creates windows as needed.
local _M = skang.moduleBegin('LSLGuiMess', nil, 'Copyright 2014 David Seikel', '0.1', '2014-05-16 11:07:00')
-- This has to be global so that the action below works.
purkle = require 'purkle'
--[[ TODO -
llTextBox()
http://wiki.secondlife.com/wiki/LlTextBox
llSetText(string text, vector color, float alpha)
http://lslwiki.net/lslwiki/wakka.php?wakka=llSetText
llSetSitText(string text)
http://lslwiki.net/lslwiki/wakka.php?wakka=llSetSitText
llSetTouchText(string text)
http://lslwiki.net/lslwiki/wakka.php?wakka=llSetTouchText
]]
--[[ llDialog(key id, string message, list buttons, integer chat_channel)
http://lslwiki.net/lslwiki/wakka.php?wakka=llDialog
TODO - Like the files window, just reuse a single window, hiding and showing it when needed.
The switch button shows the buttons from the next one.
]]
llDialog = function (id, message, buttons, channel)
local w = 80
local h = 20
local x = 2 + (((1 - 1) % 3) * w)
local y = h * math.floor((1 - 1) / 3)
local dialog = skang.window(4 + w * 3, h * math.ceil((#buttons + 1) / 3), message, 'llDialogWindow')
for i, v in ipairs(buttons) do
x = 2 + (((i - 1) % 3) * w)
y = h * math.floor((i - 1) / 3)
skang.thingasm{dialog, 'button' .. i, 'Selects button ' .. i, types = 'widget', widget='"button", "' .. v .. '", ' .. x .. ', ' .. y .. ', ' .. w .. ', ' .. h}
dialog.W['button' .. i].action = 'purkle.say(' .. channel .. ', "onefang Rejected", "' .. id .. '", "' .. v .. '")'
end
x = 2 + (((3 - 1) % 3) * w)
y = h * math.floor((#buttons + 1) / 3)
skang.thingasm{dialog, 'ignore', 'Ignore this dialog', types = 'widget', widget='"button", "ignore", ' .. x .. ', ' .. y .. ', ' .. w - 20 .. ', ' .. h}
skang.thingasm{dialog, 'switch', 'Switch to next dialog', types = 'widget', widget='"button", ">", ' .. (x + w - 20) .. ', ' .. y .. ', ' .. 20 .. ', ' .. h}
end
local doLua = function (command)
-- Yes I know, it hurt my brain just writing this. lol
-- It just swaps square brackets for curly ones, coz LSL uses [] to surround lists, and Lua uses {} to surround tables.
local c, err = loadstring(string.gsub(command, '[%[%]]', {['['] = '{', [']'] = '}'}))
if c then
setfenv(c, _M)
c()
else
print("ERROR - " .. err)
end
end
skang.thingasm('doLua', 'Run a Lua command.', doLua, 'string')
skang.moduleEnd(_M)
end
|