mirror of
https://github.com/gmod-integration/lua.git
synced 2025-06-15 22:53:59 +00:00
refact: remove materials importer
This commit is contained in:
parent
0db418ef4a
commit
6eebe5f165
|
@ -2,7 +2,6 @@ if game.SinglePlayer() then return print("Gmod Integration is not supported in S
|
||||||
gmInte = gmInte || {}
|
gmInte = gmInte || {}
|
||||||
gmInte.version = "0.5.0"
|
gmInte.version = "0.5.0"
|
||||||
gmInte.config = {}
|
gmInte.config = {}
|
||||||
gmInte.materials = {}
|
|
||||||
local function loadConfig()
|
local function loadConfig()
|
||||||
RunConsoleCommand("sv_hibernate_think", "1")
|
RunConsoleCommand("sv_hibernate_think", "1")
|
||||||
if !file.Exists("gm_integration", "DATA") || !file.Exists("gm_integration/config.json", "DATA") then
|
if !file.Exists("gm_integration", "DATA") || !file.Exists("gm_integration/config.json", "DATA") then
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
local ImageCache = {}
|
|
||||||
function gmInte.createImgurMaterials(materials, addon_var, folder, name)
|
|
||||||
if !file.Exists(folder, "DATA") then file.CreateDir(folder) end
|
|
||||||
local function getMatFromUrl(url, id)
|
|
||||||
materials[id] = Material("nil")
|
|
||||||
if file.Exists(folder .. "/" .. id .. ".png", "DATA") && !gmInte.config.redownloadMaterials then
|
|
||||||
addon_var[id] = Material("../data/" .. folder .. "/" .. id .. ".png", "noclamp smooth")
|
|
||||||
gmInte.log("materials", name .. " - Image Loaded - " .. id .. ".png")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
http.Fetch(url, function(body)
|
|
||||||
file.Write(folder .. "/" .. id .. ".png", body)
|
|
||||||
addon_var[id] = Material("../data/" .. folder .. "/" .. id .. ".png", "noclamp smooth")
|
|
||||||
ImageCache[table.Count(ImageCache) + 1] = {
|
|
||||||
["folder"] = folder,
|
|
||||||
["addon_var"] = addon_var,
|
|
||||||
["id"] = id
|
|
||||||
}
|
|
||||||
|
|
||||||
gmInte.log("materials", name .. " - Image Downloaded - " .. id .. ".png")
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
for k, v in pairs(materials) do
|
|
||||||
getMatFromUrl("https://i.imgur.com/" .. v .. ".png", k)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function gmInte.redowloadMaterials()
|
|
||||||
for k, v in pairs(ImageCache) do
|
|
||||||
v.addon_var[v.id] = Material("../data/" .. v.folder .. "/" .. v.id .. ".png", "noclamp smooth")
|
|
||||||
gmInte.log("materials", v.name .. " - Image Redownloaded - " .. v.id .. ".png")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
concommand.Add("gmod_integration_reload_materials", gmInte.redowloadMaterials)
|
|
||||||
concommand.Add("gmi_reload_materials", gmInte.redowloadMaterials)
|
|
||||||
local materialsList = {
|
|
||||||
["logo"] = "y3Mypbn"
|
|
||||||
}
|
|
||||||
|
|
||||||
gmInte.createImgurMaterials(materialsList, gmInte.materials, "gmod_integration/material", "Gmod Integration")
|
|
Loading…
Reference in New Issue
Block a user