Skip to content

Commit

Permalink
Softmod Improvements/Additions
Browse files Browse the repository at this point in the history
* Enhance logging + rich text
* New no-bluprints module
* Auto enable research queue
* Spawn area: add turrets, roboport, cliff explosives
* Game Info: add game seed to copy
  • Loading branch information
deniszholob committed Sep 22, 2020
1 parent 56c2aa5 commit 649782a
Show file tree
Hide file tree
Showing 13 changed files with 354 additions and 92 deletions.
16 changes: 9 additions & 7 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ require('config')
-- require('modules/vanilla/player-init')

-- == Import Soft Mod Modules == --
require('modules/common/spawn-marker')
require('modules/common/death-marker')
require('modules/common/autodeconstruct')
require('modules/common/floating-health')
require('modules/common/custom-tech')
-- require('modules/common/no-hand-crafting')

require('modules/dddgamer/player-init')
require('modules/dddgamer/spawn-area')
require('modules/dddgamer/player-logging')
Expand All @@ -47,6 +40,15 @@ require('modules/common/evolution')
require('modules/common/game-time')
require('modules/common/silo')

require('modules/common/spawn-marker')
require('modules/common/death-marker')
require('modules/common/autodeconstruct')
require('modules/common/floating-health')
-- require('modules/common/no-blueprints')
-- require('modules/common/no-hand-crafting')
require('modules/common/custom-tech')


-- require('modules/common/research-queue/auto-research')
-- require('modules/common/tasks') -- Has desync problems

Expand Down
2 changes: 1 addition & 1 deletion locale/en/death-marker.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[death_marker]
marker=RIP __1__
message=Death location for '__1__' has been marked on the map as '__2__'
message=Death location [gps=__3__,__4__] for '__1__' has been marked on the map as '__2__'
removed=Your death marker '__1__' has been removed. The corpse has decayed or been looted.
2 changes: 2 additions & 0 deletions locale/en/no-blueprints.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[No_Blueprints]
info=Importing Blueprints has been disabled in this Scenario (you can still create new ones)
7 changes: 7 additions & 0 deletions locale/en/player-logging.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Player_Logging]
online_count=<Players Online> count=__1__
joined=<Player Joined> name=__1__
left=<Player Left> name=__1__
mined=<Player Mined> name=__1__
decon=<Player Used Decon> name=__1__
research=Research Complete: [technology=__1__]
2 changes: 2 additions & 0 deletions locale/ru/no-blueprints.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[No_Blueprints]
info=Импорт Blueprints был отключен в этом сценарии (вы все еще можете создавать новые)
62 changes: 34 additions & 28 deletions modules/common/custom-tech.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,58 +13,64 @@

-- Constants --
-- ======================================================= --

-- Research to disable
local DISABLED_RESEARCH_LIST = {
'atomic-bomb',
'discharge-defense-equipment',
-- 'logistic-system'
}

-- Recipies to disable
local DISABLED_RECIPE_LIST = {
'atomic-bomb',
'discharge-defense-equipment',
}

