Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/williamvenner/glua-material-avatar
- Owner: WilliamVenner
- License: mit
- Created: 2021-03-30T00:14:57.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-07-21T14:20:23.000Z (over 2 years ago)
- Last Synced: 2024-10-11T11:35:28.415Z (3 months ago)
- Topics: avatar, circle, garry, garrys, garrysmod, glua, gmod, http, lua, material, picture, profile, steam, vgui
- Language: Lua
- Homepage:
- Size: 7.81 KB
- Stars: 32
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)
endsurface.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())
```