EC: Add ability to script pressing buttons in the legacy runebooks
The following code changes to the EC will allow you to script pressing buttons in the legacy rune books.
To the file source\LegacyRunebook.lua
Modify the function LegacyRunebook.OnRuneClicked
To select the first rune use the following script command
script LegacyRunebook.ClickOnRune(1)
To select the recall button use the following script command
script LegacyRunebook.ClickDefaultButton(3)
The button numbers to use with ClickDefaultButton are
To the file source\LegacyRunebook.lua
Modify the function LegacyRunebook.OnRuneClicked
function LegacyRunebook.OnRuneClicked()
local windowName = WindowUtils.GetActiveDialog()
local buttonNum = WindowGetId(SystemData.ActiveWindow.name)
local self = LegacyRunebook.knownWindows[windowName]
--start of added code
LegacyRunebook.RuneClicked(windowName, buttonNum, self)
end
function LegacyRunebook.ClickOnRune(runeNumber)
local windowName = "LEGACY_Runebook_GUMP-1"
local buttonNum = runeNumber
local self = nil
local index = 0
while(self == nil and index < 100000)
do
index = index + 1
windowName = "LEGACY_Runebook_GUMP-"..index
self = LegacyRunebook.knownWindows[windowName]
end
LegacyRunebook.RuneClicked(windowName, buttonNum, self)
end
function LegacyRunebook.RuneClicked(windowName, buttonNum, self)
--end of added code
if(self) then
Modify the function LegacyRunebook.OnDefaultClicked
function LegacyRunebook.OnDefaultClicked()
local currWindow = WindowUtils.GetActiveDialog()
local buttonNum = WindowGetId(SystemData.ActiveWindow.name)
local self = LegacyRunebook.knownWindows[currWindow]
--start of added code
LegacyRunebook.DefaultButtonClicked(currWindow, buttonNum, self)
end
function LegacyRunebook.ClickDefaultButton(buttonNum)
local currWindow = "LEGACY_Runebook_GUMP-1"
local self = nil
local index = 0
while(self == nil and index < 100000)
do
index = index + 1
currWindow = "LEGACY_Runebook_GUMP-"..index
self = LegacyRunebook.knownWindows[currWindow]
end
LegacyRunebook.DefaultButtonClicked(currWindow, buttonNum + 1, self)
end
function LegacyRunebook.DefaultButtonClicked(currWindow, buttonNum, self)
--end of added code
if(self) then
script LegacyRunebook.ClickOnRune(1)
To select the recall button use the following script command
script LegacyRunebook.ClickDefaultButton(3)
The button numbers to use with ClickDefaultButton are
LegacyRunebook.DefaultNum.RENAME_BOOK = 1
LegacyRunebook.DefaultNum.DROP_RUNE = 2
LegacyRunebook.DefaultNum.RECALL = 3
LegacyRunebook.DefaultNum.GATE_TRAVEL = 4
LegacyRunebook.DefaultNum.SACRED = 5
LegacyRunebook.DefaultNum.SET_DEFAULT = 6
Comments
I was just testing this and it's actually running on the C indexing. 'Cause UO.
Rune positions 1 - 16 are working correctly though.
--
Many thanks to TimSt for developing this solution.
If you make the above code changes and use the new scripting language you can write a macro as follows:
Runebook
Delay 0.25s
Action>Command "script LegacyRunebook.ClickOnRune(14)"
Action>Command "script LegacyRunebook.ClickDefaultButton(3)"
The macro will automagically open the runebook, click on the 14th rune, and cast recall.
No more need to carry around 20 runebooks, all with different default locations.
Visually, the macro would look like this:
Please make the Grizzled Mare a 5 slot mount, it's incredibly rare and deserves it. Some of us have been waiting a long time for this simple addition.
local name = nil
if(type (runeNumber) == "string") then
name = towstring(runeNumber)
elseif(type (runeNumber) == "wstring") then
name = runeNumber
end
if(name ~= nil) then
for index = 1, LegacyRunebook.NumActiveRunes[windowName] do
local labelName = windowName.."RuneButton"..tostring(index).."Name"
local location = LabelGetText(labelName)
if(location ~= nil and location == name ) then
buttonNum = index
break
end
end
if(type(buttonNum) ~= "number") then
return -- perhaps return true/false from this function.
end
end