From 6432326b1b779680cac28a0133dcfce5e5dd65a5 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Sun, 26 May 2019 15:32:52 +0100
Subject: [PATCH 01/41] Minor bug fixes
---
config/{file_loader.lua => _file_loader.lua} | 10 +-
..._starting_items.lua => advanced_start.lua} | 0
config/config.cfg | 3 -
.../auth_admin.lua} | 0
.../auth_roles.lua} | 0
.../auth_runtime_disable.lua} | 0
.../parse_general.lua} | 0
.../parse_roles.lua} | 2 +-
control.lua | 2 +-
expcore/gui/left.lua | 2 +-
expcore/locale/de.cfg | 9 --
expcore/locale/en.cfg | 32 -------
expcore/locale/nl.cfg | 9 --
expcore/locale/sv-SE.cfg | 9 --
locale/en/commands.cfg | 94 +++++++++++--------
locale/en/expcore.cfg | 4 +-
...-starting-items.lua => advanced-start.lua} | 2 +-
modules/addons/random-player-colours.lua | 4 +-
modules/commands/admin-chat.lua | 4 +-
modules/commands/cheat-mode.lua | 2 +-
modules/commands/clear-inventory.lua | 2 +-
modules/commands/help.lua | 14 +--
modules/commands/jail.lua | 18 ++--
modules/commands/kill.lua | 6 +-
modules/commands/repair.lua | 4 +-
modules/commands/reports.lua | 24 ++---
modules/commands/roles.lua | 12 +--
modules/commands/spawn.lua | 6 +-
modules/commands/tag.lua | 4 +-
modules/commands/teleport.lua | 14 +--
modules/commands/warnings.lua | 12 +--
31 files changed, 130 insertions(+), 174 deletions(-)
rename config/{file_loader.lua => _file_loader.lua} (77%)
rename config/{advanced_starting_items.lua => advanced_start.lua} (100%)
delete mode 100644 config/config.cfg
rename config/{command_auth_admin.lua => expcore-commands/auth_admin.lua} (100%)
rename config/{command_auth_roles.lua => expcore-commands/auth_roles.lua} (100%)
rename config/{command_auth_runtime_disable.lua => expcore-commands/auth_runtime_disable.lua} (100%)
rename config/{command_parse_general.lua => expcore-commands/parse_general.lua} (100%)
rename config/{command_parse_roles.lua => expcore-commands/parse_roles.lua} (97%)
delete mode 100644 expcore/locale/de.cfg
delete mode 100644 expcore/locale/en.cfg
delete mode 100644 expcore/locale/nl.cfg
delete mode 100644 expcore/locale/sv-SE.cfg
rename modules/addons/{advanced-starting-items.lua => advanced-start.lua} (95%)
diff --git a/config/file_loader.lua b/config/_file_loader.lua
similarity index 77%
rename from config/file_loader.lua
rename to config/_file_loader.lua
index 744c058c..0c1b476c 100644
--- a/config/file_loader.lua
+++ b/config/_file_loader.lua
@@ -26,7 +26,7 @@ return {
'modules.addons.chat-popups',
'modules.addons.damage-popups',
'modules.addons.death-logger',
- 'modules.addons.advanced-starting-items',
+ 'modules.addons.advanced-start',
'modules.addons.spawn-area',
'modules.addons.compilatron',
'modules.addons.scorched-earth',
@@ -35,10 +35,10 @@ return {
-- GUI
'modules.commands.debug',
-- Config Files
- 'config.command_auth_admin', -- commands tagged with admin_only are blocked for non admins
- 'config.command_auth_roles', -- commands must be allowed via the role config
- 'config.command_auth_runtime_disable', -- allows commands to be enabled and disabled during runtime
+ 'config.expcore-commands.auth_admin', -- commands tagged with admin_only are blocked for non admins
+ 'config.expcore-commands.auth_roles', -- commands must be allowed via the role config
+ 'config.expcore-commands.auth_runtime_disable', -- allows commands to be enabled and disabled during runtime
'config.permission_groups', -- loads some predefined permission groups
'config.roles', -- loads some predefined roles
- 'expcore.gui.test'
+ 'expcore.gui.test' -- loads multiple gui defines to test the gui system
}
\ No newline at end of file
diff --git a/config/advanced_starting_items.lua b/config/advanced_start.lua
similarity index 100%
rename from config/advanced_starting_items.lua
rename to config/advanced_start.lua
diff --git a/config/config.cfg b/config/config.cfg
deleted file mode 100644
index b12b17cf..00000000
--- a/config/config.cfg
+++ /dev/null
@@ -1,3 +0,0 @@
-[command-auth]
-admin-only=This command is for (game) admins only!
-command-disabled=This command has been disabled by management!
\ No newline at end of file
diff --git a/config/command_auth_admin.lua b/config/expcore-commands/auth_admin.lua
similarity index 100%
rename from config/command_auth_admin.lua
rename to config/expcore-commands/auth_admin.lua
diff --git a/config/command_auth_roles.lua b/config/expcore-commands/auth_roles.lua
similarity index 100%
rename from config/command_auth_roles.lua
rename to config/expcore-commands/auth_roles.lua
diff --git a/config/command_auth_runtime_disable.lua b/config/expcore-commands/auth_runtime_disable.lua
similarity index 100%
rename from config/command_auth_runtime_disable.lua
rename to config/expcore-commands/auth_runtime_disable.lua
diff --git a/config/command_parse_general.lua b/config/expcore-commands/parse_general.lua
similarity index 100%
rename from config/command_parse_general.lua
rename to config/expcore-commands/parse_general.lua
diff --git a/config/command_parse_roles.lua b/config/expcore-commands/parse_roles.lua
similarity index 97%
rename from config/command_parse_roles.lua
rename to config/expcore-commands/parse_roles.lua
index efdf2a00..3d468aaf 100644
--- a/config/command_parse_roles.lua
+++ b/config/expcore-commands/parse_roles.lua
@@ -2,7 +2,7 @@
local Commands = require 'expcore.commands'
local Roles = require 'expcore.roles'
local auto_complete = ext_require('expcore.common','auto_complete')
-require 'config.command_parse_general'
+require 'config.expcore-commands.parse_general'
Commands.add_parse('role',function(input,player,reject)
if not input then return end
diff --git a/control.lua b/control.lua
index 48a4fbbc..e4ed6c3f 100644
--- a/control.lua
+++ b/control.lua
@@ -26,7 +26,7 @@ ext_require = require('expcore.common').ext_require
-- Please go to config/file_loader.lua to edit the files that are loaded
log('[INFO] Getting file loader config')
-local files = require 'config.file_loader'
+local files = require 'config._file_loader'
-- Loads all files from the config and logs that they are loaded
local total_file_count = string.format('%3d',#files)
diff --git a/expcore/gui/left.lua b/expcore/gui/left.lua
index da7f37e4..fb62761c 100644
--- a/expcore/gui/left.lua
+++ b/expcore/gui/left.lua
@@ -239,7 +239,7 @@ end
LeftFrames.toggle_button =
Buttons.new_button()
-:set_tooltip('Close Windows')
+:set_tooltip{'expcore-gui.left-button-tooltip'}
:set_caption('<')
:on_click(function(player,element)
for _,define in pairs(LeftFrames.frames) do
diff --git a/expcore/locale/de.cfg b/expcore/locale/de.cfg
deleted file mode 100644
index e872b325..00000000
--- a/expcore/locale/de.cfg
+++ /dev/null
@@ -1,9 +0,0 @@
-[expcore-commands]
-unauthorized=401 - Unbefugt: Zugang verweigert. Du hast keinen Zugriff auf diese Befehle!
-reject-number-range=ungültige Reichweite, Min: __1__, Max: __2__
-reject-string-max-length=ungültige Länge, Max: __1__
-reject-player=ungültiger Spieler Name, __1__ , Versuche "Tab" zu benutzen, damit sich der Name automatisch vervollständigt.
-reject-player-online=Der betroffene Spieler ist offline, Befehl konnte nicht ausgeführt werden.
-reject-player-alive=Der betroffene Spieler ist Tod, Befehl konnte nicht ausgeführt werden.
-invalid-inputs=ungültige Eingabe, /__1__ __2__
-command-ran=Befehl ausgeführt.
\ No newline at end of file
diff --git a/expcore/locale/en.cfg b/expcore/locale/en.cfg
deleted file mode 100644
index 931ce162..00000000
--- a/expcore/locale/en.cfg
+++ /dev/null
@@ -1,32 +0,0 @@
-time-symbol-days-short=__1__d
-
-[expcore-commands]
-unauthorized=Unauthorized, Access is denied due to invalid credentials
-reject-string-options=Invalid Option, Must be one of: __1__
-reject-string-max-length=Invalid Length, Max: __1__
-reject-number=Invalid Number.
-reject-number-range=Invalid Range, Min (inclusive): __1__, Max (inclusive): __2__
-reject-player=Invaild Player Name, __1__ ,try using tab key to auto-complete the name
-reject-player-online=Player is offline.
-reject-player-alive=Player is dead.
-reject-force=Invaild Force Name.
-reject-surface=Invaild Surface Name.
-invalid-inputs=Invalid Input, /__1__ __2__
-invalid-param=Invalid Param "__1__"; __2__
-command-help=__1__ - __2__
-command-ran=Command Complete
-command-fail=Command failed to run: __1__
-command-error-log-format=[ERROR] command/__1__ :: __2__
-
-[expcore-roles]
-error-log-format-flag=[ERROR] roleFlag/__1__ :: __2__
-error-log-format-promote=[ERROR] rolePromote/__1__ :: __2__
-game-message-assign=__1__ has been assigned to __2__ by __3__
-game-message-unassign=__1__ has been unassigned from __2__ by __3__
-reject-role=Invalid Role Name.
-reject-player-role=Player has a higher role.
-
-[gui_util]
-button_tooltip=Shows / hides the Toolbar Gui buttons.
-
-[expcore-gui]
diff --git a/expcore/locale/nl.cfg b/expcore/locale/nl.cfg
deleted file mode 100644
index 21e1ed58..00000000
--- a/expcore/locale/nl.cfg
+++ /dev/null
@@ -1,9 +0,0 @@
-[expcore-commands]
-unauthorized=401 - Onbevoegd: toegang wordt geweigerd vanwege ongeldige inloggegevens
-reject-number-range=Onjuiste radius, Min: __1__, Max: __2__
-reject-string-max-length=Onjuiste lengte, Max: __1__
-reject-player=Onjuiste naam, __1__ , probeer tab te gebruiken om de naam automatisch in te vullen
-reject-player-online=Speler is offline.
-reject-player-alive=Speler is dood.
-invalid-inputs=Onjuiste invoer, /__1__ __2__
-command-ran=Commando uitgevoerd.
diff --git a/expcore/locale/sv-SE.cfg b/expcore/locale/sv-SE.cfg
deleted file mode 100644
index 078b7f17..00000000
--- a/expcore/locale/sv-SE.cfg
+++ /dev/null
@@ -1,9 +0,0 @@
-[expcore-commands]
-unauthorized=401 - Otillåten: Tillgång nekas på grund av otillräcklig säkerhetsprövning.
-reject-number-range=Invalid räckvid, Min: __1__, Max: __2__
-reject-string-max-length=ogiltig längd, Max: __1__
-reject-player=Ogiltigt spelarnamn, __1__ , försök använda tab-tangenten för att auto-slutföra namn.
-reject-player-online=Spelare är offline. Kommando misslyckades med att köras.
-reject-player-alive=Spelare är död. Kommando misslyckades med att köras.
-invalid-inputs=Igiltig inmatning, /__1__ __2__
-command-ran=Kommandot slutfört
diff --git a/locale/en/commands.cfg b/locale/en/commands.cfg
index f987582c..12812c63 100644
--- a/locale/en/commands.cfg
+++ b/locale/en/commands.cfg
@@ -1,38 +1,56 @@
-[exp-commands]
-kill-already-dead=You are already dead.
-admin-chat-format=[Admin Chat] __1__: __2__
-tp-no-position-found=No position to teleport to was found, please try again later.
-tp-to-self=Player can not be teleported to themselves.
-chelp-title=Help results for "__1__":
-chelp-footer=[__1__ results found; page __2__ of __3__]
-chelp-format=/__1__ __2__ - __3__ __4__
-chelp-alias=Alias: __1__
-chelp-out-of-range=__1__ is an invalid page number.
-roles-higher-role=The role you tried to assign is higher than your highest.
-roles-list=All roles are: __1__
-roles-list-player=__1__ has: __2__
-roles-list-element=__1__, __2__
-jail-give=__1__ was jailed by __2__. Reason: __3__
-jail-remove=__1__ was unjailed by __2__.
-jail-already-jailed=__1__ is already in jail.
-jail-not-jailed=__1__ is not currently in jail.
-jail-temp-ban=__1__ was temp banned until next reset by __2__. Reason: __3__
-jail-temp-ban-clear=__1__ was cleared from temp banned by __2__.
-jail-not-temp-banned=__1__ is not currently temp banned.
-jail-already-banned=__1__ is already banned.
-report-player-immune=This player can not be reported.
-report-non-admin=__1__ was reported for __2__.
-report-admin=__1__ was reported by __2__ for __3__.
-report-already-reported=You can only report a player once, you can ask a moderator to clear this report.
-report-not-reported=The player had no reports on them.
-report-player-count-title=The following players have reports against them:
-report-player-report-title=__1__ has the following reports agasinst them:
-report-list=__1__: __2__
-report-removed=__1__ has one or more reports removed by __2__.
-warnings-received=__1__ recived a warning from __2__ for __3__.
-warnings-player=__1__ has __2__ warnings and __3__/__4__ script warnings.
-warnings-list-tilte=The following player have this many warnings (and this many script warnings):
-warnings-list=__1__: __2__ (__3__/__4__)
-warnings-cleared=__1__ had all they warnings cleared by __2__.
-spawn-unavailable=They was a problem getting you to spawn, please try again later.
-repair-result=__1__ entites were revived and __2__ were healed to max health.
\ No newline at end of file
+[expcom-kill]
+already-dead=You are already dead.
+
+[expcom-admin-chat]
+format=[Admin Chat] __1__: __2__
+
+[expcom-tp]
+no-position-found=No position to teleport to was found, please try again later.
+to-self=Player can not be teleported to themselves.
+
+[expcom-chelp]
+title=Help results for "__1__":
+footer=[__1__ results found; page __2__ of __3__]
+format=/__1__ __2__ - __3__ __4__
+alias=Alias: __1__
+out-of-range=__1__ is an invalid page number.
+
+[expcom-roles]
+higher-role=The role you tried to assign is higher than your highest.
+list=All roles are: __1__
+list-player=__1__ has: __2__
+list-element=__1__, __2__
+
+[expcom-jail]
+give=__1__ was jailed by __2__. Reason: __3__
+remove=__1__ was unjailed by __2__.
+already-jailed=__1__ is already in jail.
+not-jailed=__1__ is not currently in jail.
+temp-ban=__1__ was temp banned until next reset by __2__. Reason: __3__
+temp-ban-clear=__1__ was cleared from temp banned by __2__.
+not-temp-banned=__1__ is not currently temp banned.
+already-banned=__1__ is already banned.
+
+[expcom-report]
+player-immune=This player can not be reported.
+non-admin=__1__ was reported for __2__.
+admin=__1__ was reported by __2__ for __3__.
+already-reported=You can only report a player once, you can ask a moderator to clear this report.
+not-reported=The player had no reports on them.
+player-count-title=The following players have reports against them:
+player-report-title=__1__ has the following reports agasinst them:
+list=__1__: __2__
+removed=__1__ has one or more reports removed by __2__.
+
+[expcom-warnings]
+received=__1__ recived a warning from __2__ for __3__.
+player=__1__ has __2__ warnings and __3__/__4__ script warnings.
+list-tilte=The following player have this many warnings (and this many script warnings):
+list=__1__: __2__ (__3__/__4__)
+cleared=__1__ had all they warnings cleared by __2__.
+
+[expcom-spawn]
+unavailable=They was a problem getting you to spawn, please try again later.
+
+[expcom-repair]
+result=__1__ entites were revived and __2__ were healed to max health.
\ No newline at end of file
diff --git a/locale/en/expcore.cfg b/locale/en/expcore.cfg
index 931ce162..58830616 100644
--- a/locale/en/expcore.cfg
+++ b/locale/en/expcore.cfg
@@ -1,4 +1,5 @@
time-symbol-days-short=__1__d
+color-tag=[color=__1__]__2__[/color]
[expcore-commands]
unauthorized=Unauthorized, Access is denied due to invalid credentials
@@ -27,6 +28,7 @@ reject-role=Invalid Role Name.
reject-player-role=Player has a higher role.
[gui_util]
-button_tooltip=Shows / hides the Toolbar Gui buttons.
+button_tooltip=Shows/hides the toolbar.
[expcore-gui]
+left-button-tooltip=Hide all open windows.
\ No newline at end of file
diff --git a/modules/addons/advanced-starting-items.lua b/modules/addons/advanced-start.lua
similarity index 95%
rename from modules/addons/advanced-starting-items.lua
rename to modules/addons/advanced-start.lua
index f402e5dc..07ed9ddc 100644
--- a/modules/addons/advanced-starting-items.lua
+++ b/modules/addons/advanced-start.lua
@@ -1,7 +1,7 @@
--- Adds a better method of player starting items based on production levels.
local Event = require 'utils.event'
local Game = require 'utils.game'
-local config = require 'config.advanced_starting_items'
+local config = require 'config.advanced_start'
local items = config.items
Event.add(defines.events.on_player_created, function(event)
diff --git a/modules/addons/random-player-colours.lua b/modules/addons/random-player-colours.lua
index 0e347997..9c47f8be 100644
--- a/modules/addons/random-player-colours.lua
+++ b/modules/addons/random-player-colours.lua
@@ -9,15 +9,13 @@ Global.register(config,function(tbl)
config = tbl
end)
-local white = Colours.white
-local black = Colours.black
Event.add(defines.events.on_player_created,function(event)
local player = Game.get_player_by_index(event.player_index)
local color = 'white'
if config.players[player.name] then
color = config.players[player.name]
else
- while not config.disallow[color] do
+ while config.disallow[color] do
color = table.get_random_dictionary_entry(Colours,true)
end
color = Colours[color]
diff --git a/modules/commands/admin-chat.lua b/modules/commands/admin-chat.lua
index e9f32b50..f3038941 100644
--- a/modules/commands/admin-chat.lua
+++ b/modules/commands/admin-chat.lua
@@ -1,6 +1,6 @@
local Commands = require 'expcore.commands'
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
-require 'config.command_parse_general'
+require 'config.expcore-commands.parse_general'
Commands.new_command('admin-chat','Sends a message in chat that only admins can see.')
:add_param('message',false) -- the message to send in the admin chat
@@ -11,7 +11,7 @@ Commands.new_command('admin-chat','Sends a message in chat that only admins can
local player_name_colour = format_chat_player_name(player)
for _,return_player in pairs(game.connected_players) do
if return_player.admin then
- return_player.print{'exp-commands.admin-chat-format',player_name_colour,message}
+ return_player.print{'expcom-admin-chat.format',player_name_colour,message}
end
end
return Commands.success -- prevents command complete message from showing
diff --git a/modules/commands/cheat-mode.lua b/modules/commands/cheat-mode.lua
index 6aef5fca..ab40cb30 100644
--- a/modules/commands/cheat-mode.lua
+++ b/modules/commands/cheat-mode.lua
@@ -1,5 +1,5 @@
local Commands = require 'expcore.commands'
-require 'config.command_parse_general'
+require 'config.expcore-commands.parse_general'
Commands.new_command('toggle-cheat-mode','Toggles cheat mode for your player, or another player.')
:add_param('player',true,'player') -- player to toggle chest mode of, can be nil for self
diff --git a/modules/commands/clear-inventory.lua b/modules/commands/clear-inventory.lua
index 0b8a8d26..b33c3029 100644
--- a/modules/commands/clear-inventory.lua
+++ b/modules/commands/clear-inventory.lua
@@ -1,6 +1,6 @@
local Commands = require 'expcore.commands'
local move_items = ext_require('expcore.common','move_items')
-require 'config.command_parse_roles'
+require 'config.expcore-commands.parse_roles'
Commands.new_command('clear-inventory','Clears a players inventory')
:add_param('player',false,'player-role-alive')
diff --git a/modules/commands/help.lua b/modules/commands/help.lua
index 419a23ac..11d2c647 100644
--- a/modules/commands/help.lua
+++ b/modules/commands/help.lua
@@ -1,6 +1,6 @@
local Commands = require 'expcore.commands'
local Global = require 'utils.global'
-require 'config.command_parse_general'
+require 'config.expcore-commands.parse_general'
local results_per_page = 5
@@ -42,9 +42,9 @@ Commands.new_command('chelp','Searches for a keyword in all commands you are all
-- adds the new command to the page
page_count = page_count + 1
found = found + 1
- local alias_format = #command_data.aliases > 0 and {'exp-commands.chelp-alias',table.concat(command_data.aliases,', ')} or ''
+ local alias_format = #command_data.aliases > 0 and {'expcom-chelp.alias',table.concat(command_data.aliases,', ')} or ''
table.insert(pages[current_page],{
- 'exp-commands.chelp-format',
+ 'expcom-chelp.format',
command_data.name,
command_data.description,
command_data.help,
@@ -60,15 +60,15 @@ Commands.new_command('chelp','Searches for a keyword in all commands you are all
end
-- print the requested page
keyword = keyword == '' and '' or keyword
- Commands.print({'exp-commands.chelp-title',keyword},'cyan')
+ Commands.print({'expcom-chelp.title',keyword},'cyan')
if pages[page] then
for _,command in pairs(pages[page]) do
Commands.print(command)
end
- Commands.print({'exp-commands.chelp-footer',found,page,#pages},'cyan')
+ Commands.print({'expcom-chelp.footer',found,page,#pages},'cyan')
else
- Commands.print({'exp-commands.chelp-footer',found,page,#pages},'cyan')
- return Commands.error{'exp-commands.chelp-out-of-range',page}
+ Commands.print({'expcom-chelp.footer',found,page,#pages},'cyan')
+ return Commands.error{'expcom-chelp.out-of-range',page}
end
-- blocks command complete message
return Commands.success
diff --git a/modules/commands/jail.lua b/modules/commands/jail.lua
index 6a30789f..a5d7ae37 100644
--- a/modules/commands/jail.lua
+++ b/modules/commands/jail.lua
@@ -1,7 +1,7 @@
local Commands = require 'expcore.commands'
local JailControl = require 'modules.addons.jail-control'
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
-require 'config.command_parse_roles'
+require 'config.expcore-commands.parse_roles'
Commands.new_command('jail','Puts a player into jail and removes all other roles.')
:add_param('player',false,'player-role')
@@ -12,9 +12,9 @@ Commands.new_command('jail','Puts a player into jail and removes all other roles
local action_player_name_color = format_chat_player_name(action_player)
local by_player_name_color = format_chat_player_name(player)
if JailControl.jail_player(action_player,player.name) then
- game.print{'exp-commands.jail-give',action_player_name_color,by_player_name_color,reason}
+ game.print{'expcom-jail.give',action_player_name_color,by_player_name_color,reason}
else
- return Commands.error{'exp-commands.jail-already-jailed',action_player_name_color}
+ return Commands.error{'expcom-jail.already-jailed',action_player_name_color}
end
end)
@@ -26,9 +26,9 @@ Commands.new_command('unjail','Puts a player into jail and removes all other rol
local action_player_name_color = format_chat_player_name(action_player)
local by_player_name_color = format_chat_player_name(player)
if JailControl.unjail_player(action_player,player.name) then
- game.print{'exp-commands.jail-remove',action_player_name_color,by_player_name_color}
+ game.print{'expcom-jail.remove',action_player_name_color,by_player_name_color}
else
- return Commands.error{'exp-commands.jail-not-jailed',action_player_name_color}
+ return Commands.error{'expcom-jail.not-jailed',action_player_name_color}
end
end)
@@ -40,9 +40,9 @@ Commands.new_command('temp-ban','Temp bans a player until the next reset; this r
local action_player_name_color = format_chat_player_name(action_player)
local by_player_name_color = format_chat_player_name(player)
if JailControl.temp_ban_player(action_player,player.name,reason) then
- game.print{'exp-commands.jail-temp-ban',action_player_name_color,by_player_name_color,reason}
+ game.print{'expcom-jail.temp-ban',action_player_name_color,by_player_name_color,reason}
else
- return Commands.error{'exp-commands.jail-already-banned',action_player_name_color}
+ return Commands.error{'expcom-jail.already-banned',action_player_name_color}
end
end)
@@ -54,8 +54,8 @@ Commands.new_command('clear-temp-ban','Removes temp ban from a player; this will
local action_player_name_color = format_chat_player_name(action_player)
local by_player_name_color = format_chat_player_name(player)
if JailControl.clear_temp_ban_player(action_player,player.name) then
- game.print{'exp-commands.jail-temp-ban-clear',action_player_name_color,by_player_name_color}
+ game.print{'expcom-jail.temp-ban-clear',action_player_name_color,by_player_name_color}
else
- return Commands.error{'exp-commands.jail-not-temp-banned',action_player_name_color}
+ return Commands.error{'expcom-jail.not-temp-banned',action_player_name_color}
end
end)
\ No newline at end of file
diff --git a/modules/commands/kill.lua b/modules/commands/kill.lua
index 0c36e327..e0076165 100644
--- a/modules/commands/kill.lua
+++ b/modules/commands/kill.lua
@@ -1,7 +1,7 @@
local Commands = require 'expcore.commands'
local Roles = require 'expcore.roles'
-require 'config.command_parse_general'
-require 'config.command_parse_roles'
+require 'config.expcore-commands.parse_general'
+require 'config.expcore-commands.parse_roles'
Commands.new_command('kill','Kills yourself or another player.')
:add_param('player',true,'player-role-alive') -- the player to kill, must be alive to be valid
@@ -14,7 +14,7 @@ end}
:register(function(player,action_player,raw)
if not action_player then
-- can only be nil if no player given and the user is dead
- return Commands.error{'exp-commands.kill-already-dead'}
+ return Commands.error{'expcom-kill.already-dead'}
end
if player == action_player then
action_player.character.die()
diff --git a/modules/commands/repair.lua b/modules/commands/repair.lua
index 660ec6eb..e1644fb8 100644
--- a/modules/commands/repair.lua
+++ b/modules/commands/repair.lua
@@ -1,6 +1,6 @@
local Commands = require 'expcore.commands'
local config = require 'config.repair'
-require 'config.command_parse_general'
+require 'config.expcore-commands.parse_general'
local max_time_to_live = 4294967295 -- unit32 max
Commands.new_command('repair','Repairs entities on your force around you')
@@ -40,5 +40,5 @@ Commands.new_command('repair','Repairs entities on your force around you')
end
end
end
- return Commands.success{'exp-commands.repair-result',revive_count,heal_count}
+ return Commands.success{'expcom-repair.result',revive_count,heal_count}
end)
\ No newline at end of file
diff --git a/modules/commands/reports.lua b/modules/commands/reports.lua
index 3c57f533..98fec56d 100644
--- a/modules/commands/reports.lua
+++ b/modules/commands/reports.lua
@@ -2,14 +2,14 @@ local Roles = require 'expcore.roles'
local Commands = require 'expcore.commands'
local ReportsControl = require 'modules.addons.reports-control'
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
-require 'config.command_parse_general'
+require 'config.expcore-commands.parse_general'
Commands.new_command('report','Reports a player and notifies moderators')
:add_param('player',false,function(input,player,reject)
input = Commands.parse('player',input,player,reject)
if not input then return end
if Roles.player_has_flag(input,'report-immune') then
- return reject{'exp-commands.report-player-immune'}
+ return reject{'expcom-report.player-immune'}
else
return input
end
@@ -21,10 +21,10 @@ end)
local action_player_name_color = format_chat_player_name(action_player)
local by_player_name_color = format_chat_player_name(player)
if ReportsControl.report_player(action_player,reason,player.name) then
- game.print{'exp-commands.report-non-admin',action_player_name_color,reason}
- Roles.print_to_roles_higher('Trainee',{'exp-commands.report-admin',action_player_name_color,by_player_name_color,reason})
+ game.print{'expcom-report.non-admin',action_player_name_color,reason}
+ Roles.print_to_roles_higher('Trainee',{'expcom-report.admin',action_player_name_color,by_player_name_color,reason})
else
- return Commands.error{'exp-commands.report-already-reported'}
+ return Commands.error{'expcom-report.already-reported'}
end
end)
@@ -35,18 +35,18 @@ Commands.new_command('get-reports','Gets a list of all reports that a player has
if action_player then
local reports = ReportsControl.get_player_reports(action_player)
local action_player_name_color = format_chat_player_name(action_player)
- Commands.print{'exp-commands.report-player-report-title',action_player_name_color}
+ Commands.print{'expcom-report.player-report-title',action_player_name_color}
for player_name,reason in pairs(reports) do
local by_player_name_color = format_chat_player_name(player_name)
- Commands.print{'exp-commands.report-list',by_player_name_color,reason}
+ Commands.print{'expcom-report.list',by_player_name_color,reason}
end
else
local user_reports = ReportsControl.user_reports
- Commands.print{'exp-commands.report-player-count-title'}
+ Commands.print{'expcom-report.player-count-title'}
for player_name,reports in pairs(user_reports) do
local player_name_color = format_chat_player_name(player_name)
local report_count = ReportsControl.count_player_reports(player_name)
- Commands.print{'exp-commands.report-list',player_name_color,report_count}
+ Commands.print{'expcom-report.list',player_name_color,report_count}
end
end
end)
@@ -57,14 +57,14 @@ Commands.new_command('clear-reports','Clears all reports from a player or just t
:register(function(player,action_player,from_player,raw)
if from_player then
if not ReportsControl.remove_player_report(action_player,from_player.name) then
- return Commands.error{'exp-commands.report-not-reported'}
+ return Commands.error{'expcom-report.not-reported'}
end
else
if not ReportsControl.clear_player_reports(action_player) then
- return Commands.error{'exp-commands.report-not-reported'}
+ return Commands.error{'expcom-report.not-reported'}
end
end
local action_player_name_color = format_chat_player_name(action_player)
local by_player_name_color = format_chat_player_name(player)
- game.print{'exp-commands.report-removed',action_player_name_color,by_player_name_color}
+ game.print{'expcom-report.removed',action_player_name_color,by_player_name_color}
end)
\ No newline at end of file
diff --git a/modules/commands/roles.lua b/modules/commands/roles.lua
index c8b54f57..d9d3b6d4 100644
--- a/modules/commands/roles.lua
+++ b/modules/commands/roles.lua
@@ -16,7 +16,7 @@ Commands.new_command('assign-role','Assigns a role to a player')
if player_highest.index < role.index then
Roles.assign_player(action_player,role,player.name)
else
- return Commands.error{'exp-commands.roles-higher-role'}
+ return Commands.error{'expcom-roles.higher-role'}
end
end)
@@ -30,7 +30,7 @@ Commands.new_command('unassign-role','Unassigns a role from a player')
if player_highest.index < role.index then
Roles.unassign_player(action_player,role,player.name)
else
- return Commands.error{'exp-commands.roles-higher-role'}
+ return Commands.error{'expcom-roles.higher-role'}
end
end)
@@ -39,7 +39,7 @@ Commands.new_command('list-roles','Lists all roles in they correct order')
:add_alias('lsroles','roles')
:register(function(player,action_player,raw)
local roles = Roles.config.order
- local message = {'exp-commands.roles-list'}
+ local message = {'expcom-roles.list'}
if action_player then
roles = Roles.get_player_roles(action_player)
end
@@ -48,13 +48,13 @@ Commands.new_command('list-roles','Lists all roles in they correct order')
local colour = role.custom_color or Colours.white
local role_name = format_chat_colour_localized(role.name,colour)
if index == 1 then
- message = {'exp-commands.roles-list',role_name}
+ message = {'expcom-roles.list',role_name}
if action_player then
local player_name_colour = format_chat_player_name(action_player)
- message = {'exp-commands.roles-list-player',player_name_colour,role_name}
+ message = {'expcom-roles.list-player',player_name_colour,role_name}
end
else
- message = {'exp-commands.roles-list-element',message,role_name}
+ message = {'expcom-roles.list-element',message,role_name}
end
end
return Commands.success(message)
diff --git a/modules/commands/spawn.lua b/modules/commands/spawn.lua
index 9e27bfbf..cc1fe512 100644
--- a/modules/commands/spawn.lua
+++ b/modules/commands/spawn.lua
@@ -23,14 +23,14 @@ Commands.new_command('go-to-spawn','Teleport to spawn')
:add_alias('spawn','tp-spawn')
:register(function(player,action_player)
if not action_player then
- return Commands.error{'exp-commands.spawn-unavailable'}
+ return Commands.error{'expcom-spawn.unavailable'}
elseif action_player == player then
if not teleport(player) then
- return Commands.error{'exp-commands.spawn-unavailable'}
+ return Commands.error{'expcom-spawn.unavailable'}
end
elseif Roles.player_allowed(player,'command/go-to-spawn/always') then
if not teleport(action_player) then
- return Commands.error{'exp-commands.spawn-unavailable'}
+ return Commands.error{'expcom-spawn.unavailable'}
end
else
return Commands.error{'expcore-commands.unauthorized'}
diff --git a/modules/commands/tag.lua b/modules/commands/tag.lua
index 18c1f0e5..0c5e5cf4 100644
--- a/modules/commands/tag.lua
+++ b/modules/commands/tag.lua
@@ -1,7 +1,7 @@
local Commands = require 'expcore.commands'
local Roles = require 'expcore.roles'
-require 'config.command_parse_general'
-require 'config.command_parse_roles'
+require 'config.expcore-commands.parse_general'
+require 'config.expcore-commands.parse_roles'
Commands.new_command('tag','Sets your player tag.')
:add_param('tag',false,'string-max-length',20) -- new tag for your player max 20 char
diff --git a/modules/commands/teleport.lua b/modules/commands/teleport.lua
index e1fdd893..0f456c9e 100644
--- a/modules/commands/teleport.lua
+++ b/modules/commands/teleport.lua
@@ -1,5 +1,5 @@
local Commands = require 'expcore.commands'
-require 'config.command_parse_general'
+require 'config.expcore-commands.parse_general'
local function teleport(from_player,to_player)
local surface = to_player.surface
@@ -18,11 +18,11 @@ Commands.new_command('teleport','Teleports a player to another player.')
:register(function(player,from_player,to_player,raw)
if from_player.index == to_player.index then
-- return if attempting to teleport to self
- return Commands.error{'exp-commands.tp-to-self'}
+ return Commands.error{'expcom-tp.to-self'}
end
if not teleport(from_player,to_player) then
-- return if the teleport failed
- return Commands.error{'exp-commands.tp-no-position-found'}
+ return Commands.error{'expcom-tp.no-position-found'}
end
end)
@@ -32,11 +32,11 @@ Commands.new_command('bring','Teleports a player to you.')
:register(function(player,from_player,raw)
if from_player.index == player.index then
-- return if attempting to teleport to self
- return Commands.error{'exp-commands.tp-to-self'}
+ return Commands.error{'expcom-tp.to-self'}
end
if not teleport(from_player,player) then
-- return if the teleport failed
- return Commands.error{'exp-commands.tp-no-position-found'}
+ return Commands.error{'expcom-tp.no-position-found'}
end
end)
@@ -47,10 +47,10 @@ Commands.new_command('goto','Teleports you to a player.')
:register(function(player,to_player,raw)
if to_player.index == player.index then
-- return if attempting to teleport to self
- return Commands.error{'exp-commands.tp-to-self'}
+ return Commands.error{'expcom-tp.to-self'}
end
if not teleport(player,to_player) then
-- return if the teleport failed
- return Commands.error{'exp-commands.tp-no-position-found'}
+ return Commands.error{'expcom-tp.no-position-found'}
end
end)
\ No newline at end of file
diff --git a/modules/commands/warnings.lua b/modules/commands/warnings.lua
index ae3c9692..1a86e4bd 100644
--- a/modules/commands/warnings.lua
+++ b/modules/commands/warnings.lua
@@ -2,7 +2,7 @@ local Commands = require 'expcore.commands'
local WarningsControl = require 'modules.addons.warnings-control'
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
local config = require 'config.warnings'
-require 'config.command_parse_roles'
+require 'config.expcore-commands.parse_roles'
Commands.new_command('give-warning','Gives a warning to a player; may lead to automatic script action.')
:add_param('player',false,'player-role')
@@ -13,7 +13,7 @@ Commands.new_command('give-warning','Gives a warning to a player; may lead to au
WarningsControl.add_warnings(action_player,player.name)
local action_player_name_color = format_chat_player_name(action_player)
local by_player_name_color = format_chat_player_name(player)
- game.print{'exp-commands.warnings-received',action_player_name_color,by_player_name_color,reason}
+ game.print{'expcom-warnings.received',action_player_name_color,by_player_name_color,reason}
end)
Commands.new_command('get-warnings','Gets the number of warnings a player has. If no player then lists all players and the number of warnings they have.')
@@ -24,7 +24,7 @@ Commands.new_command('get-warnings','Gets the number of warnings a player has. I
local warnings = WarningsControl.get_warnings(action_player)
local script_warnings = WarningsControl.get_temp_warnings(action_player)
local action_player_name_color = format_chat_player_name(action_player)
- Commands.print{'exp-commands.warnings-player',action_player_name_color,warnings,script_warnings,config.temp_warning_limit}
+ Commands.print{'expcom-warnings.player',action_player_name_color,warnings,script_warnings,config.temp_warning_limit}
else
local rtn = {}
local user_warnings = WarningsControl.user_warnings
@@ -38,10 +38,10 @@ Commands.new_command('get-warnings','Gets the number of warnings a player has. I
end
rtn[player_name][2] = #warnings
end
- Commands.print{'exp-commands.warnings-list-tilte'}
+ Commands.print{'expcom-warnings.list-tilte'}
for player_name,warnings in pairs(rtn) do
local player_name_color = format_chat_player_name(player_name)
- Commands.print{'exp-commands.warnings-list',player_name_color,warnings[1],warnings[2],config.temp_warning_limit}
+ Commands.print{'expcom-warnings.list',player_name_color,warnings[1],warnings[2],config.temp_warning_limit}
end
end
end)
@@ -53,5 +53,5 @@ Commands.new_command('clear-warnings','Clears all warnings (and script warnings)
WarningsControl.clear_temp_warnings(action_player,player.name)
local action_player_name_color = format_chat_player_name(action_player)
local by_player_name_color = format_chat_player_name(player)
- game.print{'exp-commands.warnings-cleared',action_player_name_color,by_player_name_color}
+ game.print{'expcom-warnings.cleared',action_player_name_color,by_player_name_color}
end)
\ No newline at end of file
From aefdb80dee8d23bc3e902fb3fbd4d439adc15d77 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Sun, 26 May 2019 19:24:27 +0100
Subject: [PATCH 02/41] Added Player List
---
config/_file_loader.lua | 1 +
config/action_buttons.lua | 42 +++++++
config/roles.lua | 1 +
expcore/gui.lua | 4 +
expcore/gui/core.lua | 52 ++++++++
expcore/gui/left.lua | 13 +-
locale/en/expcore.cfg | 4 +
modules/gui/player-list.lua | 242 ++++++++++++++++++++++++++++++++++++
8 files changed, 357 insertions(+), 2 deletions(-)
create mode 100644 config/action_buttons.lua
create mode 100644 modules/gui/player-list.lua
diff --git a/config/_file_loader.lua b/config/_file_loader.lua
index 0c1b476c..24c135c7 100644
--- a/config/_file_loader.lua
+++ b/config/_file_loader.lua
@@ -33,6 +33,7 @@ return {
'modules.addons.pollution-grading',
'modules.addons.random-player-colours',
-- GUI
+ 'modules.gui.player-list',
'modules.commands.debug',
-- Config Files
'config.expcore-commands.auth_admin', -- commands tagged with admin_only are blocked for non admins
diff --git a/config/action_buttons.lua b/config/action_buttons.lua
new file mode 100644
index 00000000..402d6481
--- /dev/null
+++ b/config/action_buttons.lua
@@ -0,0 +1,42 @@
+local Gui = require 'expcore.gui'
+local Roles = require 'expcore.roles'
+local Store = require 'expcore.store'
+local Game = require 'utils.game'
+
+local action_player_store = 'gui.left.player-list.action-player'
+
+local function tool_button_style(style)
+ Gui.set_padding_style(style,-1,-1,-1,-1)
+ style.height = 28
+ style.width = 28
+end
+
+local function auth_lower_role(player,action_player)
+ local player_highest = Roles.get_player_highest_role(player)
+ local action_player_highest = Roles.get_player_highest_role(action_player)
+ if player_highest.index < action_player_highest.index then
+ return true
+ end
+end
+
+local function get_action_player(player)
+ local action_player_name = Store.get_child(action_player_store,player.name)
+ local action_player = Game.get_player_from_any(action_player_name)
+ return action_player
+end
+
+local report_player =
+Gui.new_button()
+:set_sprites('utility/warning')
+:set_tooltip('Report player')
+:set_style('tool_button',tool_button_style)
+:on_click(function(player,element)
+ local action_player = get_action_player(player)
+end)
+
+return {
+ ['command/report'] = {
+ auth=auth_lower_role,
+ report_player
+ }
+}
\ No newline at end of file
diff --git a/config/roles.lua b/config/roles.lua
index b1863ea7..6ea8ddc9 100644
--- a/config/roles.lua
+++ b/config/roles.lua
@@ -181,6 +181,7 @@ local default = Roles.new_role('Guest','')
'command/chelp',
'command/list-roles',
'command/report',
+ 'gui/player-list',
}
--- Jail role
diff --git a/expcore/gui.lua b/expcore/gui.lua
index 5831acf8..70f0ffc3 100644
--- a/expcore/gui.lua
+++ b/expcore/gui.lua
@@ -13,6 +13,8 @@ local Gui = require 'expcore.gui.core'
Gui._prototype:debug_name(name) --- Sets a debug alias for the define
Gui._prototype:set_caption(caption) --- Sets the caption for the element define
Gui._prototype:set_tooltip(tooltip) --- Sets the tooltip for the element define
+ Gui._prototype:set_style(style,callback) --- Sets the style for the element define
+ Gui._prototype:set_embeded_flow(state) --- Sets the element to be drawn inside a nameless flow, can be given a name using a function
Gui._prototype:on_element_update(callback) --- Add a hander to run on the general value update event, different classes will handle this event differently
Gui._prototype:set_pre_authenticator(callback) --- Sets an authenticator that blocks the draw function if check fails
@@ -34,6 +36,7 @@ local Gui = require 'expcore.gui.core'
Gui.toggle_enable(element) --- Will toggle the enabled state of an element
Gui.toggle_visible(element) --- Will toggle the visiblity of an element
+ Gui.set_padding(element,up,down,left,right) --- Sets the padding for a gui element
]]
local Instances = require 'expcore.gui.instances'
@@ -195,6 +198,7 @@ Gui.classes.left_frames = LeftFrames
LeftFrames.new_frame(permision_name) --- Creates a new left frame define
LeftFrames._prototype:set_open_by_default(state) --- Sets if the frame is visible when a player joins, can also be a function to return a boolean
+ LeftFrames._prototype:set_direction(direction) --- Sets the direction of the frame, either vertical or horizontal
LeftFrames._prototype:get_frame(player) --- Gets the frame for this define from the left frame flow
LeftFrames._prototype:is_open(player) --- Returns if the player currently has this define visible
LeftFrames._prototype:toggle(player) --- Toggles the visiblty of the left frame
diff --git a/expcore/gui/core.lua b/expcore/gui/core.lua
index 07d7e8f7..8eb407cf 100644
--- a/expcore/gui/core.lua
+++ b/expcore/gui/core.lua
@@ -128,6 +128,8 @@
Gui._prototype:debug_name(name) --- Sets a debug alias for the define
Gui._prototype:set_caption(caption) --- Sets the caption for the element define
Gui._prototype:set_tooltip(tooltip) --- Sets the tooltip for the element define
+ Gui._prototype:set_style(style,callback) --- Sets the style for the element define
+ Gui._prototype:set_embeded_flow(state) --- Sets the element to be drawn inside a nameless flow, can be given a name using a function
Gui._prototype:on_element_update(callback) --- Add a hander to run on the general value update event, different classes will handle this event differently
Gui._prototype:set_pre_authenticator(callback) --- Sets an authenticator that blocks the draw function if check fails
@@ -149,6 +151,8 @@
Gui.toggle_enable(element) --- Will toggle the enabled state of an element
Gui.toggle_visible(element) --- Will toggle the visiblity of an element
+ Gui.set_padding(element,up,down,left,right) --- Sets the padding for a gui element
+ Gui.set_padding_style(style,up,down,left,right) --- Sets the padding for a gui style
]]
local Gui = require 'utils.gui'
local Game = require 'utils.game'
@@ -316,6 +320,28 @@ function Gui._prototype:set_tooltip(tooltip)
return self
end
+--- Sets the style for the element define
+-- @tparam style string the style that will be used for this element when drawn
+-- @tapram[opt] callback function function is called when element is drawn to alter its style
+-- @treturn self the element define to allow chaining
+function Gui._prototype:set_style(style,callback)
+ self.draw_data.style = style
+ self.events.on_style = callback
+ return self
+end
+
+--- Sets the element to be drawn inside a nameless flow, can be given a name using a function
+-- @tparam state ?boolean|function when true a padless flow is created to contain the element
+-- @treturn self the element define to allow chaining
+function Gui._prototype:set_embeded_flow(state)
+ if state == false or type(state) == 'function' then
+ self.embeded_flow = state
+ else
+ self.embeded_flow = true
+ end
+ return self
+end
+
--- Sets an authenticator that blocks the draw function if check fails
-- @tparam callback function the function that will be ran to test if the element should be drawn or not
-- callback param - player LuaPlayer - the player that the element is being drawn to
@@ -358,8 +384,21 @@ function Gui._prototype:draw_to(element,...)
if not self.pre_authenticator(player,self.name) then return end
end
+ if self.embeded_flow then
+ local embeded_name
+ if type(self.embeded_flow) == 'function' then
+ embeded_name = self.embeded_flow(element,...)
+ end
+ element = element.add{type='flow',name=embeded_name}
+ Gui.set_padding(element)
+ end
+
local new_element = element.add(self.draw_data)
+ if self.events.on_style then
+ self.events.on_style(new_element.style)
+ end
+
if self.post_authenticator then
new_element.enabled = self.post_authenticator(player,self.name)
end
@@ -510,4 +549,17 @@ function Gui.set_padding(element,up,down,left,right)
style.right_padding = right or 0
end
+--- Sets the padding for a gui style
+-- @tparam element LuaStyle the element to set the padding for
+-- @tparam[opt=0] up number the amount of padding on the top
+-- @tparam[opt=0] down number the amount of padding on the bottom
+-- @tparam[opt=0] left number the amount of padding on the left
+-- @tparam[opt=0] right number the amount of padding on the right
+function Gui.set_padding_style(style,up,down,left,right)
+ style.top_padding = up or 0
+ style.bottom_padding = down or 0
+ style.left_padding = left or 0
+ style.right_padding = right or 0
+end
+
return Gui
\ No newline at end of file
diff --git a/expcore/gui/left.lua b/expcore/gui/left.lua
index fb62761c..63efb267 100644
--- a/expcore/gui/left.lua
+++ b/expcore/gui/left.lua
@@ -33,6 +33,7 @@
LeftFrames.new_frame(permision_name) --- Creates a new left frame define
LeftFrames._prototype:set_open_by_default(state) --- Sets if the frame is visible when a player joins, can also be a function to return a boolean
+ LeftFrames._prototype:set_direction(direction) --- Sets the direction of the frame, either vertical or horizontal
LeftFrames._prototype:get_frame(player) --- Gets the frame for this define from the left frame flow
LeftFrames._prototype:is_open(player) --- Returns if the player currently has this define visible
LeftFrames._prototype:toggle(player) --- Toggles the visiblty of the left frame
@@ -159,6 +160,13 @@ function LeftFrames._prototype:set_open_by_default(state)
return self
end
+--- Sets the direction of the frame, either vertical or horizontal
+-- @tparam direction string the direction to have the elements be added to thef frame
+function LeftFrames._prototype:set_direction(direction)
+ self.direction = direction
+ return self
+end
+
--- Gets the frame for this define from the left frame flow
-- @tparam player LuaPlayer the player to get the frame of
-- @treturn LuaGuiElement the frame in the left frame flow for this define
@@ -212,7 +220,7 @@ end
-- @tparam player LuaPlayer the player to update the frame of
function LeftFrames._prototype:redraw(player)
local frame = self:get_frame(player)
- frame.claer()
+ frame.clear()
if self.events.on_draw then
self.events.on_draw(player,frame)
end
@@ -263,7 +271,8 @@ Event.add(defines.events.on_player_created,function(event)
for _,define in pairs(LeftFrames.frames) do
local frame = flow.add{
type='frame',
- name=define.name
+ name=define.name,
+ direction=define.direction
}
if define.events.on_draw then
diff --git a/locale/en/expcore.cfg b/locale/en/expcore.cfg
index 58830616..ddde52d4 100644
--- a/locale/en/expcore.cfg
+++ b/locale/en/expcore.cfg
@@ -1,6 +1,10 @@
time-symbol-days-short=__1__d
color-tag=[color=__1__]__2__[/color]
+[time-format]
+simple-format-tagged=__1__ __2__
+simple-format-div=__1__:__2__
+
[expcore-commands]
unauthorized=Unauthorized, Access is denied due to invalid credentials
reject-string-options=Invalid Option, Must be one of: __1__
diff --git a/modules/gui/player-list.lua b/modules/gui/player-list.lua
new file mode 100644
index 00000000..a434f1eb
--- /dev/null
+++ b/modules/gui/player-list.lua
@@ -0,0 +1,242 @@
+--- Gui left frame define for a player list
+local Gui = require 'expcore.gui'
+local Roles = require 'expcore.roles'
+local Store = require 'expcore.store'
+local Game = require 'utils.game'
+local Event = require 'utils.event'
+local format_time = ext_require('expcore.common','format_time')
+local config = require 'config.action_buttons'
+local Colors = require 'resources.color_presets'
+
+local action_player_store = 'gui.left.player-list.action-player'
+
+--- Button used to open the action bar
+local open_action_bar =
+Gui.new_button()
+:set_sprites('utility/expand_dots_white')
+:set_tooltip('Options')
+:set_embeded_flow(function(element,action_player_name)
+ return action_player_name
+end)
+:set_style('frame_button',function(style)
+ Gui.set_padding_style(style,-2,-2,-2,-2)
+ style.width = 8
+ style.height = 14
+end)
+:on_click(function(player,element)
+ Store.set_child(action_player_store,player.name,element.parent.name)
+end)
+
+--- Button used to close the action bar
+local close_action_bar =
+Gui.new_button()
+:set_sprites('utility/close_black')
+:set_tooltip('Close options')
+:set_style('tool_button',function(style)
+ Gui.set_padding_style(style,-1,-1,-1,-1)
+ style.height = 28
+ style.width = 28
+end)
+:on_click(function(player,element)
+ Store.set_child(action_player_store,player.name,nil)
+end)
+
+--[[ Creates the main gui areas for the player list
+ element
+ > container
+ >> scroll
+ >>> table
+ >> action_bar
+]]
+local function generate_container(element)
+ Gui.set_padding(element,2,2,2,2)
+ element.style.minimal_width = 200
+
+ -- main container which contains the other elements
+ local container =
+ element.add{
+ name='container',
+ type='frame',
+ direction='vertical',
+ style='window_content_frame_packed'
+ }
+ Gui.set_padding(container)
+
+ -- a scroll bar which allows 8 players to be seen at once
+ local list_scroll =
+ container.add{
+ name='scroll',
+ type='scroll-pane',
+ direction='vertical',
+ horizontal_scroll_policy='never',
+ vertical_scroll_policy='auto-and-reserve-space'
+ }
+ Gui.set_padding(list_scroll,1,1,2,2)
+ list_scroll.style.horizontally_stretchable = true
+ list_scroll.style.maximal_height = 200
+
+ -- 3 wide table to contain: action button, player name, and play time
+ local list_table =
+ list_scroll.add{
+ name='table',
+ type='table',
+ column_count=3
+ }
+ Gui.set_padding(list_table)
+ list_table.style.horizontally_stretchable = true
+ list_table.style.vertical_align = 'center'
+ list_table.style.cell_padding = 0
+
+ -- action bar which contains the different action buttons
+ local action_bar =
+ container.add{
+ name='action_bar',
+ type='frame',
+ style='subfooter_frame'
+ }
+ Gui.set_padding(action_bar,1,1,3,3)
+ action_bar.style.horizontally_stretchable = true
+ action_bar.style.height = 35
+
+ return list_table, action_bar
+end
+
+--- Adds buttons and permission flows to the action bar
+local function generate_action_bar(player,element)
+ close_action_bar(element)
+ local action_player = Store.get_child(action_player_store,player.name)
+
+ for action_name,buttons in pairs(config) do
+ local permission_flow =
+ element.add{
+ type='flow',
+ name=action_name
+ }
+
+ for _,button in ipairs(buttons) do
+ button(permission_flow)
+ end
+
+ if not Roles.player_allowed(player,action_name) then
+ permission_flow.visible = false
+ end
+
+ if buttons.auth and action_player and not buttons.auth(player,action_player) then
+ permission_flow.visible = false
+ end
+ end
+
+ if not action_player then
+ element.visible = false
+ end
+end
+
+--- Updates the action bar
+local player_list_name
+local function update_action_bar(player)
+ local frame = Gui.classes.left_frames.get_frame(player_list_name,player)
+ local element = frame.container.action_bar
+ local action_player = Store.get_child(action_player_store,player.name)
+
+ if not action_player then
+ element.visible = false
+ else
+ element.visible = true
+ for action_name,buttons in pairs(config) do
+ if buttons.auth and not buttons.auth(player,action_player) then
+ element[action_name].visible = false
+ else
+ element[action_name].visible = true
+ end
+ end
+ end
+end
+
+local function add_player(list_table,player,role_name)
+ open_action_bar(list_table,player.name)
+
+ -- player name with the tooltip of their highest role and in they colour
+ local player_name =
+ list_table.add{
+ type='label',
+ caption=player.name,
+ tooltip=role_name
+ }
+ Gui.set_padding(player_name,0,0,0,2)
+ player_name.style.font_color = player.chat_color
+
+ -- flow which allows right align for the play time
+ local time_flow =
+ list_table.add{
+ type='flow'
+ }
+ Gui.set_padding(time_flow)
+ time_flow.style.horizontal_align = 'right'
+ time_flow.style.horizontally_stretchable = true
+
+ -- time given in Xh Ym and is right aligned
+ local time =
+ time_flow.add{
+ type='label',
+ caption=format_time(player.online_time)
+ }
+ Gui.set_padding(time)
+end
+
+--- Adds fake players to the player list
+local function add_fake_players(list_table,count)
+ local role_name = 'Fake Player'
+ for i = 1,count do
+ add_player(list_table,{
+ name='Player '..i,
+ online_time=math.random(0,game.tick),
+ chat_color=table.get_random_dictionary_entry(Colors)
+ },role_name)
+ end
+end
+
+--- Registers the player list
+local player_list =
+Gui.new_left_frame('gui/player-list')
+:set_sprites('entity/character')
+:set_open_by_default()
+:set_direction('vertical')
+:on_draw(function(player,element)
+ local list_table,action_bar = generate_container(element)
+ generate_action_bar(player,action_bar)
+
+ local players = {}
+ for _,next_player in pairs(game.connected_players) do
+ local highest_role = Roles.get_player_highest_role(next_player)
+ if not players[highest_role.name] then
+ players[highest_role.name] = {}
+ end
+ table.insert(players[highest_role.name],next_player)
+ end
+
+ for _,role_name in pairs(Roles.config.order) do
+ if players[role_name] then
+ for _,next_player in pairs(players[role_name]) do
+ add_player(list_table,next_player,role_name)
+ end
+ end
+ end
+
+ add_fake_players(list_table,20)
+end)
+
+player_list_name = player_list:uid()
+
+--- When the action player is changed the action bar will update
+Store.register(action_player_store,function(value,category)
+ local player = Game.get_player_from_any(category)
+ update_action_bar(player)
+end)
+
+--- Many events which trigger the gui to be re drawn
+Event.add(defines.events.on_player_joined_game,player_list 'redraw_all')
+Event.add(defines.events.on_player_left_game,player_list 'redraw_all')
+Event.add(Roles.player_role_assigned,player_list 'redraw_all')
+Event.add(Roles.player_role_unassigned,player_list 'redraw_all')
+
+return player_list
\ No newline at end of file
From 42de74fa4f625de648c74bcdf2a049ab5f0f9898 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Sun, 26 May 2019 19:57:28 +0100
Subject: [PATCH 03/41] Added Action Buttons
---
config/action_buttons.lua | 110 +++++++++++++++++++++++++++++++++++-
config/roles.lua | 2 +
modules/gui/player-list.lua | 4 +-
3 files changed, 113 insertions(+), 3 deletions(-)
diff --git a/config/action_buttons.lua b/config/action_buttons.lua
index 402d6481..d6b169e2 100644
--- a/config/action_buttons.lua
+++ b/config/action_buttons.lua
@@ -2,6 +2,8 @@ local Gui = require 'expcore.gui'
local Roles = require 'expcore.roles'
local Store = require 'expcore.store'
local Game = require 'utils.game'
+local Reports = require 'modules.addons.reports-control'
+local Jail = require 'modules.addons.jail-control'
local action_player_store = 'gui.left.player-list.action-player'
@@ -25,18 +27,124 @@ local function get_action_player(player)
return action_player
end
+local function teleport(from_player,to_player)
+ local surface = to_player.surface
+ local position = surface.find_non_colliding_position('character',to_player.position,32,1)
+ if not position then return false end -- return false if no new position
+ if from_player.driving then from_player.driving = false end -- kicks a player out a vehicle if in one
+ from_player.teleport(position,surface)
+ return true
+end
+
+local goto_player =
+Gui.new_button()
+:set_sprites('utility/export')
+:set_tooltip('Goto player')
+:set_style('tool_button',tool_button_style)
+:on_click(function(player,element)
+ local action_player = get_action_player(player)
+ teleport(player,action_player)
+end)
+
+local bring_player =
+Gui.new_button()
+:set_sprites('utility/import')
+:set_tooltip('Bring player')
+:set_style('tool_button',tool_button_style)
+:on_click(function(player,element)
+ local action_player = get_action_player(player)
+ teleport(action_player,player)
+end)
+
+local kill_player =
+Gui.new_button()
+:set_sprites('utility/too_far')
+:set_tooltip('Kill player')
+:set_style('tool_button',tool_button_style)
+:on_click(function(player,element)
+ local action_player = get_action_player(player)
+ if action_player.character then
+ action_player.character.die()
+ end
+end)
+
local report_player =
Gui.new_button()
-:set_sprites('utility/warning')
+:set_sprites('utility/spawn_flag')
:set_tooltip('Report player')
:set_style('tool_button',tool_button_style)
:on_click(function(player,element)
local action_player = get_action_player(player)
+ Reports.report_player(action_player,reason,player.name)
+end)
+
+local jail_player =
+Gui.new_button()
+:set_sprites('utility/item_editor_icon')
+:set_tooltip('Jail player')
+:set_style('tool_button',tool_button_style)
+:on_click(function(player,element)
+ local action_player = get_action_player(player)
+ Jail.jail_player(action_player,player.name)
+end)
+
+local temp_ban_player =
+Gui.new_button()
+:set_sprites('utility/clock')
+:set_tooltip('Temp ban player')
+:set_style('tool_button',tool_button_style)
+:on_click(function(player,element)
+ local action_player = get_action_player(player)
+ Jail.temp_ban_player(action_player,player.name,reason)
+end)
+
+local kick_player =
+Gui.new_button()
+:set_sprites('utility/warning_icon')
+:set_tooltip('Kick player')
+:set_style('tool_button',tool_button_style)
+:on_click(function(player,element)
+ local action_player = get_action_player(player)
+ game.kick_player(action_player,reason)
+end)
+
+local ban_player =
+Gui.new_button()
+:set_sprites('utility/danger_icon')
+:set_tooltip('Ban player')
+:set_style('tool_button',tool_button_style)
+:on_click(function(player,element)
+ local action_player = get_action_player(player)
+ game.ban_player(action_player,reason)
end)
return {
+ ['command/teleport'] = {
+ goto_player,
+ bring_player
+ },
+ ['command/kill/always'] = {
+ auth=auth_lower_role,
+ kill_player
+ },
['command/report'] = {
auth=auth_lower_role,
report_player
+ },
+ ['command/jail'] = {
+ auth=auth_lower_role,
+ jail_player
+ },
+ ['command/temp-ban'] = {
+ auth=auth_lower_role,
+ temp_ban_player
+ },
+ ['command/kick'] = {
+ auth=auth_lower_role,
+ kick_player
+ },
+ ['command/ban'] = {
+ auth=auth_lower_role,
+ ban_player
}
}
\ No newline at end of file
diff --git a/config/roles.lua b/config/roles.lua
index 6ea8ddc9..3fe9c615 100644
--- a/config/roles.lua
+++ b/config/roles.lua
@@ -94,6 +94,8 @@ Roles.new_role('Trainee','TrMod')
'command/give-warning',
'command/get-warnings',
'command/get-reports',
+ 'command/kick',
+ 'command/ban',
}
--- Trusted Roles
diff --git a/modules/gui/player-list.lua b/modules/gui/player-list.lua
index a434f1eb..d240fb0a 100644
--- a/modules/gui/player-list.lua
+++ b/modules/gui/player-list.lua
@@ -122,7 +122,7 @@ local function generate_action_bar(player,element)
end
if buttons.auth and action_player and not buttons.auth(player,action_player) then
- permission_flow.visible = false
+ --permission_flow.visible = false
end
end
@@ -144,7 +144,7 @@ local function update_action_bar(player)
element.visible = true
for action_name,buttons in pairs(config) do
if buttons.auth and not buttons.auth(player,action_player) then
- element[action_name].visible = false
+ --element[action_name].visible = false
else
element[action_name].visible = true
end
From e7353e331f41710da20824493203e6122eb4983d Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Sun, 26 May 2019 20:38:51 +0100
Subject: [PATCH 04/41] Added reason entry
---
config/action_buttons.lua | 49 +++++++++++++++++++++++++-----
modules/gui/player-list.lua | 60 +++++++++++++++++++++++++++++++++++--
2 files changed, 99 insertions(+), 10 deletions(-)
diff --git a/config/action_buttons.lua b/config/action_buttons.lua
index d6b169e2..f3e553db 100644
--- a/config/action_buttons.lua
+++ b/config/action_buttons.lua
@@ -4,8 +4,10 @@ local Store = require 'expcore.store'
local Game = require 'utils.game'
local Reports = require 'modules.addons.reports-control'
local Jail = require 'modules.addons.jail-control'
+local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
local action_player_store = 'gui.left.player-list.action-player'
+local action_name_store = 'gui.left.player-list.action-name'
local function tool_button_style(style)
Gui.set_padding_style(style,-1,-1,-1,-1)
@@ -24,7 +26,8 @@ end
local function get_action_player(player)
local action_player_name = Store.get_child(action_player_store,player.name)
local action_player = Game.get_player_from_any(action_player_name)
- return action_player
+ local action_player_name_color = format_chat_player_name(action_player)
+ return action_player,action_player_name_color
end
local function teleport(from_player,to_player)
@@ -74,29 +77,46 @@ Gui.new_button()
:set_tooltip('Report player')
:set_style('tool_button',tool_button_style)
:on_click(function(player,element)
- local action_player = get_action_player(player)
- Reports.report_player(action_player,reason,player.name)
+ Store.set_child(action_name_store,player.name,'command/report')
end)
+local function report_player_callback(player,reason)
+ local action_player,action_player_name_color = get_action_player(player)
+ local by_player_name_color = format_chat_player_name(player)
+ game.print{'expcom-report.non-admin',action_player_name_color,reason}
+ Roles.print_to_roles_higher('Trainee',{'expcom-report.admin',action_player_name_color,by_player_name_color,reason})
+ Reports.report_player(action_player,reason,player.name)
+end
+
local jail_player =
Gui.new_button()
:set_sprites('utility/item_editor_icon')
:set_tooltip('Jail player')
:set_style('tool_button',tool_button_style)
:on_click(function(player,element)
- local action_player = get_action_player(player)
- Jail.jail_player(action_player,player.name)
+ Store.set_child(action_name_store,player.name,'command/jail')
end)
+local function jail_player_callback(player,reason)
+ local action_player,action_player_name_color = get_action_player(player)
+ local by_player_name_color = format_chat_player_name(player)
+ game.print{'expcom-jail.give',action_player_name_color,by_player_name_color,reason}
+ Jail.jail_player(action_player,player.name)
+end
+
local temp_ban_player =
Gui.new_button()
:set_sprites('utility/clock')
:set_tooltip('Temp ban player')
:set_style('tool_button',tool_button_style)
:on_click(function(player,element)
+ Store.set_child(action_name_store,player.name,'command/temp-ban')
+end)
+
+local function temp_ban_player_callback(player,reason)
local action_player = get_action_player(player)
Jail.temp_ban_player(action_player,player.name,reason)
-end)
+end
local kick_player =
Gui.new_button()
@@ -104,9 +124,13 @@ Gui.new_button()
:set_tooltip('Kick player')
:set_style('tool_button',tool_button_style)
:on_click(function(player,element)
+ Store.set_child(action_name_store,player.name,'command/kick')
+end)
+
+local function kick_player_callback(player,reason)
local action_player = get_action_player(player)
game.kick_player(action_player,reason)
-end)
+end
local ban_player =
Gui.new_button()
@@ -114,9 +138,13 @@ Gui.new_button()
:set_tooltip('Ban player')
:set_style('tool_button',tool_button_style)
:on_click(function(player,element)
+ Store.set_child(action_name_store,player.name,'command/ban')
+end)
+
+local function ban_player_callback(player,reason)
local action_player = get_action_player(player)
game.ban_player(action_player,reason)
-end)
+end
return {
['command/teleport'] = {
@@ -129,22 +157,27 @@ return {
},
['command/report'] = {
auth=auth_lower_role,
+ reason_callback=report_player_callback,
report_player
},
['command/jail'] = {
auth=auth_lower_role,
+ reason_callback=jail_player_callback,
jail_player
},
['command/temp-ban'] = {
auth=auth_lower_role,
+ reason_callback=temp_ban_player_callback,
temp_ban_player
},
['command/kick'] = {
auth=auth_lower_role,
+ reason_callback=kick_player_callback,
kick_player
},
['command/ban'] = {
auth=auth_lower_role,
+ reason_callback=ban_player_callback,
ban_player
}
}
\ No newline at end of file
diff --git a/modules/gui/player-list.lua b/modules/gui/player-list.lua
index d240fb0a..0b8d1eaa 100644
--- a/modules/gui/player-list.lua
+++ b/modules/gui/player-list.lua
@@ -9,6 +9,7 @@ local config = require 'config.action_buttons'
local Colors = require 'resources.color_presets'
local action_player_store = 'gui.left.player-list.action-player'
+local action_name_store = 'gui.left.player-list.action-name'
--- Button used to open the action bar
local open_action_bar =
@@ -39,6 +40,26 @@ Gui.new_button()
end)
:on_click(function(player,element)
Store.set_child(action_player_store,player.name,nil)
+ Store.set_child(action_name_store,player.name,nil)
+end)
+
+--- Button used to confirm a reason
+local reason_confrim =
+Gui.new_button()
+:set_sprites('utility/confirm_slot')
+:set_tooltip('Confirm Reason')
+:set_style('tool_button',function(style)
+ Gui.set_padding_style(style,-1,-1,-1,-1)
+ style.height = 28
+ style.width = 28
+end)
+:on_click(function(player,element)
+ local reason = element.parent.entry.text or 'Non Given'
+ local action_name = Store.get_child(action_name_store,player.name)
+ local reason_callback = config[action_name].reason_callback
+ reason_callback(player,reason)
+ Store.set_child(action_player_store,player.name,nil)
+ Store.set_child(action_name_store,player.name,nil)
end)
--[[ Creates the main gui areas for the player list
@@ -48,7 +69,7 @@ end)
>>> table
>> action_bar
]]
-local function generate_container(element)
+local function generate_container(player,element)
Gui.set_padding(element,2,2,2,2)
element.style.minimal_width = 200
@@ -98,6 +119,33 @@ local function generate_container(element)
action_bar.style.horizontally_stretchable = true
action_bar.style.height = 35
+ -- reason bar which contains the reason text field and confirm button
+ local reason_bar =
+ container.add{
+ name='reason_bar',
+ type='frame',
+ style='subfooter_frame'
+ }
+ Gui.set_padding(reason_bar,-1,-1,3,3)
+ reason_bar.style.horizontally_stretchable = true
+ reason_bar.style.height = 35
+ local action_name = Store.get_child(action_name_store,player.name)
+ reason_bar.visible = action_name ~= nil
+
+ -- text entry for the reason bar
+ local reason_field =
+ reason_bar.add{
+ name='entry',
+ type='textfield',
+ style='stretchable_textfield',
+ tooltip='Enter reason'
+ }
+ Gui.set_padding(reason_field)
+ reason_field.style.height = 28
+ reason_field.style.minimal_width = 160
+
+ reason_confrim(reason_bar)
+
return list_table, action_bar
end
@@ -202,7 +250,7 @@ Gui.new_left_frame('gui/player-list')
:set_open_by_default()
:set_direction('vertical')
:on_draw(function(player,element)
- local list_table,action_bar = generate_container(element)
+ local list_table,action_bar = generate_container(player,element)
generate_action_bar(player,action_bar)
local players = {}
@@ -233,6 +281,14 @@ Store.register(action_player_store,function(value,category)
update_action_bar(player)
end)
+--- When the action name is changed the reason input will update
+Store.register(action_name_store,function(value,category)
+ local player = Game.get_player_from_any(category)
+ local frame = Gui.classes.left_frames.get_frame(player_list_name,player)
+ local element = frame.container.reason_bar
+ element.visible = value ~= nil
+end)
+
--- Many events which trigger the gui to be re drawn
Event.add(defines.events.on_player_joined_game,player_list 'redraw_all')
Event.add(defines.events.on_player_left_game,player_list 'redraw_all')
From 77fc58c8a0472f89dfbb6258a9094cff176e0991 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Sun, 26 May 2019 21:44:39 +0100
Subject: [PATCH 05/41] Final Touch
---
config/action_buttons.lua | 33 +++++++++++++++++----------
expcore/gui/left.lua | 5 ++++-
locale/en/gui.cfg | 14 ++++++++++++
modules/gui/player-list.lua | 45 +++++++++++++++++++++++++++----------
4 files changed, 72 insertions(+), 25 deletions(-)
create mode 100644 locale/en/gui.cfg
diff --git a/config/action_buttons.lua b/config/action_buttons.lua
index f3e553db..401854c8 100644
--- a/config/action_buttons.lua
+++ b/config/action_buttons.lua
@@ -15,9 +15,9 @@ local function tool_button_style(style)
style.width = 28
end
-local function auth_lower_role(player,action_player)
+local function auth_lower_role(player,action_player_name)
local player_highest = Roles.get_player_highest_role(player)
- local action_player_highest = Roles.get_player_highest_role(action_player)
+ local action_player_highest = Roles.get_player_highest_role(action_player_name)
if player_highest.index < action_player_highest.index then
return true
end
@@ -42,7 +42,7 @@ end
local goto_player =
Gui.new_button()
:set_sprites('utility/export')
-:set_tooltip('Goto player')
+:set_tooltip{'player-list.goto-player'}
:set_style('tool_button',tool_button_style)
:on_click(function(player,element)
local action_player = get_action_player(player)
@@ -52,7 +52,7 @@ end)
local bring_player =
Gui.new_button()
:set_sprites('utility/import')
-:set_tooltip('Bring player')
+:set_tooltip{'player-list.bring-player'}
:set_style('tool_button',tool_button_style)
:on_click(function(player,element)
local action_player = get_action_player(player)
@@ -62,7 +62,7 @@ end)
local kill_player =
Gui.new_button()
:set_sprites('utility/too_far')
-:set_tooltip('Kill player')
+:set_tooltip{'player-list.kill-player'}
:set_style('tool_button',tool_button_style)
:on_click(function(player,element)
local action_player = get_action_player(player)
@@ -74,7 +74,7 @@ end)
local report_player =
Gui.new_button()
:set_sprites('utility/spawn_flag')
-:set_tooltip('Report player')
+:set_tooltip{'player-list.report-player'}
:set_style('tool_button',tool_button_style)
:on_click(function(player,element)
Store.set_child(action_name_store,player.name,'command/report')
@@ -91,7 +91,7 @@ end
local jail_player =
Gui.new_button()
:set_sprites('utility/item_editor_icon')
-:set_tooltip('Jail player')
+:set_tooltip{'player-list.jail-player'}
:set_style('tool_button',tool_button_style)
:on_click(function(player,element)
Store.set_child(action_name_store,player.name,'command/jail')
@@ -107,7 +107,7 @@ end
local temp_ban_player =
Gui.new_button()
:set_sprites('utility/clock')
-:set_tooltip('Temp ban player')
+:set_tooltip{'player-list.temp-ban-player'}
:set_style('tool_button',tool_button_style)
:on_click(function(player,element)
Store.set_child(action_name_store,player.name,'command/temp-ban')
@@ -121,7 +121,7 @@ end
local kick_player =
Gui.new_button()
:set_sprites('utility/warning_icon')
-:set_tooltip('Kick player')
+:set_tooltip{'player-list.kick-player'}
:set_style('tool_button',tool_button_style)
:on_click(function(player,element)
Store.set_child(action_name_store,player.name,'command/kick')
@@ -135,7 +135,7 @@ end
local ban_player =
Gui.new_button()
:set_sprites('utility/danger_icon')
-:set_tooltip('Ban player')
+:set_tooltip{'player-list.ban-player'}
:set_style('tool_button',tool_button_style)
:on_click(function(player,element)
Store.set_child(action_name_store,player.name,'command/ban')
@@ -148,11 +148,20 @@ end
return {
['command/teleport'] = {
+ auth=function(player,action_player_name)
+ return player.name ~= action_player_name
+ end,
goto_player,
bring_player
},
- ['command/kill/always'] = {
- auth=auth_lower_role,
+ ['command/kill'] = {
+ auth=function(player,action_player_name)
+ if player.name == action_player_name then
+ return true
+ elseif Roles.player_allowed(player,'command/kill/always') then
+ return auth_lower_role(player,action_player_name)
+ end
+ end,
kill_player
},
['command/report'] = {
diff --git a/expcore/gui/left.lua b/expcore/gui/left.lua
index 63efb267..aeb528d3 100644
--- a/expcore/gui/left.lua
+++ b/expcore/gui/left.lua
@@ -240,7 +240,10 @@ end
function LeftFrames._prototype:event_handler(action)
action = action or 'update'
return function(event)
- local player = Game.get_player_by_index(event.player_index)
+ local player
+ if event.player_index then
+ player = Game.get_player_by_index(event.player_index)
+ end
self[action](self,player)
end
end
diff --git a/locale/en/gui.cfg b/locale/en/gui.cfg
new file mode 100644
index 00000000..bc5ea253
--- /dev/null
+++ b/locale/en/gui.cfg
@@ -0,0 +1,14 @@
+[player-list]
+open-action-bar=Options
+close-action-bar=Close Options
+reason-confirm=Confirm Reason
+reason-entry=Enter Reason
+goto-player=Goto player
+bring-player=Bring player
+kill-player=Kill player
+report-player=Report player
+jail-player=Jail player
+temp-ban-player=Temp ban player
+kick-player=Kick player
+ban-player=Ban player
+afk-time=__1__% of total map time\nLast moved __2__ ago
\ No newline at end of file
diff --git a/modules/gui/player-list.lua b/modules/gui/player-list.lua
index 0b8d1eaa..ba976685 100644
--- a/modules/gui/player-list.lua
+++ b/modules/gui/player-list.lua
@@ -15,7 +15,7 @@ local action_name_store = 'gui.left.player-list.action-name'
local open_action_bar =
Gui.new_button()
:set_sprites('utility/expand_dots_white')
-:set_tooltip('Options')
+:set_tooltip{'player-list.open-action-bar'}
:set_embeded_flow(function(element,action_player_name)
return action_player_name
end)
@@ -32,7 +32,7 @@ end)
local close_action_bar =
Gui.new_button()
:set_sprites('utility/close_black')
-:set_tooltip('Close options')
+:set_tooltip{'player-list.close-action-bar'}
:set_style('tool_button',function(style)
Gui.set_padding_style(style,-1,-1,-1,-1)
style.height = 28
@@ -44,10 +44,10 @@ end)
end)
--- Button used to confirm a reason
-local reason_confrim =
+local reasonc_confirm =
Gui.new_button()
:set_sprites('utility/confirm_slot')
-:set_tooltip('Confirm Reason')
+:set_tooltip{'player-list.reason-confirm'}
:set_style('tool_button',function(style)
Gui.set_padding_style(style,-1,-1,-1,-1)
style.height = 28
@@ -60,6 +60,7 @@ end)
reason_callback(player,reason)
Store.set_child(action_player_store,player.name,nil)
Store.set_child(action_name_store,player.name,nil)
+ element.parent.entry.text = ''
end)
--[[ Creates the main gui areas for the player list
@@ -138,13 +139,13 @@ local function generate_container(player,element)
name='entry',
type='textfield',
style='stretchable_textfield',
- tooltip='Enter reason'
+ tooltip={'player-list.reason-entry'}
}
Gui.set_padding(reason_field)
reason_field.style.height = 28
reason_field.style.minimal_width = 160
- reason_confrim(reason_bar)
+ reasonc_confirm(reason_bar)
return list_table, action_bar
end
@@ -170,7 +171,7 @@ local function generate_action_bar(player,element)
end
if buttons.auth and action_player and not buttons.auth(player,action_player) then
- --permission_flow.visible = false
+ permission_flow.visible = false
end
end
@@ -192,7 +193,7 @@ local function update_action_bar(player)
element.visible = true
for action_name,buttons in pairs(config) do
if buttons.auth and not buttons.auth(player,action_player) then
- --element[action_name].visible = false
+ element[action_name].visible = false
else
element[action_name].visible = true
end
@@ -208,7 +209,7 @@ local function add_player(list_table,player,role_name)
list_table.add{
type='label',
caption=player.name,
- tooltip=role_name
+ tooltip=player.name..' '..player.tag..'\n'..role_name
}
Gui.set_padding(player_name,0,0,0,2)
player_name.style.font_color = player.chat_color
@@ -216,6 +217,7 @@ local function add_player(list_table,player,role_name)
-- flow which allows right align for the play time
local time_flow =
list_table.add{
+ name='player-time-'..player.index,
type='flow'
}
Gui.set_padding(time_flow)
@@ -223,10 +225,14 @@ local function add_player(list_table,player,role_name)
time_flow.style.horizontally_stretchable = true
-- time given in Xh Ym and is right aligned
+ local tick = game.tick > 0 and game.tick or 1
+ local percent = math.round(player.online_time/tick,3)*100
local time =
time_flow.add{
+ name='label',
type='label',
- caption=format_time(player.online_time)
+ caption=format_time(player.online_time),
+ tooltip={'player-list.afk-time',percent,format_time(player.afk_time,{minutes=true,long=true})}
}
Gui.set_padding(time)
end
@@ -238,6 +244,7 @@ local function add_fake_players(list_table,count)
add_player(list_table,{
name='Player '..i,
online_time=math.random(0,game.tick),
+ afk_time=math.random(0,game.tick),
chat_color=table.get_random_dictionary_entry(Colors)
},role_name)
end
@@ -270,7 +277,20 @@ Gui.new_left_frame('gui/player-list')
end
end
- add_fake_players(list_table,20)
+ --add_fake_players(list_table,20)
+end)
+:on_update(function(player,element)
+ local list = element.container.scroll.table
+ for _,next_player in pairs(game.connected_players) do
+ local time_element_name = 'player-time-'..next_player.index
+ local time_element = list[time_element_name]
+ if time_element and time_element.valid then
+ time_element.label.caption = format_time(next_player.online_time)
+ local tick = game.tick > 0 and game.tick or 1
+ local percent = math.round(player.online_time/tick,3)*100
+ time_element.label.tooltip = {'player-list.afk-time',percent,format_time(player.afk_time,{minutes=true,long=true})}
+ end
+ end
end)
player_list_name = player_list:uid()
@@ -289,7 +309,8 @@ Store.register(action_name_store,function(value,category)
element.visible = value ~= nil
end)
---- Many events which trigger the gui to be re drawn
+--- Many events which trigger the gui to be re drawn, it will also update the times every 30 seconds
+Event.on_nth_tick(1800,player_list 'update_all')
Event.add(defines.events.on_player_joined_game,player_list 'redraw_all')
Event.add(defines.events.on_player_left_game,player_list 'redraw_all')
Event.add(Roles.player_role_assigned,player_list 'redraw_all')
From 3c604c304666e956abbb36aa8ec684a7f1be98b3 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Sun, 26 May 2019 22:16:47 +0100
Subject: [PATCH 06/41] Added warn to player list
---
config/action_buttons.lua | 28 ++++++++++++++++++-
config/warnings.lua | 4 +--
locale/en/gui.cfg | 1 +
modules/gui/player-list.lua | 6 ++--
.../Guis}/ExpGamingAdmin/Gui/control.lua | 0
.../Guis}/ExpGamingAdmin/Gui/softmod.json | 0
.../Guis}/ExpGamingAdmin/control.lua | 0
.../Guis}/ExpGamingAdmin/locale/de.cfg | 0
.../Guis}/ExpGamingAdmin/locale/en.cfg | 0
.../Guis}/ExpGamingAdmin/locale/fr.cfg | 0
.../Guis}/ExpGamingAdmin/locale/nl.cfg | 0
.../Guis}/ExpGamingAdmin/locale/sv-SE.cfg | 0
.../Guis}/ExpGamingAdmin/softmod.json | 0
.../Guis}/playerList/control.lua | 0
.../Guis}/playerList/locale/de.cfg | 0
.../Guis}/playerList/locale/en.cfg | 0
.../Guis}/playerList/locale/fr.cfg | 0
.../Guis}/playerList/locale/nl.cfg | 0
.../Guis}/playerList/locale/sv-SE.cfg | 0
.../Guis}/playerList/softmod.json | 0
.../Guis}/playerList/src/ranking.lua | 0
21 files changed, 33 insertions(+), 6 deletions(-)
rename old/modules/{ => DONE/Guis}/ExpGamingAdmin/Gui/control.lua (100%)
rename old/modules/{ => DONE/Guis}/ExpGamingAdmin/Gui/softmod.json (100%)
rename old/modules/{ => DONE/Guis}/ExpGamingAdmin/control.lua (100%)
rename old/modules/{ => DONE/Guis}/ExpGamingAdmin/locale/de.cfg (100%)
rename old/modules/{ => DONE/Guis}/ExpGamingAdmin/locale/en.cfg (100%)
rename old/modules/{ => DONE/Guis}/ExpGamingAdmin/locale/fr.cfg (100%)
rename old/modules/{ => DONE/Guis}/ExpGamingAdmin/locale/nl.cfg (100%)
rename old/modules/{ => DONE/Guis}/ExpGamingAdmin/locale/sv-SE.cfg (100%)
rename old/modules/{ => DONE/Guis}/ExpGamingAdmin/softmod.json (100%)
rename old/modules/{ExpGamingPlayer => DONE/Guis}/playerList/control.lua (100%)
rename old/modules/{ExpGamingPlayer => DONE/Guis}/playerList/locale/de.cfg (100%)
rename old/modules/{ExpGamingPlayer => DONE/Guis}/playerList/locale/en.cfg (100%)
rename old/modules/{ExpGamingPlayer => DONE/Guis}/playerList/locale/fr.cfg (100%)
rename old/modules/{ExpGamingPlayer => DONE/Guis}/playerList/locale/nl.cfg (100%)
rename old/modules/{ExpGamingPlayer => DONE/Guis}/playerList/locale/sv-SE.cfg (100%)
rename old/modules/{ExpGamingPlayer => DONE/Guis}/playerList/softmod.json (100%)
rename old/modules/{ExpGamingPlayer => DONE/Guis}/playerList/src/ranking.lua (100%)
diff --git a/config/action_buttons.lua b/config/action_buttons.lua
index 401854c8..b3da006a 100644
--- a/config/action_buttons.lua
+++ b/config/action_buttons.lua
@@ -3,6 +3,7 @@ local Roles = require 'expcore.roles'
local Store = require 'expcore.store'
local Game = require 'utils.game'
local Reports = require 'modules.addons.reports-control'
+local Warnings = require 'modules.addons.warnings-control'
local Jail = require 'modules.addons.jail-control'
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
@@ -88,6 +89,22 @@ local function report_player_callback(player,reason)
Reports.report_player(action_player,reason,player.name)
end
+local warn_player =
+Gui.new_button()
+:set_sprites('utility/spawn_flag')
+:set_tooltip{'player-list.warn-player'}
+:set_style('tool_button',tool_button_style)
+:on_click(function(player,element)
+ Store.set_child(action_name_store,player.name,'command/give-warning')
+end)
+
+local function warn_player_callback(player,reason)
+ local action_player,action_player_name_color = get_action_player(player)
+ local by_player_name_color = format_chat_player_name(player)
+ game.print{'expcom-warnings.received',action_player_name_color,by_player_name_color,reason}
+ Warnings.add_warnings(action_player,player.name)
+end
+
local jail_player =
Gui.new_button()
:set_sprites('utility/item_editor_icon')
@@ -165,10 +182,19 @@ return {
kill_player
},
['command/report'] = {
- auth=auth_lower_role,
+ auth=function(player,action_player_name)
+ if not Roles.player_allowed(player,'command/give-warning') then
+ return auth_lower_role(player,action_player_name)
+ end
+ end,
reason_callback=report_player_callback,
report_player
},
+ ['command/give-warning'] = {
+ auth=auth_lower_role,
+ reason_callback=warn_player_callback,
+ warn_player
+ },
['command/jail'] = {
auth=auth_lower_role,
reason_callback=jail_player_callback,
diff --git a/config/warnings.lua b/config/warnings.lua
index 5beace17..6e6c9211 100644
--- a/config/warnings.lua
+++ b/config/warnings.lua
@@ -2,8 +2,8 @@
return {
actions = { -- what actions are taking at number of warnings
-- if a localized string is used then __1__ will by_player_name and __2__ will be the current warning count (auto inserted)
- {'warnings.received'},
- {'warnings.received'},
+ {'warnings.received',''},
+ {'warnings.received',''},
{'warnings.received',{'warnings.pre-kick'}},
function(player,by_player_name,number_of_warnings)
game.kick_player(player,{'warnings.received',by_player_name,number_of_warnings,{'warnings.kick'}})
diff --git a/locale/en/gui.cfg b/locale/en/gui.cfg
index bc5ea253..210f4ad1 100644
--- a/locale/en/gui.cfg
+++ b/locale/en/gui.cfg
@@ -7,6 +7,7 @@ goto-player=Goto player
bring-player=Bring player
kill-player=Kill player
report-player=Report player
+warn-player=Warn player
jail-player=Jail player
temp-ban-player=Temp ban player
kick-player=Kick player
diff --git a/modules/gui/player-list.lua b/modules/gui/player-list.lua
index ba976685..e5b6e51b 100644
--- a/modules/gui/player-list.lua
+++ b/modules/gui/player-list.lua
@@ -44,7 +44,7 @@ end)
end)
--- Button used to confirm a reason
-local reasonc_confirm =
+local reason_confirm =
Gui.new_button()
:set_sprites('utility/confirm_slot')
:set_tooltip{'player-list.reason-confirm'}
@@ -145,7 +145,7 @@ local function generate_container(player,element)
reason_field.style.height = 28
reason_field.style.minimal_width = 160
- reasonc_confirm(reason_bar)
+ reason_confirm(reason_bar)
return list_table, action_bar
end
@@ -194,7 +194,7 @@ local function update_action_bar(player)
for action_name,buttons in pairs(config) do
if buttons.auth and not buttons.auth(player,action_player) then
element[action_name].visible = false
- else
+ elseif Roles.player_allowed(player,action_name) then
element[action_name].visible = true
end
end
diff --git a/old/modules/ExpGamingAdmin/Gui/control.lua b/old/modules/DONE/Guis/ExpGamingAdmin/Gui/control.lua
similarity index 100%
rename from old/modules/ExpGamingAdmin/Gui/control.lua
rename to old/modules/DONE/Guis/ExpGamingAdmin/Gui/control.lua
diff --git a/old/modules/ExpGamingAdmin/Gui/softmod.json b/old/modules/DONE/Guis/ExpGamingAdmin/Gui/softmod.json
similarity index 100%
rename from old/modules/ExpGamingAdmin/Gui/softmod.json
rename to old/modules/DONE/Guis/ExpGamingAdmin/Gui/softmod.json
diff --git a/old/modules/ExpGamingAdmin/control.lua b/old/modules/DONE/Guis/ExpGamingAdmin/control.lua
similarity index 100%
rename from old/modules/ExpGamingAdmin/control.lua
rename to old/modules/DONE/Guis/ExpGamingAdmin/control.lua
diff --git a/old/modules/ExpGamingAdmin/locale/de.cfg b/old/modules/DONE/Guis/ExpGamingAdmin/locale/de.cfg
similarity index 100%
rename from old/modules/ExpGamingAdmin/locale/de.cfg
rename to old/modules/DONE/Guis/ExpGamingAdmin/locale/de.cfg
diff --git a/old/modules/ExpGamingAdmin/locale/en.cfg b/old/modules/DONE/Guis/ExpGamingAdmin/locale/en.cfg
similarity index 100%
rename from old/modules/ExpGamingAdmin/locale/en.cfg
rename to old/modules/DONE/Guis/ExpGamingAdmin/locale/en.cfg
diff --git a/old/modules/ExpGamingAdmin/locale/fr.cfg b/old/modules/DONE/Guis/ExpGamingAdmin/locale/fr.cfg
similarity index 100%
rename from old/modules/ExpGamingAdmin/locale/fr.cfg
rename to old/modules/DONE/Guis/ExpGamingAdmin/locale/fr.cfg
diff --git a/old/modules/ExpGamingAdmin/locale/nl.cfg b/old/modules/DONE/Guis/ExpGamingAdmin/locale/nl.cfg
similarity index 100%
rename from old/modules/ExpGamingAdmin/locale/nl.cfg
rename to old/modules/DONE/Guis/ExpGamingAdmin/locale/nl.cfg
diff --git a/old/modules/ExpGamingAdmin/locale/sv-SE.cfg b/old/modules/DONE/Guis/ExpGamingAdmin/locale/sv-SE.cfg
similarity index 100%
rename from old/modules/ExpGamingAdmin/locale/sv-SE.cfg
rename to old/modules/DONE/Guis/ExpGamingAdmin/locale/sv-SE.cfg
diff --git a/old/modules/ExpGamingAdmin/softmod.json b/old/modules/DONE/Guis/ExpGamingAdmin/softmod.json
similarity index 100%
rename from old/modules/ExpGamingAdmin/softmod.json
rename to old/modules/DONE/Guis/ExpGamingAdmin/softmod.json
diff --git a/old/modules/ExpGamingPlayer/playerList/control.lua b/old/modules/DONE/Guis/playerList/control.lua
similarity index 100%
rename from old/modules/ExpGamingPlayer/playerList/control.lua
rename to old/modules/DONE/Guis/playerList/control.lua
diff --git a/old/modules/ExpGamingPlayer/playerList/locale/de.cfg b/old/modules/DONE/Guis/playerList/locale/de.cfg
similarity index 100%
rename from old/modules/ExpGamingPlayer/playerList/locale/de.cfg
rename to old/modules/DONE/Guis/playerList/locale/de.cfg
diff --git a/old/modules/ExpGamingPlayer/playerList/locale/en.cfg b/old/modules/DONE/Guis/playerList/locale/en.cfg
similarity index 100%
rename from old/modules/ExpGamingPlayer/playerList/locale/en.cfg
rename to old/modules/DONE/Guis/playerList/locale/en.cfg
diff --git a/old/modules/ExpGamingPlayer/playerList/locale/fr.cfg b/old/modules/DONE/Guis/playerList/locale/fr.cfg
similarity index 100%
rename from old/modules/ExpGamingPlayer/playerList/locale/fr.cfg
rename to old/modules/DONE/Guis/playerList/locale/fr.cfg
diff --git a/old/modules/ExpGamingPlayer/playerList/locale/nl.cfg b/old/modules/DONE/Guis/playerList/locale/nl.cfg
similarity index 100%
rename from old/modules/ExpGamingPlayer/playerList/locale/nl.cfg
rename to old/modules/DONE/Guis/playerList/locale/nl.cfg
diff --git a/old/modules/ExpGamingPlayer/playerList/locale/sv-SE.cfg b/old/modules/DONE/Guis/playerList/locale/sv-SE.cfg
similarity index 100%
rename from old/modules/ExpGamingPlayer/playerList/locale/sv-SE.cfg
rename to old/modules/DONE/Guis/playerList/locale/sv-SE.cfg
diff --git a/old/modules/ExpGamingPlayer/playerList/softmod.json b/old/modules/DONE/Guis/playerList/softmod.json
similarity index 100%
rename from old/modules/ExpGamingPlayer/playerList/softmod.json
rename to old/modules/DONE/Guis/playerList/softmod.json
diff --git a/old/modules/ExpGamingPlayer/playerList/src/ranking.lua b/old/modules/DONE/Guis/playerList/src/ranking.lua
similarity index 100%
rename from old/modules/ExpGamingPlayer/playerList/src/ranking.lua
rename to old/modules/DONE/Guis/playerList/src/ranking.lua
From ac755ba2acf6a71bf411d851007a6d924826c07c Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Mon, 27 May 2019 14:24:31 +0100
Subject: [PATCH 07/41] New Readme
---
README.md | 91 ++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 76 insertions(+), 15 deletions(-)
diff --git a/README.md b/README.md
index ecec858d..c7509c63 100644
--- a/README.md
+++ b/README.md
@@ -16,28 +16,89 @@
-
+
-
ExpGaming Scenario Repository
+
ExpGaming Scenario Repository
-
Out Dated; Will be updated in the future
+## Explosive Gaming
-#### Use and Installation
+Explosive Gaming (often ExpGaming) is a server hosting community with a strong focus on Factorio and games that follow similar ideas. Our factorio server are known for hosting large maps with the main goal of being a "mega base" which can produce as much as possible with in our reset schedule. Although these server tend to the more experienced players our server are open to everyone. You can find us through our [website](website), [discord](discord), [wiki](wiki), or in the public games tab in factorio (ExpGaming S1).
-* Download the git repo
-* Move files into the scenario folder (C:\Users\User\AppData\Roaming\Factorio\scenarios\ExpGamingScenario)
-* Make edits to role and group configs as well as any other configs that you want
-* Run the scenario under Play > Multiplayer > Host Scenario > ExpGamingScenario
-* All modules will be loaded if you have not removed any, any problems see log file
+## Use and Installation
-#### Creation of new modules
+1) Download this [git repository](https://github.com/explosivegaming/scenario/archive/master.zip) for the stable release. The dev branch can be found [here](https://github.com/explosivegaming/scenario/archive/dev.zip) for those who want the latest features. See [releases](#releases) for other release branches.
-* Please see [FactorioSoftmodManager](https://github.com/explosivegaming/FactorioSoftmodManager) for making new modules
+2) Extract the downloaded zip file from the branch you downloaded into factorio's scenario directory:
+ * Windows: `%appdata%\Factorio\scenarios`
+ * Linux: `~/.factorio/scenarios`
-#### Forks and Pull Requests
+3) Within the scenario you can find `./config/_file_loader.lua` which contains a list of all the modules that will be loaded by the scenario; simply comment out (or remove) features you do not want but note that some modules may load other modules as dependencies even when removed from the list.
-* We are happy for people to make pull requests if you wish to help make our server better
-* Your server is a community server, it is all about the people and feedback is good
-* Dont be afraid to make a pull request as if it fixes something then its a good change
\ No newline at end of file
+4) More advanced users may want to play with the other configs files within `./config` but please be aware that some of the config files will require a basic understanding of lua while others may just be a list of values.
+
+5) Once you have made any config changes that you wish to make open factorio, select play, then start scenario (or host scenario from within multiplayer tab), and select the scenario which will be called `scenario-master` if you have downloaded the latest stable release and have not changed the folder name.
+
+6) The scenario will now load all the selected modules and start the map, any errors or exceptions raised in the scenario should not cause a game/server crash so if any features don't work as expected then it may be returning an error in the log, please report these errors to [the issues page](issues).
+
+## Contributing
+
+All are welcome to make pull requests and issues for this scenario, if you are in any doubt please ask someone in our [discord](discord). If you do not know lua and don't feel like learning you can always make a [feature request](issues). Please keep in mind while making code changes:
+
+* New features should have the branch names: `feature/feature-name`
+* New features are merged into `dev` after it has been completed.
+* After a number of features have been added a release branch is made: `release/X.Y.0`; this branch should have no new features and only bug fixes or localization.
+* A release is merged into `master` on the following friday in time for the the weekly reset.
+* Patches may be named `patch/X.Y.Z` and fill be merged into `master` and `dev` when appropriate.
+
+## Releases
+
+| Scenario Version* | Version Name | Factorio Version** |
+|---|---|---|
+| [v5.5](s5.5) | Gui System | [v0.17.35](f0.17.35) |
+| [v5.4](s5.4) | Admin Controls | [v0.17.32](f0.17.32) |
+| [v5.3](s5.3) | Custom Roles | [v0.17.28](f0.17.28) |
+| [v5.2](s5.2) | Quality of life | [v0.17.22](f0.17.22) |
+| [v5.1](s5.1) | Permission Groups | [v0.17.13](f0.17.13) |
+| [v5.0](s5.0) | 0.17 Overhaul| [v0.17](f0.17.9) |
+| [v4.0](s4.0) | Softmod Manager | [v0.16.51](f0.16.51) |
+| [v3.0](s3.0) | 0.16 Overhaul | [v0.16](f0.16) |
+| [v2.0](s2.0) | Localization and clean up | [v0.15](f0.15) |
+| [v1.0](s1.0) | Modulation | [v0.15](f0.15) |
+| [v0.1](s0.1) | First Tracked Version | [v0.14](f0.14) |
+\* Scenario patch versions have been omitted.
+
+\** Factorio versions show the version they were made for, often the minimum requirement.
+
+[s5.5]: https://github.com/explosivegaming/scenario/releases/tag/5.5.0
+[s5.4]: https://github.com/explosivegaming/scenario/releases/tag/5.4.0
+[s5.3]: https://github.com/explosivegaming/scenario/releases/tag/5.3.0
+[s5.2]: https://github.com/explosivegaming/scenario/releases/tag/5.2.0
+[s5.1]: https://github.com/explosivegaming/scenario/releases/tag/5.1.0
+[s5.0]: https://github.com/explosivegaming/scenario/releases/tag/5.0.0
+[s4.0]: https://github.com/explosivegaming/scenario/releases/tag/v4.0
+[s3.0]: https://github.com/explosivegaming/scenario/releases/tag/v3.0
+[s2.0]: https://github.com/explosivegaming/scenario/releases/tag/v2.0
+[s1.0]: https://github.com/explosivegaming/scenario/releases/tag/v1.0
+[s0.1]: https://github.com/explosivegaming/scenario/releases/tag/v0.1
+
+[f0.17.35]: https://wiki.factorio.com/Version_history/0.17.0#0.17.35
+[f0.17.32]: https://wiki.factorio.com/Version_history/0.17.0#0.17.32
+[f0.17.28]: https://wiki.factorio.com/Version_history/0.17.0#0.17.28
+[f0.17.22]: https://wiki.factorio.com/Version_history/0.17.0#0.17.22
+[f0.17.13]: https://wiki.factorio.com/Version_history/0.17.0#0.17.13
+[f0.17.9]: https://wiki.factorio.com/Version_history/0.17.0#0.17.9
+[f0.16.51]: https://wiki.factorio.com/Version_history/0.16.0#0.16.51
+[f0.16]: https://wiki.factorio.com/Version_history/0.16.0
+[f0.15]: https://wiki.factorio.com/Version_history/0.15.0
+[f0.14]: https://wiki.factorio.com/Version_history/0.14.0
+
+## License
+
+The Explosive Gaming codebase is licensed under the [GNU General Public License v3.0](https://github.com/explosivegaming/scenario/blob/master/LICENSE)
+
+[issues]: https://github.com/explosivegaming/scenario/issues/new/choose
+[website]: https://explosivegaming.nl
+[discord]: https://discord.explosivegaming.nl
+[wiki]: https://wiki.explosivegaming.nl
\ No newline at end of file
From e1ec16ac777cbaea6776f5ef54b053fd4fa9ebb1 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Mon, 27 May 2019 14:38:23 +0100
Subject: [PATCH 08/41] Added command find
---
config/_file_loader.lua | 1 +
config/action_buttons.lua | 2 +-
config/roles.lua | 1 +
modules/commands/find.lua | 11 +++++++++++
modules/gui/player-list.lua | 19 ++++++++++++++++++-
5 files changed, 32 insertions(+), 2 deletions(-)
create mode 100644 modules/commands/find.lua
diff --git a/config/_file_loader.lua b/config/_file_loader.lua
index 24c135c7..ca4405fd 100644
--- a/config/_file_loader.lua
+++ b/config/_file_loader.lua
@@ -22,6 +22,7 @@ return {
'modules.commands.reports',
'modules.commands.spawn',
'modules.commands.warnings',
+ 'modules.commands.find',
-- QoL Addons
'modules.addons.chat-popups',
'modules.addons.damage-popups',
diff --git a/config/action_buttons.lua b/config/action_buttons.lua
index b3da006a..cd48100d 100644
--- a/config/action_buttons.lua
+++ b/config/action_buttons.lua
@@ -184,7 +184,7 @@ return {
['command/report'] = {
auth=function(player,action_player_name)
if not Roles.player_allowed(player,'command/give-warning') then
- return auth_lower_role(player,action_player_name)
+ return not Roles.player_has_flag(action_player_name,'report-immune')
end
end,
reason_callback=report_player_callback,
diff --git a/config/roles.lua b/config/roles.lua
index 3fe9c615..3604d31a 100644
--- a/config/roles.lua
+++ b/config/roles.lua
@@ -182,6 +182,7 @@ local default = Roles.new_role('Guest','')
'command/tag-clear',
'command/chelp',
'command/list-roles',
+ 'command/find-on-map',
'command/report',
'gui/player-list',
}
diff --git a/modules/commands/find.lua b/modules/commands/find.lua
new file mode 100644
index 00000000..ee242b1b
--- /dev/null
+++ b/modules/commands/find.lua
@@ -0,0 +1,11 @@
+local Commands = require 'expcore.commands'
+require 'config.expcore-commands.parse_general'
+
+Commands.new_command('find-on-map','Find a player on your map.')
+:add_param('player',false,'player-online') -- the player to find on the map
+:add_alias('find','zoom-to')
+:register(function(player,action_player,raw)
+ local position = action_player.position
+ player.zoom_to_world(position,2)
+ return Commands.success -- prevents command complete message from showing
+end)
\ No newline at end of file
diff --git a/modules/gui/player-list.lua b/modules/gui/player-list.lua
index e5b6e51b..9987b341 100644
--- a/modules/gui/player-list.lua
+++ b/modules/gui/player-list.lua
@@ -11,6 +11,15 @@ local Colors = require 'resources.color_presets'
local action_player_store = 'gui.left.player-list.action-player'
local action_name_store = 'gui.left.player-list.action-name'
+--- used on player name label to allow zoom to map
+local zoom_to_map_name = Gui.uid_name()
+Gui.on_click(zoom_to_map_name,function(event)
+ local action_player_name = event.element.caption
+ local action_player = Game.get_player_from_any(action_player_name)
+ local position = action_player.position
+ event.player.zoom_to_world(position,2)
+end)
+
--- Button used to open the action bar
local open_action_bar =
Gui.new_button()
@@ -204,9 +213,17 @@ end
local function add_player(list_table,player,role_name)
open_action_bar(list_table,player.name)
+ -- flow to contain player_name to allow all to have trigger for zoom to map
+ local player_name_flow =
+ list_table.add{
+ type='flow'
+ }
+ Gui.set_padding(player_name_flow)
+
-- player name with the tooltip of their highest role and in they colour
local player_name =
- list_table.add{
+ player_name_flow.add{
+ name=zoom_to_map_name,
type='label',
caption=player.name,
tooltip=player.name..' '..player.tag..'\n'..role_name
From e57e44d93c27949bf191dc7a16cd21ddf85f9d1d Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Mon, 27 May 2019 14:41:45 +0100
Subject: [PATCH 09/41] Added click to open to tooltip
---
locale/en/gui.cfg | 3 ++-
modules/gui/player-list.lua | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/locale/en/gui.cfg b/locale/en/gui.cfg
index 210f4ad1..80a9e80d 100644
--- a/locale/en/gui.cfg
+++ b/locale/en/gui.cfg
@@ -12,4 +12,5 @@ jail-player=Jail player
temp-ban-player=Temp ban player
kick-player=Kick player
ban-player=Ban player
-afk-time=__1__% of total map time\nLast moved __2__ ago
\ No newline at end of file
+afk-time=__1__% of total map time\nLast moved __2__ ago
+open-map=__1__ __2__\n__3__\nClick to open map
\ No newline at end of file
diff --git a/modules/gui/player-list.lua b/modules/gui/player-list.lua
index 9987b341..79339dd4 100644
--- a/modules/gui/player-list.lua
+++ b/modules/gui/player-list.lua
@@ -226,7 +226,7 @@ local function add_player(list_table,player,role_name)
name=zoom_to_map_name,
type='label',
caption=player.name,
- tooltip=player.name..' '..player.tag..'\n'..role_name
+ tooltip={'player-list.open-map',player.name,player.tag,role_name}
}
Gui.set_padding(player_name,0,0,0,2)
player_name.style.font_color = player.chat_color
From 0b9e8b8cd50d284e06c7b2f2b20844a3ff1815bb Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Mon, 27 May 2019 22:37:59 +0100
Subject: [PATCH 10/41] Looks Sorted
---
config/_file_loader.lua | 1 +
config/rockets.lua | 37 +++
config/roles.lua | 5 +
expcore/gui/core.lua | 21 ++
locale/en/gui.cfg | 1 +
modules/gui/player-list.lua | 12 +-
modules/gui/rocket-info.lua | 506 ++++++++++++++++++++++++++++++++++++
7 files changed, 574 insertions(+), 9 deletions(-)
create mode 100644 config/rockets.lua
create mode 100644 modules/gui/rocket-info.lua
diff --git a/config/_file_loader.lua b/config/_file_loader.lua
index ca4405fd..746bbcb7 100644
--- a/config/_file_loader.lua
+++ b/config/_file_loader.lua
@@ -35,6 +35,7 @@ return {
'modules.addons.random-player-colours',
-- GUI
'modules.gui.player-list',
+ 'modules.gui.rocket-info',
'modules.commands.debug',
-- Config Files
'config.expcore-commands.auth_admin', -- commands tagged with admin_only are blocked for non admins
diff --git a/config/rockets.lua b/config/rockets.lua
new file mode 100644
index 00000000..f6e7cb3b
--- /dev/null
+++ b/config/rockets.lua
@@ -0,0 +1,37 @@
+--- This file controls what will show in each section of the rocket info gui
+-- each function will be given the player and must return the value to show and a tooltip, nil will not show the stat
+local Global = require 'utils.global'
+local Event = require 'utils.event'
+
+return {
+ stats = {
+ show_stats=true,
+ show_first_rocket = true,
+ show_last_rocket = true,
+ show_fastest_rocket = true,
+ show_total_rockets = true,
+ show_game_avg = true,
+ rolling_avg = {
+ 5,10,25
+ }
+ },
+ milestones = {
+ show_milestones=true,
+ 1,2,5,
+ 10,20,50,
+ 100,200,500,
+ 1000,1500,2000,2500,
+ 3000,3500,4000,4500,
+ 5000
+ },
+ progress = {
+ show_progress = true,
+ allow_zoom_to_map = true,
+ allow_remote_launch = true,
+ remote_launch_admins_only = false,
+ remote_launch_role_permision = 'gui/rocket-info/remote_launch',
+ allow_toggle_active = true,
+ toggle_active_admins_only = false,
+ toggle_active_role_permision = 'gui/rocket-info/toggle-active'
+ }
+}
\ No newline at end of file
diff --git a/config/roles.lua b/config/roles.lua
index 3604d31a..532b2db5 100644
--- a/config/roles.lua
+++ b/config/roles.lua
@@ -76,6 +76,8 @@ Roles.new_role('Moderator','Mod')
'command/clear-warnings',
'command/clear-temp-ban',
'command/clear-inventory',
+ 'gui/rocket-info/toggle-active',
+ 'gui/rocket-info/remote_launch',
}
Roles.new_role('Trainee','TrMod')
@@ -115,6 +117,8 @@ Roles.new_role('Pay to Win','P2W')
:set_flag('report-immune')
:set_parent('Donator')
:allow{
+ 'gui/rocket-info/toggle-active',
+ 'gui/rocket-info/remote_launch',
}
Roles.new_role('Donator','Don')
@@ -185,6 +189,7 @@ local default = Roles.new_role('Guest','')
'command/find-on-map',
'command/report',
'gui/player-list',
+ 'gui/rocket-info',
}
--- Jail role
diff --git a/expcore/gui/core.lua b/expcore/gui/core.lua
index 8eb407cf..0415e8a1 100644
--- a/expcore/gui/core.lua
+++ b/expcore/gui/core.lua
@@ -153,6 +153,7 @@
Gui.toggle_visible(element) --- Will toggle the visiblity of an element
Gui.set_padding(element,up,down,left,right) --- Sets the padding for a gui element
Gui.set_padding_style(style,up,down,left,right) --- Sets the padding for a gui style
+ Gui.create_right_align(element,flow_name) --- Allows the creation of a right align flow to place elements into
]]
local Gui = require 'utils.gui'
local Game = require 'utils.game'
@@ -515,6 +516,7 @@ end
--- Will toggle the enabled state of an element
-- @tparam element LuaGuiElement the gui element to toggle
+-- @treturn boolean the new state that the element has
function Gui.toggle_enable(element)
if not element or not element.valid then return end
if not element.enabled then
@@ -522,10 +524,12 @@ function Gui.toggle_enable(element)
else
element.enabled = false
end
+ return element.enabled
end
--- Will toggle the visiblity of an element
-- @tparam element LuaGuiElement the gui element to toggle
+-- @treturn boolean the new state that the element has
function Gui.toggle_visible(element)
if not element or not element.valid then return end
if not element.visible then
@@ -533,6 +537,7 @@ function Gui.toggle_visible(element)
else
element.visible = false
end
+ return element.visible
end
--- Sets the padding for a gui element
@@ -562,4 +567,20 @@ function Gui.set_padding_style(style,up,down,left,right)
style.right_padding = right or 0
end
+--- Allows the creation of a right align flow to place elements into
+-- @tparam element LuaGuiElement the element to add this flow to,
+-- @tparam[opt] flow_name string the name of the flow can be nil
+-- @treturn LuaGuiElement the flow that was created
+function Gui.create_right_align(element,flow_name)
+ local right_flow =
+ element.add{
+ name=flow_name,
+ type='flow'
+ }
+ Gui.set_padding(right_flow,1,1,2,2)
+ right_flow.style.horizontal_align = 'right'
+ right_flow.style.horizontally_stretchable = true
+ return right_flow
+end
+
return Gui
\ No newline at end of file
diff --git a/locale/en/gui.cfg b/locale/en/gui.cfg
index 80a9e80d..f0ff3cfc 100644
--- a/locale/en/gui.cfg
+++ b/locale/en/gui.cfg
@@ -1,4 +1,5 @@
[player-list]
+main-tooltip=Player list
open-action-bar=Options
close-action-bar=Close Options
reason-confirm=Confirm Reason
diff --git a/modules/gui/player-list.lua b/modules/gui/player-list.lua
index 79339dd4..d2545f5a 100644
--- a/modules/gui/player-list.lua
+++ b/modules/gui/player-list.lua
@@ -40,7 +40,7 @@ end)
--- Button used to close the action bar
local close_action_bar =
Gui.new_button()
-:set_sprites('utility/close_black')
+:set_sprites('utility/close_black','utility/close_white')
:set_tooltip{'player-list.close-action-bar'}
:set_style('tool_button',function(style)
Gui.set_padding_style(style,-1,-1,-1,-1)
@@ -232,14 +232,7 @@ local function add_player(list_table,player,role_name)
player_name.style.font_color = player.chat_color
-- flow which allows right align for the play time
- local time_flow =
- list_table.add{
- name='player-time-'..player.index,
- type='flow'
- }
- Gui.set_padding(time_flow)
- time_flow.style.horizontal_align = 'right'
- time_flow.style.horizontally_stretchable = true
+ local time_flow = Gui.create_right_align(list_table,'player-time-'..player.index)
-- time given in Xh Ym and is right aligned
local tick = game.tick > 0 and game.tick or 1
@@ -271,6 +264,7 @@ end
local player_list =
Gui.new_left_frame('gui/player-list')
:set_sprites('entity/character')
+:set_tooltip{'player-list.main-tooltip'}
:set_open_by_default()
:set_direction('vertical')
:on_draw(function(player,element)
diff --git a/modules/gui/rocket-info.lua b/modules/gui/rocket-info.lua
new file mode 100644
index 00000000..9531e0ab
--- /dev/null
+++ b/modules/gui/rocket-info.lua
@@ -0,0 +1,506 @@
+local Gui = require 'expcore.gui'
+local Roles = require 'expcore.roles'
+local Event = require 'utils.event'
+local config = require 'config.rockets'
+local Global = require 'utils.global'
+local format_time = ext_require('expcore.common','format_time')
+local Colors = require 'resources.color_presets'
+
+local rocket_times = {}
+local rocket_stats = {}
+local rocket_silos = {}
+
+Global.register({
+ rocket_times = rocket_times,
+ rocket_stats = rocket_stats,
+ rocket_silos = rocket_silos
+},function(tbl)
+ rocket_times = tbl.rocket_times
+ rocket_stats = tbl.rocket_stats
+ rocket_silos = tbl.rocket_silos
+end)
+
+local function get_silo_name(entity)
+ local position = entity.position
+ return 'X '..math.floor(position.x)..' Y '..math.floor(position.y)
+end
+
+local zoom_to_map_name = Gui.uid_name()
+Gui.on_click(zoom_to_map_name,function(event)
+ local force = event.player.force
+ local rocket_silo_name = event.element.caption
+ local rocket_silo = rocket_silos[force.name][rocket_silo_name]
+ local position = rocket_silo.entity.position
+ event.player.zoom_to_world(position,2)
+end)
+
+local launch_rocket =
+Gui.new_button()
+:set_sprites('utility/center')
+:set_tooltip('Click to launch rocket')
+:set_embeded_flow(function(element,rocket_silo_name)
+ return 'launch_'..rocket_silo_name
+end)
+:set_style('tool_button',function(style)
+ Gui.set_padding_style(style,-2,-2,-2,-2)
+ style.width = 16
+ style.height = 16
+end)
+:on_click(function(player,element)
+ local force = player.force
+ local rocket_silo_name = element.parent.name:sub(8)
+ local rocket_silo = rocket_silos[force.name][rocket_silo_name]
+ rocket_silo.entity.launch_rocket()
+end)
+
+local toggle_rocket =
+Gui.new_button()
+:set_sprites('utility/play')
+:set_tooltip('Click to launch rocket')
+:set_embeded_flow(function(element,rocket_silo_name)
+ return 'toggle_'..rocket_silo_name
+end)
+:set_style('tool_button',function(style)
+ Gui.set_padding_style(style,-2,-2,-2,-2)
+ style.width = 16
+ style.height = 16
+end)
+:on_click(function(player,element)
+ local force = player.force
+ local rocket_silo_name = element.parent.name:sub(7)
+ local rocket_silo = rocket_silos[force.name][rocket_silo_name]
+ local status = true
+ if status then
+ player.print('WIP; We currently have no way to test or set the auto launch of a rocket so this button does not work!')
+ else
+ element.sprite = 'utility/stop'
+ end
+end)
+
+local header_expand =
+Gui.new_button()
+:set_sprites('utility/expand_dark','utility/expand')
+:set_tooltip('Click to expand')
+:set_style('tool_button',function(style)
+ Gui.set_padding_style(style,-2,-2,-2,-2)
+ style.height = 20
+ style.width = 20
+end)
+:on_click(function(player,element)
+ local flow_name = element.parent.name
+ local flow = element.parent.parent.parent[flow_name]
+ if Gui.toggle_visible(flow) then
+ element.sprite = 'utility/collapse_dark'
+ element.hovered_sprite = 'utility/collapse'
+ else
+ element.sprite = 'utility/expand_dark'
+ element.hovered_sprite = 'utility/expand'
+ end
+end)
+
+local function create_header_flow_combo(player,element,name,table_size,caption,tooltip)
+ -- header for the combo
+ local header =
+ element.add{
+ type='frame',
+ name=name..'-header',
+ style='subheader_frame',
+ }
+ Gui.set_padding(header,1,1,3,3)
+ header.style.horizontally_stretchable = true
+
+ -- caption for header bar
+ header.add{
+ type='label',
+ style='heading_1_label',
+ caption=caption,
+ tooltip=tooltip
+ }
+
+ -- right aligned button to toggle the drop down area
+ local expand_flow = Gui.create_right_align(header,name)
+ header_expand(expand_flow)
+
+ -- flow for the combo
+ local flow =
+ element.add{
+ name=name,
+ type='scroll-pane',
+ direction='vertical',
+ horizontal_scroll_policy='never',
+ vertical_scroll_policy='auto-and-reserve-space'
+ }
+ Gui.set_padding(flow,1,1,2,2)
+ flow.style.horizontally_stretchable = true
+ flow.style.maximal_height = 215
+
+ flow.visible = false
+
+ -- table to allow for nice looking labels
+ local flow_table =
+ flow.add{
+ name='table',
+ type='table',
+ column_count=table_size
+ }
+ Gui.set_padding(flow_table)
+ flow_table.style.horizontally_stretchable = true
+ flow_table.style.vertical_align = 'center'
+ flow_table.style.cell_padding = 0
+end
+
+local function player_allowed(player,action)
+ if not config.progress['allow_'..action] then
+ return false
+ end
+
+ if config.progress[action..'_admins_only'] and not player.admin then
+ return false
+ end
+
+ if config.progress[action..'_role_permision'] and not Roles.player_allowed(player,config.progress[action..'_role_permision']) then
+ return false
+ end
+
+ return true
+end
+
+local function generate_container(player,element)
+ Gui.set_padding(element,1,2,2,2)
+ element.style.minimal_width = 200
+
+ -- main container which contains the other elements
+ local container =
+ element.add{
+ name='container',
+ type='frame',
+ direction='vertical',
+ style='window_content_frame_packed'
+ }
+ Gui.set_padding(container)
+
+ if config.stats.show_stats then
+ create_header_flow_combo(player,container,'stats',2,'Statistics','Stats about rockets')
+ end
+
+ if config.milestones.show_milestones then
+ create_header_flow_combo(player,container,'milestones',2,'Milestones','Rocket milestones')
+ end
+
+ if config.progress.show_progress then
+ local col_count = 2
+ if player_allowed(player,'remote_launch') then col_count = col_count+1 end
+ if player_allowed(player,'toggle_active') then col_count = col_count+1 end
+
+ create_header_flow_combo(player,container,'progress',col_count,'Build Progress','Build progress of rockets')
+ container.progress.add{
+ type='label',
+ name='no_silos',
+ caption='Your force has no silos'
+ }
+ end
+
+end
+
+local function create_label_pair_time(element,name,raw_value,caption,tooltip,no_hours)
+ local value = no_hours and format_time(raw_value,{minutes=true,seconds=true}) or format_time(raw_value)
+ local value_tooltip = format_time(raw_value,{hours=not no_hours,minutes=true,seconds=true,long=true})
+ if not element[name] then
+ -- main label to show the name of the value
+ element.add{
+ type='label',
+ name=name..'-label',
+ caption=caption,
+ tooltip=tooltip
+ }
+ -- flow which allows right align for the value
+ local right_flow = Gui.create_right_align(element,name)
+ right_flow.add{
+ type='label',
+ name='label',
+ caption=value,
+ tooltip=value_tooltip
+ }
+ else
+ element[name].label.caption = value
+ element[name].label.tooltip = value_tooltip
+ end
+end
+
+local function generate_stats(player,frame)
+ if not config.stats.show_stats then return end
+ local element = frame.container.stats.table
+ local force_rockets = player.force.rockets_launched
+
+ if config.stats.show_first_rocket then
+ create_label_pair_time(element,'first_launch',rocket_stats.first_launch or 0,'First Launch','The time of launch of the first rocket')
+ end
+
+ if config.stats.show_last_rocket then
+ create_label_pair_time(element,'last_launch',rocket_stats.last_launch or 0,'Last Launch','The time that the last rocket was launched')
+ end
+
+ if config.stats.show_fastest_rocket then
+ create_label_pair_time(element,'fastest_launch',rocket_stats.fastest_launch or 0,'Fastest Launch','The time taken for the fastest launch',true)
+ end
+
+ if config.stats.show_total_rockets then
+ local total_rockets = 0
+
+ for _,force in pairs(game.forces) do
+ total_rockets = total_rockets + force.rockets_launched
+ end
+ total_rockets = total_rockets > 0 and total_rockets or 1
+ local percentage = math.round(force_rockets/total_rockets,3)*100
+
+ if not element.total_rockets then
+ -- main label to show the name of the value
+ element.add{
+ type='label',
+ name='total_rockets-label',
+ caption='Total Lauched',
+ tooltip='The total number of rockets launched'
+ }
+ -- flow which allows right align for the value
+ local right_flow = Gui.create_right_align(element,'total_rockets')
+ right_flow.add{
+ type='label',
+ name='label',
+ caption=force_rockets,
+ tooltip=percentage
+ }
+ else
+ element.total_rockets.label.caption = force_rockets
+ element.total_rockets.label.tooltip = percentage
+ end
+ end
+
+ if config.stats.show_game_avg then
+ local tick = game.tick > 0 and game.tick or 1
+ local avg = math.floor(force_rockets/tick)
+ create_label_pair_time(element,'avg_launch',avg,'Avg Launch','The average time to launch a rocket',true)
+ end
+
+ for _,over in pairs(config.stats.rolling_avg) do
+ local total = 0
+ local rocket_count = 0
+ for i = force_rockets,force_rockets-over,-1 do
+ if rocket_times[i] then
+ rocket_count = rocket_count + 1
+ total = total + rocket_times[i]
+ end
+ end
+ total = total > 0 and total or 1
+ local avg = math.floor(rocket_count/total)
+ create_label_pair_time(element,'avg_launch_'..over,avg,'Avg Launch '..over,'The rolling average time to launch a rocket for the past '..over..' rockets',true)
+ end
+
+end
+
+local function generate_milestones(player,frame)
+ if not config.milestones.show_milestones then return end
+ local element = frame.container.milestones.table
+ local force_rockets = player.force.rockets_launched
+
+ for _,milestone in ipairs(config.milestones) do
+ if milestone <= force_rockets and not element['milstone-'..milestone] then
+ create_label_pair_time(element,'milstone-'..milestone,rocket_times[player.force.name][milestone],'Milestone '..milestone,'Time taken to launch '..milestone..' rockets')
+ end
+ end
+end
+
+local function generate_progress(player,frame)
+ if not config.progress.show_progress then return end
+ local element = frame.container.progress.table
+ local force = player.force.name
+
+ if not rocket_silos[force] or table.size(rocket_silos[force]) == 0 then
+ element.parent.no_silos.visible = true
+
+ else
+ element.parent.no_silos.visible = false
+ for rocket_silo_name,rocket_silo in pairs(rocket_silos[force]) do
+ if not rocket_silo.entity or not rocket_silo.entity.valid then
+ rocket_silos[force][rocket_silo_name] = nil
+ if element['label_'..rocket_silo_name] then element['label_'..rocket_silo_name].destroy() end
+ if element['launch_'..rocket_silo_name] then element['launch_'..rocket_silo_name].destroy() end
+ if element['toggle_'..rocket_silo_name] then element['toggle_'..rocket_silo_name].destroy() end
+ if element[rocket_silo_name] then element[rocket_silo_name].destroy() end
+
+ elseif not element[rocket_silo_name] then
+ local progress = rocket_silo.entity.rocket_parts
+ local status = rocket_silo.entity.status == 21
+ local active = false -- need way to check this
+
+ if player_allowed(player,'toggle_active') then
+ local toggle_rocket_element = toggle_rocket(element,rocket_silo_name)
+ toggle_rocket_element.enabled = false -- remove when done
+ if active then
+ toggle_rocket_element.sprite = 'utility/stop'
+ else
+ toggle_rocket_element.sprite = 'utility/play'
+ end
+ end
+
+ if player_allowed(player,'remote_launch') then
+ local launch_rocket_element = launch_rocket(element,rocket_silo_name)
+ launch_rocket_element.enabled = status
+ end
+
+ -- main label to show the name of the value
+ local flow = element.add{type='flow',name='label_'..rocket_silo_name}
+ Gui.set_padding(flow,0,0,2,0)
+ flow.add{
+ type='label',
+ name=zoom_to_map_name,
+ caption=rocket_silo_name,
+ tooltip='Click to view on map'
+ }
+
+ -- flow which allows right align for the value
+ local right_flow = Gui.create_right_align(element,rocket_silo_name)
+ right_flow.add{
+ type='label',
+ name='label',
+ caption=progress..'%',
+ tooltip=rocket_silo.launched or 0
+ }
+
+ else
+ local progress = rocket_silo.entity.rocket_parts
+ local status = rocket_silo.entity.status == 21
+ local active = false -- need way to check this
+
+ local label = element[rocket_silo_name].label
+ label.caption = progress..'%'
+ label.tooltip = rocket_silo.launched or 0
+
+ if status then
+ label.caption = '100%'
+ label.style.font_color = Colors.cyan
+ else
+ label.style.font_color = Colors.white
+ end
+
+ if player_allowed(player,'toggle_active') then
+ local toggle_rocket_element = element['toggle_'..rocket_silo_name]
+ if active then
+ toggle_rocket_element[toggle_rocket.name].sprite = 'utility/stop'
+ else
+ toggle_rocket_element[toggle_rocket.name].sprite = 'utility/play'
+ end
+ end
+
+ if player_allowed(player,'remote_launch') then
+ local launch_rocket_element = element['launch_'..rocket_silo_name]
+ launch_rocket_element[launch_rocket.name].enabled = status
+ end
+
+
+
+ end
+ end
+
+ end
+end
+
+local rocket_info =
+Gui.new_left_frame('gui/rocket-info')
+:set_sprites('entity/rocket-silo')
+:set_post_authenticator(function(player,define_name)
+ return true
+ --return player.force.rockets_launched > 0 and Gui.classes.toolbar.allowed(player,define_name)
+end)
+:set_open_by_default(function(player,define_name)
+ return true
+ --return player.force.rockets_launched > 0
+end)
+:set_direction('vertical')
+:on_draw(function(player,element)
+ generate_container(player,element)
+ generate_stats(player,element)
+ generate_milestones(player,element)
+ generate_progress(player,element)
+end)
+:on_update(function(player,element)
+ generate_stats(player,element)
+ generate_milestones(player,element)
+ generate_progress(player,element)
+end)
+
+Event.add(defines.events.on_rocket_launched,function(event)
+ local force = event.rocket_silo.force
+ local force_name = force.name
+ local rockets_launched = force.rockets_launched
+
+ if not rocket_stats[force_name] then
+ rocket_stats[force_name] = {}
+ end
+
+ if rockets_launched == 1 then
+ rocket_stats.first_launch = event.tick
+ rocket_stats.fastest_launch = event.tick
+ elseif event.tick-rocket_stats.last_launch < rocket_stats.fastest_launch then
+ rocket_stats.fastest_launch = event.tick-rocket_stats.last_launch
+ end
+
+ rocket_stats.last_launch = event.tick
+
+ if not rocket_times[force_name] then
+ rocket_times[force_name] = {}
+ end
+
+ rocket_times[force_name][rockets_launched] = event.tick
+
+ local silo_name = get_silo_name(event.rocket_silo)
+
+ if not rocket_silos[force_name] then
+ rocket_silos[force_name] = {}
+ end
+
+ if not rocket_silos[force_name][silo_name] then
+ rocket_silos[force_name][silo_name] = {entity=event.rocket_silo,launched=0}
+ end
+
+ rocket_silos[force_name][silo_name].launched = rocket_silos[force_name][silo_name].launched+1
+
+ for _,player in pairs(force.players) do
+ rocket_info:update(player)
+ Gui.update_toolbar(player)
+ end
+end)
+
+local function on_built(event)
+ local entity = event.created_entity
+ if entity.valid and entity.name == 'rocket-silo' then
+ local force = entity.force
+ local force_name = force.name
+ local silo_name = get_silo_name(entity)
+
+ if not rocket_silos[force_name] then
+ rocket_silos[force_name] = {}
+ end
+
+ rocket_silos[force_name][silo_name] = {entity=entity,launched=0}
+
+ for _,player in pairs(force.players) do
+ rocket_info:update(player)
+ end
+ end
+end
+
+Event.add(defines.events.on_built_entity,on_built)
+Event.add(defines.events.on_robot_built_entity,on_built)
+Event.on_nth_tick(150,function()
+ for _,force in pairs(game.forces) do
+ local silos = rocket_silos[force.name]
+ if silos then
+ for _,player in pairs(force.connected_players) do
+ local frame = rocket_info:get_frame(player)
+ generate_progress(player,frame)
+ end
+ end
+ end
+end)
+
+return rocket_info
\ No newline at end of file
From 56b102d823c6bf2977bfa5d175966d9fc2e42899 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Tue, 28 May 2019 01:08:09 +0100
Subject: [PATCH 11/41] Finished Rocket Gui
---
expcore/gui.lua | 3 +
expcore/gui/core.lua | 11 +
locale/en/gui.cfg | 39 ++-
modules/gui/rocket-info.lua | 631 ++++++++++++++++++++----------------
4 files changed, 411 insertions(+), 273 deletions(-)
diff --git a/expcore/gui.lua b/expcore/gui.lua
index 70f0ffc3..7f38e777 100644
--- a/expcore/gui.lua
+++ b/expcore/gui.lua
@@ -37,6 +37,9 @@ local Gui = require 'expcore.gui.core'
Gui.toggle_enable(element) --- Will toggle the enabled state of an element
Gui.toggle_visible(element) --- Will toggle the visiblity of an element
Gui.set_padding(element,up,down,left,right) --- Sets the padding for a gui element
+ Gui.set_padding_style(style,up,down,left,right) --- Sets the padding for a gui style
+ Gui.create_right_align(element,flow_name) --- Allows the creation of a right align flow to place elements into
+ Gui.destory_if_valid(element) --- Destroies an element but tests for it being present and valid first
]]
local Instances = require 'expcore.gui.instances'
diff --git a/expcore/gui/core.lua b/expcore/gui/core.lua
index 0415e8a1..c58de2e3 100644
--- a/expcore/gui/core.lua
+++ b/expcore/gui/core.lua
@@ -154,6 +154,7 @@
Gui.set_padding(element,up,down,left,right) --- Sets the padding for a gui element
Gui.set_padding_style(style,up,down,left,right) --- Sets the padding for a gui style
Gui.create_right_align(element,flow_name) --- Allows the creation of a right align flow to place elements into
+ Gui.destory_if_valid(element) --- Destroies an element but tests for it being present and valid first
]]
local Gui = require 'utils.gui'
local Game = require 'utils.game'
@@ -583,4 +584,14 @@ function Gui.create_right_align(element,flow_name)
return right_flow
end
+--- Destroies an element but tests for it being present and valid first
+-- @tparam element LuaGuiElement the element to be destroied
+-- @treturn boolean true if it was destoried
+function Gui.destory_if_valid(element)
+ if element and element.valid then
+ element.destroy()
+ return true
+ end
+end
+
return Gui
\ No newline at end of file
diff --git a/locale/en/gui.cfg b/locale/en/gui.cfg
index f0ff3cfc..e7e2aee4 100644
--- a/locale/en/gui.cfg
+++ b/locale/en/gui.cfg
@@ -14,4 +14,41 @@ temp-ban-player=Temp ban player
kick-player=Kick player
ban-player=Ban player
afk-time=__1__% of total map time\nLast moved __2__ ago
-open-map=__1__ __2__\n__3__\nClick to open map
\ No newline at end of file
+open-map=__1__ __2__\n__3__\nClick to open map
+
+[rocket-info]
+main-tooltip=Rocket info
+launch-tooltip=Launch rocket
+launch-tooltip-disabled=Launch rocket (not ready)
+toggle-rocket-tooltip=Disable auto launch
+toggle-rocket-tooltip-disabled=Enable auto launch
+toggle-section-tooltip=Expand Section
+toggle-section-collapse-tooltip=Collapse Section
+section-caption-stats=Statistics
+section-tooltip-stats=Statistics about how rockets are launched
+section-caption-milestones=Milestones
+section-tooltip-milestones=The times when milestones were met
+section-caption-progress=Build Progress
+section-tooltip-progress=The progress for your rocket silos
+progress-no-silos=You have no rocket silos
+data-caption-first-launch=First Launch
+data-tooltip-first-launch=The time of the first launch
+data-caption-last-launch=Last Launch
+data-tooltip-last-launch=The time of the last launch
+data-caption-fastest-launch=Fastest Launch
+data-tooltip-fastest-launch=The time taken for the fastest launch
+data-caption-total-rockets=Total Launched
+data-tooltip-total-rockets=Total number of rockets launched by your force
+value-tooltip-total-rockets=__1__% of all rockets on this map
+data-caption-avg-launch=Avg Time
+data-tooltip-avg-launch=The average amount of time taken to launch a rocket
+data-caption-avg-launch-n=Avg Time __1__
+data-tooltip-avg-launch-n=The average amount of time taken to launch the last __1__ rockets
+data-caption-milstone-n=Milestone __1__
+data-tooltip-milstone-n=Time taken to each __1__ rockets
+progress-x-pos=X __1__
+progress-y-pos=Y __1__
+progress-label-tooltip=View on map
+progress-launched=Launched
+progress-caption=__1__%
+progress-tooltip=This silo has launched __1__ rockets
\ No newline at end of file
diff --git a/modules/gui/rocket-info.lua b/modules/gui/rocket-info.lua
index 9531e0ab..3171643d 100644
--- a/modules/gui/rocket-info.lua
+++ b/modules/gui/rocket-info.lua
@@ -20,135 +20,13 @@ Global.register({
rocket_silos = tbl.rocket_silos
end)
+--- Gets the name used to refrence the the rocket silo
local function get_silo_name(entity)
local position = entity.position
- return 'X '..math.floor(position.x)..' Y '..math.floor(position.y)
-end
-
-local zoom_to_map_name = Gui.uid_name()
-Gui.on_click(zoom_to_map_name,function(event)
- local force = event.player.force
- local rocket_silo_name = event.element.caption
- local rocket_silo = rocket_silos[force.name][rocket_silo_name]
- local position = rocket_silo.entity.position
- event.player.zoom_to_world(position,2)
-end)
-
-local launch_rocket =
-Gui.new_button()
-:set_sprites('utility/center')
-:set_tooltip('Click to launch rocket')
-:set_embeded_flow(function(element,rocket_silo_name)
- return 'launch_'..rocket_silo_name
-end)
-:set_style('tool_button',function(style)
- Gui.set_padding_style(style,-2,-2,-2,-2)
- style.width = 16
- style.height = 16
-end)
-:on_click(function(player,element)
- local force = player.force
- local rocket_silo_name = element.parent.name:sub(8)
- local rocket_silo = rocket_silos[force.name][rocket_silo_name]
- rocket_silo.entity.launch_rocket()
-end)
-
-local toggle_rocket =
-Gui.new_button()
-:set_sprites('utility/play')
-:set_tooltip('Click to launch rocket')
-:set_embeded_flow(function(element,rocket_silo_name)
- return 'toggle_'..rocket_silo_name
-end)
-:set_style('tool_button',function(style)
- Gui.set_padding_style(style,-2,-2,-2,-2)
- style.width = 16
- style.height = 16
-end)
-:on_click(function(player,element)
- local force = player.force
- local rocket_silo_name = element.parent.name:sub(7)
- local rocket_silo = rocket_silos[force.name][rocket_silo_name]
- local status = true
- if status then
- player.print('WIP; We currently have no way to test or set the auto launch of a rocket so this button does not work!')
- else
- element.sprite = 'utility/stop'
- end
-end)
-
-local header_expand =
-Gui.new_button()
-:set_sprites('utility/expand_dark','utility/expand')
-:set_tooltip('Click to expand')
-:set_style('tool_button',function(style)
- Gui.set_padding_style(style,-2,-2,-2,-2)
- style.height = 20
- style.width = 20
-end)
-:on_click(function(player,element)
- local flow_name = element.parent.name
- local flow = element.parent.parent.parent[flow_name]
- if Gui.toggle_visible(flow) then
- element.sprite = 'utility/collapse_dark'
- element.hovered_sprite = 'utility/collapse'
- else
- element.sprite = 'utility/expand_dark'
- element.hovered_sprite = 'utility/expand'
- end
-end)
-
-local function create_header_flow_combo(player,element,name,table_size,caption,tooltip)
- -- header for the combo
- local header =
- element.add{
- type='frame',
- name=name..'-header',
- style='subheader_frame',
- }
- Gui.set_padding(header,1,1,3,3)
- header.style.horizontally_stretchable = true
-
- -- caption for header bar
- header.add{
- type='label',
- style='heading_1_label',
- caption=caption,
- tooltip=tooltip
- }
-
- -- right aligned button to toggle the drop down area
- local expand_flow = Gui.create_right_align(header,name)
- header_expand(expand_flow)
-
- -- flow for the combo
- local flow =
- element.add{
- name=name,
- type='scroll-pane',
- direction='vertical',
- horizontal_scroll_policy='never',
- vertical_scroll_policy='auto-and-reserve-space'
- }
- Gui.set_padding(flow,1,1,2,2)
- flow.style.horizontally_stretchable = true
- flow.style.maximal_height = 215
-
- flow.visible = false
-
- -- table to allow for nice looking labels
- local flow_table =
- flow.add{
- name='table',
- type='table',
- column_count=table_size
- }
- Gui.set_padding(flow_table)
- flow_table.style.horizontally_stretchable = true
- flow_table.style.vertical_align = 'center'
- flow_table.style.cell_padding = 0
+ return math.floor(position.x)..':'..math.floor(position.y)
end
+--- Gets if a player is allowed to use the action buttons
local function player_allowed(player,action)
if not config.progress['allow_'..action] then
return false
@@ -165,6 +43,166 @@ local function player_allowed(player,action)
return true
end
+--- Used on the name label to allow zoom to map
+local zoom_to_map_name = Gui.uid_name()
+Gui.on_click(zoom_to_map_name,function(event)
+ local force = event.player.force
+ local rocket_silo_name = event.element.parent.caption
+ local rocket_silo_data = rocket_silos[force.name][rocket_silo_name]
+ local position = rocket_silo_data.entity.position
+ event.player.zoom_to_world(position,2)
+end)
+
+--- Used to launch the rocket, when it is ready
+local launch_rocket =
+Gui.new_button()
+:set_sprites('utility/center')
+:set_tooltip{'rocket-info.launch-tooltip'}
+:set_embeded_flow(function(element,rocket_silo_name)
+ return 'launch-'..rocket_silo_name
+end)
+:set_style('tool_button',function(style)
+ Gui.set_padding_style(style,-2,-2,-2,-2)
+ style.width = 16
+ style.height = 16
+end)
+:on_click(function(player,element)
+ local force = player.force
+ local rocket_silo_name = element.parent.name:sub(8)
+ local rocket_silo_data = rocket_silos[force.name][rocket_silo_name]
+ if rocket_silo_data.entity.launch_rocket() then
+ rocket_silo_data.awaiting_reset = true
+ element.enabled = false
+ end
+end)
+
+--- Used to toggle the auto launch on a rocket
+local toggle_rocket =
+Gui.new_button()
+:set_sprites('utility/play')
+:set_tooltip{'rocket-info.toggle-rocket-tooltip'}
+:set_embeded_flow(function(element,rocket_silo_name)
+ return 'toggle-'..rocket_silo_name
+end)
+:set_style('tool_button',function(style)
+ Gui.set_padding_style(style,-2,-2,-2,-2)
+ style.width = 16
+ style.height = 16
+end)
+:on_click(function(player,element)
+ local force = player.force
+ local rocket_silo_name = element.parent.name:sub(7)
+ local rocket_silo = rocket_silos[force.name][rocket_silo_name]
+ local active = true -- need to test for auto launch
+ if active then
+ player.print('WIP; We currently have no way to test or set the auto launch of a rocket so this button does not work!')
+ element.sprite = 'utility/play'
+ element.tooltip = {'rocket-info.toggle-rocket-tooltip'}
+ -- insert function to disable auto launch
+ else
+ element.sprite = 'utility/stop'
+ element.tooltip = {'rocket-info.toggle-rocket-tooltip-disabled'}
+ -- insert function to enable auto launch
+ end
+end)
+
+--- Used to toggle the visiblty of the different sections
+local toggle_section =
+Gui.new_button()
+:set_sprites('utility/expand_dark','utility/expand')
+:set_tooltip{'rocket-info.toggle-section-tooltip'}
+:set_style('tool_button',function(style)
+ Gui.set_padding_style(style,-2,-2,-2,-2)
+ style.height = 20
+ style.width = 20
+end)
+:on_click(function(player,element)
+ local flow_name = element.parent.name
+ local flow = element.parent.parent.parent[flow_name]
+ if Gui.toggle_visible(flow) then
+ element.sprite = 'utility/collapse_dark'
+ element.hovered_sprite = 'utility/collapse'
+ element.tooltip = {'rocket-info.toggle-section-collapse-tooltip'}
+ else
+ element.sprite = 'utility/expand_dark'
+ element.hovered_sprite = 'utility/expand'
+ element.tooltip = {'rocket-info.toggle-section-tooltip'}
+ end
+end)
+
+--- Used to create the three different sections
+local function create_section(container,section_name,table_size)
+ --- Header for the section
+ local header =
+ container.add{
+ type='frame',
+ name=section_name..'-header',
+ style='subheader_frame',
+ }
+ Gui.set_padding(header,1,1,3,3)
+ header.style.horizontally_stretchable = true
+
+ --- Caption for the header bar
+ header.add{
+ type='label',
+ style='heading_1_label',
+ caption={'rocket-info.section-caption-'..section_name},
+ tooltip={'rocket-info.section-tooltip-'..section_name}
+ }
+
+ --- Right aligned button to toggle the section
+ local expand_flow = Gui.create_right_align(header,section_name)
+ toggle_section(expand_flow)
+
+ --- The area which contains the section content
+ local flow =
+ container.add{
+ name=section_name,
+ type='scroll-pane',
+ direction='vertical',
+ horizontal_scroll_policy='never',
+ vertical_scroll_policy='auto-and-reserve-space'
+ }
+ Gui.set_padding(flow,1,1,2,2)
+ flow.style.horizontally_stretchable = true
+ flow.style.maximal_height = 215
+ flow.visible = false
+
+ --- Table used to store the data
+ local flow_table =
+ flow.add{
+ name='table',
+ type='table',
+ column_count=table_size
+ }
+ Gui.set_padding(flow_table)
+ flow_table.style.horizontally_stretchable = true
+ flow_table.style.vertical_align = 'center'
+ flow_table.style.cell_padding = 0
+end
+
+--[[ Creates the main structure for the gui
+ element
+ > container
+
+ >> stats-header
+ >>> stats
+ >>>> toggle_section.name
+ >> stats
+ >>> table
+
+ >> milestones-header
+ >>> milestones
+ >>>> toggle_section.name
+ >> milestones
+ >>> table
+
+ >> progress-header
+ >>> progress
+ >>>> toggle_section.name
+ >> progress
+ >>> table
+]]
local function generate_container(player,element)
Gui.set_padding(element,1,2,2,2)
element.style.minimal_width = 200
@@ -180,223 +218,257 @@ local function generate_container(player,element)
Gui.set_padding(container)
if config.stats.show_stats then
- create_header_flow_combo(player,container,'stats',2,'Statistics','Stats about rockets')
+ create_section(container,'stats',2)
end
if config.milestones.show_milestones then
- create_header_flow_combo(player,container,'milestones',2,'Milestones','Rocket milestones')
+ create_section(container,'milestones',2)
end
if config.progress.show_progress then
- local col_count = 2
+ local col_count = 3
if player_allowed(player,'remote_launch') then col_count = col_count+1 end
if player_allowed(player,'toggle_active') then col_count = col_count+1 end
-
- create_header_flow_combo(player,container,'progress',col_count,'Build Progress','Build progress of rockets')
+ create_section(container,'progress',col_count)
+ --- label used when no active silos
container.progress.add{
type='label',
name='no_silos',
- caption='Your force has no silos'
+ caption={'rocket-info.progress-no-silos'}
}
end
end
-local function create_label_pair_time(element,name,raw_value,caption,tooltip,no_hours)
- local value = no_hours and format_time(raw_value,{minutes=true,seconds=true}) or format_time(raw_value)
- local value_tooltip = format_time(raw_value,{hours=not no_hours,minutes=true,seconds=true,long=true})
- if not element[name] then
- -- main label to show the name of the value
+--- Creates a text label followed by a data label, or updates them if already present
+local function create_label_value_pair(element,data_name,value,tooltip,extra)
+ local data_name_extra = extra and data_name..extra or data_name
+ if element[data_name_extra] then
+ element[data_name_extra].label.caption = value
+ element[data_name_extra].label.tooltip = tooltip
+ else
+ --- Label used with the data
element.add{
type='label',
- name=name..'-label',
- caption=caption,
- tooltip=tooltip
+ name=data_name_extra..'-label',
+ caption={'rocket-info.data-caption-'..data_name,extra},
+ tooltip={'rocket-info.data-tooltip-'..data_name,extra}
}
- -- flow which allows right align for the value
- local right_flow = Gui.create_right_align(element,name)
+ --- Right aligned label to store the data
+ local right_flow = Gui.create_right_align(element,data_name_extra)
right_flow.add{
type='label',
name='label',
caption=value,
- tooltip=value_tooltip
+ tooltip=tooltip
}
- else
- element[name].label.caption = value
- element[name].label.tooltip = value_tooltip
end
end
+--- Creates a text and data label using times as the data
+local function create_label_value_pair_time(element,data_name,raw_value,no_hours,extra)
+ local value = no_hours and format_time(raw_value,{minutes=true,seconds=true}) or format_time(raw_value)
+ local tooltip = format_time(raw_value,{hours=not no_hours,minutes=true,seconds=true,long=true})
+ create_label_value_pair(element,data_name,value,tooltip,extra)
+end
+
+--- Adds the data to the stats section
local function generate_stats(player,frame)
if not config.stats.show_stats then return end
local element = frame.container.stats.table
local force_rockets = player.force.rockets_launched
if config.stats.show_first_rocket then
- create_label_pair_time(element,'first_launch',rocket_stats.first_launch or 0,'First Launch','The time of launch of the first rocket')
+ create_label_value_pair_time(element,'first-launch',rocket_stats.first_launch or 0)
end
if config.stats.show_last_rocket then
- create_label_pair_time(element,'last_launch',rocket_stats.last_launch or 0,'Last Launch','The time that the last rocket was launched')
+ create_label_value_pair_time(element,'last-launch',rocket_stats.last_launch or 0)
end
if config.stats.show_fastest_rocket then
- create_label_pair_time(element,'fastest_launch',rocket_stats.fastest_launch or 0,'Fastest Launch','The time taken for the fastest launch',true)
+ create_label_value_pair_time(element,'fastest-launch',rocket_stats.fastest_launch or 0,true)
end
if config.stats.show_total_rockets then
- local total_rockets = 0
-
- for _,force in pairs(game.forces) do
- total_rockets = total_rockets + force.rockets_launched
+ local total_rockets = 1
+ if force_rockets > 0 then
+ total_rockets = 0
+ for _,force in pairs(game.forces) do
+ total_rockets = total_rockets + force.rockets_launched
+ end
end
- total_rockets = total_rockets > 0 and total_rockets or 1
local percentage = math.round(force_rockets/total_rockets,3)*100
-
- if not element.total_rockets then
- -- main label to show the name of the value
- element.add{
- type='label',
- name='total_rockets-label',
- caption='Total Lauched',
- tooltip='The total number of rockets launched'
- }
- -- flow which allows right align for the value
- local right_flow = Gui.create_right_align(element,'total_rockets')
- right_flow.add{
- type='label',
- name='label',
- caption=force_rockets,
- tooltip=percentage
- }
- else
- element.total_rockets.label.caption = force_rockets
- element.total_rockets.label.tooltip = percentage
- end
+ create_label_value_pair(element,'total-rockets',force_rockets,{'rocket-info.value-tooltip-total-rockets',percentage})
end
if config.stats.show_game_avg then
- local tick = game.tick > 0 and game.tick or 1
- local avg = math.floor(force_rockets/tick)
- create_label_pair_time(element,'avg_launch',avg,'Avg Launch','The average time to launch a rocket',true)
+ local avg = force_rockets > 0 and math.floor(game.tick/force_rockets) or 0
+ create_label_value_pair_time(element,'avg-launch',avg,true)
end
- for _,over in pairs(config.stats.rolling_avg) do
- local total = 0
- local rocket_count = 0
- for i = force_rockets,force_rockets-over,-1 do
- if rocket_times[i] then
- rocket_count = rocket_count + 1
- total = total + rocket_times[i]
- end
+ for _,avg_over in pairs(config.stats.rolling_avg) do
+ local rocket_count = avg_over
+ local first_rocket = 0
+ if avg_over < force_rockets then
+ first_rocket = rocket_times[player.force.name][force_rockets-avg_over]
+ else
+ rocket_count = force_rockets
end
- total = total > 0 and total or 1
- local avg = math.floor(rocket_count/total)
- create_label_pair_time(element,'avg_launch_'..over,avg,'Avg Launch '..over,'The rolling average time to launch a rocket for the past '..over..' rockets',true)
+ local avg = rocket_count > 0 and math.floor((game.tick-first_rocket)/rocket_count) or 0
+ create_label_value_pair_time(element,'avg-launch-n',avg,true,avg_over)
end
end
+--- Creates the list of milestones
local function generate_milestones(player,frame)
if not config.milestones.show_milestones then return end
local element = frame.container.milestones.table
local force_rockets = player.force.rockets_launched
for _,milestone in ipairs(config.milestones) do
- if milestone <= force_rockets and not element['milstone-'..milestone] then
- create_label_pair_time(element,'milstone-'..milestone,rocket_times[player.force.name][milestone],'Milestone '..milestone,'Time taken to launch '..milestone..' rockets')
+ if milestone <= force_rockets then
+ local time = rocket_times[player.force.name][milestone]
+ create_label_value_pair_time(element,'milstone-n',time,true,milestone)
+ else
+ create_label_value_pair_time(element,'milstone-n',0,true,milestone)
+ break
end
end
end
+--- Creats the different action buttons
+local function generate_progress_buttons(player,element,rocket_silo_data)
+ local silo_name = rocket_silo_data.name
+ local status = rocket_silo_data.entity.status == 21
+ local active = false -- need way to check this
+
+ if player_allowed(player,'toggle_active') then
+ local button_element = element['toggle-'..silo_name]
+
+ if button_element then
+ button_element = button_element[toggle_rocket.name]
+ else
+ button_element = toggle_rocket(element,silo_name)
+ end
+
+ button_element.enabled = false -- remove once check is added
+ if active then
+ button_element.sprite = 'utility/stop'
+ else
+ button_element.sprite = 'utility/play'
+ end
+ end
+
+ if player_allowed(player,'remote_launch') then
+ local button_element = element['launch-'..silo_name]
+
+ if button_element then
+ button_element = button_element[launch_rocket.name]
+ else
+ button_element = launch_rocket(element,silo_name)
+ end
+
+ if rocket_silo_data.awaiting_reset then
+ button_element.enabled = false
+ else
+ button_element.enabled = status
+ end
+ end
+
+end
+
+--- Creates build progress section
local function generate_progress(player,frame)
if not config.progress.show_progress then return end
local element = frame.container.progress.table
- local force = player.force.name
+ local force = player.force
+ local force_name = force.name
+ local force_silo_data = rocket_silos[force_name]
- if not rocket_silos[force] or table.size(rocket_silos[force]) == 0 then
+ if not force_silo_data or table.size(force_silo_data) == 0 then
element.parent.no_silos.visible = true
else
element.parent.no_silos.visible = false
- for rocket_silo_name,rocket_silo in pairs(rocket_silos[force]) do
- if not rocket_silo.entity or not rocket_silo.entity.valid then
- rocket_silos[force][rocket_silo_name] = nil
- if element['label_'..rocket_silo_name] then element['label_'..rocket_silo_name].destroy() end
- if element['launch_'..rocket_silo_name] then element['launch_'..rocket_silo_name].destroy() end
- if element['toggle_'..rocket_silo_name] then element['toggle_'..rocket_silo_name].destroy() end
- if element[rocket_silo_name] then element[rocket_silo_name].destroy() end
- elseif not element[rocket_silo_name] then
- local progress = rocket_silo.entity.rocket_parts
- local status = rocket_silo.entity.status == 21
- local active = false -- need way to check this
+ for silo_name,rocket_silo_data in pairs(force_silo_data) do
+ if not rocket_silo_data.entity or not rocket_silo_data.entity.valid then
+ force_silo_data[silo_name] = nil
+ Gui.destory_if_valid(element['toggle-'..silo_name])
+ Gui.destory_if_valid(element['launch-'..silo_name])
+ Gui.destory_if_valid(element['label-x-'..silo_name])
+ Gui.destory_if_valid(element['label-y-'..silo_name])
+ Gui.destory_if_valid(element[silo_name])
- if player_allowed(player,'toggle_active') then
- local toggle_rocket_element = toggle_rocket(element,rocket_silo_name)
- toggle_rocket_element.enabled = false -- remove when done
- if active then
- toggle_rocket_element.sprite = 'utility/stop'
- else
- toggle_rocket_element.sprite = 'utility/play'
- end
- end
-
- if player_allowed(player,'remote_launch') then
- local launch_rocket_element = launch_rocket(element,rocket_silo_name)
- launch_rocket_element.enabled = status
- end
-
- -- main label to show the name of the value
- local flow = element.add{type='flow',name='label_'..rocket_silo_name}
- Gui.set_padding(flow,0,0,2,0)
- flow.add{
- type='label',
- name=zoom_to_map_name,
- caption=rocket_silo_name,
- tooltip='Click to view on map'
+ elseif not element[silo_name] then
+ local entity = rocket_silo_data.entity
+ local progress = entity.rocket_parts
+ local pos = {
+ x=entity.position.x,
+ y=entity.position.y
}
- -- flow which allows right align for the value
- local right_flow = Gui.create_right_align(element,rocket_silo_name)
+ generate_progress_buttons(player,element,rocket_silo_data)
+
+ --- Creats two flows and two labels for the X and Y position
+ local flow_x = element.add{
+ type='flow',
+ name='label-x-'..silo_name,
+ caption=silo_name
+ }
+ Gui.set_padding(flow_x,0,0,1,2)
+ flow_x.add{
+ type='label',
+ name=zoom_to_map_name,
+ caption={'rocket-info.progress-x-pos',pos.x},
+ tooltip={'rocket-info.progress-label-tooltip'}
+ }
+
+ local flow_y = element.add{
+ type='flow',
+ name='label-y-'..silo_name,
+ caption=silo_name
+ }
+ Gui.set_padding(flow_y,0,0,1,2)
+ flow_y.add{
+ type='label',
+ name=zoom_to_map_name,
+ caption={'rocket-info.progress-y-pos',pos.y},
+ tooltip={'rocket-info.progress-label-tooltip'}
+ }
+
+ --- Creates the progress value which is right aligned
+ local right_flow = Gui.create_right_align(element,silo_name)
right_flow.add{
type='label',
name='label',
- caption=progress..'%',
- tooltip=rocket_silo.launched or 0
+ caption={'rocket-info.progress-caption',progress},
+ tooltip={'rocket-info.progress-tooltip',rocket_silo_data.launched or 0}
}
else
- local progress = rocket_silo.entity.rocket_parts
- local status = rocket_silo.entity.status == 21
- local active = false -- need way to check this
+ local entity = rocket_silo_data.entity
+ local progress = entity.rocket_parts
+ local status = entity.status == 21
- local label = element[rocket_silo_name].label
- label.caption = progress..'%'
- label.tooltip = rocket_silo.launched or 0
+ local label = element[silo_name].label
+ label.caption = {'rocket-info.progress-caption',progress}
+ label.tooltip = {'rocket-info.progress-tooltip',rocket_silo_data.launched or 0}
- if status then
- label.caption = '100%'
+ if status and rocket_silo_data.awaiting_reset then
+ label.caption = {'rocket-info.progress-launched'}
+ label.style.font_color = Colors.green
+ elseif status then
+ label.caption = {'rocket-info.progress-caption',100}
label.style.font_color = Colors.cyan
else
+ rocket_silo_data.awaiting_reset = false
label.style.font_color = Colors.white
end
- if player_allowed(player,'toggle_active') then
- local toggle_rocket_element = element['toggle_'..rocket_silo_name]
- if active then
- toggle_rocket_element[toggle_rocket.name].sprite = 'utility/stop'
- else
- toggle_rocket_element[toggle_rocket.name].sprite = 'utility/play'
- end
- end
-
- if player_allowed(player,'remote_launch') then
- local launch_rocket_element = element['launch_'..rocket_silo_name]
- launch_rocket_element[launch_rocket.name].enabled = status
- end
-
-
+ generate_progress_buttons(player,element,rocket_silo_data)
end
end
@@ -408,12 +480,10 @@ local rocket_info =
Gui.new_left_frame('gui/rocket-info')
:set_sprites('entity/rocket-silo')
:set_post_authenticator(function(player,define_name)
- return true
- --return player.force.rockets_launched > 0 and Gui.classes.toolbar.allowed(player,define_name)
+ return player.force.rockets_launched > 0 and Gui.classes.toolbar.allowed(player,define_name)
end)
:set_open_by_default(function(player,define_name)
- return true
- --return player.force.rockets_launched > 0
+ return player.force.rockets_launched > 0
end)
:set_direction('vertical')
:on_draw(function(player,element)
@@ -429,15 +499,20 @@ end)
end)
Event.add(defines.events.on_rocket_launched,function(event)
+ local entity = event.rocket_silo
+ local silo_name = get_silo_name(entity)
local force = event.rocket_silo.force
local force_name = force.name
+ local force_silo_data = rocket_silos[force_name]
local rockets_launched = force.rockets_launched
+ local first_rocket = rockets_launched == 1
+ --- Handles updates to the rocket stats
if not rocket_stats[force_name] then
rocket_stats[force_name] = {}
end
- if rockets_launched == 1 then
+ if first_rocket then
rocket_stats.first_launch = event.tick
rocket_stats.fastest_launch = event.tick
elseif event.tick-rocket_stats.last_launch < rocket_stats.fastest_launch then
@@ -446,30 +521,34 @@ Event.add(defines.events.on_rocket_launched,function(event)
rocket_stats.last_launch = event.tick
+ --- Appends the new rocket into the array
if not rocket_times[force_name] then
rocket_times[force_name] = {}
end
rocket_times[force_name][rockets_launched] = event.tick
- local silo_name = get_silo_name(event.rocket_silo)
-
- if not rocket_silos[force_name] then
- rocket_silos[force_name] = {}
- end
-
- if not rocket_silos[force_name][silo_name] then
- rocket_silos[force_name][silo_name] = {entity=event.rocket_silo,launched=0}
- end
-
- rocket_silos[force_name][silo_name].launched = rocket_silos[force_name][silo_name].launched+1
+ --- Adds this 1 to the launch count for this silo
+ force_silo_data[silo_name].launched = force_silo_data[silo_name].launched+1
+ --- Updates all the guis (and toolbar since the button may now be visible)
for _,player in pairs(force.players) do
rocket_info:update(player)
- Gui.update_toolbar(player)
+ if first_rocket then Gui.update_toolbar(player) end
end
end)
+--- When a launch is reiggered it will await reset
+Event.add(defines.events.on_rocket_launch_ordered,function(event)
+ local entity = event.rocket_silo
+ local silo_name = get_silo_name(entity)
+ local force = event.rocket_silo.force
+ local force_name = force.name
+ local force_silo_data = rocket_silos[force_name]
+ force_silo_data[silo_name].awaiting_reset = true
+end)
+
+--- Adds a silo to the list when it is built
local function on_built(event)
local entity = event.created_entity
if entity.valid and entity.name == 'rocket-silo' then
@@ -481,16 +560,24 @@ local function on_built(event)
rocket_silos[force_name] = {}
end
- rocket_silos[force_name][silo_name] = {entity=entity,launched=0}
+ rocket_silos[force_name][silo_name] = {
+ name=silo_name,
+ entity=entity,
+ launched=0,
+ awaiting_reset=false
+ }
for _,player in pairs(force.players) do
- rocket_info:update(player)
+ local frame = rocket_info:get_frame(player)
+ generate_progress(player,frame)
end
end
end
Event.add(defines.events.on_built_entity,on_built)
Event.add(defines.events.on_robot_built_entity,on_built)
+
+--- Optimised update for only the build progress
Event.on_nth_tick(150,function()
for _,force in pairs(game.forces) do
local silos = rocket_silos[force.name]
From 0ddf4676fe3bc0e38c3b918f1b7ccbd4786aa890 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Tue, 28 May 2019 01:20:58 +0100
Subject: [PATCH 12/41] Added config for silo script
---
config/advanced_start.lua | 3 +++
modules/addons/advanced-start.lua | 10 ++++++++
modules/factorio-control.lua | 39 ++++++++++++++++++++++---------
3 files changed, 41 insertions(+), 11 deletions(-)
diff --git a/config/advanced_start.lua b/config/advanced_start.lua
index 0847ac6d..586530ad 100644
--- a/config/advanced_start.lua
+++ b/config/advanced_start.lua
@@ -62,6 +62,9 @@ end
return {
skip_intro=true, -- skips the intro given in the default factorio free play scenario
+ skip_victory=true, -- will skip the victory screen when a rocket is launched
+ disable_base_game_silo_script=true, -- will not load the silo script at all
+ research_queue_from_start=true, -- when true the research queue is useible from the start
friendly_fire=false, -- weather players will be able to attack each other on the same force
enemy_expansion=false, -- a catch all for in case the map settings file fails to load
chart_radius=10*32, -- the number of tiles that will be charted when the map starts
diff --git a/modules/addons/advanced-start.lua b/modules/addons/advanced-start.lua
index 07ed9ddc..5379705b 100644
--- a/modules/addons/advanced-start.lua
+++ b/modules/addons/advanced-start.lua
@@ -31,4 +31,14 @@ Event.on_init(function()
remote.call('freeplay','set_created_items',{})
remote.call('freeplay','set_chart_distance',0)
remote.call('freeplay','set_skip_intro',config.skip_intro)
+ if config.research_queue_from_start then
+ for _,force in pairs(game.forces) do
+ force.research_queue_enabled = true
+ end
+ end
+ if not config.disable_base_game_silo_script then
+ if config.skip_victory then
+ remote.call('silo_script','set_no_victory',true)
+ end
+ end
end)
\ No newline at end of file
diff --git a/modules/factorio-control.lua b/modules/factorio-control.lua
index 13557506..20394547 100644
--- a/modules/factorio-control.lua
+++ b/modules/factorio-control.lua
@@ -1,8 +1,13 @@
local Event = require 'utils.event'
local Global = require 'utils.global'
+local config = require 'config.advanced_start'
+local use_silo_script = not config.disable_base_game_silo_script
local util = require("util")
-local silo_script = require("silo-script")
+local silo_script
+if use_silo_script then
+ silo_script = require("silo-script")
+end
local global = {}
Global.register(global,function(tbl)
@@ -29,8 +34,10 @@ local respawn_items = function()
}
end
-for k,v in pairs(silo_script.get_events()) do
- Event.add(k, v)
+if use_silo_script then
+ for k,v in pairs(silo_script.get_events()) do
+ Event.add(k, v)
+ end
end
Event.add(defines.events.on_player_created, function(event)
@@ -48,27 +55,37 @@ Event.add(defines.events.on_player_created, function(event)
end
end
- silo_script.on_event(event)
+ if use_silo_script then
+ silo_script.on_event(event)
+ end
end)
Event.add(defines.events.on_player_respawned, function(event)
local player = game.players[event.player_index]
util.insert_safe(player, global.respawn_items)
- silo_script.on_event(event)
+ if use_silo_script then
+ silo_script.on_event(event)
+ end
end)
-Event.on_load(function()
- silo_script.on_load()
-end)
+if use_silo_script then
+ Event.on_load(function()
+ silo_script.on_load()
+ end)
+end
Event.on_init(function()
global.created_items = created_items()
global.respawn_items = respawn_items()
- silo_script.on_init()
+ if use_silo_script then
+ silo_script.on_init()
+ end
end)
-silo_script.add_remote_interface()
-silo_script.add_commands()
+if use_silo_script then
+ silo_script.add_remote_interface()
+ silo_script.add_commands()
+end
remote.add_interface("freeplay",
{
From 84a377f4e57e81dccc18728f4d207e8c5b2510d0 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Tue, 28 May 2019 01:37:43 +0100
Subject: [PATCH 13/41] Updated config for rocket Gui
---
config/rockets.lua | 42 +++++++++++++++++--------------------
modules/gui/rocket-info.lua | 15 +++++++------
2 files changed, 28 insertions(+), 29 deletions(-)
diff --git a/config/rockets.lua b/config/rockets.lua
index f6e7cb3b..7025ae16 100644
--- a/config/rockets.lua
+++ b/config/rockets.lua
@@ -1,22 +1,18 @@
--- This file controls what will show in each section of the rocket info gui
--- each function will be given the player and must return the value to show and a tooltip, nil will not show the stat
-local Global = require 'utils.global'
-local Event = require 'utils.event'
-
return {
- stats = {
- show_stats=true,
- show_first_rocket = true,
- show_last_rocket = true,
- show_fastest_rocket = true,
- show_total_rockets = true,
- show_game_avg = true,
- rolling_avg = {
+ stats = { --- The data that will show in the stats section
+ show_stats=true, -- false will hide this section all together
+ show_first_rocket = true, -- false will not show when the first rocket was launched
+ show_last_rocket = true, -- false will not show when the last rocket was launched
+ show_fastest_rocket = true, -- false will not show the time taken for the fastest rocket
+ show_total_rockets = true, -- false will not show the total number of rockets launched
+ show_game_avg = true, -- false will hide the avg across the entire map time
+ rolling_avg = { -- each number will be one stat; 5 means the avg time taken for the last 5 rockets
5,10,25
}
},
- milestones = {
- show_milestones=true,
+ milestones = { -- each number will be one stat; 5 means the time that the 5th rocket was launched
+ show_milestones=true, -- false will hide this section all together
1,2,5,
10,20,50,
100,200,500,
@@ -24,14 +20,14 @@ return {
3000,3500,4000,4500,
5000
},
- progress = {
- show_progress = true,
- allow_zoom_to_map = true,
- allow_remote_launch = true,
- remote_launch_admins_only = false,
- remote_launch_role_permision = 'gui/rocket-info/remote_launch',
- allow_toggle_active = true,
- toggle_active_admins_only = false,
- toggle_active_role_permision = 'gui/rocket-info/toggle-active'
+ progress = { --- The data and buttons in the build progress section
+ show_progress = true, -- false will hide this section altogether
+ allow_zoom_to_map = true, -- false will disable the zoom to map feature
+ allow_remote_launch = true, -- false removes the remote launch button for all players
+ remote_launch_admins_only = false, -- true will remove the remote launch button for all non (game) admins
+ remote_launch_role_permision = 'gui/rocket-info/remote_launch', -- value used by custom permission system to allow or disllow the button
+ allow_toggle_active = true, -- false removes the remote toggle auto launch button for all players
+ toggle_active_admins_only = false, -- true will remove the toggle auto launch button for all non (game) admins
+ toggle_active_role_permision = 'gui/rocket-info/toggle-active' -- value used by custom permission system to allow or disllow the button
}
}
\ No newline at end of file
diff --git a/modules/gui/rocket-info.lua b/modules/gui/rocket-info.lua
index 3171643d..53734299 100644
--- a/modules/gui/rocket-info.lua
+++ b/modules/gui/rocket-info.lua
@@ -139,7 +139,7 @@ local function create_section(container,section_name,table_size)
name=section_name..'-header',
style='subheader_frame',
}
- Gui.set_padding(header,1,1,3,3)
+ Gui.set_padding(header,4,1,4,4)
header.style.horizontally_stretchable = true
--- Caption for the header bar
@@ -413,6 +413,8 @@ local function generate_progress(player,frame)
generate_progress_buttons(player,element,rocket_silo_data)
--- Creats two flows and two labels for the X and Y position
+ local name = config.progress.allow_zoom_to_map and zoom_to_map_name or nil
+ local tooltip = config.progress.allow_zoom_to_map and {'rocket-info.progress-label-tooltip'} or nil
local flow_x = element.add{
type='flow',
name='label-x-'..silo_name,
@@ -421,9 +423,9 @@ local function generate_progress(player,frame)
Gui.set_padding(flow_x,0,0,1,2)
flow_x.add{
type='label',
- name=zoom_to_map_name,
+ name=name,
caption={'rocket-info.progress-x-pos',pos.x},
- tooltip={'rocket-info.progress-label-tooltip'}
+ tooltip=tooltip
}
local flow_y = element.add{
@@ -434,9 +436,9 @@ local function generate_progress(player,frame)
Gui.set_padding(flow_y,0,0,1,2)
flow_y.add{
type='label',
- name=zoom_to_map_name,
+ name=name,
caption={'rocket-info.progress-y-pos',pos.y},
- tooltip={'rocket-info.progress-label-tooltip'}
+ tooltip=tooltip
}
--- Creates the progress value which is right aligned
@@ -483,7 +485,8 @@ Gui.new_left_frame('gui/rocket-info')
return player.force.rockets_launched > 0 and Gui.classes.toolbar.allowed(player,define_name)
end)
:set_open_by_default(function(player,define_name)
- return player.force.rockets_launched > 0
+ return true
+ --return player.force.rockets_launched > 0
end)
:set_direction('vertical')
:on_draw(function(player,element)
From 361438400f5ef52a19469b1e79a8cc269e7cb19d Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Tue, 28 May 2019 01:38:42 +0100
Subject: [PATCH 14/41] Removed debug open by deafult
---
modules/gui/rocket-info.lua | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/modules/gui/rocket-info.lua b/modules/gui/rocket-info.lua
index 53734299..6a62a6f4 100644
--- a/modules/gui/rocket-info.lua
+++ b/modules/gui/rocket-info.lua
@@ -485,8 +485,7 @@ Gui.new_left_frame('gui/rocket-info')
return player.force.rockets_launched > 0 and Gui.classes.toolbar.allowed(player,define_name)
end)
:set_open_by_default(function(player,define_name)
- return true
- --return player.force.rockets_launched > 0
+ return player.force.rockets_launched > 0
end)
:set_direction('vertical')
:on_draw(function(player,element)
From 53ebc00631c8d6f2c7a8f48779ce274602c997eb Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Tue, 28 May 2019 19:39:13 +0100
Subject: [PATCH 15/41] Added science info
---
config/_file_loader.lua | 3 +-
config/roles.lua | 1 +
expcore/common.lua | 12 +-
expcore/gui/left.lua | 4 +-
locale/en/gui.cfg | 13 +-
modules/gui/science-info.lua | 329 +++++++++++++++++++++++++++++++++++
6 files changed, 357 insertions(+), 5 deletions(-)
create mode 100644 modules/gui/science-info.lua
diff --git a/config/_file_loader.lua b/config/_file_loader.lua
index 746bbcb7..38857d22 100644
--- a/config/_file_loader.lua
+++ b/config/_file_loader.lua
@@ -34,8 +34,9 @@ return {
'modules.addons.pollution-grading',
'modules.addons.random-player-colours',
-- GUI
- 'modules.gui.player-list',
'modules.gui.rocket-info',
+ 'modules.gui.science-info',
+ 'modules.gui.player-list',
'modules.commands.debug',
-- Config Files
'config.expcore-commands.auth_admin', -- commands tagged with admin_only are blocked for non admins
diff --git a/config/roles.lua b/config/roles.lua
index 532b2db5..dab32e8f 100644
--- a/config/roles.lua
+++ b/config/roles.lua
@@ -190,6 +190,7 @@ local default = Roles.new_role('Guest','')
'command/report',
'gui/player-list',
'gui/rocket-info',
+ 'gui/science-info',
}
--- Jail role
diff --git a/expcore/common.lua b/expcore/common.lua
index 8e8c6e72..41adffd5 100644
--- a/expcore/common.lua
+++ b/expcore/common.lua
@@ -171,7 +171,8 @@ function Public.format_time(ticks,options)
seconds=false,
long=false,
time=false,
- string=false
+ string=false,
+ null=false
}
-- Basic numbers that are used in calculations
local max_days, max_hours, max_minutes, max_seconds = ticks/5184000, ticks/216000, ticks/3600, ticks/60
@@ -188,6 +189,13 @@ function Public.format_time(ticks,options)
if not options.minutes then
rtn_seconds = rtn_seconds + rtn_minutes*60
end
+ -- Creates the null time format, does not work with long
+ if options.null and not options.long then
+ rtn_days='--'
+ rtn_hours='--'
+ rtn_minutes='--'
+ rtn_seconds='--'
+ end
-- Format options
local suffix = 'time-symbol-'
local suffix_2 = '-short'
@@ -215,7 +223,7 @@ function Public.format_time(ticks,options)
rtn_minutes = {suffix..'minutes'..suffix_2,rtn_minutes}
rtn_seconds = {suffix..'seconds'..suffix_2,rtn_seconds}
end
- else
+ elseif not options.null then
-- weather string or not it has same format
rtn_days = string.format('%02d',rtn_days)
rtn_hours = string.format('%02d',rtn_hours)
diff --git a/expcore/gui/left.lua b/expcore/gui/left.lua
index aeb528d3..b96e587c 100644
--- a/expcore/gui/left.lua
+++ b/expcore/gui/left.lua
@@ -154,6 +154,8 @@ end
function LeftFrames._prototype:set_open_by_default(state)
if state == false then
self.open_by_default = false
+ elseif state == nil then
+ self.open_by_default = true
else
self.open_by_default = state
end
@@ -282,7 +284,7 @@ Event.add(defines.events.on_player_created,function(event)
define.events.on_draw(player,frame)
end
- if define.open_by_default == false then
+ if not define.open_by_default then
frame.visible = false
elseif type(define.open_by_default) == 'function' then
if not define.open_by_default(player,define.name) then
diff --git a/locale/en/gui.cfg b/locale/en/gui.cfg
index e7e2aee4..32b8088a 100644
--- a/locale/en/gui.cfg
+++ b/locale/en/gui.cfg
@@ -51,4 +51,15 @@ progress-y-pos=Y __1__
progress-label-tooltip=View on map
progress-launched=Launched
progress-caption=__1__%
-progress-tooltip=This silo has launched __1__ rockets
\ No newline at end of file
+progress-tooltip=This silo has launched __1__ rockets
+
+[science-info]
+main-caption=Science Packs
+main-tooltip=Science Info
+eta-caption=ETA:
+eta-tooltip=The estimated time left for the current research
+eta-time=T- __1__
+unit=__1__spm
+pos-tooltip=Total made: __1__
+neg-tooltip=Total used: __1__
+net-tooltip=Total net: __1__
\ No newline at end of file
diff --git a/modules/gui/science-info.lua b/modules/gui/science-info.lua
new file mode 100644
index 00000000..2775a168
--- /dev/null
+++ b/modules/gui/science-info.lua
@@ -0,0 +1,329 @@
+local Gui = require 'expcore.gui'
+local Event = require 'utils.event'
+local Colors = require 'resources.color_presets'
+local format_time = ext_require('expcore.common','format_time')
+local format_number = ext_require('util','format_number')
+
+local null_time_short = {'science-info.eta-time',format_time(0,{hours=true,minutes=true,seconds=true,time=true,null=true})}
+local null_time_long = format_time(0,{hours=true,minutes=true,seconds=true,long=true,null=true})
+
+local science_packs ={
+ red='automation-science-pack',
+ green='logistic-science-pack',
+ grey='military-science-pack',
+ blue='chemical-science-pack',
+ purple='production-science-pack',
+ yellow='utility-science-pack',
+ white='space-science-pack',
+}
+
+local function get_production_stats(player,science_pack)
+ local item_name = science_packs[science_pack]
+ local force = player.force
+ local stats = force.item_production_statistics
+ local total_made = stats.get_input_count(item_name)
+ local total_used = stats.get_output_count(item_name)
+ local minute_made = stats.get_flow_count{
+ name=item_name,
+ input=true,
+ precision_index=defines.flow_precision_index.one_minute,
+ }
+ local minute_used = stats.get_flow_count{
+ name=item_name,
+ input=false,
+ precision_index=defines.flow_precision_index.one_minute,
+ }
+ return {
+ total_made=total_made,
+ total_used=total_used,
+ total_net=total_made-total_used,
+ minute_made=minute_made,
+ minute_used=minute_used,
+ minute_net=minute_made-minute_used
+ }
+end
+
+local function get_font_colour(value,secondary)
+ if value > 1 then
+ return Colors.light_green
+ elseif value < -1 then
+ return Colors.indian_red
+ elseif secondary and secondary > 0 or not secondary and value ~= 0 then
+ return Colors.orange
+ else
+ return Colors.grey
+ end
+end
+
+local function generate_container(player,element)
+ Gui.set_padding(element,1,2,2,2)
+ element.style.minimal_width = 200
+
+ -- main container which contains the other elements
+ local container =
+ element.add{
+ name='container',
+ type='frame',
+ direction='vertical',
+ style='window_content_frame_packed'
+ }
+ Gui.set_padding(container)
+
+ -- main header for the gui
+ local header =
+ container.add{
+ name='header',
+ type='frame',
+ caption={'science-info.main-caption'},
+ style='subheader_frame'
+ }
+ Gui.set_padding(header,2,2,4,4)
+ header.style.horizontally_stretchable = true
+
+ -- main flow for the data
+ local flow =
+ container.add{
+ name='scroll',
+ type='scroll-pane',
+ direction='vertical',
+ horizontal_scroll_policy='never',
+ vertical_scroll_policy='auto-and-reserve-space'
+ }
+ Gui.set_padding(flow,1,1,2,2)
+ flow.style.horizontally_stretchable = true
+ flow.style.maximal_height = 185
+
+ -- table that stores all the data
+ local flow_table =
+ flow.add{
+ name='table',
+ type='table',
+ column_count=4
+ }
+ Gui.set_padding(flow_table)
+ flow_table.style.horizontally_stretchable = true
+ flow_table.style.vertical_align = 'center'
+
+ -- footer used to store the eta
+ local footer =
+ container.add{
+ name='footer',
+ type='frame',
+ style='subheader_frame'
+ }
+ Gui.set_padding(footer,2,2,4,4)
+ footer.style.horizontally_stretchable = true
+
+ -- label for the footer
+ footer.add{
+ name='eta-label',
+ type='label',
+ caption={'science-info.eta-caption'},
+ tooltip={'science-info.eta-tooltip'},
+ style='heading_1_label'
+ }
+
+ -- data for the footer
+ local right_align = Gui.create_right_align(footer,'eta')
+ local eta =
+ right_align.add{
+ name='label',
+ type='label',
+ caption=null_time_short,
+ tooltip=null_time_long,
+ style='heading_1_label'
+ }
+
+ return flow_table, eta
+end
+
+local function add_data_pair(element,name,value,secondary,tooltip)
+ local data_colour = get_font_colour(value,secondary)
+ local caption = format_number(math.round(value,1),true)
+
+ local surfix = caption:sub(-1)
+ if not tonumber(surfix) then
+ caption = caption:sub(1,-2)
+ else
+ surfix = ''
+ end
+
+ if value > 0 then
+ caption = '+'..caption
+ elseif value == 0 and caption:sub(1,1) == '-' then
+ caption = caption:sub(2)
+ end
+
+ if element[name] then
+ local data = element[name].label
+ data.caption = caption
+ data.tooltip = tooltip
+ data.style.font_color = data_colour
+ local label = element['spm-'..name]
+ label.caption = {'science-info.unit',surfix}
+ label.tooltip = tooltip
+ label.style.font_color = data_colour
+
+ else
+ -- right aligned number
+ local right_align = Gui.create_right_align(element,name)
+ local data =
+ right_align.add{
+ name='label',
+ type='label',
+ caption=caption,
+ tooltip=tooltip
+ }
+ data.style.font_color = data_colour
+
+ -- adds the unit onto the end
+ local label =
+ element.add{
+ name='spm-'..name,
+ type='label',
+ caption={'science-info.unit',surfix},
+ tooltip=tooltip
+ }
+ label.style.font_color = data_colour
+ end
+end
+
+local function generate_science_pack(player,element,pack_name)
+ local stats = get_production_stats(player,pack_name)
+ local item_name = science_packs[pack_name]
+ if stats.total_made > 0 then
+ local icon_style = 'quick_bar_slot_button'
+ if stats.minute_net > 1 then
+ icon_style = 'green_slot_button'
+ elseif stats.minute_net < -1 then
+ icon_style = 'red_slot_button'
+ elseif stats.minute_made > 0 then
+ icon_style = 'selected_slot_button'
+ end
+
+ local icon = element['icon-'..pack_name]
+
+ if icon then
+ icon.style = icon_style
+ icon.style.height = 55
+ if icon_style == 'quick_bar_slot_button' then
+ icon.style.width = 36
+ Gui.set_padding(icon,0,0,-2,-2)
+ end
+
+ else
+ icon =
+ element.add{
+ name='icon-'..pack_name,
+ type='sprite-button',
+ sprite='item/'..item_name,
+ tooltip={'item-name.'..item_name},
+ style=icon_style
+ }
+ icon.style.height = 55
+ if icon_style == 'quick_bar_slot_button' then
+ icon.style.width = 36
+ Gui.set_padding(icon,0,0,-2,-2)
+ end
+
+ end
+
+ local delta = element['delta-'..pack_name]
+
+ if not delta then
+ delta =
+ element.add{
+ name='delta-'..pack_name,
+ type='frame',
+ style='bordered_frame'
+ }
+ Gui.set_padding(delta,0,0,3,3)
+
+ local delta_table =
+ delta.add{
+ name='table',
+ type='table',
+ column_count=2
+ }
+ Gui.set_padding(delta_table)
+ end
+
+ add_data_pair(delta.table,'pos-'..pack_name,stats.minute_made,nil,{'science-info.pos-tooltip',stats.total_made})
+ add_data_pair(delta.table,'neg-'..pack_name,-stats.minute_used,nil,{'science-info.neg-tooltip',stats.total_used})
+ add_data_pair(element,'net-'..pack_name,stats.minute_net,stats.minute_made,{'science-info.net-tooltip',stats.total_net})
+ end
+end
+
+local function generate_eta(player,element)
+ local force = player.force
+ local research = force.current_research
+ if not research then
+ element.caption = null_time_short
+ element.tooltip = null_time_long
+
+ else
+ local progress = force.research_progress
+ local remaining = research.research_unit_count*(1-progress)
+ local limit
+
+ local stats = player.force.item_production_statistics
+ for _,ingredient in pairs(research.research_unit_ingredients) do
+ local pack_name = ingredient.name
+ local required = ingredient.amount * remaining
+ local consumed = stats.get_flow_count{
+ name=pack_name,
+ input=false,
+ precision_index=defines.flow_precision_index.one_minute,
+ }
+ if consumed == 0 then
+ limit = -1
+ break
+ end
+ local minutes = required / consumed
+ if not limit or limit < minutes then
+ limit = minutes
+ end
+ end
+
+ if not limit or limit == -1 then
+ element.caption = null_time_short
+ element.tooltip = null_time_long
+
+ else
+ local ticks = limit*3600
+ element.caption = {'science-info.eta-time',format_time(ticks,{hours=true,minutes=true,seconds=true,time=true})}
+ element.tooltip = format_time(ticks,{hours=true,minutes=true,seconds=true,long=true})
+
+ end
+ end
+end
+
+local science_info =
+Gui.new_left_frame('gui/science-info')
+:set_sprites('entity/lab')
+:set_direction('vertical')
+:set_tooltip{'science-info.main-tooltip'}
+:on_draw(function(player,element)
+ local table, eta = generate_container(player,element)
+
+ for pack_name,item_name in pairs(science_packs) do
+ generate_science_pack(player,table,pack_name)
+ end
+
+ generate_eta(player,eta)
+end)
+:on_update(function(player,element)
+ local container = element.container
+ local table = container.scroll.table
+ local eta = container.footer.eta.label
+
+ for pack_name,item_name in pairs(science_packs) do
+ generate_science_pack(player,table,pack_name)
+ end
+
+ generate_eta(player,eta)
+end)
+
+Event.on_nth_tick(60,science_info 'update_all')
+
+return science_info
\ No newline at end of file
From 81b99162989f1032d26c2547810b7ccc59af8516 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Tue, 28 May 2019 19:55:57 +0100
Subject: [PATCH 16/41] Small changes to science info
---
config/science.lua | 10 +++
locale/en/gui.cfg | 3 +-
modules/gui/science-info.lua | 126 ++++++++++++++++++-----------------
3 files changed, 78 insertions(+), 61 deletions(-)
create mode 100644 config/science.lua
diff --git a/config/science.lua b/config/science.lua
new file mode 100644
index 00000000..9fd7334a
--- /dev/null
+++ b/config/science.lua
@@ -0,0 +1,10 @@
+return {
+ show_eta=true,
+ 'automation-science-pack',
+ 'logistic-science-pack',
+ 'military-science-pack',
+ 'chemical-science-pack',
+ 'production-science-pack',
+ 'utility-science-pack',
+ 'space-science-pack',
+}
\ No newline at end of file
diff --git a/locale/en/gui.cfg b/locale/en/gui.cfg
index 32b8088a..d38a2e9c 100644
--- a/locale/en/gui.cfg
+++ b/locale/en/gui.cfg
@@ -62,4 +62,5 @@ eta-time=T- __1__
unit=__1__spm
pos-tooltip=Total made: __1__
neg-tooltip=Total used: __1__
-net-tooltip=Total net: __1__
\ No newline at end of file
+net-tooltip=Total net: __1__
+no-packs=You have not made any science packs yet
\ No newline at end of file
diff --git a/modules/gui/science-info.lua b/modules/gui/science-info.lua
index 2775a168..a0f63fcf 100644
--- a/modules/gui/science-info.lua
+++ b/modules/gui/science-info.lua
@@ -3,33 +3,23 @@ local Event = require 'utils.event'
local Colors = require 'resources.color_presets'
local format_time = ext_require('expcore.common','format_time')
local format_number = ext_require('util','format_number')
+local config = require 'config.science'
local null_time_short = {'science-info.eta-time',format_time(0,{hours=true,minutes=true,seconds=true,time=true,null=true})}
local null_time_long = format_time(0,{hours=true,minutes=true,seconds=true,long=true,null=true})
-local science_packs ={
- red='automation-science-pack',
- green='logistic-science-pack',
- grey='military-science-pack',
- blue='chemical-science-pack',
- purple='production-science-pack',
- yellow='utility-science-pack',
- white='space-science-pack',
-}
-
local function get_production_stats(player,science_pack)
- local item_name = science_packs[science_pack]
local force = player.force
local stats = force.item_production_statistics
- local total_made = stats.get_input_count(item_name)
- local total_used = stats.get_output_count(item_name)
+ local total_made = stats.get_input_count(science_pack)
+ local total_used = stats.get_output_count(science_pack)
local minute_made = stats.get_flow_count{
- name=item_name,
+ name=science_pack,
input=true,
precision_index=defines.flow_precision_index.one_minute,
}
local minute_used = stats.get_flow_count{
- name=item_name,
+ name=science_pack,
input=false,
precision_index=defines.flow_precision_index.one_minute,
}
@@ -44,9 +34,9 @@ local function get_production_stats(player,science_pack)
end
local function get_font_colour(value,secondary)
- if value > 1 then
+ if value > 5 then
return Colors.light_green
- elseif value < -1 then
+ elseif value < -5 then
return Colors.indian_red
elseif secondary and secondary > 0 or not secondary and value ~= 0 then
return Colors.orange
@@ -79,6 +69,7 @@ local function generate_container(player,element)
}
Gui.set_padding(header,2,2,4,4)
header.style.horizontally_stretchable = true
+ header.style.use_header_filler = false
-- main flow for the data
local flow =
@@ -93,6 +84,16 @@ local function generate_container(player,element)
flow.style.horizontally_stretchable = true
flow.style.maximal_height = 185
+ -- message to say that you have not made any packs yet
+ local non_made =
+ flow.add{
+ name='non_made',
+ type='label',
+ caption={'science-info.no-packs'}
+ }
+ non_made.style.width = 200
+ non_made.style.single_line = false
+
-- table that stores all the data
local flow_table =
flow.add{
@@ -104,35 +105,38 @@ local function generate_container(player,element)
flow_table.style.horizontally_stretchable = true
flow_table.style.vertical_align = 'center'
- -- footer used to store the eta
- local footer =
- container.add{
- name='footer',
- type='frame',
- style='subheader_frame'
- }
- Gui.set_padding(footer,2,2,4,4)
- footer.style.horizontally_stretchable = true
+ local eta
+ if config.show_eta then
+ -- footer used to store the eta
+ local footer =
+ container.add{
+ name='footer',
+ type='frame',
+ style='subheader_frame'
+ }
+ Gui.set_padding(footer,2,2,4,4)
+ footer.style.horizontally_stretchable = true
- -- label for the footer
- footer.add{
- name='eta-label',
- type='label',
- caption={'science-info.eta-caption'},
- tooltip={'science-info.eta-tooltip'},
- style='heading_1_label'
- }
+ -- label for the footer
+ footer.add{
+ name='eta-label',
+ type='label',
+ caption={'science-info.eta-caption'},
+ tooltip={'science-info.eta-tooltip'},
+ style='heading_1_label'
+ }
- -- data for the footer
- local right_align = Gui.create_right_align(footer,'eta')
- local eta =
- right_align.add{
- name='label',
- type='label',
- caption=null_time_short,
- tooltip=null_time_long,
- style='heading_1_label'
- }
+ -- data for the footer
+ local right_align = Gui.create_right_align(footer,'eta')
+ eta =
+ right_align.add{
+ name='label',
+ type='label',
+ caption=null_time_short,
+ tooltip=null_time_long,
+ style='heading_1_label'
+ }
+ end
return flow_table, eta
end
@@ -188,10 +192,11 @@ local function add_data_pair(element,name,value,secondary,tooltip)
end
end
-local function generate_science_pack(player,element,pack_name)
- local stats = get_production_stats(player,pack_name)
- local item_name = science_packs[pack_name]
+local function generate_science_pack(player,element,science_pack)
+ local stats = get_production_stats(player,science_pack)
if stats.total_made > 0 then
+ element.parent.non_made.visible = false
+
local icon_style = 'quick_bar_slot_button'
if stats.minute_net > 1 then
icon_style = 'green_slot_button'
@@ -201,7 +206,7 @@ local function generate_science_pack(player,element,pack_name)
icon_style = 'selected_slot_button'
end
- local icon = element['icon-'..pack_name]
+ local icon = element['icon-'..science_pack]
if icon then
icon.style = icon_style
@@ -214,10 +219,10 @@ local function generate_science_pack(player,element,pack_name)
else
icon =
element.add{
- name='icon-'..pack_name,
+ name='icon-'..science_pack,
type='sprite-button',
- sprite='item/'..item_name,
- tooltip={'item-name.'..item_name},
+ sprite='item/'..science_pack,
+ tooltip={'item-name.'..science_pack},
style=icon_style
}
icon.style.height = 55
@@ -228,12 +233,12 @@ local function generate_science_pack(player,element,pack_name)
end
- local delta = element['delta-'..pack_name]
+ local delta = element['delta-'..science_pack]
if not delta then
delta =
element.add{
- name='delta-'..pack_name,
+ name='delta-'..science_pack,
type='frame',
style='bordered_frame'
}
@@ -248,13 +253,14 @@ local function generate_science_pack(player,element,pack_name)
Gui.set_padding(delta_table)
end
- add_data_pair(delta.table,'pos-'..pack_name,stats.minute_made,nil,{'science-info.pos-tooltip',stats.total_made})
- add_data_pair(delta.table,'neg-'..pack_name,-stats.minute_used,nil,{'science-info.neg-tooltip',stats.total_used})
- add_data_pair(element,'net-'..pack_name,stats.minute_net,stats.minute_made,{'science-info.net-tooltip',stats.total_net})
+ add_data_pair(delta.table,'pos-'..science_pack,stats.minute_made,nil,{'science-info.pos-tooltip',stats.total_made})
+ add_data_pair(delta.table,'neg-'..science_pack,-stats.minute_used,nil,{'science-info.neg-tooltip',stats.total_used})
+ add_data_pair(element,'net-'..science_pack,stats.minute_net,stats.minute_made,{'science-info.net-tooltip',stats.total_net})
end
end
local function generate_eta(player,element)
+ if not config.show_eta then return end
local force = player.force
local research = force.current_research
if not research then
@@ -306,8 +312,8 @@ Gui.new_left_frame('gui/science-info')
:on_draw(function(player,element)
local table, eta = generate_container(player,element)
- for pack_name,item_name in pairs(science_packs) do
- generate_science_pack(player,table,pack_name)
+ for _,science_pack in ipairs(config) do
+ generate_science_pack(player,table,science_pack)
end
generate_eta(player,eta)
@@ -317,8 +323,8 @@ end)
local table = container.scroll.table
local eta = container.footer.eta.label
- for pack_name,item_name in pairs(science_packs) do
- generate_science_pack(player,table,pack_name)
+ for _,science_pack in ipairs(config) do
+ generate_science_pack(player,table,science_pack)
end
generate_eta(player,eta)
From df014a12077ce7d223d0712161d25cab04102afc Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Wed, 29 May 2019 19:01:32 +0100
Subject: [PATCH 17/41] Added task list
---
config/_file_loader.lua | 1 +
config/roles.lua | 2 +
config/tasks.lua | 4 +
expcore/gui/left.lua | 2 +-
locale/en/gui.cfg | 15 +-
modules/gui/task-list.lua | 371 ++++++++++++++++++++++++++++++++++++++
6 files changed, 393 insertions(+), 2 deletions(-)
create mode 100644 config/tasks.lua
create mode 100644 modules/gui/task-list.lua
diff --git a/config/_file_loader.lua b/config/_file_loader.lua
index 38857d22..23eb99dd 100644
--- a/config/_file_loader.lua
+++ b/config/_file_loader.lua
@@ -36,6 +36,7 @@ return {
-- GUI
'modules.gui.rocket-info',
'modules.gui.science-info',
+ 'modules.gui.task-list',
'modules.gui.player-list',
'modules.commands.debug',
-- Config Files
diff --git a/config/roles.lua b/config/roles.lua
index dab32e8f..ebc40583 100644
--- a/config/roles.lua
+++ b/config/roles.lua
@@ -159,6 +159,7 @@ Roles.new_role('Member','Mem')
:set_custom_color{r=24,g=172,b=188}
:set_parent('Regular')
:allow{
+ 'gui/task-list/edit'
}
Roles.new_role('Regular','Reg')
@@ -191,6 +192,7 @@ local default = Roles.new_role('Guest','')
'gui/player-list',
'gui/rocket-info',
'gui/science-info',
+ 'gui/task-list',
}
--- Jail role
diff --git a/config/tasks.lua b/config/tasks.lua
new file mode 100644
index 00000000..0a1a3d13
--- /dev/null
+++ b/config/tasks.lua
@@ -0,0 +1,4 @@
+return {
+ only_admins_can_edit = false,
+ edit_tasks_role_permision = 'gui/task-list/edit'
+}
\ No newline at end of file
diff --git a/expcore/gui/left.lua b/expcore/gui/left.lua
index b96e587c..35a8b66b 100644
--- a/expcore/gui/left.lua
+++ b/expcore/gui/left.lua
@@ -243,7 +243,7 @@ function LeftFrames._prototype:event_handler(action)
action = action or 'update'
return function(event)
local player
- if event.player_index then
+ if event and event.player_index then
player = Game.get_player_by_index(event.player_index)
end
self[action](self,player)
diff --git a/locale/en/gui.cfg b/locale/en/gui.cfg
index d38a2e9c..882562a3 100644
--- a/locale/en/gui.cfg
+++ b/locale/en/gui.cfg
@@ -63,4 +63,17 @@ unit=__1__spm
pos-tooltip=Total made: __1__
neg-tooltip=Total used: __1__
net-tooltip=Total net: __1__
-no-packs=You have not made any science packs yet
\ No newline at end of file
+no-packs=You have not made any science packs yet
+
+[task-list]
+main-caption=Task List
+main-tooltip=Task list
+sub-tooltip=Tasks that remain to be done
+no-tasks=You have no tasks
+last-edit=Last edited by __1__ at __2__
+add-tooltip=Add new task
+confirm-tooltip=Save changes
+cancel-tooltip=Discard changes
+edit-tooltip=Currently being edited by: __1__
+edit-tooltip-none=Currently being edited by: Nobody
+discord-tooltip=Remove task
\ No newline at end of file
diff --git a/modules/gui/task-list.lua b/modules/gui/task-list.lua
new file mode 100644
index 00000000..6a1b82c8
--- /dev/null
+++ b/modules/gui/task-list.lua
@@ -0,0 +1,371 @@
+local Gui = require 'expcore.gui'
+local Store = require 'expcore.store'
+local Global = require 'utils.global'
+local Roles = require 'expcore.roles'
+local Token = require 'utils.token'
+local config = require 'config.tasks'
+local format_time,table_keys = ext_require('expcore.common','format_time','table_keys')
+
+local task_store = 'gui.left.task-list.tasks'
+
+local task_details = {}
+local force_tasks = {}
+Global.register({
+ task_details=task_details,
+ force_tasks=force_tasks
+},function(tbl)
+ task_details = tbl.task_details
+ force_tasks = tbl.force_tasks
+end)
+
+local function add_task(player,task_number)
+ local task_id = tostring(Token.uid())
+
+ if not force_tasks[player.force.name] then
+ force_tasks[player.force.name] = {}
+ end
+ if task_number then
+ table.insert(force_tasks[player.force.name],task_number,task_id)
+ else
+ table.insert(force_tasks[player.force.name],task_id)
+ end
+
+ task_details[task_id] = {
+ task_id=task_id,
+ force=player.force.name,
+ last_edit_player=player.name,
+ last_edit_time=game.tick,
+ editing={[player.name]=true}
+ }
+
+ Store.set_child(task_store,task_id,'test')
+end
+
+local function remove_task(task_id)
+ local force_name = task_details[task_id].force
+ Store.set_child(task_store,task_id)
+ task_details[task_id] = nil
+ table.remove_element(force_tasks[force_name],task_id)
+end
+
+local function player_allowed_edit(player)
+ if config.only_admins_can_edit and not player.admin then
+ return false
+ end
+
+ if config.edit_tasks_role_permision and not Roles.player_allowed(player,config.edit_tasks_role_permision) then
+ return false
+ end
+
+ return true
+end
+
+local update_all
+local add_new_task_end =
+Gui.new_button()
+:set_sprites('utility/add')
+:set_tooltip{'task-list.add-tooltip'}
+:set_style('tool_button',function(style)
+ Gui.set_padding_style(style,-2,-2,-2,-2)
+ style.height = 20
+ style.width = 20
+end)
+:on_click(function(player,element)
+ add_task(player)
+end)
+
+local confirm_edit =
+Gui.new_button()
+:set_sprites('utility/downloaded')
+:set_tooltip{'task-list.confirm-tooltip'}
+:set_style('tool_button',function(style)
+ Gui.set_padding_style(style,-2,-2,-2,-2)
+ style.height = 20
+ style.width = 20
+end)
+:on_click(function(player,element)
+ local task_id = element.parent.name
+ local task = element.parent.task.text
+ local details = task_details[task_id]
+ details.editing[player.name] = nil
+ Store.set_child(task_store,task_id,task)
+end)
+
+local generate_task
+local cancel_edit =
+Gui.new_button()
+:set_sprites('utility/close_black')
+:set_tooltip{'task-list.cancel-tooltip'}
+:set_style('tool_button',function(style)
+ Gui.set_padding_style(style,-2,-2,-2,-2)
+ style.height = 20
+ style.width = 20
+end)
+:on_click(function(player,element)
+ local task_id = element.parent.name
+ local details = task_details[task_id]
+ details.editing[player.name] = nil
+ generate_task(player,element.parent.parent,task_id)
+end)
+
+local discard_task =
+Gui.new_button()
+:set_sprites('utility/trash')
+:set_tooltip{'task-list.discord-tooltip'}
+:set_style('tool_button',function(style)
+ Gui.set_padding_style(style,-2,-2,-2,-2)
+ style.height = 20
+ style.width = 20
+end)
+:on_click(function(player,element)
+ local task_id = element.parent.caption
+ remove_task(task_id)
+ update_all()
+end)
+
+local edit_task =
+Gui.new_button()
+:set_sprites('utility/rename_icon_normal')
+:set_tooltip{'task-list.edit-tooltip-none'}
+:set_style('tool_button',function(style)
+ Gui.set_padding_style(style,-2,-2,-2,-2)
+ style.height = 20
+ style.width = 20
+end)
+:on_click(function(player,element)
+ local task_id = element.parent.caption
+ local details = task_details[task_id]
+ details.editing[player.name] = true
+ generate_task(player,element.parent.parent,task_id)
+end)
+
+function generate_task(player,element,task_id)
+ local task = Store.get_child(task_store,task_id)
+ local details = task_details[task_id]
+ local editing = details.editing[player.name]
+ local last_edit_player = details.last_edit_player
+ local last_edit_time = details.last_edit_time
+ local tasks = force_tasks[player.force.name]
+ local task_number = table.index_of(tasks, task_id)
+
+ if not task then
+ element.parent.no_tasks.visible = #tasks == 01
+ Gui.destory_if_valid(element['count-'..task_id])
+ Gui.destory_if_valid(element['edit-'..task_id])
+ Gui.destory_if_valid(element[task_id])
+
+ else
+ element.parent.no_tasks.visible = false
+ local task_area = element[task_id]
+ if not task_area then
+ -- label to show the task number
+ local top_align = element.add{
+ name='count-'..task_id,
+ type='flow'
+ }
+ top_align.style.vertical_align = 'top'
+ top_align.style.vertically_stretchable = true
+ top_align.add{
+ name='label',
+ type='label',
+ caption=task_number..')'
+ }
+ -- area which stores the task and buttons
+ task_area =
+ element.add{
+ name=task_id,
+ type='flow',
+ }
+ Gui.set_padding(task_area)
+ task_area.style.vertical_align = 'top'
+
+ if player_allowed_edit(player) then
+ local flow = Gui.create_right_align(element,'edit-'..task_id)
+ flow.caption = task_id
+ flow.style.vertical_align = 'top'
+ flow.style.vertically_stretchable = true
+
+ edit_task(flow)
+ discard_task(flow)
+ end
+
+ end
+
+ element['count-'..task_id].label.caption = task_number..')'
+ if element['edit-'..task_id] then
+ local players = table_keys(details.editing)
+ if #players > 0 then
+ element['edit-'..task_id][edit_task.name].tooltip = {'task-list.edit-tooltip',table.concat(players,', ')}
+ else
+ element['edit-'..task_id][edit_task.name].tooltip = {'task-list.edit-tooltip-none'}
+ end
+ end
+
+ local element_type = task_area.task and task_area.task.type or nil
+ if not editing and element_type == 'label' then
+ -- update the label already present
+ task_area.task.caption = task
+ task_area.task.tooltip = {'task-list.last-edit',last_edit_player,format_time(last_edit_time)}
+
+ elseif not editing then
+ -- create the label
+ if element['edit-'..task_id] then
+ element['edit-'..task_id][edit_task.name].enabled = true
+ end
+
+ task_area.clear()
+
+ local label =
+ task_area.add{
+ name='task',
+ type='label',
+ caption=task,
+ tooltip={'task-list.last-edit',last_edit_player,format_time(last_edit_time)}
+ }
+ label.style.single_line = false
+ label.style.maximal_width = 150
+
+ elseif editing and element_type ~= 'textfield' then
+ -- create the text field
+ if element['edit-'..task_id] then
+ element['edit-'..task_id][edit_task.name].enabled = false
+ end
+
+ task_area.clear()
+
+ local entry =
+ task_area.add{
+ name='task',
+ type='textfield',
+ text=task
+ }
+ entry.style.maximal_width = 150
+ entry.style.height = 20
+
+ cancel_edit(task_area)
+ confirm_edit(task_area)
+
+ end
+
+ end
+
+end
+
+local function generate_container(player,element)
+ Gui.set_padding(element,2,2,2,2)
+ element.style.minimal_width = 200
+
+ -- main container which contains the other elements
+ local container =
+ element.add{
+ name='container',
+ type='frame',
+ direction='vertical',
+ style='window_content_frame_packed'
+ }
+ Gui.set_padding(container)
+ container.style.vertically_stretchable = false
+
+ -- main header for the gui
+ local header =
+ container.add{
+ name='header',
+ type='frame',
+ style='subheader_frame'
+ }
+ Gui.set_padding(header,2,2,4,4)
+ header.style.horizontally_stretchable = true
+ header.style.use_header_filler = false
+
+ --- Caption for the header bar
+ header.add{
+ type='label',
+ style='heading_1_label',
+ caption={'task-list.main-caption'},
+ tooltip={'task-list.sub-tooltip'}
+ }
+
+ --- Right aligned button to toggle the section
+ local right_align = Gui.create_right_align(header)
+ add_new_task_end(right_align)
+
+ -- main flow for the data
+ local flow =
+ container.add{
+ name='scroll',
+ type='scroll-pane',
+ direction='vertical',
+ horizontal_scroll_policy='never',
+ vertical_scroll_policy='auto-and-reserve-space'
+ }
+ Gui.set_padding(flow,1,1,2,2)
+ flow.style.horizontally_stretchable = true
+ flow.style.maximal_height = 185
+
+ -- message to say that you have no tasks
+ local non_made =
+ flow.add{
+ name='no_tasks',
+ type='label',
+ caption={'task-list.no-tasks'}
+ }
+ non_made.style.width = 200
+ non_made.style.single_line = false
+
+ -- table that stores all the data
+ local col_count = 2
+ if player_allowed_edit(player) then col_count = col_count+1 end
+ local flow_table =
+ flow.add{
+ name='table',
+ type='table',
+ column_count=col_count,
+ draw_horizontal_lines=true
+ }
+ Gui.set_padding(flow_table)
+ flow_table.style.horizontally_stretchable = true
+ flow_table.style.top_cell_padding = 3
+ flow_table.style.bottom_cell_padding = 3
+
+ return flow_table
+end
+
+local task_list =
+Gui.new_left_frame('gui/task-list')
+:set_sprites('utility/not_enough_repair_packs_icon')
+:set_direction('vertical')
+:set_tooltip{'task-list.main-tooltip'}
+:set_open_by_default()
+:on_draw(function(player,element)
+ local data_table = generate_container(player,element)
+ local force_name = player.force.name
+
+ local tasks = force_tasks[force_name] or {}
+ for _,task_id in pairs(tasks) do
+ generate_task(player,data_table,task_id)
+ end
+end)
+:on_update(function(player,element)
+ local data_table = element.container.scroll.table
+ local force_name = player.force.name
+
+ local tasks = force_tasks[force_name] or {}
+ for _,task_id in pairs(tasks) do
+ generate_task(player,data_table,task_id)
+ end
+end)
+
+update_all = task_list 'update_all'
+
+Store.register(task_store,function(value,task_id)
+ local details = task_details[task_id]
+ local force = game.forces[details.force]
+
+ for _,player in pairs(force.players) do
+ local frame = task_list:get_frame(player)
+ local element = frame.container.scroll.table
+ generate_task(player,element,task_id)
+ end
+end)
+
+return task_list
\ No newline at end of file
From a79440a840407ab00f20382718a1eeeff9949194 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Wed, 29 May 2019 19:11:23 +0100
Subject: [PATCH 18/41] Added comments
---
config/tasks.lua | 4 ++--
modules/gui/task-list.lua | 43 +++++++++++++++++++++++++++++++++++----
2 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/config/tasks.lua b/config/tasks.lua
index 0a1a3d13..7b1502e5 100644
--- a/config/tasks.lua
+++ b/config/tasks.lua
@@ -1,4 +1,4 @@
return {
- only_admins_can_edit = false,
- edit_tasks_role_permision = 'gui/task-list/edit'
+ only_admins_can_edit = false, -- true will hide the edit and delete buttons from non (game) admins
+ edit_tasks_role_permision = 'gui/task-list/edit' -- value used with custom permision system
}
\ No newline at end of file
diff --git a/modules/gui/task-list.lua b/modules/gui/task-list.lua
index 6a1b82c8..713435c3 100644
--- a/modules/gui/task-list.lua
+++ b/modules/gui/task-list.lua
@@ -18,6 +18,7 @@ Global.register({
force_tasks = tbl.force_tasks
end)
+--- Adds a new task for this force with this players name attached
local function add_task(player,task_number)
local task_id = tostring(Token.uid())
@@ -41,6 +42,7 @@ local function add_task(player,task_number)
Store.set_child(task_store,task_id,'test')
end
+--- Removes all refrences to a task
local function remove_task(task_id)
local force_name = task_details[task_id].force
Store.set_child(task_store,task_id)
@@ -48,6 +50,7 @@ local function remove_task(task_id)
table.remove_element(force_tasks[force_name],task_id)
end
+--- If a player is allowed to use the edit buttons
local function player_allowed_edit(player)
if config.only_admins_can_edit and not player.admin then
return false
@@ -60,8 +63,9 @@ local function player_allowed_edit(player)
return true
end
+--- Button in the header to add a new task
local update_all
-local add_new_task_end =
+local add_new_task =
Gui.new_button()
:set_sprites('utility/add')
:set_tooltip{'task-list.add-tooltip'}
@@ -74,6 +78,7 @@ end)
add_task(player)
end)
+--- Used to save changes to a task
local confirm_edit =
Gui.new_button()
:set_sprites('utility/downloaded')
@@ -91,6 +96,7 @@ end)
Store.set_child(task_store,task_id,task)
end)
+--- Used to cancel any changes you made to a task
local generate_task
local cancel_edit =
Gui.new_button()
@@ -108,6 +114,7 @@ end)
generate_task(player,element.parent.parent,task_id)
end)
+--- Removes the task from the list
local discard_task =
Gui.new_button()
:set_sprites('utility/trash')
@@ -123,6 +130,7 @@ end)
update_all()
end)
+--- Opens edit mode for the task
local edit_task =
Gui.new_button()
:set_sprites('utility/rename_icon_normal')
@@ -139,6 +147,18 @@ end)
generate_task(player,element.parent.parent,task_id)
end)
+--[[ Generates each task, handles both view and edit mode
+ element
+ > count-"task_id"
+ >> label
+ > "task_id"
+ >> task
+ >> cancel_edit (edit mode)
+ >> confirm_edit (edit mode)
+ > edit-"task_id"
+ >> edit_task
+ >> discard_task
+]]
function generate_task(player,element,task_id)
local task = Store.get_child(task_store,task_id)
local details = task_details[task_id]
@@ -149,6 +169,7 @@ function generate_task(player,element,task_id)
local task_number = table.index_of(tasks, task_id)
if not task then
+ -- task is nil so remove it from the list
element.parent.no_tasks.visible = #tasks == 01
Gui.destory_if_valid(element['count-'..task_id])
Gui.destory_if_valid(element['edit-'..task_id])
@@ -156,6 +177,7 @@ function generate_task(player,element,task_id)
else
element.parent.no_tasks.visible = false
+ -- if it is not already present then add it now
local task_area = element[task_id]
if not task_area then
-- label to show the task number
@@ -170,6 +192,7 @@ function generate_task(player,element,task_id)
type='label',
caption=task_number..')'
}
+
-- area which stores the task and buttons
task_area =
element.add{
@@ -179,6 +202,7 @@ function generate_task(player,element,task_id)
Gui.set_padding(task_area)
task_area.style.vertical_align = 'top'
+ -- if the player can edit then it adds the edit and delete button
if player_allowed_edit(player) then
local flow = Gui.create_right_align(element,'edit-'..task_id)
flow.caption = task_id
@@ -191,6 +215,7 @@ function generate_task(player,element,task_id)
end
+ -- update the number indexes and the current editing players
element['count-'..task_id].label.caption = task_number..')'
if element['edit-'..task_id] then
local players = table_keys(details.editing)
@@ -201,6 +226,7 @@ function generate_task(player,element,task_id)
end
end
+ -- draws/updates the task area
local element_type = task_area.task and task_area.task.type or nil
if not editing and element_type == 'label' then
-- update the label already present
@@ -208,7 +234,7 @@ function generate_task(player,element,task_id)
task_area.task.tooltip = {'task-list.last-edit',last_edit_player,format_time(last_edit_time)}
elseif not editing then
- -- create the label
+ -- create the label, view mode
if element['edit-'..task_id] then
element['edit-'..task_id][edit_task.name].enabled = true
end
@@ -226,7 +252,7 @@ function generate_task(player,element,task_id)
label.style.maximal_width = 150
elseif editing and element_type ~= 'textfield' then
- -- create the text field
+ -- create the text field, edit mode, update it omited as value is being edited
if element['edit-'..task_id] then
element['edit-'..task_id][edit_task.name].enabled = false
end
@@ -251,6 +277,15 @@ function generate_task(player,element,task_id)
end
+--[[ generates the main gui structure
+ element
+ > container
+ >> header
+ >>> right aligned add_new_task
+ >> scroll
+ >>> no_tasks
+ >>> table
+]]
local function generate_container(player,element)
Gui.set_padding(element,2,2,2,2)
element.style.minimal_width = 200
@@ -287,7 +322,7 @@ local function generate_container(player,element)
--- Right aligned button to toggle the section
local right_align = Gui.create_right_align(header)
- add_new_task_end(right_align)
+ add_new_task(right_align)
-- main flow for the data
local flow =
From 31e67f8a1c999fe25fb74f7f3603181ecca673cd Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Wed, 29 May 2019 19:35:16 +0100
Subject: [PATCH 19/41] Added comments to config files
---
config/action_buttons.lua | 26 ++++++++++++++++++++++----
config/compilatron.lua | 1 +
config/preset_player_colours.lua | 1 +
config/repair.lua | 11 ++++++-----
config/science.lua | 5 +++--
config/tasks.lua | 1 +
6 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/config/action_buttons.lua b/config/action_buttons.lua
index cd48100d..10002094 100644
--- a/config/action_buttons.lua
+++ b/config/action_buttons.lua
@@ -1,3 +1,8 @@
+--- Config for the different action buttons that show on the player list
+-- each button has the button define(s) given along side an auth function, and optional reason callback
+-- if a reason callback is used then Store.set_child(action_name_store,player.name,'BUTTON_NAME') should be called during on_click
+-- buttons can be removed from the gui by commenting them out of the config at the bottom of this file
+-- the key used for the name of the button is the permision name used by the role system
local Gui = require 'expcore.gui'
local Roles = require 'expcore.roles'
local Store = require 'expcore.store'
@@ -10,12 +15,14 @@ local format_chat_player_name = ext_require('expcore.common','format_chat_player
local action_player_store = 'gui.left.player-list.action-player'
local action_name_store = 'gui.left.player-list.action-name'
+-- common style used by all action buttons
local function tool_button_style(style)
Gui.set_padding_style(style,-1,-1,-1,-1)
style.height = 28
style.width = 28
end
+-- auth that will only allow when on player's of lower roles
local function auth_lower_role(player,action_player_name)
local player_highest = Roles.get_player_highest_role(player)
local action_player_highest = Roles.get_player_highest_role(action_player_name)
@@ -24,6 +31,7 @@ local function auth_lower_role(player,action_player_name)
end
end
+-- gets the action player and a coloured name for the action to be used on
local function get_action_player(player)
local action_player_name = Store.get_child(action_player_store,player.name)
local action_player = Game.get_player_from_any(action_player_name)
@@ -31,6 +39,7 @@ local function get_action_player(player)
return action_player,action_player_name_color
end
+-- telports one player to another
local function teleport(from_player,to_player)
local surface = to_player.surface
local position = surface.find_non_colliding_position('character',to_player.position,32,1)
@@ -40,6 +49,7 @@ local function teleport(from_player,to_player)
return true
end
+-- teleports the user to the action player
local goto_player =
Gui.new_button()
:set_sprites('utility/export')
@@ -50,6 +60,7 @@ Gui.new_button()
teleport(player,action_player)
end)
+-- teleports the action player to the user
local bring_player =
Gui.new_button()
:set_sprites('utility/import')
@@ -60,6 +71,7 @@ Gui.new_button()
teleport(action_player,player)
end)
+-- kills the action player, if there are alive
local kill_player =
Gui.new_button()
:set_sprites('utility/too_far')
@@ -72,6 +84,7 @@ Gui.new_button()
end
end)
+-- reports the action player, requires a reason to be given
local report_player =
Gui.new_button()
:set_sprites('utility/spawn_flag')
@@ -89,6 +102,7 @@ local function report_player_callback(player,reason)
Reports.report_player(action_player,reason,player.name)
end
+-- gives the action player a warning, requires a reason
local warn_player =
Gui.new_button()
:set_sprites('utility/spawn_flag')
@@ -105,6 +119,7 @@ local function warn_player_callback(player,reason)
Warnings.add_warnings(action_player,player.name)
end
+-- jails the action player, requires a reason
local jail_player =
Gui.new_button()
:set_sprites('utility/item_editor_icon')
@@ -121,6 +136,7 @@ local function jail_player_callback(player,reason)
Jail.jail_player(action_player,player.name)
end
+-- temp bans the action player, requires a reason
local temp_ban_player =
Gui.new_button()
:set_sprites('utility/clock')
@@ -135,6 +151,7 @@ local function temp_ban_player_callback(player,reason)
Jail.temp_ban_player(action_player,player.name,reason)
end
+-- kicks the action player, requires a reason
local kick_player =
Gui.new_button()
:set_sprites('utility/warning_icon')
@@ -149,6 +166,7 @@ local function kick_player_callback(player,reason)
game.kick_player(action_player,reason)
end
+-- bans the action player, requires a reason
local ban_player =
Gui.new_button()
:set_sprites('utility/danger_icon')
@@ -167,7 +185,7 @@ return {
['command/teleport'] = {
auth=function(player,action_player_name)
return player.name ~= action_player_name
- end,
+ end, -- cant teleport to your self
goto_player,
bring_player
},
@@ -178,7 +196,7 @@ return {
elseif Roles.player_allowed(player,'command/kill/always') then
return auth_lower_role(player,action_player_name)
end
- end,
+ end, -- player must be lower role, or your self
kill_player
},
['command/report'] = {
@@ -186,12 +204,12 @@ return {
if not Roles.player_allowed(player,'command/give-warning') then
return not Roles.player_has_flag(action_player_name,'report-immune')
end
- end,
+ end, -- can report any player that isnt immune and you arnt able to give warnings
reason_callback=report_player_callback,
report_player
},
['command/give-warning'] = {
- auth=auth_lower_role,
+ auth=auth_lower_role, -- warn a lower user, replaces report
reason_callback=warn_player_callback,
warn_player
},
diff --git a/config/compilatron.lua b/config/compilatron.lua
index a4980f92..47ffccb3 100644
--- a/config/compilatron.lua
+++ b/config/compilatron.lua
@@ -1,3 +1,4 @@
+-- config file for the compliatrons including where they spawn and what messages they show
return {
message_cycle=60*15, -- 15 seconds default, how often (in ticks) the messages will cycle
locations={ -- defines the spawn locations for all compilatrons
diff --git a/config/preset_player_colours.lua b/config/preset_player_colours.lua
index 527ad065..d10fd64a 100644
--- a/config/preset_player_colours.lua
+++ b/config/preset_player_colours.lua
@@ -1,3 +1,4 @@
+-- preset colours that players get when they join the server, if not in the list then will be given a random colour (which isnt disallowed)
return {
players={
BADgamerNL={r=255,g=20,b=147},
diff --git a/config/repair.lua b/config/repair.lua
index dd58d8be..5980c8c2 100644
--- a/config/repair.lua
+++ b/config/repair.lua
@@ -1,13 +1,14 @@
+-- config file for the repair command
return {
- disallow = {
+ disallow = { -- items in this list will never be repaired
['loader']=true,
['fast-loader']=true,
['express-loader']=true,
['electric-energy-interface']=true,
['infinity-chest']=true
},
- max_range=50,
- allow_blueprint_repair=false,
- allow_ghost_revive=true,
- allow_heal_entities=true
+ max_range=50, -- the max range that can be used with the repair command
+ allow_blueprint_repair=false, -- when true will allow blueprints (things not destroied by biters) to be build instently using the repair command
+ allow_ghost_revive=true, -- when true will allow ghosts (things destoried by biters) to be build instently using the repair command
+ allow_heal_entities=true -- when true will heal entities to full health that are within range
}
\ No newline at end of file
diff --git a/config/science.lua b/config/science.lua
index 9fd7334a..194303f3 100644
--- a/config/science.lua
+++ b/config/science.lua
@@ -1,5 +1,6 @@
-return {
- show_eta=true,
+-- config file for the science info gui
+return { -- list of all science packs to be shown in the gui
+ show_eta=true, -- when true the eta for research completion will be shown
'automation-science-pack',
'logistic-science-pack',
'military-science-pack',
diff --git a/config/tasks.lua b/config/tasks.lua
index 7b1502e5..4c6bd54a 100644
--- a/config/tasks.lua
+++ b/config/tasks.lua
@@ -1,3 +1,4 @@
+-- config file for the tasks gui
return {
only_admins_can_edit = false, -- true will hide the edit and delete buttons from non (game) admins
edit_tasks_role_permision = 'gui/task-list/edit' -- value used with custom permision system
From 420dd4789d2ff8393c9d0910af9ba0f3dd4a0127 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Wed, 29 May 2019 19:56:40 +0100
Subject: [PATCH 20/41] Added missing comments to gui defines
---
modules/gui/player-list.lua | 1 +
modules/gui/rocket-info.lua | 26 +++++++++++++++++---
modules/gui/science-info.lua | 47 ++++++++++++++++++++++++++++++------
modules/gui/task-list.lua | 3 +++
4 files changed, 66 insertions(+), 11 deletions(-)
diff --git a/modules/gui/player-list.lua b/modules/gui/player-list.lua
index d2545f5a..c10fab2f 100644
--- a/modules/gui/player-list.lua
+++ b/modules/gui/player-list.lua
@@ -210,6 +210,7 @@ local function update_action_bar(player)
end
end
+--- Adds a player to the player list
local function add_player(list_table,player,role_name)
open_action_bar(list_table,player.name)
diff --git a/modules/gui/rocket-info.lua b/modules/gui/rocket-info.lua
index 6a62a6f4..a2e9c161 100644
--- a/modules/gui/rocket-info.lua
+++ b/modules/gui/rocket-info.lua
@@ -1,3 +1,4 @@
+--- Adds a rocket infomation gui which shows general stats, milestones and build progress of rockets
local Gui = require 'expcore.gui'
local Roles = require 'expcore.roles'
local Event = require 'utils.event'
@@ -240,7 +241,12 @@ local function generate_container(player,element)
end
---- Creates a text label followed by a data label, or updates them if already present
+--[[ Creates a text label followed by a data label, or updates them if already present
+ element
+ > "data_name_extra"-label
+ > "data_name_extra"
+ >> label
+]]
local function create_label_value_pair(element,data_name,value,tooltip,extra)
local data_name_extra = extra and data_name..extra or data_name
if element[data_name_extra] then
@@ -272,7 +278,7 @@ local function create_label_value_pair_time(element,data_name,raw_value,no_hours
create_label_value_pair(element,data_name,value,tooltip,extra)
end
---- Adds the data to the stats section
+--- Adds the different data values to the stats section
local function generate_stats(player,frame)
if not config.stats.show_stats then return end
local element = frame.container.stats.table
@@ -338,7 +344,7 @@ local function generate_milestones(player,frame)
end
end
---- Creats the different action buttons
+--- Creats the different buttons used with the rocket silos
local function generate_progress_buttons(player,element,rocket_silo_data)
local silo_name = rocket_silo_data.name
local status = rocket_silo_data.entity.status == 21
@@ -379,7 +385,17 @@ local function generate_progress_buttons(player,element,rocket_silo_data)
end
---- Creates build progress section
+--[[ Creates build progress section
+ element
+ > toggle-"silo_name" (generate_progress_buttons)
+ > launch-"silo_name" (generate_progress_buttons)
+ > label-x-"silo_name"
+ >> "silo_name"
+ > label-y-"silo_name"
+ >> "silo_name"
+ > "silo_name"
+ >> label
+]]
local function generate_progress(player,frame)
if not config.progress.show_progress then return end
local element = frame.container.progress.table
@@ -478,6 +494,7 @@ local function generate_progress(player,frame)
end
end
+--- Registers the new left gui
local rocket_info =
Gui.new_left_frame('gui/rocket-info')
:set_sprites('entity/rocket-silo')
@@ -500,6 +517,7 @@ end)
generate_progress(player,element)
end)
+--- Event used to update the stats and the hui when a rocket is launched
Event.add(defines.events.on_rocket_launched,function(event)
local entity = event.rocket_silo
local silo_name = get_silo_name(entity)
diff --git a/modules/gui/science-info.lua b/modules/gui/science-info.lua
index a0f63fcf..8637e559 100644
--- a/modules/gui/science-info.lua
+++ b/modules/gui/science-info.lua
@@ -1,3 +1,4 @@
+--- Adds a science info gui that shows production usage and net for the different science packs as well as an eta
local Gui = require 'expcore.gui'
local Event = require 'utils.event'
local Colors = require 'resources.color_presets'
@@ -8,6 +9,7 @@ local config = require 'config.science'
local null_time_short = {'science-info.eta-time',format_time(0,{hours=true,minutes=true,seconds=true,time=true,null=true})}
local null_time_long = format_time(0,{hours=true,minutes=true,seconds=true,long=true,null=true})
+--- Gets the production stats for a certain science pack
local function get_production_stats(player,science_pack)
local force = player.force
local stats = force.item_production_statistics
@@ -33,6 +35,7 @@ local function get_production_stats(player,science_pack)
}
end
+--- Gets the font colour for a certain level of production
local function get_font_colour(value,secondary)
if value > 5 then
return Colors.light_green
@@ -45,6 +48,18 @@ local function get_font_colour(value,secondary)
end
end
+--[[ Generates the main structure for the gui
+ element
+ > container
+ >> header
+ >> scroll
+ >>> non_made
+ >>> table
+ >> footer (when eta is enabled)
+ >>> eta-label
+ >>> eta
+ >>>> label
+]]
local function generate_container(player,element)
Gui.set_padding(element,1,2,2,2)
element.style.minimal_width = 200
@@ -141,7 +156,13 @@ local function generate_container(player,element)
return flow_table, eta
end
-local function add_data_pair(element,name,value,secondary,tooltip)
+--[[ Adds two labels where one is right aligned and the other is a unit
+ element
+ > "name"
+ >> label
+ > spm-"name"
+]]
+local function add_data_label(element,name,value,secondary,tooltip)
local data_colour = get_font_colour(value,secondary)
local caption = format_number(math.round(value,1),true)
@@ -192,6 +213,15 @@ local function add_data_pair(element,name,value,secondary,tooltip)
end
end
+--[[ Adds a science pack to the list
+ element
+ > icon-"science_pack"
+ > delta-"science_pack"
+ >> table
+ >>> pos-"science_pack" (add_data_label)
+ >>> neg-"science_pack" (add_data_label)
+ > net-"science_pack" (add_data_label)
+]]
local function generate_science_pack(player,element,science_pack)
local stats = get_production_stats(player,science_pack)
if stats.total_made > 0 then
@@ -253,13 +283,14 @@ local function generate_science_pack(player,element,science_pack)
Gui.set_padding(delta_table)
end
- add_data_pair(delta.table,'pos-'..science_pack,stats.minute_made,nil,{'science-info.pos-tooltip',stats.total_made})
- add_data_pair(delta.table,'neg-'..science_pack,-stats.minute_used,nil,{'science-info.neg-tooltip',stats.total_used})
- add_data_pair(element,'net-'..science_pack,stats.minute_net,stats.minute_made,{'science-info.net-tooltip',stats.total_net})
+ add_data_label(delta.table,'pos-'..science_pack,stats.minute_made,nil,{'science-info.pos-tooltip',stats.total_made})
+ add_data_label(delta.table,'neg-'..science_pack,-stats.minute_used,nil,{'science-info.neg-tooltip',stats.total_used})
+ add_data_label(element,'net-'..science_pack,stats.minute_net,stats.minute_made,{'science-info.net-tooltip',stats.total_net})
end
end
-local function generate_eta(player,element)
+--- Updates the eta label that was created with generate_container
+local function update_eta(player,element)
if not config.show_eta then return end
local force = player.force
local research = force.current_research
@@ -304,6 +335,7 @@ local function generate_eta(player,element)
end
end
+--- Registerse the new science info gui
local science_info =
Gui.new_left_frame('gui/science-info')
:set_sprites('entity/lab')
@@ -316,7 +348,7 @@ Gui.new_left_frame('gui/science-info')
generate_science_pack(player,table,science_pack)
end
- generate_eta(player,eta)
+ update_eta(player,eta)
end)
:on_update(function(player,element)
local container = element.container
@@ -327,9 +359,10 @@ end)
generate_science_pack(player,table,science_pack)
end
- generate_eta(player,eta)
+ update_eta(player,eta)
end)
+--- Updates the gui every 1 second
Event.on_nth_tick(60,science_info 'update_all')
return science_info
\ No newline at end of file
diff --git a/modules/gui/task-list.lua b/modules/gui/task-list.lua
index 713435c3..9dad2e48 100644
--- a/modules/gui/task-list.lua
+++ b/modules/gui/task-list.lua
@@ -1,3 +1,4 @@
+--- Adds a task list to the game which players can add remove and edit items on
local Gui = require 'expcore.gui'
local Store = require 'expcore.store'
local Global = require 'utils.global'
@@ -365,6 +366,7 @@ local function generate_container(player,element)
return flow_table
end
+--- Registeres the task list
local task_list =
Gui.new_left_frame('gui/task-list')
:set_sprites('utility/not_enough_repair_packs_icon')
@@ -392,6 +394,7 @@ end)
update_all = task_list 'update_all'
+--- When a new task is added it will udpate the task list for everyone on that force
Store.register(task_store,function(value,task_id)
local details = task_details[task_id]
local force = game.forces[details.force]
From f22f62db47a94034b6158a3cef54c4f589c5583b Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Wed, 29 May 2019 19:58:06 +0100
Subject: [PATCH 21/41] Fixed server not being able to use role bassed commands
---
expcore/roles.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/expcore/roles.lua b/expcore/roles.lua
index a2dca09e..ec088fef 100644
--- a/expcore/roles.lua
+++ b/expcore/roles.lua
@@ -321,7 +321,7 @@ end
-- @treturn table a table where the values are the roles which the player has
function Roles.get_player_roles(player)
player = Game.get_player_from_any(player)
- if not player then return end
+ if not player then return {Roles.config.internal.root} end
local roles = Roles.config.players[player.name] or {}
local default = Roles.config.roles[Roles.config.internal.default]
local rtn = {default}
From 87497ee0f35b25dd649cfec9aa9766c42c723b7a Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Wed, 29 May 2019 20:04:19 +0100
Subject: [PATCH 22/41] Made toolbar icons bigger
---
expcore/gui/toolbar.lua | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/expcore/gui/toolbar.lua b/expcore/gui/toolbar.lua
index 87843f5a..4c384dcc 100644
--- a/expcore/gui/toolbar.lua
+++ b/expcore/gui/toolbar.lua
@@ -19,6 +19,7 @@ local Gui = require 'expcore.gui.core'
local Roles = require 'expcore.roles'
local Event = require 'utils.event'
local Game = require 'utils.game'
+local mod_gui = require 'mod-gui'
local Toolbar = {
permisison_names = {},
@@ -38,8 +39,12 @@ end
-- @tparam[opt] name string when given allows an alias to the button for the permission system
-- @treturn table the button define
function Toolbar.new_button(name)
- local button = Buttons.new_button()
- button:set_post_authenticator(Toolbar.allowed)
+ local button =
+ Buttons.new_button()
+ :set_post_authenticator(Toolbar.allowed)
+ :set_style(mod_gui.button_style,function(style)
+ Gui.set_padding_style(style,-2,-2,-2,-2)
+ end)
Toolbar.add_button(button)
Toolbar.permission_alias(button.name,name)
return button
From 7dbe18a88d32f5105cb8225ff096724a7e535d81 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Wed, 29 May 2019 20:18:22 +0100
Subject: [PATCH 23/41] Optimised rocket gui
---
modules/gui/rocket-info.lua | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/modules/gui/rocket-info.lua b/modules/gui/rocket-info.lua
index a2e9c161..6510ec06 100644
--- a/modules/gui/rocket-info.lua
+++ b/modules/gui/rocket-info.lua
@@ -7,6 +7,13 @@ local Global = require 'utils.global'
local format_time = ext_require('expcore.common','format_time')
local Colors = require 'resources.color_presets'
+local largest_rolling_avg = 0
+for _,avg_over in pairs(config.stats.rolling_avg) do
+ if avg_over > largest_rolling_avg then
+ largest_rolling_avg = avg_over
+ end
+end
+
local rocket_times = {}
local rocket_stats = {}
local rocket_silos = {}
@@ -548,13 +555,21 @@ Event.add(defines.events.on_rocket_launched,function(event)
rocket_times[force_name][rockets_launched] = event.tick
+ local remove_rocket = rockets_launched-largest_rolling_avg
+ if remove_rocket > 0 and not table.includes(config.milestones,remove_rocket) then
+ rocket_times[force_name][remove_rocket] = nil
+ end
+
--- Adds this 1 to the launch count for this silo
force_silo_data[silo_name].launched = force_silo_data[silo_name].launched+1
--- Updates all the guis (and toolbar since the button may now be visible)
for _,player in pairs(force.players) do
rocket_info:update(player)
- if first_rocket then Gui.update_toolbar(player) end
+ if first_rocket then
+ Gui.update_toolbar(player)
+ rocket_info:toggle(player)
+ end
end
end)
From 38a1ff2199e8ec929476b59d1d26a2439cce192a Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Wed, 29 May 2019 20:20:46 +0100
Subject: [PATCH 24/41] Added text colour to confix
---
config/science.lua | 2 ++
modules/gui/science-info.lua | 8 ++++----
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/config/science.lua b/config/science.lua
index 194303f3..3cd3ce5f 100644
--- a/config/science.lua
+++ b/config/science.lua
@@ -1,6 +1,8 @@
-- config file for the science info gui
return { -- list of all science packs to be shown in the gui
show_eta=true, -- when true the eta for research completion will be shown
+ required_for_green=5, -- the amount required for the text to show as green
+ required_for_red=-5, -- the amount required for the text to show as red
'automation-science-pack',
'logistic-science-pack',
'military-science-pack',
diff --git a/modules/gui/science-info.lua b/modules/gui/science-info.lua
index 8637e559..572bfc3b 100644
--- a/modules/gui/science-info.lua
+++ b/modules/gui/science-info.lua
@@ -37,9 +37,9 @@ end
--- Gets the font colour for a certain level of production
local function get_font_colour(value,secondary)
- if value > 5 then
+ if value > config.required_for_green then
return Colors.light_green
- elseif value < -5 then
+ elseif value < config.required_for_red then
return Colors.indian_red
elseif secondary and secondary > 0 or not secondary and value ~= 0 then
return Colors.orange
@@ -228,9 +228,9 @@ local function generate_science_pack(player,element,science_pack)
element.parent.non_made.visible = false
local icon_style = 'quick_bar_slot_button'
- if stats.minute_net > 1 then
+ if stats.minute_net > config.required_for_green then
icon_style = 'green_slot_button'
- elseif stats.minute_net < -1 then
+ elseif stats.minute_net < config.required_for_red then
icon_style = 'red_slot_button'
elseif stats.minute_made > 0 then
icon_style = 'selected_slot_button'
From 9f00de8ae264bb85a2ea1eea91a44fdabb913cc2 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Wed, 29 May 2019 20:37:41 +0100
Subject: [PATCH 25/41] Made launch button more responsive
---
modules/gui/rocket-info.lua | 3 +++
1 file changed, 3 insertions(+)
diff --git a/modules/gui/rocket-info.lua b/modules/gui/rocket-info.lua
index 6510ec06..129b7c73 100644
--- a/modules/gui/rocket-info.lua
+++ b/modules/gui/rocket-info.lua
@@ -81,6 +81,9 @@ end)
if rocket_silo_data.entity.launch_rocket() then
rocket_silo_data.awaiting_reset = true
element.enabled = false
+ local progress_label = element.parent.parent[rocket_silo_name].label
+ progress_label.caption = {'rocket-info.progress-launched'}
+ progress_label.style.font_color = Colors.green
end
end)
From aa46e33a5a0293739d0714987208046f63d0f51b Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Wed, 29 May 2019 20:51:49 +0100
Subject: [PATCH 26/41] Fixed gui closing when pressing them
---
expcore/gui/center.lua | 20 ++++++++++----------
expcore/gui/left.lua | 6 +++---
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/expcore/gui/center.lua b/expcore/gui/center.lua
index b849075a..59c978c2 100644
--- a/expcore/gui/center.lua
+++ b/expcore/gui/center.lua
@@ -75,8 +75,8 @@ function CenterFrames.toggle_frame(player,name,state)
return true
elseif state == false then
local flow = CenterFrames.get_flow(player)
- if flow[define.name] then
- flow[define.name].destroy()
+ if flow[define.name..'-frame'] then
+ flow[define.name..'-frame'].destroy()
end
return false
else
@@ -99,7 +99,7 @@ function CenterFrames.new_frame(permision_name)
mt.__index = CenterFrames._prototype
mt.__call = self.event_handler
- Gui.on_custom_close(self.name,function(event)
+ Gui.on_custom_close(self.name..'-frame',function(event)
local element = event.element
if element and element.valid then element.destroy() end
end)
@@ -124,8 +124,8 @@ function CenterFrames._prototype:draw_frame(player)
player = Game.get_player_from_any(player)
local flow = CenterFrames.get_flow(player)
- if flow[self.name] then
- return flow[self.name]
+ if flow[self.name..'-frame'] then
+ return flow[self.name..'-frame']
end
if self.auto_focus then
@@ -134,7 +134,7 @@ function CenterFrames._prototype:draw_frame(player)
local frame = flow.add{
type='frame',
- name=self.name
+ name=self.name..'-frame'
}
if self.auto_focus then
@@ -155,8 +155,8 @@ function CenterFrames._prototype:redraw_frame(player)
player = Game.get_player_from_any(player)
local flow = CenterFrames.get_flow(player)
- if flow[self.name] then
- flow[self.name].destroy()
+ if flow[self.name..'-frame'] then
+ flow[self.name..'-frame'].destroy()
end
return self:draw_frame(player)
@@ -169,8 +169,8 @@ function CenterFrames._prototype:toggle_frame(player)
player = Game.get_player_from_any(player)
local flow = CenterFrames.get_flow(player)
- if flow[self.name] then
- flow[self.name].destroy()
+ if flow[self.name..'-frame'] then
+ flow[self.name..'-frame'].destroy()
return false
else
self:draw_frame(player)
diff --git a/expcore/gui/left.lua b/expcore/gui/left.lua
index 35a8b66b..a2dcf1d1 100644
--- a/expcore/gui/left.lua
+++ b/expcore/gui/left.lua
@@ -174,8 +174,8 @@ end
-- @treturn LuaGuiElement the frame in the left frame flow for this define
function LeftFrames._prototype:get_frame(player)
local flow = LeftFrames.get_flow(player)
- if flow[self.name] and flow[self.name].valid then
- return flow[self.name]
+ if flow[self.name..'-frame'] and flow[self.name..'-frame'].valid then
+ return flow[self.name..'-frame']
end
end
@@ -276,7 +276,7 @@ Event.add(defines.events.on_player_created,function(event)
for _,define in pairs(LeftFrames.frames) do
local frame = flow.add{
type='frame',
- name=define.name,
+ name=define.name..'-frame',
direction=define.direction
}
From d068a07b8b62a85410f522acf285a04e2c1eba5c Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Wed, 29 May 2019 20:55:46 +0100
Subject: [PATCH 27/41] Added version to readme
---
README.md | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index c7509c63..a150c64a 100644
--- a/README.md
+++ b/README.md
@@ -56,7 +56,8 @@ All are welcome to make pull requests and issues for this scenario, if you are i
| Scenario Version* | Version Name | Factorio Version** |
|---|---|---|
-| [v5.5](s5.5) | Gui System | [v0.17.35](f0.17.35) |
+| [v5.6](s5.6) | Information Guis | [v0.17.43](f0.17.43) |
+| [v5.5](s5.5) | Gui System | [v0.17.43](f0.17.43) |
| [v5.4](s5.4) | Admin Controls | [v0.17.32](f0.17.32) |
| [v5.3](s5.3) | Custom Roles | [v0.17.28](f0.17.28) |
| [v5.2](s5.2) | Quality of life | [v0.17.22](f0.17.22) |
@@ -71,6 +72,7 @@ All are welcome to make pull requests and issues for this scenario, if you are i
\** Factorio versions show the version they were made for, often the minimum requirement.
+[s5.6]: https://github.com/explosivegaming/scenario/releases/tag/5.6.0
[s5.5]: https://github.com/explosivegaming/scenario/releases/tag/5.5.0
[s5.4]: https://github.com/explosivegaming/scenario/releases/tag/5.4.0
[s5.3]: https://github.com/explosivegaming/scenario/releases/tag/5.3.0
@@ -83,7 +85,7 @@ All are welcome to make pull requests and issues for this scenario, if you are i
[s1.0]: https://github.com/explosivegaming/scenario/releases/tag/v1.0
[s0.1]: https://github.com/explosivegaming/scenario/releases/tag/v0.1
-[f0.17.35]: https://wiki.factorio.com/Version_history/0.17.0#0.17.35
+[f0.17.43]: https://wiki.factorio.com/Version_history/0.17.0#0.17.43
[f0.17.32]: https://wiki.factorio.com/Version_history/0.17.0#0.17.32
[f0.17.28]: https://wiki.factorio.com/Version_history/0.17.0#0.17.28
[f0.17.22]: https://wiki.factorio.com/Version_history/0.17.0#0.17.22
From 922cd225e5014f1a946cf9c1a6afab0ee7435fa4 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Wed, 29 May 2019 21:07:21 +0100
Subject: [PATCH 28/41] Better issuse formats
---
.github/ISSUE_TEMPLATE/Bug_report.md | 20 +++++-----
.github/ISSUE_TEMPLATE/Desync_report.md | 24 ++++++++++++
.github/ISSUE_TEMPLATE/Error_report.md | 46 ++++++++++++-----------
.github/ISSUE_TEMPLATE/Feature_request.md | 17 +++++----
4 files changed, 68 insertions(+), 39 deletions(-)
create mode 100644 .github/ISSUE_TEMPLATE/Desync_report.md
diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md
index 8d1d7915..885ebd8e 100644
--- a/.github/ISSUE_TEMPLATE/Bug_report.md
+++ b/.github/ISSUE_TEMPLATE/Bug_report.md
@@ -1,18 +1,24 @@
---
name: Bug report
-about: Create a report to help us improve
+about: Report a bug which does not crash the game, any bug from the latest major scenario version
---
-**Describe the bug**
+**Factorio version**
+Version number: X.Y.Z
+
+**Scenario version**
+Version number: X.Y.Z
+
+**Bug description**
A clear and concise description of what the bug is.
-**To Reproduce**
+**Reproduction method**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
-4. See error
+4. See error in log
**Expected behavior**
A clear and concise description of what you expected to happen.
@@ -20,9 +26,5 @@ 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.
+Add any other context about the problem here.
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/Desync_report.md b/.github/ISSUE_TEMPLATE/Desync_report.md
new file mode 100644
index 00000000..5c7e81f9
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/Desync_report.md
@@ -0,0 +1,24 @@
+---
+name: Desync report
+about: Report a desync, latest version of scenario only including patches
+
+---
+
+**Factorio version**
+Version number: X.Y.Z
+
+**Scenario version**
+Version number: X.Y.Z
+
+**Desync description**
+A clear and concise description of what you believe causes the desync.
+
+**Reproduction method**
+Steps to reproduce the behavior:
+1. Go to '...'
+2. Click on '....'
+3. Scroll down to '....'
+4. See error in log
+
+**Additional context**
+Add any other context about the problem here.
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/Error_report.md b/.github/ISSUE_TEMPLATE/Error_report.md
index 85f5a32f..d9ca9b28 100644
--- a/.github/ISSUE_TEMPLATE/Error_report.md
+++ b/.github/ISSUE_TEMPLATE/Error_report.md
@@ -1,33 +1,35 @@
---
-name: Error/Desync Report
-about: Create a report on a bug which gives an error or desync
+name: Error report
+about: Report a bug which cases the game to crash, any bug from the latest major scenario version
---
-**Error Message**
-Error: insert error message
+**Factorio version**
+Version number: X.Y.Z
-**Known Causes**
-Know causes that will result in error:
- - Cause 1
- - Cause 2
+**Scenario version**
+Version number: X.Y.Z
-**To Reproduce (please give for each cause outlined above)**
+**Error message**
+```
+error message and stacktrace back
+```
+
+**Error description**
+A clear and concise description of what you believe causes the crash.
+
+**Reproduction method**
Steps to reproduce the behavior:
- - Cause 1
- 1. Go to '...'
- 2. Click on '....'
- 3. Scroll down to '....'
- 4. See error
- - Cause 2
- 1. Go to '...'
- 2. Click on '....'
- 3. Scroll down to '....'
- 4. See error
+1. Go to '...'
+2. Click on '....'
+3. Scroll down to '....'
+4. See error in log
-**Other information (please complete the following information):**
- - OS: [e.g. iOS, Windows, Linux]
- - Factorio Version: [e.g. 0.16.30]
+**Expected behavior**
+A clear and concise description of what you expected to happen.
+
+**Screenshots**
+If applicable, add screenshots to help explain your problem.
**Additional context**
Add any other context about the problem here.
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/Feature_request.md b/.github/ISSUE_TEMPLATE/Feature_request.md
index 066b2d92..6bdc2252 100644
--- a/.github/ISSUE_TEMPLATE/Feature_request.md
+++ b/.github/ISSUE_TEMPLATE/Feature_request.md
@@ -1,17 +1,18 @@
---
name: Feature request
-about: Suggest an idea for this project
+about: Suggest a new idea to be worked on
---
-**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 [...]
+**Feature overview**
+Name: name-here
+TL;DR: a few words about what the feature is
-**Describe the solution you'd like**
-A clear and concise description of what you want to happen.
+**Details**
+A detailed description of what the new feature is.
-**Describe alternatives you've considered**
-A clear and concise description of any alternative solutions or features you've considered.
+**Possible methods**
+Any ideas you have had about how to implement the feature or any problems that may arise.
**Additional context**
-Add any other context or screenshots about the feature request here.
+Add any other context or screenshots about the feature request here.
\ No newline at end of file
From 98f6266ad11821eb440f0266098a5bcf84605f71 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Wed, 29 May 2019 21:33:09 +0100
Subject: [PATCH 29/41] Removed outdated docs
---
doc/index.html | 144 ----
doc/ldoc.css | 303 -------
doc/modules/ExpGamingCore.Commands.html | 401 ---------
doc/modules/ExpGamingCore.Gui.Center.html | 337 --------
doc/modules/ExpGamingCore.Gui.Inputs.html | 498 -----------
doc/modules/ExpGamingCore.Gui.Left.html | 240 ------
doc/modules/ExpGamingCore.Gui.Popup.html | 185 -----
doc/modules/ExpGamingCore.Gui.Test.html | 144 ----
doc/modules/ExpGamingCore.Gui.Toolbar.html | 190 -----
doc/modules/ExpGamingCore.Gui.html | 366 --------
doc/modules/ExpGamingCore.Ranking.html | 883 --------------------
doc/modules/ExpGamingCore.Server.html | 848 -------------------
doc/modules/ExpGamingCore.Sync.html | 820 ------------------
doc/modules/ExpGamingLib.html | 672 ---------------
doc/modules/FSM.html | 455 ----------
doc/modules/StdLib.Color.html | 561 -------------
doc/modules/StdLib.Game.html | 222 -----
doc/modules/StdLib.String.html | 302 -------
doc/modules/StdLib.Table.html | 922 ---------------------
doc/modules/StdLib.Time.html | 139 ----
20 files changed, 8632 deletions(-)
delete mode 100644 doc/index.html
delete mode 100644 doc/ldoc.css
delete mode 100644 doc/modules/ExpGamingCore.Commands.html
delete mode 100644 doc/modules/ExpGamingCore.Gui.Center.html
delete mode 100644 doc/modules/ExpGamingCore.Gui.Inputs.html
delete mode 100644 doc/modules/ExpGamingCore.Gui.Left.html
delete mode 100644 doc/modules/ExpGamingCore.Gui.Popup.html
delete mode 100644 doc/modules/ExpGamingCore.Gui.Test.html
delete mode 100644 doc/modules/ExpGamingCore.Gui.Toolbar.html
delete mode 100644 doc/modules/ExpGamingCore.Gui.html
delete mode 100644 doc/modules/ExpGamingCore.Ranking.html
delete mode 100644 doc/modules/ExpGamingCore.Server.html
delete mode 100644 doc/modules/ExpGamingCore.Sync.html
delete mode 100644 doc/modules/ExpGamingLib.html
delete mode 100644 doc/modules/FSM.html
delete mode 100644 doc/modules/StdLib.Color.html
delete mode 100644 doc/modules/StdLib.Game.html
delete mode 100644 doc/modules/StdLib.String.html
delete mode 100644 doc/modules/StdLib.Table.html
delete mode 100644 doc/modules/StdLib.Time.html
diff --git a/doc/index.html b/doc/index.html
deleted file mode 100644
index f5d24cda..00000000
--- a/doc/index.html
+++ /dev/null
@@ -1,144 +0,0 @@
-
-
-
-
- Reference
-
-
-
-
-
description
- string
- the description of the command
- (default 'No Description')
-
-
inputs
- table
- a table of the inputs to be used, last index being true makes the last parameter open ended (longer than one word)
- (default an infite string)
-
-
callback
- function
- the function to call on the event
-
-
-
-
-
-
-
Usage:
-
-
--see examples in file
-
-
-
-
-
Tables
-
-
-
-
- validate
-
-
- Collection of funcations that can be used to validate inputs
-
-
-
Fields:
-
-
__comment
- replace _ with - the ldoc did not like me using - in the names
-
-
string
- basicly does nothing but a type filed is required
-
-
string_inf
- same as string but is infite in length, must be last arg
-
-
string_len
- same as string but can define a max lengh
-
-
number
- converts the input into a number
-
-
number_int
- conerts the input to a number and floors it
-
-
number_range
- allows a number in a range after it has been floored min < math.floor(X) <= max
-
-
number_range
- allows a number in a range after it has been floored min < math.floor(X) <= max
-
-
player
- converts the input into a valid player
-
-
player_online
- converts the input to a player if the player is online
-
-
player_alive
- converts the input to a player if the player is online and alive
-
-
player_rank
- -online converts the input to a player if the player is a lower rank than the user and online
-
-
player_rank
- -online converts the input to a player if the player is a lower rank than the user and online
-
-
player_rank_alive
- converts the input to a player if the player is a lower rank than the user and online and alive
-
-
type
- string
- the type that the value should be
-
-
value
- the value that will be tested
-
-
...
- any other data that can be passed to the function
-
-
-
-
-
-
-
Usage:
-
-
commands.validate[type](value,event,...)
-
-
-
-
-
Fields
-
-
-
-
- error
-
-
- Used as an error constant for validation
-
-
-
-
-
-
-
Usage:
-
-
return commands.error, 'err message'
-
return commands.error('err message')
-
-
-
-
-
- data
-
-
- Index of all command data
-
-
-
-
key
- string, table or event
- the command that will be returned: string is the name, table is the command data, event is event from add_command
-
-
-
-
-
-
-
Usage:
-
-
commands.command_name -- returns command data
-
commands.data -- returns all data
-
-
-
-
-
-
-
-
-
-generated by LDoc 1.4.6
-Last updated 2018-06-07 12:58:23
-
- This is a submodule of ExpGamingCore.Gui but for ldoc reasons it is under its own module
-
-
-
-
-
-
-
-
-
-
- add (obj)
-
-
- Used to add a left gui frame
-
-
-
Parameters:
-
-
obj
- this is what will be made, needs a name and a draw function(root_frame), open_on_join can be used to set the deaful state true/false, can_open is a test to block it from opening but is not needed
-
-
-
-
Returns:
-
-
- the object that is made to... well idk but for the future
-
-
-
-
-
Sync.emit_embedded{title='BAN',color='0x0',description='A player was banned' ... }
-
-
-
-
-
- count_admins ()
-
-
- Used to get the number of admins currently online
-
-
-
-
Returns:
-
-
- number
- the number of admins online
-
-
-
-
-
Usage:
-
-
Sync.count_admins() -- returns number
-
-
-
-
-
- count_afk ([time=7200])
-
-
- Used to get the number of afk players defined by 2 min by default
-
-
-
Parameters:
-
-
time
- int
- in ticks that a player is called afk
- (default 7200)
-
-
-
-
Returns:
-
-
- number
- the number of afk players
-
-
-
-
-
Usage:
-
-
Sync.count_afk()
-
-
-
-
-
- count_ranks ()
-
-
- Used to get the number of players in each rank and currently online; if ExpGamingCore/Ranking is present then it will give more than admin and user
-
-
-
-
Returns:
-
-
- table
- contains the ranks and the players in that rank
-
-
-
-
-
Usage:
-
-
Sync.count_ranks()
-
-
-
-
-
- count_players (online)
-
-
- Used to get a list of every player name with the option to limit to only online players
-
-
-
Parameters:
-
-
online
- boolean
- true will get only the online players
-
A more detailed replacement for the lua error function to allow for handlers to be added; repleaces default error so error can be used instead of Manager.error
rtn
- string
- the value that will be returned though verbose output
-
-
-
-
-
-
-
Usage:
-
-
Manager.verbose('Hello, World!')
-
-
-
-
-
- verbose (rtn, action)
-
-
- Used to call the output of the verbose when the current state allows it
-
-
-
Parameters:
-
-
rtn
- string
- the value that will be returned though verbose output
-
-
action
- string
- is used to decide which verbose this is error || event etc
-
-
-
-
-
-
-
Usage:
-
-
Manager.verbose('Hello, World!')
-
-
-
-
-
- setVerbose (settings)
-
-
- Main logic for allowing verbose at different stages though out the script
-
-
-
Parameters:
-
-
settings
- newTbl
- the table that will be searched for settings to be updated
-
-
-
-
-
-
-
Usage:
-
-
Manager.setVerbose{output=log}
-
Manager.setVerbose[setting] -- returns the value of that setting
-
tostring(Manager.setVerbose) -- returns a formated list of the current settings
-
-
-
-
-
- sandbox (callback[, env])
-
-
- Creates a sand box envorment and runs a callback in that sand box; provents global pollution
-
-
-
Parameters:
-
-
callback
- function
- the function that will be ran in the sandbox
-
-
env
- any other params that the function will use
- (optional)
-
-
-
-
-
-
-
Usage:
-
-
Manager.sandbox(callback) -- return sandbox, success, other returns from callback
-
Manager.sandbox() -- returns and empty sandbox
-
Manager.sandbox[key] -- returns the sand box value in that key
-
-
-
-
-
- loadModules ()
-
-
- Loads the modules that are present in the index list
-
-
-
-
-
-
-
Usage:
-
-
Manager.loadModules() -- loads all moddules in the index list
-
#Manager.loadModules -- returns the number of modules loaded
-
tostring(Manager.loadModules) -- returns a formatted list of all modules loaded
-
pairs(Manager.loadModules) -- loops over the loaded modules moduleName, module
-
-
-
-
-
- error (err, callback)
-
-
- A more detailed replacement for the lua error function to allow for handlers to be added; repleaces default error so error can be used instead of Manager.error
-
-
-
Parameters:
-
-
err
- string or fucntion
- the string to be passed to handlers; if a function it will register a handler
-
-
callback
- function
- if given the err param will be used to given the handler a name
-
-
-
-
-
-
-
Usage:
-
-
Manager.error(err) -- calls all error handlers that are set or if none then prints to game and if that fails crashs game
-
Manager.error() -- returns an error constant that can be used to crash game
-
Manager.error(Manager.error()) -- crashs the game
-
Manager.error.addHandler(name,callback) -- adds a new handler if handler returns Manager.error() then game will crash
-
Manager.error[name] -- returns the handler of that name if present
-
#Manager.error-- returns the number of error handlers that are present
-
pairs(Manager.error) -- loops over only the error handlers handler_name,hander
-
-
-
-
-
- event (event_name, callback)
-
-
- Event handler that modules can use, each module can register one function per event
-
-
-
Parameters:
-
-
event_name
- int or string
- that referes to an event
-
-
callback
- function
- the function that will be set for that event
-
-
-
-
-
-
-
Usage:
-
-
Manager.event[event_name] = callback -- sets the callback for that event
-
Manager.event[event_name] = nil-- clears the callback for that event
-
Manager.event(event_name,callback) -- sets the callback for that event
-
Manager.event[event_name] -- returns the callback for that event or the event id if not registered
-
Manager.event(event_name) -- runs all the call backs for that event
-
Manager.event() -- returns the stop value for the event proccessor, if returned during an event will stop all other callbacks
-
#Manager.event -- returns the number of callbacks that are registered
-
pairs(Manager.events) -- returns event_id,table of callbacks
-
-
-
-
-
Tables
-
-
-
-
- verboseSettings
-
-
- Different verbose settings used for setVerbose
-
-
-
Fields:
-
-
selfInit
- boolean
- called while the manager is being set up
-
-
moduleLoad
- boolean
- when a module is required by the manager
-
-
moduleInit
- boolean
- when and within the initation of a module
-
-
moduleEnv
- boolean
- during module runtime, this is a global option set within each module(module_verbose=true ln:1) for fine control
-
-
eventRegistered
- boolean
- when a module registers its event handlers
-
-
errorCaught
- boolean
- when an error is caught during runtime
-
-
output
- function
- can be: print || log || or other function
-
-
_output
- a constant value that can used to store output data
-
-
-
-
-
-
-
-
-
-
- Manager.event.names
-
-
- Sub set to Manger.event and acts as a coverter between event_name and event_id
-
-
-
-
-
-
-
Usage:
-
-
Manager.event[event_name]
-
-
-
-
-
Fields
-
-
-
-
- global
-
-
- Used to avoid conflicts in the global table
-
-
-
-
if
- table, string or true
- table then the default for the global, if a string then the module to get the global of, if true then reset the global to default
- (default {})
-
-
-
-
-
-
-
Usage:
-
-
global[key] -- used like the normal global table
-
global{'foo','bar'} -- sets the default value
-
global(true) -- restores global to default
-
global(mopdule_name) -- returns that module's global
-
-
-
-
-
-
-
-
-
-generated by LDoc 1.4.6
-Last updated 2018-06-07 12:58:23
-
- Messages all players currently connected to the game.
-> Offline players are not counted as having received the message.
- If no players exist msg is stored in the `global._print_queue` table.
-
-
-
Given a mapping function, creates a transformed copy of the table
- by calling the function for each element in the table, and using
- the result as the new value for the key.
Given a filter function, creates a filtered copy of the table
- by calling the function for each element in the table, and
- filtering out any key-value pairs for non-true results.
Given a candidate search function, iterates over the table, calling the function
- for each element in the table, and returns the first element the search function returned true.
Given a candidate search function, iterates over the table, calling the function
- for each element in the table, and returns true if search function returned true.
For all string or number values in an array map them to a key = true table
-
-
-
-
-
-
-
-
Functions
-
-
-
-
- map (tbl, func[, ...])
-
-
- Given a mapping function, creates a transformed copy of the table
- by calling the function for each element in the table, and using
- the result as the new value for the key. Passes the index as second argument to the function.
-
-
-
Parameters:
-
-
tbl
- table
- the table to be mapped to the transform
-
-
func
- function
- the function to transform values
-
-
...
- additional arguments passed to the function
- (optional)
-
-
-
-
Returns:
-
-
- table
- a new table containing the keys and mapped values
-
-
-
-
-
a = {1, 2, 3, 4, 5}
-table.map(a, function(v, k, x) return v * k + x end, 100) --produces { 101, 104, 109, 116, 125}
-
-
-
-
-
- filter (tbl, func[, ...])
-
-
- Given a filter function, creates a filtered copy of the table
- by calling the function for each element in the table, and
- filtering out any key-value pairs for non-true results. Passes the index as second argument to the function.
-
-
-
- Given a candidate search function, iterates over the table, calling the function
- for each element in the table, and returns the first element the search function returned true.
- Passes the index as second argument to the function.
-
-
-
a = {1, 2, 3, 4, 5}
-table.find(a, function(v, k, x) return k % 2 == 1end) --produces: 1
-
-
-
-
-
- any (tbl, func[, ...])
-
-
- Given a candidate search function, iterates over the table, calling the function
- for each element in the table, and returns true if search function returned true.
- Passes the index as second argument to the function.
-
-
-
- Returns a new array that is a one-dimensional recursive flattening of the given array.
- For every element that is an array, extract its elements into the new array.
-
The optional level argument determines the level of recursion to flatten.
-> This function flattens an integer-indexed array, but not an associative array.
-
-
-
Parameters:
-
-
tbl
- array
- the array to be flattened
-
-
level
- uint
- recursive levels, or no limit to recursion if not supplied
- (optional)
-
-
-
-
Returns:
-
-
- array
- a new array that represents the flattened contents of the given array
-
-
-
-
-
-
-
-
- first (tbl)
-
-
- Given an array, returns the first element or nil if no element exists.
-
-
-
Parameters:
-
-
tbl
- array
- the array
-
-
-
-
Returns:
-
-
- nil or Mixed
- the first element
-
-
-
-
-
-
-
-
- last (tbl)
-
-
- Given an array, returns the last element or nil if no elements exist.
-
-
-
Parameters:
-
-
tbl
- array
- the array
-
-
-
-
Returns:
-
-
- nil or Mixed
- the last element or nil
-
-
-
-
-
-
-
-
- min (tbl)
-
-
- Given an array of only numeric values, returns the minimum or nil if no element exists.
-
-
-
Parameters:
-
-
tbl
- {number,...}
- the array with only numeric values
-
-
-
-
Returns:
-
-
- nil or number
- the minimum value
-
-
-
-
-
-
-
-
- max (tbl)
-
-
- Given an array of only numeric values, returns the maximum or nil if no element exists.
-
-
-
Parameters:
-
-
tbl
- {number,...}
- the array with only numeric values
-
-
-
-
Returns:
-
-
- nil or number
- the maximum value
-
-
-
-
-
-
-
-
- sum (tbl)
-
-
- Given an array of only numeric values, return the sum of all values, or 0 for empty arrays.
-
-
-
Parameters:
-
-
tbl
- {number,...}
- the array with only numeric values
-
-
-
-
Returns:
-
-
- number
- the sum of the numbers or zero if the given array was empty
-
-
-
-
-
-
-
-
- avg (tbl)
-
-
- Given an array of only numeric values, returns the average or nil if no element exists.
-
-
-
Parameters:
-
-
tbl
- {number,...}
- the array with only numeric values
-
-
-
-
Returns:
-
-
- nil or number
- the average value
-
-
-
-
-
-
-
-
- merge (tblA, tblB[, array_merge=false])
-
-
- Merges two tables — values from first get overwritten by the second.
-
-
-
array_merge
- boolean
- set to true to merge the tables as an array or false for an associative array
- (default false)
-
-
-
-
Returns:
-
-
- array or table
- an array or an associated array where tblA and tblB have been merged
-
-
-
-
-
Usage:
-
-
function some_func(x, y, args)
- args = table.merge({option1=false}, args)
- if opts.option1 == truethenreturn x elsereturn y end
-end
-some_func(1,2) -- returns 2
-some_func(1,2,{option1=true}) -- returns 1
-
-
-
-
-
- deepcopy (object)
-
-
- Creates a deep copy of table without copying Factorio objects.
-
-
-
func
- function
- to incremement counter
- (optional)
-
-
...
- additional arguments passed to the function
- (optional)
-
-
-
-
Returns:
-
-
- number
- The number of keys matching the function or the number of all keys if func isn't passed
-
- number
- The total number of keys
-
-
-
-
-
Usage:
-
-
local a = { 1, 2, 3, 4, 5}
- table.count_keys(a) -- produces: 5, 5
-
local a = {1, 2, 3, 4, 5}
- table.count_keys(a, function(v, k) return k % 2 == 1end) -- produces: 3, 5
-
-
-
-
-
- invert (tbl)
-
-
- Returns an inverted (***{[value] = key,...}***) copy of the given table. If the values are not unique, the assigned key depends on the order of pairs().
-
-
-
This contains a list of all files that will be loaded and the order they are loaded in
+ to stop a file from loading add "--" in front of it, remove the "--" to have the file be loaded
+ config files should be loaded after all modules are loaded
+ core files should be required by modules and not be present in this list
Config for the different action buttons that show on the player list
+ each button has the button define(s) given along side an auth function, and optional reason callback
+ if a reason callback is used then Store.set_child(action_name_store,player.name,'BUTTON_NAME') should be called during on_click
+ buttons can be removed from the gui by commenting them out of the config at the bottom of this file
+ the key used for the name of the button is the permision name used by the role system
This config controls what happens when a player dies mostly about map markers and item collection
+ allow_teleport_to_body_command and allow_collect_bodies_command can be over ridden if command_auth_runtime_disable is present
+ if not present then the commands will not be loaded into the game
This is a very simple config file which adds a admin only auth function
+ not much to change here its more so it can be enabled and disabled from ./config/file_loader.lua
+ either way you can change the requirements to be "admin" if you wanted to
This config for command auth allows commands to be globally enabled and disabled during runtime
+ this config adds Commands.disable and Commands.enable to enable and disable commands for all users
This file contains some common command param parse functions
+ this file is less of a config and more of a requirement but you may wish to change how some behave
+ as such you need to be confident with lua but you edit this config file
+ use Commands.add_parse('name',function(input,player,reject) end) to add a parse
+ see ./expcore/commands.lua for more details
Use this file to add new permission groups to the game
+ start with Permission_Groups.new_group('name')
+ then use either :allow_all() or :disallow_all() to set the default for non specified actions
+ then use :allow{} and :disallow{} to specify certain actions to allow/disallow
Please go to ./config if you want to change settings, each file is commented with what it does
+ if it is not in ./config then you should not attempt to change it unless you know what you are doing
+ all files which are loaded (including the config files) are present in ./config/file_loader.lua
+ this file is the landing point for all scenarios please DO NOT edit directly, further comments are to aid development
This file is used to require all the different elements of the gui module
+ each module has an outline here but for more details see their seperate files in ./gui
Core gui file for making element defines and element classes (use require 'expcore.gui')
+ see utils.gui for event handlering
+ see expcore.gui.test for examples for element defines
+[[
This file creates a teste gui that is used to test every input method
+ note that this does not cover every permutation only features in indepentance
+ for example store in most cases is just by player name, but other store methods are tested with checkbox
info
+ Original (javascript) version: https://hastebin.com/udakacavap.js
+ Can be tested against: https://wiki.factorio.com/Enemies#Spawn_chances_by_evolution_factor
Used to set the role order, higher in the list is better, must be called at least once in config
+ nb: function also re links parents due to expected position in the config file
Sets the parent for a role, any action not in allow or disallow will be looked for in its parents
+ nb: this is a recursive action, and changing the allows and disallows will effect all children roles
Sets an auto promote condition that is checked every 5 seconds, if true is returned then the player will recive the role
+ nb: this is one way, failing false after already gaining the role will not revoke the role
+
+
+ Roles._prototype
+ the role with that name or nil
+
+
+
+
+
+
+
+
+ Roles.get_role_by_order (index)
+
+
+ Get a role with the given order index
+
+
+
Parameters:
+
+
index
+ number
+ the place in the oder list of the role to get
+
+
+
+
Returns:
+
+
+ Roles._prototype
+ the role with that index in the order list or nil
+
+
+
+
+
+
+
+
+ Roles.get_role_from_any (any)
+
+
+ Gets a role from a name,index or role object (where it is just returned)
+ nb: this function is used for the input for most outward facing functions
+
+
+
Parameters:
+
+
any
+ number, string or table
+ the value used to find the role
+
+
+
+
Returns:
+
+
+ Roles._prototype
+ the role that was found or nil see above
+
+
+
+
+
+
+
+
+ Roles.get_player_roles (player)
+
+
+ Gets all the roles of the given player, this will always contain the default role
+
+
+
Parameters:
+
+
player
+ LuaPlayer
+ the player to get the roles of
+
+
+
+
Returns:
+
+
+ table
+ a table where the values are the roles which the player has
+
+
+
+
+
+
+
+
+ Roles.get_player_highest_role (player)
+
+
+ Gets the highest role which the player has, can be used to compeer one player to another
+
+
+
Parameters:
+
+
player
+ LuaPlayer
+ the player to get the highest role of
+
+
+
+
Returns:
+
+
+ the
+ role with the highest order index which this player has
+
+
+
+
+
+
+ Removes a player from the given role(s) with an option to pass a by player name used in the log
+
+
+
Parameters:
+
+
player
+ LuaPlayer
+ the player that will have the roles removed
+
+
roles
+ table
+ table a of roles to be removed from the player, can be one role and can be role names
+
+
by_player_name
+ string
+ the name of the player that will be shown in the logs
+ (default)
+
+
silent
+ boolean
+ when true there will be no game message printed
+ (default false)
+
+
+
+
+
+
+
+
+
+
+ Roles.override_player_roles (roles)
+
+
+ Overrides all player roles with the given table of roles, useful to mass set roles on game start
+
+
+
Parameters:
+
+
roles
+ table
+ table a which is indexed by case sensitive player names and has the value of a table of role names
+
+
+
+
+
+
+
+
+
+
+ Roles.player_has_role (player, search_role)
+
+
+ A test for weather a player has the given role
+
+
+
Parameters:
+
+
player
+ LuaPlayer
+ the player to test the roles of
+
+
search_role
+ string, number or table
+ a pointer to the role that is being searched for
+
+
+
+
Returns:
+
+
+ boolean
+ true if the player has the role, false otherwise, nil for errors
+
+
+
+
+
+
+
+
+ Roles.player_has_flag (player, flag_name)
+
+
+ A test for weather a player has the given flag true for at least one of they roles
+
+
+
Parameters:
+
+
player
+ LuaPlayer
+ the player to test the roles of
+
+
flag_name
+ string
+ the name of the flag that is being looked for
+
+
+
+
Returns:
+
+
+ boolean
+ true if the player has at least one role which has the flag set to true, false otherwise, nil for errors
+
+
+
+
+
+
+
+
+ Roles.player_allowed (player, action)
+
+
+ A test for weather a player has at least one role which is allowed the given action
+
+
+
Parameters:
+
+
player
+ LuaPlayer
+ the player to test the roles of
+
+
action
+ string
+ the name of the action that is being tested for
+
+
+
+
Returns:
+
+
+ boolean
+ true if the player has at least one role which is allowed this action, false otherwise, nil for errors
+
+
+
+
+
+
+
+
+ Roles.define_role_order (order)
+
+
+ Used to set the role order, higher in the list is better, must be called at least once in config
+ nb: function also re links parents due to expected position in the config file
+
+
+
Parameters:
+
+
order
+ table
+ table a which is keyed only by numbers (start 1) and values are roles in order with highest first
+
+
+
+
+
+
+
+
+
+
+ Roles.define_flag_trigger (name, callback)
+
+
+ Defines a new trigger for when a tag is added or removed from a player
+
+
+
Parameters:
+
+
name
+ string
+ the name of the flag which the roles will have
+
+
callback
+ function
+ the function that is called when roles are assigned
+ flag param - player - the player that has had they roles changed
+ flag param - state - the state of the flag, aka if the flag is present
+
+
+
+
+
+
+
+
+
+
+ Roles.set_default (name)
+
+
+ Sets the default role which every player will have, this needs to be called at least once
+
+
+
+ Sets the parent for a role, any action not in allow or disallow will be looked for in its parents
+ nb: this is a recursive action, and changing the allows and disallows will effect all children roles
+
+
+
Parameters:
+
+
role
+ string
+ the name of the role that will be the parent; has imminent effect if role is already defined
+
+ Sets an auto promote condition that is checked every 5 seconds, if true is returned then the player will recive the role
+ nb: this is one way, failing false after already gaining the role will not revoke the role
+
+
+
Parameters:
+
+
callback
+ function
+ receives only one param which is player to promote, return true to promote the player
+
Formats tick into a clean format, denominations from highest to lowest
+ long will use words rather than letters
+ time will use : separates
+ string will return a string not a locale string
+ when a denomination is false it will overflow into the next one
https://github.com/Refactorio/RedMew/blob/9184b2940f311d8c9c891e83429fc57ec7e0c4a2/map_gen/maps/diggy/debug.lua#L31
+ Prints a colored value on a location.
+ Will return a value of any type to the player/server console, allows colour for in-game players
+
+
+
Parameters:
+
+
value
+ any value of any type that will be returned to the player or console
+
+
colour
+ defines.color or string
+ the colour of the text for the player, ignored when printing to console
+ (default defines.colour.white)
+
+
player
+ LuaPlayer
+ the player that return will go to, if no game.player then returns to server
+ (default game.player)
+
+
+
+
+
+
+
Usage:
+
+
player_return('Hello, World!') -- returns 'Hello, World!' to game.player or server console
+
player_return('Hello, World!','green') -- returns 'Hello, World!' to game.player with colour green or server console
+
player_return('Hello, World!',nil,player) -- returns 'Hello, World!' to the given player
+
+
+
+
+
+ write_json (path, tbl)
+
+
+ Writes a table object to a file in json format
+
+
+
Parameters:
+
+
path
+ string
+ the path of the file to write include / to use dir
+
+
tbl
+ table
+ the table that will be converted to a json string and wrote to file
+
+
+
+
+
+
+
+
+
+
+ opt_require (path)
+
+
+ Calls a require that will not error if the file is not found
+
+
+
Parameters:
+
+
path
+ string
+ the path that you want to require
+
+
+
+
Returns:
+
+
+ the returns from that file or nil, error if not loaded
+
+
+
+
+
Usage:
+
+
local file = opt_require('file.not.present') -- will not cause any error
+
+
+
+
+
+ ext_require (path, ...)
+
+
+ Calls a require and returns only the keys given, file must return a table
+
+
+
Parameters:
+
+
path
+ string
+ the path that you want to require
+
+
...
+ string
+ the name of the keys that you want returned
+
+
+
+
Returns:
+
+
+ the keys in the order given
+
+
+
+
+
Usage:
+
+
local extract, param_check = ext_require('expcore.common','extract','param_check')
+
+
+
+
+
+ format_time (ticks, options)
+
+
+ Formats tick into a clean format, denominations from highest to lowest
+ long will use words rather than letters
+ time will use : separates
+ string will return a string not a locale string
+ when a denomination is false it will overflow into the next one
+
+
+
Parameters:
+
+
ticks
+ number
+ the number of ticks that represents a time
+
+
options
+ table
+ table a of options to use for the format
+
+
+
+
Returns:
+
+
+ string
+ a locale string that can be used
+
+
+
+
+
+
+ https://github.com/Refactorio/RedMew/blob/9184b2940f311d8c9c891e83429fc57ec7e0c4a2/map_gen/maps/diggy/debug.lua#L31
+ Prints a colored value on a location.
+
+
+
Parameters:
+
+
value
+ between -1 and 1
+
+
surface
+ LuaSurface
+
+
position
+ Position {x, y}
+
+
scale
+ float
+
+
offset
+ float
+
+
immutable
+ bool if immutable, only set, never do a surface lookup, values never change
+
+ Prints a colored value on a location. When given a color_value and a delta_color,
+ will change the color of the text from the base to base + value * delta. This will
+ make the color of the text range from 'base_color' to 'base_color + delta_color'
+ as the color_value ranges from 0 to 1
+
+
+
Parameters:
+
+
value
+ of number to be displayed
+
+
surface
+ LuaSurface
+
+
position
+ Position {x, y}
+
+
offset
+ float position offset
+
+
immutable
+ bool if immutable, only set, never do a surface lookup, values never change
+
+
color_value
+ float How far along the range of values of colors the value is to be displayed
+
+
base_color
+ {r,g,b} The color for the text to be if color_value is 0
+
+
delta_color
+ {r,g,b} The amount to correct the base_color if color_value is 1
+
+
under_bound
+ {r,g,b} The color to be used if color_value < 0
+
+
over_bound
+ {r,g,b} The color to be used if color_value > 1
+
+
+
+
+
+
+
+
+
+
+ clear_flying_text (surface)
+
+
+ Clears all flying text entites on a surface
+
+
+
Parameters:
+
+
surface
+ LuaSurface
+ the surface to clear
+
+
+
+
+
+
+
+
+
+
+ string_contains (s, contains)
+
+
+ Tests if a string contains a given substring.
+
+
+
Parameters:
+
+
s
+ string
+ the string to check for the substring
+
This contains a list of all files that will be loaded and the order they are loaded in
+ to stop a file from loading add "--" in front of it, remove the "--" to have the file be loaded
+ config files should be loaded after all modules are loaded
+ core files should be required by modules and not be present in this list
+
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.3
+Last updated 2019-05-29 22:22:59
+
Config for the different action buttons that show on the player list
+ each button has the button define(s) given along side an auth function, and optional reason callback
+ if a reason callback is used then Store.set_child(action_name_store,player.name,'BUTTON_NAME') should be called during on_click
+ buttons can be removed from the gui by commenting them out of the config at the bottom of this file
+ the key used for the name of the button is the permision name used by the role system
+
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.3
+Last updated 2019-05-29 22:22:59
+
This config controls what happens when a player dies mostly about map markers and item collection
+ allow_teleport_to_body_command and allow_collect_bodies_command can be over ridden if command_auth_runtime_disable is present
+ if not present then the commands will not be loaded into the game
+
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.3
+Last updated 2019-05-29 22:22:59
+
This is a very simple config file which adds a admin only auth function
+ not much to change here its more so it can be enabled and disabled from ./config/file_loader.lua
+ either way you can change the requirements to be "admin" if you wanted to
+
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.3
+Last updated 2019-05-29 22:22:59
+
This config for command auth allows commands to be globally enabled and disabled during runtime
+ this config adds Commands.disable and Commands.enable to enable and disable commands for all users
+
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.3
+Last updated 2019-05-29 22:22:59
+
This file contains some common command param parse functions
+ this file is less of a config and more of a requirement but you may wish to change how some behave
+ as such you need to be confident with lua but you edit this config file
+ use Commands.add_parse('name',function(input,player,reject) end) to add a parse
+ see ./expcore/commands.lua for more details
+
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.3
+Last updated 2019-05-29 22:22:59
+
Use this file to add new permission groups to the game
+ start with Permission_Groups.new_group('name')
+ then use either :allow_all() or :disallow_all() to set the default for non specified actions
+ then use :allow{} and :disallow{} to specify certain actions to allow/disallow
+
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.3
+Last updated 2019-05-29 22:22:59
+
Please go to ./config if you want to change settings, each file is commented with what it does
+ if it is not in ./config then you should not attempt to change it unless you know what you are doing
+ all files which are loaded (including the config files) are present in ./config/file_loader.lua
+ this file is the landing point for all scenarios please DO NOT edit directly, further comments are to aid development
+
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.3
+Last updated 2019-05-29 22:22:59
+
+ Registers a new option set that can be linked to radiobutotns (only one can be true at a time)
+
+
+
Parameters:
+
+
name
+ string
+ the name of the option set, must be unique
+
+
callback
+ function
+ the update callback when the value of the option set chagnes
+ callback param - value string - the new selected option for this option set
+ callback param - category string - the category that updated if categorize was used
+
+
categorize
+ function
+ the function used to convert an element into a string
+
+
+
+
Returns:
+
+
+ string
+ the name of this option set to be passed to add_as_option
+
+
+
+
+
+
+
+
+ Checkbox.draw_option_set (name, element)
+
+
+ Draws all radiobuttons that are part of an option set at once (Gui.draw will not work)
+
+
+
Parameters:
+
+
name
+ string
+ the name of the option set to draw the radiobuttons of
+
+
element
+ LuaGuiElement
+ the parent element that the radiobuttons will be drawn to
+
Core gui file for making element defines and element classes (use require 'expcore.gui')
+ see utils.gui for event handlering
+ see expcore.gui.test for examples for element defines
+[[
+
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.3
+Last updated 2019-05-29 22:22:59
+
+ Adds a callback which should return a table of values to be added as options for the dropdown (appended after static options)
+
+
+
Parameters:
+
+
callback
+ function
+ the function that will run to get the options for the dropdown
+ callback param - player LuaPlayer - the player that the element is being drawn to
+ callback param - element LuaGuiElement - the element that is being drawn
+ callback return - table - the values of this table will be appended to the static options of the dropdown
+
+
+
+
Returns:
+
+
+ self
+ the define to allow chaining
+
+
+
+
+
+
+ Adds a case specific callback which will only run when that option is selected (general case still triggered)
+
+
+
Parameters:
+
+
option
+ string
+ the name of the option to trigger the callback on; if not already added then will be added as an option
+
+
callback
+ function
+ the function that will be called when that option is selected
+ callback param - player LuaPlayer - the player who owns the gui element
+ callback param - element LuaGuiElement - the element which is being effected
+ callback param - value string - the new option that has been selected
+
+
+
+
Returns:
+
+
+ self
+ the define to allow chaining
+
+
+
+
+
+
+
+
+ Dropdown.select_value (element, value)
+
+
+ Selects the option from a dropdown or list box given the value rather than key
+
+
+
Parameters:
+
+
element
+ LuaGuiElement
+ the element that contains the option
+
+
value
+ string
+ the option to select from the dropdown
+
+
+
+
Returns:
+
+
+ number
+ the key where the value was
+
+
+
+
+
+
+
+
+ Dropdown.get_selected_value (element)
+
+
+ Returns the currently selected value rather than index
+
+
+
Parameters:
+
+
element
+ LuaGuiElement
+ the gui element that you want to get the value of
+
+
+
+
Returns:
+
+
+ string
+ the value that is currently selected
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.3
+Last updated 2019-05-29 22:22:59
+
This file is used to require all the different elements of the gui module
+ each module has an outline here but for more details see their seperate files in ./gui
+
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.3
+Last updated 2019-05-29 22:22:59
+
+ Sets if the frame is visible when a player joins, can also be a function to return a boolean
+
+
+
Parameters:
+
+
state
+ boolean or function
+ the default state of the visiblty, can be a function
+ state param - player LuaPlayer - the player that has joined the game
+ state param - define_name string - the define name for the frame
+ state return - boolean - false will hide the frame
+ (default true)
+
Adds an element into the list of instances that will are waiting to complete, does not work with store
+ note use store if you want persistent data, this only stores the elements not the values which they have
+ Adds an element into the list of instances that will are waiting to complete, does not work with store
+ note use store if you want persistent data, this only stores the elements not the values which they have
+
+
+
Parameters:
+
+
element
+ LuaGuiElement
+ the element that you want to add into the waiting to complete list
+
+
maximum
+ number
+ the maximum for this element if not given the default for this define is used
+ (optional)
+
This file creates a teste gui that is used to test every input method
+ note that this does not cover every permutation only features in indepentance
+ for example store in most cases is just by player name, but other store methods are tested with checkbox
+
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.3
+Last updated 2019-05-29 22:22:59
+
Gets all non nil children at a location, children can be added and removed during runtime
+ this is similar to Store.get but will always return a table even if it is empty
Sets the value of the chlid to a location, children can be added and removed during runtime
+ when a child is set it will call the update handler of the parent allowing children be to added at runtime
+ this may be used when a player joins the game and the child is the players name
+ Registers a new cross server synced location with an update callback, and external script is required for cross server
+
+
+
Parameters:
+
+
location
+ string
+ string a unique that points to the data, string used rather than token to allow migration
+
+
callback
+ function
+ this callback will be called when the stored value is set to a new value
+
+
start_value
+ any
+ this value will be the inital value that is stored at this location
+ (optional)
+
+
+
+
+
+
+
+
+
+
+ Store.add_watch (location, callback)
+
+
+ Adds a function that will be checked every tick for a change in the returned value, when the value changes it will be saved in the store
+
+
+
Parameters:
+
+
location
+ string
+ the location where the data will be saved and compeared to, must already be a registered location
+
+
callback
+ function
+ this function will be called every tick to check for a change in value
+
+
+
+
+
+
+
+
+
+
+ Store.get (location[, no_error=false])
+
+
+ Gets the value stored at a location, this location must be registered
+
+
+
Parameters:
+
+
location
+ string
+ the location to get the data from
+
+
no_error
+ boolean
+ when true no error is returned if the location is not registered
+ (default false)
+
+
+
+
Returns:
+
+
+ any
+ the data which was stored at the location
+
+
+
+
+
+
+
+
+ Store.set (location, value)
+
+
+ Sets the value at a location, this location must be registered, if server synced it will emit the change to file
+
+
+
Parameters:
+
+
location
+ string
+ the location to set the data to
+
+
value
+ any
+ the new value to set at the location, value may be reverted if there is a watch callback
+
+
+
+
Returns:
+
+
+ boolean
+ true if it was successful
+
+
+
+
+
+
+
+
+ Store.get_children (location)
+
+
+ Gets all non nil children at a location, children can be added and removed during runtime
+ this is similar to Store.get but will always return a table even if it is empty
+
+
+
Parameters:
+
+
location
+ string
+ the location to get the children of
+
+
+
+
Returns:
+
+
+ table
+ a table containg all the children and they values
+
+
+
+
+
+
+
+
+ Store.get_child (location, child)
+
+
+ Gets the value of the child to a location, children can be added and removed during runtime
+
+
+
Parameters:
+
+
location
+ string
+ the location of which the child is located
+
+
child
+ string
+ the child element to get the value of
+
+
+
+
Returns:
+
+
+ any
+ the value which was stored at that location
+
+
+
+
+
+
+
+
+ Store.set_child (location, child, value)
+
+
+ Sets the value of the chlid to a location, children can be added and removed during runtime
+ when a child is set it will call the update handler of the parent allowing children be to added at runtime
+ this may be used when a player joins the game and the child is the players name
+
+
+
Parameters:
+
+
location
+ string
+ the location of which the child is located
+
+
child
+ string
+ the child element to set the value of
+
+
value
+ any
+ the value to set at this location
+
+
+
+
Returns:
+
+
+ boolean
+ true if it was successful
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.3
+Last updated 2019-05-29 22:22:59
+
info
+ Original (javascript) version: https://hastebin.com/udakacavap.js
+ Can be tested against: https://wiki.factorio.com/Enemies#Spawn_chances_by_evolution_factor
+ Creates the spawner_request structure required for AlienEvolutionProgress.get_aliens for all
+available spawners. If dividing the total spawners by the total aliens causes a fraction, the
+fraction will decide a chance to spawn. 1 alien for 2 spawners will have 50% on both.
+
+
+
Parameters:
+
+
total_aliens
+ table
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.3
+Last updated 2019-05-29 22:22:59
+
Returns the Lua data type or the factorio LuaObject type
+ or 'NoHelpLuaObject' if the LuaObject does not have a help function
+ or 'InvalidLuaObject' if the LuaObject is invalid.
Returns true if the function is a closure, false otherwise.
+
+
+
+
+
+
+
+
Functions
+
+
+
+
+ Debug.print (message, stack_traceback)
+
+
+ Shows the given message if debug is enabled. Uses serpent to print non scalars.
+
+
+
Parameters:
+
+
message
+
+
+
stack_traceback
+ levels of stack trace to give, defaults to 1 level if nil
+
+
+
+
+
+
+
+
+
+
+ Debug.get_meta_value (object, key)
+
+
+ Returns the value of the key inside the object
+ or 'InvalidLuaObject' if the LuaObject is invalid.
+ or 'InvalidLuaObjectKey' if the LuaObject does not have an entry at that key
+
+
+
Parameters:
+
+
object
+
LuaObject or metatable
+
+
key
+
+
+
+
+
Returns:
+
+
+
+
+
+
+
+
+
+
+
+ Debug.object_type (object)
+
+
+ Returns the Lua data type or the factorio LuaObject type
+ or 'NoHelpLuaObject' if the LuaObject does not have a help function
+ or 'InvalidLuaObject' if the LuaObject is invalid.
+
+
+
Parameters:
+
+
object
+
+
+
+
+
Returns:
+
+
+ string
+
+
+
+
+
+
+
+
+ Debug.print_position (position, message)
+
+
+ Shows the given message if debug is on.
+
+
+
Parameters:
+
+
position
+ Position
+
+
message
+ string
+
+
+
+
+
+
+
+
+
+
+ Debug.cheat (callback)
+
+
+ Executes the given callback if cheating is enabled.
+
+
+
Parameters:
+
+
callback
+ function
+
+
+
+
+
+
+
+
+
+
+ Debug.is_closure (func)
+
+
+ Returns true if the function is a closure, false otherwise.
+ A closure is a function that contains 'upvalues' or in other words
+ has a reference to a local variable defined outside the function's scope.
+
+
+
Parameters:
+
+
func
+
+
+
+
+
Returns:
+
+
+ boolean
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.3
+Last updated 2019-05-29 22:22:59
+
This Module allows for registering multiple handlers to the same event, overcoming the limitation of script.register.
+
+
** Event.add(event_name, handler) **
+
Handlers added with Event.add must be added at the control stage or in Event.on_init or Event.on_load.
+ Remember that for each player, on_init or on_load is run, never both. So if you can't add the handler in the
+ control stage add the handler in both on_init and on_load.
+ Handlers added with Event.add cannot be removed.
+ For handlers that need to be removed or added at runtime use Event.add_removable.
+
Usage:
+
+
+ local Event = require 'utils.event'
+ Event.add(
+ defines.events.on_built_entity,
+ function(event)
+ game.print(serpent.block(event)) -- prints the content of the event table to console.
+ end
+ )
+
+ ** Event.add_removable(event_name, token) **
+
+ For conditional event handlers. Event.add_removable can be safely called at runtime without desync risk.
+ Only use this if you need to add the handler at runtime or need to remove the handler, otherwise use Event.add
+
+ Event.add_removable can be safely used at the control stage or in Event.on_init. If used in on_init you don't
+ need to also add in on_load (unlike Event.add).
+ Event.add_removable cannot be called in on_load, doing so will crash the game on loading.
+ Token is used because it's a desync risk to store closures inside the global table.
+
+
+ local Token = require 'utils.token'
+ local Event = require 'utils.event'
+
+ Token.register must not be called inside an event handler.
+ local handler =
+ Token.register(
+ function(event)
+ game.print(serpent.block(event)) -- prints the content of the event table to console.
+ end
+ )
+
+ The below code would typically be inside another event or a custom command.
+ Event.add_removable(defines.events.on_built_entity, handler)
+
+ When you no longer need the handler.
+ Event.remove_removable(defines.events.on_built_entity, handler)
+
+ It's not an error to register the same token multiple times to the same event, however when
+ removing only the first occurrence is removed.
+
+ ** Event.add_removable_function(event_name, func) **
+
+ Only use this function if you can't use Event.add_removable. i.e you are registering the handler at the console.
+ The same restrictions that apply to Event.add_removable also apply to Event.add_removable_function.
+ func cannot be a closure in this case, as there is no safe way to store closures in the global table.
+ A closure is a function that uses a local variable not defined in the function.
+
+
+ local Event = require 'utils.event'
+
+ If you want to remove the handler you will need to keep a reference to it.
+ global.handler = function(event)
+ game.print(serpent.block(event)) -- prints the content of the event table to console.
+ end
+
+ The below code would typically be used at the command console.
+ Event.add_removable_function(defines.events.on_built_entity, global.handler)
+
+ When you no longer need the handler.
+ Event.remove_removable_function(defines.events.on_built_entity, global.handler)
+
+ ** Other Events **
+
+ Use Event.on_init(handler) for script.on_init(handler)
+ Use Event.on_load(handler) for script.on_load(handler)
+
+ Use Event.on_nth_tick(tick, handler) for script.on_nth_tick(tick, handler)
+ Favour this event over Event.add(defines.events.on_tick, handler)
+ There are also Event.add_removable_nth_tick(tick, token) and Event.add_removable_nth_tick_function(tick, func)
+ That work the same as above.
+
+ ** Custom Scenario Events **
+
+ local Event = require 'utils.event'
+
+ local event_id = script.generate_event_name()
+
+ Event.add(
+ event_id,
+ function(event)
+ game.print(serpent.block(event)) -- prints the content of the event table to console.
+ end
+ )
+
+ The table contains extra information that you want to pass to the handler.
+ script.raise_event(event_id, {extra = 'data'})
+ Register a handler for the event_name event.
+ This function must be called in the control stage or in Event.on_init or Event.on_load.
+ See documentation at top of file for details on using events.
+
+
+
Parameters:
+
+
event_name
+
+
+
handler
+
+
+
+
+
+
+
+
+
+
+
+ Event.on_init (handler)
+
+
+ Register a handler for the script.on_init event.
+ This function must be called in the control stage or in Event.on_init or Event.on_load
+ See documentation at top of file for details on using events.
+
+
+
Parameters:
+
+
handler
+
+
+
+
+
+
+
+
+
+
+
+ Event.on_load (handler)
+
+
+ Register a handler for the script.on_load event.
+ This function must be called in the control stage or in Event.on_init or Event.on_load
+ See documentation at top of file for details on using events.
+
+
+
Parameters:
+
+
handler
+
+
+
+
+
+
+
+
+
+
+
+ Event.on_nth_tick (tick, handler)
+
+
+ Register a handler for the nth_tick event.
+ This function must be called in the control stage or in Event.on_init or Event.on_load.
+ See documentation at top of file for details on using events.
+
+
+
Parameters:
+
+
tick
+ The handler will be called every nth tick
+
+
handler
+
+
+
+
+
+
+
+
+
+
+
+ Event.add_removable (event_name, token)
+
+
+ Register a token handler that can be safely added and removed at runtime.
+ Do NOT call this method during on_load.
+ See documentation at top of file for details on using events.
+
+
+
Parameters:
+
+
event_name
+
+
+
token
+
+
+
+
+
+
+
+
+
+
+
+ Event.remove_removable (event_name, token)
+
+
+ Removes a token handler for the given event_name.
+ Do NOT call this method during on_load.
+ See documentation at top of file for details on using events.
+
+
+
+ Register a handler that can be safely added and removed at runtime.
+ The handler must not be a closure, as that is a desync risk.
+ Do NOT call this method during on_load.
+ See documentation at top of file for details on using events.
+
+
+
+ Removes a handler for the given event_name.
+ Do NOT call this method during on_load.
+ See documentation at top of file for details on using events.
+
+
+
Parameters:
+
+
event_name
+
+
+
func
+
+
+
+
+
+
+
+
+
+
+
+ Event.add_removable_nth_tick (tick, token)
+
+
+ Register a token handler for the nth tick that can be safely added and removed at runtime.
+ Do NOT call this method during on_load.
+ See documentation at top of file for details on using events.
+
+
+
+ Removes a token handler for the nth tick.
+ Do NOT call this method during on_load.
+ See documentation at top of file for details on using events.
+
+
+
+ Register a handler for the nth tick that can be safely added and removed at runtime.
+ The handler must not be a closure, as that is a desync risk.
+ Do NOT call this method during on_load.
+ See documentation at top of file for details on using events.
+
+
+
This module provides a classical mealy/moore state machine.
+
+ Each machine in constructed by calling new()
+ States and Transitions are lazily added to the machine as transition handlers and state tick handlers are registered.
+ However the state machine must be fully defined after init is done. Dynamic machine changes are currently unsupported
+ An example usage can be found here: map_gen\combined\tetris\control.lua
Register a handler that will be invoked by StateMachine.machine_tick
+ You may register multiple handlers for the same transition
+ NOTICE: This function will invoke an error if called after init.
Register a handler that will be invoked by StateMachine.transition
+ You may register multiple handlers for the same transition
+ NOTICE: This function will invoke an error if called after init.
+ Register a handler that will be invoked by StateMachine.machine_tick
+ You may register multiple handlers for the same transition
+ NOTICE: This function will invoke an error if called after init. Dynamic machine changes are currently unsupported
+
+
+
Parameters:
+
+
self
+ StateMachine the machine
+
+
state
+ number/string The state, that the machine will be in, when callback is invoked
+
+ Register a handler that will be invoked by StateMachine.transition
+ You may register multiple handlers for the same transition
+ NOTICE: This function will invoke an error if called after init. Dynamic machine changes are currently unsupported
+
+
+
Parameters:
+
+
self
+ StateMachine the machine
+
+
state
+ number/string entering state
+
+
state
+ number/string entering state
+
+
callback
+ function
+
+
+
+
+
+
+
+
+
+
+ Module.new (init_state)
+
+
+ Constructs a new state machine
+
+
+
Parameters:
+
+
init_state
+ number/string The starting state of the machine
+
+
+
+
Returns:
+
+
+ StateMachine The constructed state machine object
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.3
+Last updated 2019-05-29 22:22:59
+
Creates a fisher-yates shuffle of a sequential number-indexed table
+ because this uses math.random, it cannot be used outside of events if no rng is supplied
+ from: http://www.sdknews.com/cross-platform/corona/tutorial-how-to-shuffle-table-items
+ Chooses a random entry from a weighted table
+ because this uses math.random, it cannot be used outside of events
+
+
+
Parameters:
+
+
weight_table
+
of tables with items and their weights
+
+
item_index
+ of the index of items, defaults to 1
+
+
weight_index
+ of the index of the weights, defaults to 2
+
+
+
+
Returns:
+
+
+ table element
+
+
+
+
See also:
+
+
+
+
+
+
+
+ shuffle_table (t)
+
+
+ Creates a fisher-yates shuffle of a sequential number-indexed table
+ because this uses math.random, it cannot be used outside of events if no rng is supplied
+ from: http://www.sdknews.com/cross-platform/corona/tutorial-how-to-shuffle-table-items
+
+
+
Parameters:
+
+
t
+
to shuffle
+
+
+
+
+
+
+
+
+
+
+ clear_table (t, array)
+
+
+ Clears all existing entries in a table
+
+
+
Parameters:
+
+
t
+
to clear
+
+
array
+ to indicate whether the table is an array or not
+
+
+
+
+
+
+
+
+
+
Fields
+
+
+
+
+ inspect
+
+
+ Similar to serpent.block, returns a string with a pretty representation of a table.
+ Notice: This method is not appropriate for saving/restoring tables. It is meant to be used by the programmer mainly while debugging a program.
+ depth sets the maximum depth that will be printed out. When the max depth is reached, inspect will stop parsing tables and just return {...}
+ process is a function which allow altering the passed object before transforming it into a string.
+ A typical way to use it would be to remove certain values so that they don't appear at all.
+ return the prettied table
+
+
+
+
table
+
the table to serialize
+
+
options
+
options are depth, newline, indent, process
+
+
+
+
+
+
+
+
+
+
+ size
+
+
+ Takes a table and returns the number of entries in the table. (Slower than #table, faster than iterating via pairs)
+
+
+
+
+
+
+
+
+
+
+ deep_copy
+
+
+ Creates a deepcopy of a table. Metatables and LuaObjects inside the table are shallow copies.
+ Shallow copies meaning it copies the reference to the object instead of the object itself.
+
+
+
+
object
+
the object to copy
+
+
+
+
+
+
+
+
+
+
+ merge
+
+
+ Merges multiple tables. Tables later in the list will overwrite entries from tables earlier in the list.
+ Ex. merge({{1, 2, 3}, {[2] = 0}, {[3] = 0}}) will return {1, 0, 0}
+
+
+
+
tables
+
takes a table of tables to merge
+
+
+
+
+
+
+
+
+
+
+ equals
+
+
+ Determines if two tables are structurally equal.
+ Notice: tables that are LuaObjects or contain LuaObjects won't be compared correctly, use == operator for LuaObjects
+
+
+
+
tbl1
+
+
+
tbl2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.3
+Last updated 2019-05-29 22:22:59
+
Queueing allows you to split up heavy tasks which don't need to be completed in the same tick.
+
+
+
+
+
+
+
+
Functions
+
+
+
+
+ Task.set_timeout (sec, func_token, params)
+
+
+ Allows you to set a timer (in seconds) after which the tokened function will be run with params given as an argument
+ Cannot be called before init
+
+
+
Parameters:
+
+
sec
+
+
+
func_token
+ a token for a function store via the token system
+
+
params
+ the argument to send to the tokened function
+
+ Queueing allows you to split up heavy tasks which don't need to be completed in the same tick.
+ Queued tasks are generally run 1 per tick. If the queue backs up, more tasks will be processed per tick.
+ Ex. if the task is expected to repeat multiple times (ie. the function returns true and loops several ticks)
+
+
+
Parameters:
+
+
func_token
+ a token for a function stored via the token system
+ If this function returns `true` it will run again the next tick, delaying other queued tasks (see weight)
+
+
params
+ the argument to send to the tokened function
+
+
weight
+ (defaults to 1) weight is the number of ticks a task is expected to take.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.3
+Last updated 2019-05-29 22:22:59
+
+ Converts unix epoch timestamp into human readable string.
+
+
+
Parameters:
+
+
secs
+ unix epoch timestamp
+
+
+
+
Returns:
+
+
+ string
+
+
+
+
+
+
+
+
+
+
+
+
+generated by LDoc 1.4.3
+Last updated 2019-05-29 22:22:59
+
+
+
+
diff --git a/expcore/commands.lua b/expcore/commands.lua
index c7698802..c27bea4a 100644
--- a/expcore/commands.lua
+++ b/expcore/commands.lua
@@ -235,8 +235,7 @@ local Commands = {
}
--- Adds an authorization callback, function used to check if a player if allowed to use a command
--- @see Commands.authorize
--- @tparam callback function the callback you want to register as an authenticator
+-- @tparam function callback the callback you want to register as an authenticator
-- callback param - player: LuaPlayer - the player who is trying to use the command
-- callback param - command: string - the name of the command which is being used
-- callback param - flags: table - any flags which have been set for the command
@@ -248,8 +247,7 @@ function Commands.add_authenticator(callback)
end
--- Removes an authorization callback
--- @see Commands.add_authenticator
--- @tparam callback function|number the callback to remove, an index returned by add_authenticator can be passed
+-- @tparam function|number callback the callback to remove, an index returned by add_authenticator can be passed
-- @treturn boolean was the callback found and removed
function Commands.remove_authenticator(callback)
if type(callback) == 'number' then
@@ -277,8 +275,8 @@ function Commands.remove_authenticator(callback)
end
--- Mostly used internally, calls all authorization callbacks, returns if the player is authorized
--- @tparam player LuaPlayer the player that is using the command, passed to callbacks
--- @tparam command_name string the command that is being used, passed to callbacks
+-- @tparam LuaPlayer player the player that is using the command, passed to callbacks
+-- @tparam string command_name the command that is being used, passed to callbacks
-- @treturn[1] boolean true player is authorized
-- @treturn[1] string commands const for success
-- @treturn[2] boolean false player is unauthorized
@@ -322,7 +320,7 @@ function Commands.authorize(player,command_name)
end
--- Gets all commands that a player is allowed to use, game commands not included
--- @tparam[opt] player LuaPlayer the player that you want to get commands of, nil will return all commands
+-- @tparam[opt] LuaPlayer player the player that you want to get commands of, nil will return all commands
-- @treturn table all commands that that player is allowed to use, or all commands
function Commands.get(player)
player = Game.get_player_from_any(player)
@@ -337,8 +335,8 @@ function Commands.get(player)
end
--- Searches command names and help messages to find possible commands, game commands included
--- @tparam keyword string the word which you are trying to find
--- @tparam[opt] allowed_player LuaPlayer the player to get allowed commands of, if nil all commands are searched
+-- @tparam string keyword the word which you are trying to find
+-- @tparam[opt] LuaPlayer allowed_player the player to get allowed commands of, if nil all commands are searched
-- @treturn table all commands that contain the key word, and allowed by player if player given
function Commands.search(keyword,allowed_player)
local custom_commands = Commands.get(allowed_player)
@@ -369,8 +367,8 @@ end
--- Adds a parse function which can be called by name rather than callback (used in add_param)
-- nb: this is not needed as you can use the callback directly this just allows it to be called by name
--- @tparam name string the name of the parse, should be the type like player or player_alive, must be unique
--- @tparam callback function the callback that is ran to parse the input
+-- @tparam string name the name of the parse, should be the type like player or player_alive, must be unique
+-- @tparam function callback the callback that is ran to parse the input
-- parse param - input: string - the input given by the user for this param
-- parse param - player: LuaPlayer - the player who is using the command
-- parse param - reject: function(error_message) - use this function to send a error to the user and fail running
@@ -386,14 +384,16 @@ function Commands.add_parse(name,callback)
end
--- Removes a parse function, see add_parse for adding them
--- @tparam name string the name of the parse to remove
+-- @tparam string name the name of the parse to remove
function Commands.remove_parse(name)
Commands.parse_functions[name] = nil
end
--- Intended to be used within other parse functions, runs a parse and returns success and new value
--- @tparam name string the name of the parse to call, must be registered and cant be a function
--- @tparam input string the input to pass to the parse, will always be a string but might not be the orginal input
+-- @tparam string name the name of the parse to call, must be registered and cant be a function
+-- @tparam string input string the input to pass to the parse, will always be a but might not be the orginal input
+-- @tparam LuaPlayer player the player that is calling using the command
+-- @tparam function reject the reject function that was passed by the command hander
-- @treturn any the new value for the input, may be nil, if nil then either there was an error or input was nil
function Commands.parse(name,input,player,reject,...)
if not Commands.parse_functions[name] then return end
@@ -405,8 +405,8 @@ function Commands.parse(name,input,player,reject,...)
end
--- Creates a new command object to added details to, note this does not register the command to the game
--- @tparam name string the name of the command to be created
--- @tparam help string the help message for the command
+-- @tparam string name the name of the command to be created
+-- @tparam string help the help message for the command
-- @treturn Commands._prototype this will be used with other functions to generate the command functions
function Commands.new_command(name,help)
local command = setmetatable({
@@ -427,9 +427,9 @@ function Commands.new_command(name,help)
end
--- Adds a new param to the command this will be displayed in the help and used to parse the input
--- @tparam name string the name of the new param that is being added to the command
--- @tparam[opt=true] optional is this param required for this command, these must be after all required params
--- @tparam[opt=pass through] parse function this function will take the input and return a new (or same) value
+-- @tparam string name the name of the new param that is being added to the command
+-- @tparam[opt=true] boolean optional is this param required for this command, these must be after all required params
+-- @tparam[opt=pass function through] ?string|function parse this function will take the input and return a new (or same) value
-- @param[opt] ... extra args you want to pass to the parse function; for example if the parse is general use
-- parse param - input: string - the input given by the user for this param
-- parse param - player: LuaPlayer - the player who is using the command
@@ -452,7 +452,7 @@ function Commands._prototype:add_param(name,optional,parse,...)
end
--- Adds default values to params only matters if the param is optional, if default value is a function it is called with param player
--- @tparam defaults table a table keyed by the name of the param with the value as the default value {paramName=defaultValue}
+-- @tparam table defaults table a keyed by the name of the param with the value as the default value {paramName=defaultValue}
-- callback param - player: LuaPlayer - the player using the command, default value does not need to be a function callback
-- @treturn Commands._prototype pass through to allow more functions to be called
function Commands._prototype:set_defaults(defaults)
@@ -465,8 +465,8 @@ function Commands._prototype:set_defaults(defaults)
end
--- Adds a tag to the command which is passed via the flags param to the authenticators, can be used to assign command roles or type
--- @tparam name string the name of the tag to be added; used to keep flags separate
--- @tparam value any the tag that you want can be anything that the authenticators are expecting
+-- @tparam string name the name of the tag to be added; used to keep flags separate
+-- @tparam any value the tag that you want can be anything that the authenticators are expecting
-- nb: if value is nil then name will be assumed as the value and added at a numbered index
-- @treturn Commands._prototype pass through to allow more functions to be called
function Commands._prototype:set_flag(name,value)
@@ -482,7 +482,7 @@ end
--- Adds an alias or multiple that will also be registered with the same callback, eg /teleport can be /tp with both working
-- @usage command:add_alias('aliasOne','aliasTwo','etc')
--- @tparam ... string any amount of aliases that you want this command to be callable with
+-- @tparam string any ... amount of aliases that you want this command to be callable with
-- @treturn Commands._prototype pass through to allow more functions to be called
function Commands._prototype:add_alias(...)
for _,alias in pairs({...}) do
@@ -503,7 +503,7 @@ end
--- Adds the callback to the command and registers all aliases, params and help message with the game
-- nb: this must be the last function ran on the command and must be done for the command to work
--- @tparam callback function the callback for the command, will receive the player running command, and params added with add_param
+-- @tparam function callback the callback for the command, will receive the player running command, and params added with add_param
-- callback param - player: LuaPlayer - the player who used the command
-- callback param - ... - any params which were registered with add_param in the order they where registered
-- callback param - raw: string - the raw input from the user, comes after every param added with add_param
@@ -540,8 +540,8 @@ end
-- nb: this is for non fatal errors meaning there is no log of this event
-- nb: if reject is giving as a param to the callback use that instead
-- @usage return Commands.error()
--- @tparam[opt] error_message string an optional error message that can be sent to the user
--- @tparam[opt] play_sound string the sound to play for the error
+-- @tparam[opt] string error_message an optional error message that can be sent to the user
+-- @tparam[opt] string play_sound the sound to play for the error
-- @treturn Commands.defines.error return this to command handler to exit execution
function Commands.error(error_message,play_sound)
error_message = error_message or ''
@@ -555,9 +555,9 @@ end
--- Sends an error to the player and logs the error, used with pcall within command handler please avoid direct use
-- nb: use error(error_message) within your callback to trigger do not trigger directly as the handler may still continue
--- @tparam success boolean the success value returned from pcall, or just false to trigger error
--- @tparam command_name string the name of the command this is used within the log
--- @tparam error_message string the error returned by pcall or some other error, this is logged and not returned to player
+-- @tparam boolean success the success value returned from pcall, or just false to trigger error
+-- @tparam string command_name the name of the command this is used within the log
+-- @tparam string error_message the error returned by pcall or some other error, this is logged and not returned to player
-- @treturn boolean the opposite of success so true means to cancel execution, used internally
function Commands.internal_error(success,command_name,error_message)
if not success then
@@ -569,7 +569,7 @@ end
--- Sends a value to the player, followed by a command complete message
-- nb: either return a value from your callback to trigger or return the return of this to prevent two messages
--- @tparam[opt] value any the value to return to the player, if nil then only success message returned
+-- @tparam[opt] any value the value to return to the player, if nil then only success message returned
-- @treturn Commands.defines.success return this to the command handler to prevent two success messages
function Commands.success(value)
if value ~= nil then player_return(value) end
@@ -591,7 +591,7 @@ local function command_log(player,command,comment,params,raw,details)
end
--- Main event function that is ran for all commands, used internally please avoid direct use
--- @tparam command_event table passed directly from command event from the add_command function
+-- @tparam table command_event passed directly from command event from the add_command function
function Commands.run_command(command_event)
local command_data = Commands.commands[command_event.name]
-- player can be nil when it is the server
diff --git a/expcore/common.lua b/expcore/common.lua
index 41adffd5..674793e3 100644
--- a/expcore/common.lua
+++ b/expcore/common.lua
@@ -48,7 +48,7 @@ local Public = {}
--- Compare types faster for faster validation of params
-- @usage type_check('foo','string') -- return true
-- @usage type_check('foo') -- return false
--- @param v the value to be tested
+-- @tparam any value the value to be tested
-- @tparam[opt=nil] string test_type the type to test for if not given then it tests for nil
-- @treturn boolean is v of type test_type
function Public.type_check(value,test_type)
@@ -57,10 +57,10 @@ end
--- Raises an error if the value is of the wrong type
-- @usage type_check_error('foo','number','Value must be a number') -- will raise error "Value must be a number"
--- @tparam value any the value that you want to test the type of
--- @tparam test_type string the type that the value should be
--- @tparam error_message string the error message that is returned
--- @tparam level number the level to call the error on (level = 1 means the caller)
+-- @tparam any value the value that you want to test the type of
+-- @tparam string test_type the type that the value should be
+-- @tparam string error_message the error message that is returned
+-- @tparam number level the level to call the error on (level = 1 means the caller)
-- @treturn boolean true if no error was called
function Public.type_check_error(value,test_type,error_message,level)
level = level and level+1 or 2
@@ -69,10 +69,10 @@ end
--- Raises an error when the value is the incorrect type, uses a consistent error message format
-- @usage param_check('foo','number','repeat_count',2) -- will raise error "Invalid param #02 given to ; repeat_count is not of type number"
--- @tparam value any the value that you want to test the type of
--- @tparam test_type string the type that the value should be
--- @tparam param_name string the name of the param
--- @tparam param_number number the number param it is
+-- @tparam any value the value that you want to test the type of
+-- @tparam string test_type the type that the value should be
+-- @tparam string param_name the name of the param
+-- @tparam number param_number the number param it is
-- @treturn boolean true if no error was raised
function Public.param_check(value,test_type,param_name,param_number)
if not Public.test_type(value,test_type) then
@@ -125,15 +125,15 @@ function Public.player_return(value,colour,player)
end
--- Writes a table object to a file in json format
--- @tparam path string the path of the file to write include / to use dir
--- @tpatam tbl table the table that will be converted to a json string and wrote to file
+-- @tparam string path the path of the file to write include / to use dir
+-- @tparam table tbl the table that will be converted to a json string and wrote to file
function Public.write_json(path,tbl)
game.write_file(path,game.table_to_json(tbl)..'\n',true,0)
end
--- Calls a require that will not error if the file is not found
-- @usage local file = opt_require('file.not.present') -- will not cause any error
--- @tparam path string the path that you want to require
+-- @tparam string path the path that you want to require
-- @return the returns from that file or nil, error if not loaded
function Public.opt_require(path)
local success, rtn = pcall(require,path)
@@ -142,9 +142,9 @@ function Public.opt_require(path)
end
--- Calls a require and returns only the keys given, file must return a table
--- @useage local extract, param_check = ext_require('expcore.common','extract','param_check')
--- @tparam path string the path that you want to require
--- @tparam ... string the name of the keys that you want returned
+-- @usage local extract, param_check = ext_require('expcore.common','extract','param_check')
+-- @tparam string path the path that you want to require
+-- @tparam string ... the name of the keys that you want returned
-- @return the keys in the order given
function Public.ext_require(path,...)
local rtn = require(path)
@@ -159,8 +159,8 @@ end
-- time will use : separates
-- string will return a string not a locale string
-- when a denomination is false it will overflow into the next one
--- @tparam ticks number the number of ticks that represents a time
--- @tparam options table a table of options to use for the format
+-- @tparam number ticks the number of ticks that represents a time
+-- @tparam table options table a of options to use for the format
-- @treturn string a locale string that can be used
function Public.format_time(ticks,options)
-- Sets up the options
@@ -247,10 +247,11 @@ function Public.format_time(ticks,options)
end
--- Moves items to the position and stores them in the closest entity of the type given
--- @tparam items table items which are to be added to the chests, ['name']=count
--- @tparam[opt=navies] surface LuaSurface the surface that the items will be moved to
--- @tparam[opt={0,0}] position table the position that the items will be moved to {x=100,y=100}
--- @tparam[opt=32] radius number the radius in which the items are allowed to be placed
+-- @tparam table items items which are to be added to the chests, ['name']=count
+-- @tparam[opt=navies] LuaSurface surface the surface that the items will be moved to
+-- @tparam[opt={0,0}] table position the position that the items will be moved to {x=100,y=100}
+-- @tparam[opt=32] number radius the radius in which the items are allowed to be placed
+-- @tparam[opt=iron-chest] string chest_type the chest type that the items should be moved into
function Public.move_items(items,surface,position,radius,chest_type)
chest_type = chest_type or 'iron-chest'
surface = surface or game.surfaces[1]
@@ -438,7 +439,7 @@ function Public.print_colored_grid_value(value, surface, position, offset, immut
end
--- Clears all flying text entites on a surface
--- @tparam surface LuaSurface the surface to clear
+-- @tparam LuaSurface surface the surface to clear
function Public.clear_flying_text(surface)
local entities = surface.find_entities_filtered{name ='flying-text'}
for _,entity in pairs(entities) do
@@ -458,8 +459,8 @@ end
--- Extracts certain keys from a table
-- @usage local key_three, key_one = extract({key_one='foo',key_two='bar',key_three=true},'key_three','key_one')
--- @tparam tbl table the table which contains the keys
--- @tparam ... string the names of the keys you want extracted
+-- @tparam table tbl table the which contains the keys
+-- @tparam string ... the names of the keys you want extracted
-- @return the keys in the order given
function Public.extract_keys(tbl,...)
local values = {}
@@ -470,7 +471,7 @@ function Public.extract_keys(tbl,...)
end
--- Converts a table to an enum
--- @tparam tbl table the table that will be converted
+-- @tparam table tbl table the that will be converted
-- @treturn table the new table that acts like an enum
function Public.enum(tbl)
local rtn = {}
@@ -491,10 +492,10 @@ function Public.enum(tbl)
end
--- Returns the closest match to the input
--- @tparam options table a table of options for the auto complete
--- @tparam input string the input string that will be completed
--- @tparam[opt=false] use_key boolean when true the keys of options will be used as the options
--- @tparam[opt=false] rtn_key boolean when true the the key will be returned rather than the value
+-- @tparam table options table a of options for the auto complete
+-- @tparam string input string the input that will be completed
+-- @tparam[opt=false] boolean use_key when true the keys of options will be used as the options
+-- @tparam[opt=false] boolean rtn_key when true the the key will be returned rather than the value
-- @return the list item found that matches the input
function Public.auto_complete(options,input,use_key,rtn_key)
local rtn = {}
@@ -511,7 +512,7 @@ function Public.auto_complete(options,input,use_key,rtn_key)
end
--- Returns all the keys of a table
--- @tparam tbl table the table to get the keys of
+-- @tparam table tbl table the to get the keys of
-- @treturn table an array of the table keys
function Public.table_keys(tbl)
local rtn = {}
@@ -522,7 +523,7 @@ function Public.table_keys(tbl)
end
--- Returns all the values of a table
--- @tparam tbl table the table to get the values of
+-- @tparam table tbl table the to get the values of
-- @treturn table an array of the table values
function Public.table_values(tbl)
local rtn = {}
@@ -558,8 +559,8 @@ function Public.table_keysort(tbl)
end
--- Returns a message with valid chat tags to change its colour
--- @tparam message string the message that will be in the output
--- @tparam color table a color which contains r,g,b as its keys
+-- @tparam string message the message that will be in the output
+-- @tparam table color a color which contains r,g,b as its keys
-- @treturn string the message with the color tags included
function Public.format_chat_colour(message,color)
color = color or Colours.white
@@ -568,8 +569,8 @@ function Public.format_chat_colour(message,color)
end
--- Returns a message with valid chat tags to change its colour, using localization
--- @tparam message ?string|table the message that will be in the output
--- @tparam color table a color which contains r,g,b as its keys
+-- @tparam ?string|table message the message that will be in the output
+-- @tparam table color a color which contains r,g,b as its keys
-- @treturn table the message with the color tags included
function Public.format_chat_colour_localized(message,color)
color = color or Colours.white
@@ -578,8 +579,8 @@ function Public.format_chat_colour_localized(message,color)
end
--- Returns the players name in the players color
--- @tparam player LuaPlayer the player to use the name and color of
--- @tparam[opt=false] raw_string boolean when true a string is returned rather than a localized string
+-- @tparam LuaPlayer player the player to use the name and color of
+-- @tparam[opt=false] boolean raw_string when true a is returned rather than a localized string
-- @treturn table the players name with tags for the players color
function Public.format_chat_player_name(player,raw_string)
player = Game.get_player_from_any(player)
diff --git a/expcore/gui/buttons.lua b/expcore/gui/buttons.lua
index 9e3ae887..9a5d794b 100644
--- a/expcore/gui/buttons.lua
+++ b/expcore/gui/buttons.lua
@@ -25,7 +25,7 @@ local Button = {
}
--- Creates a new button element define
--- @tparam[opt] name string the optional debug name that can be added
+-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new button element define
function Button.new_button(name)
@@ -68,9 +68,9 @@ function Button.new_button(name)
end
--- Adds sprites to a button making it a spirte button
--- @tparam sprite SpritePath the sprite path for the default sprite for the button
--- @tparam[opt] hovered_sprite SpritePath the sprite path for the sprite when the player hovers over the button
--- @tparam[opt] clicked_sprite SpritePath the sprite path for the sprite when the player clicks the button
+-- @tparam SpritePath sprite the sprite path for the default sprite for the button
+-- @tparam[opt] SpritePath hovered_sprite the sprite path for the sprite when the player hovers over the button
+-- @tparam[opt] SpritePath clicked_sprite the sprite path for the sprite when the player clicks the button
-- @treturn self returns the button define to allow chaining
function Button._prototype:set_sprites(sprite,hovered_sprite,clicked_sprite)
self.draw_data.type = 'sprite-button'
@@ -81,8 +81,8 @@ function Button._prototype:set_sprites(sprite,hovered_sprite,clicked_sprite)
end
--- Adds a click / mouse button filter to the button
--- @tparam filter ?string|table either a table of mouse buttons or the first mouse button to filter, with a table true means allowed
--- @tparam[opt] ... when filter is not a table you can add the mouse buttons one after each other
+-- @tparam table filter ?string|table either a of mouse buttons or the first mouse button to filter, with a table true means allowed
+-- @tparam[opt] table ... when filter is not a you can add the mouse buttons one after each other
-- @treturn self returns the button define to allow chaining
function Button._prototype:set_click_filter(filter,...)
if type(filter) == 'string' then
@@ -103,8 +103,8 @@ function Button._prototype:set_click_filter(filter,...)
end
--- Adds a control key filter to the button
--- @tparam filter ?string|table either a table of control keys or the first control keys to filter, with a table true means allowed
--- @tparam[opt] ... when filter is not a table you can add the control keyss one after each other
+-- @tparam table filter ?string|table either a of control keys or the first control keys to filter, with a table true means allowed
+-- @tparam[opt] table ... when filter is not a you can add the control keyss one after each other
-- @treturn self returns the button define to allow chaining
function Button._prototype:set_key_filter(filter,...)
if type(filter) == 'string' then
diff --git a/expcore/gui/center.lua b/expcore/gui/center.lua
index 59c978c2..2788e804 100644
--- a/expcore/gui/center.lua
+++ b/expcore/gui/center.lua
@@ -26,7 +26,7 @@ local CenterFrames = {
}
--- Gets the center flow for a player
--- @tparam player LuapPlayer the player to get the flow for
+-- @tparam LuaPlayer player the player to get the flow for
-- @treturn LuaGuiElement the center flow
function CenterFrames.get_flow(player)
player = Game.get_player_from_any(player)
@@ -34,15 +34,15 @@ function CenterFrames.get_flow(player)
end
--- Clears the center flow for a player
--- @tparam player LuapPlayer the player to clear the flow for
+-- @tparam LuaPlayer player the player to clear the flow for
function CenterFrames.clear_flow(player)
local flow = CenterFrames.get_flow(player)
flow.clear()
end
--- Draws the center frame for a player, if already open then will do nothing
--- @tparam player LuapPlayer the player that will have the frame drawn
--- @tparam name string the name of the hui that will drawn
+-- @tparam LuaPlayer player the player that will have the frame drawn
+-- @tparam string name the name of the hui that will drawn
-- @treturn LuaGuiElement the new frame that was made
function CenterFrames.draw_frame(player,name)
local define = Gui.get_define(name,true)
@@ -52,8 +52,8 @@ function CenterFrames.draw_frame(player,name)
end
--- Draws the center frame for a player, if already open then will destroy it and redraw
--- @tparam player LuapPlayer the player that will have the frame drawn
--- @tparam name string the name of the hui that will drawn
+-- @tparam LuaPlayer player the player that will have the frame drawn
+-- @tparam string name the name of the hui that will drawn
-- @treturn LuaGuiElement the new frame that was made
function CenterFrames.redraw_frame(player,name)
local define = Gui.get_define(name,true)
@@ -63,9 +63,9 @@ function CenterFrames.redraw_frame(player,name)
end
--- Toggles if the frame is currently open or not, will open if closed and close if open
--- @tparam player LuapPlayer the player that will have the frame toggled
--- @tparam name string the name of the hui that will be toggled
--- @tparam[opt] state boolean when set will force a state for the frame
+-- @tparam LuaPlayer player the player that will have the frame toggled
+-- @tparam string name the name of the hui that will be toggled
+-- @tparam[opt] boolean state when set will force a state for the frame
-- @treturn boolean if the frame if no open or closed
function CenterFrames.toggle_frame(player,name,state)
local define = Gui.get_define(name,true)
@@ -86,7 +86,7 @@ function CenterFrames.toggle_frame(player,name,state)
end
--- Creates a new center frame define
--- @tparam permision_name string the name that can be used with the permision system
+-- @tparam string permision_name the name that can be used with the permision system
-- @treturn table the new center frame define
function CenterFrames.new_frame(permision_name)
local self = Toolbar.new_button(permision_name)
@@ -108,7 +108,7 @@ function CenterFrames.new_frame(permision_name)
end
--- Sets the frame to be the current active gui when opened and closes all other frames
--- @tparam[opt=true] state boolean when true will auto close other frames and set this frame as player.opened
+-- @tparam[opt=true] boolean state when true will auto close other frames and set this frame as player.opened
function CenterFrames._prototype:set_auto_focus(state)
if state == false then
self.auto_focus = false
@@ -118,7 +118,7 @@ function CenterFrames._prototype:set_auto_focus(state)
end
--- Draws this frame to the player, if already open does nothing (will call on_draw to draw to the frame)
--- @tparam player LuaPlayer the player to draw the frame for
+-- @tparam LuaPlayer player the player to draw the frame for
-- @treturn LuaGuiElement the new frame that was drawn
function CenterFrames._prototype:draw_frame(player)
player = Game.get_player_from_any(player)
@@ -149,7 +149,7 @@ function CenterFrames._prototype:draw_frame(player)
end
--- Draws this frame to the player, if already open it will remove it and redraw it (will call on_draw to draw to the frame)
--- @tparam player LuaPlayer the player to draw the frame for
+-- @tparam LuaPlayer player the player to draw the frame for
-- @treturn LuaGuiElement the new frame that was drawn
function CenterFrames._prototype:redraw_frame(player)
player = Game.get_player_from_any(player)
@@ -163,7 +163,7 @@ function CenterFrames._prototype:redraw_frame(player)
end
--- Toggles if the frame is open, if open it will close it and if closed it will open it
--- @tparam player LuaPlayer the player to draw the frame for
+-- @tparam LuaPlayer player the player to draw the frame for
-- @treturn boolean with the gui frame is now open
function CenterFrames._prototype:toggle_frame(player)
player = Game.get_player_from_any(player)
@@ -179,7 +179,7 @@ function CenterFrames._prototype:toggle_frame(player)
end
--- Creates an event handler that will trigger one of its functions, use with Event.add
--- @tparam[opt=update] action string the action to take on this event
+-- @tparam[opt=update] string action the action to take on this event
function CenterFrames._prototype:event_handler(action)
action = action or 'update'
return function(event)
diff --git a/expcore/gui/checkboxs.lua b/expcore/gui/checkboxs.lua
index b31d9f6e..a87d9c02 100644
--- a/expcore/gui/checkboxs.lua
+++ b/expcore/gui/checkboxs.lua
@@ -50,9 +50,9 @@ local Store = require 'expcore.store'
local Game = require 'utils.game'
--- Event call for on_checked_state_changed and store update
--- @tparam define table the define that this is acting on
--- @tparam element LuaGuiElement the element that triggered the event
--- @tparam value boolean the new state of the checkbox
+-- @tparam table define the define that this is acting on
+-- @tparam LuaGuiElement element the element that triggered the event
+-- @tparam boolean value the new state of the checkbox
local function event_call(define,element,value)
if define.events.on_element_update then
local player = Game.get_player_by_index(element.player_index)
@@ -61,9 +61,9 @@ local function event_call(define,element,value)
end
--- Store call for store update
--- @tparam define table the define that this is acting on
--- @tparam element LuaGuiElement the element that triggered the event
--- @tparam value boolean the new state of the checkbox
+-- @tparam table define the define that this is acting on
+-- @tparam LuaGuiElement element the element that triggered the event
+-- @tparam boolean value the new state of the checkbox
local function store_call(define,element,value)
element.state = value
event_call(define,element,value)
@@ -87,7 +87,7 @@ local Checkbox = {
}
--- Creates a new checkbox element define
--- @tparam[opt] name string the optional debug name that can be added
+-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new checkbox element define
function Checkbox.new_checkbox(name)
@@ -131,7 +131,7 @@ function Checkbox.new_checkbox(name)
end
--- Creates a new radiobutton element define, has all functions checkbox has
--- @tparam[opt] name string the optional debug name that can be added
+-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new button element define
function Checkbox.new_radiobutton(name)
local self = Checkbox.new_checkbox(name)
@@ -144,9 +144,9 @@ function Checkbox.new_radiobutton(name)
end
--- Adds this radiobutton to be an option in the given option set (only one can be true at a time)
--- @tparam option_set string the name of the option set to add this element to
--- @tparam option_name string the name of this option that will be used to idenitife it
--- @tparam self the define to allow chaining
+-- @tparam string option_set the name of the option set to add this element to
+-- @tparam string option_name the name of this option that will be used to idenitife it
+-- @treturn self the define to allow chaining
function Checkbox._prototype_radiobutton:add_as_option(option_set,option_name)
self.option_set = option_set
self.option_name = option_name or self.name
@@ -160,7 +160,8 @@ function Checkbox._prototype_radiobutton:add_as_option(option_set,option_name)
end
--- Gets the stored value of the radiobutton or the option set if present
--- @tparam category[opt] string the category to get such as player name or force name
+-- @tparam string category[opt] the category to get such as player name or force name
+-- @tparam boolean internal used to prevent stackover flow
-- @treturn any the value that is stored for this define
function Checkbox._prototype_radiobutton:get_store(category,internal)
if not self.store then return end
@@ -174,8 +175,9 @@ function Checkbox._prototype_radiobutton:get_store(category,internal)
end
--- Sets the stored value of the radiobutton or the option set if present
--- @tparam category[opt] string the category to get such as player name or force name
--- @tparam value any the value to set for this define, must be valid for its type ie boolean for checkbox etc
+-- @tparam string category[opt] the category to get such as player name or force name
+-- @tparam boolean value the value to set for this define, must be valid for its type ie for checkbox etc
+-- @tparam boolean internal used to prevent stackover flow
-- @treturn boolean true if the value was set
function Checkbox._prototype_radiobutton:set_store(category,value,internal)
if not self.store then return end
@@ -189,11 +191,11 @@ function Checkbox._prototype_radiobutton:set_store(category,value,internal)
end
--- Registers a new option set that can be linked to radiobutotns (only one can be true at a time)
--- @tparam name string the name of the option set, must be unique
--- @tparam callback function the update callback when the value of the option set chagnes
+-- @tparam string name the name of the option set, must be unique
+-- @tparam function callback the update callback when the value of the option set chagnes
-- callback param - value string - the new selected option for this option set
-- callback param - category string - the category that updated if categorize was used
--- @tpram categorize function the function used to convert an element into a string
+-- @tparam function categorize the function used to convert an element into a string
-- @treturn string the name of this option set to be passed to add_as_option
function Checkbox.new_option_set(name,callback,categorize)
@@ -216,8 +218,8 @@ function Checkbox.new_option_set(name,callback,categorize)
end
--- Draws all radiobuttons that are part of an option set at once (Gui.draw will not work)
--- @tparam name string the name of the option set to draw the radiobuttons of
--- @tparam element LuaGuiElement the parent element that the radiobuttons will be drawn to
+-- @tparam string name the name of the option set to draw the radiobuttons of
+-- @tparam LuaGuiElement element the parent element that the radiobuttons will be drawn to
function Checkbox.draw_option_set(name,element)
if not Checkbox.option_sets[name] then return end
local options = Checkbox.option_sets[name]
@@ -231,9 +233,9 @@ function Checkbox.draw_option_set(name,element)
end
--- Sets all radiobutotn in a element to false (unless excluded) and can act recursivly
--- @tparam element LuaGuiElement the root gui element to start setting radio buttons from
--- @tparam[opt] exclude ?string|table the name of the radiobutton to exclude or a table of radiobuttons where true will set the state true
--- @tparam[opt=false] recursive boolean if true will recur as much as possible, if a number will recur that number of times
+-- @tparam LuaGuiElement element the root gui element to start setting radio buttons from
+-- @tparam[opt] table exclude ?string|table the name of the radiobutton to exclude or a of radiobuttons where true will set the state true
+-- @tparam[opt=false] ?number|boolean recursive if true will recur as much as possible, if a will recur that number of times
-- @treturn boolean true if successful
function Checkbox.reset_radiobuttons(element,exclude,recursive)
if not element or not element.valid then return end
diff --git a/expcore/gui/core.lua b/expcore/gui/core.lua
index c58de2e3..3288d195 100644
--- a/expcore/gui/core.lua
+++ b/expcore/gui/core.lua
@@ -167,7 +167,7 @@ Gui.defines = {} -- Stores the indivdual element definations
Gui.names = {} -- Stores debug names to link to gui uids
--- Used internally to create new prototypes for element defines
--- @tparam tbl table a table that will have functions added to it
+-- @tparam table tbl table a that will have functions added to it
-- @treturn table the new table with the keys added to it
function Gui._prototype_factory(tbl)
for k,v in pairs(Gui._prototype) do
@@ -177,12 +177,12 @@ function Gui._prototype_factory(tbl)
end
--- Used internally to create event handler adders for element defines
--- @tparam name string the key that the event will be stored under, should be the same as the event name
+-- @tparam string name the key that the event will be stored under, should be the same as the event name
-- @treturn function the function that can be used to add an event handler
function Gui._event_factory(name)
--- Gui._prototype:on_event(callback)
--- Add a hander to run on this event, replace event with the event, different classes have different events
- -- @tparam callback function the function that will be called on the event
+ -- @tparam function callback the function that will be called on the event
-- callback param - player LuaPlayer - the player who owns the gui element
-- callback param - element LuaGuiElement - the element that caused the event
-- callback param - value any - (not always present) the updated value for the element
@@ -204,7 +204,7 @@ end
function Gui._store_factory(callback)
--- Gui._prototype:add_store(categorize)
--- Adds a store location for the define that will save the state of the element, categorize is a function that returns a string
- -- @tparam[opt] categorize function if present will be called to convert an element into a category string
+ -- @tparam[opt] function categorize if present will be called to convert an element into a category string
-- categorize param - element LuaGuiElement - the element that needs to be converted
-- categorize return - string - a determistic string that referses to a category such as player name or force name
-- @treturn self the element define to allow chaining
@@ -238,8 +238,8 @@ end
function Gui._sync_store_factory(callback)
--- Gui._prototype:add_sync_store(location,categorize)
--- Adds a store location for the define that will sync between games, categorize is a function that returns a string
- -- @tparam location string a unique string location, unlike add_store a uid location should not be used to avoid migration problems
- -- @tparam[opt] categorize function if present will be called to convert an element into a category string
+ -- @tparam string location string a unique location, unlike add_store a uid location should not be used to avoid migration problems
+ -- @tparam[opt] function categorize if present will be called to convert an element into a category string
-- categorize param - element LuaGuiElement - the element that needs to be converted
-- categorize return - string - a determistic string that referses to a category such as player name or force name
-- @treturn self the element define to allow chaining
@@ -272,7 +272,7 @@ function Gui._sync_store_factory(callback)
end
--- Used internally to create new element defines from a class prototype
--- @tparam prototype table the class prototype that will be used for the element define
+-- @tparam table prototype the class prototype that will be used for the element define
-- @treturn table the new element define with all functions accessed via __index metamethod
function Gui._define_factory(prototype)
local uid = Gui.uid_name()
@@ -299,7 +299,7 @@ function Gui._prototype:uid()
end
--- Sets a debug alias for the define
--- @tparam name string the debug name for the element define that can be used to get this element define
+-- @tparam string name the debug name for the element define that can be used to get this element define
-- @treturn self the element define to allow chaining
function Gui._prototype:debug_name(name)
self.debug_name = name
@@ -307,7 +307,7 @@ function Gui._prototype:debug_name(name)
end
--- Sets the caption for the element define
--- @tparam caption string the caption that will be drawn with the element
+-- @tparam string caption the caption that will be drawn with the element
-- @treturn self the element define to allow chaining
function Gui._prototype:set_caption(caption)
self.draw_data.caption = caption
@@ -315,7 +315,7 @@ function Gui._prototype:set_caption(caption)
end
--- Sets the tooltip for the element define
--- @tparam tooltip string the tooltip that will be displayed for this element when drawn
+-- @tparam string tooltip the tooltip that will be displayed for this element when drawn
-- @treturn self the element define to allow chaining
function Gui._prototype:set_tooltip(tooltip)
self.draw_data.tooltip = tooltip
@@ -323,8 +323,8 @@ function Gui._prototype:set_tooltip(tooltip)
end
--- Sets the style for the element define
--- @tparam style string the style that will be used for this element when drawn
--- @tapram[opt] callback function function is called when element is drawn to alter its style
+-- @tparam string style the style that will be used for this element when drawn
+-- @tparam[opt] callback function function is called when element is drawn to alter its style
-- @treturn self the element define to allow chaining
function Gui._prototype:set_style(style,callback)
self.draw_data.style = style
@@ -345,7 +345,7 @@ function Gui._prototype:set_embeded_flow(state)
end
--- Sets an authenticator that blocks the draw function if check fails
--- @tparam callback function the function that will be ran to test if the element should be drawn or not
+-- @tparam function callback the function that will be ran to test if the element should be drawn or not
-- callback param - player LuaPlayer - the player that the element is being drawn to
-- callback param - define_name string - the name of the define that is being drawn
-- callback return - boolean - false will stop the element from being drawn
@@ -360,7 +360,7 @@ function Gui._prototype:set_pre_authenticator(callback)
end
--- Sets an authenticator that disables the element if check fails
--- @tparam callback function the function that will be ran to test if the element should be enabled or not
+-- @tparam function callback the function that will be ran to test if the element should be enabled or not
-- callback param - player LuaPlayer - the player that the element is being drawn to
-- callback param - define_name string - the name of the define that is being drawn
-- callback return - boolean - false will disable the element
@@ -376,7 +376,7 @@ end
--- Draws the element using what is in the draw_data table, allows use of authenticator if present, registers new instances if store present
-- the data with in the draw_data is set up through the use of all the other functions
--- @tparam element LuaGuiElement the element that the define will draw a copy of its self onto
+-- @tparam LuaGuiElement element the element that the define will draw a copy of its self onto
-- @treturn LuaGuiElement the new element that was drawn so styles can be applied
function Gui._prototype:draw_to(element,...)
if element[self.name] then return end
@@ -415,7 +415,7 @@ function Gui._prototype:draw_to(element,...)
end
--- Gets the value in this elements store, category needed if categorize function used
--- @tparam category[opt] string the category to get such as player name or force name
+-- @tparam string category[opt] the category to get such as player name or force name
-- @treturn any the value that is stored for this define
function Gui._prototype:get_store(category)
if not self.store then return end
@@ -427,8 +427,8 @@ function Gui._prototype:get_store(category)
end
--- Sets the value in this elements store, category needed if categorize function used
--- @tparam category[opt] string the category to get such as player name or force name
--- @tparam value any the value to set for this define, must be valid for its type ie boolean for checkbox etc
+-- @tparam string category[opt] the category to get such as player name or force name
+-- @tparam boolean any value the value to set for this define, must be valid for its type ie for checkbox etc
-- @treturn boolean true if the value was set
function Gui._prototype:set_store(category,value)
if not self.store then return end
@@ -441,7 +441,7 @@ end
--- Gets an element define give the uid, debug name or a copy of the element define
-- @tparam name ?string|table the uid, debug name or define for the element define to get
--- @tparam[opt] internal boolean when true the error trace is one level higher (used internally)
+-- @tparam[opt] boolean internal when true the error trace is one level higher (used internally)
-- @treturn table the element define that was found or an error
function Gui.get_define(name,internal)
if type(name) == 'table' then
@@ -465,7 +465,7 @@ end
--- Gets the value that is stored for a given element define, category needed if categorize function used
-- @tparam name ?string|table the uid, debug name or define for the element define to get
--- @tparam[opt] category string the category to get the value for
+-- @tparam[opt] string category the category to get the value for
-- @treturn any the value that is stored for this define
function Gui.get_store(name,category)
local define = Gui.get_define(name,true)
@@ -474,8 +474,8 @@ end
--- Sets the value stored for a given element define, category needed if categorize function used
-- @tparam name ?string|table the uid, debug name or define for the element define to set
--- @tparam[opt] category string the category to set the value for
--- @tparam value any the value to set for the define, must be valid for its type ie boolean for a checkbox
+-- @tparam[opt] string category the category to set the value for
+-- @tparam boolean any value the value to set for the define, must be valid for its type ie for a checkbox
-- @treturn boolean true if the value was set
function Gui.set_store(name,category,value)
local define = Gui.get_define(name,true)
@@ -483,7 +483,7 @@ function Gui.set_store(name,category,value)
end
--- A categorize function to be used with add_store, each player has their own value
--- @tparam element LuaGuiElement the element that will be converted to a string
+-- @tparam LuaGuiElement element the element that will be converted to a string
-- @treturn string the player's name who owns this element
function Gui.player_store(element)
local player = Game.get_player_by_index(element.player_index)
@@ -491,7 +491,7 @@ function Gui.player_store(element)
end
--- A categorize function to be used with add_store, each force has its own value
--- @tparam element LuaGuiElement the element that will be converted to a string
+-- @tparam LuaGuiElement element the element that will be converted to a string
-- @treturn string the player's force name who owns this element
function Gui.force_store(element)
local player = Game.get_player_by_index(element.player_index)
@@ -499,7 +499,7 @@ function Gui.force_store(element)
end
--- A categorize function to be used with add_store, each surface has its own value
--- @tparam element LuaGuiElement the element that will be converted to a string
+-- @tparam LuaGuiElement element the element that will be converted to a string
-- @treturn string the player's surface name who owns this element
function Gui.surface_store(element)
local player = Game.get_player_by_index(element.player_index)
@@ -516,7 +516,7 @@ function Gui.draw(name,element,...)
end
--- Will toggle the enabled state of an element
--- @tparam element LuaGuiElement the gui element to toggle
+-- @tparam LuaGuiElement element the gui element to toggle
-- @treturn boolean the new state that the element has
function Gui.toggle_enable(element)
if not element or not element.valid then return end
@@ -529,7 +529,7 @@ function Gui.toggle_enable(element)
end
--- Will toggle the visiblity of an element
--- @tparam element LuaGuiElement the gui element to toggle
+-- @tparam LuaGuiElement element the gui element to toggle
-- @treturn boolean the new state that the element has
function Gui.toggle_visible(element)
if not element or not element.valid then return end
@@ -542,11 +542,11 @@ function Gui.toggle_visible(element)
end
--- Sets the padding for a gui element
--- @tparam element LuaGuiElement the element to set the padding for
--- @tparam[opt=0] up number the amount of padding on the top
--- @tparam[opt=0] down number the amount of padding on the bottom
--- @tparam[opt=0] left number the amount of padding on the left
--- @tparam[opt=0] right number the amount of padding on the right
+-- @tparam LuaGuiElement element the element to set the padding for
+-- @tparam[opt=0] number up the amount of padding on the top
+-- @tparam[opt=0] number down the amount of padding on the bottom
+-- @tparam[opt=0] number left the amount of padding on the left
+-- @tparam[opt=0] number right the amount of padding on the right
function Gui.set_padding(element,up,down,left,right)
local style = element.style
style.top_padding = up or 0
@@ -557,10 +557,10 @@ end
--- Sets the padding for a gui style
-- @tparam element LuaStyle the element to set the padding for
--- @tparam[opt=0] up number the amount of padding on the top
--- @tparam[opt=0] down number the amount of padding on the bottom
--- @tparam[opt=0] left number the amount of padding on the left
--- @tparam[opt=0] right number the amount of padding on the right
+-- @tparam[opt=0] number up the amount of padding on the top
+-- @tparam[opt=0] number down the amount of padding on the bottom
+-- @tparam[opt=0] number left the amount of padding on the left
+-- @tparam[opt=0] number right the amount of padding on the right
function Gui.set_padding_style(style,up,down,left,right)
style.top_padding = up or 0
style.bottom_padding = down or 0
@@ -569,8 +569,8 @@ function Gui.set_padding_style(style,up,down,left,right)
end
--- Allows the creation of a right align flow to place elements into
--- @tparam element LuaGuiElement the element to add this flow to,
--- @tparam[opt] flow_name string the name of the flow can be nil
+-- @tparam LuaGuiElement element the element to add this flow to,
+-- @tparam[opt] string flow_name the name of the flow can be nil
-- @treturn LuaGuiElement the flow that was created
function Gui.create_right_align(element,flow_name)
local right_flow =
@@ -585,7 +585,7 @@ function Gui.create_right_align(element,flow_name)
end
--- Destroies an element but tests for it being present and valid first
--- @tparam element LuaGuiElement the element to be destroied
+-- @tparam LuaGuiElement element the element to be destroied
-- @treturn boolean true if it was destoried
function Gui.destory_if_valid(element)
if element and element.valid then
diff --git a/expcore/gui/dropdown.lua b/expcore/gui/dropdown.lua
index 1737577e..8d976162 100644
--- a/expcore/gui/dropdown.lua
+++ b/expcore/gui/dropdown.lua
@@ -20,9 +20,9 @@ local Gui = require 'expcore.gui.core'
local Game = require 'utils.game'
--- Event call for on_selection_state_changed and store update
--- @tparam define table the define that this is acting on
--- @tparam element LuaGuiElement the element that triggered the event
--- @tparam value string the new option for the dropdown
+-- @tparam table define the define that this is acting on
+-- @tparam LuaGuiElement element the element that triggered the event
+-- @tparam string value the new option for the dropdown
local function event_call(define,element,value)
local player = Game.get_player_by_index(element.player_index)
@@ -35,11 +35,11 @@ local function event_call(define,element,value)
end
end
---- Store call for store update
--- @tparam define table the define that this is acting on
--- @tparam element LuaGuiElement the element that triggered the event
--- @tparam value string the new option for the dropdown
local _select_value
+--- Store call for store update
+-- @tparam table define the define that this is acting on
+-- @tparam LuaGuiElement element the element that triggered the event
+-- @tparam string value the new option for the dropdown
local function store_call(define,element,value)
_select_value(element,value)
event_call(define,element,value)
@@ -55,7 +55,7 @@ local Dropdown = {
}
--- Creates a new dropdown element define
--- @tparam[opt] name string the optional debug name that can be added
+-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new dropdown element define
function Dropdown.new_dropdown(name)
@@ -103,7 +103,7 @@ function Dropdown.new_dropdown(name)
end
--- Creates a new list box element define
--- @tparam[opt] name string the optional debug name that can be added
+-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new list box element define
function Dropdown.new_list_box(name)
local self = Dropdown.new_dropdown(name)
@@ -113,8 +113,8 @@ function Dropdown.new_list_box(name)
end
--- Adds new static options to the dropdown which will trigger the general callback
--- @tparam options ?string|table either a table of option strings or the first option string, with a table values are the options
--- @tparam[opt] ... when options is not a table you can add the options one after each other
+-- @tparam table options ?string|table either a of option strings or the first option string, with a table values are the options
+-- @tparam[opt] table ... when options is not a you can add the options one after each other
-- @tparam self the define to allow chaining
function Dropdown._prototype:new_static_options(options,...)
if type(options) == 'string' then
@@ -131,11 +131,11 @@ end
Dropdown._prototype.add_options = Dropdown._prototype.new_static_options
--- Adds a callback which should return a table of values to be added as options for the dropdown (appended after static options)
--- @tparam callback function the function that will run to get the options for the dropdown
+-- @tparam function callback the function that will run to get the options for the dropdown
-- callback param - player LuaPlayer - the player that the element is being drawn to
-- callback param - element LuaGuiElement - the element that is being drawn
-- callback return - table - the values of this table will be appended to the static options of the dropdown
--- @tparam self the define to allow chaining
+-- @treturn self the define to allow chaining
function Dropdown._prototype:new_dynamic_options(callback)
if type(callback) ~= 'function' then
return error('Dynamic options callback must be a function',2)
@@ -146,12 +146,12 @@ end
Dropdown._prototype.add_dynamic = Dropdown._prototype.new_dynamic_options
--- Adds a case specific callback which will only run when that option is selected (general case still triggered)
--- @tparam option string the name of the option to trigger the callback on; if not already added then will be added as an option
--- @tparam callback function the function that will be called when that option is selected
+-- @tparam string option the name of the option to trigger the callback on; if not already added then will be added as an option
+-- @tparam function callback the function that will be called when that option is selected
-- callback param - player LuaPlayer - the player who owns the gui element
-- callback param - element LuaGuiElement - the element which is being effected
-- callback param - value string - the new option that has been selected
--- @tparam self the define to allow chaining
+-- @treturn self the define to allow chaining
function Dropdown._prototype:add_option_callback(option,callback)
if not self.option_callbacks then self.option_callbacks = {} end
if not self.options then self.options = {} end
@@ -165,8 +165,8 @@ function Dropdown._prototype:add_option_callback(option,callback)
end
--- Selects the option from a dropdown or list box given the value rather than key
--- @tparam element LuaGuiElement the element that contains the option
--- @tparam value string the option to select from the dropdown
+-- @tparam LuaGuiElement element the element that contains the option
+-- @tparam string value the option to select from the dropdown
-- @treturn number the key where the value was
function Dropdown.select_value(element,value)
for k,item in pairs(element.items) do
@@ -179,7 +179,7 @@ end
_select_value = Dropdown.select_value
--- Returns the currently selected value rather than index
--- @tparam element LuaGuiElement the gui element that you want to get the value of
+-- @tparam LuaGuiElement element the gui element that you want to get the value of
-- @treturn string the value that is currently selected
function Dropdown.get_selected_value(element)
local index = element.selected_index
diff --git a/expcore/gui/elem-button.lua b/expcore/gui/elem-button.lua
index e976d3d5..b20cae59 100644
--- a/expcore/gui/elem-button.lua
+++ b/expcore/gui/elem-button.lua
@@ -15,9 +15,9 @@ local Gui = require 'expcore.gui.core'
local Game = require 'utils.game'
--- Event call for on_elem_changed and store update
--- @tparam define table the define that this is acting on
--- @tparam element LuaGuiElement the element that triggered the event
--- @tparam value string the new value for the elem button
+-- @tparam table define the define that this is acting on
+-- @tparam LuaGuiElement element the element that triggered the event
+-- @tparam string value the new value for the elem button
local function event_call(define,element,value)
local player = Game.get_player_by_index(element.player_index)
@@ -28,12 +28,12 @@ local function event_call(define,element,value)
end
--- Store call for store update
--- @tparam define table the define that this is acting on
--- @tparam element LuaGuiElement the element that triggered the event
--- @tparam value string the new value for the elem button
-local function store_call(self,element,value)
+-- @tparam table define the define that this is acting on
+-- @tparam LuaGuiElement element the element that triggered the event
+-- @tparam string value the new value for the elem button
+local function store_call(define,element,value)
element.elem_value = value
- event_call(self,element,value)
+ event_call(define,element,value)
end
local ElemButton = {
@@ -46,7 +46,7 @@ local ElemButton = {
}
--- Creates a new elem button element define
--- @tparam[opt] name string the optional debug name that can be added
+-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new elem button element define
function ElemButton.new_elem_button(name)
@@ -90,7 +90,7 @@ function ElemButton.new_elem_button(name)
end
--- Sets the type of the elem button, the type is required so this must be called at least once
--- @tparam type string the type that this elem button is see factorio api
+-- @tparam string type the type that this elem button is see factorio api
-- @treturn the element define to allow for chaining
function ElemButton._prototype:set_type(type)
self.draw_data.elem_type = type
@@ -98,7 +98,7 @@ function ElemButton._prototype:set_type(type)
end
--- Sets the default value for the elem button, this may be a function or a string
--- @tparam value ?string|function a string will be a static default and a function will be called when drawn to get the default
+-- @tparam ?string|function value string a will be a static default and a function will be called when drawn to get the default
-- @treturn the element define to allow for chaining
function ElemButton._prototype:set_default(value)
self.default = value
diff --git a/expcore/gui/instances.lua b/expcore/gui/instances.lua
index 7e0fde9f..1bb502b9 100644
--- a/expcore/gui/instances.lua
+++ b/expcore/gui/instances.lua
@@ -86,22 +86,22 @@ Global.register(Instances.data,function(tbl)
end)
--- Returns if a instnace group has a categorise function; must be registerd
--- @tparam name string the name of the instance group
+-- @tparam string name the name of the instance group
-- @treturn boolean true if there is a categorise function
function Instances.has_categories(name)
return type(Instances.categorise[name]) == 'function'
end
--- Returns if the given name is a registered instance group
--- @tparam name string the name of the instance group you are testing
+-- @tparam string name the name of the instance group you are testing
-- @treturn boolean true if the name is registered
function Instances.is_registered(name)
return Instances.categorise[name] ~= nil
end
--- Registers the name of an instance group to allow for storing element instances
--- @tparam name string the name of the instance group; must to unique
--- @tparam[opt] categorise function function used to turn the element into a string
+-- @tparam string name the name of the instance group; must to unique
+-- @tparam[opt] function categorise function used to turn the element into a string
-- categorise param - element LuaGuiElement - the gui element to be turned into a string
-- categorise return - string - the category that the element will be added to like the player's name or force's name
-- @treturn string the name that was added so it can be used as a varible
@@ -123,8 +123,8 @@ function Instances.register(name,categorise)
end
--- Adds an element to the instance group under the correct category; must be registered
--- @tparam name string the name of the instance group to add the element to
--- @tparam element LuaGuiElement the element to add the the instance group
+-- @tparam string name the name of the instance group to add the element to
+-- @tparam LuaGuiElement element the element to add the the instance group
function Instances.add_element(name,element)
if not Instances.categorise[name] then
return error('Inavlid name for instance group: '..name,2)
@@ -140,8 +140,8 @@ function Instances.add_element(name,element)
end
--- Gets all element instances without first removing any invalid ones; used internally and must be registered
--- @tparam name string the name of the instance group to get the instances of
--- @tparam[opt] category string the category to get the instance from, not needed when no categorise function
+-- @tparam string name the name of the instance group to get the instances of
+-- @tparam[opt] string category the category to get the instance from, not needed when no categorise function
-- @treturn table the table of element instances of which some may be invalid
function Instances.get_elements_raw(name,category)
if not Instances.categorise[name] then
@@ -156,8 +156,8 @@ function Instances.get_elements_raw(name,category)
end
--- Gets all valid element instances and has the option of running a callback on those that are valid
--- @tparam name string the name of the instance group to get the instances of
--- @tparam[opt] category string the category to get the instances of, not needed when no categorise function
+-- @tparam string name the name of the instance group to get the instances of
+-- @tparam[opt] string category the category to get the instances of, not needed when no categorise function
-- @tparan[opt] callback function when given the callback will be ran on all valid elements
-- callback param - element LuaGuiElement - the current valid element
-- @treturn table the table of element instances with all invalid ones removed
@@ -185,9 +185,9 @@ Instances.get_elements = Instances.get_valid_elements
Instances.apply_to_elements = Instances.get_valid_elements
--- A version of add_element that does not require the group to be registered
--- @tparam name string the name of the instance group to add the element to
+-- @tparam string name the name of the instance group to add the element to
-- @tparam category ?string|nil the category to add the element to, can be nil but must still be given
--- @tparam element LuaGuiElement the element to add to the instance group
+-- @tparam LuaGuiElement element the element to add to the instance group
function Instances.unregistered_add_element(name,category,element)
if not Instances.data[name] then Instances.data[name] = {} end
if category then
@@ -199,9 +199,9 @@ function Instances.unregistered_add_element(name,category,element)
end
--- A version of get_elements that does not require the group to be registered
--- @tparam name string the name of the instance group to get the instances of
+-- @tparam string name the name of the instance group to get the instances of
-- @tparam category ?string|nil the category to get the instances of, can be nil but must still be given
--- @tparam[opt] callback function when given will be called on all valid instances
+-- @tparam[opt] function callback when given will be called on all valid instances
-- callback param - element LuaGuiElement - the current valid element
-- @treturn table the table of element instances with all invalid ones removed
function Instances.unregistered_get_elements(name,category,callback)
diff --git a/expcore/gui/left.lua b/expcore/gui/left.lua
index a2dcf1d1..77a03db0 100644
--- a/expcore/gui/left.lua
+++ b/expcore/gui/left.lua
@@ -66,7 +66,7 @@ setmetatable(LeftFrames._prototype, {
})
--- Gets the left frame flow for a player
--- @tparam player LuaPlayer the player to get the flow of
+-- @tparam LuaPlayer player the player to get the flow of
-- @treturn LuaGuiElement the left frame flow for the player
function LeftFrames.get_flow(player)
player = Game.get_player_from_any(player)
@@ -74,8 +74,8 @@ function LeftFrames.get_flow(player)
end
--- Gets one frame from the left flow by its name
--- @tparam name string the name of the gui frame to get
--- @tparam player LuaPlayer the player to get the frame of
+-- @tparam string name the name of the gui frame to get
+-- @tparam LuaPlayer player the player to get the frame of
-- @treturn LuaGuiElement the frame in the left frame flow with that name
function LeftFrames.get_frame(name,player)
local define = LeftFrames.frames[name]
@@ -86,7 +86,7 @@ function LeftFrames.get_frame(name,player)
end
--- Gets all open frames for a player, if non are open it will remove the close all button
--- @tparam player LuaPlayer the player to get the flow of
+-- @tparam LuaPlayer player the player to get the flow of
-- @treturn table contains all the open (and registered) frames for the player
function LeftFrames.get_open(player)
local open = {}
@@ -104,9 +104,9 @@ function LeftFrames.get_open(player)
end
--- Toggles the visiblty of a left frame, or sets its visiblty state
--- @tparam name string the name of the gui frame to toggle
--- @tparam player LuaPlayer the player to get the frame of
--- @tparam[opt] state boolean when given will be the state that the visiblty is set to
+-- @tparam string name the name of the gui frame to toggle
+-- @tparam LuaPlayer player the player to get the frame of
+-- @tparam[opt] boolean state when given will be the state that the visiblty is set to
-- @treturn boolean the new state of the visiblity
function LeftFrames.toggle_frame(name,player,state)
local define = LeftFrames.frames[name]
@@ -127,7 +127,7 @@ function LeftFrames.toggle_frame(name,player,state)
end
--- Creates a new left frame define
--- @tparam permision_name string the name that can be used with the permision system
+-- @tparam string permision_name the name that can be used with the permision system
-- @treturn table the new left frame define
function LeftFrames.new_frame(permision_name)
@@ -147,7 +147,7 @@ function LeftFrames.new_frame(permision_name)
end
--- Sets if the frame is visible when a player joins, can also be a function to return a boolean
--- @tparam[opt=true] state ?boolean|function the default state of the visiblty, can be a function
+-- @tparam[opt=true] ?boolean|function state the default state of the visiblty, can be a function
-- state param - player LuaPlayer - the player that has joined the game
-- state param - define_name string - the define name for the frame
-- state return - boolean - false will hide the frame
@@ -163,14 +163,14 @@ function LeftFrames._prototype:set_open_by_default(state)
end
--- Sets the direction of the frame, either vertical or horizontal
--- @tparam direction string the direction to have the elements be added to thef frame
+-- @tparam string direction the direction to have the elements be added to thef frame
function LeftFrames._prototype:set_direction(direction)
self.direction = direction
return self
end
--- Gets the frame for this define from the left frame flow
--- @tparam player LuaPlayer the player to get the frame of
+-- @tparam LuaPlayer player the player to get the frame of
-- @treturn LuaGuiElement the frame in the left frame flow for this define
function LeftFrames._prototype:get_frame(player)
local flow = LeftFrames.get_flow(player)
@@ -180,7 +180,7 @@ function LeftFrames._prototype:get_frame(player)
end
--- Returns if the player currently has this define visible
--- @tparam player LuaPlayer the player to get the frame of
+-- @tparam LuaPlayer player the player to get the frame of
-- @treturn boolean true if it is open/visible
function LeftFrames._prototype:is_open(player)
local frame = self:get_frame(player)
@@ -188,7 +188,7 @@ function LeftFrames._prototype:is_open(player)
end
--- Toggles the visiblty of the left frame
--- @tparam player LuaPlayer the player to toggle the frame of
+-- @tparam LuaPlayer player the player to toggle the frame of
-- @treturn boolean the new state of the visiblity
function LeftFrames._prototype:toggle(player)
local frame = self:get_frame(player)
@@ -198,7 +198,7 @@ function LeftFrames._prototype:toggle(player)
end
--- Updates the contents of the left frame, first tries update callback, oter wise will clear and redraw
--- @tparam player LuaPlayer the player to update the frame of
+-- @tparam LuaPlayer player the player to update the frame of
function LeftFrames._prototype:update(player)
local frame = self:get_frame(player)
if self.events.on_update then
@@ -210,7 +210,7 @@ function LeftFrames._prototype:update(player)
end
--- Updates the frame for all players, see update
--- @tparam[opt=false] update_offline boolean when true will update the frame for offline players
+-- @tparam[opt=false] boolean update_offline when true will update the frame for offline players
function LeftFrames._prototype:update_all(update_offline)
local players = update_offline == true and game.players or game.connected_players
for _,player in pairs(players) do
@@ -219,7 +219,7 @@ function LeftFrames._prototype:update_all(update_offline)
end
--- Redraws the frame by calling on_draw, will always clear the frame
--- @tparam player LuaPlayer the player to update the frame of
+-- @tparam LuaPlayer player the player to update the frame of
function LeftFrames._prototype:redraw(player)
local frame = self:get_frame(player)
frame.clear()
@@ -229,7 +229,7 @@ function LeftFrames._prototype:redraw(player)
end
--- Redraws the frame for all players, see redraw
--- @tparam[opt=false] update_offline boolean when true will update the frame for offline players
+-- @tparam[opt=false] boolean update_offline when true will update the frame for offline players
function LeftFrames._prototype:redraw_all(update_offline)
local players = update_offline == true and game.players or game.connected_players
for _,player in pairs(players) do
@@ -238,7 +238,7 @@ function LeftFrames._prototype:redraw_all(update_offline)
end
--- Creates an event handler that will trigger one of its functions, use with Event.add
--- @tparam[opt=update] action string the action to take on this event
+-- @tparam[opt=update] string action the action to take on this event
function LeftFrames._prototype:event_handler(action)
action = action or 'update'
return function(event)
diff --git a/expcore/gui/popups.lua b/expcore/gui/popups.lua
index fa0c0668..b324f0c0 100644
--- a/expcore/gui/popups.lua
+++ b/expcore/gui/popups.lua
@@ -34,22 +34,22 @@ Global.register(PopupFrames.paused_popups,function(tbl)
end)
--- Sets the state of the element in the pasued list, nil or true
--- @tparam element LuaGuiElement the element to set the state of
--- @tparam[opt] state boolean the state to set it to, true will pause the the progress bar
+-- @tparam LuaGuiElement element the element to set the state of
+-- @tparam[opt] boolean state the state to set it to, true will pause the the progress bar
local function set_pasued_state(element,state)
local name = element.player_index..':'..element.index
PopupFrames.paused_popups[name] = state
end
--- Gets the state of the element in the pasued list, nil or true
--- @tparam element LuaGuiElement the element to get the state of
+-- @tparam LuaGuiElement element the element to get the state of
local function get_pasued_state(element)
local name = element.player_index..':'..element.index
return PopupFrames.paused_popups[name]
end
--- Gets the left flow that contains the popup frames
--- @tparam player LuaPlayer the player to get the flow for
+-- @tparam LuaPlayer player the player to get the flow for
-- @treturn LuaGuiElement the left flow that contains the popup frames
function PopupFrames.get_flow(player)
player = Game.get_player_from_any(player)
@@ -58,10 +58,10 @@ function PopupFrames.get_flow(player)
end
--- Opens a popup for the player, can give the amount of time it is open as well as params for the draw function
--- @tparam define_name string the name of the define that you want to open for the player
--- @tparam player LuaPlayer the player to open the popup for
--- @tparam[opt] open_time number the minimum number of ticks you want the popup open for, 0 means no limit, nil will take default
--- @tparam ... any the other params that you want to pass to your on_draw event
+-- @tparam string define_name the name of the define that you want to open for the player
+-- @tparam LuaPlayer player the player to open the popup for
+-- @tparam[opt] number open_time the minimum number of ticks you want the popup open for, 0 means no limit, nil will take default
+-- @tparam any ... the other params that you want to pass to your on_draw event
-- @treturn LuaGuiElement the frame that was drawn, the inner gui flow which contains the content
function PopupFrames.open(define_name,player,open_time,...)
local define = Gui.get_define(define_name,true)
@@ -70,7 +70,7 @@ function PopupFrames.open(define_name,player,open_time,...)
end
--- Closes the popup, is called by progress bar and close button
--- @tparam element LuaGuiElement either the progress bar or the close button
+-- @tparam LuaGuiElement element either the progress bar or the close button
local function close_popup(element)
local frame = element.parent.parent.parent
if not frame or not frame.valid then return end
@@ -117,7 +117,7 @@ Gui.on_click(PopupFrames.close_frame_name,function(event)
end)
--- Creates a new popup frame define
--- @tparam[opt] name string the optional debug name that can be added
+-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new popup frame define
function PopupFrames.new_popup(name)
local self = Gui._define_factory(PopupFrames._prototype)
@@ -182,7 +182,7 @@ function PopupFrames.new_popup(name)
end
--- Sets the default open time for the popup, will be used if non is provided with open
--- @tparam amount number the number of ticks, by default, the popup will be open for
+-- @tparam number amount the number of ticks, by default, the popup will be open for
-- @treturn table the define to allow for chaining
function PopupFrames._prototype:set_default_open_time(amount)
self.default_open_time = amount
@@ -190,9 +190,9 @@ function PopupFrames._prototype:set_default_open_time(amount)
end
--- Opens this define for a player, can be given open time and any other params for the draw function
--- @tparam player LuaPlayer the player to open the popup for
--- @tparam[opt] open_time number the minimum number of ticks you want the popup open for, 0 means no limit, nil will take default
--- @tparam ... any the other params that you want to pass to your on_draw event
+-- @tparam LuaPlayer player the player to open the popup for
+-- @tparam[opt] number open_time the minimum number of ticks you want the popup open for, 0 means no limit, nil will take default
+-- @tparam any ... the other params that you want to pass to your on_draw event
-- @treturn LuaGuiElement the frame that was drawn, the inner gui flow which contains the content
function PopupFrames._prototype:open(player,open_time,...)
open_time = open_time or self.default_open_time or 0
diff --git a/expcore/gui/progress-bar.lua b/expcore/gui/progress-bar.lua
index 2b4ffcbc..78bb7f78 100644
--- a/expcore/gui/progress-bar.lua
+++ b/expcore/gui/progress-bar.lua
@@ -25,8 +25,8 @@ local Global = require 'utils.global'
local Game = require 'utils.game'
--- Event call for when the value is outside the range 0-1
--- @tparam define table the define that this is acting on
--- @tparam element LuaGuiElement the element that triggered the event
+-- @tparam table define the define that this is acting on
+-- @tparam LuaGuiElement element the element that triggered the event
local function event_call(define,element)
local player = Game.get_player_by_index(element.player_index)
@@ -39,8 +39,9 @@ local function event_call(define,element)
end
--- Store call for store update
--- @tparam define table the define that this is acting on
--- @tparam element LuaGuiElement the element that triggered the event
+-- @tparam table define the define that this is acting on
+-- @tparam LuaGuiElement element the element that triggered the event
+-- @tparam number value the new value for the progress bar
local function store_call(define,element,value)
if value then
element.value = value
@@ -71,7 +72,7 @@ Global.register({
end)
--- Gets the define data, cant use Gui.get_define as it would error
--- @tparam define ?table|string the define to get
+-- @tparam ?table|string define the define to get
-- @treturn table the define or nil
local function get_define(define)
if type(define) == 'table' then
@@ -84,7 +85,7 @@ local function get_define(define)
end
--- Gets the element data, used when there is no define
--- @tparam element LuaGuiElement
+-- @tparam LuaGuiElement element the element to get the data of
-- @treturn table the element data simialr to define
local function get_element(element)
if not element.valid then return end
@@ -96,8 +97,8 @@ local function get_element(element)
end
--- Sets the maximum value that represents the end value of the progress bar
--- @tparam element ?LuaGuiElement|string either a gui element or a registered define
--- @tparam amount number the amount to have set as the maximum
+-- @tparam ?LuaGuiElement|string element either a gui element or a registered define
+-- @tparam number amount the amount to have set as the maximum
function ProgressBar.set_maximum(element,amount)
amount = amount > 0 and amount or error('amount must be greater than 0')
@@ -124,8 +125,8 @@ function ProgressBar.set_maximum(element,amount)
end
--- Increases the value of the progressbar, if a define is given all of its instances are incremented
--- @tapram element ?LuaGuiElement|string either a gui element or a registered define
--- @tparam[opt=1] amount number the amount to increase the progressbar by
+-- @tparam ?LuaGuiElement|string element either a gui element or a registered define
+-- @tparam[opt=1] number amount the amount to increase the progressbar by
function ProgressBar.increment(element,amount)
amount = type(amount) == 'number' and amount or 1
@@ -151,8 +152,8 @@ function ProgressBar.increment(element,amount)
end
--- Decreases the value of the progressbar, if a define is given all of its instances are decresed
--- @tapram element ?LuaGuiElement|string either a gui element or a registered define
--- @tparam[opt=1] amount number the amount to decrease the progressbar by
+-- @tparam ?LuaGuiElement|string element either a gui element or a registered define
+-- @tparam[opt=1] number amount the amount to decrease the progressbar by
function ProgressBar.decrement(element,amount)
amount = type(amount) == 'number' and amount or 1
@@ -178,7 +179,7 @@ function ProgressBar.decrement(element,amount)
end
--- Creates a new progressbar element define
--- @tparam[opt] name string the optional debug name that can be added
+-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new progressbar elemente define
function ProgressBar.new_progressbar(name)
local self = Gui._define_factory(ProgressBar._prototype)
@@ -220,7 +221,7 @@ function ProgressBar.new_progressbar(name)
end
--- Sets the maximum value that represents the end value of the progress bar
--- @tparam amount number the amount to have set as the maximum
+-- @tparam number amount the amount to have set as the maximum
-- @treturn table the define to allow chaining
function ProgressBar._prototype:set_default_maximum(amount)
amount = amount > 0 and amount or error('amount must be greater than 0')
@@ -229,7 +230,7 @@ function ProgressBar._prototype:set_default_maximum(amount)
end
--- Will set the progress bar to start at 1 and trigger when it hits 0
--- @tparam[opt=true] state boolean when true the bar will start filled, to be used with decrease
+-- @tparam[opt=true] boolean state when true the bar will start filled, to be used with decrease
-- @treturn table the define to allow chaining
function ProgressBar._prototype:use_count_down(state)
if state == false then
@@ -241,9 +242,10 @@ function ProgressBar._prototype:use_count_down(state)
end
--- Main logic for changing the value of a progress bar, this only applies when its a registered define
--- @tparam self table the define that is being changed
--- @tparam amount number the amount which it is being changed by, may be negative
--- @tparam[opt] category string the category to use with store
+-- @tparam table self the define that is being changed
+-- @tparam number amount the amount which it is being changed by, may be negative
+-- @tparam[opt] string category the category to use with store
+-- @tparam[opt] function filter when given the filter must return true for the value of the element to be changed
local function change_value_prototype(self,amount,category,filter)
local function reset_store()
@@ -298,32 +300,32 @@ local function change_value_prototype(self,amount,category,filter)
end
--- Increases the value of the progressbar
--- @tparam[opt=1] amount number the amount to increase the progressbar by
--- @tparam[opt] category string the category that is used with a store
+-- @tparam[opt=1] number amount the amount to increase the progressbar by
+-- @tparam[opt] string category the category that is used with a store
function ProgressBar._prototype:increment(amount,category)
amount = type(amount) == 'number' and amount or 1
change_value_prototype(self,amount,category)
end
--- Increases the value of the progressbar, if the filter condition is met, does not work with store
--- @tparam[opt=1] amount number the amount to increase the progressbar by
--- @tparam[opt] category string the category that is used with a store
+-- @tparam[opt=1] number amount the amount to increase the progressbar by
+-- @tparam function filter the filter to be used
function ProgressBar._prototype:increment_filtered(amount,filter)
amount = type(amount) == 'number' and amount or 1
change_value_prototype(self,amount,nil,filter)
end
--- Decreases the value of the progressbar
--- @tparam[opt=1] amount number the amount to decrease the progressbar by
--- @tparam[opt] category string the category that is used with a store
+-- @tparam[opt=1] number amount the amount to decrease the progressbar by
+-- @tparam[opt] string category the category that is used with a store
function ProgressBar._prototype:decrement(amount,category)
amount = type(amount) == 'number' and amount or 1
change_value_prototype(self,-amount,category)
end
--- Decreases the value of the progressbar, if the filter condition is met, does not work with store
--- @tparam[opt=1] amount number the amount to decrease the progressbar by
--- @tparam[opt] category string the category that is used with a store
+-- @tparam[opt=1] number amount the amount to decrease the progressbar by
+-- @tparam function filter the filter to be used
function ProgressBar._prototype:decrement_filtered(amount,filter)
amount = type(amount) == 'number' and amount or 1
change_value_prototype(self,-amount,nil,filter)
@@ -331,8 +333,8 @@ end
--- Adds an element into the list of instances that will are waiting to complete, does not work with store
-- note use store if you want persistent data, this only stores the elements not the values which they have
--- @tparam element LuaGuiElement the element that you want to add into the waiting to complete list
--- @tparam[opt] maximum number the maximum for this element if not given the default for this define is used
+-- @tparam LuaGuiElement element the element that you want to add into the waiting to complete list
+-- @tparam[opt] number maximum the maximum for this element if not given the default for this define is used
function ProgressBar._prototype:add_element(element,maximum)
if self.store then return end
if not ProgressBar.independent[self.name] then
@@ -345,7 +347,7 @@ function ProgressBar._prototype:add_element(element,maximum)
end
--- Resets an element, or its store, to be back at the start, either 1 or 0
--- @tparam element LuaGuiElement the element that you want to reset the progress of
+-- @tparam LuaGuiElement element the element that you want to reset the progress of
function ProgressBar._prototype:reset_element(element)
if not element or not element.valid then return end
local value = self.count_down and 1 or 0
@@ -358,7 +360,7 @@ function ProgressBar._prototype:reset_element(element)
end
--- Event handler factory that counts up by 1 every time the event triggeres, can filter which elements are incremented
--- @tparam[opt] filter function when given will use filtered incerement
+-- @tparam[opt] function filter when given will use filtered incerement
-- @treturn function the event handler
function ProgressBar._prototype:event_counter(filter)
if type(filter) == 'function' then
@@ -373,7 +375,7 @@ function ProgressBar._prototype:event_counter(filter)
end
--- Event handler factory that counts down by 1 every time the event triggeres, can filter which elements are decremented
--- @tparam[opt] filter function when given will use filtered decerement
+-- @tparam[opt] function filter when given will use filtered decerement
-- @treturn function the event handler
function ProgressBar._prototype:event_countdown(filter)
if type(filter) == 'function' then
diff --git a/expcore/gui/slider.lua b/expcore/gui/slider.lua
index 7c0df3ee..f8bdef5e 100644
--- a/expcore/gui/slider.lua
+++ b/expcore/gui/slider.lua
@@ -18,9 +18,9 @@ local Instances = require 'expcore.gui.instances'
local Game = require 'utils.game'
--- Event call for on_value_changed and store update
--- @tparam define table the define that this is acting on
--- @tparam element LuaGuiElement the element that triggered the event
--- @tparam value number the new value for the slider
+-- @tparam table define the define that this is acting on
+-- @tparam LuaGuiElement element the element that triggered the event
+-- @tparam number value the new value for the slider
local function event_call(define,element,value)
local player = Game.get_player_by_index(element.player_index)
@@ -43,9 +43,9 @@ local function event_call(define,element,value)
end
--- Store call for store update
--- @tparam define table the define that this is acting on
--- @tparam element LuaGuiElement the element that triggered the event
--- @tparam value number the new value for the slider
+-- @tparam table define the define that this is acting on
+-- @tparam LuaGuiElement element the element that triggered the event
+-- @tparam number value the new value for the slider
local function store_call(define,element,value)
element.slider_value = value
event_call(define,element,value)
@@ -61,7 +61,7 @@ local Slider = {
}
--- Creates a new slider element define
--- @tparam[opt] name string the optional debug name that can be added
+-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new slider element define
function Slider.new_slider(name)
@@ -116,7 +116,7 @@ function Slider.new_slider(name)
end
--- Adds notches to the slider
--- @tparam[opt] state boolean when true will draw notches onto the slider
+-- @tparam[opt] boolean state when true will draw notches onto the slider
function Slider._prototype:use_notches(state)
if state == false then
self.draw_data.style = nil
@@ -127,8 +127,8 @@ function Slider._prototype:use_notches(state)
end
--- Sets the range of a slider, if not used will use default values for a slider
--- @tparam[opt] min number the minimum value that the slider can take
--- @tparam[opt] max number the maximum value that the slider can take
+-- @tparam[opt] number min the minimum value that the slider can take
+-- @tparam[opt] number max the maximum value that the slider can take
-- @treturn self the define to allow chaining
function Slider._prototype:set_range(min,max)
self.min = min
@@ -146,7 +146,7 @@ function Slider._prototype:set_range(min,max)
end
--- Draws a new label and links its value to the value of this slider, if no store then it will only show one value per player
--- @tparam element LuaGuiElement the parent element that the lable will be drawn to
+-- @tparam LuaGuiElement element the parent element that the lable will be drawn to
-- @treturn LuaGuiElement the new label element so that styles can be applied
function Slider._prototype:draw_label(element)
local name = self.name..'-label'
@@ -173,7 +173,7 @@ function Slider._prototype:draw_label(element)
end
--- Enables auto draw of the label, the label will share the same parent element as the slider
--- @tparam[opt=true] state boolean when false will disable the auto draw of the label
+-- @tparam[opt=true] boolean state when false will disable the auto draw of the label
-- @treturn self the define to allow chaining
function Slider._prototype:enable_auto_draw_label(state)
if state == false then
diff --git a/expcore/gui/text.lua b/expcore/gui/text.lua
index 3a06e439..4fb5b43f 100644
--- a/expcore/gui/text.lua
+++ b/expcore/gui/text.lua
@@ -18,9 +18,9 @@ local Gui = require 'expcore.gui.core'
local Game = require 'utils.game'
--- Event call for on_text_changed and store update
--- @tparam define table the define that this is acting on
--- @tparam element LuaGuiElement the element that triggered the event
--- @tparam value string the new text for the text field
+-- @tparam table define the define that this is acting on
+-- @tparam LuaGuiElement element the element that triggered the event
+-- @tparam string value the new text for the text field
local function event_call(define,element,value)
local player = Game.get_player_by_index(element.player_index)
@@ -31,12 +31,12 @@ local function event_call(define,element,value)
end
--- Store call for store update
--- @tparam define table the define that this is acting on
--- @tparam element LuaGuiElement the element that triggered the event
--- @tparam value string the new text for the text field
-local function store_call(self,element,value)
+-- @tparam table define the define that this is acting on
+-- @tparam LuaGuiElement element the element that triggered the event
+-- @tparam string value the new text for the text field
+local function store_call(define,element,value)
element.text = value
- event_call(self,element,value)
+ event_call(define,element,value)
end
local Text = {
@@ -55,7 +55,7 @@ local Text = {
}
--- Creates a new text field element define
--- @tparam[opt] name string the optional debug name that can be added
+-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new text field element define
function Text.new_text_field(name)
@@ -105,7 +105,7 @@ function Text.new_text_field(name)
end
--- Creates a new text box element define
--- @tparam[opt] name string the optional debug name that can be added
+-- @tparam[opt] string name the optional debug name that can be added
-- @treturn table the new text box element define
function Text.new_text_box(name)
local self = Text.new_text_field(name)
@@ -118,7 +118,7 @@ function Text.new_text_box(name)
end
--- Sets the text box to be selectable
--- @tparam[opt=true] state boolean when false will set the state to false
+-- @tparam[opt=true] boolean state when false will set the state to false
-- @treturn self table the define to allow for chaining
function Text._prototype_box:set_selectable(state)
if state == false then
@@ -130,7 +130,7 @@ function Text._prototype_box:set_selectable(state)
end
--- Sets the text box to have word wrap
--- @tparam[opt=true] state boolean when false will set the state to false
+-- @tparam[opt=true] boolean state when false will set the state to false
-- @treturn self table the define to allow for chaining
function Text._prototype_box:set_word_wrap(state)
if state == false then
@@ -142,7 +142,7 @@ function Text._prototype_box:set_word_wrap(state)
end
--- Sets the text box to be read only
--- @tparam[opt=true] state boolean when false will set the state to false
+-- @tparam[opt=true] boolean state when false will set the state to false
-- @treturn self table the define to allow for chaining
function Text._prototype_box:set_read_only(state)
if state == false then
diff --git a/expcore/gui/toolbar.lua b/expcore/gui/toolbar.lua
index 4c384dcc..9c83541d 100644
--- a/expcore/gui/toolbar.lua
+++ b/expcore/gui/toolbar.lua
@@ -36,7 +36,7 @@ function Toolbar.permission_alias(define_name,permisison_name)
end
--- Adds a new button to the toolbar
--- @tparam[opt] name string when given allows an alias to the button for the permission system
+-- @tparam[opt] string name when given allows an alias to the button for the permission system
-- @treturn table the button define
function Toolbar.new_button(name)
local button =
@@ -51,7 +51,7 @@ function Toolbar.new_button(name)
end
--- Adds an existing buttton to the toolbar
--- @tparam button table the button define for the button to be added
+-- @tparam table button the button define for the button to be added
function Toolbar.add_button(button)
table.insert(Toolbar.buttons,button)
Gui.allow_player_to_toggle_top_element_visibility(button.name)
@@ -66,7 +66,7 @@ function Toolbar.add_button(button)
end
--- Updates the player's toolbar with an new buttons or expected change in auth return
--- @tparam player LuaPlayer the player to update the toolbar for
+-- @tparam LuaPlayer player the player to update the toolbar for
function Toolbar.update(player)
local top = Gui.get_top_element_flow(player)
if not top then return end
diff --git a/expcore/permission_groups.lua b/expcore/permission_groups.lua
index a237bf80..a87f3b18 100644
--- a/expcore/permission_groups.lua
+++ b/expcore/permission_groups.lua
@@ -59,7 +59,7 @@ local Permissions_Groups = {
}
--- Defines a new permission group that can have it actions set in the config
--- @tparam name string the name of the new group
+-- @tparam string name the name of the new group
-- @treturn Permissions_Groups._prototype the new group made with function to allow and disallow actions
function Permissions_Groups.new_group(name)
local group = setmetatable({
@@ -74,14 +74,14 @@ function Permissions_Groups.new_group(name)
end
--- Returns the group with the given name, case sensitive
--- @tparam name string the name of the group to get
+-- @tparam string name the name of the group to get
-- @treturn ?Permissions_Groups._prototype|nil the group with that name or nil if non found
function Permissions_Groups.get_group_by_name(name)
return Permissions_Groups.groups[name]
end
--- Returns the group that a player is in
--- @tparam LuaPlayer the player to get the group of can be LuaPlayer name index etc
+-- @tparam LuaPlayer player the player to get the group of can be name index etc
-- @treturn ?Permissions_Groups._prototype|nil the group with that player or nil if non found
function Permissions_Groups.get_group_from_player(player)
player = Game.get_player_from_any(player)
@@ -100,7 +100,7 @@ function Permissions_Groups.reload_permissions()
end
--- Removes all permissions from every permission group except for "Default" and any passed as exempt
--- @tparam string|Array any groups that you want to be except, "Default" is always exempt
+-- @tparam ?string|Array exempt groups that you want to be except, "Default" is always exempt
-- @treturn number the number of groups that had they permissions removed
function Permissions_Groups.lockdown_permissions(exempt)
local count = 0
@@ -126,8 +126,8 @@ function Permissions_Groups.lockdown_permissions(exempt)
end
--- Sets a player's group to the one given, a player can only have one group at a time
--- @tparam LuaPlayer the player to effect can be LuaPlayer name index etc
--- @tparam string the name of the group to give to the player
+-- @tparam LuaPlayer player the player to effect can be name index etc
+-- @tparam string group the name of the group to give to the player
-- @treturn boolean true if the player was added successfully, false other wise
function Permissions_Groups.set_player_group(player,group)
player = Game.get_player_from_any(player)
@@ -138,8 +138,8 @@ function Permissions_Groups.set_player_group(player,group)
end
--- Sets the allow state of an action for this group, used internally but is safe to use else where
--- @tparam action ?string|defines.input_action the action that you want to set the state of
--- @tparam state boolean the state that you want to set it to, true = allow, false = disallow
+-- @tparam ?string|defines.input_action action the action that you want to set the state of
+-- @tparam boolean state the state that you want to set it to, true = allow, false = disallow
-- @treturn Permissions_Groups._prototype returns self so function can be chained
function Permissions_Groups._prototype:set_action(action,state)
if type(action) == 'string' then
@@ -150,7 +150,7 @@ function Permissions_Groups._prototype:set_action(action,state)
end
--- Sets an action or actions to be allowed for this group even with disallow_all triggered, Do not use in runtime
--- @tparam string|Array the action or actions that you want to allow for this group
+-- @tparam string|Array actions the action or actions that you want to allow for this group
-- @treturn Permissions_Groups._prototype returns self so function can be chained
function Permissions_Groups._prototype:allow(actions)
if type(actions) ~= 'table' then
@@ -163,7 +163,7 @@ function Permissions_Groups._prototype:allow(actions)
end
--- Sets an action or actions to be disallowed for this group even with allow_all triggered, Do not use in runtime
--- @tparam string|Array the action or actions that you want to disallow for this group
+-- @tparam string|Array actions the action or actions that you want to disallow for this group
-- @treturn Permissions_Groups._prototype returns self so function can be chained
function Permissions_Groups._prototype:disallow(actions)
if type(actions) ~= 'table' then
@@ -190,7 +190,7 @@ function Permissions_Groups._prototype:disallow_all()
end
--- Returns if an input action is allowed for this group
--- @tparam action ?string|defines.input_action the action that you want to test for
+-- @tparam ?string|defines.input_action action the action that you want to test for
-- @treturn boolean true if the group is allowed the action, false other wise
function Permissions_Groups._prototype:is_allowed(action)
if type(action) == 'string' then
@@ -223,7 +223,7 @@ function Permissions_Groups._prototype:create()
end
--- Adds a player to this group
--- @tparam player LuaPlayer the player you want to add to this group can be LuaPlayer name or index etc
+-- @tparam LuaPlayer player LuaPlayer the player you want to add to this group can be name or index etc
-- @treturn boolean true if the player was added successfully, false other wise
function Permissions_Groups._prototype:add_player(player)
player = Game.get_player_from_any(player)
@@ -234,7 +234,7 @@ function Permissions_Groups._prototype:add_player(player)
end
--- Removes a player from this group
--- @tparam player LuaPlayer the player you want to remove from this group can be LuaPlayer name or index etc
+-- @tparam LuaPlayer player LuaPlayer the player you want to remove from this group can be name or index etc
-- @treturn boolean true if the player was removed successfully, false other wise
function Permissions_Groups._prototype:remove_player(player)
player = Game.get_player_from_any(player)
@@ -245,7 +245,7 @@ function Permissions_Groups._prototype:remove_player(player)
end
--- Returns all player that are in this group with the option to filter to online/offline only
--- @tparam[opt] online boolean if nil returns all players, if true online players only, if false returns online players only
+-- @tparam[opt] boolean online if nil returns all players, if true online players only, if false returns online players only
-- @treturn table a table of players that are in this group; filtered if online param is given
function Permissions_Groups._prototype:get_players(online)
local players = {}
@@ -265,7 +265,7 @@ function Permissions_Groups._prototype:get_players(online)
end
--- Prints a message to every player in this group
--- @tparam message string the message that you want to send to the players
+-- @tparam string message the message that you want to send to the players
-- @treturn number the number of players that received the message
function Permissions_Groups._prototype:print(message)
local players = self:get_players(true)
diff --git a/expcore/roles.lua b/expcore/roles.lua
index ec088fef..9dddcbb4 100644
--- a/expcore/roles.lua
+++ b/expcore/roles.lua
@@ -246,8 +246,8 @@ function Roles.debug()
end
--- Prints a message to all players in the given roles, may send duplicate message however factorio blocks spam
--- @tparam roles table a table of roles which to send the message to
--- @tparam message string the message to send to the players
+-- @tparam table roles table a of roles which to send the message to
+-- @tparam string message the message to send to the players
function Roles.print_to_roles(roles,message)
for _,role in pairs(roles) do
role = Roles.get_role_from_any(role)
@@ -256,8 +256,8 @@ function Roles.print_to_roles(roles,message)
end
--- Prints a message to all players who have the given role or one which is higher (excluding default)
--- @tparam role string the name of the role to send the message to
--- @tparam message string the message to send to the players
+-- @tparam string role the name of the role to send the message to
+-- @tparam string message the message to send to the players
function Roles.print_to_roles_higher(role,message)
role = Roles.get_role_from_any(role)
if not role then return end
@@ -271,8 +271,8 @@ function Roles.print_to_roles_higher(role,message)
end
--- Prints a message to all players who have the given role or one which is lower (excluding default)
--- @tparam role string the name of the role to send the message to
--- @tparam message string the message to send to the players
+-- @tparam string role the name of the role to send the message to
+-- @tparam string message the message to send to the players
function Roles.print_to_roles_lower(role,message)
role = Roles.get_role_from_any(role)
if not role then return end
@@ -286,14 +286,14 @@ function Roles.print_to_roles_lower(role,message)
end
--- Get a role for the given name
--- @tparam name string the name of the role to get
+-- @tparam string name the name of the role to get
-- @treturn Roles._prototype the role with that name or nil
function Roles.get_role_by_name(name)
return Roles.config.roles[name]
end
--- Get a role with the given order index
--- @tparam index number the place in the oder list of the role to get
+-- @tparam number index the place in the oder list of the role to get
-- @treturn Roles._prototype the role with that index in the order list or nil
function Roles.get_role_by_order(index)
local name = Roles.config.order[index]
@@ -302,7 +302,7 @@ end
--- Gets a role from a name,index or role object (where it is just returned)
-- nb: this function is used for the input for most outward facing functions
--- @tparam any ?number|string|table the value used to find the role
+-- @tparam ?number|string|table any the value used to find the role
-- @treturn Roles._prototype the role that was found or nil see above
function Roles.get_role_from_any(any)
local tany = type(any)
@@ -317,7 +317,7 @@ function Roles.get_role_from_any(any)
end
--- Gets all the roles of the given player, this will always contain the default role
--- @tparam player LuaPlayer the player to get the roles of
+-- @tparam LuaPlayer player the player to get the roles of
-- @treturn table a table where the values are the roles which the player has
function Roles.get_player_roles(player)
player = Game.get_player_from_any(player)
@@ -332,7 +332,7 @@ function Roles.get_player_roles(player)
end
--- Gets the highest role which the player has, can be used to compeer one player to another
--- @tparam player LuaPlayer the player to get the highest role of
+-- @tparam LuaPlayer player the player to get the highest role of
-- @treturn the role with the highest order index which this player has
function Roles.get_player_highest_role(player)
local roles = Roles.get_player_roles(player)
@@ -347,10 +347,10 @@ function Roles.get_player_highest_role(player)
end
--- Gives a player the given role(s) with an option to pass a by player name used in the log
--- @tparam player LuaPlayer the player that will be assigned the roles
--- @tparam role table a table of roles that the player will be given, can be one role and can be role names
--- @tparam[opt=] by_player_name string the name of the player that will be shown in the log
--- @tparam[opt=false] silent boolean when true there will be no game message printed
+-- @tparam LuaPlayer player the player that will be assigned the roles
+-- @tparam table roles table a of roles that the player will be given, can be one role and can be role names
+-- @tparam[opt=] string by_player_name the name of the player that will be shown in the log
+-- @tparam[opt=false] boolean silent when true there will be no game message printed
function Roles.assign_player(player,roles,by_player_name,silent)
player = Game.get_player_from_any(player)
if not player then return end
@@ -367,10 +367,10 @@ function Roles.assign_player(player,roles,by_player_name,silent)
end
--- Removes a player from the given role(s) with an option to pass a by player name used in the log
--- @tparam player LuaPlayer the player that will have the roles removed
--- @tparam roles table a table of roles to be removed from the player, can be one role and can be role names
--- @tparam[opt=] by_player_name string the name of the player that will be shown in the logs
--- @tparam[opt=false] silent boolean when true there will be no game message printed
+-- @tparam LuaPlayer player the player that will have the roles removed
+-- @tparam table roles table a of roles to be removed from the player, can be one role and can be role names
+-- @tparam[opt=] string by_player_name the name of the player that will be shown in the logs
+-- @tparam[opt=false] boolean silent when true there will be no game message printed
function Roles.unassign_player(player,roles,by_player_name,silent)
player = Game.get_player_from_any(player)
if not player then return end
@@ -387,14 +387,14 @@ function Roles.unassign_player(player,roles,by_player_name,silent)
end
--- Overrides all player roles with the given table of roles, useful to mass set roles on game start
--- @tparam roles table a table which is indexed by case sensitive player names and has the value of a table of role names
+-- @tparam table roles table a which is indexed by case sensitive player names and has the value of a table of role names
function Roles.override_player_roles(roles)
Roles.config.players = roles
end
--- A test for weather a player has the given role
--- @tparam player LuaPlayer the player to test the roles of
--- @tparam search_role ?string|number|table a pointer to the role that is being searched for
+-- @tparam LuaPlayer player the player to test the roles of
+-- @tparam ?string|number|table search_role a pointer to the role that is being searched for
-- @treturn boolean true if the player has the role, false otherwise, nil for errors
function Roles.player_has_role(player,search_role)
local roles = Roles.get_player_roles(player)
@@ -408,8 +408,8 @@ function Roles.player_has_role(player,search_role)
end
--- A test for weather a player has the given flag true for at least one of they roles
--- @tparam player LuaPlayer the player to test the roles of
--- @tparam flag_name string the name of the flag that is being looked for
+-- @tparam LuaPlayer player the player to test the roles of
+-- @tparam string flag_name the name of the flag that is being looked for
-- @treturn boolean true if the player has at least one role which has the flag set to true, false otherwise, nil for errors
function Roles.player_has_flag(player,flag_name)
local roles = Roles.get_player_roles(player)
@@ -423,8 +423,8 @@ function Roles.player_has_flag(player,flag_name)
end
--- A test for weather a player has at least one role which is allowed the given action
--- @tparam player LuaPlayer the player to test the roles of
--- @tparam action string the name of the action that is being tested for
+-- @tparam LuaPlayer player the player to test the roles of
+-- @tparam string action the name of the action that is being tested for
-- @treturn boolean true if the player has at least one role which is allowed this action, false otherwise, nil for errors
function Roles.player_allowed(player,action)
local roles = Roles.get_player_roles(player)
@@ -439,7 +439,7 @@ end
--- Used to set the role order, higher in the list is better, must be called at least once in config
-- nb: function also re links parents due to expected position in the config file
--- @tparam order table a table which is keyed only by numbers (start 1) and values are roles in order with highest first
+-- @tparam table order table a which is keyed only by numbers (start 1) and values are roles in order with highest first
function Roles.define_role_order(order)
-- Clears and then rebuilds the order table
Roles.config.order = {}
@@ -462,8 +462,8 @@ function Roles.define_role_order(order)
end
--- Defines a new trigger for when a tag is added or removed from a player
--- @tparam name string the name of the flag which the roles will have
--- @tparam callback function the function that is called when roles are assigned
+-- @tparam string name the name of the flag which the roles will have
+-- @tparam function callback the function that is called when roles are assigned
-- flag param - player - the player that has had they roles changed
-- flag param - state - the state of the flag, aka if the flag is present
function Roles.define_flag_trigger(name,callback)
@@ -471,7 +471,7 @@ function Roles.define_flag_trigger(name,callback)
end
--- Sets the default role which every player will have, this needs to be called at least once
--- @tparam name string the name of the default role
+-- @tparam string name the name of the default role
function Roles.set_default(name)
local role = Roles.config.roles[name]
if not role then return end
@@ -479,7 +479,7 @@ function Roles.set_default(name)
end
--- Sets the root role which will always have all permissions, any server actions act from this role
--- @tparam name string the name of the root role
+-- @tparam string name the name of the root role
function Roles.set_root(name)
local role = Roles.config.roles[name]
if not role then return end
@@ -488,8 +488,8 @@ function Roles.set_root(name)
end
--- Defines a new role and returns the prototype to allow configuration
--- @tparam name string the name of the new role, must be unique
--- @tparam[opt=name] shirt_hand string the shortened version of the name
+-- @tparam string name the name of the new role, must be unique
+-- @tparam[opt=name] string short_hand the shortened version of the name
-- @treturn Roles._prototype the start of the config chain for this role
function Roles.new_role(name,short_hand)
if Roles.config.roles[name] then return error('Role name is non unique') end
@@ -505,7 +505,7 @@ function Roles.new_role(name,short_hand)
end
--- Sets the default allow state of the role, true will allow all actions
--- @tparam[opt=true] strate boolean true will allow all actions
+-- @tparam[opt=true] boolean state true will allow all actions
-- @treturn Roles._prototype allows chaining
function Roles._prototype:set_allow_all(state)
if state == nil then state = true end
@@ -514,7 +514,7 @@ function Roles._prototype:set_allow_all(state)
end
--- Sets the allow actions for this role, actions in this list will be allowed for this role
--- @tparam actions table indexed with numbers and is an array of action names, order has no effect
+-- @tparam table actions indexed with numbers and is an array of action names, order has no effect
-- @treturn Roles._prototype allows chaining
function Roles._prototype:allow(actions)
if type(actions) ~= 'table' then
@@ -527,7 +527,7 @@ function Roles._prototype:allow(actions)
end
--- Sets the disallow actions for this role, will prevent actions from being allowed regardless of inheritance
--- @tparam actions table indexed with numbers and is an array of action names, order has no effect
+-- @tparam table actions indexed with numbers and is an array of action names, order has no effect
-- @treturn Roles._prototype allows chaining
function Roles._prototype:disallow(actions)
if type(actions) ~= 'table' then
@@ -540,7 +540,7 @@ function Roles._prototype:disallow(actions)
end
--- Test for if a role is allowed the given action, mostly internal see Roles.player_allowed
--- @tparam action string the name of the action to test if it is allowed
+-- @tparam string action the name of the action to test if it is allowed
-- @treturn boolean true if action is allowed, false otherwise
function Roles._prototype:is_allowed(action)
local is_root = Roles.config.internal.root.name == self.name
@@ -548,8 +548,8 @@ function Roles._prototype:is_allowed(action)
end
--- Sets the state of a flag for a role, flags can be used to apply effects to players
--- @tparam name string the name of the flag to set the value of
--- @tparam[opt=true] value boolean the state to set the flag to
+-- @tparam string name the name of the flag to set the value of
+-- @tparam[opt=true] boolean value the state to set the flag to
-- @treturn Roles._prototype allows chaining
function Roles._prototype:set_flag(name,value)
if value == nil then value = true end
@@ -565,14 +565,14 @@ function Roles._prototype:clear_flags()
end
--- A test for if the role has a flag set
--- @tparam name string the name of the flag to test for
+-- @tparam string name the name of the flag to test for
-- @treturn boolean true if the flag is set, false otherwise
function Roles._prototype:has_flag(name)
return self.flags[name] or false
end
--- Sets a custom player tag for the role, can be accessed by other code
--- @tparam tag string the value that the tag will be
+-- @tparam string tag the value that the tag will be
-- @treturn Roles._prototype allows chaining
function Roles._prototype:set_custom_tag(tag)
self.custom_tag = tag
@@ -580,7 +580,7 @@ function Roles._prototype:set_custom_tag(tag)
end
--- Sets a custom colour for the role, can be accessed by other code
--- @tparam color ?string|table can either be and rgb colour table or the name of a colour defined in the presets
+-- @tparam table color ?string|table can either be and rgb colour or the name of a colour defined in the presets
-- @treturn Roles._prototype allows chaining
function Roles._prototype:set_custom_color(color)
if type(color) ~= 'table' then
@@ -591,8 +591,8 @@ function Roles._prototype:set_custom_color(color)
end
--- Sets the permission group for this role, players will be moved to the group of they highest role
--- @tparam name string the name of the permission group to have players moved to
--- @tparam[opt=false] use_factorio_api boolean when true the custom permission group module is ignored
+-- @tparam string name the name of the permission group to have players moved to
+-- @tparam[opt=false] boolean use_factorio_api when true the custom permission group module is ignored
-- @treturn Roles._prototype allows chaining
function Roles._prototype:set_permission_group(name,use_factorio_api)
if use_factorio_api then
@@ -607,7 +607,7 @@ end
--- Sets the parent for a role, any action not in allow or disallow will be looked for in its parents
-- nb: this is a recursive action, and changing the allows and disallows will effect all children roles
--- @tparam role string the name of the role that will be the parent; has imminent effect if role is already defined
+-- @tparam string role the name of the role that will be the parent; has imminent effect if role is already defined
-- @treturn Roles._prototype allows chaining
function Roles._prototype:set_parent(role)
self.parent = role
@@ -619,7 +619,7 @@ end
--- Sets an auto promote condition that is checked every 5 seconds, if true is returned then the player will recive the role
-- nb: this is one way, failing false after already gaining the role will not revoke the role
--- @tparam callback function receives only one param which is player to promote, return true to promote the player
+-- @tparam function callback receives only one param which is player to promote, return true to promote the player
-- @treturn Roles._prototype allows chaining
function Roles._prototype:set_auto_promote_condition(callback)
self.auto_promote_condition = callback
@@ -627,7 +627,7 @@ function Roles._prototype:set_auto_promote_condition(callback)
end
--- Sets the role to not allow players to have auto promote effect them, useful to keep people locked to a punishment
--- @tparam[opt=true] state boolean when true the players with this role will not be auto promoted
+-- @tparam[opt=true] boolean state when true the players with this role will not be auto promoted
-- @treturn Roles._prototype allows chaining
function Roles._prototype:set_block_auto_promote(state)
if state == nil then state = true end
@@ -636,9 +636,9 @@ function Roles._prototype:set_block_auto_promote(state)
end
--- Adds a player to this role, players can have more than one role at a time, used internally see Roles.assign
--- @tparam player LuaPlayer the player that will be given this role
--- @tparam skip_check boolean when true player will be taken as the player name (use when player has not yet joined)
--- @tparam skip_event boolean when true the event emit will be skipped, this is used internally with Roles.assign
+-- @tparam LuaPlayer player the player that will be given this role
+-- @tparam boolean skip_check when true player will be taken as the player name (use when player has not yet joined)
+-- @tparam boolean skip_event when true the event emit will be skipped, this is used internally with Roles.assign
-- @treturn boolean true if the player was added successfully
function Roles._prototype:add_player(player,skip_check,skip_event)
player = Game.get_player_from_any(player)
@@ -670,9 +670,9 @@ function Roles._prototype:add_player(player,skip_check,skip_event)
end
--- Removes a player from this role, players can have more than one role at a time, used internally see Roles.unassign
--- @tparam player LuaPlayer the player that will lose this role
--- @tparam skip_check boolean when true player will be taken as the player name (use when player has not yet joined)
--- @tparam skip_event boolean when true the event emit will be skipped, this is used internally with Roles.unassign
+-- @tparam LuaPlayer player the player that will lose this role
+-- @tparam boolean skip_check when true player will be taken as the player name (use when player has not yet joined)
+-- @tparam boolean skip_event when true the event emit will be skipped, this is used internally with Roles.unassign
-- @treturn boolean true if the player was removed successfully
function Roles._prototype:remove_player(player,skip_check,skip_event)
player = Game.get_player_from_any(player)
@@ -709,7 +709,7 @@ function Roles._prototype:remove_player(player,skip_check,skip_event)
end
--- Returns an array of all the players who have this role, can be filtered by online status
--- @tparam[opt=nil] online boolean when given will filter by this online state, nil will return all players
+-- @tparam[opt=nil] boolean online when given will filter by this online state, nil will return all players
-- @treturn table all the players who have this role, indexed order is meaningless
function Roles._prototype:get_players(online)
local players = {}
@@ -740,7 +740,7 @@ function Roles._prototype:get_players(online)
end
--- Will print a message to all players with this role
--- @tparam message string the message that will be printed to the players
+-- @tparam string message the message that will be printed to the players
-- @treturn number the number of players who received the message
function Roles._prototype:print(message)
local players = self:get_players(true)
diff --git a/expcore/store.lua b/expcore/store.lua
index f391dbd2..7a05be78 100644
--- a/expcore/store.lua
+++ b/expcore/store.lua
@@ -108,7 +108,7 @@ Global.register(Store.data,function(tbl)
end)
--- Check for if a lcoation is registered
--- @tparam location string the location to test for
+-- @tparam string location the location to test for
-- @treturn boolean true if registered
function Store.is_registered(location)
return not not Store.callbacks[location]
@@ -121,9 +121,9 @@ function Store.uid_location()
end
--- Registers a new location with an update callback which is triggered when the value updates
--- @tparam location string a unique string that points to the data, string used rather than token to allow migration
--- @tparam callback function this callback will be called when the stored value is set to a new value
--- @tparam[opt] start_value any this value will be the inital value that is stored at this location
+-- @tparam string location string a unique that points to the data, string used rather than token to allow migration
+-- @tparam function callback this callback will be called when the stored value is set to a new value
+-- @tparam[opt] any start_value this value will be the inital value that is stored at this location
function Store.register(location,callback,start_value)
if _LIFECYCLE ~= _STAGE.control then
return error('Can only be called during the control stage', 2)
@@ -144,9 +144,9 @@ function Store.register(location,callback,start_value)
end
--- Registers a new cross server synced location with an update callback, and external script is required for cross server
--- @tparam location string a unique string that points to the data, string used rather than token to allow migration
--- @tparam callback function this callback will be called when the stored value is set to a new value
--- @tparam[opt] start_value any this value will be the inital value that is stored at this location
+-- @tparam string location string a unique that points to the data, string used rather than token to allow migration
+-- @tparam function callback this callback will be called when the stored value is set to a new value
+-- @tparam[opt] any start_value this value will be the inital value that is stored at this location
function Store.register_synced(location,callback,start_value)
if _LIFECYCLE ~= _STAGE.control then
return error('Can only be called during the control stage', 2)
@@ -166,8 +166,8 @@ function Store.register_synced(location,callback,start_value)
end
--- Adds a function that will be checked every tick for a change in the returned value, when the value changes it will be saved in the store
--- @tparam location string the location where the data will be saved and compeared to, must already be a registered location
--- @tparam callback function this function will be called every tick to check for a change in value
+-- @tparam string location the location where the data will be saved and compeared to, must already be a registered location
+-- @tparam function callback this function will be called every tick to check for a change in value
function Store.add_watch(location,callback)
if _LIFECYCLE ~= _STAGE.control then
return error('Can only be called during the control stage', 2)
@@ -185,8 +185,8 @@ function Store.add_watch(location,callback)
end
--- Gets the value stored at a location, this location must be registered
--- @tparam location string the location to get the data from
--- @tparam[opt=false] no_error boolean when true no error is returned if the location is not registered
+-- @tparam string location the location to get the data from
+-- @tparam[opt=false] boolean no_error when true no error is returned if the location is not registered
-- @treturn any the data which was stored at the location
function Store.get(location,no_error)
if not Store.callbacks[location] and not no_error then
@@ -197,8 +197,8 @@ function Store.get(location,no_error)
end
--- Sets the value at a location, this location must be registered, if server synced it will emit the change to file
--- @tparam location string the location to set the data to
--- @tparam value any the new value to set at the location, value may be reverted if there is a watch callback
+-- @tparam string location the location to set the data to
+-- @tparam any value the new value to set at the location, value may be reverted if there is a watch callback
-- @treturn boolean true if it was successful
function Store.set(location,value)
if not Store.callbacks[location] then
@@ -220,7 +220,7 @@ end
--- Gets all non nil children at a location, children can be added and removed during runtime
-- this is similar to Store.get but will always return a table even if it is empty
--- @tparam location string the location to get the children of
+-- @tparam string location the location to get the children of
-- @treturn table a table containg all the children and they values
function Store.get_children(location)
local store = Store.get(location)
@@ -233,8 +233,8 @@ function Store.get_children(location)
end
--- Gets the value of the child to a location, children can be added and removed during runtime
--- @tparam location string the location of which the child is located
--- @tparam child string the child element to get the value of
+-- @tparam string location the location of which the child is located
+-- @tparam string child the child element to get the value of
-- @treturn any the value which was stored at that location
function Store.get_child(location,child)
local store = Store.get(location)
@@ -249,9 +249,9 @@ end
--- Sets the value of the chlid to a location, children can be added and removed during runtime
-- when a child is set it will call the update handler of the parent allowing children be to added at runtime
-- this may be used when a player joins the game and the child is the players name
--- @tparam location string the location of which the child is located
--- @tparam child string the child element to set the value of
--- @tparam value any the value to set at this location
+-- @tparam string location the location of which the child is located
+-- @tparam string child the child element to set the value of
+-- @tparam any value the value to set at this location
-- @treturn boolean true if it was successful
function Store.set_child(location,child,value)
local store = Store.get(location)
diff --git a/modules/addons/compilatron.lua b/modules/addons/compilatron.lua
index cbe75b0c..e8511ff0 100644
--- a/modules/addons/compilatron.lua
+++ b/modules/addons/compilatron.lua
@@ -63,7 +63,7 @@ Event.on_nth_tick(config.message_cycle, circle_messages)
--- This will add a compilatron to the global and start his message cycle
-- @tparam entity LuaEntity the compilatron entity that moves around
--- @tparam name string the name of the location that the complitron is at
+-- @tparam string name the name of the location that the complitron is at
function Public.add_compilatron(entity, name)
if not entity and not entity.valid then
return
@@ -80,8 +80,8 @@ function Public.add_compilatron(entity, name)
end
--- This spawns a new compilatron on a surface with the given location tag (not a position)
--- @tparam surface LuaSurface the surface to spawn the compilatron on
--- @tparam location string the location tag that is in the config file
+-- @tparam LuaSurface surface the surface to spawn the compilatron on
+-- @tparam string location the location tag that is in the config file
function Public.spawn_compilatron(surface,location)
local position = locations[location]
local pos = surface.find_non_colliding_position('compilatron', position, 1.5, 0.5)
diff --git a/modules/addons/jail-control.lua b/modules/addons/jail-control.lua
index 2706f0a1..054e7dd9 100644
--- a/modules/addons/jail-control.lua
+++ b/modules/addons/jail-control.lua
@@ -31,8 +31,8 @@ local function event_emit(event,player,by_player_name,reason)
end
--- Jails a player, this is only the logic there is no output to players
--- @tparam player LuaPlayer the player that will be jailed, must not be in jail
--- @tparam[opt=''] by_player_name string the name of the player doing the action used in logs
+-- @tparam LuaPlayer player the player that will be jailed, must not be in jail
+-- @tparam[opt=''] string by_player_name the name of the player doing the action used in logs
-- @treturn the number of roles that were removed, nil if there was an error
function Public.jail_player(player,by_player_name)
player = Game.get_player_from_any(player)
@@ -47,8 +47,8 @@ function Public.jail_player(player,by_player_name)
end
--- Unjails a player, this is only the logic there is no output to players
--- @tparam player LuaPlayer the player that will be unjailed, must be in jail
--- @tparam[opt=''] by_player_name string string the name of the player who is doing the action
+-- @tparam LuaPlayer player the player that will be unjailed, must be in jail
+-- @tparam[opt=''] string string by_player_name the name of the player who is doing the action
-- @treturn the number of roles that were added, nil if there was an error
function Public.unjail_player(player,by_player_name)
player = Game.get_player_from_any(player)
@@ -62,9 +62,9 @@ function Public.unjail_player(player,by_player_name)
end
--- Temp bans a player which is similar to jail but will store the reason for the action and clears items
--- @tparam player LuaPlayer the player that will be temp baned, must not be temp banned
--- @tparam[opt=''] by_player_name string the name of the player that is doing the action
--- @tparam[opt='None Given.'] reason string the reason that will be stored for this temp ban
+-- @tparam LuaPlayer player the player that will be temp baned, must not be temp banned
+-- @tparam[opt=''] string by_player_name the name of the player that is doing the action
+-- @tparam[opt='None string Given.'] reason the reason that will be stored for this temp ban
-- @treturn boolean true if successful else will return nil
function Public.temp_ban_player(player,by_player_name,reason)
player = Game.get_player_from_any(player)
@@ -81,8 +81,8 @@ function Public.temp_ban_player(player,by_player_name,reason)
end
--- Removes temp ban from a player, note this does not restore the items
--- @tparam player LuaPlayer the player that will be cleared from temp baned, must be temp banned
--- @tparam[opt=''] by_player_name string the name of the player that is doing the action
+-- @tparam LuaPlayer player the player that will be cleared from temp baned, must be temp banned
+-- @tparam[opt=''] string by_player_name the name of the player that is doing the action
-- @treturn boolean true if successful else will return nil
function Public.clear_temp_ban_player(player,by_player_name)
player = Game.get_player_from_any(player)
diff --git a/modules/addons/reports-control.lua b/modules/addons/reports-control.lua
index e71b97f5..673f3f3c 100644
--- a/modules/addons/reports-control.lua
+++ b/modules/addons/reports-control.lua
@@ -24,9 +24,9 @@ local function event_emit(event,player,by_player_name)
end
--- Adds a report to a player, reports are stored in global table and can be accessed later
--- @tparam player LuaPlayer the player that will be reported
--- @tparam[opt='Non Given.'] reason string the reason that the player is being reported
--- @tparam[opt=''] by_player_name string the name of the player doing the action
+-- @tparam LuaPlayer player the player that will be reported
+-- @tparam[opt='Non string Given.'] reason the reason that the player is being reported
+-- @tparam[opt=''] string by_player_name the name of the player doing the action
-- @treturn boolean true if the report was added, nil if there is an error
function Public.report_player(player,reason,by_player_name)
player = Game.get_player_from_any(player)
@@ -46,8 +46,8 @@ function Public.report_player(player,reason,by_player_name)
end
--- Removes a report from a player by the given player, see clear_player_reports to remove all
--- @tparam player LuaPlayer the player that will have the report removed
--- @tparam[opt=''] by_player_name string the name of the player doing the action
+-- @tparam LuaPlayer player the player that will have the report removed
+-- @tparam[opt=''] string by_player_name the name of the player doing the action
-- @treturn boolean true if the report was removed, nil if there was an error
function Public.remove_player_report(player,by_player_name)
player = Game.get_player_from_any(player)
@@ -66,7 +66,7 @@ function Public.remove_player_report(player,by_player_name)
end
--- Clears all reports from a player, will emit an event for each individual report as if remove_player_report was used
--- @tparam player LuaPlayer the player to clear the reports of
+-- @tparam LuaPlayer player the player to clear the reports of
-- @treturn boolean true if the reports were cleared, nil if error
function Public.clear_player_reports(player)
player = Game.get_player_from_any(player)
@@ -83,9 +83,9 @@ function Public.clear_player_reports(player)
end
--- Test for if a player has been reported by another player, can also return the reason from that player
--- @tparam player LuaPlayer the player to check the reports of
--- @tparam by_player_name string the player that made if the report if present (note server is not default here)
--- @tparam[opt=false] rtn_reason boolean true will return the reason for the report rather than a boolean
+-- @tparam LuaPlayer player the player to check the reports of
+-- @tparam string by_player_name the player that made if the report if present (note server is not default here)
+-- @tparam[opt=false] boolean rtn_reason true will return the reason for the report rather than a boolean
-- @treturn boolean true if a report from the player is present unless rtn_reason is true when a string is returned (or false)
function Public.player_is_reported_by(player,by_player_name,rtn_reason)
player = Game.get_player_from_any(player)
@@ -98,7 +98,7 @@ function Public.player_is_reported_by(player,by_player_name,rtn_reason)
end
--- Gets all the reports that are on a player
--- @tparam player LuaPlayer the player to get the reports of
+-- @tparam LuaPlayer player the player to get the reports of
-- @treturn table a table of all the reports for this player, empty table if no reports
function Public.get_player_reports(player)
player = Game.get_player_from_any(player)
@@ -107,8 +107,8 @@ function Public.get_player_reports(player)
end
--- Counts all reports on a player returning a number, a custom count function can be given which should return a number
--- @tparam player LuaPlayer the player to count the reports of
--- @tparam[opt] count_callback function should return a number or true (for 1) this will be passed every report on the player
+-- @tparam LuaPlayer player the player to count the reports of
+-- @tparam[opt] number function count_callback should return a or true (for 1) this will be passed every report on the player
-- count_callback param - player_name string - the name of the player who made the report
-- count_callback param - reason string - the reason the reason was made
-- count_callback return - number or boolean - if number then this will be added to the count, if boolean then false = 0 and true = 1
diff --git a/modules/addons/warnings-control.lua b/modules/addons/warnings-control.lua
index bb19e7aa..616ef3d1 100644
--- a/modules/addons/warnings-control.lua
+++ b/modules/addons/warnings-control.lua
@@ -36,9 +36,9 @@ local function event_emit(event,player,by_player_name)
end
--- Adds X number (default 1) of warnings to a player from the given player
--- @tparam player LuaPlayer the player to add the warning to
--- @tparam[opt=''] by_player_name string the name of the player doing the action
--- @tparam[opt=1] count number the number of warnings to add
+-- @tparam LuaPlayer player the player to add the warning to
+-- @tparam[opt=''] string by_player_name the name of the player doing the action
+-- @tparam[opt=1] number count the number of warnings to add
-- @treturn number the new number of warnings
function Public.add_warnings(player,by_player_name,count)
player = Game.get_player_from_any(player)
@@ -58,9 +58,9 @@ function Public.add_warnings(player,by_player_name,count)
end
--- Removes X number (default 1) of warnings from a player, removes in order fifo
--- @tparam player LuaPlayer the player to remove the warnings from
--- @tparam[opt=''] by_playey_name string the name of the player doing the action
--- @tparam[opt=1] count number the number of warnings to remove (if greater than current warning count then all are removed)
+-- @tparam LuaPlayer player the player to remove the warnings from
+-- @tparam[opt=''] string by_playey_name the name of the player doing the action
+-- @tparam[opt=1] number count the number of warnings to remove (if greater than current warning count then all are removed)
-- @treturn number the new number of warnings
function Public.remove_warnings(player,by_player_name,count)
player = Game.get_player_from_any(player)
@@ -82,8 +82,8 @@ function Public.remove_warnings(player,by_player_name,count)
end
--- Clears all warnings from a player, emits event multiple times as if remove_warnings was used
--- @tparam player LuaPlayer the player to clear the warnings of
--- @tparam[oot=''] by_player_name string the name of the player who is doing the action
+-- @tparam LuaPlayer player the player to clear the warnings of
+-- @tparam[oot=''] string by_player_name the name of the player who is doing the action
-- @treturn boolean true if the warnings were cleared, nil if error
function Public.clear_warnings(player,by_player_name)
player = Game.get_player_from_any(player)
@@ -99,8 +99,8 @@ function Public.clear_warnings(player,by_player_name)
end
--- Gets the number of warnings that a player has, raw table will contain the names of who gave warnings
--- @tparam player LuaPlayer the player to get the warnings of
--- @tparam[opt=false] raw_table when true will return a table which contains who gave warnings (the table stored in global)
+-- @tparam LuaPlayer player the player to get the warnings of
+-- @tparam[opt=false] table table raw_table when true will return a which contains who gave warnings (the stored in global)
-- @treturn number the number of warnings a player has, a table if raw_table is true
function Public.get_warnings(player,raw_table)
player = Game.get_player_from_any(player)
@@ -114,8 +114,8 @@ function Public.get_warnings(player,raw_table)
end
--- Adds a temp warning to a player that will timeout after some time, used for script given warnings (ie silent to outside players as a buffer)
--- @tparam player LuaPlayer the player to give the warnings to
--- @tparam[opt=1] count number the number of warnings to give to the player
+-- @tparam LuaPlayer player the player to give the warnings to
+-- @tparam[opt=1] number count the number of warnings to give to the player
-- @treturn number the new number of warnings
function Public.add_temp_warnings(player,count)
player = Game.get_player_from_any(player)
@@ -153,8 +153,8 @@ Event.on_nth_tick(temp_warning_cool_down/4,function()
end)
--- Clears all temp warnings from a player, emits events as if the warnings had been removed due to time
--- @tparam player LuaPlayer the player to clear the warnings of
--- @tparam[opt=''] by_player_name string the name of the player doing the action
+-- @tparam LuaPlayer player the player to clear the warnings of
+-- @tparam[opt=''] string by_player_name the name of the player doing the action
-- @treturn boolean true if the warnings were cleared, nil for error
function Public.clear_temp_warnings(player,by_player_name)
player = Game.get_player_from_any(player)
@@ -170,8 +170,8 @@ function Public.clear_temp_warnings(player,by_player_name)
end
--- Gets the number of temp warnings, raw table is a table of when temp warnings were given
--- @tparam player LuaPlayer the player to get the warnings of
--- @tparam[opt=false] raw_table if true will return a table of ticks when warnings were added (the global table)
+-- @tparam LuaPlayer player the player to get the warnings of
+-- @tparam[opt=false] table raw_table if true will return a of ticks when warnings were added (the global table)
-- @treturn number the number of warnings which the player has, a table if raw_table is true
function Public.get_temp_warnings(player,raw_table)
player = Game.get_player_from_any(player)
diff --git a/modules/commands/interface.lua b/modules/commands/interface.lua
index 51752618..217ff43f 100644
--- a/modules/commands/interface.lua
+++ b/modules/commands/interface.lua
@@ -33,8 +33,8 @@ end)
--- Adds a callback function when the interface command is used
-- nb: returned value is saved in the env that the interface uses
--- @tparam name string the name that the value is loaded under, cant use upvalues
--- @tparam callback function the function that will run whent he command is used
+-- @tparam string name the name that the value is loaded under, cant use upvalues
+-- @tparam function callback the function that will run whent he command is used
-- callback param - player: LuaPlayer - the player who used the command
local function add_interface_callback(name,callback)
if type(callback) == 'function' then
diff --git a/modules/gui/debug/_g_view.lua b/modules/gui/debug/_g_view.lua
index 3cf4bbd2..2e484eb8 100644
--- a/modules/gui/debug/_g_view.lua
+++ b/modules/gui/debug/_g_view.lua
@@ -1,3 +1,4 @@
+--non-luadoc=true
local Gui = require 'utils.gui'
local Model = require 'modules.gui.debug.model'
local Color = require 'resources.color_presets'
diff --git a/old/modules/DONE/Core/Command/control.lua b/old/modules/DONE/Core/Command/control.lua
index 72cdde36..ffe85e73 100644
--- a/old/modules/DONE/Core/Command/control.lua
+++ b/old/modules/DONE/Core/Command/control.lua
@@ -24,7 +24,7 @@ function commands.add_middleware(callback) if not is_type(callback,'function') t
-- @field commands.data
-- @usage commands.command_name -- returns command data
-- @usage commands.data -- returns all data
--- @tparam ?string|table|event key the command that will be returned: string is the name, table is the command data, event is event from add_command
+-- @tparam string table ?string|table|event key the command that will be returned: is the name, is the command data, event is event from add_command
-- @treturn table the command data
setmetatable(commands,{
__index=function(tbl,key) return is_type(key,'table') and (key.command and rawget(commandDataStore,key.name) or key) or key == 'data' and commandDataStore or rawget(commandDataStore,key) end
@@ -242,9 +242,9 @@ end
--- Used to define commands
-- @usage --see examples in file
-- @tparam string name the name of the command
--- @tparam[opt='No Description'] string description the description of the command
--- @tparam[opt=an infinite string] table inputs a table of the inputs to be used, last index being true makes the last parameter open ended (longer than one word)
--- @tparam function callback the function to call on the event
+-- @tparam[opt='No string Description'] description the description of the command
+-- @tparam[opt=an table table infinite string] inputs a of the inputs to be used, last index being true makes the last parameter open ended (longer than one word)
+-- @tparam function function callback the to call on the event
commands.add_command = function(name, description, inputs, callback)
if commands[name] then error('That command is already registered',2) end
if not is_type(name,'string') then error('Command name has not been given') end
diff --git a/old/modules/DONE/Core/Group/control.lua b/old/modules/DONE/Core/Group/control.lua
index 97843d35..5c1e42fb 100644
--- a/old/modules/DONE/Core/Group/control.lua
+++ b/old/modules/DONE/Core/Group/control.lua
@@ -40,7 +40,7 @@ _GroupSelfRef=Group
--- Defines a new instance of a group
-- @usage Group.define{name='foo',disallow={'edit_permission_group','delete_permission_group','add_permission_group'}} -- returns new group
-- @usage Group{name='foo',disallow={'edit_permission_group','delete_permission_group','add_permission_group'}} -- returns new group
--- @tparam table obj contains string name and table disallow of defines.input_action
+-- @tparam string table table obj contains name and disallow of defines.input_action
-- @treturn Group the group which has been made
function Group.define(obj)
if not type_error(game,nil,'Cant define Group during runtime.') then return end
diff --git a/old/modules/DONE/Core/Gui/control.lua b/old/modules/DONE/Core/Gui/control.lua
index 1ffe615f..0c9968f9 100644
--- a/old/modules/DONE/Core/Gui/control.lua
+++ b/old/modules/DONE/Core/Gui/control.lua
@@ -48,7 +48,7 @@ end
--- Adds a label that is centered
-- @usage Gui.centered_label(frame, 'Hello, world!')
-- @tparam LuaGuiElement frame the parent frame to add the label to
--- @tparam string string the string that the label will have
+-- @tparam string string string the that the label will have
function Gui.centered_label(frame, string)
local flow = frame.add {frame = 'flow'}
local flow_style = flow.style
diff --git a/old/modules/DONE/Core/Gui/inputs/control.lua b/old/modules/DONE/Core/Gui/inputs/control.lua
index 9d6aab03..1da9afee 100644
--- a/old/modules/DONE/Core/Gui/inputs/control.lua
+++ b/old/modules/DONE/Core/Gui/inputs/control.lua
@@ -28,7 +28,7 @@ inputs.events = {
--- Sets the input to trigger on an certain event
-- @usage button:on_event(defines.events.on_gui_click,player_return)
-- @param event the event to raise callback on | can be number of the event | can be a key of inputs.events
--- @tparam function callback the function you want to run on the event
+-- @tparam function function callback the you want to run on the event
-- @treturn table returns self so you can chain together
function inputs._prototype:on_event(event,callback)
if not is_type(callback,'function') then return self end
@@ -311,8 +311,8 @@ end
-- @tparam string orientation direction of the slider
-- @tparam number min the lowest number
-- @tparam number max the highest number
--- @tparam function start_callback either a number or a function to return a number
--- @tparam function callback the function to be called on value_changed function(player,value,percent,element)
+-- @tparam number function function start_callback either a or a to return a number
+-- @tparam function function callback the to be called on value_changed function(player,value,percent,element)
-- @treturn table the slider object that was made, to allow a custom error event if wanted
function inputs.add_slider(name,orientation,min,max,start_callback,callback)
local slider = inputs.add{
diff --git a/old/modules/DONE/Core/Gui/toolbar/control.lua b/old/modules/DONE/Core/Gui/toolbar/control.lua
index a31f2d98..4bc95bb4 100644
--- a/old/modules/DONE/Core/Gui/toolbar/control.lua
+++ b/old/modules/DONE/Core/Gui/toolbar/control.lua
@@ -38,7 +38,7 @@ end)
-- @tparam string name the name of the button
-- @tparam string caption can be a sprite path or text to show
-- @tparam string tooltip the help to show for the button
--- @tparam function callback the function which is called on_click
+-- @tparam function function callback the which is called on_click
-- @treturn table the button object that was made, calling the returned value will draw the toolbar button added
function toolbar.add(name,caption,tooltip,callback)
verbose('Created Toolbar Button: '..name)
diff --git a/old/modules/DONE/Core/Role/control.lua b/old/modules/DONE/Core/Role/control.lua
index fa049446..61a32206 100644
--- a/old/modules/DONE/Core/Role/control.lua
+++ b/old/modules/DONE/Core/Role/control.lua
@@ -80,7 +80,7 @@ function Role.set_preassign(tbl) if game then global.preassign = tbl else Role.p
--- Defines a new instance of a role
-- @usage Role.define{name='Root',short_hand='Root',tag='[Root]',group='Root',colour={r=255,b=255,g=255},is_root=true,allow={}} -- returns new role
-- @usage Role{name='Root',short_hand='Root',tag='[Root]',group='Root',colour={r=255,b=255,g=255},is_root=true,allow={}} -- returns new role
--- @tparam table obj contains the strings: name,short_hand,tag a table called allow a table called colour and a pointer to a permission group
+-- @tparam table table obj contains the strings: name,short_hand,tag a called allow a table called colour and a pointer to a permission group
-- @treturn Role the role which has been made
function Role.define(obj)
if not type_error(game,nil,'Cant define Role during runtime.') then return end
@@ -127,7 +127,7 @@ end
-- @usage Role.assign(player,'Root')
-- @usage Role.assign(player,{'Root','Foo'})
-- @tparam ?LuaPlayer|pointerToPlayer player the player to assign the role to
--- @tparam ?string|role|table the role to add the player to, if its a table then it will act recursively though the table
+-- @tparam table ?string|role|table the role to add the player to, if its a then it will act recursively though the table
-- @tparam[opt=''] ?LuaPlayer|pointerToPlayer by_player the player who assigned the roles to the player
-- @tparam[opt] table batch this is used internally to prevent multiple event calls, contains {role_index_in_batch,batch}
-- @treturn boolean was the player assigned the roles
@@ -153,7 +153,7 @@ end
--- Used to remove a player from a role(s)
-- @usage Role.unassign(player,'Root')
-- @tparam ?LuaPlayer|pointerToPlayer player the player to unassign the role to
--- @tparam ?string|role|table role the role to remove the player from, if its a table then it will act recursively though the table
+-- @tparam table ?string|role|table role the role to remove the player from, if its a then it will act recursively though the table
-- @tparam[opt=''] ?LuaPlayer|pointerToPlayer by_player the player who unassigned the roles from the player
-- @tparam[opt] table batch this is used internally to prevent multiple event calls
-- @treturn boolean was the player unassigned the roles
@@ -179,7 +179,7 @@ end
--- Returns the highest role given in a list, if a player is passed then it returns the highest role of the player
-- @usage Role.get_highest{'Root','Admin','Mod'} -- returns Root (given that root is highest)
-- @usage Role.get_highest(player) -- returns the players highest role
--- @tparam ?table|LuaPlayer|pointerToPlayer options table of options or a player
+-- @tparam table ?table|LuaPlayer|pointerToPlayer options of options or a player
-- @treturn role the highest role given in the options
function Role.get_highest(options)
local player = Game.get_player(options)
@@ -199,7 +199,7 @@ end
-- @usage Role.revert(player) -- reverts the last change to the players roles
-- @tparam ?LuaPlayer|pointerToPlayer player the player to revert the changes of
-- @tparam[opt] ?LuaPlayer|pointerToPlayer the player who preformed the role revert
--- @tparam[opt=1] count the number of reverts to do, if 0 all changes cached are reverted
+-- @tparam[opt=1] number count the of reverts to do, if 0 all changes cached are reverted
-- @treturn number the number of changes that occurred
function Role.revert(player,by_player,count)
player = Game.get_player(player)
@@ -224,7 +224,7 @@ end
--- Adds a flag which can be set on roles; these flags act as a quick way to access general role changes
-- @usage Role.add_flag('is_admin',function(player,state) player.admin = state end) -- the function is passed player and if the flag is true or false
-- @tparam string flag the name of the flag that is being added
--- @tparam[opt] function callback the function(player,state) which is called when a player loses or gains a flag, if nil no function is called
+-- @tparam[opt] function function callback the function(player,state) which is called when a player loses or gains a flag, if nil no is called
function Role.add_flag(flag,callback)
if not type_error(flag,'string','Invalid argument #1 to Role.add_flag, flag is not a string.') then return end
if callback and not type_error(callback,'function','Invalid argument #2 to Role.add_flag, callback is not a function.') then return end
diff --git a/old/modules/DONE/ExpGamingLib/control.lua b/old/modules/DONE/ExpGamingLib/control.lua
index 77b4685c..5bc65516 100644
--- a/old/modules/DONE/ExpGamingLib/control.lua
+++ b/old/modules/DONE/ExpGamingLib/control.lua
@@ -12,7 +12,7 @@ local ExpLib = {}
--- Loads a table into _G even when sandboxes; will not overwrite values or append to tables; will not work during runtime to avoid desyncs
-- @usage unpack_to_G{key1='foo',key2='bar'}
--- @tparam table tbl table to be unpacked
+-- @tparam table table tbl to be unpacked
function ExpLib.unpack_to_G(tbl)
if not type(tbl) == 'table' or game then return end
for key,value in pairs(tbl) do
@@ -60,9 +60,9 @@ end
--- Creates a table that will act like a string and a function
-- @usage add_metatable({},function) -- returns table
--- @tparam table tbl the table that will have its metatable set
--- @tparam[opt=tostring] function callback the function that will be used for the call
--- @tparam[opt=table.tostring] ?function|string string a function that resolves to a string or a string
+-- @tparam table table tbl the that will have its metatable set
+-- @tparam[opt=tostring] function function callback the that will be used for the call
+-- @tparam[opt=table.tostring] function string string ?function|string a that resolves to a or a string
-- @treturn table the new table with its metatable set
function ExpLib.add_metatable(tbl,callback,string)
if not ExpLib.is_type(tbl,'table') then error('No table given to add_metatable',2) end
@@ -98,7 +98,7 @@ end
--- A specialised version of type_error to test for self
-- @usage self_test(self,'Object','get_name')
--- @tparam table self the table that is the object
+-- @tparam table table self the that is the object
-- @tparam string prototype_name the name of the class
-- @tparam string function_name the name of the function
function ExpLib.self_test(self,prototype_name,function_name)
@@ -240,7 +240,7 @@ end
--- Returns a table in a form able to be read as a table
-- @usage table.tostring{k1='foo',k2='bar'} -- return '{["k1"]="foo",["k2"]="bar"}'
--- @tparam table tbl table to convert
+-- @tparam table table tbl to convert
-- @treturn string the converted table
function table.tostring(tbl)
if type(tbl) ~= 'table' then return tostring(tbl) end
@@ -260,7 +260,7 @@ end
--- Similar to table.tostring but converts a lua table to a json one
-- @usage table.json{k1='foo',k2='bar'} -- return '{"k1":"foo","k2":"bar"}'
--- @tparam table lua_table the table to convert
+-- @tparam table table lua_table the to convert
-- @treturn string the table in a json format
function table.json(lua_table)
--if game and game.table_to_json then return game.table_to_json(lua_table) end
@@ -288,8 +288,8 @@ end
--- Returns the closest match to a key
-- @usage table.autokey({foo=1,bar=2},'f') -- return 1
--- @tparam table tbl the table that will be searched
--- @tparam string str the string that will be looked for in the keys
+-- @tparam table table tbl the that will be searched
+-- @tparam string string str the that will be looked for in the keys
function table.autokey(tbl,str)
if not ExpLib.is_type(str,'string') then return end
local _return = {}
@@ -301,7 +301,7 @@ end
--- Returns the list is a sorted way that would be expected by people (this is by key)
-- @usage tbl = table.alphanumsort(tbl)
--- @tparam table tbl the table to be sorted
+-- @tparam table table tbl the to be sorted
-- @treturn table the sorted table
function table.alphanumsort(tbl)
local o = table.keys(tbl)
@@ -317,7 +317,7 @@ end
--- Returns the list is a sorted way that would be expected by people (this is by key) (faster alterative than above)
-- @usage tbl = table.alphanumsort(tbl)
--- @tparam table tbl the table to be sorted
+-- @tparam table table tbl the to be sorted
-- @treturn table the sorted table
function table.keysort(tbl)
local o = table.keys(tbl,true)
diff --git a/old/modules/DONE/FactorioStdLib/Color/control.lua b/old/modules/DONE/FactorioStdLib/Color/control.lua
index 9ccedbc5..e7eeae1f 100644
--- a/old/modules/DONE/FactorioStdLib/Color/control.lua
+++ b/old/modules/DONE/FactorioStdLib/Color/control.lua
@@ -177,7 +177,7 @@ end
--- Get a color table with a hexadecimal string.
-- Optionally provide the value for the alpha channel.
--- @tparam string hex hexadecimal color string (#ffffff, not #fff)
+-- @tparam string string hex hexadecimal color (#ffffff, not #fff)
-- @tparam[opt=1] float alpha the alpha value to set; such that ***[ 0 ⋜ value ⋜ 1 ]***
-- @treturn a color table with RGB converted from Hex and with alpha
function Color.from_hex(hex, alpha)
diff --git a/old/modules/DONE/FactorioStdLib/Game/control.lua b/old/modules/DONE/FactorioStdLib/Game/control.lua
index b7608965..1c783c38 100644
--- a/old/modules/DONE/FactorioStdLib/Game/control.lua
+++ b/old/modules/DONE/FactorioStdLib/Game/control.lua
@@ -36,7 +36,7 @@ end
--- Print msg if specified var evaluates to false.
-- @tparam Mixed var variable to evaluate
--- @tparam[opt="missing value"] string msg message
+-- @tparam[opt="missing string value"] msg message
function Game.fail_if_missing(var, msg)
if not var then
error(msg or "Missing value", 3)
diff --git a/old/modules/DONE/FactorioStdLib/String/control.lua b/old/modules/DONE/FactorioStdLib/String/control.lua
index 24ff26ad..48ccea0b 100644
--- a/old/modules/DONE/FactorioStdLib/String/control.lua
+++ b/old/modules/DONE/FactorioStdLib/String/control.lua
@@ -5,14 +5,14 @@
-- luacheck: globals string (Allow mutating string)
--- Returns a copy of the string with any leading or trailing whitespace from the string removed.
--- @tparam string s the string to remove leading or trailing whitespace from
+-- @tparam string string s the to remove leading or trailing whitespace from
-- @treturn string a copy of the string without leading or trailing whitespace
function string.trim(s)
return (s:gsub("^%s*(.-)%s*$", "%1"))
end
--- Tests if a string starts with a given substring.
--- @tparam string s the string to check for the start substring
+-- @tparam string string s the to check for the start substring
-- @tparam string start the substring to test for
-- @treturn boolean true if the start substring was found in the string
function string.starts_with(s, start)
@@ -20,7 +20,7 @@ function string.starts_with(s, start)
end
--- Tests if a string ends with a given substring.
--- @tparam string s the string to check for the end substring
+-- @tparam string string s the to check for the end substring
-- @tparam string ends the substring to test for
-- @treturn boolean true if the end substring was found in the string
function string.ends_with(s, ends)
@@ -28,7 +28,7 @@ function string.ends_with(s, ends)
end
--- Tests if a string contains a given substring.
--- @tparam string s the string to check for the substring
+-- @tparam string string s the to check for the substring
-- @tparam string contains the substring to test for
-- @treturn boolean true if the substring was found in the string
function string.contains(s, contains)
@@ -36,7 +36,7 @@ function string.contains(s, contains)
end
--- Tests whether a string is empty.
--- @tparam string s the string to test
+-- @tparam string string s the to test
-- @treturn boolean true if the string is empty
function string.is_empty(s)
return s == nil or s == ''
@@ -45,9 +45,9 @@ end
--- Splits a string into an array.
-- *Note:* Empty split substrings are not included in the resulting table.
--
For example, `string.split("foo.bar...", ".", false)` results in the table `{"foo", "bar"}`.
--- @tparam string s the string to split
+-- @tparam string string s the to split
-- @tparam[opt="."] string sep the separator to use.
--- @tparam[opt=false] boolean pattern whether to interpret the separator as a lua pattern or plaintext for the string split
+-- @tparam[opt=false] string boolean pattern whether to interpret the separator as a lua pattern or plaintext for the split
-- @treturn {string,...} an array of strings
function string.split(s, sep, pattern)
sep = sep or "."
@@ -76,7 +76,7 @@ end
--- Returns a string as a hex format (also a string)
-- @usage a = 'foo'
-- string.to_hex(a) -- return '666f6f'
--- @tparam string str the string to encode
+-- @tparam string string str the to encode
-- @treturn string the hex format of the string
function string.to_hex(str)
if not is_type(str,'string') then return '' end
diff --git a/old/modules/DONE/FactorioStdLib/Table/control.lua b/old/modules/DONE/FactorioStdLib/Table/control.lua
index 04f048fc..e9196e1c 100644
--- a/old/modules/DONE/FactorioStdLib/Table/control.lua
+++ b/old/modules/DONE/FactorioStdLib/Table/control.lua
@@ -11,8 +11,8 @@
---table.map(a, function(v) return v * 10 end) --produces: { 10, 20, 30, 40, 50 }
--- @usage a = {1, 2, 3, 4, 5}
---table.map(a, function(v, k, x) return v * k + x end, 100) --produces { 101, 104, 109, 116, 125}
--- @tparam table tbl the table to be mapped to the transform
--- @tparam function func the function to transform values
+-- @tparam table table tbl the to be mapped to the transform
+-- @tparam function function func the to transform values
-- @param[opt] ... additional arguments passed to the function
-- @treturn table a new table containing the keys and mapped values
function table.map(tbl, func, ...)
@@ -30,8 +30,8 @@ end
---table.filter(a, function(v) return v % 2 == 0 end) --produces: { 2, 4 }
--- @usage a = {1, 2, 3, 4, 5}
---table.filter(a, function(v, k, x) return k % 2 == 1 end) --produces: { 1, 3, 5 }
--- @tparam table tbl the table to be filtered
--- @tparam function func the function to filter values
+-- @tparam table table tbl the to be filtered
+-- @tparam function function func the to filter values
-- @param[opt] ... additional arguments passed to the function
-- @treturn table a new table containing the filtered key-value pairs
function table.filter(tbl, func, ...)
@@ -53,8 +53,8 @@ end
---table.find(a, function(v) return v % 2 == 0 end) --produces: 2
--- @usage a = {1, 2, 3, 4, 5}
---table.find(a, function(v, k, x) return k % 2 == 1 end) --produces: 1
--- @tparam table tbl the table to be searched
--- @tparam function func the function to use to search for any matching element
+-- @tparam table table tbl the to be searched
+-- @tparam function any func the function to use to search for matching element
-- @param[opt] ... additional arguments passed to the function
-- @treturn ?|nil|Mixed the first found value, or nil if none was found
function table.find(tbl, func, ...)
@@ -68,7 +68,7 @@ end
--- Finds the first index at which the value appears in the table
-- @usage table.index({'foo','bar','baz'},'bar') -- retuns 2,'bar'
--- @tparam table tbl the table to search though
+-- @tparam table table tbl the to search though
-- @param value the value you want the index of
-- @treturn number the index that the value apeears at
-- @return the value in that possition
@@ -83,7 +83,7 @@ end
--- Returns a boolean on weather the table includes the value or not
-- @usage table.includes({'foo','bar','baz'},'bar') -- retuns true
--- @tparam table tbl the table to search though
+-- @tparam table table tbl the to search though
-- @param value the value you want the index of
-- @treturn boolean if the table includes the value
function table.includes(tbl, value)
@@ -100,8 +100,8 @@ end
-- Passes the index as second argument to the function.
-- @usage a= { 1, 2, 3, 4, 5} table.any(a, function(v) return v % 2 == 0 end) --produces: true
-- @usage a = {1, 2, 3, 4, 5} table.any(a, function(v, k, x) return k % 2 == 1 end) --produces: true
--- @tparam table tbl the table to be searched
--- @tparam function func the function to use to search for any matching element
+-- @tparam table table tbl the to be searched
+-- @tparam function any func the function to use to search for matching element
-- @param[opt] ... additional arguments passed to the function
-- @treturn boolean true if an element was found, false if none was found
function table.any(tbl, func, ...)
@@ -114,8 +114,8 @@ end
-- @usage
-- a = {10, 20, 30, 40}
-- table.each(a, function(v) game.print(v) end) --prints 10, 20, 30, 40, 50
--- @tparam table tbl the table to be iterated
--- @tparam function func the function to apply to elements
+-- @tparam table table tbl the to be iterated
+-- @tparam function function func the to apply to elements
-- @param[opt] ... additional arguments passed to the function
-- @treturn table the table where the given function has been applied to its elements
function table.each(tbl, func, ...)
@@ -250,7 +250,7 @@ end
--- Creates a deep copy of table without copying Factorio objects.
-- @usage local copy = table.deepcopy[data.raw.["stone-furnace"]["stone-furnace"]] -- returns a copy of the stone furnace entity
--- @tparam table object the table to copy
+-- @tparam table table object the to copy
-- @treturn table a copy of the table
function table.deepcopy(object)
local lookup_table = {}
@@ -294,7 +294,7 @@ local function sortFunc(x, y) --sorts tables with mixed index types.
end
--- Returns a copy of all of the values in the table.
--- @tparam table tbl the table to copy the keys from, or an empty table if tbl is nil
+-- @tparam table table tbl the to copy the keys from, or an empty table if tbl is nil
-- @tparam[opt] boolean sorted whether to sort the keys (slower) or keep the random order from pairs()
-- @tparam[opt] boolean as_string whether to try and parse the values as strings, or leave them as their existing type
-- @treturn array an array with a copy of all the values in the table
@@ -320,7 +320,7 @@ function table.values(tbl, sorted, as_string)
end
--- Returns a copy of all of the keys in the table.
--- @tparam table tbl the table to copy the keys from, or an empty table if tbl is nil
+-- @tparam table table tbl the to copy the keys from, or an empty table if tbl is nil
-- @tparam[opt] boolean sorted whether to sort the keys (slower) or keep the random order from pairs()
-- @tparam[opt] boolean as_string whether to try and parse the keys as strings, or leave them as their existing type
-- @treturn array an array with a copy of all the keys in the table
@@ -350,7 +350,7 @@ end
--table.remove_keys(a, {1,3}) --returns {nil, 2, nil, 4}
-- @usage local b = {k1 = 1, k2 = 'foo', old_key = 'bar'}
--table.remove_keys(b, {'old_key'}) --returns {k1 = 1, k2 = 'foo'}
--- @tparam table tbl the table to remove the keys from
+-- @tparam table table tbl the to remove the keys from
-- @tparam {Mixed,...} keys an array of keys that exist in the given table
-- @treturn table tbl without the specified keys
function table.remove_keys(tbl, keys)
@@ -391,7 +391,7 @@ end
--table.invert(a) --returns {'foo' = k1, 'bar' = k2}
-- @usage local b = {k1 = 'foo', k2 = 'bar', k3 = 'bar'}
--table.invert(b) --returns {'foo' = k1, 'bar' = ?}
--- @tparam table tbl the table to invert
+-- @tparam table table tbl the to invert
-- @treturn table a new table with inverted mapping
function table.invert(tbl)
local inverted = {}
@@ -410,7 +410,7 @@ table.size = table_size
--- For all string or number values in an array map them to a key = true table
-- @usage local a = {"v1", "v2"}
-- table.array_to_dict_bool(a) -- return {["v1"] = true, ["v2"]= true}
--- @tparam table tbl the table to convert
+-- @tparam table table tbl the to convert
-- @treturn table the converted table
function table.arr_to_bool(tbl)
local newtbl = {}
diff --git a/old/modules/ExpGamingCore/Server/control.lua b/old/modules/ExpGamingCore/Server/control.lua
index 33523468..4de7da63 100644
--- a/old/modules/ExpGamingCore/Server/control.lua
+++ b/old/modules/ExpGamingCore/Server/control.lua
@@ -206,7 +206,7 @@ end
--- Acts as a bypass for running functions, can accept a string
-- @usage Server.interface('local x = 1+1 print(x) return x') -- return 2
-- @usage Server.interface('local x = 1+1 print(x)',true) -- will create a thread to run as root (this is the bypass)
--- @tparam ?string|function callback function to be ran
+-- @tparam function ?string|function callback to be ran
-- @tparam[opt] ?Server._thread|true use_thread run the command on a pre-made thread or let it make its own
-- @tparam[opt] table env run the env to run the command in must have _env key as true to be
-- @param[opt] ... any args you want to pass to the function
@@ -467,8 +467,8 @@ end
--- Set function to run then an event is triggered, none of them are 'needed' but you are advised to have at least one
-- @usage thread:on_event('close',function) -- if event is not one below then a game event is used
-- @usage thread_only_events = ['close','timeout','tick','resolve','success','error']
--- @tparam ?string|index event the name of the event that the function should be called on
--- @tparam function callback the function which is called by the event trigger
+-- @tparam function ?string|index event the name of the event that the should be called on
+-- @tparam function function callback the which is called by the event trigger
-- @treturn table returns self so that they can be chained together
function Server._thread:on_event(event,callback)
local events = {'close','timeout','tick','resolve','success','error'}
diff --git a/old/modules/ExpGamingCore/Sync/control.lua b/old/modules/ExpGamingCore/Sync/control.lua
index 4a780a95..d7511518 100644
--- a/old/modules/ExpGamingCore/Sync/control.lua
+++ b/old/modules/ExpGamingCore/Sync/control.lua
@@ -104,7 +104,7 @@ end
--- Logs an embed to the json.data we use a js script to add things we cant here
-- @usage Sync.emit_embedded{title='BAN',color='0x0',description='A player was banned' ... }
--- @tparam table args a table which contains everything that the embedded will use
+-- @tparam table table args a which contains everything that the embedded will use
-- @see EmitEmbededParamaters
function Sync.emit_embedded(args)
if not is_type(args,'table') then error('Args table not given to Sync.emit_embedded',2) end
@@ -282,7 +282,7 @@ end
--- Adds a callback to be called when the info is updated
-- @usage Sync.add_update('players',function() return #game.players end)
-- @tparam string key the key that the value will be stored in
--- @tparam function callback the function which will return this value
+-- @tparam function function callback the 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
diff --git a/utils/gui.lua b/utils/gui.lua
index 8a765dff..8f1427aa 100644
--- a/utils/gui.lua
+++ b/utils/gui.lua
@@ -192,7 +192,7 @@ end
--- Returns the flow where top elements can be added and will be effected by google visibility
-- For the toggle to work it must be registed with Gui.allow_player_to_toggle_top_element_visibility(element_name)
--- @tparam player LuaPlayer pointer to the player who has the gui
+-- @tparam LuaPlayer player pointer to the player who has the gui
-- @treturn LuaGuiEelement the top element flow
function Gui.get_top_element_flow(player)
player = Game.get_player_from_any(player)
From 801f942d2914d33a68c7e2adb34f8a2843882b91 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Wed, 29 May 2019 22:28:53 +0100
Subject: [PATCH 32/41] Renamed Public to Common
---
doc/index.html | 6 +-
doc/modules/Commands.html | 4 +-
doc/modules/{Public.html => Common.html} | 6 +-
doc/modules/Permissions_Groups.html | 4 +-
doc/modules/config._file_loader.html | 4 +-
doc/modules/config.action_buttons.html | 4 +-
doc/modules/config.advanced_start.html | 4 +-
doc/modules/config.death_logger.html | 4 +-
.../config.expcore-commands.auth_admin.html | 4 +-
.../config.expcore-commands.auth_roles.html | 4 +-
...expcore-commands.auth_runtime_disable.html | 4 +-
...config.expcore-commands.parse_general.html | 4 +-
.../config.expcore-commands.parse_roles.html | 4 +-
doc/modules/config.permission_groups.html | 4 +-
doc/modules/config.popup_messages.html | 4 +-
doc/modules/config.rockets.html | 4 +-
doc/modules/config.roles.html | 4 +-
doc/modules/config.scorched_earth.html | 4 +-
doc/modules/config.spawn_area.html | 4 +-
doc/modules/config.warnings.html | 4 +-
doc/modules/control.html | 4 +-
doc/modules/expcore.gui.buttons.html | 4 +-
doc/modules/expcore.gui.center.html | 4 +-
doc/modules/expcore.gui.checkboxs.html | 4 +-
doc/modules/expcore.gui.core.html | 4 +-
doc/modules/expcore.gui.dropdown.html | 4 +-
doc/modules/expcore.gui.elem-button.html | 4 +-
doc/modules/expcore.gui.html | 4 +-
doc/modules/expcore.gui.instances.html | 4 +-
doc/modules/expcore.gui.left.html | 4 +-
doc/modules/expcore.gui.popups.html | 4 +-
doc/modules/expcore.gui.progress-bar.html | 4 +-
doc/modules/expcore.gui.slider.html | 4 +-
doc/modules/expcore.gui.test.html | 4 +-
doc/modules/expcore.gui.text.html | 4 +-
doc/modules/expcore.gui.toolbar.html | 4 +-
doc/modules/expcore.store.html | 4 +-
.../modules.addons.advanced-start.html | 4 +-
doc/modules/modules.addons.chat-popups.html | 4 +-
doc/modules/modules.addons.damage-popups.html | 4 +-
doc/modules/modules.gui.player-list.html | 4 +-
doc/modules/modules.gui.rocket-info.html | 4 +-
doc/modules/modules.gui.science-info.html | 4 +-
doc/modules/modules.gui.task-list.html | 4 +-
.../utils.alien_evolution_progress.html | 4 +-
doc/modules/utils.core.html | 4 +-
doc/modules/utils.debug.html | 4 +-
doc/modules/utils.event.html | 4 +-
doc/modules/utils.event_core.html | 4 +-
doc/modules/utils.math.html | 4 +-
doc/modules/utils.recipe_locker.html | 4 +-
doc/modules/utils.state_machine.html | 4 +-
doc/modules/utils.table.html | 4 +-
doc/modules/utils.task.html | 4 +-
doc/modules/utils.timestamp.html | 4 +-
expcore/common.lua | 124 +++++++++---------
56 files changed, 174 insertions(+), 174 deletions(-)
rename doc/modules/{Public.html => Common.html} (99%)
diff --git a/doc/index.html b/doc/index.html
index d67b00a1..953f2c7e 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -49,7 +49,7 @@