Author |
Message |
Henri Beauchamp
Joined: 2009-03-17 18:42:51 Posts: 6030
|
All you need to do is to create a small Lua floater, with a list and a few buttons... Then RTFM !  (*)
(*) Hints: in the above example for OnGroupNotification(), replace the printing and cancellation code with code for opening your Lua floater (if not already opened), and inserting the notification data into its list. Then, setup actions for your buttons, which would operate on the selected list elements (notifications).
|
2025-04-05 18:01:38 |
|
 |
Ibrew Meads
Joined: 2010-03-14 21:12:58 Posts: 92
|
Oh, that is awesome, Henri. Thank you so much! 
|
2025-04-07 00:46:37 |
|
 |
g0rd0ngrfr33mailgr
Joined: 2011-09-27 11:18:31 Posts: 244
|
Thank you!!! I didn't know that that is what lists do! It's very rudimentary for now and the buttons won't work, but so far I have something: https://i.imgur.com/nF2XdpH.pngI'll keep working on it! <3
|
2025-04-07 07:19:50 |
|
 |
g0rd0ngrfr33mailgr
Joined: 2011-09-27 11:18:31 Posts: 244
|
My progress so far:  floater_lua_gnm.xml: automation.lua  |  |  |  | Code: function OnGroupNotification(group_name, group_id, dialog_id, timestamp, sender, subject, message, inventory) local notice notice = group_name .. "|" .. group_id .. "|" .. dialog_id .. "|" .. GetTimeStamp(-8,'%H:%M:%S') .. "|" .. sender .. "|" .. subject.. "|" .. message .. "|" .. inventory OpenLuaFloater("gnm") SetLuaFloaterValue("gnm", "list1", notice) CancelNotification(dialog_id) end
|  |  |  |  |
and in OnLuaFloaterAction: But that's where the problem is: the button's command returns "nil", so I presume I'm using the command wrong. It says in the manual it gives a "table of arrays", which I take to mean something like {"this" "that"} but it doesn't seem to work. Could you give me another pointer please?
|
2025-04-09 15:43:51 |
|
 |
Henri Beauchamp
Joined: 2009-03-17 18:42:51 Posts: 6030
|

Labels are free-form: I'd rather use "Group name" instead of "group_name", for example. Also, I doubt that you care much about seeing the group and dialog Ids, so you could either not use them at all, or shrink their width to 0 to hide them in the list (which leaves more room for other columns too). You might want to add GroupNotificationAcceptOffer(dialog_id) before CancelNotification(dialog_id), since you are closing the dialogs systematically and would loose the offered inventory when there is one... There are several problems here: - OnLuaFloaterAction() is not the right callback to setup an UI element floater command (i.e. associate a Lua command to the commit callback of an UI element): setting commands can be done either directly in the floater XUI definition, using the lua_command attribute (see the example in Appendix B of the Lua manual, for spinner "spin1", for example), or via SetLuaFloaterCommand() in the OnLuaFloaterOpen() callback (i.e. you set the Lua commands when the floater gets opened; here again, see Appendix B of the manual for a example).
- The command you are using for button1 cannot work: for a list, GetLuaFloaterValues() only returns the selected lines indices in the list, not the columns contents for those selected lines...
- You are using an array key (message) which you fail to quote: valid syntax would be some_table["message"] or some_table.message, but since there is no such key returned by GetLuaFloaterValues('gnm','list1') anyway, you would get nil as well.
To deal with the "Show" (button1) action, it would be simpler to test for the control string in OnLuaFloaterAction(name, control, value): test name against "gnm" and control against "button1" and when they match, execute your code. It would be possible to retrieve the "message" column contents for the list line at index GetLuaFloaterValues('gnm','list1'), but it would involve more complex code using the (non Lua-floater specific) GetFloaterList() function (and GetFloaterInstances("floater_lua_gnm") to get your Lua floater Id that GetFloaterList() needs), but this is complicating things uselessly. My advice is to store the messages inside a global array defined in automation.lua (for example, outside of any function definition, use group_messages = {} on a line). Then, in OnGroupNotification(), use that array to store incoming messages, and when you get a button click event, display the message corresponding to the selected line in the floater:  |  |  |  | Code: group_messages = {} function OnGroupNotification(group_name, group_id, dialog_id, timestamp, sender, subject, message, inventory) group_messages[#group_messages + 1] = message local notice notice = group_name .. "|" .. group_id .. "|" .. dialog_id .. "|" .. GetTimeStamp(-8,'%H:%M:%S') .. "|" .. sender .. "|" .. subject.. "|" .. message .. "|" .. inventory OpenLuaFloater("gnm") SetLuaFloaterValue("gnm", "list1", notice) GroupNotificationAcceptOffer(dialog_id) CancelNotification(dialog_id) end
function OnLuaFloaterAction(name, control, value) if name == "gnm" and control == "button1" then -- Reminder: XUI list indices start at 0, Lua indices start at 1 print(group_messages[GetLuaFloaterValue(name, 'list1') + 1]) end end
function OnLuaFloaterClose(name, parameter) if name == "gnm" then group_messages = {} end end
|  |  |  |  |
|
2025-04-09 19:10:08 |
|
 |
g0rd0ngrfr33mailgr
Joined: 2011-09-27 11:18:31 Posts: 244
|
Ah, I see. I had hoped it would be a way to get the content of the current "cell", or at least a table of strings containing the contents of the current line per column. I will read into that, because it seems more natural to me: in maths, in matrices we simply call A_(ij)  But programming is not maths… Thank you, Henri. I have something a little more complicated in mind, actually, but I'll work from that onwards. By the way, shouldn't group_messages = [ ] be group_messages = {}? Also, if I replace the print() with OpenNotification("2", …), it doesn't work. I get bad argument #2 to 'OpenNotification' (string expected, got nil) and of course putting quotes around it just prints the content of the quotes. But why nil? It's not nil, it's the element of an array, you just printed it.
|
2025-04-10 11:50:10 |
|
 |
Henri Beauchamp
Joined: 2009-03-17 18:42:51 Posts: 6030
|
And I just implemented GetLuaFloaterListLine() for this purpose, for next release... Yes, my bad (fixed in my above post). Which is normal... The first parameter for OpenNotification() must be an integer, so you must use OpenNotification(2, ...). Please, RTFM !  You might also prefer notification type 1 (script-menu-like) instead of 2 (modal alert dialog) for this...
|
2025-04-10 13:06:09 |
|
 |
g0rd0ngrfr33mailgr
Joined: 2011-09-27 11:18:31 Posts: 244
|
Oh, thank you! <3 It works either way actually (2 or "2"), but in this case it doesn't.
|
2025-04-10 14:32:10 |
|
|
Who is online |
Users browsing this forum: No registered users and 2 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|