Skip to content

Instantly share code, notes, and snippets.

View theandrew61's full-sized avatar

Andrew theandrew61

View GitHub Profile
@theandrew61
theandrew61 / extractgmafile.lua
Created January 13, 2017 02:50
How to extract a GMA (Garry's Mod Addon) file using just Lua. This does not work in Garry's Mod.
-- How to extract a GMA file using Lua (does not work in Garry's Mod)
-- Use forward slashes (/) like on Mac OS X and Linux, since we have to escape backslashes
-- Window's directory conventions are stupid
local steamFolder = "C:/Program Files (x86)/Steam/steamapps/common/GarrysMod" -- adjust for where Garry's Mod is installed, this is default
extractFile(steamFolder .. "/garrysmod/addons/falldamagecustomizer_423859984.gma", "C:/Users/zachr/Desktop/extracted") -- extract one of my mods
function extractFile(infile, outfolder) -- extract a gma to the specified folder
local strExecute = [["cd {sf} & gmad.exe extract -file {if} -out {of}"]]
@theandrew61
theandrew61 / replaceallinstring.lua
Last active September 3, 2025 13:44
Replace all (globally) in string - Lua
-- Turns out, string.gsub does string replacements globally.
-- For example:
print(string.gsub("Hello there! You are on GitHub.", "GitHub", "Gist"))