{"action":"created","comment":{"url":"https://api.github.com/repos/wiremod/wire/pulls/comments/25123698","id":25123698,"diff_hunk":"@@ -155,12 +155,121 @@ function EGP:SendMaterial( obj ) -- ALWAYS use this when sending material\n \tend\n end\n \n+EGP.CachedURLMaterials = {}\n+EGP.LoadingURLQueue = {}\n+setmetatable(EGP.CachedURLMaterials, {__mode = \"v\"})\n+\n+function EGP:CheckURLDownloads()\n+\tlocal numqueued = #EGP.LoadingURLQueue\n+\tlocal urltable = EGP.LoadingURLQueue[numqueued]\n+\t\n+\tif urltable then\n+\t\tif urltable.Panel then\n+\t\t\tif not urltable.Panel:IsLoading() then\n+\t\t\t\ttimer.Simple(0.2,function()\n+\t\t\t\t\tlocal tex = urltable.Panel:GetHTMLMaterial():GetTexture(\"$basetexture\")\n+\t\t\t\t\ttex:Download()\n+\t\t\t\t\turltable.Material:SetTexture(\"$basetexture\", tex)\n+\t\t\t\t\ttex:Download()\n+\t\t\t\t\turltable.Panel:Remove()\n+\t\t\t\t\n+\t\t\t\t\tEGP.CachedURLMaterials[urltable.Url] = urltable.Material\n+\t\t\t\t\tEGP.LoadingURLQueue[numqueued] = nil\n+\t\t\t\tend)\t\t\t\n+\t\t\telse\n+\t\t\t\tif CurTime() > urltable.Timeout then\n+\t\t\t\t\turltable.Panel:Remove()\n+\t\t\t\t\tEGP.LoadingURLQueue[numqueued] = nil\n+\t\t\t\tend\n+\t\t\tend\n+\t\t\n+\t\telse\t\t\n+\t\t\tlocal Panel = vgui.Create( \"DHTML\" )\n+\t\t\tPanel:SetSize( 1024, 1024 )\n+\t\t\tPanel:SetAlpha( 0 )\n+\t\t\tPanel:SetMouseInputEnabled( false )\n+\t\t\tPanel:SetHTML(\n+\t\t\t[[\n+\t\t\t\t<style type=\"text/css\">\n+\t\t\t\t\thtml \n+\t\t\t\t\t{\t\t\t\n+\t\t\t\t\t\toverflow:hidden;\n+\t\t\t\t\t\tmargin: -7.5px -7.5px;\n+\t\t\t\t\t}\n+\t\t\t\t</style>\n+\t\t\t\t\n+\t\t\t\t<body>\n+\t\t\t\t\t<img src=\"]] .. urltable.Url .. [[\" alt=\"\" width=\"1024\" height=\"1024\" />\n+\t\t\t\t</body>\n+\t\t\t]]\n+\t\t\t)\n+\t\t\turltable.Timeout = CurTime()+20\n+\t\t\turltable.Panel = Panel\n+\t\tend\n+\tend\n+\t\n+\tif #EGP.LoadingURLQueue == 0 then\n+\t\ttimer.Destroy(\"EGP_URLMaterialChecker\")\n+\tend\n+end\n+\n+local cv_max_url_materials = CreateConVar( \"wire_egp_max_urlmaterials\", \"30\", { FCVAR_REPLICATED, FCVAR_ARCHIVE } ) \n+\n+function EGP:LoadURLMaterial( tbl, url )\n+\tif EGP.CachedURLMaterials[url] then\n+\t\ttbl.material = EGP.CachedURLMaterials[url]\n+\telse\n+\t\tfor k,v in pairs(EGP.LoadingURLQueue) do\n+\t\t\tif v.Url == url then\n+\t\t\t\ttbl.material = v.Material\n+\t\t\t\treturn\n+\t\t\tend\n+\t\tend\n+\t\n+\t\t--Count the number of materials\n+\t\tlocal totalMaterials = 0, key\n+\t\twhile true do\n+\t\t\tkey = next(EGP.CachedURLMaterials, key)\n+\t\t\tif not key then break end\n+\t\t\ttotalMaterials = totalMaterials + 1\n+\t\tend\n+\t\t\n+\t\tlocal queuesize = #EGP.LoadingURLQueue\n+\t\ttotalMaterials = totalMaterials + queuesize\n+\t\t\n+\t\tif totalMaterials>=cv_max_url_materials:GetInt() then\n+\t\t\ttbl.material = false\n+\t\t\treturn\n+\t\tend\n+\t\t\n+\t\tlocal ShaderInfo = {\n+\t\t\t[\"$vertexcolor\"] = 1,\n+\t\t\t[\"$vertexalpha\"] = 1,\n+\t\t\t[\"$ignorez\"] = 1,\n+\t\t\t[\"$nolod\"] = 1\n+\t\t}\n+\t\tlocal urlmaterial = CreateMaterial(\"egp_urltex_\" .. util.CRC(url .. SysTime()), \"UnlitGeneric\", ShaderInfo)\n+\t\ttbl.material = urlmaterial\n+\t\t\t\t\t\n+\t\tif queuesize == 0 then\n+\t\t\ttimer.Create(\"EGP_URLMaterialChecker\",1,0,function() EGP:CheckURLDownloads() end)\n+\t\tend\n+\t\t\n+\t\tEGP.LoadingURLQueue[queuesize + 1] = {Material = urlmaterial, Url = url}\n+\tend\n+end\n+\n function EGP:ReceiveMaterial( tbl ) -- ALWAYS use this when receiving material","path":"lua/entities/gmod_wire_egp/lib/egplib/usefulfunctions.lua","position":108,"original_position":108,"commit_id":"78c75902f30e64f7575b6315f7f9a9f7c2353a87","original_commit_id":"78c75902f30e64f7575b6315f7f9a9f7c2353a87","user":{"login":"thegrb93","id":6713261,"avatar_url":"https://avatars.githubusercontent.com/u/6713261?v=3","gravatar_id":"","url":"https://api.github.com/users/thegrb93","html_url":"https://github.com/thegrb93","followers_url":"https://api.github.com/users/thegrb93/followers","following_url":"https://api.github.com/users/thegrb93/following{/other_user}","gists_url":"https://api.github.com/users/thegrb93/gists{/gist_id}","starred_url":"https://api.github.com/users/thegrb93/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thegrb93/subscriptions","organizations_url":"https://api.github.com/users/thegrb93/orgs","repos_url":"https://api.github.com/users/thegrb93/repos","events_url":"https://api.github.com/users/thegrb93/events{/privacy}","received_events_url":"https://api.github.com/users/thegrb93/received_events","type":"User","site_admin":false},"body":"I need the EGP passed to this function.","created_at":"2015-02-21T17:17:48Z","updated_at":"2015-02-21T17:17:48Z","html_url":"https://github.com/wiremod/wire/pull/790#discussion_r25123698","pull_request_url":"https://api.github.com/repos/wiremod/wire/pulls/790","_links":{"self":{"href":"https://api.github.com/repos/wiremod/wire/pulls/comments/25123698"},"html":{"href":"https://github.com/wiremod/wire/pull/790#discussion_r25123698"},"pull_request":{"href":"https://api.github.com/repos/wiremod/wire/pulls/790"}}},"pull_request":{"url":"https://api.github.com/repos/wiremod/wire/pulls/790","id":27585159,"html_url":"https://github.com/wiremod/wire/pull/790","diff_url":"https://github.com/wiremod/wire/pull/790.diff","patch_url":"https://github.com/wiremod/wire/pull/790.patch","issue_url":"https://api.github.com/repos/wiremod/wire/issues/790","number":790,"state":"open","locked":false,"title":"Expression2 EGP allow setMaterial to use urls","user":{"login":"thegrb93","id":6713261,"avatar_url":"https://avatars.githubusercontent.com/u/6713261?v=3","gravatar_id":"","url":"https://api.github.com/users/thegrb93","html_url":"https://github.com/thegrb93","followers_url":"https://api.github.com/users/thegrb93/followers","following_url":"https://api.github.com/users/thegrb93/following{/other_user}","gists_url":"https://api.github.com/users/thegrb93/gists{/gist_id}","starred_url":"https://api.github.com/users/thegrb93/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thegrb93/subscriptions","organizations_url":"https://api.github.com/users/thegrb93/orgs","repos_url":"https://api.github.com/users/thegrb93/repos","events_url":"https://api.github.com/users/thegrb93/events{/privacy}","received_events_url":"https://api.github.com/users/thegrb93/received_events","type":"User","site_admin":false},"body":"This is almost finished but I need to find a way to update the EGP when the online image finishes loading. Also I need a way to clean unused materials and limit them so it doesn't use up gpu memory.\r\n\r\nIf anyone can help me with this I'd appreciate it.","created_at":"2015-01-19T04:57:19Z","updated_at":"2015-02-21T17:17:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9d08f7806acf50db0c094f8e89300fb6a7e71ec2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wiremod/wire/pulls/790/commits","review_comments_url":"https://api.github.com/repos/wiremod/wire/pulls/790/comments","review_comment_url":"https://api.github.com/repos/wiremod/wire/pulls/comments/{number}","comments_url":"https://api.github.com/repos/wiremod/wire/issues/790/comments","statuses_url":"https://api.github.com/repos/wiremod/wire/statuses/78c75902f30e64f7575b6315f7f9a9f7c2353a87","head":{"label":"thegrb93:expression2_setMaterialrl","ref":"expression2_setMaterialrl","sha":"78c75902f30e64f7575b6315f7f9a9f7c2353a87","user":{"login":"thegrb93","id":6713261,"avatar_url":"https://avatars.githubusercontent.com/u/6713261?v=3","gravatar_id":"","url":"https://api.github.com/users/thegrb93","html_url":"https://github.com/thegrb93","followers_url":"https://api.github.com/users/thegrb93/followers","following_url":"https://api.github.com/users/thegrb93/following{/other_user}","gists_url":"https://api.github.com/users/thegrb93/gists{/gist_id}","starred_url":"https://api.github.com/users/thegrb93/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thegrb93/subscriptions","organizations_url":"https://api.github.com/users/thegrb93/orgs","repos_url":"https://api.github.com/users/thegrb93/repos","events_url":"https://api.github.com/users/thegrb93/events{/privacy}","received_events_url":"https://api.github.com/users/thegrb93/received_events","type":"User","site_admin":false},"repo":{"id":20392467,"name":"wire","full_name":"thegrb93/wire","owner":{"login":"thegrb93","id":6713261,"avatar_url":"https://avatars.githubusercontent.com/u/6713261?v=3","gravatar_id":"","url":"https://api.github.com/users/thegrb93","html_url":"https://github.com/thegrb93","followers_url":"https://api.github.com/users/thegrb93/followers","following_url":"https://api.github.com/users/thegrb93/following{/other_user}","gists_url":"https://api.github.com/users/thegrb93/gists{/gist_id}","starred_url":"https://api.github.com/users/thegrb93/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thegrb93/subscriptions","organizations_url":"https://api.github.com/users/thegrb93/orgs","repos_url":"https://api.github.com/users/thegrb93/repos","events_url":"https://api.github.com/users/thegrb93/events{/privacy}","received_events_url":"https://api.github.com/users/thegrb93/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/thegrb93/wire","description":"Garry's Mod add-on that allows users to wire up components in order to make more elaborate automatic and user-controlled contraptions.","fork":true,"url":"https://api.github.com/repos/thegrb93/wire","forks_url":"https://api.github.com/repos/thegrb93/wire/forks","keys_url":"https://api.github.com/repos/thegrb93/wire/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thegrb93/wire/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thegrb93/wire/teams","hooks_url":"https://api.github.com/repos/thegrb93/wire/hooks","issue_events_url":"https://api.github.com/repos/thegrb93/wire/issues/events{/number}","events_url":"https://api.github.com/repos/thegrb93/wire/events","assignees_url":"https://api.github.com/repos/thegrb93/wire/assignees{/user}","branches_url":"https://api.github.com/repos/thegrb93/wire/branches{/branch}","tags_url":"https://api.github.com/repos/thegrb93/wire/tags","blobs_url":"https://api.github.com/repos/thegrb93/wire/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thegrb93/wire/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thegrb93/wire/git/refs{/sha}","trees_url":"https://api.github.com/repos/thegrb93/wire/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thegrb93/wire/statuses/{sha}","languages_url":"https://api.github.com/repos/thegrb93/wire/languages","stargazers_url":"https://api.github.com/repos/thegrb93/wire/stargazers","contributors_url":"https://api.github.com/repos/thegrb93/wire/contributors","subscribers_url":"https://api.github.com/repos/thegrb93/wire/subscribers","subscription_url":"https://api.github.com/repos/thegrb93/wire/subscription","commits_url":"https://api.github.com/repos/thegrb93/wire/commits{/sha}","git_commits_url":"https://api.github.com/repos/thegrb93/wire/git/commits{/sha}","comments_url":"https://api.github.com/repos/thegrb93/wire/comments{/number}","issue_comment_url":"https://api.github.com/repos/thegrb93/wire/issues/comments/{number}","contents_url":"https://api.github.com/repos/thegrb93/wire/contents/{+path}","compare_url":"https://api.github.com/repos/thegrb93/wire/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thegrb93/wire/merges","archive_url":"https://api.github.com/repos/thegrb93/wire/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thegrb93/wire/downloads","issues_url":"https://api.github.com/repos/thegrb93/wire/issues{/number}","pulls_url":"https://api.github.com/repos/thegrb93/wire/pulls{/number}","milestones_url":"https://api.github.com/repos/thegrb93/wire/milestones{/number}","notifications_url":"https://api.github.com/repos/thegrb93/wire/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thegrb93/wire/labels{/name}","releases_url":"https://api.github.com/repos/thegrb93/wire/releases{/id}","created_at":"2014-06-02T03:39:21Z","updated_at":"2015-02-18T03:41:47Z","pushed_at":"2015-02-21T10:55:14Z","git_url":"git://github.com/thegrb93/wire.git","ssh_url":"git@github.com:thegrb93/wire.git","clone_url":"https://github.com/thegrb93/wire.git","svn_url":"https://github.com/thegrb93/wire","homepage":"http://www.wiremod.com","size":17506,"stargazers_count":0,"watchers_count":0,"language":"Lua","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"wiremod:master","ref":"master","sha":"7d14ee761cc1c6b39cb6b510af230af6bc9f3215","user":{"login":"wiremod","id":113164,"avatar_url":"https://avatars.githubusercontent.com/u/113164?v=3","gravatar_id":"","url":"https://api.github.com/users/wiremod","html_url":"https://github.com/wiremod","followers_url":"https://api.github.com/users/wiremod/followers","following_url":"https://api.github.com/users/wiremod/following{/other_user}","gists_url":"https://api.github.com/users/wiremod/gists{/gist_id}","starred_url":"https://api.github.com/users/wiremod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wiremod/subscriptions","organizations_url":"https://api.github.com/users/wiremod/orgs","repos_url":"https://api.github.com/users/wiremod/repos","events_url":"https://api.github.com/users/wiremod/events{/privacy}","received_events_url":"https://api.github.com/users/wiremod/received_events","type":"Organization","site_admin":false},"repo":{"id":4248640,"name":"wire","full_name":"wiremod/wire","owner":{"login":"wiremod","id":113164,"avatar_url":"https://avatars.githubusercontent.com/u/113164?v=3","gravatar_id":"","url":"https://api.github.com/users/wiremod","html_url":"https://github.com/wiremod","followers_url":"https://api.github.com/users/wiremod/followers","following_url":"https://api.github.com/users/wiremod/following{/other_user}","gists_url":"https://api.github.com/users/wiremod/gists{/gist_id}","starred_url":"https://api.github.com/users/wiremod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wiremod/subscriptions","organizations_url":"https://api.github.com/users/wiremod/orgs","repos_url":"https://api.github.com/users/wiremod/repos","events_url":"https://api.github.com/users/wiremod/events{/privacy}","received_events_url":"https://api.github.com/users/wiremod/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wiremod/wire","description":"Garry's Mod add-on that allows users to wire up components in order to make more elaborate automatic and user-controlled contraptions.","fork":false,"url":"https://api.github.com/repos/wiremod/wire","forks_url":"https://api.github.com/repos/wiremod/wire/forks","keys_url":"https://api.github.com/repos/wiremod/wire/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wiremod/wire/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wiremod/wire/teams","hooks_url":"https://api.github.com/repos/wiremod/wire/hooks","issue_events_url":"https://api.github.com/repos/wiremod/wire/issues/events{/number}","events_url":"https://api.github.com/repos/wiremod/wire/events","assignees_url":"https://api.github.com/repos/wiremod/wire/assignees{/user}","branches_url":"https://api.github.com/repos/wiremod/wire/branches{/branch}","tags_url":"https://api.github.com/repos/wiremod/wire/tags","blobs_url":"https://api.github.com/repos/wiremod/wire/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wiremod/wire/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wiremod/wire/git/refs{/sha}","trees_url":"https://api.github.com/repos/wiremod/wire/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wiremod/wire/statuses/{sha}","languages_url":"https://api.github.com/repos/wiremod/wire/languages","stargazers_url":"https://api.github.com/repos/wiremod/wire/stargazers","contributors_url":"https://api.github.com/repos/wiremod/wire/contributors","subscribers_url":"https://api.github.com/repos/wiremod/wire/subscribers","subscription_url":"https://api.github.com/repos/wiremod/wire/subscription","commits_url":"https://api.github.com/repos/wiremod/wire/commits{/sha}","git_commits_url":"https://api.github.com/repos/wiremod/wire/git/commits{/sha}","comments_url":"https://api.github.com/repos/wiremod/wire/comments{/number}","issue_comment_url":"https://api.github.com/repos/wiremod/wire/issues/comments/{number}","contents_url":"https://api.github.com/repos/wiremod/wire/contents/{+path}","compare_url":"https://api.github.com/repos/wiremod/wire/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wiremod/wire/merges","archive_url":"https://api.github.com/repos/wiremod/wire/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wiremod/wire/downloads","issues_url":"https://api.github.com/repos/wiremod/wire/issues{/number}","pulls_url":"https://api.github.com/repos/wiremod/wire/pulls{/number}","milestones_url":"https://api.github.com/repos/wiremod/wire/milestones{/number}","notifications_url":"https://api.github.com/repos/wiremod/wire/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wiremod/wire/labels{/name}","releases_url":"https://api.github.com/repos/wiremod/wire/releases{/id}","created_at":"2012-05-07T10:55:50Z","updated_at":"2015-02-21T17:06:04Z","pushed_at":"2015-02-21T17:06:01Z","git_url":"git://github.com/wiremod/wire.git","ssh_url":"git@github.com:wiremod/wire.git","clone_url":"https://github.com/wiremod/wire.git","svn_url":"https://github.com/wiremod/wire","homepage":"http://www.wiremod.com","size":26494,"stargazers_count":188,"watchers_count":188,"language":"Lua","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":214,"mirror_url":null,"open_issues_count":41,"forks":214,"open_issues":41,"watchers":188,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wiremod/wire/pulls/790"},"html":{"href":"https://github.com/wiremod/wire/pull/790"},"issue":{"href":"https://api.github.com/repos/wiremod/wire/issues/790"},"comments":{"href":"https://api.github.com/repos/wiremod/wire/issues/790/comments"},"review_comments":{"href":"https://api.github.com/repos/wiremod/wire/pulls/790/comments"},"review_comment":{"href":"https://api.github.com/repos/wiremod/wire/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/wiremod/wire/pulls/790/commits"},"statuses":{"href":"https://api.github.com/repos/wiremod/wire/statuses/78c75902f30e64f7575b6315f7f9a9f7c2353a87"}}}}