mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-04-17 11:46:41 +02:00
pirates: flying text to everyone on surface
This commit is contained in:
parent
3a5134a014
commit
d8a39168ea
@ -1621,14 +1621,19 @@ function Public.check_for_cliff_explosives_in_hold_wooden_chests()
|
||||
queued_chests_timers[i] = nil
|
||||
else
|
||||
local tick_tacks = { '*tick*', '*tick*', '*tack*', '*tak*', '*tik*', '*tok*' }
|
||||
-- surface.create_entity(
|
||||
-- {
|
||||
-- name = 'flying-text',
|
||||
-- position = chest.position,
|
||||
-- text = tick_tacks[Math.random(#tick_tacks)],
|
||||
-- color = { r = 0.75, g = 0.75, b = 0.75 }
|
||||
-- }
|
||||
-- )
|
||||
|
||||
for _, player in pairs(game.players) do
|
||||
if player.surface_index == surface.index then
|
||||
player.create_local_flying_text(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = chest.position,
|
||||
text = tick_tacks[Math.random(#tick_tacks)],
|
||||
color = { r = 0.75, g = 0.75, b = 0.75 }
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
-- we probably don't want to have it in the queue anymore if it's invalid now, do we?
|
||||
|
@ -193,21 +193,26 @@ function Public.parrot_speak(force, message)
|
||||
Server.to_discord_embed_raw({ '', '[' .. memory.name .. '] ', { 'pirates.notify_parrot' }, ' ', message }, true)
|
||||
end
|
||||
|
||||
function Public.flying_text(player, position, text)
|
||||
player.create_local_flying_text {
|
||||
name = 'flying-text',
|
||||
position = { position.x - 0.7, position.y - 3.05 },
|
||||
text = text
|
||||
}
|
||||
function Public.flying_text(surface, position, text)
|
||||
for _, player in pairs(game.players) do
|
||||
if player.surface_index == surface.index then
|
||||
player.create_local_flying_text {
|
||||
position = { position.x - 0.7, position.y - 3.05 },
|
||||
text = text
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.flying_text_small(player, position, text) --differs just in the location of the text, more suitable for small things like '+'
|
||||
player.create_local_flying_text {
|
||||
name = 'flying-text',
|
||||
position = { position.x - 0.08, position.y - 1.5 },
|
||||
-- position = {position.x - 0.06, position.y - 1.5},
|
||||
text = text
|
||||
}
|
||||
function Public.flying_text_small(surface, position, text) --differs just in the location of the text, more suitable for small things like '+'
|
||||
for _, player in pairs(game.players) do
|
||||
if player.surface_index == surface.index then
|
||||
player.create_local_flying_text {
|
||||
position = { position.x - 0.08, position.y - 1.5 },
|
||||
text = text
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.processed_loot_data(raw_data)
|
||||
@ -401,9 +406,9 @@ function Public.give(player, stacks, spill_position, short_form, spill_surface,
|
||||
if #stacks2 > 1 then
|
||||
text2 = '(' .. text2 .. ')'
|
||||
end
|
||||
Public.flying_text(player, flying_text_position, text1 .. ' [font=count-font]' .. text2 .. '[/font]')
|
||||
Public.flying_text(player.surface, flying_text_position, text1 .. ' [font=count-font]' .. text2 .. '[/font]')
|
||||
else
|
||||
Public.flying_text(player, flying_text_position, text1)
|
||||
Public.flying_text(player.surface, flying_text_position, text1)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -39,14 +39,18 @@ local function create_flying_text(surface, position, text)
|
||||
if not surface.valid then
|
||||
return
|
||||
end
|
||||
-- surface.create_entity(
|
||||
-- {
|
||||
-- name = 'flying-text',
|
||||
-- position = position,
|
||||
-- text = text,
|
||||
-- color = { r = 0.75, g = 0.75, b = 0.75 }
|
||||
-- }
|
||||
-- )
|
||||
|
||||
for _, player in pairs(game.players) do
|
||||
if player.surface_index == surface.index then
|
||||
player.create_local_flying_text(
|
||||
{
|
||||
position = position,
|
||||
text = text,
|
||||
color = { r = 0.75, g = 0.75, b = 0.75 }
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
if text == '...' then
|
||||
return
|
||||
end
|
||||
@ -60,14 +64,17 @@ local function create_kaboom(force_name, surface, position, name)
|
||||
local target = position
|
||||
local speed = 0.5
|
||||
if name == 'defender-capsule' or name == 'destroyer-capsule' or name == 'distractor-capsule' then
|
||||
-- surface.create_entity(
|
||||
-- {
|
||||
-- name = 'flying-text',
|
||||
-- position = position,
|
||||
-- text = '(((Sentries Engaging Target)))',
|
||||
-- color = { r = 0.8, g = 0.0, b = 0.0 }
|
||||
-- }
|
||||
-- )
|
||||
for _, player in pairs(game.players) do
|
||||
if player.surface_index == surface.index then
|
||||
player.create_local_flying_text(
|
||||
{
|
||||
position = position,
|
||||
text = '(((Sentries Engaging Target)))',
|
||||
color = { r = 0.8, g = 0.0, b = 0.0 }
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
local nearest_player_unit = surface.find_nearest_enemy({ position = position, max_distance = 128, force = force_name })
|
||||
if nearest_player_unit then
|
||||
target = nearest_player_unit.position
|
||||
|
@ -316,7 +316,7 @@ function Public.event_on_market_item_purchased(event)
|
||||
local text1 = '[color=1,1,1]+' .. thisPurchaseData.offer_giveitem_count .. '[/color] [item=' .. thisPurchaseData.offer_giveitem_name .. ']'
|
||||
local text2 = '[color=' .. flying_text_color.r .. ',' .. flying_text_color.g .. ',' .. flying_text_color.b .. '](' .. inv.get_item_count(thisPurchaseData.offer_giveitem_name) .. ')[/color]'
|
||||
|
||||
Common.flying_text(player, player.position, text1 .. ' [font=count-font]' .. text2 .. '[/font]')
|
||||
Common.flying_text(player.surface, player.position, text1 .. ' [font=count-font]' .. text2 .. '[/font]')
|
||||
else
|
||||
local decay_param = Balance.barter_decay_parameter()
|
||||
if thisPurchaseData.decay_type == 'fast_decay' then decay_param = Balance.barter_decay_parameter() ^ 3 end
|
||||
@ -326,7 +326,7 @@ function Public.event_on_market_item_purchased(event)
|
||||
local text1 = '[color=1,1,1]+' .. thisPurchaseData.offer_giveitem_count .. '[/color] [item=' .. thisPurchaseData.offer_giveitem_name .. ']'
|
||||
local text2 = '[color=' .. flying_text_color.r .. ',' .. flying_text_color.g .. ',' .. flying_text_color.b .. '](' .. inv.get_item_count(thisPurchaseData.offer_giveitem_name) .. ')[/color]'
|
||||
|
||||
Common.flying_text(player, player.position, text1 .. ' [font=count-font]' .. text2 .. '[/font]')
|
||||
Common.flying_text(player.surface, player.position, text1 .. ' [font=count-font]' .. text2 .. '[/font]')
|
||||
|
||||
--update market trades:
|
||||
thisPurchaseData.alloffers[offer_index].offer.count = Math.max(Math.floor(thisPurchaseData.alloffers[offer_index].offer.count * decay_param), 1)
|
||||
|
@ -90,17 +90,23 @@ local function create_floaty_text(surface, position, name, count)
|
||||
else
|
||||
this.floating_text_y_offsets[position.x .. '_' .. position.y] = 0
|
||||
end
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = {
|
||||
position.x,
|
||||
position.y + this.floating_text_y_offsets[position.x .. '_' .. position.y]
|
||||
},
|
||||
text = { '', '-', count, ' ', prototypes.item[name].localised_name },
|
||||
color = { r = 255, g = 255, b = 255 }
|
||||
}
|
||||
)
|
||||
|
||||
if not surface.valid then return end
|
||||
|
||||
for _, player in pairs(game.players) do
|
||||
if player.surface_index == surface.index then
|
||||
player.create_local_flying_text(
|
||||
{
|
||||
position = {
|
||||
position.x,
|
||||
position.y + this.floating_text_y_offsets[position.x .. '_' .. position.y]
|
||||
},
|
||||
text = { '', '-', count, ' ', prototypes.item[name].localised_name },
|
||||
color = { r = 255, g = 255, b = 255 }
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function prepare_floaty_text(list, surface, position, name, count)
|
||||
|
@ -48,24 +48,26 @@ local whitelist = {
|
||||
}
|
||||
|
||||
local function on_entity_damaged(event)
|
||||
if not event.cause then
|
||||
return
|
||||
end
|
||||
if not event.cause.valid then
|
||||
return
|
||||
end
|
||||
if not whitelist[event.cause.name] then
|
||||
return
|
||||
end
|
||||
if not event.cause then return end
|
||||
if not event.cause.valid then return end
|
||||
|
||||
if not whitelist[event.cause.name] then return end
|
||||
|
||||
local surface = event.cause.surface
|
||||
if not surface.valid then return end
|
||||
|
||||
if math_random(1, 5) == 1 then
|
||||
event.cause.surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = event.cause.position,
|
||||
text = strings[math_random(1, size_of_strings)],
|
||||
color = {r = math_random(130, 170), g = math_random(130, 170), b = 130}
|
||||
}
|
||||
)
|
||||
for _, player in pairs(game.players) do
|
||||
if player.surface_index == event.cause.surface_index then
|
||||
player.create_local_flying_text(
|
||||
{
|
||||
position = event.cause.position,
|
||||
text = strings[math_random(1, size_of_strings)],
|
||||
color = { r = math_random(130, 170), g = math_random(130, 170), b = 130 }
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user