From 596199eb3fc7af8915ec5e35966715a44601e86a Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 26 Apr 2018 16:24:49 +0100 Subject: [PATCH 1/6] Added Sync.add_update --- ExpCore/ranking.lua | 2 +- ExpCore/sync.lua | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ExpCore/ranking.lua b/ExpCore/ranking.lua index 3617ed5f..e0a3cf87 100644 --- a/ExpCore/ranking.lua +++ b/ExpCore/ranking.lua @@ -131,7 +131,7 @@ function Ranking.give_rank(player,rank,by_player,tick) if old_rank.name == rank.name then return end if rank.power < old_rank.power then message = 'ranking.rank-up' player.play_sound{path='utility/achievement_unlocked'} else player.play_sound{path='utility/game_lost'} end - game.print({message,player.name,rank.name,by_player_name},print_colour) + if player.online_time > 60 or by_player_name ~= 'server' then game.print({message,player.name,rank.name,by_player_name},print_colour) end if rank.group.name ~= 'User' then player_return({'ranking.rank-given',rank.name},print_colour,player) end if player.tag ~= old_rank.tag then player_return({'ranking.tag-reset'},print_colour,player) end -- rank change diff --git a/ExpCore/sync.lua b/ExpCore/sync.lua index fc04e588..2a529af0 100644 --- a/ExpCore/sync.lua +++ b/ExpCore/sync.lua @@ -10,6 +10,7 @@ Discord: https://discord.gg/r6dC2uK -- this file is used to allow easy syncing with out side programes local Sync = {} local Sync_gui_functions = {} +local Sync_updates = {} --- Used as a faster way to get to the ranking function, overrides previous -- @usage Sync.set_ranks{name=rank_name} @@ -222,9 +223,16 @@ function Sync.update() } info.ranks = Sync.count_ranks() info.rockets = game.forces['player'].get_item_launched('satellite') + for key,callback in pairs(Sync_updates) do info[key] = callback() end return info end +function Sync.add_update(key,callback) + if game then return end + if not is_type(callback,'function') then return end + Sync_updates[key] = callback +end + --- outputs the curent server info into a file -- @usage Sync.emit_data() function Sync.emit_data() From fd4b85857b378ec89de53e2308ccaca84362ae32 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 26 Apr 2018 16:46:07 +0100 Subject: [PATCH 2/6] Added Sync.tick_format --- ExpCore/sync.lua | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ExpCore/sync.lua b/ExpCore/sync.lua index 2a529af0..067c5ccb 100644 --- a/ExpCore/sync.lua +++ b/ExpCore/sync.lua @@ -18,6 +18,12 @@ function Sync.set_ranks(...) Ranking._base_preset(...) end +--- Used to standidise the tick format for any sync info +-- @usage Sync.tick_format(60) -- return {60,'1.00M'} +function Sync.tick_format(tick) + return {tick,tick_to_display_format(18000)} +end + --- Prints to chat as if it were a player -- @usage Sync.print('Test','Cooldude2606') -- @param player_message the message to be printed in chat @@ -146,7 +152,7 @@ function Sync.count_player_times() if not game then return {'Offline'} end local _players = {} for index,player in pairs(game.players) do - _players[player.name] = {player.online_time,tick_to_display_format(player.online_time)} + _players[player.name] = Sync.tick_format(player.online_time) end return _players end @@ -162,9 +168,9 @@ function Sync.info(set) server_description='A factorio server for everyone', reset_time='On Demand', time='Day Mth 00 00:00:00 UTC Year', - time_set={0,tick_to_display_format(0)}, - last_update={0,tick_to_display_format(0)}, - time_period={18000,tick_to_display_format(18000)}, + time_set=Sync.tick_format(0), + last_update=Sync.tick_format(0), + time_period=Sync.tick_format(18000), players={ online=Sync.count_players(true), n_online=#game.connected_players, @@ -227,6 +233,10 @@ function Sync.update() return info end +--- Adds a callback to be called when the info is updated +-- @usage Sync.add_update('players',function() return #game.players end) +-- @tparam key string the key that the value will be stored in +-- @tparam callback function the function which will return this value function Sync.add_update(key,callback) if game then return end if not is_type(callback,'function') then return end From 6a7f270f90a845baf84b975259bf36db345613b9 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 26 Apr 2018 17:58:40 +0100 Subject: [PATCH 3/6] Fixed Sync.tick_format --- ExpCore/sync.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ExpCore/sync.lua b/ExpCore/sync.lua index 067c5ccb..3e148464 100644 --- a/ExpCore/sync.lua +++ b/ExpCore/sync.lua @@ -21,7 +21,7 @@ end --- Used to standidise the tick format for any sync info -- @usage Sync.tick_format(60) -- return {60,'1.00M'} function Sync.tick_format(tick) - return {tick,tick_to_display_format(18000)} + return {tick,tick_to_display_format(tick)} end --- Prints to chat as if it were a player From d4fd9d53ef5bfcc096c91c4174268e624ad04d4d Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 8 May 2018 16:51:08 +0100 Subject: [PATCH 4/6] Some Git files that were auto added --- .github/ISSUE_TEMPLATE/Bug_report.md | 28 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/Feature_request.md | 17 ++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/Bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/Feature_request.md diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md new file mode 100644 index 00000000..519efb41 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Bug_report.md @@ -0,0 +1,28 @@ +--- +name: Bug report +about: Create a report to help us improve + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Other information (please complete the following information):** + - OS: [e.g. iOS, Windows, Linux] + - Factorio Version [e.g. 0.16.30] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/Feature_request.md b/.github/ISSUE_TEMPLATE/Feature_request.md new file mode 100644 index 00000000..066b2d92 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Feature_request.md @@ -0,0 +1,17 @@ +--- +name: Feature request +about: Suggest an idea for this project + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. From fcced7d95e5697b0dcce56bb5ee83ad8578bc598 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Sun, 13 May 2018 12:24:48 +0100 Subject: [PATCH 5/6] Added position ot /interface --- ExpCore/server.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ExpCore/server.lua b/ExpCore/server.lua index 3f43de5c..f72a6888 100644 --- a/ExpCore/server.lua +++ b/ExpCore/server.lua @@ -197,7 +197,7 @@ if commands._expgaming then commands.add_command('interface', 'Runs the given input from the script', {'code',true}, function(event,args) local callback = args.code if not string.find(callback,'%s') and not string.find(callback,'return') then callback = 'return '..callback end - if game.player then callback = 'local player, surface, force, entity = game.player, game.player.surface, game.player.force, game.player.selected;'..callback end + if game.player then callback = 'local player, surface, force, entity, position = game.player, game.player.surface, game.player.force, game.player.selected, game.player.position;'..callback end if Ranking and Ranking.get_rank and game.player then callback = 'local rank = Ranking.get_rank(game.player);'..callback end local success, err = Server.interface(callback) if not success and is_type(err,'string') then local _end = string.find(err,'stack traceback') if _end then err = string.sub(err,0,_end-2) end end From 33eab7334b22cb16e894f10a0b1049adb14b8280 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Sun, 13 May 2018 12:26:35 +0100 Subject: [PATCH 6/6] Added Tile to /interface --- ExpCore/server.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ExpCore/server.lua b/ExpCore/server.lua index f72a6888..7a07df0c 100644 --- a/ExpCore/server.lua +++ b/ExpCore/server.lua @@ -197,7 +197,7 @@ if commands._expgaming then commands.add_command('interface', 'Runs the given input from the script', {'code',true}, function(event,args) local callback = args.code if not string.find(callback,'%s') and not string.find(callback,'return') then callback = 'return '..callback end - if game.player then callback = 'local player, surface, force, entity, position = game.player, game.player.surface, game.player.force, game.player.selected, game.player.position;'..callback end + if game.player then callback = 'local player, surface, force, position, entity, tile = game.player, game.player.surface, game.player.force, game.player.position, game.player.selected, game.player.surface.get_tile(game.player.position);'..callback end if Ranking and Ranking.get_rank and game.player then callback = 'local rank = Ranking.get_rank(game.player);'..callback end local success, err = Server.interface(callback) if not success and is_type(err,'string') then local _end = string.find(err,'stack traceback') if _end then err = string.sub(err,0,_end-2) end end