From df293f80cf292cc2d6eb3cd68ff199e59d1d3fe1 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Wed, 25 Jul 2018 15:08:54 +0100 Subject: [PATCH] Added ExpGamingPlayer.playerInfo --- .../{player-info.lua => control.lua} | 43 ++++++++++++------- .../ExpGamingPlayer/playerInfo/softmod.json | 18 ++++++++ .../ExpGamingPlayer/playerList/control.lua | 11 +++-- 3 files changed, 51 insertions(+), 21 deletions(-) rename modules/ExpGamingPlayer/playerInfo/{player-info.lua => control.lua} (52%) create mode 100644 modules/ExpGamingPlayer/playerInfo/softmod.json diff --git a/modules/ExpGamingPlayer/playerInfo/player-info.lua b/modules/ExpGamingPlayer/playerInfo/control.lua similarity index 52% rename from modules/ExpGamingPlayer/playerInfo/player-info.lua rename to modules/ExpGamingPlayer/playerInfo/control.lua index 465a8a21..1455d4ea 100644 --- a/modules/ExpGamingPlayer/playerInfo/player-info.lua +++ b/modules/ExpGamingPlayer/playerInfo/control.lua @@ -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 \ No newline at end of file +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 +}) \ No newline at end of file diff --git a/modules/ExpGamingPlayer/playerInfo/softmod.json b/modules/ExpGamingPlayer/playerInfo/softmod.json new file mode 100644 index 00000000..98efebf6 --- /dev/null +++ b/modules/ExpGamingPlayer/playerInfo/softmod.json @@ -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": "", + "keywords": [ + "Cam", + "Follow", + "Player", + "Info", + "Useful" + ], + "author": "", + "contact": "", + "license": "", + "dependencies": {} +} \ No newline at end of file diff --git a/modules/ExpGamingPlayer/playerList/control.lua b/modules/ExpGamingPlayer/playerList/control.lua index 53f682d7..bf9bc889 100644 --- a/modules/ExpGamingPlayer/playerList/control.lua +++ b/modules/ExpGamingPlayer/playerList/control.lua @@ -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 } \ No newline at end of file