-- Tech to begin researched with
local RESEARCH_TECH = {
'toolbelt',
'steel-axe',
'optics',
local Custom_Tech = {
-- Research to disable
DISABLED_RESEARCH_LIST = {
'atomic-bomb',
'discharge-defense-equipment',
-- 'logistic-system'
},
-- Recipies to disable
DISABLED_RECIPE_LIST = {
'atomic-bomb',
'discharge-defense-equipment',
},
-- Tech to begin researched with
RESEARCH_TECH = {
'toolbelt',
'steel-axe',
'optics',
},
PRINT_DISABLED_TECH = false,
ENABLE_RESEARCH_QUEUE = true,
}

local PRINT_DISABLED_TECH = false

-- Event Functions --
-- ======================================================= --

-- Various action when new player joins in game
-- @param event on_player_created event
function on_player_created(event)
function Custom_Tech.on_player_created(event)
local player = game.players[event.player_index]

-- Research to disable
for i, research in ipairs(DISABLED_RESEARCH_LIST) do
for i, research in ipairs(Custom_Tech.DISABLED_RESEARCH_LIST) do
player.force.technologies[research].enabled = false
if PRINT_DISABLED_TECH then player.print({'custom_tech.disable_research', research}) end
if Custom_Tech.PRINT_DISABLED_TECH then player.print({'custom_tech.disable_research', research}) end
end

-- Recipies to disable
for i, recipe in ipairs(DISABLED_RECIPE_LIST) do
for i, recipe in ipairs(Custom_Tech.DISABLED_RECIPE_LIST) do
player.force.recipes[recipe].enabled = false
if PRINT_DISABLED_TECH then player.print({'custom_tech.disable_recipe', recipe}) end
if Custom_Tech.PRINT_DISABLED_TECH then player.print({'custom_tech.disable_recipe', recipe}) end
end

-- Tech to start already researched with
for i, research in ipairs(RESEARCH_TECH) do
for i, research in ipairs(Custom_Tech.RESEARCH_TECH) do
player.force.technologies[research].researched = true
end

if(Custom_Tech.ENABLE_RESEARCH_QUEUE) then
player.force.research_queue_enabled = true
-- game.difficulty_settings.research_queue_setting = "always"
end

-- Enable Research Queue
end

-- Event Registration --
-- ======================================================= --
Event.register(defines.events.on_player_created, on_player_created)
Event.register(defines.events.on_player_created, Custom_Tech.on_player_created)

-- Helper Functions --
-- ======================================================= --
2 changes: 1 addition & 1 deletion modules/common/death-marker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function deathmarkers.playerDied(event)

for index, cplayer in pairs(player.force.connected_players) do
if cplayer.surface == surface then
cplayer.print({'death_marker.message', player.name, text})
cplayer.print({'death_marker.message', player.name, text, position.x, position.y})
end
end
end
Expand Down
49 changes: 49 additions & 0 deletions modules/common/no-blueprints.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
-- No Blueprints Soft Module
-- Uses locale no-blueprints.cfg
-- @usage require('modules/common/no-blueprints')
-- ------------------------------------------------------- --
-- @author Denis Zholob (DDDGamer)
-- github: https://github.com/deniszholob/factorio-softmod-pack
-- ======================================================= --

-- Dependencies --
-- ======================================================= --

-- Constants --
-- ======================================================= --
local No_Blueprints = {
PERMISSION_GROUP = 'no_blueprints'
}

-- Event Functions --
-- ======================================================= --

-- Various action when new player joins in game
-- @param event on_player_created event
function No_Blueprints.on_player_created(event)
local player = game.players[event.player_index]
No_Blueprints.dissalowBlueprints(player)
player.print({'No_Blueprints.info'})
end

-- Event Registration
-- ================== --
Event.register(defines.events.on_player_created, No_Blueprints.on_player_created)

-- Helper Functions --
-- ======================================================= --

function No_Blueprints.dissalowBlueprints(player)
-- Get existing grouip or add one if doesnt exist
local group =
game.permissions.get_group(No_Blueprints.PERMISSION_GROUP) or
game.permissions.create_group(No_Blueprints.PERMISSION_GROUP)
-- Dissalow Hand Crafting (https://lua-api.factorio.com/latest/defines.html)
group.set_allows_action(defines.input_action['import_blueprint'], false)
group.set_allows_action(defines.input_action['import_blueprint_string'], false)
-- group.set_allows_action(defines.input_action['open_blueprint_library_gui'], false)
group.set_allows_action(defines.input_action['grab_blueprint_record'], false)
group.set_allows_action(defines.input_action['open_blueprint_record'], false)
-- Add player to the group
game.permissions.get_group(No_Blueprints.PERMISSION_GROUP).add_player(player)
end
4 changes: 2 additions & 2 deletions modules/common/no-hand-crafting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function addNoHandcraftKitItems(player)
-- Always get the Lvl 3 Assembler as it can craft every item in the game
player.insert {name = 'assembling-machine-3', count = 1}
-- Always include power pole as needed to transmit power
player.insert {name = 'small-electric-pole', count = 1}
player.insert {name = 'medium-electric-pole', count = 1}

-- Power (solar or steam)
if NO_HAND_CRAFT_DEFAULT_SETTINGS.useSteamInsteadOfSolar then
Expand All @@ -72,7 +72,7 @@ function disallowHandcrafting(player)
game.permissions.get_group(NO_HAND_CRAFT_PERMISSION_GROUP) or
game.permissions.create_group(NO_HAND_CRAFT_PERMISSION_GROUP)

-- Dissalow Hand Crafting
-- Dissalow Hand Crafting (https://lua-api.factorio.com/latest/defines.html)
group.set_allows_action(defines.input_action['craft'], false)
-- Add player to the group
game.permissions.get_group(NO_HAND_CRAFT_PERMISSION_GROUP).add_player(player)
Expand Down
20 changes: 17 additions & 3 deletions modules/dddgamer/game-info.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ local SECTION_CONTENT = {
title = '',
content = {
'* Gameplay: Vanilla with QOL Mods',
'* Chat with the [color=orange]`[/color] Key (Under the [color=orange]ESC[/color] Key)',
-- '* Gameplay: Handcrafting and Blueprints have been disabled',
-- '* NOTE: Handcrafting is Disabled!',
'* Chat with the [color=orange]`[/color] Key (Under the [color=orange]ESC[/color] Key)',
'* Join discord for discussion, voice chat and admin support:',
'https://discord.gg/PkyzXzz',
'* Check the Factorio Cheat Sheet for help:',
Expand All @@ -55,7 +56,6 @@ local SECTION_CONTENT = {
'* Taxi Trains: #PAX_[Location]_[Resource-Name]_[ID]',
'* Example Ore: "Mine_L_Iron-Ore_1"',
'* Example PAX: "#PAX_Mine_Copper-Ore_3"',
'* Example MEF: "MEF_S_Steel"',
}
},
}
Expand Down Expand Up @@ -104,7 +104,7 @@ local function on_gui_click(event)
if el_name == Game_Info.MASTER_BUTTON_NAME or el_name == 'btn_gameinfo_close' then
-- Call toggle if frame has been created
if(player.gui.center[Game_Info.MASTER_FRAME_NAME] ~= nil) then
GUI.toggle_element(player.gui.center[Game_Info.MASTER_FRAME_NAME])
GUI.destroy_element(player.gui.center[Game_Info.MASTER_FRAME_NAME])
else -- Call create if it hasnt
draw_gameinfo_frame(player)
end
Expand Down Expand Up @@ -181,6 +181,20 @@ function draw_gameinfo_frame(player)
scrollable_content_frame.style.top_padding = 10
scrollable_content_frame.style.bottom_padding = 10

-- Flow
local mapInfoSection = scrollable_content_frame.add({type = 'flow', direction = 'horizontal'})
mapInfoSection.style.horizontally_stretchable = true
mapInfoSection.style.bottom_padding = 15

local text_box = mapInfoSection.add({
type = "label",
caption = "Map Seed"
})
local text_box = mapInfoSection.add({
type = "textfield",
text = player.surface.map_gen_settings.seed
})

-- Insert content
for i, section in pairs(SECTION_CONTENT) do
draw_section(scrollable_content_frame, section)
Expand Down
Loading

0 comments on commit 649782a

Please sign in to comment.