Skip to content

Simple script demonstrating how to download Steam avatars and generate a Material from them using clientside GLua.

License

Notifications You must be signed in to change notification settings

WilliamVenner/glua-material-avatar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

glua-material-avatar

Simple script demonstrating how to download Steam avatars and generate a Material from them using clientside GLua.

This script is particularly stringent and applies a lot of defensive programming techniques.

Avatar images are cached for 1 day and 1 server session.

Circle Avatars

This code could be combined with Circles! to produce a textured circular avatar.

Examples

Basic Example

getAvatarMaterial(LocalPlayer():SteamID64(), function(mat)
	print("Downloaded", mat)
end)

HUDPaint Example

local avatar, downloaded = ( Material("vgui/avatar_default") )
hook.Add("HUDPaint", "showMyAvatar", function()
	if not downloaded then
		downloaded = true
		-- NEVER call this every frame unless you are planning on DDoSing Steam.
		getAvatarMaterial(LocalPlayer():SteamID64(), function(mat)
			avatar = mat
		end)
	end

	surface.SetDrawColor(255, 255, 255)
	surface.SetMaterial(avatar)
	surface.DrawTexturedRect(50, 50, 128, 128)
end)

VGUI Element Example

include("vgui-element.lua")

local avatar = vgui.Create("AvatarMaterial")
avatar:SetSize(128, 128)
avatar:SetPos(50, 200)
avatar:SetSteamID64(LocalPlayer():SteamID64())
--avatar:SetPlayer(LocalPlayer())

About

Simple script demonstrating how to download Steam avatars and generate a Material from them using clientside GLua.

Topics

Resources

License

Stars

Watchers

Forks

Languages