{"action":"created","comment":{"url":"https://api.github.com/repos/Refactorio/RedMew/pulls/comments/241965438","pull_request_review_id":185372227,"id":241965438,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MTk2NTQzOA==","diff_hunk":"@@ -1,10 +1,30 @@\n local Token = require 'utils.token'\n local Event = require 'utils.event'\n local Game = require 'utils.game'\n+local Global = require 'utils.global'\n+local table = require 'utils.table'\n \n local Gui = {}\n \n-global.Gui_data = {}\n+local data = {}\n+local top_elements = {}\n+\n+Global.register(\n+    {\n+        data = data,\n+        top_elements = top_elements\n+    },\n+    function(tbl)\n+        data = tbl.data\n+        top_elements = tbl.top_elements\n+    end\n+)\n+\n+local on_visable_event_id = script.generate_event_name()\n+local on_pre_hidden_event_id = script.generate_event_name()","path":"utils/gui.lua","position":25,"original_position":25,"commit_id":"8bf193db70b44f8ad8732c5e92899ebdcc9cff07","original_commit_id":"8bf193db70b44f8ad8732c5e92899ebdcc9cff07","user":{"login":"stickler-ci[bot]","id":41810448,"node_id":"MDM6Qm90NDE4MTA0NDg=","avatar_url":"https://avatars3.githubusercontent.com/in/15299?v=4","gravatar_id":"","url":"https://api.github.com/users/stickler-ci%5Bbot%5D","html_url":"https://github.com/apps/stickler-ci","followers_url":"https://api.github.com/users/stickler-ci%5Bbot%5D/followers","following_url":"https://api.github.com/users/stickler-ci%5Bbot%5D/following{/other_user}","gists_url":"https://api.github.com/users/stickler-ci%5Bbot%5D/gists{/gist_id}","starred_url":"https://api.github.com/users/stickler-ci%5Bbot%5D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stickler-ci%5Bbot%5D/subscriptions","organizations_url":"https://api.github.com/users/stickler-ci%5Bbot%5D/orgs","repos_url":"https://api.github.com/users/stickler-ci%5Bbot%5D/repos","events_url":"https://api.github.com/users/stickler-ci%5Bbot%5D/events{/privacy}","received_events_url":"https://api.github.com/users/stickler-ci%5Bbot%5D/received_events","type":"Bot","site_admin":false},"body":"(W211) unused variable 'on_pre_hidden_event_id'","created_at":"2018-12-16T01:39:58Z","updated_at":"2018-12-16T01:39:58Z","html_url":"https://github.com/Refactorio/RedMew/pull/553#discussion_r241965438","pull_request_url":"https://api.github.com/repos/Refactorio/RedMew/pulls/553","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/Refactorio/RedMew/pulls/comments/241965438"},"html":{"href":"https://github.com/Refactorio/RedMew/pull/553#discussion_r241965438"},"pull_request":{"href":"https://api.github.com/repos/Refactorio/RedMew/pulls/553"}}},"pull_request":{"url":"https://api.github.com/repos/Refactorio/RedMew/pulls/553","id":238941720,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM4OTQxNzIw","html_url":"https://github.com/Refactorio/RedMew/pull/553","diff_url":"https://github.com/Refactorio/RedMew/pull/553.diff","patch_url":"https://github.com/Refactorio/RedMew/pull/553.patch","issue_url":"https://api.github.com/repos/Refactorio/RedMew/issues/553","number":553,"state":"open","locked":false,"title":"allow player to toggle top buttons visibility","user":{"login":"grilledham","id":10003572,"node_id":"MDQ6VXNlcjEwMDAzNTcy","avatar_url":"https://avatars3.githubusercontent.com/u/10003572?v=4","gravatar_id":"","url":"https://api.github.com/users/grilledham","html_url":"https://github.com/grilledham","followers_url":"https://api.github.com/users/grilledham/followers","following_url":"https://api.github.com/users/grilledham/following{/other_user}","gists_url":"https://api.github.com/users/grilledham/gists{/gist_id}","starred_url":"https://api.github.com/users/grilledham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grilledham/subscriptions","organizations_url":"https://api.github.com/users/grilledham/orgs","repos_url":"https://api.github.com/users/grilledham/repos","events_url":"https://api.github.com/users/grilledham/events{/privacy}","received_events_url":"https://api.github.com/users/grilledham/received_events","type":"User","site_admin":false},"body":"![image](https://user-images.githubusercontent.com/10003572/50048991-18294200-00d2-11e9-9a7c-61c332ad6476.png)\r\n\r\n![image](https://user-images.githubusercontent.com/10003572/50048993-1e1f2300-00d2-11e9-92c6-e6e8285ba2f0.png)\r\n\r\n![image](https://user-images.githubusercontent.com/10003572/50048994-24150400-00d2-11e9-9b88-b684365191f5.png)\r\n\r\nHow to use in code:\r\n1. Let Gui know that you want the button to be toggle-able by the player \r\n```lua\r\nGui.allow_player_to_toggle_top_element_visibility(element_name)\r\n```\r\nThat is all.\r\n\r\nIf you want to register a handler for when the button is toggled you can use\r\n```lua\r\nGui.on_player_show_top(element_name, handler)\r\nGui.on_pre_player_hide_top(element_name, handler)\r\n```\r\n\r\nI think I've registered all the top buttons.\r\n\r\nElements that are opened by the top buttons will remain open when the player hides the top buttons, like so\r\n\r\n![image](https://user-images.githubusercontent.com/10003572/50049037-1613b300-00d3-11e9-8e9e-226e441a273d.png)\r\n\r\n\r\nWe could use the callbacks above to control that.\r\n\r\n","created_at":"2018-12-16T01:39:46Z","updated_at":"2018-12-16T01:39:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"91d0c83b8c2527af4a44df4412fd27bf846e10ed","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Refactorio/RedMew/pulls/553/commits","review_comments_url":"https://api.github.com/repos/Refactorio/RedMew/pulls/553/comments","review_comment_url":"https://api.github.com/repos/Refactorio/RedMew/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Refactorio/RedMew/issues/553/comments","statuses_url":"https://api.github.com/repos/Refactorio/RedMew/statuses/8bf193db70b44f8ad8732c5e92899ebdcc9cff07","head":{"label":"grilledham:top_buttons_visibility","ref":"top_buttons_visibility","sha":"8bf193db70b44f8ad8732c5e92899ebdcc9cff07","user":{"login":"grilledham","id":10003572,"node_id":"MDQ6VXNlcjEwMDAzNTcy","avatar_url":"https://avatars3.githubusercontent.com/u/10003572?v=4","gravatar_id":"","url":"https://api.github.com/users/grilledham","html_url":"https://github.com/grilledham","followers_url":"https://api.github.com/users/grilledham/followers","following_url":"https://api.github.com/users/grilledham/following{/other_user}","gists_url":"https://api.github.com/users/grilledham/gists{/gist_id}","starred_url":"https://api.github.com/users/grilledham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grilledham/subscriptions","organizations_url":"https://api.github.com/users/grilledham/orgs","repos_url":"https://api.github.com/users/grilledham/repos","events_url":"https://api.github.com/users/grilledham/events{/privacy}","received_events_url":"https://api.github.com/users/grilledham/received_events","type":"User","site_admin":false},"repo":{"id":99452175,"node_id":"MDEwOlJlcG9zaXRvcnk5OTQ1MjE3NQ==","name":"RedMew","full_name":"grilledham/RedMew","private":false,"owner":{"login":"grilledham","id":10003572,"node_id":"MDQ6VXNlcjEwMDAzNTcy","avatar_url":"https://avatars3.githubusercontent.com/u/10003572?v=4","gravatar_id":"","url":"https://api.github.com/users/grilledham","html_url":"https://github.com/grilledham","followers_url":"https://api.github.com/users/grilledham/followers","following_url":"https://api.github.com/users/grilledham/following{/other_user}","gists_url":"https://api.github.com/users/grilledham/gists{/gist_id}","starred_url":"https://api.github.com/users/grilledham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grilledham/subscriptions","organizations_url":"https://api.github.com/users/grilledham/orgs","repos_url":"https://api.github.com/users/grilledham/repos","events_url":"https://api.github.com/users/grilledham/events{/privacy}","received_events_url":"https://api.github.com/users/grilledham/received_events","type":"User","site_admin":false},"html_url":"https://github.com/grilledham/RedMew","description":null,"fork":true,"url":"https://api.github.com/repos/grilledham/RedMew","forks_url":"https://api.github.com/repos/grilledham/RedMew/forks","keys_url":"https://api.github.com/repos/grilledham/RedMew/keys{/key_id}","collaborators_url":"https://api.github.com/repos/grilledham/RedMew/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/grilledham/RedMew/teams","hooks_url":"https://api.github.com/repos/grilledham/RedMew/hooks","issue_events_url":"https://api.github.com/repos/grilledham/RedMew/issues/events{/number}","events_url":"https://api.github.com/repos/grilledham/RedMew/events","assignees_url":"https://api.github.com/repos/grilledham/RedMew/assignees{/user}","branches_url":"https://api.github.com/repos/grilledham/RedMew/branches{/branch}","tags_url":"https://api.github.com/repos/grilledham/RedMew/tags","blobs_url":"https://api.github.com/repos/grilledham/RedMew/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/grilledham/RedMew/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/grilledham/RedMew/git/refs{/sha}","trees_url":"https://api.github.com/repos/grilledham/RedMew/git/trees{/sha}","statuses_url":"https://api.github.com/repos/grilledham/RedMew/statuses/{sha}","languages_url":"https://api.github.com/repos/grilledham/RedMew/languages","stargazers_url":"https://api.github.com/repos/grilledham/RedMew/stargazers","contributors_url":"https://api.github.com/repos/grilledham/RedMew/contributors","subscribers_url":"https://api.github.com/repos/grilledham/RedMew/subscribers","subscription_url":"https://api.github.com/repos/grilledham/RedMew/subscription","commits_url":"https://api.github.com/repos/grilledham/RedMew/commits{/sha}","git_commits_url":"https://api.github.com/repos/grilledham/RedMew/git/commits{/sha}","comments_url":"https://api.github.com/repos/grilledham/RedMew/comments{/number}","issue_comment_url":"https://api.github.com/repos/grilledham/RedMew/issues/comments{/number}","contents_url":"https://api.github.com/repos/grilledham/RedMew/contents/{+path}","compare_url":"https://api.github.com/repos/grilledham/RedMew/compare/{base}...{head}","merges_url":"https://api.github.com/repos/grilledham/RedMew/merges","archive_url":"https://api.github.com/repos/grilledham/RedMew/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/grilledham/RedMew/downloads","issues_url":"https://api.github.com/repos/grilledham/RedMew/issues{/number}","pulls_url":"https://api.github.com/repos/grilledham/RedMew/pulls{/number}","milestones_url":"https://api.github.com/repos/grilledham/RedMew/milestones{/number}","notifications_url":"https://api.github.com/repos/grilledham/RedMew/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/grilledham/RedMew/labels{/name}","releases_url":"https://api.github.com/repos/grilledham/RedMew/releases{/id}","deployments_url":"https://api.github.com/repos/grilledham/RedMew/deployments","created_at":"2017-08-05T23:00:06Z","updated_at":"2018-11-18T13:08:21Z","pushed_at":"2018-12-16T01:39:26Z","git_url":"git://github.com/grilledham/RedMew.git","ssh_url":"git@github.com:grilledham/RedMew.git","clone_url":"https://github.com/grilledham/RedMew.git","svn_url":"https://github.com/grilledham/RedMew","homepage":null,"size":73567,"stargazers_count":2,"watchers_count":2,"language":"Lua","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"Refactorio:develop","ref":"develop","sha":"edf50d24f7bcbcc43a825d8e873af47c6fe40c95","user":{"login":"Refactorio","id":45128763,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ1MTI4NzYz","avatar_url":"https://avatars3.githubusercontent.com/u/45128763?v=4","gravatar_id":"","url":"https://api.github.com/users/Refactorio","html_url":"https://github.com/Refactorio","followers_url":"https://api.github.com/users/Refactorio/followers","following_url":"https://api.github.com/users/Refactorio/following{/other_user}","gists_url":"https://api.github.com/users/Refactorio/gists{/gist_id}","starred_url":"https://api.github.com/users/Refactorio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Refactorio/subscriptions","organizations_url":"https://api.github.com/users/Refactorio/orgs","repos_url":"https://api.github.com/users/Refactorio/repos","events_url":"https://api.github.com/users/Refactorio/events{/privacy}","received_events_url":"https://api.github.com/users/Refactorio/received_events","type":"Organization","site_admin":false},"repo":{"id":94204284,"node_id":"MDEwOlJlcG9zaXRvcnk5NDIwNDI4NA==","name":"RedMew","full_name":"Refactorio/RedMew","private":false,"owner":{"login":"Refactorio","id":45128763,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ1MTI4NzYz","avatar_url":"https://avatars3.githubusercontent.com/u/45128763?v=4","gravatar_id":"","url":"https://api.github.com/users/Refactorio","html_url":"https://github.com/Refactorio","followers_url":"https://api.github.com/users/Refactorio/followers","following_url":"https://api.github.com/users/Refactorio/following{/other_user}","gists_url":"https://api.github.com/users/Refactorio/gists{/gist_id}","starred_url":"https://api.github.com/users/Refactorio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Refactorio/subscriptions","organizations_url":"https://api.github.com/users/Refactorio/orgs","repos_url":"https://api.github.com/users/Refactorio/repos","events_url":"https://api.github.com/users/Refactorio/events{/privacy}","received_events_url":"https://api.github.com/users/Refactorio/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Refactorio/RedMew","description":"The RedMew scenario code for Factorio.","fork":false,"url":"https://api.github.com/repos/Refactorio/RedMew","forks_url":"https://api.github.com/repos/Refactorio/RedMew/forks","keys_url":"https://api.github.com/repos/Refactorio/RedMew/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Refactorio/RedMew/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Refactorio/RedMew/teams","hooks_url":"https://api.github.com/repos/Refactorio/RedMew/hooks","issue_events_url":"https://api.github.com/repos/Refactorio/RedMew/issues/events{/number}","events_url":"https://api.github.com/repos/Refactorio/RedMew/events","assignees_url":"https://api.github.com/repos/Refactorio/RedMew/assignees{/user}","branches_url":"https://api.github.com/repos/Refactorio/RedMew/branches{/branch}","tags_url":"https://api.github.com/repos/Refactorio/RedMew/tags","blobs_url":"https://api.github.com/repos/Refactorio/RedMew/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Refactorio/RedMew/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Refactorio/RedMew/git/refs{/sha}","trees_url":"https://api.github.com/repos/Refactorio/RedMew/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Refactorio/RedMew/statuses/{sha}","languages_url":"https://api.github.com/repos/Refactorio/RedMew/languages","stargazers_url":"https://api.github.com/repos/Refactorio/RedMew/stargazers","contributors_url":"https://api.github.com/repos/Refactorio/RedMew/contributors","subscribers_url":"https://api.github.com/repos/Refactorio/RedMew/subscribers","subscription_url":"https://api.github.com/repos/Refactorio/RedMew/subscription","commits_url":"https://api.github.com/repos/Refactorio/RedMew/commits{/sha}","git_commits_url":"https://api.github.com/repos/Refactorio/RedMew/git/commits{/sha}","comments_url":"https://api.github.com/repos/Refactorio/RedMew/comments{/number}","issue_comment_url":"https://api.github.com/repos/Refactorio/RedMew/issues/comments{/number}","contents_url":"https://api.github.com/repos/Refactorio/RedMew/contents/{+path}","compare_url":"https://api.github.com/repos/Refactorio/RedMew/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Refactorio/RedMew/merges","archive_url":"https://api.github.com/repos/Refactorio/RedMew/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Refactorio/RedMew/downloads","issues_url":"https://api.github.com/repos/Refactorio/RedMew/issues{/number}","pulls_url":"https://api.github.com/repos/Refactorio/RedMew/pulls{/number}","milestones_url":"https://api.github.com/repos/Refactorio/RedMew/milestones{/number}","notifications_url":"https://api.github.com/repos/Refactorio/RedMew/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Refactorio/RedMew/labels{/name}","releases_url":"https://api.github.com/repos/Refactorio/RedMew/releases{/id}","deployments_url":"https://api.github.com/repos/Refactorio/RedMew/deployments","created_at":"2017-06-13T11:10:45Z","updated_at":"2018-12-15T20:31:23Z","pushed_at":"2018-12-16T01:39:46Z","git_url":"git://github.com/Refactorio/RedMew.git","ssh_url":"git@github.com:Refactorio/RedMew.git","clone_url":"https://github.com/Refactorio/RedMew.git","svn_url":"https://github.com/Refactorio/RedMew","homepage":"http://redmew.com","size":66413,"stargazers_count":78,"watchers_count":78,"language":"Lua","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":29,"mirror_url":null,"archived":false,"open_issues_count":47,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":29,"open_issues":47,"watchers":78,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/Refactorio/RedMew/pulls/553"},"html":{"href":"https://github.com/Refactorio/RedMew/pull/553"},"issue":{"href":"https://api.github.com/repos/Refactorio/RedMew/issues/553"},"comments":{"href":"https://api.github.com/repos/Refactorio/RedMew/issues/553/comments"},"review_comments":{"href":"https://api.github.com/repos/Refactorio/RedMew/pulls/553/comments"},"review_comment":{"href":"https://api.github.com/repos/Refactorio/RedMew/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Refactorio/RedMew/pulls/553/commits"},"statuses":{"href":"https://api.github.com/repos/Refactorio/RedMew/statuses/8bf193db70b44f8ad8732c5e92899ebdcc9cff07"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"stickler-ci"}}