Merge branch 'core' into testing

This commit is contained in:
Cooldude2606
2018-05-14 19:48:19 +01:00
5 changed files with 69 additions and 6 deletions

28
.github/ISSUE_TEMPLATE/Bug_report.md vendored Normal file
View File

@@ -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.

View File

@@ -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.

View File

@@ -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

View File

@@ -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, 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

View File

@@ -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}
@@ -17,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(tick)}
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
@@ -145,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
@@ -161,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,
@@ -222,9 +229,20 @@ 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
--- 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
Sync_updates[key] = callback
end
--- outputs the curent server info into a file
-- @usage Sync.emit_data()
function Sync.emit_data()