1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-05 13:15:03 +02:00

some fixes

This commit is contained in:
MewMew 2019-12-18 19:08:09 +01:00
parent e092eae5f9
commit f491df7df4
8 changed files with 52 additions and 41 deletions

View File

@ -1,7 +1,5 @@
--atoll-- mewmew made this --
require "modules.dynamic_landfill"
require "modules.satellite_score"
require "modules.spawners_contain_biters"
require "modules.surrounded_by_worms"

View File

@ -452,6 +452,12 @@ local function on_player_joined_game(event)
global.map_init_done = true
end
local function on_force_created(event)
event.force.set_friend(game.forces.scrap, true)
game.forces.scrap.set_friend(event.force, true)
event.force.technologies["optics"].researched = true
end
local function on_player_mined_entity(event)
local entity = event.entity
if not entity.valid then return end
@ -521,6 +527,7 @@ local T = Map.Pop_info()
end
event.on_init(on_init)
event.add(defines.events.on_force_created, on_force_created)
event.add(defines.events.on_research_finished, on_research_finished)
event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)
event.add(defines.events.on_player_joined_game, on_player_joined_game)

View File

@ -54,7 +54,7 @@ local function on_console_chat(event)
if button.caption ~= "Global Chat" then return end
for _, force in pairs(game.forces) do
if force.name ~= player.force.name then
force.print(event.message, player.chat_color)
force.print(player.name .. " " .. player.tag .. ": " .. event.message, player.chat_color)
end
end
end

View File

