mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 04:21:41 +09:00
Added ExpGamingPlayer.playerInfo
This commit is contained in:
@@ -1,14 +1,13 @@
|
|||||||
--[[
|
--- A full ranking system for factorio.
|
||||||
Explosive Gaming
|
-- @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.
|
local Game = require('FactorioStdLib.Game')
|
||||||
Contact a member of management on our discord to seek permission to use our code.
|
local Gui = require('ExpGamingCore.Gui')
|
||||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
local Ranking -- hanndled on load
|
||||||
Discord: https://discord.gg/r6dC2uK
|
|
||||||
]]
|
|
||||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
|
||||||
|
|
||||||
function get_player_info(player,frame,add_cam)
|
local function get_player_info(player,frame,add_cam)
|
||||||
local player = Game.get_player(player)
|
local player = Game.get_player(player)
|
||||||
if not player then return {} end
|
if not player then return {} end
|
||||||
local _player = {}
|
local _player = {}
|
||||||
@@ -19,22 +18,36 @@ function get_player_info(player,frame,add_cam)
|
|||||||
_player.color = player.color
|
_player.color = player.color
|
||||||
_player.admin = player.admin
|
_player.admin = player.admin
|
||||||
_player.online_time = player.online_time
|
_player.online_time = player.online_time
|
||||||
_player.rank = Ranking.get_rank(player).name
|
if Ranking then
|
||||||
_player.group = Ranking.get_group(player).name
|
_player.rank = Ranking.get_rank(player).name
|
||||||
|
_player.group = Ranking.get_group(player).name
|
||||||
|
end
|
||||||
if frame then
|
if frame then
|
||||||
local frame = frame.add{type='frame',direction='vertical',style='image_frame'}
|
local frame = frame.add{type='frame',direction='vertical',style='image_frame'}
|
||||||
frame.style.width = 200
|
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'}
|
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
|
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)}}
|
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
|
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.admin',_admin}}
|
||||||
frame.add{type='label',caption={'player-info.group',_player.group}}
|
if Ranking then
|
||||||
frame.add{type='label',caption={'player-info.rank',_player.rank}}
|
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
|
if add_cam then
|
||||||
Gui.cam_link{entity=player.character,frame=frame,width=200,height=150,zoom=0.5,respawn_open=true}
|
Gui.cam_link{entity=player.character,frame=frame,width=200,height=150,zoom=0.5,respawn_open=true}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return _player
|
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
|
||||||
|
})
|
||||||
18
modules/ExpGamingPlayer/playerInfo/softmod.json
Normal file
18
modules/ExpGamingPlayer/playerInfo/softmod.json
Normal 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": {}
|
||||||
|
}
|
||||||
@@ -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.on_player_left_game,queue_update)
|
||||||
script.on_event(defines.events.rank_change,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 {
|
return {
|
||||||
force_update=function() return Gui.left.update('player-list') end,
|
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
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user