1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-25 21:29:06 +02:00
This commit is contained in:
MewMew 2019-12-23 18:09:01 +01:00
parent df71d20de1
commit b1032a0772
3 changed files with 22 additions and 12 deletions

@ -44,7 +44,11 @@ local function on_player_died(event)
if cause.name == "character" then
if not player.name then return end
if not cause.player.name then return end
game.print(player.name .. tag .. " was killed by " .. cause.player.name .. " " .. cause.player.tag .. ".", message_color)
if cause.player.tag then
game.print(player.name .. tag .. " was killed by " .. cause.player.name .. " " .. cause.player.tag .. ".", message_color)
else
game.print(player.name .. tag .. " was killed by " .. cause.player.name .. ".", message_color)
end
return
end

@ -125,8 +125,12 @@ local function ally_outlander(player, target)
if global.towny.requests[target_player.index] then
if global.towny.requests[target_player.index] == player.force.name then
if not can_force_accept_member(player.force) then return true end
game.print(">> " .. player.name .. " has accepted " .. target_player.name .. " into their Town!", {255, 255, 0})
if not can_force_accept_member(player.force) then return true end
if player.force.name == player.name then
game.print(">> " .. player.name .. " has accepted " .. target_player.name .. " into their Town!", {255, 255, 0})
else
game.print(">> " .. player.name .. " has accepted " .. target_player.name .. " into" .. player.force.name .. "'s Town!", {255, 255, 0})
end
Public.add_player_to_town(target_player, global.towny.town_centers[player.force.name])
return true
end

@ -5,7 +5,7 @@ local math_random = math.random
local table_insert = table.insert
local math_floor = math.floor
local min_distance_to_spawn = 1
local min_distance_to_spawn = 136
local square_min_distance_to_spawn = min_distance_to_spawn ^ 2
local town_radius = 27
local radius_between_towns = 160
@ -13,8 +13,8 @@ local ore_amount = 750
local colors = {}
local c1 = 250
local c2 = 225
local c3 = -25
local c2 = 210
local c3 = -40
for v = c1, c2, c3 do
table.insert(colors, {0, 0, v})
end
@ -287,24 +287,26 @@ end
local function is_color_used(color, town_centers)
for k, center in pairs(town_centers) do
if center.color == color then return true end
if center.color then
if center.color.r == color.r and center.color.g == color.g and center.color.b == color.b then return true end
end
end
end
local function get_color()
local shuffle_index = {}
local town_centers = global.towny.town_centers
local color
local c
local shuffle_index = {}
for i = 1, #colors, 1 do shuffle_index[i] = i end
table.shuffle_table(shuffle_index)
for i = 1, #colors, 1 do
color = colors[shuffle_index[i]]
if not is_color_used(color, town_centers) then return color end
c = {r = colors[shuffle_index[i]][1], g = colors[shuffle_index[i]][2], b = colors[shuffle_index[i]][3],}
if not is_color_used(c, town_centers) then return c end
end
return color
return c
end
function Public.found(event)