summaryrefslogtreecommitdiff
path: root/indra/newview/scripts/lua
AgeCommit message (Collapse)Author
2024-06-20Use LLLeapListener to listen to LLNearbyChat pumpMnikolenko Productengine
2024-06-19Move popup.lua to require subdir with the rest of the modules.Nat Goodspeed
2024-06-18Remove special-case ~LuaState() code to call fiber.run().Nat Goodspeed
Instead, make fiber.lua call LL.atexit(fiber.run) to schedule that final run() call at ~LuaState() time using the generic mechanism. Append an explicit fiber.run() call to a specific test in llluamanager_test.cpp because the test code wants to interact with multiple Lua fibers *before* we destroy the LuaState.
2024-06-14Move Lua modules for 'require' to indra/newview/scripts/lua/require.Nat Goodspeed
Make viewer_manifest.py copy them into the viewer install image. Make the require() function look for them there.
2024-06-14Add nearby chat listenerMnikolenko Productengine
2024-06-12Avoid messing up Lua's global namespace in 'require' modules.Nat Goodspeed
2024-06-12Make popup() directly pass payload.Nat Goodspeed
The expression (payload or {}) is unnecessary, since that value will be converted to LLSD -- and both Lua nil and empty table convert to LLSD::isUndefined().
2024-06-11Add popup.lua, a preliminary API for viewer notifications.Nat Goodspeed
WIP: This is known not to work yet.
2024-06-11Add login.lua module with login() function.Nat Goodspeed
The nullary login() call (login with saved credentials) has been tested, but the binary login(username, password) call is known not to work yet.
2024-06-11Add to UI.lua a set of 'LLWindow' listener operations.Nat Goodspeed
Add listviews(), viewinfo(), click(), doubleclick(), drag(), keypress() and type(). WIP: These are ported from Python LEAP equivalents, but the Lua implementation has only been partially tested.
2024-06-11Fix a couple bugs in startup.lua.Nat Goodspeed
The 'startup' table, the module's namespace, must be defined near the top because its local waitfor:process() override references startup. The byname table's metatable's __index() function wants to raise an error if you try to access an undefined entry, but it referenced t[k] to check that, producing infinite recursion. Use rawget(t, k) instead. Also use new leap.WaitFor(args) syntax instead of leap.WaitFor:new(args).
2024-06-11Allow Python-like 'object = ClassName(ctor args)' constructor calls.Nat Goodspeed
The discussions we've read about Lua classes conventionally use ClassName:new() as the constructor, and so far we've followed that convention. But setting metaclass(ClassName).__call = ClassName.new permits Lua to respond to calls of the form ClassName(ctor args) by implicitly calling ClassName:new(ctor args). Introduce util.classctor(). Calling util.classctor(ClassName) sets ClassName's metaclass's __call to ClassName's constructor method. If the constructor method is named something other than new(), pass ClassName.method as the second arg. Use util.classctor() on each of our classes that defines a new() method. Replace ClassName:new(args) calls with ClassName(args) calls throughout.
2024-06-11mapargs() now accepts 'name1,name2,...' as argument namesNat Goodspeed
in addition to a list {'name1', 'name2', ...}.
2024-06-11Merge branch 'release/luau-scripting' into lua-loginNat Goodspeed
2024-06-10Merge branch 'release/luau-scripting' into lua-ui-callbacksMnikolenko Productengine
2024-06-07Introduce mapargs.lua, which defines the mapargs() function.Nat Goodspeed
There are two conventions for Lua function calls. You can call a function with positional arguments as usual: f(1, 2, 3) Lua makes it easy to handle omitted positional arguments: their values are nil. But as in C++, positional arguments get harder to read when there are many, or when you want to omit arguments other than the last ones. Alternatively, using Lua syntactic sugar, you can pass a single argument which is a table containing the desired function arguments. For this you can use table constructor syntax to effect keyword arguments: f{a=1, b=2, c=3} A call passing keyword arguments is more readable because you explicitly associate the parameter name with each argument value. Moreover, it gracefully handles the case of multiple optional arguments. The reader need not be concerned about parameters *not* being passed. Now you're coding a Lua module with a number of functions. Some have numerous or complicated arguments; some do not. For simplicity, you code the simple functions to accept positional arguments, the more complicated functions to accept the single-table argument style. But how the bleep is a consumer of your module supposed to remember which calling style to use for a given function? mapargs() blurs the distinction, accepting either style. Coding a function like this (where '...' is literal code, not documentation ellipsis): function f(...) local args = mapargs({'a', 'b', 'c'}, ...) -- now use args.a, args.b, args.c end supports calls like: f(1, 2, 3) f{1, 2, 3} f{c=3, a=1, b=2} f{1, 2, c=3} f{c=3, 1, 2} -- unlike Python! In every call above, args.a == 1, args.b == 2, args.c == 3. Moreover, omitting arguments (or explicitly passing nil, positionally or by keyword) works correctly. test_mapargs.lua exercises these cases.
2024-06-04Comment the intent of test_timers.luaNat Goodspeed
so the user need not reverse-engineer the code to figure out the output.
2024-06-03Leverage new leap.eventstream() function in Floater.lua.Nat Goodspeed
2024-05-31Add timers.lua API module and test_timers.lua test program.Nat Goodspeed
Since timers presents a timers.Timer Lua class supporting queries and cancellation, make TimersListener::scheduleAfter() and scheduleEvery() respond immediately so the newly constructed Timer object has the reqid necessary to perform those subsequent operations. This requires that Lua invocations of these operations avoid calling the caller's callback with that initial response. Reinvent leap.generate() to return a Lua object supporting next() and done() methods. A plain Lua coroutine that (indirectly) calls fiber.wait() confuses the fiber scheduler, so avoid implementing generate() as a Lua coroutine. Add a bit more leap.lua diagnostic output.
2024-05-31Tweak for current Lua dbg() convention.Nat Goodspeed
2024-05-31Cherry-pick leap.lua changes; other clean upMnikolenko Productengine
2024-05-31Add leap.eventstream() and cancelreq() functions.Nat Goodspeed
leap.eventstream() is used when we expect the viewer's LLEventAPI to send an immediate first response with the reqid from the request, followed by some number of subsequent responses bearing the same reqid. The difference between eventstream() and generate() is that generate() expects the caller to request each such response, whereas eventstream calls the caller's callback with each response. cancelreq() is for canceling the background fiber launched by eventstream() before the callback tells it to quit. Make WaitFor:close() remove the object from the waitfors list; similarly, make WaitForReqid:close() remove the object from the pending list. For this reason, cleanup() must iterate over a copy of each of the pending and waitfors lists. Instead of unregisterWaitFor() manually searching the waitfors list, use table.find().
2024-05-31Add a bit more dbg() conditional diagnostic output.Nat Goodspeed
2024-05-31Don't check if printf(format) arg is a string.Nat Goodspeed
2024-05-30Merge branch release/luau-scriptingMnikolenko Productengine
2024-05-24Merge branch 'release/luau-scripting' into lua-timersNat Goodspeed
2024-05-24Merge branch 'release/luau-scripting' into lua-chatplusNat Goodspeed
2024-05-24Nat's ideas from PR #1547Nat Goodspeed
2024-05-24Mark script messages in compact mode too; code clean upMnikolenko Productengine
2024-05-22add throttle for sending messages; add simple demo scriptMnikolenko Productengine
2024-05-22Add support for sending messages to Nearby chat from Lua scriptMnikolenko Productengine
2024-05-15Add trusted flag to UI callbacks, so not everything is accessible from the ↵Mnikolenko Productengine
script
2024-05-15Make leap.lua honor an "error" key in viewer response.Nat Goodspeed
2024-05-08Tweak a couple thingsNat Goodspeed
2024-05-07Copy xml files to scripts/lua; make Lua debug floater resizableMnikolenko Productengine
2024-05-02Raise Lua error if LLViewerControlListener response contains oneMnikolenko Productengine
2024-05-01Use LLViewerControlListener to access debug settingsMnikolenko Productengine
2024-04-29Allow getting the value of debug settings via Lua scriptMnikolenko Productengine
2024-04-22Add demo script with idle and notification interactionsMnikolenko Productengine
2024-04-09Add Lua Floater class to simplify Lua script showing floaters.Nat Goodspeed
Add test_luafloater_demo2.lua and test_luafloater_gesture_list2.lua examples.
2024-04-02Fix std::filesystem::path - to - std::string conversions on Windows.Nat Goodspeed
On Windows, std::filesystem::path::value_type is wchar_t, not char -- so path::string_type is std::wstring, not std::string. So while Posix path instances implicitly convert to string, Windows path instances do not. Add explicit u8string() calls. Also add LL.abspath() Lua entry point to further facilitate finding a resource file relative to the calling Lua script. Use abspath() for both test_luafloater_demo.lua and test_luafloater_gesture_list.lua.
2024-04-02Add startup.lua module with startup.ensure(), wait() functions.Nat Goodspeed
This lets a calling script verify that it's running at the right point in the viewer's life cycle. A script that wants to interact with the SL agent wouldn't work if run from the viewer's command line -- unless it calls startup.wait("STATE_STARTED"), which pauses until login is complete. Modify test_luafloater_demo.lua and test_luafloater_gesture_list.lua to find their respective floater XUI files in the same directory as themselves. Make them both capture the reqid returned by the "showLuaFloater" operation, and filter for events bearing the same reqid. This paves the way for a given script to display more than one floater concurrently. Make test_luafloater_demo.lua (which does not require in-world resources) wait until 'STATE_LOGIN_WAIT', the point at which the viewer has presented the login screen. Make test_luafloater_gesture_list.lua (which interacts with the agent) wait until 'STATE_STARTED', the point at which the viewer is fully in world. Either or both can now be launched from the viewer's command line.
2024-04-02Defend leap.request(), generate() from garbage collection.Nat Goodspeed
Earlier we had blithely designated the 'pending' list (which stores WaitForReqid objects for pending request() and generate() calls) as a weak table. But the caller of request() or generate() does not hold a reference to the WaitForReqid object. Make pending hold "strong" references. Private collections (pending, waitfors) and private scalars that are never reassigned (reply, command) need not be entries in the leap table.
2024-03-29Merge branch 'release/luau-scripting' into lua-startupNat Goodspeed
2024-03-27Merge 'release/luau-scripting' of secondlife/viewer into lua-startupNat Goodspeed
2024-03-27Run each script file with new LuaStateMnikolenko Productengine
2024-03-27Enhance Lua debugging output.Nat Goodspeed
Don't use "debug" as the name of a function to conditionally write debug messages: "debug" is a Luau built-in library, and assigning that name locally would shadow the builtin. Use "dbg" instead. Recast fiber.print_all() as fiber.format_all() that returns a string; then print_all() is simply print(format_all()). This refactoring allows us to use dbg(format_all()) as well. Add a couple new dbg() messages at fiber state changes.
2024-03-27poetryNat Goodspeed
2024-03-26Merge branch 'release/luau-scripting' into luau-keystrokeMnikolenko Productengine
2024-03-26update scripts to use fiber.launch()Mnikolenko Productengine