diff --git a/config/_file_loader.lua b/config/_file_loader.lua index c4a5bba6..ab0c84e4 100644 --- a/config/_file_loader.lua +++ b/config/_file_loader.lua @@ -39,17 +39,17 @@ return { 'modules.addons.discord-alerts', 'modules.addons.chat-reply', -- GUI - 'modules.gui.rocket-info', - 'modules.gui.science-info', - 'modules.gui.warp-list', - 'modules.gui.task-list', - 'modules.gui.player-list', - 'modules.commands.debug', + --'modules.gui.rocket-info', + --'modules.gui.science-info', + --'modules.gui.warp-list', + --'modules.gui.task-list', + --'modules.gui.player-list', + --'modules.commands.debug', -- Config Files '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' -- loads multiple gui defines to test the gui system + --'expcore.gui.test' -- loads multiple gui defines to test the gui system } \ No newline at end of file diff --git a/docs/addons/Advanced-Start.html b/docs/addons/Advanced-Start.html index 0b56fc11..b51f20a5 100644 --- a/docs/addons/Advanced-Start.html +++ b/docs/addons/Advanced-Start.html @@ -348,7 +348,7 @@ generated by LDoc
diff --git a/docs/addons/Chat-Popups.html b/docs/addons/Chat-Popups.html index 75114dcc..fdb6a24b 100644 --- a/docs/addons/Chat-Popups.html +++ b/docs/addons/Chat-Popups.html @@ -349,7 +349,7 @@ generated by LDoc diff --git a/docs/addons/Chat-Reply.html b/docs/addons/Chat-Reply.html index be18394a..91b5fa1d 100644 --- a/docs/addons/Chat-Reply.html +++ b/docs/addons/Chat-Reply.html @@ -376,7 +376,7 @@ generated by LDoc diff --git a/docs/addons/Compilatron.html b/docs/addons/Compilatron.html index 3ad91922..889058f8 100644 --- a/docs/addons/Compilatron.html +++ b/docs/addons/Compilatron.html @@ -585,7 +585,7 @@ generated by LDoc diff --git a/docs/addons/Damage-Popups.html b/docs/addons/Damage-Popups.html index 42cd4094..99fe3f44 100644 --- a/docs/addons/Damage-Popups.html +++ b/docs/addons/Damage-Popups.html @@ -349,7 +349,7 @@ generated by LDoc diff --git a/docs/addons/Death-Logger.html b/docs/addons/Death-Logger.html index 01b1f797..590c7e4b 100644 --- a/docs/addons/Death-Logger.html +++ b/docs/addons/Death-Logger.html @@ -404,7 +404,7 @@ generated by LDoc diff --git a/docs/addons/Discord-Alerts.html b/docs/addons/Discord-Alerts.html index cce518e8..3e22e16a 100644 --- a/docs/addons/Discord-Alerts.html +++ b/docs/addons/Discord-Alerts.html @@ -460,7 +460,7 @@ generated by LDoc diff --git a/docs/addons/Player-Colours.html b/docs/addons/Player-Colours.html index d17bb676..94b6590b 100644 --- a/docs/addons/Player-Colours.html +++ b/docs/addons/Player-Colours.html @@ -404,7 +404,7 @@ generated by LDoc diff --git a/docs/addons/Pollution-Grading.html b/docs/addons/Pollution-Grading.html index bfc08f0d..ed128319 100644 --- a/docs/addons/Pollution-Grading.html +++ b/docs/addons/Pollution-Grading.html @@ -320,7 +320,7 @@ generated by LDoc diff --git a/docs/addons/Scorched-Earth.html b/docs/addons/Scorched-Earth.html index 09d37fe9..16ca5e5a 100644 --- a/docs/addons/Scorched-Earth.html +++ b/docs/addons/Scorched-Earth.html @@ -404,7 +404,7 @@ generated by LDoc diff --git a/docs/addons/Spawn-Area.html b/docs/addons/Spawn-Area.html index 3ba5ee0d..d708d75a 100644 --- a/docs/addons/Spawn-Area.html +++ b/docs/addons/Spawn-Area.html @@ -376,7 +376,7 @@ generated by LDoc diff --git a/docs/commands/Admin-Chat.html b/docs/commands/Admin-Chat.html index e8b3303d..7dc05f4a 100644 --- a/docs/commands/Admin-Chat.html +++ b/docs/commands/Admin-Chat.html @@ -388,7 +388,7 @@ generated by LDoc diff --git a/docs/commands/Bonus.html b/docs/commands/Bonus.html index 4b41076e..58ab06cc 100644 --- a/docs/commands/Bonus.html +++ b/docs/commands/Bonus.html @@ -500,7 +500,7 @@ generated by LDoc diff --git a/docs/commands/Cheat-Mode.html b/docs/commands/Cheat-Mode.html index cb0d0a09..6873b6fd 100644 --- a/docs/commands/Cheat-Mode.html +++ b/docs/commands/Cheat-Mode.html @@ -361,7 +361,7 @@ generated by LDoc diff --git a/docs/commands/Clear-Inventory.html b/docs/commands/Clear-Inventory.html index 27f45940..c280d9eb 100644 --- a/docs/commands/Clear-Inventory.html +++ b/docs/commands/Clear-Inventory.html @@ -388,7 +388,7 @@ generated by LDoc diff --git a/docs/commands/Debug.html b/docs/commands/Debug.html index e2f78d24..6ebb7007 100644 --- a/docs/commands/Debug.html +++ b/docs/commands/Debug.html @@ -365,7 +365,7 @@ generated by LDoc diff --git a/docs/commands/Find.html b/docs/commands/Find.html index c727cd0e..e2cd0dcc 100644 --- a/docs/commands/Find.html +++ b/docs/commands/Find.html @@ -360,7 +360,7 @@ generated by LDoc diff --git a/docs/commands/Help.html b/docs/commands/Help.html index d5178346..cece090c 100644 --- a/docs/commands/Help.html +++ b/docs/commands/Help.html @@ -404,7 +404,7 @@ generated by LDoc diff --git a/docs/commands/Home.html b/docs/commands/Home.html index a1ba8bce..3c7a8205 100644 --- a/docs/commands/Home.html +++ b/docs/commands/Home.html @@ -458,7 +458,7 @@ generated by LDoc diff --git a/docs/commands/Interface.html b/docs/commands/Interface.html index c38850c0..bba2600b 100644 --- a/docs/commands/Interface.html +++ b/docs/commands/Interface.html @@ -416,7 +416,7 @@ generated by LDoc diff --git a/docs/commands/Jail.html b/docs/commands/Jail.html index 2f087f4c..43f5e5e8 100644 --- a/docs/commands/Jail.html +++ b/docs/commands/Jail.html @@ -611,7 +611,7 @@ generated by LDoc diff --git a/docs/commands/Kill.html b/docs/commands/Kill.html index 33cd787e..fa88b477 100644 --- a/docs/commands/Kill.html +++ b/docs/commands/Kill.html @@ -389,7 +389,7 @@ generated by LDoc diff --git a/docs/commands/Me.html b/docs/commands/Me.html index ee42acca..6865f47d 100644 --- a/docs/commands/Me.html +++ b/docs/commands/Me.html @@ -360,7 +360,7 @@ generated by LDoc diff --git a/docs/commands/Rainbow.html b/docs/commands/Rainbow.html index b7f2a851..4a57c50a 100644 --- a/docs/commands/Rainbow.html +++ b/docs/commands/Rainbow.html @@ -388,7 +388,7 @@ generated by LDoc diff --git a/docs/commands/Repair.html b/docs/commands/Repair.html index 19e506ca..0bce4305 100644 --- a/docs/commands/Repair.html +++ b/docs/commands/Repair.html @@ -321,7 +321,7 @@ generated by LDoc diff --git a/docs/commands/Reports.html b/docs/commands/Reports.html index c0f17772..cfe0a159 100644 --- a/docs/commands/Reports.html +++ b/docs/commands/Reports.html @@ -585,7 +585,7 @@ generated by LDoc diff --git a/docs/commands/Roles.html b/docs/commands/Roles.html index d9a1f285..cc0ee869 100644 --- a/docs/commands/Roles.html +++ b/docs/commands/Roles.html @@ -557,7 +557,7 @@ generated by LDoc diff --git a/docs/commands/Spawn.html b/docs/commands/Spawn.html index bb58d8a9..859247a4 100644 --- a/docs/commands/Spawn.html +++ b/docs/commands/Spawn.html @@ -389,7 +389,7 @@ generated by LDoc diff --git a/docs/commands/Tag.html b/docs/commands/Tag.html index 43fab495..dfdcbf48 100644 --- a/docs/commands/Tag.html +++ b/docs/commands/Tag.html @@ -443,7 +443,7 @@ generated by LDoc diff --git a/docs/commands/Teleport.html b/docs/commands/Teleport.html index 42089cc1..1848f1a0 100644 --- a/docs/commands/Teleport.html +++ b/docs/commands/Teleport.html @@ -484,7 +484,7 @@ generated by LDoc diff --git a/docs/commands/Warnings.html b/docs/commands/Warnings.html index 0bb7d855..eb9dd3ff 100644 --- a/docs/commands/Warnings.html +++ b/docs/commands/Warnings.html @@ -569,7 +569,7 @@ generated by LDoc diff --git a/docs/config.ld b/docs/config.ld index f5a7a308..7573fa6d 100644 --- a/docs/config.ld +++ b/docs/config.ld @@ -1,5 +1,5 @@ file = '../' -dir = '../doc' +dir = '../docs' project = 'ExpGaming Scenario' title = 'ExpGaming Scenario' description = 'Explosive Gaming\'s server scenario for 0.17' @@ -10,8 +10,8 @@ not_luadoc = true no_lua_ref = true template_escape = ">" topics = {"../README.md", "../LICENSE"} -style = '../doc' -template = '../doc' +style = '../docs' +template = '../docs' no_space_before_args = true merge=true diff --git a/docs/configs/Advanced-Start.html b/docs/configs/Advanced-Start.html index 46ef69a1..0c5783c8 100644 --- a/docs/configs/Advanced-Start.html +++ b/docs/configs/Advanced-Start.html @@ -506,7 +506,7 @@ generated by LDoc diff --git a/docs/configs/Bonuses.html b/docs/configs/Bonuses.html index e1806bce..52c1dcc5 100644 --- a/docs/configs/Bonuses.html +++ b/docs/configs/Bonuses.html @@ -237,7 +237,7 @@ generated by LDoc diff --git a/docs/configs/Chat-Reply.html b/docs/configs/Chat-Reply.html index c8ef6dfa..6594a2c5 100644 --- a/docs/configs/Chat-Reply.html +++ b/docs/configs/Chat-Reply.html @@ -485,7 +485,7 @@ generated by LDoc diff --git a/docs/configs/Commands-Auth-Admin.html b/docs/configs/Commands-Auth-Admin.html index ffc290aa..d02099b4 100644 --- a/docs/configs/Commands-Auth-Admin.html +++ b/docs/configs/Commands-Auth-Admin.html @@ -294,7 +294,7 @@ generated by LDoc diff --git a/docs/configs/Commands-Auth-Roles.html b/docs/configs/Commands-Auth-Roles.html index 1f3c18d9..45cda632 100644 --- a/docs/configs/Commands-Auth-Roles.html +++ b/docs/configs/Commands-Auth-Roles.html @@ -320,7 +320,7 @@ generated by LDoc diff --git a/docs/configs/Commands-Auth-Runtime-Disable.html b/docs/configs/Commands-Auth-Runtime-Disable.html index f68dc361..1e2b5098 100644 --- a/docs/configs/Commands-Auth-Runtime-Disable.html +++ b/docs/configs/Commands-Auth-Runtime-Disable.html @@ -442,7 +442,7 @@ generated by LDoc diff --git a/docs/configs/Commands-Parse-Roles.html b/docs/configs/Commands-Parse-Roles.html index d18424fa..47d2034e 100644 --- a/docs/configs/Commands-Parse-Roles.html +++ b/docs/configs/Commands-Parse-Roles.html @@ -354,7 +354,7 @@ generated by LDoc diff --git a/docs/configs/Commands-Parse.html b/docs/configs/Commands-Parse.html index 2f413722..a1895ddb 100644 --- a/docs/configs/Commands-Parse.html +++ b/docs/configs/Commands-Parse.html @@ -338,7 +338,7 @@ see ./expcore/commands.lua for more details generated by LDoc diff --git a/docs/configs/Compilatron.html b/docs/configs/Compilatron.html index 5bf4b1ba..64adcfc4 100644 --- a/docs/configs/Compilatron.html +++ b/docs/configs/Compilatron.html @@ -354,7 +354,7 @@ generated by LDoc diff --git a/docs/configs/Death-Logger.html b/docs/configs/Death-Logger.html index 76aec8f5..74805d6c 100644 --- a/docs/configs/Death-Logger.html +++ b/docs/configs/Death-Logger.html @@ -416,7 +416,7 @@ generated by LDoc diff --git a/docs/configs/Discord-Alerts.html b/docs/configs/Discord-Alerts.html index 03ca2c6d..07cba503 100644 --- a/docs/configs/Discord-Alerts.html +++ b/docs/configs/Discord-Alerts.html @@ -237,7 +237,7 @@ generated by LDoc diff --git a/docs/configs/File-Loader.html b/docs/configs/File-Loader.html index 58c755b1..58ae563e 100644 --- a/docs/configs/File-Loader.html +++ b/docs/configs/File-Loader.html @@ -240,7 +240,7 @@ generated by LDoc diff --git a/docs/configs/Permission-Groups.html b/docs/configs/Permission-Groups.html index 7043ae72..87281de1 100644 --- a/docs/configs/Permission-Groups.html +++ b/docs/configs/Permission-Groups.html @@ -295,7 +295,7 @@ generated by LDoc diff --git a/docs/configs/Player-List.html b/docs/configs/Player-List.html index c6e1c748..a64923b7 100644 --- a/docs/configs/Player-List.html +++ b/docs/configs/Player-List.html @@ -812,7 +812,7 @@ generated by LDoc diff --git a/docs/configs/Pollution-Grading.html b/docs/configs/Pollution-Grading.html index 9eb9892f..bb836f8f 100644 --- a/docs/configs/Pollution-Grading.html +++ b/docs/configs/Pollution-Grading.html @@ -384,7 +384,7 @@ generated by LDoc diff --git a/docs/configs/Popup-Messages.html b/docs/configs/Popup-Messages.html index 39690dd2..8834a58c 100644 --- a/docs/configs/Popup-Messages.html +++ b/docs/configs/Popup-Messages.html @@ -414,7 +414,7 @@ generated by LDoc diff --git a/docs/configs/Preset-Player-Colours.html b/docs/configs/Preset-Player-Colours.html index 9d37a9a8..d5e06589 100644 --- a/docs/configs/Preset-Player-Colours.html +++ b/docs/configs/Preset-Player-Colours.html @@ -324,7 +324,7 @@ generated by LDoc diff --git a/docs/configs/Repair.html b/docs/configs/Repair.html index 8625da88..741a2beb 100644 --- a/docs/configs/Repair.html +++ b/docs/configs/Repair.html @@ -414,7 +414,7 @@ generated by LDoc diff --git a/docs/configs/Rockets.html b/docs/configs/Rockets.html index 9be2580d..35e5d51b 100644 --- a/docs/configs/Rockets.html +++ b/docs/configs/Rockets.html @@ -834,7 +834,7 @@ generated by LDoc diff --git a/docs/configs/Roles.html b/docs/configs/Roles.html index c1aebec6..2fc9736f 100644 --- a/docs/configs/Roles.html +++ b/docs/configs/Roles.html @@ -292,7 +292,7 @@ generated by LDoc diff --git a/docs/configs/Science.html b/docs/configs/Science.html index d279267e..65bcb95e 100644 --- a/docs/configs/Science.html +++ b/docs/configs/Science.html @@ -354,7 +354,7 @@ generated by LDoc diff --git a/docs/configs/Scorched-Earth.html b/docs/configs/Scorched-Earth.html index 508bde53..9de50ddf 100644 --- a/docs/configs/Scorched-Earth.html +++ b/docs/configs/Scorched-Earth.html @@ -388,7 +388,7 @@ generated by LDoc diff --git a/docs/configs/Spawn-Area.html b/docs/configs/Spawn-Area.html index 9b9a9a5a..d72010dc 100644 --- a/docs/configs/Spawn-Area.html +++ b/docs/configs/Spawn-Area.html @@ -744,7 +744,7 @@ generated by LDoc diff --git a/docs/configs/Tasks.html b/docs/configs/Tasks.html index 6072ae03..50107b1f 100644 --- a/docs/configs/Tasks.html +++ b/docs/configs/Tasks.html @@ -384,7 +384,7 @@ generated by LDoc diff --git a/docs/configs/Warnings.html b/docs/configs/Warnings.html index f3edf5aa..d02fb163 100644 --- a/docs/configs/Warnings.html +++ b/docs/configs/Warnings.html @@ -355,7 +355,7 @@ generated by LDoc diff --git a/docs/configs/Warps.html b/docs/configs/Warps.html index 8800c822..76a67c3e 100644 --- a/docs/configs/Warps.html +++ b/docs/configs/Warps.html @@ -684,7 +684,7 @@ generated by LDoc diff --git a/docs/control/Jail.html b/docs/control/Jail.html index 5f68c34b..8bf0dabd 100644 --- a/docs/control/Jail.html +++ b/docs/control/Jail.html @@ -1208,7 +1208,7 @@ generated by LDoc diff --git a/docs/control/Production.html b/docs/control/Production.html index ccfd8f5f..48c4e2d0 100644 --- a/docs/control/Production.html +++ b/docs/control/Production.html @@ -1329,7 +1329,7 @@ generated by LDoc diff --git a/docs/control/Reports.html b/docs/control/Reports.html index ddcdfb3e..ec69b942 100644 --- a/docs/control/Reports.html +++ b/docs/control/Reports.html @@ -1110,7 +1110,7 @@ generated by LDoc diff --git a/docs/control/Rockets.html b/docs/control/Rockets.html index 431f9815..cc03876e 100644 --- a/docs/control/Rockets.html +++ b/docs/control/Rockets.html @@ -984,7 +984,7 @@ generated by LDoc diff --git a/docs/control/Tasks.html b/docs/control/Tasks.html index 7fa706cc..c4ff0bac 100644 --- a/docs/control/Tasks.html +++ b/docs/control/Tasks.html @@ -1039,7 +1039,7 @@ generated by LDoc diff --git a/docs/control/Warnings.html b/docs/control/Warnings.html index c1ac81e7..09e669fd 100644 --- a/docs/control/Warnings.html +++ b/docs/control/Warnings.html @@ -1465,7 +1465,7 @@ generated by LDoc diff --git a/docs/control/Warps.html b/docs/control/Warps.html index 5fa18a14..1edc8de5 100644 --- a/docs/control/Warps.html +++ b/docs/control/Warps.html @@ -1413,7 +1413,7 @@ generated by LDoc diff --git a/docs/core/Commands.html b/docs/core/Commands.html index 683bf908..652d0f97 100644 --- a/docs/core/Commands.html +++ b/docs/core/Commands.html @@ -1972,7 +1972,7 @@ generated by LDoc diff --git a/docs/core/Common-Library.html b/docs/core/Common-Library.html index 44c6136e..f5b36e19 100644 --- a/docs/core/Common-Library.html +++ b/docs/core/Common-Library.html @@ -357,6 +357,10 @@Returns a desync safe file path for the current file
+ + + + Parameters: + +
----- Basic Use
- -- At the most basic level this allows for the naming of locations to store in the global table, the second feature is that you are
- -- able to listen for updates of this value, which means that when ever the set function is called it will trigger the update callback.
-
- -- This may be useful when storing config values and when they get set you want to make sure it is taken care of, or maybe you want
- -- to have a value that you can trigger an update of from different places.
-
- -- This will register a new location called 'scenario.difficulty'
- -- note that setting a start value is optional and we could take nil to mean normal
- Store.register('scenario.difficulty',function(value)
- game.print('The scenario difficulty has be set to: '..value)
- end)
+-- The data store module is designed to be an alterative way to store data in the global table
+-- each piece of data is stored at a location and optional key of that location
+-- it is recomented that you use a local varible to store the location
+local scenario_difficuly = Store.uid_location()
+local team_scores = 'team-scores'
- -- This will set the value in the store to 'hard' and will trigger the update callback which will print a message to the game
- Store.set('scenario.difficulty','hard')
+-- Setting and getting data is then as simple as
+Store.set(scenario_difficuly,'Hard')
+Store.set(team_scores,game.player.force.name,20)
- -- This will return 'hard'
- Store.get('scenario.difficulty')
-
----- Using Children
- -- One limitation of store is that all locations must be registered to avoid desyncs, to get round this issue "children" can be used.
- -- When you set the value of a child it does not have its own update callback so rather the "parent" location which has been registered
- -- will have its update value called with a second param of the name of that child.
+Store.get(scenario_difficuly) -- returns 'Hard'
+Store.get(team_scores,game.player.force.name) -- returns 20
- -- This may be useful when you want a value of each player or force and since you cant register every player at the start you must use
- -- the players name as the child name.
-
- -- This will register the location 'scenario.score' where we plan to use force names as the child
- Store.register('scenario.score',function(value,child)
- game.print(child..' now has a score of '..value)
- end)
+-- The reason for using stores over global is the abilty to watch for updates
+-- for stores to work you must register them, often at the end of the file
+-- note that storing a table value may cause issues as a key changing does not cause the set function to trigger
+Store.register(scenario_difficuly,function(value)
+ game.print('Scenario difficulty has been set to: '..value)
+end)
- -- This will return nil, but will not error as children don't need to be registered
- Store.get('scenario.score','player')
+Store.register(team_scores,function(value,key)
+ game.print('Team '..key..' now has a score of '..value)
+end)
- -- This will set 'player' to have a value of 10 for 'scenario.score' and trigger the game message print
- Store.set('scenario.score','player',10)
-
- -- This would be the similar to Store.get however this will return the names of all the children
- Store.get_children('scenario.score')
-
----- Using Sync
- -- There is the option to use synced values which is the same as a normal value however you can combine this with an external script
- -- which can read the output from 'script-output/log/store.log' and have it send rcon commands back to the game allowing for cross instance
- -- syncing of values.
-
- -- This may be useful when you want to have a value change effect multiple instances or even if you just want a database to store values so
- -- you can sync data between map resets.
-
- -- This example will register the location 'statistics.total-play-time' where we plan to use plan names as the child
- -- note that the location must be the same across instances
- Store.register('statistics.total-play-time',true,function(value,child)
- game.print(child..' now has now played for '..value)
- end)
-
- -- Use of set and are all the same as non synced but you should include from_sync as true
-
-
----- Alternative method
- -- Some people may prefer to use a variable rather than a string for formating reasons here is an example. Also for any times when
- -- there will be little external input Store.uid_location() can be used to generate non conflicting locations, uid_location will also
- -- be used if you give a nil location.
-
- local store_game_speed =
- Store.register(function(value)
- game.print('The game speed has been set to: '..value)
- end)
+-- This can be very powerful when working with data that can be changed for a number of locations
+-- with this module you can enable any location to output its changes to a file
+-- say we wanted team scores to be synced across servers or between saves
+-- although you will need to set up a method of storing the data outside the game
+Store.register(team_scores,true,function(value,key)
+ game.print('Team '..key..' now has a score of '..value)
+end)
@@ -333,33 +297,37 @@
Registers a new location with an update callback which is triggered when the value updates
+ + + + Parameters: + +Gets the value stored at a location, this location must be registered
+ + + + Parameters: + +Sets the value at a location, this location must be registered
+ + + + Parameters: + +Triggers the change handler manually
+ + + + Parameters: + +Sets the value at a location to nil, this location must be registered
+ + + + Parameters: + +Gets all non nil keys at a location, keys 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: + +Registers a new location with an update callback which is triggered when the value updates
- - - - Parameters: - -Gets the value stored at a location, this location must be registered
- - - - Parameters: - -Sets the value at a location, this location must be registered
- - - - Parameters: - -Sets the value at a location to nil, this location must be registered
- - - - Parameters: - -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: - -## Releases
| Scenario Version* | Version Name | Factorio Version** | |---|---|---| -| [v5.7][s5.8] | Home and Chat Bot | [v0.17.47][f0.17.49] | +| [v5.9][s5.9] | Control Modules and Documentation | [v0.17.63][f0.17.63] | +| [v5.8][s5.8] | Home and Chat Bot | [v0.17.47][f0.17.49] | | [v5.7][s5.7] | Warp System | [v0.17.47][f0.17.47] | | [v5.6][s5.6] | Information Guis | [v0.17.44][f0.17.44] | | [v5.5][s5.5] | Gui System | [v0.17.43][f0.17.43] | @@ -264,7 +265,8 @@ | [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.8]: https://github.com/explosivegaming/scenario/releases/tag/5.8.0 +
[s5.9]: https://github.com/explosivegaming/scenario/releases/tag/5.9.0 +[s5.8]: https://github.com/explosivegaming/scenario/releases/tag/5.8.0 [s5.7]: https://github.com/explosivegaming/scenario/releases/tag/5.7.0 [s5.6]: https://github.com/explosivegaming/scenario/releases/tag/5.6.0 [s5.5]: https://github.com/explosivegaming/scenario/releases/tag/5.5.0 @@ -278,7 +280,8 @@ [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.49]: https://wiki.factorio.com/Version_history/0.17.0#0.17.49 +
[f0.17.63]: https://wiki.factorio.com/Version_history/0.17.0#0.17.63 +[f0.17.49]: https://wiki.factorio.com/Version_history/0.17.0#0.17.49 [f0.17.47]: https://wiki.factorio.com/Version_history/0.17.0#0.17.47 [f0.17.44]: https://wiki.factorio.com/Version_history/0.17.0#0.17.44 [f0.17.43]: https://wiki.factorio.com/Version_history/0.17.0#0.17.43 @@ -329,7 +332,7 @@ generated by LDoc
diff --git a/expcore/common.lua b/expcore/common.lua index 19cd711b..8efb7d1b 100644 --- a/expcore/common.lua +++ b/expcore/common.lua @@ -611,4 +611,12 @@ function Common.format_chat_player_name(player,raw_string) end end +--- Returns a desync safe file path for the current file +-- @tparam[opt=0] number offset the offset in the stack to get, 0 is current file +-- @treturn string the file path +function Common.get_file_path(offset) + offset = offset or 0 + return debug.getinfo(offset+2, 'S').source:match('^.+/currently%-playing/(.+)$'):sub(1, -5) +end + return Common \ No newline at end of file diff --git a/expcore/gui/test.lua b/expcore/gui/test.lua index 2e25c61b..38319c3f 100644 --- a/expcore/gui/test.lua +++ b/expcore/gui/test.lua @@ -650,7 +650,7 @@ end) Event.add(defines.events.on_tick,function() progressbar_one:increment() progressbar_three:decrement() - local categories = Store.get_children(progressbar_two.store) + local categories = Store.get_keys(progressbar_two.store) for _,category in pairs(categories) do progressbar_two:increment(1,category) end diff --git a/expcore/store.lua b/expcore/store.lua index 83d2ed26..6bc00f4b 100644 --- a/expcore/store.lua +++ b/expcore/store.lua @@ -4,119 +4,68 @@ @alias Store @usage ----- Basic Use - -- At the most basic level this allows for the naming of locations to store in the global table, the second feature is that you are - -- able to listen for updates of this value, which means that when ever the set function is called it will trigger the update callback. +-- The data store module is designed to be an alterative way to store data in the global table +-- each piece of data is stored at a location and optional key of that location +-- it is recomented that you use a local varible to store the location +local scenario_difficuly = Store.uid_location() +local team_scores = 'team-scores' - -- This may be useful when storing config values and when they get set you want to make sure it is taken care of, or maybe you want - -- to have a value that you can trigger an update of from different places. +-- Setting and getting data is then as simple as +Store.set(scenario_difficuly,'Hard') +Store.set(team_scores,game.player.force.name,20) - -- This will register a new location called 'scenario.difficulty' - -- note that setting a start value is optional and we could take nil to mean normal - Store.register('scenario.difficulty',function(value) - game.print('The scenario difficulty has be set to: '..value) - end) +Store.get(scenario_difficuly) -- returns 'Hard' +Store.get(team_scores,game.player.force.name) -- returns 20 - -- This will set the value in the store to 'hard' and will trigger the update callback which will print a message to the game - Store.set('scenario.difficulty','hard') +-- The reason for using stores over global is the abilty to watch for updates +-- for stores to work you must register them, often at the end of the file +-- note that storing a table value may cause issues as a key changing does not cause the set function to trigger +Store.register(scenario_difficuly,function(value) + game.print('Scenario difficulty has been set to: '..value) +end) - -- This will return 'hard' - Store.get('scenario.difficulty') +Store.register(team_scores,function(value,key) + game.print('Team '..key..' now has a score of '..value) +end) - @usage ----- Using Children - -- One limitation of store is that all locations must be registered to avoid desyncs, to get round this issue "children" can be used. - -- When you set the value of a child it does not have its own update callback so rather the "parent" location which has been registered - -- will have its update value called with a second param of the name of that child. - - -- This may be useful when you want a value of each player or force and since you cant register every player at the start you must use - -- the players name as the child name. - - -- This will register the location 'scenario.score' where we plan to use force names as the child - Store.register('scenario.score',function(value,child) - game.print(child..' now has a score of '..value) - end) - - -- This will return nil, but will not error as children don't need to be registered - Store.get('scenario.score','player') - - -- This will set 'player' to have a value of 10 for 'scenario.score' and trigger the game message print - Store.set('scenario.score','player',10) - - -- This would be the similar to Store.get however this will return the names of all the children - Store.get_children('scenario.score') - - @usage ----- Using Sync - -- There is the option to use synced values which is the same as a normal value however you can combine this with an external script - -- which can read the output from 'script-output/log/store.log' and have it send rcon commands back to the game allowing for cross instance - -- syncing of values. - - -- This may be useful when you want to have a value change effect multiple instances or even if you just want a database to store values so - -- you can sync data between map resets. - - -- This example will register the location 'statistics.total-play-time' where we plan to use plan names as the child - -- note that the location must be the same across instances - Store.register('statistics.total-play-time',true,function(value,child) - game.print(child..' now has now played for '..value) - end) - - -- Use of set and are all the same as non synced but you should include from_sync as true - - @usage ----- Alternative method - -- Some people may prefer to use a variable rather than a string for formating reasons here is an example. Also for any times when - -- there will be little external input Store.uid_location() can be used to generate non conflicting locations, uid_location will also - -- be used if you give a nil location. - - local store_game_speed = - Store.register(function(value) - game.print('The game speed has been set to: '..value) - end) +-- This can be very powerful when working with data that can be changed for a number of locations +-- with this module you can enable any location to output its changes to a file +-- say we wanted team scores to be synced across servers or between saves +-- although you will need to set up a method of storing the data outside the game +Store.register(team_scores,true,function(value,key) + game.print('Team '..key..' now has a score of '..value) +end) ]] local Global = require 'utils.global' --- @dep utils.global local Event = require 'utils.event' --- @dep utils.event -local table_keys,write_json = ext_require('expcore.common','table_keys','write_json') --- @dep expcore.common +local table_keys,write_json,get_file_path = ext_require('expcore.common','table_keys','write_json','get_file_path') --- @dep expcore.common local Token = require 'utils.token' --- @dep utils.token local Store = { - data={}, registered={}, synced={}, callbacks={}, events = { - on_value_update=script.generate_event_name() + on_value_changed=script.generate_event_name() } } +local store_data = {} Global.register(Store.data,function(tbl) - Store.data = tbl + store_data = tbl end) local function error_not_table(value) if type(value) ~= 'table' then - error('Location is not a table can not use child locations',3) + error('Location is not a table can not use key locations',3) end end ---- Check for if a location is registered --- @tparam string location the location to test for --- @treturn boolean true if registered -function Store.is_registered(location) - return Store.registered[location] -end - ---- Returns a unique name that can be used for a store --- @treturn string a unique name -function Store.uid_location() - return tostring(Token.uid()) -end - --- Registers a new location with an update callback which is triggered when the value updates -- @tparam[opt] string location string a unique that points to the data, string used rather than token to allow migration --- @tparam[opt] boolean synced when true will output changes to a file so it can be synced +-- @tparam[opt=false] boolean synced when true will output changes to a file so it can be synced -- @tparam[opt] function callback when given the callback will be automatically registered to the update of the value -- @treturn string the location that is being used function Store.register(location,synced,callback) @@ -136,10 +85,10 @@ function Store.register(location,synced,callback) location = type(location) == 'string' and location or Store.uid_location() if Store.registered[location] then - return error('Location is already registered', 2) + return error('Location '..location..' is already registered by '..Store.registered[location], 2) end - Store.registered[location] = true + Store.registered[location] = get_file_path(1) Store.synced[location] = synced and true or nil Store.callbacks[location] = callback or nil @@ -148,18 +97,17 @@ end --- Gets the value stored at a location, this location must be registered -- @tparam string location the location to get the data from --- @tparam[opt] string child the child location if required --- @tparam[opt=false] boolean allow_unregistered when true no error is returned if the location is not registered +-- @tparam[opt] string key the key location if used -- @treturn any the data which was stored at the location -function Store.get(location,child,allow_unregistered) - if not Store.callbacks[location] and not allow_unregistered then +function Store.get(location,key) + if not Store.registered[location] then return error('Location is not registered', 2) end - local data = Store.data[location] - if child and data then + local data = store_data[location] + if key and data then error_not_table(data) - return data[child] + return data[key] end return data @@ -167,94 +115,120 @@ end --- Sets the value at a location, this location must be registered -- @tparam string location the location to set the data to --- @tparam[opt] string child the child location if required +-- @tparam[opt] string key the key location if used -- @tparam any value the new value to set at the location, value may be reverted if there is a watch callback, cant be nil --- @tparam[opt] boolean from_sync set this true to avoid an output to the sync file +-- @tparam[opt=false] boolean from_sync set this true to avoid an output to the sync file -- @treturn boolean true if it was successful -function Store.set(location,child,value,from_sync) +function Store.set(location,key,value,from_sync) if not Store.callbacks[location] then return error('Location is not registered', 2) end - if child == nil or value == nil then - value = child or value - child = nil + if key == nil or value == nil then + value = key or value + key = nil end - local data = Store.data - if child then - data = data[location] + if key then + local data = store_data[location] if not data then data = {} - Store.data[location] = data + store_data[location] = data end error_not_table(data) - data[child] = value + data[key] = value else - data[location] = value + store_data[location] = value end - script.raise_event(Store.events.on_value_update,{ + script.raise_event(Store.events.on_value_changed,{ tick=game.tick, location=location, - child=child, + key=key, value=value, - from_sync=from_sync + from_sync=from_sync or false }) return true end +--- Triggers the change handler manually +-- @tparam string location the location to set the data to +-- @tparam[opt] string key the key location if required +function Store.update(location,key) + local value = Store.get(location,key) + script.raise_event(Store.events.on_value_changed,{ + tick=game.tick, + location=location, + key=key, + value=value, + from_sync=false + }) +end + + --- Sets the value at a location to nil, this location must be registered -- @tparam string location the location to set the data to --- @tparam[opt] string child the child location if required --- @tparam[opt] boolean from_sync set this true to avoid an output to the sync file +-- @tparam[opt] string key the key location if used +-- @tparam[opt=false] boolean from_sync set this true to avoid an output to the sync file -- @treturn boolean true if it was successful -function Store.clear(location,child,from_sync) +function Store.clear(location,key,from_sync) if not Store.callbacks[location] then return error('Location is not registered', 2) end - local data = Store.data - if child then - data = data[location] + if key then + local data = store_data[location] if not data then return end error_not_table(data) - data[child] = nil + data[key] = nil else - data[location] = nil + store_data[location] = nil end - script.raise_event(Store.events.on_value_update,{ + script.raise_event(Store.events.on_value_changed,{ tick=game.tick, location=location, - child=child, - from_sync=from_sync + key=key, + from_sync=from_sync or false }) return true end ---- Gets all non nil children at a location, children can be added and removed during runtime +--- Gets all non nil keys at a location, keys 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 string location the location to get the children of --- @treturn table a table containing all the children names -function Store.get_children(location) +-- @tparam string location the location to get the keys of +-- @treturn table a table containing all the keys names +function Store.get_keys(location) local data = Store.get(location) return type(data) == 'table' and table_keys(data) or {} end +--- Check for if a location is registered +-- @tparam string location the location to test for +-- @treturn boolean true if registered +function Store.is_registered(location) + return Store.registered[location] +end + +--- Returns a unique name that can be used for a store +-- @treturn string a unique name +function Store.uid_location() + return tostring(Token.uid()) +end + -- Handles syncing -Event.add(Store.events.on_value_update,function(event) +Event.add(Store.events.on_value_changed,function(event) if Store.callbacks[event.location] then - Store.callbacks[event.location](event.value,event.child) + Store.callbacks[event.location](event.value,event.key) end if not event.from_sync and Store.synced[event.location] then write_json('log/store.log',{ tick=event.tick, location=event.location, - child=event.child, + key=event.key, value=event.value, }) end diff --git a/modules/commands/interface.lua b/modules/commands/interface.lua index 51b20ebf..cd6263b1 100644 --- a/modules/commands/interface.lua +++ b/modules/commands/interface.lua @@ -16,7 +16,7 @@ local interface_modules = { ['Group']='expcore.permission_groups', ['Roles']='expcore.roles', ['Store']='expcore.store', - ['Gui']='expcore.gui', + --['Gui']='expcore.gui', ['Sudo']='expcore.sudo' } diff --git a/modules/gui/warp-list.lua b/modules/gui/warp-list.lua index 4e06b335..9fb9e390 100644 --- a/modules/gui/warp-list.lua +++ b/modules/gui/warp-list.lua @@ -478,7 +478,7 @@ end) local r2 = config.activation_range^2 local rs2 = config.spawn_activation_range^2 Event.on_nth_tick(math.floor(60/config.update_smoothing),function() - local categories = Store.get_children(warp_timer.store) + local categories = Store.get_keys(warp_timer.store) for _,category in pairs(categories) do warp_timer:increment(1,category) end