Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerkiz committed Nov 13, 2023
1 parent 7e38c6c commit a3f2d9d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
10 changes: 5 additions & 5 deletions modules/show_inventory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ local function validate_player(player)
if not player.connected then
return false
end
if not game.players[player.index] then
if not game.get_player(player.index) then
return false
end
return true
Expand Down Expand Up @@ -331,7 +331,7 @@ local function open_inventory(source, target)
end

local function on_gui_click(event)
local player = game.players[event.player_index]
local player = game.get_player(event.player_index)
if not this.data[player.index] then
return
end
Expand Down Expand Up @@ -384,7 +384,7 @@ local function on_gui_click(event)
end
end
local function gui_closed(event)
local player = game.players[event.player_index]
local player = game.get_player(event.player_index)
if not this.data[player.index] then
return
end
Expand All @@ -401,7 +401,7 @@ local function gui_closed(event)
end

local function on_pre_player_left_game(event)
local player = game.players[event.player_index]
local player = game.get_player(event.player_index)
if not this.data[player.index] then
return
end
Expand Down Expand Up @@ -443,7 +443,7 @@ commands.add_command(
if not cmd.parameter then
return
end
local target_player = game.players[cmd.parameter]
local target_player = game.get_player(cmd.parameter)

if target_player == player and not player.admin then
return player.print('Cannot open self.', Color.warning)
Expand Down
2 changes: 1 addition & 1 deletion utils/gui/group.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ local this = {
['Production'] = {name = 'Production', founder = 'script', description = '[img=item/assembling-machine-1]', static = true},
['Science'] = {name = 'Science', founder = 'script', description = '[img=item/chemical-science-pack]', static = true},
['Trainman'] = {name = 'Trainman', founder = 'script', description = '[img=item/locomotive]', static = true},
['Oil processing'] = {name = 'processing', founder = 'script', description = '[img=fluid/crude-oil]', static = true},
['Oil processing'] = {name = 'Oil Processing', founder = 'script', description = '[img=fluid/crude-oil]', static = true},
['Trooper'] = {name = 'Trooper', founder = 'script', description = '[img=item/submachine-gun]', static = true},
['Fortifications'] = {name = 'Fortifications', founder = 'script', description = '[img=item/stone-wall]', static = true},
['Support'] = {name = 'Support', founder = 'script', description = '[img=item/repair-pack]', static = true}
Expand Down
8 changes: 7 additions & 1 deletion utils/gui/player_list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@ local function get_sorted_list(sort_by)
player_data.admin = player.admin
player_data.color = player.color
player_data.index = player.index
player_data.coins = player.get_inventory(defines.inventory.character_main).get_item_count('coin') or 0
local inventory = player.get_main_inventory()
if inventory and inventory.valid then
local player_item_count = inventory.get_item_count('coin')
player_data.coins = player_item_count
else
player_data.coins = 0
end

player_data.played_time = get_formatted_playtime(player.online_time)
player_data.played_ticks = player.online_time
Expand Down

0 comments on commit a3f2d9d

Please sign in to comment.