Skip to content

Instantly share code, notes, and snippets.

@NoobTaco
NoobTaco / wow-version-check.lua
Last active April 14, 2023 03:07
WoW Version Check Code - LUA
-- Version 1
-- Get WoW Client version 1-Classic, 2-TBCc, 9-Retail
local wowver=floor((floor(select(4, GetBuildInfo()))/10000))
print("Toc:", wowver)
if wowver == 1 then
print("This is Classic")
elseif wowver == 2 then
print("This is TBC")
@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
@Jakobud
Jakobud / Core.lua
Last active August 7, 2022 14:09
WOW Classic Addon Ace-3.0 Bootstrap
MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon")
MyAddon.version = "1.0"
local Console = LibStub("AceConsole-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("MyAddon")
-- Register slash command /myaddon
MyAddon:RegisterChatCommand("myaddon", "MyAddonCommand")
@Rubgrsch
Rubgrsch / LocaleKeysCleanUp.lua
Last active August 7, 2022 14:13
Find unused localeKeys in your WoW addon
-- LocaleKeysCleanUp.lua
-- Author: Rubgrsch
-- License: MIT
-- This code helps you find unused localeKeys in your WoW addon.
-- What may cause false positive
-- 1. keys in comments
-- 2. keys in several lines
-- 3. keys doesn't match any patterns, e.g. L[ThisIsVariable]
@Choonster
Choonster / OnUpdate_Throttle_Example.lua
Created January 9, 2015 10:59
An example of OnUpdate throttling in WoW.
local frame = CreateFrame("Frame")
-- The minimum number of seconds between each update
local ONUPDATE_INTERVAL = 0.1
-- The number of seconds since the last update
local TimeSinceLastUpdate = 0
frame:SetScript("OnUpdate", function(self, elapsed)
TimeSinceLastUpdate = TimeSinceLastUpdate + elapsed
if TimeSinceLastUpdate >= ONUPDATE_INTERVAL then