Added ExpGamingPlayer.playerInfo

This commit is contained in:
Cooldude2606
2018-07-25 15:08:54 +01:00
parent 8e0ae8c2de
commit df293f80cf
3 changed files with 51 additions and 21 deletions

View File

@@ -1,14 +1,13 @@
--[[
Explosive Gaming
--- A full ranking system for factorio.
-- @module ExpGamingPlayer.playerInfo
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
This file can be used with permission but this and the credit below must remain in the file.
Contact a member of management on our discord to seek permission to use our code.
Any changes that you may make to the code are yours but that does not make the script yours.
Discord: https://discord.gg/r6dC2uK
]]
--Please Only Edit Below This Line-----------------------------------------------------------
local Game = require('FactorioStdLib.Game')
local Gui = require('ExpGamingCore.Gui')
local Ranking -- hanndled on load
function get_player_info(player,frame,add_cam)
local function get_player_info(player,frame,add_cam)
local player = Game.get_player(player)
if not player then return {} end
local _player = {}
@@ -19,22 +18,36 @@ function get_player_info(player,frame,add_cam)
_player.color = player.color
_player.admin = player.admin
_player.online_time = player.online_time
_player.rank = Ranking.get_rank(player).name
_player.group = Ranking.get_group(player).name
if Ranking then
_player.rank = Ranking.get_rank(player).name
_player.group = Ranking.get_group(player).name
end
if frame then
local frame = frame.add{type='frame',direction='vertical',style='image_frame'}
frame.style.width = 200
frame.style.height = 275
if Ranking then frame.style.height = 275
else frame.style.height = 260 end
frame.add{type='label',caption={'player-info.name',_player.index,_player.name},style='caption_label'}
local _online = {'player-info.no'}; if _player.online then _online = {'player-info.yes'} end
frame.add{type='label',caption={'player-info.online',_online,tick_to_display_format(_player.online_time)}}
local _admin = {'player-info.no'}; if _player.admin then _admin = {'player-info.yes'} end
frame.add{type='label',caption={'player-info.admin',_admin}}
frame.add{type='label',caption={'player-info.group',_player.group}}
frame.add{type='label',caption={'player-info.rank',_player.rank}}
if Ranking then
frame.add{type='label',caption={'player-info.group',_player.group}}
frame.add{type='label',caption={'player-info.rank',_player.rank}}
end
if add_cam then
Gui.cam_link{entity=player.character,frame=frame,width=200,height=150,zoom=0.5,respawn_open=true}
end
end
return _player
end
end
return setmetatable({
get_player_info=get_player_info,
on_init=function(self)
if loaded_modules['ExpGamingCore.Ranking'] then Ranking = require('ExpGamingCore.Ranking') end
end
},{
__call=function(self) self.get_player_info(...) end
})

View File

@@ -0,0 +1,18 @@
{
"name": "playerInfo",
"version": "4.0.0",
"type": "Module",
"description": "Used to give so common info on a player as a lua table or a frame.",
"location": "<blank>",
"keywords": [
"Cam",
"Follow",
"Player",
"Info",
"Useful"
],
"author": "<blank>",
"contact": "<blank>",
"license": "<blank>",
"dependencies": {}
}

View File

@@ -121,12 +121,11 @@ script.on_event(defines.events.on_player_joined_game,queue_update)
script.on_event(defines.events.on_player_left_game,queue_update)
script.on_event(defines.events.rank_change,queue_update)
function commands:on_init()
if loaded_modules['ExpGamingPlayer.playerInfo'] then playerInfo = require('ExpGamingPlayer.playerInfo') end
if loaded_modules['ExpGamingAdmin'] then Admin = require('ExpGamingAdmin') end
end
return {
force_update=function() return Gui.left.update('player-list') end,
update=queue_update
update=queue_update,
on_init=function(self)
if loaded_modules['ExpGamingPlayer.playerInfo'] then playerInfo = require('ExpGamingPlayer.playerInfo') end
if loaded_modules['ExpGamingAdmin'] then Admin = require('ExpGamingAdmin') end
end
}