From 5cc5546a05c7ddb4375151681729a7e9c5728c1d Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Sat, 29 Sep 2018 17:55:44 +0100 Subject: [PATCH] Added ExpGamingInfo --- modules/ExpGamingCore/Group/control.lua | 2 +- modules/ExpGamingCore/Role/control.lua | 2 +- .../readme.lua => Readme/control.lua} | 38 +++---- modules/ExpGamingInfo/Readme/softmod.json | 22 ++++ modules/ExpGamingInfo/Readme/src/sync.lua | 14 +++ modules/ExpGamingInfo/Rockets/control.lua | 103 +++++++++++++++++ modules/ExpGamingInfo/Rockets/softmod.json | 21 ++++ modules/ExpGamingInfo/Rockets/src/sync.lua | 20 ++++ modules/ExpGamingInfo/Science/control.lua | 103 +++++++++++++++++ modules/ExpGamingInfo/Science/softmod.json | 22 ++++ modules/ExpGamingInfo/Science/src/sync.lua | 18 +++ .../tasklist.lua => Tasklist/control.lua} | 46 +++++--- modules/ExpGamingInfo/Tasklist/softmod.json | 20 ++++ modules/ExpGamingInfo/softmod.json | 91 +++++++++++++++ modules/ExpGamingInfo/to convert/rockets.lua | 104 ------------------ modules/ExpGamingInfo/to convert/science.lua | 102 ----------------- modules/index.lua | 6 +- 17 files changed, 489 insertions(+), 245 deletions(-) rename modules/ExpGamingInfo/{to convert/readme.lua => Readme/control.lua} (77%) create mode 100644 modules/ExpGamingInfo/Readme/softmod.json create mode 100644 modules/ExpGamingInfo/Readme/src/sync.lua create mode 100644 modules/ExpGamingInfo/Rockets/control.lua create mode 100644 modules/ExpGamingInfo/Rockets/softmod.json create mode 100644 modules/ExpGamingInfo/Rockets/src/sync.lua create mode 100644 modules/ExpGamingInfo/Science/control.lua create mode 100644 modules/ExpGamingInfo/Science/softmod.json create mode 100644 modules/ExpGamingInfo/Science/src/sync.lua rename modules/ExpGamingInfo/{to convert/tasklist.lua => Tasklist/control.lua} (88%) create mode 100644 modules/ExpGamingInfo/Tasklist/softmod.json create mode 100644 modules/ExpGamingInfo/softmod.json delete mode 100644 modules/ExpGamingInfo/to convert/rockets.lua delete mode 100644 modules/ExpGamingInfo/to convert/science.lua diff --git a/modules/ExpGamingCore/Group/control.lua b/modules/ExpGamingCore/Group/control.lua index 7cd289af..e7513482 100644 --- a/modules/ExpGamingCore/Group/control.lua +++ b/modules/ExpGamingCore/Group/control.lua @@ -1,7 +1,7 @@ --- Adds a system to manage and auto-create permission groups. -- @module ExpGamingCore@Group -- @author Cooldude2606 --- @license Discord: Cooldude2606@5241 +-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE -- @alais Group -- Module Require diff --git a/modules/ExpGamingCore/Role/control.lua b/modules/ExpGamingCore/Role/control.lua index b57dcd3f..71d06894 100644 --- a/modules/ExpGamingCore/Role/control.lua +++ b/modules/ExpGamingCore/Role/control.lua @@ -1,7 +1,7 @@ --- Adds roles where a player can have more than one role -- @module ExpGamingCore.Role@4.0.0 -- @author Cooldude2606 --- @license https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCore.Role_4.0.0.zip +-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE -- @alais Role -- Module Require diff --git a/modules/ExpGamingInfo/to convert/readme.lua b/modules/ExpGamingInfo/Readme/control.lua similarity index 77% rename from modules/ExpGamingInfo/to convert/readme.lua rename to modules/ExpGamingInfo/Readme/control.lua index 09c2a895..219b26d1 100644 --- a/modules/ExpGamingInfo/to convert/readme.lua +++ b/modules/ExpGamingInfo/Readme/control.lua @@ -1,13 +1,22 @@ ---[[ -Explosive Gaming +--- Adds a readme gui to the game that contains useful information +-- @module ExpGamingInfo.Readme +-- @author Cooldude2606 +-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE +-- @alais ThisModule -This file can be used with permission but this and the credit below must remain in the file. -Contact a member of management on our discord to seek permission to use our code. -Any changes that you may make to the code are yours but that does not make the script yours. -Discord: https://discord.gg/r6dC2uK -]] ---Please Only Edit Below This Line----------------------------------------------------------- +-- Module Require +local Gui = require('ExpGamingCore.Gui@^4.0.0') +local Game = require('FactoiorStdLib.Game@^0.8.0') +-- Module Define +local module_verbose = false +local ThisModule = { + on_init=function() + if loaded_modules['ExpGamingCore.Sync^4.0.0'] then require(module_path..'/src/sync',{Gui=Gui}) end + end +} + +-- Function Define local function format_label(label) label.style.maximal_width = 480 label.style.single_line = false @@ -119,14 +128,5 @@ end):add_tab('rules',{'readme.rules-name'},{'readme.rules-tooltip'},function(fra end end) -Sync.add_to_gui(Gui.inputs.add_button('readme-sync-guildlines','View Guildlines','View the guildlines in the readme',function(player,element) - Gui.center.open_tab(player,'readme','guildlines') -end)) - -Sync.add_to_gui(Gui.inputs.add_button('readme-sync-links','View Other Links','View the links in the readme',function(player,element) - Gui.center.open_tab(player,'readme','links') -end)) - -Sync.add_to_gui(Gui.inputs.add_button('readme-sync-rules','View All Rules','View the all rules in the readme',function(player,element) - Gui.center.open_tab(player,'readme','rules') -end)) +-- Module Return +return ThisModule \ No newline at end of file diff --git a/modules/ExpGamingInfo/Readme/softmod.json b/modules/ExpGamingInfo/Readme/softmod.json new file mode 100644 index 00000000..8f5739d9 --- /dev/null +++ b/modules/ExpGamingInfo/Readme/softmod.json @@ -0,0 +1,22 @@ +{ + "name": "Readme", + "version": "4.0.0", + "type": "Submodule", + "description": "Adds a readme gui to the game that contains useful information", + "location": "", + "keywords": [ + "Gui", + "Info", + "ExpGaming", + "Readme", + "New Player" + ], + "author": "", + "contact": "", + "license": "", + "dependencies": { + "ExpGamingCore.Gui": "^4.0.0", + "FactoiorStdLib.Game": "^0.8.0", + "ExpGamingCore.Sync": "?^4.0.0" + } +} \ No newline at end of file diff --git a/modules/ExpGamingInfo/Readme/src/sync.lua b/modules/ExpGamingInfo/Readme/src/sync.lua new file mode 100644 index 00000000..93203cfd --- /dev/null +++ b/modules/ExpGamingInfo/Readme/src/sync.lua @@ -0,0 +1,14 @@ +local Sync = require('ExpGamingCore.Sync@^4.0.0') +local Gui = Gui + +Sync.add_to_gui(Gui.inputs.add_button('readme-sync-guildlines','View Guildlines','View the guildlines in the readme',function(player,element) + Gui.center.open_tab(player,'readme','guildlines') +end)) + +Sync.add_to_gui(Gui.inputs.add_button('readme-sync-links','View Other Links','View the links in the readme',function(player,element) + Gui.center.open_tab(player,'readme','links') +end)) + +Sync.add_to_gui(Gui.inputs.add_button('readme-sync-rules','View All Rules','View the all rules in the readme',function(player,element) + Gui.center.open_tab(player,'readme','rules') +end)) \ No newline at end of file diff --git a/modules/ExpGamingInfo/Rockets/control.lua b/modules/ExpGamingInfo/Rockets/control.lua new file mode 100644 index 00000000..6dfe0394 --- /dev/null +++ b/modules/ExpGamingInfo/Rockets/control.lua @@ -0,0 +1,103 @@ +--- Adds a rocket count gui to the game that shows milestones and average rocket time +-- @module ExpGamingInfo.Rockets +-- @author Cooldude2606 +-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE +-- @alais ThisModule + +-- Module Require +local Gui = require('ExpGamingCore.Gui@^4.0.0') +local Game = require('FactoiorStdLib.Game@^0.8.0') + +-- Module Define +local module_verbose = false +local ThisModule = { + on_init=function() + if loaded_modules['ExpGamingCore.Sync^4.0.0'] then require(module_path..'/src/sync') end + end +} + +-- Global Define +local global = global{ + update=0, + first=0, + _last=0, + last=0, + fastest=0, + milestones={m1=0,m2=0,m5=0,m10=0,m20=0,m50=0,m100=0,m200=0,m500=0,m1000=0,m2000=0,m5000=0} +} + +-- Function Define +Gui.left.add{ + name='rockets', + caption='item/rocket-silo', + tooltip={'rockets.tooltip'}, + draw=function(frame) + frame.caption = {'rockets.name'} + local player = Game.get_player(frame.player_index) + local satellites = player.force.get_item_launched('satellite') + local time = {'rockets.nan'} + if satellites == 1 then time = tick_to_display_format(game.tick) + elseif satellites > 1 then time = tick_to_display_format((game.tick-global.first)/satellites) end + if satellites ~= global.update then + global.update = satellites + if global.first == 0 then global.first = game.tick end + global._last = global.last + global.last = game.tick + if global.last-global._last < global.fastest or global.fastest == 0 then global.fastest = global.last-global._last end + end + frame.add{ + type='label', + caption={'rockets.sent',satellites} + } + frame.add{ + type='label', + caption={'rockets.first',tick_to_display_format(global.first)} + } + frame.add{ + type='label', + caption={'rockets.last',tick_to_display_format(global.last-global._last)} + } + frame.add{ + type='label', + caption={'rockets.time',time} + } + frame.add{ + type='label', + caption={'rockets.fastest',tick_to_display_format(global.fastest)} + } + frame.add{ + type='label', + caption={'rockets.milestones'}, + style='caption_label' + } + local milestones = frame.add{ + type='flow', + direction='vertical' + } + for milestone,time in pairs(global.milestones) do + local milestone = tonumber(milestone:match('%d+')) + if time == 0 and satellites == milestone then + global.milestones['m'..milestone] = global.last + time = global.last + Gui.left.open('rockets') + end + local _time = {'rockets.nan'} + if time > 0 then _time = tick_to_display_format(time) end + milestones.add{ + type='label', + caption={'rockets.format',tostring(milestone),_time} + } + if time == 0 then break end + end + end, + can_open=function(player) + if player.force.get_item_launched('satellite') > 0 then return true + else return {'rockets.none'} end + end +} + +-- Event Define +script.on_event(defines.events.on_rocket_launched,function(event) Gui.left.update('rockets') end) + +-- Module Return +return ThisModule \ No newline at end of file diff --git a/modules/ExpGamingInfo/Rockets/softmod.json b/modules/ExpGamingInfo/Rockets/softmod.json new file mode 100644 index 00000000..aadbecc3 --- /dev/null +++ b/modules/ExpGamingInfo/Rockets/softmod.json @@ -0,0 +1,21 @@ +{ + "name": "Rockets", + "version": "4.0.0", + "type": "Submodule", + "description": "Adds a rocket count gui to the game that shows milestones and average rocket time", + "location": "", + "keywords": [ + "Gui", + "Info", + "ExpGaming", + "Rockets" + ], + "author": "", + "contact": "", + "license": "", + "dependencies": { + "ExpGamingCore.Gui": "^4.0.0", + "FactoiorStdLib.Game": "^0.8.0", + "ExpGamingCore.Sync": "?^4.0.0" + } +} \ No newline at end of file diff --git a/modules/ExpGamingInfo/Rockets/src/sync.lua b/modules/ExpGamingInfo/Rockets/src/sync.lua new file mode 100644 index 00000000..e215f530 --- /dev/null +++ b/modules/ExpGamingInfo/Rockets/src/sync.lua @@ -0,0 +1,20 @@ +local Sync = require('ExpGamingCore.Sync@^4.0.0') +local global = global['ExpGamingInfo.Rockets@^4.0.0'] + +Sync.add_update('rockets',function() + local _return = {} + local satellites = game.forces.player.get_item_launched('satellite') + local time = {'rockets.nan'} + if satellites == 1 then time = tick_to_display_format(game.tick) + elseif satellites > 1 then time = tick_to_display_format((game.tick-global.first)/satellites) end + _return.total = satellites + _return.first = Sync.tick_format(global.first) + _return.last = Sync.tick_format(global.last-global._last) + _return.time = Sync.tick_format(time) + _return.fastest = Sync.tick_format(global.fastest) + _return.milestones = {} + for milestone,time in pairs(global.milestones) do + _return.milestones[milestone] = Sync.tick_format(time) + end + return _return +end) \ No newline at end of file diff --git a/modules/ExpGamingInfo/Science/control.lua b/modules/ExpGamingInfo/Science/control.lua new file mode 100644 index 00000000..86018e2d --- /dev/null +++ b/modules/ExpGamingInfo/Science/control.lua @@ -0,0 +1,103 @@ +--- Adds a science count gui to the game that shows toatal made and per minute +-- @module ExpGamingInfo.Science +-- @author Cooldude2606 +-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE +-- @alais ThisModule + +-- Module Require +local Gui = require('ExpGamingCore.Gui@^4.0.0') +local Game = require('FactoiorStdLib.Game@^0.8.0') + +-- Local Varibles +local science_packs = { + 'science-pack-1', + 'science-pack-2', + 'science-pack-3', + 'military-science-pack', + 'production-science-pack', + 'high-tech-science-pack', + 'space-science-pack' +} + +-- Module Define +local module_verbose = false +local ThisModule = { + on_init=function() + if loaded_modules['ExpGamingCore.Sync^4.0.0'] then require(module_path..'/src/sync') end + end +} + +-- Global Define +local global = global{ + _base={ + update=0, + _update=0, + made={0,0,0,0,0,0,0}, + _made={0,0,0,0,0,0,0} + } +} + +-- Function Define +Gui.left.add{ + name='science', + caption='item/lab', + tooltip={'science.tooltip'}, + draw=function(frame) + local player = Game.get_player(frame.player_index) + if not global[player.force.name] then + global[player.force.name] = table.deepcopy(global._base) + end + global = global[player.force.name] + frame.caption = {'science.name'} + frame.add{ + type='label', + caption={'science.total'}, + style='caption_label' + } + local totals = frame.add{ + type='flow', + direction='vertical' + } + frame.add{ + type='label', + caption={'science.time'}, + style='caption_label' + } + local times = frame.add{ + type='flow', + direction='vertical' + } + if global.update < game.tick-100 then + global._update = global.update + global._made = table.deepcopy(global.made) + for i,name in pairs(science_packs) do + global.made[i] = player.force.item_production_statistics.get_input_count(name) + end + global.update = game.tick + end + for i,name in pairs(science_packs) do + local made = global.made[i] + if made > 0 then + totals.add{ + type='label', + caption={'science.format',{'science.'..name},made} + } + local _made = string.format('%.2f',(made-global._made[i])/((global.update-global._update)/(3600*game.speed))) + times.add{ + type='label', + caption={'science.format',{'science.'..name},_made} + } + end + end + end, + can_open=function(player) + if player.force.item_production_statistics.get_input_count('science-pack-1') > 0 then return true + else return {'science.none'} end + end +} + +-- Event Define +script.on_event(defines.events.on_research_finished,function(event) Gui.left.update('science') end) + +-- Module Return +return ThisModule \ No newline at end of file diff --git a/modules/ExpGamingInfo/Science/softmod.json b/modules/ExpGamingInfo/Science/softmod.json new file mode 100644 index 00000000..4a7ea608 --- /dev/null +++ b/modules/ExpGamingInfo/Science/softmod.json @@ -0,0 +1,22 @@ +{ + "name": "Science", + "version": "4.0.0", + "type": "Submodule", + "description": "Adds a science count gui to the game that shows toatal made and per minute", + "location": "", + "keywords": [ + "Gui", + "Info", + "ExpGaming", + "Science", + "Production" + ], + "author": "", + "contact": "", + "license": "", + "dependencies": { + "ExpGamingCore.Gui": "^4.0.0", + "FactoiorStdLib.Game": "^0.8.0", + "ExpGamingCore.Sync": "?^4.0.0" + } +} \ No newline at end of file diff --git a/modules/ExpGamingInfo/Science/src/sync.lua b/modules/ExpGamingInfo/Science/src/sync.lua new file mode 100644 index 00000000..3c7649c1 --- /dev/null +++ b/modules/ExpGamingInfo/Science/src/sync.lua @@ -0,0 +1,18 @@ +local Sync = require('ExpGamingCore.Sync@^4.0.0') +local data = global['ExpGamingInfo.Science@^4.0.0'] + +Sync.add_update('science',function() + local _return = {} + for force_name,global in pairs(data) do + if force_name ~= '_base' then + _return[force_name] = {totals={},times={}} + for i,name in pairs(science_packs) do + local made = global.made[i] + _return[force_name].totals[name] = made + local _made = string.format('%.2f',(made-global._made[i])/((global.update-global._update)/(3600*game.speed))) + _return[force_name].times[name] = _made + end + end + end + return _return +end) \ No newline at end of file diff --git a/modules/ExpGamingInfo/to convert/tasklist.lua b/modules/ExpGamingInfo/Tasklist/control.lua similarity index 88% rename from modules/ExpGamingInfo/to convert/tasklist.lua rename to modules/ExpGamingInfo/Tasklist/control.lua index 756e5868..042df4f1 100644 --- a/modules/ExpGamingInfo/to convert/tasklist.lua +++ b/modules/ExpGamingInfo/Tasklist/control.lua @@ -1,26 +1,36 @@ ---[[ - Explosive Gaming - - This file can be used with permission but this and the credit below must remain in the file. -Contact a member of management on our discord to seek permission to use our code. -Any changes that you may make to the code are yours but that does not make the script yours. -Discord: https://discord.gg/r6dC2uK -]] ---Please Only Edit Below This Line----------------------------------------------------------- +--- Adds a task list gui which acts like a bulletin board for the current tasks +-- @module ExpGamingInfo.Tasklist +-- @author Cooldude2606 +-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE +-- @alais ThisModule -local function _global(reset) - global.addons = not reset and global.addons or {} - global.addons.tasklist = not reset and global.addons.tasklist or {tasks={},_edit={},_base={_edit=false,_tasks={},_editing={}}} - return global.addons.tasklist -end +-- Module Require +local Gui = require('ExpGamingCore.Role@^4.0.0') +local Game = require('FactoiorStdLib.Game@^0.8.0') +-- Module Define +local module_verbose = false +local ThisModule = {} + +-- Global Define +local global = global{ + tasks={}, + _edit={}, + _base={ + _edit=false, + _tasks={}, + _editing={} + } +} + +-- Function Define local edit = Gui.inputs.add{ name='tasklist-edit', type='button', caption='utility/rename_icon_normal' }:on_event('click',function(event) local text_flow = event.element.parent.parent.text_flow - local data = _global()._edit[event.player_index] + local data = global._edit[event.player_index] if not data._edit then data._tasks = table.deepcopy(_global().tasks) end if text_flow.input.type == 'label' then data._editing[tonumber(text_flow.parent.name)]=true @@ -38,7 +48,7 @@ local function _edit(frame) element.style.height = 20 element.style.width = 20 local text_flow = element.parent.parent.text_flow - local data = _global()._edit[frame.player_index] + local data = global._edit[frame.player_index] data._tasks[text_flow.parent.name]=text if data._editing[tonumber(text_flow.parent.name)] then element.style.height = 30 @@ -189,4 +199,6 @@ Gui.left.add{ else return {'tasklist.none'} end end, open_on_join=true -} \ No newline at end of file +} + +return ThisModule \ No newline at end of file diff --git a/modules/ExpGamingInfo/Tasklist/softmod.json b/modules/ExpGamingInfo/Tasklist/softmod.json new file mode 100644 index 00000000..ba743a75 --- /dev/null +++ b/modules/ExpGamingInfo/Tasklist/softmod.json @@ -0,0 +1,20 @@ +{ + "name": "Tasklist", + "version": "4.0.0", + "type": "Submodule", + "description": "Adds a task list gui which acts like a bulletin board for the current tasks", + "location": "", + "keywords": [ + "Gui", + "Info", + "ExpGaming", + "Tasks" + ], + "author": "", + "contact": "", + "license": "", + "dependencies": { + "ExpGamingCore.Gui": "^4.0.0", + "FactoiorStdLib.Game": "^0.8.0" + } +} \ No newline at end of file diff --git a/modules/ExpGamingInfo/softmod.json b/modules/ExpGamingInfo/softmod.json new file mode 100644 index 00000000..a614d7a1 --- /dev/null +++ b/modules/ExpGamingInfo/softmod.json @@ -0,0 +1,91 @@ +{ + "name": "ExpGamingInfo", + "version": "4.0.0", + "type": "Collection", + "description": "Adds info guis to the game for different production areas", + "location": "", + "keywords": [ + "Gui", + "Info", + "ExpGaming", + "Production" + ], + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606@5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "submodules": { + "Readme": { + "name": "Readme", + "version": "4.0.0", + "type": "Submodule", + "description": "Adds a readme gui to the game that contains useful information", + "location": "", + "keywords": [ + "Gui", + "Info", + "ExpGaming", + "Readme", + "New Player" + ], + "dependencies": { + "ExpGamingCore.Gui": "^4.0.0", + "FactoiorStdLib.Game": "^0.8.0", + "ExpGamingCore.Sync": "?^4.0.0" + } + }, + "Rockets": { + "name": "Rockets", + "version": "4.0.0", + "type": "Submodule", + "description": "Adds a rocket count gui to the game that shows milestones and average rocket time", + "location": "", + "keywords": [ + "Gui", + "Info", + "ExpGaming", + "Rockets" + ], + "dependencies": { + "ExpGamingCore.Gui": "^4.0.0", + "FactoiorStdLib.Game": "^0.8.0", + "ExpGamingCore.Sync": "?^4.0.0" + } + }, + "Science": { + "name": "Science", + "version": "4.0.0", + "type": "Submodule", + "description": "Adds a science count gui to the game that shows toatal made and per minute", + "location": "", + "keywords": [ + "Gui", + "Info", + "ExpGaming", + "Science", + "Production" + ], + "dependencies": { + "ExpGamingCore.Gui": "^4.0.0", + "FactoiorStdLib.Game": "^0.8.0", + "ExpGamingCore.Sync": "?^4.0.0" + } + }, + "Tasklist": { + "name": "Tasklist", + "version": "4.0.0", + "type": "Submodule", + "description": "Adds a task list gui which acts like a bulletin board for the current tasks", + "location": "", + "keywords": [ + "Gui", + "Info", + "ExpGaming", + "Tasks" + ], + "dependencies": { + "ExpGamingCore.Gui": "^4.0.0", + "FactoiorStdLib.Game": "^0.8.0" + } + } + } +} \ No newline at end of file diff --git a/modules/ExpGamingInfo/to convert/rockets.lua b/modules/ExpGamingInfo/to convert/rockets.lua deleted file mode 100644 index 6ef4ce44..00000000 --- a/modules/ExpGamingInfo/to convert/rockets.lua +++ /dev/null @@ -1,104 +0,0 @@ ---[[ -Explosive Gaming - -This file can be used with permission but this and the credit below must remain in the file. -Contact a member of management on our discord to seek permission to use our code. -Any changes that you may make to the code are yours but that does not make the script yours. -Discord: https://discord.gg/r6dC2uK -]] ---Please Only Edit Below This Line----------------------------------------------------------- - -local function _global(reset) - global.addons = not reset and global.addons or {} - global.addons.rockets = not reset and global.addons.rockets or {update=0,first=0,_last=0,last=0,fastest=0,milestones={m1=0,m2=0,m5=0,m10=0,m20=0,m50=0,m100=0,m200=0,m500=0,m1000=0,m2000=0,m5000=0}} - return global.addons.rockets -end -Gui.left.add{ - name='rockets', - caption='item/rocket-silo', - tooltip={'rockets.tooltip'}, - draw=function(frame) - frame.caption = {'rockets.name'} - local player = Game.get_player(frame.player_index) - local data = _global() - local satellites = player.force.get_item_launched('satellite') - local time = {'rockets.nan'} - if satellites == 1 then time = tick_to_display_format(game.tick) - elseif satellites > 1 then time = tick_to_display_format((game.tick-data.first)/satellites) end - if satellites ~= data.update then - data.update = satellites - if data.first == 0 then data.first = game.tick end - data._last = data.last - data.last = game.tick - if data.last-data._last < data.fastest or data.fastest == 0 then data.fastest = data.last-data._last end - end - frame.add{ - type='label', - caption={'rockets.sent',satellites} - } - frame.add{ - type='label', - caption={'rockets.first',tick_to_display_format(data.first)} - } - frame.add{ - type='label', - caption={'rockets.last',tick_to_display_format(data.last-data._last)} - } - frame.add{ - type='label', - caption={'rockets.time',time} - } - frame.add{ - type='label', - caption={'rockets.fastest',tick_to_display_format(data.fastest)} - } - frame.add{ - type='label', - caption={'rockets.milestones'}, - style='caption_label' - } - local milestones = frame.add{ - type='flow', - direction='vertical' - } - for milestone,time in pairs(data.milestones) do - local milestone = tonumber(milestone:match('%d+')) - if time == 0 and satellites == milestone then - data.milestones['m'..milestone] = data.last - time = data.last - Gui.left.open('rockets') - end - local _time = {'rockets.nan'} - if time > 0 then _time = tick_to_display_format(time) end - milestones.add{ - type='label', - caption={'rockets.format',tostring(milestone),_time} - } - if time == 0 then break end - end - end, - can_open=function(player) - if player.force.get_item_launched('satellite') > 0 then return true - else return {'rockets.none'} end - end -} - -Event.register(defines.events.on_rocket_launched,function(event) Gui.left.update('rockets') end) -Sync.add_update('rockets',function() - local _return = {} - local data = _global() - local satellites = game.forces.player.get_item_launched('satellite') - local time = {'rockets.nan'} - if satellites == 1 then time = tick_to_display_format(game.tick) - elseif satellites > 1 then time = tick_to_display_format((game.tick-data.first)/satellites) end - _return.total = satellites - _return.first = Sync.tick_format(data.first) - _return.last = Sync.tick_format(data.last-data._last) - _return.time = Sync.tick_format(time) - _return.fastest = Sync.tick_format(data.fastest) - _return.milestones = {} - for milestone,time in pairs(data.milestones) do - _return.milestones[milestone] = Sync.tick_format(time) - end - return _return -end) \ No newline at end of file diff --git a/modules/ExpGamingInfo/to convert/science.lua b/modules/ExpGamingInfo/to convert/science.lua deleted file mode 100644 index 1cdf7887..00000000 --- a/modules/ExpGamingInfo/to convert/science.lua +++ /dev/null @@ -1,102 +0,0 @@ ---[[ -Explosive Gaming - -This file can be used with permission but this and the credit below must remain in the file. -Contact a member of management on our discord to seek permission to use our code. -Any changes that you may make to the code are yours but that does not make the script yours. -Discord: https://discord.gg/r6dC2uK -]] ---Please Only Edit Below This Line----------------------------------------------------------- - -local science_packs = { - 'science-pack-1', - 'science-pack-2', - 'science-pack-3', - 'military-science-pack', - 'production-science-pack', - 'high-tech-science-pack', - 'space-science-pack' -} - -local function _global(reset) - global.addons = not reset and global.addons or {} - global.addons.science = not reset and global.addons.science or {_base={update=0,_update=0,made={0,0,0,0,0,0,0},_made={0,0,0,0,0,0,0}}} - return global.addons.science -end - -Gui.left.add{ - name='science', - caption='item/lab', - tooltip={'science.tooltip'}, - draw=function(frame) - local data = _global() - local player = Game.get_player(frame.player_index) - if not data[player.force.name] then - data[player.force.name] = table.deepcopy(data._base) - end - data = data[player.force.name] - frame.caption = {'science.name'} - frame.add{ - type='label', - caption={'science.total'}, - style='caption_label' - } - local totals = frame.add{ - type='flow', - direction='vertical' - } - frame.add{ - type='label', - caption={'science.time'}, - style='caption_label' - } - local times = frame.add{ - type='flow', - direction='vertical' - } - if data.update < game.tick-100 then - data._update = data.update - data._made = table.deepcopy(data.made) - for i,name in pairs(science_packs) do - data.made[i] = player.force.item_production_statistics.get_input_count(name) - end - data.update = game.tick - end - for i,name in pairs(science_packs) do - local made = data.made[i] - if made > 0 then - totals.add{ - type='label', - caption={'science.format',{'science.'..name},made} - } - local _made = string.format('%.2f',(made-data._made[i])/((data.update-data._update)/(3600*game.speed))) - times.add{ - type='label', - caption={'science.format',{'science.'..name},_made} - } - end - end - end, - can_open=function(player) - if player.force.item_production_statistics.get_input_count('science-pack-1') > 0 then return true - else return {'science.none'} end - end -} - -Event.register(defines.events.on_research_finished,function(event) Gui.left.update('science') end) -Sync.add_update('science',function() - local _return = {} - local _data = _global() - for force_name,data in pairs(_data) do - if force_name ~= '_base' then - _return[force_name] = {totals={},times={}} - for i,name in pairs(science_packs) do - local made = data.made[i] - _return[force_name].totals[name] = made - local _made = string.format('%.2f',(made-data._made[i])/((data.update-data._update)/(3600*game.speed))) - _return[force_name].times[name] = _made - end - end - end - return _return -end) \ No newline at end of file diff --git a/modules/index.lua b/modules/index.lua index c8a71d85..2bc08154 100644 --- a/modules/index.lua +++ b/modules/index.lua @@ -49,5 +49,9 @@ return { ['ExpGamingAdmin.Commands@4.0.0']='./modules/ExpGamingAdmin/Commands', ['ExpGamingAdmin.Ban@4.0.0']='./modules/ExpGamingAdmin/Ban', ['ChatPopup@4.0.0']='./modules/ChatPopup', - ['DamagePopup@4.0.0']='./modules/DamagePopup' + ['DamagePopup@4.0.0']='./modules/DamagePopup', + ['ExpGamingInfo.Readme@4.0.0']='./modules/DamagePopup', + ['ExpGamingInfo.Rockets@4.0.0']='./modules/DamagePopup', + ['ExpGamingInfo.Science@4.0.0']='./modules/DamagePopup', + ['ExpGamingInfo.Tasklist@4.0.0']='./modules/DamagePopup', } \ No newline at end of file