@ -1,6 +1,6 @@
local Public = {}
local connection_radius = 4
local connection_radius = 5
local entity_type_whitelist = {
["accumulator"] = true,
@ -13,14 +13,15 @@ local entity_type_whitelist = {
["container"] = true,
["curved-rail"] = true,
["decider-combinator"] = true,
["electric-pole"] = true,
["electric-turret"] = true,
["fluid-turret"] = true,
["furnace"] = true,
["gate"] = true,
["generator"] = true,
["heat-interface"] = true,
["heat-pipe"] = true,
["infinity-container"] = true,
["heat-interface"] = true,
["infinity-pipe"] = true,
["inserter"] = true,
["lamp"] = true,

View File

@ -4,7 +4,7 @@ local Market = require "modules.towny.market"
local Team = require "modules.towny.team"
local Town_center = require "modules.towny.town_center"
require "modules.global_chat_toggle"
require "modules.custom_death_messages"
local function on_player_joined_game(event)
local player = game.players[event.player_index]
@ -14,7 +14,7 @@ local function on_player_joined_game(event)
Team.set_player_to_homeless(player)
player.print("Towny is enabled! To found your town, place down a stone furnace.", {255, 255, 0})
player.print("To ally or settle with another player, drop a fish on their market or character. Coal will yield the opposite result.", {255, 255, 0})
player.print("To ally or settle with another player, drop a fish on their market or character. Coal yields the opposite result.", {255, 255, 0})
if player.online_time == 0 then
Team.give_homeless_items(player)
@ -74,7 +74,7 @@ end
local function on_player_dropped_item(event)
local player = game.players[event.player_index]
local entity = event.entity
local entity = event.entity
if entity.stack.name == "raw-fish" then
Team.ally_town(player, entity)
return
@ -108,34 +108,15 @@ local function on_init()
local p = game.permissions.create_group("Homeless")
for action_name, _ in pairs(defines.input_action) do
p.set_allows_action(defines.input_action[action_name], false)
p.set_allows_action(defines.input_action[action_name], true)
end
local defs = {
defines.input_action.craft,
defines.input_action.build_item,
defines.input_action.cursor_split,
defines.input_action.cursor_transfer,
defines.input_action.clean_cursor_stack,
defines.input_action.drop_item,
defines.input_action.begin_mining,
defines.input_action.change_picking_state,
defines.input_action.edit_permission_group,
defines.input_action.gui_click,
defines.input_action.gui_confirmed,
defines.input_action.gui_elem_changed,
defines.input_action.gui_location_changed,
defines.input_action.gui_selected_tab_changed,
defines.input_action.gui_selection_state_changed,
defines.input_action.gui_switch_state_changed,
defines.input_action.gui_text_changed,
defines.input_action.gui_value_changed,
defines.input_action.open_character_gui,
defines.input_action.open_kills_gui,
defines.input_action.start_walking,
defines.input_action.toggle_show_entity_info,
defines.input_action.write_to_console,
defines.input_action.deconstruct,
defines.input_action.start_research,
defines.input_action.open_technology_gui,
}
for _, d in pairs(defs) do p.set_allows_action(d, true) end
for _, d in pairs(defs) do p.set_allows_action(d, false) end
end
local Event = require 'utils.event'

View File

@ -21,6 +21,7 @@ local function set_offers(town_center)
local market = town_center.market
local market_items = {
{price = {{"coin", town_center.max_health * 0.1}}, offer = {type = 'nothing', effect_description = "Upgrade Town Center Health"}},
{price = {{"coin", 3}}, offer = {type = 'give-item', item = 'raw-fish', count = 1}},
{price = {{"coin", 10}}, offer = {type = 'give-item', item = 'wood', count = 50}},
{price = {{"coin", 10}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}},
{price = {{"coin", 10}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}},
@ -33,6 +34,7 @@ local function set_offers(town_center)
{price = {{'stone', 12}}, offer = {type = 'give-item', item = "coin"}},
{price = {{'coal', 12}}, offer = {type = 'give-item', item = "coin"}},
{price = {{'uranium-ore', 10}}, offer = {type = 'give-item', item = "coin"}},
{price = {{'uranium-ore', 10}}, offer = {type = 'give-item', item = "coin"}},
}
for _, item in pairs(market_items) do
market.add_market_item(item)

View File

@ -1,6 +1,6 @@
local Public = {}
local item_drop_radius = 2
local item_drop_radius = 1.75
function Public.set_player_color(player)
if player.force.index == 1 then
@ -31,7 +31,7 @@ function Public.set_town_color(event)
town_center.color = {player.color.r, player.color.g, player.color.b}
rendering.set_color(town_center.town_caption, town_center.color)
for _, p in pairs(player.force.players) do
Public.set_player_color(player)
Public.set_player_color(p)
end
end
@ -63,6 +63,26 @@ local function ally_homeless(player, target)
if requesting_force.index == 1 then
global.towny.requests[player.index] = target_force.name
local target_player = false
if target.type == "character" then
target_player = target.player
else
target_player = game.players[target_force.name]
end
if target_player then
if global.towny.requests[target_player.index] then
if global.towny.requests[target_player.index] == player.name then
if global.towny.town_centers[target_force.name] then
game.print(">> " .. player.name .. " has settled in " .. target_force.name .. "'s Town!", {255, 255, 0})
Public.add_player_to_town(player, global.towny.town_centers[target_force.name])
return true
end
end
end
end
game.print(">> " .. player.name .. " wants to settle in " .. target_force.name .. " Town!", {255, 255, 0})
return true
end
@ -76,7 +96,7 @@ local function ally_homeless(player, target)
if global.towny.requests[target_player.index] then
if global.towny.requests[target_player.index] == player.force.name then
game.print(">> " .. player.name .. " has accepted " .. target_player.name .. " into their Town!", {255, 255, 0})
Public.add_player_to_town(target_player, global.towny.town_centers[player.name])
Public.add_player_to_town(target_player, global.towny.town_centers[player.force.name])
return true
end
end
@ -104,7 +124,7 @@ function Public.ally_town(player, item)
local position = item.position
local surface = player.surface
local area = {{position.x - item_drop_radius, position.y - item_drop_radius}, {position.x + item_drop_radius, position.y + item_drop_radius}}
local requesting_force = player.force
local target = false
for _, e in pairs(surface.find_entities_filtered({type = {"character", "market"}, area = area})) do
@ -115,6 +135,7 @@ function Public.ally_town(player, item)
end
if not target then return end
if target.force.index == 2 or target.force.index == 3 then return end
if ally_homeless(player, target) then return end
ally_neighbour_towns(player, target)
@ -130,8 +151,7 @@ function Public.declare_war(player, item)
if not target then return end
local target_force = target.force
if target_force.index == 1 then return end
if target_force.index <= 3 then return end
if requesting_force.name == target_force.name then
if player.name ~= target.force.name then
@ -146,6 +166,7 @@ function Public.declare_war(player, item)
if target_player.index == player.index then return end
Public.set_player_to_homeless(target_player)
game.print(">> " .. player.name .. " has banished " .. target_player.name .. " from their Town!", {255, 255, 0})
global.towny.requests[player.index] = nil
end
return
end

View File

@ -4,14 +4,14 @@ local Public = {}
local math_random = math.random
local table_insert = table.insert
local min_distance_to_spawn = 1
local min_distance_to_spawn = 96
local square_min_distance_to_spawn = min_distance_to_spawn ^ 2
local town_radius = 30
local radius_between_towns = town_radius * 4
local radius_between_towns = 160
local colors = {}
local c1 = 250
local c2 = 150
local c2 = 175
local c3 = -25
for v = c1, c2, c3 do
table.insert(colors, {0, 0, v})
@ -101,6 +101,7 @@ local clear_blacklist_types = {
}
local starter_supplies = {
{name = "raw-fish", count = 3},
{name = "grenade", count = 3},
{name = "stone", count = 32},
{name = "submachine-gun", count = 1},