aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/LSLGuiMess.lua
blob: ff7538eebef99b57da487fffdf9f4f0922b97925 (plain)
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
--[[  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')
  local 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
]]
llDialog = function (id, message, buttons, channel)
  local win = skang.window(200, 25 + 25 * #buttons, message, 'llDialogWindow')

print('llDialog(' .. id .. ', ' .. message .. ', , ' .. channel .. ')')
skang.printTableStart(buttons, '', 'buttons')

  for i, v in ipairs(buttons) do
    skang.thingasm{win, 'button' .. i, 'Selects button ' .. i, types = 'widget', widget='"button", "' .. v .. '", 10, ' .. (25 * i) ..  ', 60, 25'}
    win.W['button' .. i].action = 'purkle.say(' .. channel .. ', "onefang Rejected", "' .. id .. '", "' .. v .. '")'
  end

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