{"action":"created","comment":{"url":"https://api.github.com/repos/pioneerspacesim/pioneer/pulls/comments/31874155","id":31874155,"diff_hunk":"@@ -0,0 +1,20 @@\n+-- Public Functions\n+\n+-- spawn pirates\n+function SpawnPirate(name,risk) \n+\tlocal shipdef = shipdefs[Engine.rand:Integer(1,#shipdefs)]\n+\tlocal default_drive = Equipment.hyperspace['hyperdrive_'..tostring(shipdef.hyperdriveClass)]\n+\n+\tlocal max_laser_size = shipdef.capacity - default_drive.capabilities.mass\n+\tlocal laserdefs = utils.build_array(utils.filter(\n+\t\tfunction (k,l) return l:IsValidSlot('laser_front') and l.capabilities.mass <= max_laser_size and l.l10n_key:find(\"PULSECANNON\") end,\n+\t\t\tpairs(Equipment.laser)\n+\t\t))\n+\tlocal laserdef = laserdefs[Engine.rand:Integer(1,#laserdefs)]\n+\n+\tname = Space.SpawnShipNear(shipdef.id, Game.player, 50, 100)\n+\tname:SetLabel(Ship.MakeRandomLabel())\n+\tname:AddEquip(default_drive)\n+\tname:AddEquip(laserdef)\n+","path":"data/libs/PublicFunctions.lua","position":19,"original_position":19,"commit_id":"4fde72368e100f2a72b48e58ecbe712a451c49e9","original_commit_id":"4fde72368e100f2a72b48e58ecbe712a451c49e9","user":{"login":"prestotron","id":5394574,"avatar_url":"https://avatars.githubusercontent.com/u/5394574?v=3","gravatar_id":"","url":"https://api.github.com/users/prestotron","html_url":"https://github.com/prestotron","followers_url":"https://api.github.com/users/prestotron/followers","following_url":"https://api.github.com/users/prestotron/following{/other_user}","gists_url":"https://api.github.com/users/prestotron/gists{/gist_id}","starred_url":"https://api.github.com/users/prestotron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prestotron/subscriptions","organizations_url":"https://api.github.com/users/prestotron/orgs","repos_url":"https://api.github.com/users/prestotron/repos","events_url":"https://api.github.com/users/prestotron/events{/privacy}","received_events_url":"https://api.github.com/users/prestotron/received_events","type":"User","site_admin":false},"body":"Well, I called it name because in some cases it was \"pirate\" and most other cases it was \"ship\", so I left it flexible.","created_at":"2015-06-07T05:49:20Z","updated_at":"2015-06-07T05:49:20Z","html_url":"https://github.com/pioneerspacesim/pioneer/pull/3403#discussion_r31874155","pull_request_url":"https://api.github.com/repos/pioneerspacesim/pioneer/pulls/3403","_links":{"self":{"href":"https://api.github.com/repos/pioneerspacesim/pioneer/pulls/comments/31874155"},"html":{"href":"https://github.com/pioneerspacesim/pioneer/pull/3403#discussion_r31874155"},"pull_request":{"href":"https://api.github.com/repos/pioneerspacesim/pioneer/pulls/3403"}}},"pull_request":{"url":"https://api.github.com/repos/pioneerspacesim/pioneer/pulls/3403","id":37095652,"html_url":"https://github.com/pioneerspacesim/pioneer/pull/3403","diff_url":"https://github.com/pioneerspacesim/pioneer/pull/3403.diff","patch_url":"https://github.com/pioneerspacesim/pioneer/pull/3403.patch","issue_url":"https://api.github.com/repos/pioneerspacesim/pioneer/issues/3403","number":3403,"state":"open","locked":false,"title":"SpawnPirate() Function","user":{"login":"prestotron","id":5394574,"avatar_url":"https://avatars.githubusercontent.com/u/5394574?v=3","gravatar_id":"","url":"https://api.github.com/users/prestotron","html_url":"https://github.com/prestotron","followers_url":"https://api.github.com/users/prestotron/followers","following_url":"https://api.github.com/users/prestotron/following{/other_user}","gists_url":"https://api.github.com/users/prestotron/gists{/gist_id}","starred_url":"https://api.github.com/users/prestotron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prestotron/subscriptions","organizations_url":"https://api.github.com/users/prestotron/orgs","repos_url":"https://api.github.com/users/prestotron/repos","events_url":"https://api.github.com/users/prestotron/events{/privacy}","received_events_url":"https://api.github.com/users/prestotron/received_events","type":"User","site_admin":false},"body":"I was chatting with impaktor on the IRC to see what could be done for missions, so s/he recommended that I make a function to spawn pirates rather than continue to copy and paste it, so I made a file in /data/libs/ called PublicFunctions.lua which has a SpawnPirate() function to spawn pirates rather than copying and pasting everytime.\r\n\r\n(The missions Taxi, DeliverPackage and CargoRun use this function currently, so if you need an example on how to use the function, check it out)\r\n\r\nSeems like a good idea, eh?\r\n\r\nAlso, my IRC name is prestotron, I plan on changing my GitHub name to prestotron soon as well. Just letting you all know :) (My GitHub name may have changed already)","created_at":"2015-06-06T19:47:20Z","updated_at":"2015-06-07T05:49:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"27bcb310a0c3290f44a4f8e8ee0e88f36286570f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pioneerspacesim/pioneer/pulls/3403/commits","review_comments_url":"https://api.github.com/repos/pioneerspacesim/pioneer/pulls/3403/comments","review_comment_url":"https://api.github.com/repos/pioneerspacesim/pioneer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pioneerspacesim/pioneer/issues/3403/comments","statuses_url":"https://api.github.com/repos/pioneerspacesim/pioneer/statuses/4fde72368e100f2a72b48e58ecbe712a451c49e9","head":{"label":"prestotron:master","ref":"master","sha":"4fde72368e100f2a72b48e58ecbe712a451c49e9","user":{"login":"prestotron","id":5394574,"avatar_url":"https://avatars.githubusercontent.com/u/5394574?v=3","gravatar_id":"","url":"https://api.github.com/users/prestotron","html_url":"https://github.com/prestotron","followers_url":"https://api.github.com/users/prestotron/followers","following_url":"https://api.github.com/users/prestotron/following{/other_user}","gists_url":"https://api.github.com/users/prestotron/gists{/gist_id}","starred_url":"https://api.github.com/users/prestotron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prestotron/subscriptions","organizations_url":"https://api.github.com/users/prestotron/orgs","repos_url":"https://api.github.com/users/prestotron/repos","events_url":"https://api.github.com/users/prestotron/events{/privacy}","received_events_url":"https://api.github.com/users/prestotron/received_events","type":"User","site_admin":false},"repo":{"id":36990198,"name":"pioneer","full_name":"prestotron/pioneer","owner":{"login":"prestotron","id":5394574,"avatar_url":"https://avatars.githubusercontent.com/u/5394574?v=3","gravatar_id":"","url":"https://api.github.com/users/prestotron","html_url":"https://github.com/prestotron","followers_url":"https://api.github.com/users/prestotron/followers","following_url":"https://api.github.com/users/prestotron/following{/other_user}","gists_url":"https://api.github.com/users/prestotron/gists{/gist_id}","starred_url":"https://api.github.com/users/prestotron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prestotron/subscriptions","organizations_url":"https://api.github.com/users/prestotron/orgs","repos_url":"https://api.github.com/users/prestotron/repos","events_url":"https://api.github.com/users/prestotron/events{/privacy}","received_events_url":"https://api.github.com/users/prestotron/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/prestotron/pioneer","description":"A game of lonely space adventure","fork":true,"url":"https://api.github.com/repos/prestotron/pioneer","forks_url":"https://api.github.com/repos/prestotron/pioneer/forks","keys_url":"https://api.github.com/repos/prestotron/pioneer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prestotron/pioneer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prestotron/pioneer/teams","hooks_url":"https://api.github.com/repos/prestotron/pioneer/hooks","issue_events_url":"https://api.github.com/repos/prestotron/pioneer/issues/events{/number}","events_url":"https://api.github.com/repos/prestotron/pioneer/events","assignees_url":"https://api.github.com/repos/prestotron/pioneer/assignees{/user}","branches_url":"https://api.github.com/repos/prestotron/pioneer/branches{/branch}","tags_url":"https://api.github.com/repos/prestotron/pioneer/tags","blobs_url":"https://api.github.com/repos/prestotron/pioneer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prestotron/pioneer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prestotron/pioneer/git/refs{/sha}","trees_url":"https://api.github.com/repos/prestotron/pioneer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prestotron/pioneer/statuses/{sha}","languages_url":"https://api.github.com/repos/prestotron/pioneer/languages","stargazers_url":"https://api.github.com/repos/prestotron/pioneer/stargazers","contributors_url":"https://api.github.com/repos/prestotron/pioneer/contributors","subscribers_url":"https://api.github.com/repos/prestotron/pioneer/subscribers","subscription_url":"https://api.github.com/repos/prestotron/pioneer/subscription","commits_url":"https://api.github.com/repos/prestotron/pioneer/commits{/sha}","git_commits_url":"https://api.github.com/repos/prestotron/pioneer/git/commits{/sha}","comments_url":"https://api.github.com/repos/prestotron/pioneer/comments{/number}","issue_comment_url":"https://api.github.com/repos/prestotron/pioneer/issues/comments{/number}","contents_url":"https://api.github.com/repos/prestotron/pioneer/contents/{+path}","compare_url":"https://api.github.com/repos/prestotron/pioneer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prestotron/pioneer/merges","archive_url":"https://api.github.com/repos/prestotron/pioneer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prestotron/pioneer/downloads","issues_url":"https://api.github.com/repos/prestotron/pioneer/issues{/number}","pulls_url":"https://api.github.com/repos/prestotron/pioneer/pulls{/number}","milestones_url":"https://api.github.com/repos/prestotron/pioneer/milestones{/number}","notifications_url":"https://api.github.com/repos/prestotron/pioneer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prestotron/pioneer/labels{/name}","releases_url":"https://api.github.com/repos/prestotron/pioneer/releases{/id}","created_at":"2015-06-06T18:12:47Z","updated_at":"2015-06-06T18:12:58Z","pushed_at":"2015-06-06T19:45:42Z","git_url":"git://github.com/prestotron/pioneer.git","ssh_url":"git@github.com:prestotron/pioneer.git","clone_url":"https://github.com/prestotron/pioneer.git","svn_url":"https://github.com/prestotron/pioneer","homepage":"http://pioneerspacesim.net/","size":1455097,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"pioneerspacesim:master","ref":"master","sha":"5d1cfdd23c5042d365c59b9289f4ee3b47001f86","user":{"login":"pioneerspacesim","id":719820,"avatar_url":"https://avatars.githubusercontent.com/u/719820?v=3","gravatar_id":"","url":"https://api.github.com/users/pioneerspacesim","html_url":"https://github.com/pioneerspacesim","followers_url":"https://api.github.com/users/pioneerspacesim/followers","following_url":"https://api.github.com/users/pioneerspacesim/following{/other_user}","gists_url":"https://api.github.com/users/pioneerspacesim/gists{/gist_id}","starred_url":"https://api.github.com/users/pioneerspacesim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pioneerspacesim/subscriptions","organizations_url":"https://api.github.com/users/pioneerspacesim/orgs","repos_url":"https://api.github.com/users/pioneerspacesim/repos","events_url":"https://api.github.com/users/pioneerspacesim/events{/privacy}","received_events_url":"https://api.github.com/users/pioneerspacesim/received_events","type":"Organization","site_admin":false},"repo":{"id":1593053,"name":"pioneer","full_name":"pioneerspacesim/pioneer","owner":{"login":"pioneerspacesim","id":719820,"avatar_url":"https://avatars.githubusercontent.com/u/719820?v=3","gravatar_id":"","url":"https://api.github.com/users/pioneerspacesim","html_url":"https://github.com/pioneerspacesim","followers_url":"https://api.github.com/users/pioneerspacesim/followers","following_url":"https://api.github.com/users/pioneerspacesim/following{/other_user}","gists_url":"https://api.github.com/users/pioneerspacesim/gists{/gist_id}","starred_url":"https://api.github.com/users/pioneerspacesim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pioneerspacesim/subscriptions","organizations_url":"https://api.github.com/users/pioneerspacesim/orgs","repos_url":"https://api.github.com/users/pioneerspacesim/repos","events_url":"https://api.github.com/users/pioneerspacesim/events{/privacy}","received_events_url":"https://api.github.com/users/pioneerspacesim/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pioneerspacesim/pioneer","description":"A game of lonely space adventure","fork":false,"url":"https://api.github.com/repos/pioneerspacesim/pioneer","forks_url":"https://api.github.com/repos/pioneerspacesim/pioneer/forks","keys_url":"https://api.github.com/repos/pioneerspacesim/pioneer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pioneerspacesim/pioneer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pioneerspacesim/pioneer/teams","hooks_url":"https://api.github.com/repos/pioneerspacesim/pioneer/hooks","issue_events_url":"https://api.github.com/repos/pioneerspacesim/pioneer/issues/events{/number}","events_url":"https://api.github.com/repos/pioneerspacesim/pioneer/events","assignees_url":"https://api.github.com/repos/pioneerspacesim/pioneer/assignees{/user}","branches_url":"https://api.github.com/repos/pioneerspacesim/pioneer/branches{/branch}","tags_url":"https://api.github.com/repos/pioneerspacesim/pioneer/tags","blobs_url":"https://api.github.com/repos/pioneerspacesim/pioneer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pioneerspacesim/pioneer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pioneerspacesim/pioneer/git/refs{/sha}","trees_url":"https://api.github.com/repos/pioneerspacesim/pioneer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pioneerspacesim/pioneer/statuses/{sha}","languages_url":"https://api.github.com/repos/pioneerspacesim/pioneer/languages","stargazers_url":"https://api.github.com/repos/pioneerspacesim/pioneer/stargazers","contributors_url":"https://api.github.com/repos/pioneerspacesim/pioneer/contributors","subscribers_url":"https://api.github.com/repos/pioneerspacesim/pioneer/subscribers","subscription_url":"https://api.github.com/repos/pioneerspacesim/pioneer/subscription","commits_url":"https://api.github.com/repos/pioneerspacesim/pioneer/commits{/sha}","git_commits_url":"https://api.github.com/repos/pioneerspacesim/pioneer/git/commits{/sha}","comments_url":"https://api.github.com/repos/pioneerspacesim/pioneer/comments{/number}","issue_comment_url":"https://api.github.com/repos/pioneerspacesim/pioneer/issues/comments{/number}","contents_url":"https://api.github.com/repos/pioneerspacesim/pioneer/contents/{+path}","compare_url":"https://api.github.com/repos/pioneerspacesim/pioneer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pioneerspacesim/pioneer/merges","archive_url":"https://api.github.com/repos/pioneerspacesim/pioneer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pioneerspacesim/pioneer/downloads","issues_url":"https://api.github.com/repos/pioneerspacesim/pioneer/issues{/number}","pulls_url":"https://api.github.com/repos/pioneerspacesim/pioneer/pulls{/number}","milestones_url":"https://api.github.com/repos/pioneerspacesim/pioneer/milestones{/number}","notifications_url":"https://api.github.com/repos/pioneerspacesim/pioneer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pioneerspacesim/pioneer/labels{/name}","releases_url":"https://api.github.com/repos/pioneerspacesim/pioneer/releases{/id}","created_at":"2011-04-09T22:17:05Z","updated_at":"2015-05-27T18:16:11Z","pushed_at":"2015-06-06T19:47:22Z","git_url":"git://github.com/pioneerspacesim/pioneer.git","ssh_url":"git@github.com:pioneerspacesim/pioneer.git","clone_url":"https://github.com/pioneerspacesim/pioneer.git","svn_url":"https://github.com/pioneerspacesim/pioneer","homepage":"http://pioneerspacesim.net/","size":1455097,"stargazers_count":453,"watchers_count":453,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":202,"mirror_url":null,"open_issues_count":313,"forks":202,"open_issues":313,"watchers":453,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pioneerspacesim/pioneer/pulls/3403"},"html":{"href":"https://github.com/pioneerspacesim/pioneer/pull/3403"},"issue":{"href":"https://api.github.com/repos/pioneerspacesim/pioneer/issues/3403"},"comments":{"href":"https://api.github.com/repos/pioneerspacesim/pioneer/issues/3403/comments"},"review_comments":{"href":"https://api.github.com/repos/pioneerspacesim/pioneer/pulls/3403/comments"},"review_comment":{"href":"https://api.github.com/repos/pioneerspacesim/pioneer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pioneerspacesim/pioneer/pulls/3403/commits"},"statuses":{"href":"https://api.github.com/repos/pioneerspacesim/pioneer/statuses/4fde72368e100f2a72b48e58ecbe712a451c49e9"}}}}