1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Greetings Guest!!

    In order to combat SPAM on the forums, all users are required to have a minimum of 2 posts before they can submit links in any post or thread.

    Dismiss Notice

[Tech Help] lua Command to Use a Skill

Discussion in 'UO Enhanced Client Discussion' started by LowdownandShifty, Jun 4, 2014.

  1. LowdownandShifty

    LowdownandShifty Journeyman

    Joined:
    Nov 19, 2013
    Messages:
    177
    Likes Received:
    49
    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
    
     
  2. LowdownandShifty

    LowdownandShifty Journeyman

    Joined:
    Nov 19, 2013
    Messages:
    177
    Likes Received:
    49
    I forgot to mention: the ability to Use Last Skill would suffice for this
     
  3. Storm

    Storm UO Forum Moderator
    Moderator Professional Premium Wiki Moderator Stratics Veteran Stratics Legend

    Joined:
    Mar 18, 2004
    Messages:
    7,469
    Likes Received:
    361
    Hopefully @Pinco or one of the modders will respond as I have no clue
     
  4. LowdownandShifty

    LowdownandShifty Journeyman

    Joined:
    Nov 19, 2013
    Messages:
    177
    Likes Received:
    49
  5. Pinco

    Pinco UOEC Modder
    Stratics Veteran Stratics Legend

    Joined:
    Jul 25, 2005
    Messages:
    5,673
    Likes Received:
    865
    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.
     
    Storm likes this.
  6. Petra Fyde

    Petra Fyde Peerless Chatterbox
    Stratics Veteran Alumni Stratics Legend

    Joined:
    Jan 5, 2001
    Messages:
    30,888
    Likes Received:
    5,169
    Perhaps if you were to tell us exactly what you were hoping to achieve we might be able to suggest something?
     
    Storm likes this.
  7. LowdownandShifty

    LowdownandShifty Journeyman

    Joined:
    Nov 19, 2013
    Messages:
    177
    Likes Received:
    49
    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.
     
  8. Pinco

    Pinco UOEC Modder
    Stratics Veteran Stratics Legend

    Joined:
    Jul 25, 2005
    Messages:
    5,673
    Likes Received:
    865
    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 "."