GSE: Advanced Macro Compiler

repository·master·Indexed 42 days ago

https://github.com/timothyluke/gse-advanced-macro-compiler

An advanced macro compiler for World of Warcraft (WoW) that allows users to create complex command stacks (Blocks) to overcome standard macro limitations while remaining compliant with Blizzard's rules. Features include an in-game editor, syntax highlighting, a macro debugger, and a macro recorder. The project also includes wowmock for unit testing WoW addons using luaunit 2.1 and mockagne 1.0+.

Tokens
1.3K
Snippets
3
Records
6
Agent score
4%

What's inside GSE

  1. Overview of GSE: Advanced Macro Compiler

    master

    GSE is an advanced macro compiler for World of Warcraft (WoW) designed to overcome the limitations of the standard WoW macro system. Unlike standard macros, GSE does not wait for the success or failure of an action before proceeding; it sends a stack of commands to WoW and moves to the next line immediately.

    Core Mental Model: Command Blocks GSE operates using the concept of a Block of commands. You arrange commands (such as targeting an enemy, casting a spell, or using a trinket) into a stack. When you click the macro, GSE sends this stack to WoW. WoW then attempts to execute each line from the top of the stack down.

    Rules and Limitations

    • GSE follows all Blizzard rules.
    • Because of Blizzard's rules, a single stack can only attempt one GCD (Global Cooldown) ability.
    • To handle cooldowns, you can design sequences where subsequent clicks trigger different blocks, allowing you to attempt different abilities if the previous one was unavailable.
  2. Key Features of GSE

    master

    GSE provides several advanced tools for macro creation and management within WoW, including:

    • Loops: For repetitive execution patterns.
    • In-game Editor: To create and modify macros without leaving the game.
    • Syntax Highlighting: For easier macro readability.
    • Macro Variables and WoW API incorporation: To leverage game data within your macros.
    • Macro Debugger: To troubleshoot macro behavior.
    • Macro Recorder: To capture sequences of actions.
    • Share Macro In-game: To distribute your creations.
    • Localisation support: For multi-language compatibility.
  3. Example: Unit testing a WoW addon with wowmock

    master

    To test an addon, use mockagne to create mocks for the global environment and the addon's private table. Pass these mocks into wowmock during your test setup. You can then use when to define API behavior and verify to ensure the API was called correctly.

    local LuaUnit = require('luaunit')
    local mockagne = require('mockagne')
    local wowmock = require('wowmock')
    
    local when, verify = mockagne.when, mockagne.verify
    
    -- Mocks
    local globals, addon
    
    -- The test "class"
    tests = {}
    
    -- Setup, before every test
    function tests:setup()
    	-- Prepare an addon mock
    	addon = mockagne:getMock()
    	
    	-- Prepare a globals mock
    	globals = mockagne:getMock()
    	
    	-- Load the file to test 
    	wowmock("FileToTest.lua", globals, "MyAddon", addon)
    end
    
    -- A test
    function tests:test_addon_doSomething()
    	-- When UnitSpeed("player") is called, return 7
    	when(globals.UnitSpeed("player")).thenAnswer(7)
    	
    	-- Call the function to test
    	local result = addon.doSomething()
    	
    	-- Ensure UnitSpeed("player") has been called
    	verify(globals.UnitSpeed("player"))
    	
    	-- Ensure the result returned the expected result
    	assertEquals("expectedResult", result)
    end
    
    -- Run the tests
    os.exit(LuaUnit:Run())
  4. Use the wowmock function to load files

    master

    The wowmock function loads a Lua file into a controlled environment using setfenv. This allows you to simulate a WoW environment where the code has access to standard Lua globals and a subset of WoW Lua functions.

    Most specific WoW API functions are not implemented by default and should be mocked using the globals parameter.

    function wowmock(filepath, globals, ...)