Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/williamvenner/glua-material-avatar

Simple script demonstrating how to download Steam avatars and generate a Material from them using clientside GLua.
https://github.com/williamvenner/glua-material-avatar

avatar circle garry garrys garrysmod glua gmod http lua material picture profile steam vgui

Last synced: 3 months ago
JSON representation

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

Awesome Lists containing this project

README

        

# 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!](https://github.com/SneakySquid/Circles) to produce a textured circular avatar.

## Examples

### Basic Example

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

### HUDPaint Example

```lua
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

```lua
include("vgui-element.lua")

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