From 0836375e0251a6ae1f249b7b822a15fa2a2f8dbe Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 28 May 2020 23:08:08 +0100 Subject: [PATCH] Added Alt View --- docs/config.ld | 1 + modules/data/alt-view.lua | 21 +++++++++++++++++++++ modules/data/bonus.lua | 6 ++---- modules/data/greetings.lua | 2 +- modules/data/player-colours.lua | 2 +- modules/data/quickbar.lua | 2 +- modules/data/tag.lua | 2 +- 7 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 modules/data/alt-view.lua diff --git a/docs/config.ld b/docs/config.ld index 30e23b4b..68c0c7a5 100644 --- a/docs/config.ld +++ b/docs/config.ld @@ -19,6 +19,7 @@ new_type("core", "Core", true) new_type("control", "Control", true) new_type("addon", "Addons", true) new_type("gui", "Guis", true) +new_type("data", "Data", true) new_type("commands", "Commands", true) new_type("config", "Configs", true, "Settings") diff --git a/modules/data/alt-view.lua b/modules/data/alt-view.lua new file mode 100644 index 00000000..83aca25a --- /dev/null +++ b/modules/data/alt-view.lua @@ -0,0 +1,21 @@ +--- Stores if you use alt mode or not and auto applies it +-- @data Alt-View + +local Event = require 'utils.event' ---@dep utils.event + +--- Stores the join message that the player have +local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data +local UsesAlt = PlayerData.Settings:combine('UsesAlt') +UsesAlt:set_default(false) + +--- When your data loads apply alt view if you have it enabled +UsesAlt:on_load(function(player_name, uses_alt) + local player = game.players[player_name] + player.game_view_settings.show_entity_info = uses_alt or false +end) + +--- When alt view is toggled update this +Event.add(defines.events.on_player_toggled_alt_mode, function(event) + local player = game.players[event.player_index] + UsesAlt:set(player, player.game_view_settings.show_entity_info) +end) \ No newline at end of file diff --git a/modules/data/bonus.lua b/modules/data/bonus.lua index 7bf686c5..6cf1752f 100644 --- a/modules/data/bonus.lua +++ b/modules/data/bonus.lua @@ -1,14 +1,12 @@ --[[-- Commands Module - Bonus - Adds a command that allows players to have increased stats - @commands Bonus + @data Bonus ]] -local Commands = require 'expcore.commands' --- @dep expcore.commands local Roles = require 'expcore.roles' --- @dep expcore.roles local Event = require 'utils.event' --- @dep utils.event -local Game = require 'utils.game' --- @dep utils.game -local Store = require 'expcore.store' --- @dep expcore.store local config = require 'config.bonuses' --- @dep config.bonuses +local Commands = require 'expcore.commands' --- @dep expcore.commands require 'config.expcore.command_general_parse' --- Stores the bonus for the player diff --git a/modules/data/greetings.lua b/modules/data/greetings.lua index 04a736cd..84def7e3 100644 --- a/modules/data/greetings.lua +++ b/modules/data/greetings.lua @@ -1,5 +1,5 @@ --- Greets players on join --- @addon greetings +-- @data Greetings local config = require 'config.join_messages' --- @dep config.join_messages local Commands = require 'expcore.commands' ---@dep expcore.commands diff --git a/modules/data/player-colours.lua b/modules/data/player-colours.lua index 74732d67..bed8012f 100644 --- a/modules/data/player-colours.lua +++ b/modules/data/player-colours.lua @@ -1,5 +1,5 @@ --- Gives players random colours when they join, also applies preset colours to those who have them --- @addon Player-Colours +-- @data Player-Colours local Event = require 'utils.event' --- @dep utils.event local Colours = require 'utils.color_presets' --- @dep utils.color_presets diff --git a/modules/data/quickbar.lua b/modules/data/quickbar.lua index 5c53f183..d2352a7f 100644 --- a/modules/data/quickbar.lua +++ b/modules/data/quickbar.lua @@ -1,6 +1,6 @@ --[[-- Commands Module - Quickbar - Adds a command that allows players to load Quickbar presets - @commands Quickbar + @data Quickbar ]] local Commands = require 'expcore.commands' --- @dep expcore.commands diff --git a/modules/data/tag.lua b/modules/data/tag.lua index 693d5346..644fc0f3 100644 --- a/modules/data/tag.lua +++ b/modules/data/tag.lua @@ -1,6 +1,6 @@ --[[-- Commands Module - Tag - Adds a command that allows players to have a custom tag after their name - @commands Tag + @data Tag ]] local Commands = require 'expcore.commands' --- @dep expcore.commands