Skip to content

Instantly share code, notes, and snippets.

@meepen
meepen / non-powerof2-png-gmod.lua
Last active February 22, 2021 17:40
Loads non power of 2 PNG into a Garry's Mod texture without fucking over scaling.
local function wait_png(matstr)
local html = vgui.Create("DHTML")
html:AddFunction("console", "memeify", function()
html.done = true
end)
local mat = Material(matstr)
local rw, rh = mat:GetInt "$realwidth", mat:GetInt "$realheight"
local f = file.Open("materials/"..matstr, "rb", "GAME")
local cont = f:Read(f:Size())
@mattkrins
mattkrins / cl_Interactive2D3D.lua
Last active May 14, 2017 17:49
An Interactive 2D3D button library for Garry's Mod.
local Interactive2D3D = {}
Interactive2D3D.IsVisible = function(self) return (self.Visible or false) end
Interactive2D3D.Start = function(self, vPos, aRot, vScale)
if !vPos or !aRot then return false end
self.Valid = true
local plpostoscreenx = vPos.x - LocalPlayer():GetShootPos().x
local plpostoscreeny = vPos.y - LocalPlayer():GetShootPos().y
local plpostoscreen = math.sqrt( plpostoscreenx^2+plpostoscreeny^2 )
local dist1 = 1/( math.cos( math.rad( EyeAngles().y ) ) ) * plpostoscreen
local distfull = 1/( math.cos( math.rad( EyeAngles().p ) ) ) * dist1
@Gamewalker
Gamewalker / getModIDS.php
Last active January 14, 2025 17:12
Prints Mod IDs for Steam Workshop Collection ID (SpaceEngineers Server helper)
<?php
$file = file_get_contents("http://steamcommunity.com/sharedfiles/filedetails/?id=493980032");
$muster = '<a href="http:\/\/steamcommunity.com\/sharedfiles\/filedetails\/\?id=([0-9]+)">';
preg_match_all($muster, $file, $match);
$arr = array_unique(array_values($match[1]));
sort($arr);