Skip to content

Instantly share code, notes, and snippets.

@theawesomecoder61
theawesomecoder61 / drawarc.lua
Last active September 16, 2024 17:56
Draw arcs or pie charts/graphs in Garry's Mod. I did not make this, this is only re-uploaded for archival reasons.
-- Draws an arc on your screen.
-- startang and endang are in degrees,
-- radius is the total radius of the outside edge to the center.
-- cx, cy are the x,y coordinates of the center of the arc.
-- roughness determines how many triangles are drawn. Number between 1-360; 2 or 3 is a good number.
function draw.Arc(cx,cy,radius,thickness,startang,endang,roughness,color)
surface.SetDrawColor(color)
surface.DrawArc(surface.PrecacheArc(cx,cy,radius,thickness,startang,endang,roughness))
end
@jrus
jrus / lua-uuid.lua
Created July 29, 2012 09:26
quick lua implementation of "random" UUID
local random = math.random
local function uuid()
local template ='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
return string.gsub(template, '[xy]', function (c)
local v = (c == 'x') and random(0, 0xf) or random(8, 0xb)
return string.format('%x', v)
end)
end