Hack

Hack

Currently, until Mud decides otherwise, Vandesdelca32 is going to be maintaining this project.

Hack is a lightweight notebook and/or code development addon.

Hack makes it easy to manage a large collection of notes/scripts and share them with other Hack users. Pages containing Lua code can be run and/or flagged to auto-run on startup; they can call other pages, passing arguments and receiving return values. This lets Hack serve as an in-game file system for Lua scripts.

OPTIONAL:

Hack includes several example pages. They are easily deleted from within Hack, or you can prevent them from ever being loaded by deleting HackExamples.lua from the Hack folder.

Hack itself is lightweight (<60KB), but it includes a library for highlighting/indenting Lua code (FAIAP) which will add some additional memory usage and garbage generation. It's not a big deal, but if you just use Hack as a notebook and never edit Lua code, feel free to delete Indent.lua from the Hack directory.

IMPORT:

Hack's example pages include scripts to import pages from Tinypad, Nefpad, WowLua, and LuaSlinger. LuaSlinger supports triggering pages by events, and the importer shows how easily you can wire up the same functionality in Hack.

If you have another notepad addon you want to pull pages from, lemme know.

USAGE:

/hack toggle Hack UI
/hack <hack name> run a Hack page by name

The UI is mostly self-explanatory (mouse over buttons to see what they do), but a few things deserve special mention:

1. To run the current page as Lua code, click the 'play' button at the top of edit window (this one) or hit SHIFT+TAB from the editor.

2. To make a page run automatically when Hack loads, click the 'play' button next to it's name in the list window. This makes Hack useful for little tweaks that don't warrant a full-blown addon. For instance, I hate the mail font. It's easy to fix, but I don't want to write a whole addon for two lines of code, so I type the lines into a Hack page and flag it to execute. Done.

NOTES:

  • Pages are saved as you type and there is no undo, so be careful. If you really screw up a page, you can hit the Revert button, which will give you back the page as it was when you first opened it.
  • The list frame and edit frame are resizable. Just grab the little handle in the bottom right corner.
  • You can double-click a page name to rename it (in addition to using the rename button).
  • Page search is case insensitive. You use a subset of regex search patterns (^$.*-+?).
  • Autorun pages run in the order they appear, so you can control their execution order by moving them up and down the list.

EXAMPLES:

I included example pages to show how I use Hack. You can delete these quickly via the books tab. To speed Hack's loading, remove HackExamples.lua from the addon folder.

The "lib:" pages contain library code I find useful in many scripts. To facilitate the use of libraries, Hack contains one built-in function Hack.Require, which can be used to make sure a page you are dependent on is loaded, while preventing it from being loaded more than once.

The arg processing examples show how you can execute a page by name, optionally passing arguments and/or receiving return values.

The "timer lib" examples show how to use "lib: timer".

The "cmd:" examples add new slash commands to the game.

The "ui:" examples are various minor tweaks to the UI.

The "hack:" examples are bits of code I used to write Hack. Saves you a lot of reloading to develop with a tool like this.

FEEDBACK:

I'd love to get feedback about Hack. What you like, what you don't like, what you'd like to see in future versions (keeping in mind that my intention is to keep it as small as possible).

Cheers,
Eric Tetz
<[email protected]>

You must login to post a comment. Don't have an account? Register to get one!

  • 2 comments
  • Avatar of Mapartipin Mapartipin Dec 12, 2013 at 13:32 UTC - 0 likes

    XD, hack cool, thanks!

    local AutoSave_SEND_UPDATE_INTERVAL = 180.0;
    local EventFrame = CreateFrame("Frame")
    
    function EventFrame:OnEvent(event, ...) 
       print("HelloWorld:", event)
       self[event](self, ...) 
    end
    
    EventFrame:SetScript("OnEvent", EventFrame.OnEvent)
    
    EventFrame:RegisterEvent("PLAYER_LOGIN")
    
    function EventFrame:PLAYER_LOGIN() 
       TimeSinceLastUpdate = 0;
       DEFAULT_CHAT_FRAME:AddMessage("|c00FF0000Autosave loaded.|r");
    end
    
    function EventFrame:OnUpdate(elapsed) 
       TimeSinceLastUpdate = TimeSinceLastUpdate + elapsed;
       if (TimeSinceLastUpdate > AutoSave_SEND_UPDATE_INTERVAL ) then
          SendChatMessage( ".save" );
          TimeSinceLastUpdate = 0;
       end
    end
    
    EventFrame:SetScript("OnUpdate", EventFrame.OnUpdate)
    
  • Avatar of marciowb marciowb Nov 19, 2013 at 23:55 UTC - 0 likes

    First, thank you, really thank you so much! 'cause this addon is being my IDE for learn Lua and Wow addon development and it is great.

    Until now, I've used 'Hack' from time-to-time, but now I'm testing dual-box and I'm doing my own script in order to better control things. Only today, I've noticed that the "Send this page to another hack user" feature isn't working anymore. So after putting my head into Hack.lua/Hack.xml code for a couple of hours - I know, I'm too newbie yet programming Wow addon / lua :( - I've fixed it.

    The changes were:

    Hack.xml

    <Scripts><!-- 2013-11-19 mwb: fixed for wow 5.4.1 - method arguments was changed. -->
                <OnEvent> Hack[event](self, event, ...) </OnEvent>
                <OnLoad>
                    Hack.OnLoad(self)
                    PanelTemplates_SetNumTabs(HackListFrame, 2)
                    PanelTemplates_SetTab(HackListFrame, 1)
                </OnLoad>
                <OnShow> PlaySound('igSpellBookOpen') </OnShow>
                <OnHide> PlaySound('igSpellBookClose') </OnHide>
            </Scripts>
    

    1) Hack.lua

    local PLAYERNAME = GetUnitName('player')
    
    -- 2013-11-19 mwb: fixed for wow 5.4.1
    RegisterAddonMessagePrefix("Hack1");
    RegisterAddonMessagePrefix("Hack2");
    RegisterAddonMessagePrefix("HackAck");
    RegisterAddonMessagePrefix("HackNack");
    
    StaticPopupDialogs.HackAccept = {
    

    2) Hack.lua

    function Hack.Send()
          -- 2013-11-19 mwb: fixed for wow 5.4.1
          menu[2].disabled = GetNumGroupMembers() == 0
          menu[3].disabled = not UnitInRaid('player')
          menu[4].disabled = not IsInGuild()
          EasyMenu(menu, HackSendMenu, 'cursor', nil, nil, 'MENU')
       end
    

    3) Hack.lua

    function Hack.SendPage(page, channel, name)
       -- 2013-11-19 mwb: fixed for wow 5.4.1
       local id = 'Hack' .. (time()%2+1); 
       local chunksize = 254 - #id
       local pagename = format('%s [from %s on %s]', page.name, PLAYERNAME, date())
       SendAddonMessage(id, pagename, channel, name)
    

    4) Hack.lua

    do -- receive page
       local receiving = {}
       -- 2013-11-19 mwb: fixed for wow 5.4.1
       function Hack.CHAT_MSG_ADDON(self, msg, prefix, body, channel, sender)
          if sender == PLAYERNAME then return end
        local id
    

    Congratulations for your great work on this addon.

    My best regards, Marcio Wesley Borges Doggod-Azralon

    Ps.: Sorry for this long post.

    Last edited Nov 20, 2013 by marciowb: Formatting text
  • 2 comments

Facts

Date created
May 07, 2009
Categories
Last update
Nov 12, 2014
Development stage
Release
Language
  • enUS
License
Public Domain
Curse link
Hack
Downloads
5,795
Recent files

Authors