API:LogDisplayGetStringFromCursorPos
From RoR Wiki
UI Lua API · LogDisplay functions
Version: WAR 1.4.8
Returns the line of text of a LogDisplay at a given position.
text = LogDisplayGetStringFromCursorPos(logDisplayName, x, y)
Arguments
- logDisplayName
string– Name of a LogDisplay window.- x, y
number– The position to test. The stock UI passes thecursorX, cursorYvalues handed to its spam-report handler (see the example).
Returns
- text
wstring– The text at that position, orL""if there is none.
Details
- The client finds the character at the position in the display's text, then returns everything from the line break before it to the line break after it. The result can start with that leading line break.
- If nothing is found at the position, an empty string is returned.
- If the window does not exist or is not a LogDisplay, the error is logged and nothing is returned.
- The function needs at least three arguments and only reads the last three.
Errors
These are written to the UI log; the call returns normally.
Error in function call 'LogDisplayGetStringFromCursorPos': Window %s does not existError in function call 'LogDisplayGetStringFromCursorPos': Window %s is not a TextLogDisplay
Example
Grabbing the chat line to report as spam, from ea_playermenu/source/playermenuwindow.lua:
function PlayerMenuWindow.OnReportSpam(wndGroupId, cursorX, cursorY)
...
local offendingMessage = LogDisplayGetStringFromCursorPos(activeTabName.."TextLog", cursorX, cursorY)
HelpUtils.AutoReportGoldSeller(PlayerMenuWindow.curPlayer.name, offendingMessage)
