summaryrefslogtreecommitdiff
path: root/indra/newview/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/scripts')
-rw-r--r--indra/newview/scripts/lua/luafloater_demo.xml13
-rw-r--r--indra/newview/scripts/lua/test_luafloater_demo.lua24
-rw-r--r--indra/newview/scripts/lua/test_luafloater_gesture_list.lua21
-rw-r--r--indra/newview/scripts/lua/util.lua10
4 files changed, 23 insertions, 45 deletions
diff --git a/indra/newview/scripts/lua/luafloater_demo.xml b/indra/newview/scripts/lua/luafloater_demo.xml
index 069f229128..b2273d7718 100644
--- a/indra/newview/scripts/lua/luafloater_demo.xml
+++ b/indra/newview/scripts/lua/luafloater_demo.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<floater
legacy_header_height="18"
- height="150"
+ height="300"
layout="topleft"
name="lua_demo"
title="LUA"
@@ -79,4 +79,15 @@
text_color="white"
left_delta="15"
name="time_lbl"/>
+ <text_editor
+ follows="top|left"
+ font="SansSerif"
+ height="140"
+ left="5"
+ enabled="false"
+ name="events_editor"
+ top_pad="15"
+ word_wrap="true"
+ max_length="65536"
+ width="310"/>
</floater>
diff --git a/indra/newview/scripts/lua/test_luafloater_demo.lua b/indra/newview/scripts/lua/test_luafloater_demo.lua
index 4e071e4abe..c375a2abc7 100644
--- a/indra/newview/scripts/lua/test_luafloater_demo.lua
+++ b/indra/newview/scripts/lua/test_luafloater_demo.lua
@@ -1,21 +1,15 @@
XML_FILE_PATH = "luafloater_demo.xml"
leap = require 'leap'
-coro = require 'coro'
-util = require 'util'
+fiber = require 'fiber'
--event pump for sending actions to the floater
COMMAND_PUMP_NAME = ""
--table of floater UI events
-event_list={}
-coro.launch(function ()
- event_list = leap.request("LLFloaterReg", {op="getFloaterEvents"})["events"]
- leap.done()
-end)
-leap.process()
+event_list=leap.request("LLFloaterReg", {op="getFloaterEvents"}).events
local function _event(event_name)
- if not util.contains(event_list, event_name) then
+ if not table.find(event_list, event_name) then
LL.print_warning("Incorrect event name: " .. event_name)
end
return event_name
@@ -31,6 +25,7 @@ function getCurrentTime()
end
function handleEvents(event_data)
+ post({action="add_text", ctrl_name="events_editor", value = event_data})
if event_data.event == _event("commit") then
if event_data.ctrl_name == "disable_ctrl" then
post({action="set_enabled", ctrl_name="open_btn", value = (1 - event_data.value)})
@@ -53,12 +48,7 @@ end
local key = {xml_path = XML_FILE_PATH, op = "showLuaFloater"}
--sign for additional events for defined control {<control_name>= {action1, action2, ...}}
key.extra_events={show_time_lbl = {_event("right_mouse_down"), _event("double_click")}}
-coro.launch(function ()
- --script received event pump name, after floater was built
- COMMAND_PUMP_NAME = leap.request("LLFloaterReg", key)["command_name"]
- leap.done()
-end)
-leap.process()
+COMMAND_PUMP_NAME = leap.request("LLFloaterReg", key).command_name
catch_events = leap.WaitFor:new(-1, "all_events")
function catch_events:filter(pump, data)
@@ -73,6 +63,4 @@ function process_events(waitfor)
end
end
-coro.launch(process_events, catch_events)
-leap.process()
-LL.print_warning("End of the script")
+fiber.launch("catch_events", process_events, catch_events)
diff --git a/indra/newview/scripts/lua/test_luafloater_gesture_list.lua b/indra/newview/scripts/lua/test_luafloater_gesture_list.lua
index 9c718c353b..6d4a8e0cad 100644
--- a/indra/newview/scripts/lua/test_luafloater_gesture_list.lua
+++ b/indra/newview/scripts/lua/test_luafloater_gesture_list.lua
@@ -1,22 +1,16 @@
XML_FILE_PATH = "luafloater_gesture_list.xml"
leap = require 'leap'
-coro = require 'coro'
-util = require 'util'
+fiber = require 'fiber'
LLGesture = require 'LLGesture'
--event pump for sending actions to the floater
COMMAND_PUMP_NAME = ""
--table of floater UI events
-event_list={}
-coro.launch(function ()
- event_list = leap.request("LLFloaterReg", {op="getFloaterEvents"})["events"]
- leap.done()
-end)
-leap.process()
+event_list=leap.request("LLFloaterReg", {op="getFloaterEvents"}).events
local function _event(event_name)
- if not util.contains(event_list, event_name) then
+ if not table.find(event_list, event_name) then
LL.print_warning("Incorrect event name: " .. event_name)
end
return event_name
@@ -51,11 +45,7 @@ end
local key = {xml_path = XML_FILE_PATH, op = "showLuaFloater"}
--receive additional events for defined control {<control_name>= {action1, action2, ...}}
key.extra_events={gesture_list = {_event("double_click")}}
-coro.launch(function ()
- handleEvents(leap.request("LLFloaterReg", key))
- leap.done()
-end)
-leap.process()
+handleEvents(leap.request("LLFloaterReg", key))
catch_events = leap.WaitFor:new(-1, "all_events")
function catch_events:filter(pump, data)
@@ -70,5 +60,4 @@ function process_events(waitfor)
end
end
-coro.launch(process_events, catch_events)
-leap.process()
+fiber.launch("catch_events", process_events, catch_events)
diff --git a/indra/newview/scripts/lua/util.lua b/indra/newview/scripts/lua/util.lua
index 5d6042dfe5..e3af633ea7 100644
--- a/indra/newview/scripts/lua/util.lua
+++ b/indra/newview/scripts/lua/util.lua
@@ -36,14 +36,4 @@ function util.equal(t1, t2)
return util.empty(temp)
end
--- check if array-like table contains certain value
-function util.contains(t, v)
- for _, value in ipairs(t) do
- if value == v then
- return true
- end
- end
- return false
-end
-
return util