Skip to content

Instantly share code, notes, and snippets.

@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
@Choonster
Choonster / ForgeGradleMod.gitignore
Last active April 1, 2023 01:57
A .gitignore file suitable for developing Minecraft Forge mods using ForgeGradle.
## Based on GitHub's Eclipse .gitignore
run/
.gradle/
build/
gradle-app.setting
## IntelliJ IDEA
.idea/
@Choonster
Choonster / randomSounds.lua
Created December 4, 2012 15:06
A WoW script that provides two functions to play a random sound from a list.
local soundFiles = { -- These are example files only
"Sound\\Creature\\SomeCreature\\SomeCreature_Aggro01.ogg",
"Sound\\Creature\\OtherThing\\OtherThing_Greeting01.ogg"
"Interface\\AddOns\\MyAddOn\\Sounds\\levelup1.ogg"
}
local numSounds = #soundFiles -- Get the number of entries in the soundFiles table
local function PlayRandomSound()
local index = random(1, numSounds) -- Generate a random number between 1 and numSounds to use as an index. random is an alias of the math.random function
@Choonster
Choonster / StealthMusic_Core.lua
Created August 30, 2012 15:34
A WoW AddOn that plays music when you're stealthed and moving.
-- Declare a local variable called something like IS_PLAYING (we use this a bit later) and set it to false.
-- Create a frame
-- Hide it
-- Register whatever event(s) fire when the player enters/leaves stealth
-- Set its OnEvent script to show the frame when the player enters stealth (allowing its OnUpdate script to run) and hide the frame, stop the music and set IS_PLAYING to false when the player leaves stealth (stopping its OnUpdate script from running).
-- Set its OnUpdate script to check the player's speed every 0.X seconds.
-- If the player is moving and IS_PLAYING is false, use PlayMusic to start your music and set IS_PLAYING to true.
-- If the player isn't moving and IS_PLAYING is true, use StopMusic to stop the music and set IS_PLAYING to false.
-- http://us.battle.net/wow/en/forum/topic/6412105149#4
@Choonster
Choonster / DebuggingNodeJSHerokuApps.md
Last active November 14, 2021 03:10
How to debug Node.js web applications running on Heroku using ngrok

Debugging Node.js web applications running on Heroku using ngrok

Introduction

Heroku only allows each dyno to send and receive external network traffic on a single port, which means you can't simply run node --debug server.js and attach your debugger to your-app.herokuapp.com:5858.

To work around this, you can use ngrok and Heroku ngrok Buildpack to tunnel to the debugger's port and access it externally.

@Choonster
Choonster / ModelLoadingProcess.md
Last active January 15, 2021 11:20
A description of the model loading process in Minecraft Forge 1.9-1.12.1

In this document, I use strings in the format "foo:bar" to represent ResourceLocations with domain foo and path bar. I also use [square brackets] for placeholders.

The Model Loading Process

Blocks

On startup and whenever the resources are reloaded (in ModelLoader#setupModelRegistry), Minecraft iterates through every registered Block (in ModelLoader#loadBlocks) and asks its custom IStateMapper (or DefaultStateMapper if none has been registered) to create a mapping between every valid IBlockState of the Block and the ModelResourceLocation for that state (with the domain and path pointing to a blockstates file and the variant to a variant within that file). It then attempts to load these models.

DefaultStateMapper looks for the blockstates file with the Block's registry name (i.e. assets/[modid]/blockstates/[name].json) and serialises each property and value of the IBlockState to create the variant name that the model is loaded from (e.g. "enabled=true,type=foobar"

{
"__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
"__parent": "minecraft:block/block",
"textures": {
"0": "testmod3:blocks/chest/wood"
},
"elements": [
{
"name": "Base",
"from": [ 1.0, 0.0, 1.0 ],
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
@Choonster
Choonster / VSVariables.txt
Created July 24, 2018 10:24
Variables set in the Visual Studio 2017 Professional Developer Command Prompt - https://github.com/luarocks/luarocks/issues/850
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\<USER>\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=<COMPUTER>
ComSpec=C:\WINDOWS\system32\cmd.exe
DevEnvDir=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\
DriverData=C:\Windows\System32\Drivers\DriverData
FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer
@Choonster
Choonster / README.md
Last active July 21, 2018 11:34
My AddOn list for p3lim's AddOn Packager Proxy (https://github.com/p3lim/addon-packager-proxy)