• Hail Guest!
    We're looking for Community Content Contribuitors to Stratics. If you would like to write articles, fan fiction, do guild or shard event recaps, it's simple. Find out how in this thread: Community Contributions
  • Greetings Guest, Having Login Issues? Check this thread!
  • Hail Guest!,
    Please take a moment to read this post reminding you all of the importance of Account Security.
  • Hail Guest!
    Please read the new announcement concerning the upcoming addition to Stratics. You can find the announcement Here!

[Tech Help] lua Command to Use a Skill

LowdownandShifty

Journeyman
Stratics Veteran
I'm trying to write a function that will cause my character to use a skill based on certain inputs. I found a function in the commands list called UserActionUseSkill(), but I can't locate any documentation on it. The SkillsWindow.lua uses this command to use the skill whenever you click the button in the skills list. Can anyone help?

Code:
function SkillsWindow.SkillLButtonUp()
    -- Player is using a skill by single clicking on an icon
    --Debug.PrintToDebugConsole(L"SkillsWindow.SkillLButtonUp()")
    --Debug.PrintToDebugConsole(L"SkillsWindow.SkillLButtonUp(): window name = "..StringToWString(SystemData.ActiveWindow.name))

    local buttonNum = WindowGetId( SystemData.ActiveWindow.name)
    --Debug.PrintToDebugConsole(L"SkillsWindow.SkillLButtonUp(): button = "..StringToWString(tostring(buttonNum)))

    -- button number is its location on the screen (1 = top of left column, 2 = 2nd in left column, etc with left column done first before starting through the right column)

    local tab = data.activeTab
    --Debug.PrintToDebugConsole(L"SkillsWindow.SkillLButtonDown(): window name = "..StringToWString(SystemData.ActiveWindow.name))
    local activeContent = tabContents[tab]
    -- skillIndex is the line index in the csv file for this skill
    local skillIndex = activeContent[buttonNum]
   
    local skillId = WindowData.SkillsCSV[skillIndex].ServerId

    --Debug.PrintToDebugConsole(L"SkillsWindow.SkillLButtonDown(): tab = "..StringToWString(tostring(tab)))
    --Debug.PrintToDebugConsole(L"SkillsWindow.SkillLButtonDown(): skillIndex = "..StringToWString(tostring(skillIndex)))
    --Debug.PrintToDebugConsole(L"SkillsWindow.SkillLButtonDown(): skillId = "..StringToWString(tostring(skillId)))
   
    -- if the skill icon is not dragable, then it can't be directly used
    if (WindowData.SkillsCSV[skillIndex].DragIcon == 1) then
        SkillsWindow.UseSkill (skillId)
    else
       PrintTidToChatWindow(500014,SystemData.ChatLogFilters.SYSTEM)
    end       
end

function SkillsWindow.UseSkill (skillId)
    -- skillId is the server id for the skill
    --Debug.PrintToDebugConsole(L"SkillsWindow.UseSkill(): serverId = "..StringToWString(tostring(skillId)))
   
    UserActionUseSkill(skillId)
end
 

Storm

UO Forum Moderator
Alumni
Stratics Veteran
Stratics Legend
Awards
1
Hopefully @Pinco or one of the modders will respond as I have no clue
 

Pinco

UOEC Modder
Stratics Veteran
Stratics Legend
I'm trying to write a function that will cause my character to use a skill based on certain inputs. I found a function in the commands list called UserActionUseSkill(), but I can't locate any documentation on it. The SkillsWindow.lua uses this command to use the skill whenever you click the button in the skills list. Can anyone help?

Code:
function SkillsWindow.SkillLButtonUp()
    -- Player is using a skill by single clicking on an icon
    --Debug.PrintToDebugConsole(L"SkillsWindow.SkillLButtonUp()")
    --Debug.PrintToDebugConsole(L"SkillsWindow.SkillLButtonUp(): window name = "..StringToWString(SystemData.ActiveWindow.name))

    local buttonNum = WindowGetId( SystemData.ActiveWindow.name)
    --Debug.PrintToDebugConsole(L"SkillsWindow.SkillLButtonUp(): button = "..StringToWString(tostring(buttonNum)))

    -- button number is its location on the screen (1 = top of left column, 2 = 2nd in left column, etc with left column done first before starting through the right column)

    local tab = data.activeTab
    --Debug.PrintToDebugConsole(L"SkillsWindow.SkillLButtonDown(): window name = "..StringToWString(SystemData.ActiveWindow.name))
    local activeContent = tabContents[tab]
    -- skillIndex is the line index in the csv file for this skill
    local skillIndex = activeContent[buttonNum]
  
    local skillId = WindowData.SkillsCSV[skillIndex].ServerId

    --Debug.PrintToDebugConsole(L"SkillsWindow.SkillLButtonDown(): tab = "..StringToWString(tostring(tab)))
    --Debug.PrintToDebugConsole(L"SkillsWindow.SkillLButtonDown(): skillIndex = "..StringToWString(tostring(skillIndex)))
    --Debug.PrintToDebugConsole(L"SkillsWindow.SkillLButtonDown(): skillId = "..StringToWString(tostring(skillId)))
  
    -- if the skill icon is not dragable, then it can't be directly used
    if (WindowData.SkillsCSV[skillIndex].DragIcon == 1) then
        SkillsWindow.UseSkill (skillId)
    else
       PrintTidToChatWindow(500014,SystemData.ChatLogFilters.SYSTEM)
    end      
end

function SkillsWindow.UseSkill (skillId)
    -- skillId is the server id for the skill
    --Debug.PrintToDebugConsole(L"SkillsWindow.UseSkill(): serverId = "..StringToWString(tostring(skillId)))
  
    UserActionUseSkill(skillId)
end
you can't use skill, cast spells, use special attacks, items or character abilities outside the context where those functions are used. For example the UseSkill can only be triggered by clicking a skill inside the skill window.
 

Petra Fyde

Peerless Chatterbox
Alumni
Stratics Veteran
Stratics Legend
Perhaps if you were to tell us exactly what you were hoping to achieve we might be able to suggest something?
 

LowdownandShifty

Journeyman
Stratics Veteran
I'd like to modify pinco's EnhancePack.KeepAliveMan function. I wanted to be able to toggle the option on my characters to either a.) hide, b.) cast invis, c.) use invisibility potion, or d.) just say "."

However, I'm having trouble doing this. I pulled the code above from SkillsWindow because it looked to me like UserActionUseSkill(skillId) was a global function built into EC. But I wasn't sure how to call it. If that's not the case, please let me know if you know how to use a skill, cast a spell, or use an item in these luas.
 

Pinco

UOEC Modder
Stratics Veteran
Stratics Legend
I'd like to modify pinco's EnhancePack.KeepAliveMan function. I wanted to be able to toggle the option on my characters to either a.) hide, b.) cast invis, c.) use invisibility potion, or d.) just say "."

However, I'm having trouble doing this. I pulled the code above from SkillsWindow because it looked to me like UserActionUseSkill(skillId) was a global function built into EC. But I wasn't sure how to call it. If that's not the case, please let me know if you know how to use a skill, cast a spell, or use an item in these luas.
you can't do that at all. As I said, you can't cast spells, use skills, use items, use special attacks or vitues through the UI, those things works only on certain windows and only by doing certain things.

The afk mode already says "."
 
Top