Skip to content

Instantly share code, notes, and snippets.

@Meorawr
Meorawr / HybridScrollDemo.lua
Last active October 28, 2023 12:17
HybridScrollFrame Demo
local function CreateDemoModel(numItems)
local listModel = {};
for index = 1, numItems do
table.insert(listModel, {
text = string.format("List Item %1$d", index),
icon = string.format([[Interface\Icons\INV_Sword_%1$d]], 30 + (index % 30)),
});
end
@Meorawr
Meorawr / savedvars.py
Last active January 13, 2020 02:40
TRP3 Saved Variables Parser
#!/usr/bin/python3
'''
Limited reimplementation of the Lua 5.1 lexer and parser providing utilities
for serialization and deserialization of World of Warcraft saved variables
files.
The grammar supported by the parser is a subset of the Lua 5.1 grammar,
any unimplemented features will raise errors if encountered in a source file.
'''
@Meorawr
Meorawr / async.lua
Last active December 12, 2023 05:13
Lua 5.1 Async/Await
#!/usr/bin/lua5.1
--- Async/Await for Lua 5.1
-- This script implements async/await functions for Lua, allowing tasks to
-- be queued and scheduled independently.
--
-- This is just an example and has a bunch of issues, isn't tested, isn't
-- even actually used anywhere; I basically just got bored and had one of
-- those "what if?" type ideas 6 hours ago.
local co_create = coroutine.create
@Meorawr
Meorawr / UnitSearcher.lua
Created January 20, 2020 17:37
Unit Searcher
-- Mapping of all root unit tokens in the game.
local UNIT_TOKENS = {
["player"] = true,
["target"] = true,
["mouseover"] = true,
["focus"] = true,
["pet"] = true,
["npc"] = true,
["vehicle"] = true,
};
@Meorawr
Meorawr / CraftingSpells.tsv
Last active May 8, 2020 11:30
Classic 1.13.2 Tradeskill/Crafting Spell ID Dump
Effect SpellID
53 2832
53 2833
53 3974
53 2831
53 2605
53 3231
53 3975
53 3976
53 6476
@Meorawr
Meorawr / ButtonGroupMixin.lua
Created June 28, 2020 11:12
ButtonGroupMixin
local ButtonGroupMixin = CreateFromMixins(CallbackRegistryBaseMixin);
function ButtonGroupMixin:Init()
CallbackRegistryBaseMixin.OnLoad(self);
self.buttons = {};
self.selectedButton = nil;
end
function ButtonGroupMixin:AddButton(button)
@Meorawr
Meorawr / ParentlessFrameBug.xml
Last active July 17, 2020 22:50
Parentless Frame Bug (9.x)
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
<!--
Bug #1:
Instantiating a frame ("TestFrame") that has no parent attribute
specified and is hidden upon creation seems to cause some issues
with the visiblity of child frames.
This is quite odd to explain, but running `TestFrame:Show()` ingame
causes only the "MagicTexture" Texture element to appear until the
frame itself is relocated or resized (click to drag), at which point
@Meorawr
Meorawr / BackdropMixinTaintTest.xml
Last active August 14, 2020 17:24
BackdropMixin Taint
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
<!--
Upon login, run the following in the chat frame - if taint has
occurred both of the following variables will report as being insecure:
/dump issecurevariable(PTR_IssueReporter.Data, "CurrentMapID")
/dump issecurevariable(PTRIssueReporterAlertFrame, "FrameComponents")
It's possible for the first one to spuriously return "true" - there
might be an element of luck to it, but the "FrameComponents" key on
@Meorawr
Meorawr / BackdropTemplate.lua
Last active January 11, 2021 23:13
Backdrop Polyfill Example
local BackdropTemplatePolyfillMixin = {};
function BackdropTemplatePolyfillMixin:OnBackdropLoaded()
if not self.backdropInfo then
return;
end
if not self.backdropInfo.edgeFile and not self.backdropInfo.bgFile then
self.backdropInfo = nil;
return;
@Meorawr
Meorawr / UserWaypointSkeleton.lua
Created July 22, 2020 19:01
User Waypoint Position Skeleton
local distances = {}; -- Array of 4 distances to TL, TR, BR, BL.
local function GetPointToQuery(index)
local mapID = C_Map.GetBestMapForUnit("player");
local x, y;
if index == 1 then
x, y = 0, 0;
elseif index == 2 then
x, y = 1, 0;