mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-25 21:29:06 +02:00
More porting for 2.0
This commit is contained in:
parent
8942a5714a
commit
93cdb0fb54
@ -17,12 +17,10 @@ require 'utils.chatbot'
|
||||
require 'utils.common_commands'
|
||||
require 'utils.antigrief'
|
||||
require 'utils.debug.command'
|
||||
require 'modules.corpse_markers'
|
||||
require 'modules.floaty_chat'
|
||||
require 'modules.show_inventory'
|
||||
require 'modules.inserter_drops_pickup'
|
||||
require 'modules.autostash'
|
||||
require 'modules.blueprint_requesting'
|
||||
|
||||
require 'utils.gui.init'
|
||||
require 'utils.freeplay'
|
||||
|
@ -143,7 +143,7 @@ win_conditions=Win conditions
|
||||
|
||||
season=[font=default-bold]Season: [/font]
|
||||
rounds_survived=[font=default-bold]Rounds survived: [/font]
|
||||
win_streak=[font=default-bold]Current win streak: [/font]
|
||||
current_streak=[font=default-bold]Current win streak: [/font]
|
||||
buffs=[font=default-bold]Buffs: [/font]
|
||||
zone=[font=default-bold]Breach zones: [/font]
|
||||
wave=[font=default-bold]Survive until wave: [/font]
|
||||
@ -164,6 +164,7 @@ research=[font=default-bold]Research __1__: [/font]
|
||||
|
||||
season_tooltip=Whenever a new season starts, all buffs are reset.\nGerkiz tries to add new content for each season that starts.\nSeason resets in __1__ days.
|
||||
rounds_survived_tooltip=Winning the game increases this number by 1.\nThis number resets as of now every 2 months.
|
||||
current_streak_tooltip=How many rounds will you survive?\nThis number resets when the game is lost.
|
||||
buff_tooltip=Each buff that is given to the players is listed here.\nClick the icon to the right to view the buffs.
|
||||
buff_tooltip_click=Click the icon view the buffs.
|
||||
zone_tooltip=Complete this objective by breaching/moving forward until you've reached the given zone.
|
||||
|
@ -291,7 +291,7 @@ local compare_player_and_train = function (player, entity)
|
||||
color = color,
|
||||
}
|
||||
)
|
||||
player.print(msg, color)
|
||||
player.print(msg, { color = color })
|
||||
elseif locomotive_distance_too_far then
|
||||
local msg = 'Warning! You are too far away from the train! TURN BACK!'
|
||||
player.create_local_flying_text(
|
||||
@ -301,7 +301,7 @@ local compare_player_and_train = function (player, entity)
|
||||
color = color,
|
||||
}
|
||||
)
|
||||
player.print(msg, color)
|
||||
player.print(msg, { color = color })
|
||||
if entity.health then
|
||||
if car and car.health_pool and car.health_pool.health then
|
||||
car.health_pool.health = car.health_pool.health - 500
|
||||
|
@ -6,7 +6,7 @@ local WD = require 'modules.wave_defense.table'
|
||||
local Discord = require 'utils.discord_handler'
|
||||
local Commands = require 'utils.commands'
|
||||
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
|
||||
local scenario_name = Public.scenario_name
|
||||
local scenario_name = 'Mtn Fortress'
|
||||
|
||||
local gather_time_token =
|
||||
Task.register(
|
||||
|
@ -264,6 +264,7 @@ local function set_train_final_health(final_damage_amount, repair)
|
||||
locomotive.destructible = false
|
||||
locomotive.health = 1
|
||||
Public.set('game_lost', true)
|
||||
Public.set_stateful('current_streak', 0)
|
||||
Public.loco_died()
|
||||
end
|
||||
|
||||
|
@ -969,6 +969,8 @@ local function on_primary_target_missing()
|
||||
end
|
||||
|
||||
WD.set('target', locomotive)
|
||||
local target_settings = WD.get_es('target_settings')
|
||||
target_settings.main_target = locomotive
|
||||
WD.set_main_target(locomotive)
|
||||
end
|
||||
|
||||
@ -1552,7 +1554,6 @@ function Public.is_creativity_mode_on()
|
||||
local creative_enabled = Misc.get('creative_enabled')
|
||||
if creative_enabled then
|
||||
WD.set('next_wave', 1000)
|
||||
Collapse.start_now(true)
|
||||
Public.set_difficulty()
|
||||
end
|
||||
end
|
||||
@ -1746,7 +1747,7 @@ function Public.on_research_finished(event)
|
||||
local research_name = research.name
|
||||
local force = research.force
|
||||
|
||||
if event.tick > 100 then
|
||||
if event.tick > 2000 then
|
||||
if Public.get('print_tech_to_discord') and force.name == 'player' then
|
||||
Server.to_discord_embed_raw('<a:Modded:835932131036364810> ' .. research_name:gsub('^%l', string.upper) .. ' has been researched!')
|
||||
end
|
||||
@ -1756,7 +1757,7 @@ function Public.on_research_finished(event)
|
||||
Public.set('toolbelt_researched_count', 10)
|
||||
end
|
||||
|
||||
if script.feature_flags.quality then
|
||||
if script.active_mods.quality then
|
||||
local quality_list = Public.get('quality_list')
|
||||
if research.name == 'quality-module' then
|
||||
quality_list[#quality_list + 1] = 'uncommon'
|
||||
|
@ -1028,7 +1028,7 @@ local function gui_opened(event)
|
||||
}
|
||||
)
|
||||
|
||||
if script.feature_flags.quality then
|
||||
if script.active_mods.quality then
|
||||
if game.forces.player.technologies['quality-module'].researched then
|
||||
local quality_list = Public.get('quality_list')
|
||||
local bg_right = bottom_grid.add({ type = 'label', caption = ({ 'locomotive.quality_text' }) })
|
||||
|
@ -277,7 +277,7 @@ function Public.reset_map()
|
||||
wave_defense_table.game_lost = false
|
||||
wave_defense_table.spawn_position = { x = 0, y = 84 }
|
||||
WD.alert_boss_wave(true)
|
||||
WD.enable_side_target(true)
|
||||
WD.enable_side_target(false)
|
||||
WD.remove_entities(true)
|
||||
WD.enable_threat_log(false) -- creates waaaay to many entries in the global table
|
||||
WD.check_collapse_position(true)
|
||||
@ -668,9 +668,9 @@ Event.add(
|
||||
|
||||
Event.on_init(function ()
|
||||
local nauvis = game.surfaces.nauvis
|
||||
-- nauvis.clear(true)
|
||||
-- nauvis.request_to_generate_chunks({ 0, 0 }, 3)
|
||||
-- nauvis.force_generate_chunk_requests()
|
||||
nauvis.clear(true)
|
||||
nauvis.request_to_generate_chunks({ 0, 0 }, 3)
|
||||
nauvis.force_generate_chunk_requests()
|
||||
end)
|
||||
|
||||
return Public
|
||||
|
@ -79,6 +79,45 @@ local function pretty_format(input)
|
||||
return result
|
||||
end
|
||||
|
||||
local function final_arena_disabled()
|
||||
if stateful.collection.final_arena_disabled then
|
||||
game.print('[color=yellow][Mtn v3][/color] Game won!')
|
||||
game.print('[color=yellow][Mtn v3][/color] Final battle arena is currently being tweaked.')
|
||||
collection.game_won = true
|
||||
stateful.collection.gather_time = 0
|
||||
stateful.collection.gather_time_timer = 0
|
||||
collection.survive_for = 0
|
||||
collection.survive_for_timer = 0
|
||||
refresh_frames()
|
||||
|
||||
local reversed = Public.get_stateful_settings('reversed')
|
||||
if reversed then
|
||||
Public.set_stateful_settings('reversed', false)
|
||||
else
|
||||
Public.set_stateful_settings('reversed', true)
|
||||
end
|
||||
|
||||
collection.game_won_notified = true
|
||||
refresh_boss_frame()
|
||||
play_game_won()
|
||||
WD.disable_spawning_biters(true)
|
||||
Collapse.start_now(false)
|
||||
WD.nuke_wave_gui()
|
||||
Server.to_discord_embed('Game won!')
|
||||
stateful.rounds_survived = stateful.rounds_survived + 1
|
||||
stateful.selected_objectives = nil
|
||||
local buff = Stateful.save_settings()
|
||||
notify_won_to_discord(buff)
|
||||
local locomotive = Public.get('locomotive')
|
||||
if locomotive and locomotive.valid then
|
||||
locomotive.surface.spill_item_stack({ position = locomotive.position, stack = { name = 'coin', count = 512, quality = 'normal' } })
|
||||
end
|
||||
Public.set('game_reset_tick', 5400)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function notify_won_to_discord(buff)
|
||||
if not buff then
|
||||
return error('Buff is required when sending message to discord.', 2)
|
||||
@ -113,26 +152,31 @@ local function notify_won_to_discord(buff)
|
||||
inline = 'false'
|
||||
},
|
||||
field3 = {
|
||||
text1 = 'Current winning streak:',
|
||||
text2 = stateful.current_streak,
|
||||
inline = 'false'
|
||||
},
|
||||
field4 = {
|
||||
text1 = 'Wave:',
|
||||
text2 = format_number(wave, true),
|
||||
inline = 'false'
|
||||
},
|
||||
field4 = {
|
||||
field5 = {
|
||||
text1 = 'Total connected players:',
|
||||
text2 = total_players,
|
||||
inline = 'false'
|
||||
},
|
||||
field5 = {
|
||||
field6 = {
|
||||
text1 = 'Pickaxe Upgrade:',
|
||||
text2 = pick_tier .. ' (' .. upgrades.pickaxe_tier .. ')',
|
||||
inline = 'false'
|
||||
},
|
||||
field6 = {
|
||||
field7 = {
|
||||
text1 = 'Connected players:',
|
||||
text2 = total_connected_players,
|
||||
inline = 'false'
|
||||
},
|
||||
field7 = {
|
||||
field8 = {
|
||||
text1 = 'Buff granted:',
|
||||
text2 = buff.discord,
|
||||
inline = 'false'
|
||||
@ -547,6 +591,22 @@ local function boss_frame(player, alert)
|
||||
data.rounds_survived_label = rounds_survived_right_flow.add({ type = 'label', caption = stateful.rounds_survived })
|
||||
spacer(frame)
|
||||
|
||||
local current_streak_tbl = frame.add { type = 'table', column_count = 2 }
|
||||
current_streak_tbl.style.horizontally_stretchable = true
|
||||
|
||||
local current_streak_flow = current_streak_tbl.add({ type = 'flow' })
|
||||
current_streak_flow.style.horizontal_align = 'left'
|
||||
current_streak_flow.style.horizontally_stretchable = true
|
||||
|
||||
current_streak_flow.add({ type = 'label', caption = { 'stateful.current_streak' }, tooltip = { 'stateful.current_streak_tooltip' } })
|
||||
frame.add({ type = 'line', direction = 'vertical' })
|
||||
local current_streak_right_flow = current_streak_tbl.add({ type = 'flow' })
|
||||
current_streak_right_flow.style.horizontal_align = 'right'
|
||||
current_streak_right_flow.style.horizontally_stretchable = true
|
||||
|
||||
data.current_streak_label = current_streak_right_flow.add({ type = 'label', caption = stateful.current_streak })
|
||||
spacer(frame)
|
||||
|
||||
frame.add({ type = 'line' })
|
||||
|
||||
spacer(frame)
|
||||
@ -664,6 +724,22 @@ main_frame = function (player)
|
||||
data.rounds_survived_label = rounds_survived_right_flow.add({ type = 'label', caption = stateful.rounds_survived })
|
||||
spacer(frame)
|
||||
|
||||
local current_streak_tbl = frame.add { type = 'table', column_count = 2 }
|
||||
current_streak_tbl.style.horizontally_stretchable = true
|
||||
|
||||
local current_streak_flow = current_streak_tbl.add({ type = 'flow' })
|
||||
current_streak_flow.style.horizontal_align = 'left'
|
||||
current_streak_flow.style.horizontally_stretchable = true
|
||||
|
||||
current_streak_flow.add({ type = 'label', caption = { 'stateful.current_streak' }, tooltip = { 'stateful.current_streak_tooltip' } })
|
||||
frame.add({ type = 'line', direction = 'vertical' })
|
||||
local current_streak_right_flow = current_streak_tbl.add({ type = 'flow' })
|
||||
current_streak_right_flow.style.horizontal_align = 'right'
|
||||
current_streak_right_flow.style.horizontally_stretchable = true
|
||||
|
||||
data.current_streak_label = current_streak_right_flow.add({ type = 'label', caption = stateful.current_streak })
|
||||
spacer(frame)
|
||||
|
||||
frame.add({ type = 'line' })
|
||||
|
||||
spacer(frame)
|
||||
@ -819,6 +895,10 @@ local function update_data()
|
||||
if data.rounds_survived_label and data.rounds_survived_label.valid then
|
||||
data.rounds_survived_label.caption = stateful.rounds_survived
|
||||
end
|
||||
|
||||
if data.current_streak_label and data.current_streak_label.valid then
|
||||
data.current_streak_label.caption = stateful.current_streak
|
||||
end
|
||||
if data.randomized_zone_label and data.randomized_zone_label.valid and stateful.objectives.randomized_zone then
|
||||
if breached_wall >= stateful.objectives.randomized_zone then
|
||||
data.randomized_zone_label.caption = breached_wall .. '/' .. stateful.objectives.randomized_zone .. ' [img=utility/check_mark_green]'
|
||||
@ -938,6 +1018,10 @@ local function update_data()
|
||||
data_boss.rounds_survived_label.caption = stateful.rounds_survived
|
||||
end
|
||||
|
||||
if data_boss.current_streak_label and data_boss.current_streak_label.valid then
|
||||
data_boss.current_streak_label.caption = stateful.current_streak
|
||||
end
|
||||
|
||||
if collection.survive_for and data_boss.survive_for and data_boss.survive_for.valid then
|
||||
if not stateful.objectives_completed.warn_players then
|
||||
stateful.objectives_completed.warn_players = true
|
||||
@ -1173,39 +1257,7 @@ local function update_raw()
|
||||
Alert.alert_all_players(300, 'All objectives has been completed!')
|
||||
Alert.alert_all_players(300, 'Take your time to prepare for the final push!')
|
||||
|
||||
if stateful.collection.final_arena_disabled then
|
||||
game.print('[color=yellow][Mtn v3][/color] Game won!')
|
||||
game.print('[color=yellow][Mtn v3][/color] Final battle arena is currently being tweaked.')
|
||||
collection.game_won = true
|
||||
stateful.collection.gather_time = 0
|
||||
stateful.collection.gather_time_timer = 0
|
||||
collection.survive_for = 0
|
||||
collection.survive_for_timer = 0
|
||||
refresh_frames()
|
||||
|
||||
local reversed = Public.get_stateful_settings('reversed')
|
||||
if reversed then
|
||||
Public.set_stateful_settings('reversed', false)
|
||||
else
|
||||
Public.set_stateful_settings('reversed', true)
|
||||
end
|
||||
|
||||
collection.game_won_notified = true
|
||||
refresh_boss_frame()
|
||||
play_game_won()
|
||||
WD.disable_spawning_biters(true)
|
||||
Collapse.start_now(false)
|
||||
WD.nuke_wave_gui()
|
||||
Server.to_discord_embed('Game won!')
|
||||
stateful.rounds_survived = stateful.rounds_survived + 1
|
||||
stateful.selected_objectives = nil
|
||||
local buff = Stateful.save_settings()
|
||||
notify_won_to_discord(buff)
|
||||
local locomotive = Public.get('locomotive')
|
||||
if locomotive and locomotive.valid then
|
||||
locomotive.surface.spill_item_stack({ position = locomotive.position, stack = { name = 'coin', count = 512, quality = 'normal' } })
|
||||
end
|
||||
Public.set('game_reset_tick', 5400)
|
||||
if final_arena_disabled() then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -20,6 +20,7 @@ local Difficulty = require 'modules.difficulty_vote_by_amount'
|
||||
local this = {
|
||||
enabled = false,
|
||||
rounds_survived = 0,
|
||||
current_streak = 0,
|
||||
season = 1,
|
||||
buffs = {},
|
||||
reset_after = 60,
|
||||
@ -1408,6 +1409,8 @@ function Public.save_settings()
|
||||
local granted_buff = grant_non_limit_reached_buff()
|
||||
this.buffs[#this.buffs + 1] = granted_buff
|
||||
|
||||
this.current_streak = this.current_streak + 1
|
||||
|
||||
local settings = {
|
||||
objectives_time_spent = this.objectives_time_spent,
|
||||
rounds_survived = this.rounds_survived,
|
||||
|
@ -9,7 +9,7 @@ local random = math.random
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
function(tbl)
|
||||
function (tbl)
|
||||
this = tbl
|
||||
end
|
||||
)
|
||||
@ -19,9 +19,9 @@ init - Initialize claim system.
|
||||
@param names - Table of entity names that should be used as a marker.
|
||||
@param max_distance - Maximal distance allowed between markers
|
||||
--]]
|
||||
Public.init = function(names, max_distance)
|
||||
Public.init = function (names, max_distance)
|
||||
if type(names) ~= 'table' then
|
||||
names = {names}
|
||||
names = { names }
|
||||
end
|
||||
|
||||
this._claims_info = {}
|
||||
@ -112,7 +112,7 @@ end
|
||||
on_build_entity - Event processing function.
|
||||
@param ent - Entity
|
||||
--]]
|
||||
Public.on_built_entity = function(ent)
|
||||
Public.on_built_entity = function (ent)
|
||||
if not claims_in_markers(ent.name) then
|
||||
return
|
||||
end
|
||||
@ -153,7 +153,7 @@ end
|
||||
on_entity_died - Event processing function.
|
||||
@param ent - Entity
|
||||
--]]
|
||||
Public.on_entity_died = function(ent)
|
||||
Public.on_entity_died = function (ent)
|
||||
if not claims_in_markers(ent.name) then
|
||||
return
|
||||
end
|
||||
@ -164,7 +164,7 @@ end
|
||||
on_player_mined_entity - Event processing function.
|
||||
@param ent - Entity
|
||||
--]]
|
||||
Public.on_player_mined_entity = function(ent)
|
||||
Public.on_player_mined_entity = function (ent)
|
||||
Public.on_entity_died(ent)
|
||||
end
|
||||
|
||||
@ -172,18 +172,18 @@ end
|
||||
on_player_died - Event processing function
|
||||
@param player - Player
|
||||
--]]
|
||||
Public.on_player_died = function(player)
|
||||
Public.on_player_died = function (player)
|
||||
this._claims_info[player.name] = nil
|
||||
end
|
||||
|
||||
Public.clear_player_base = function(player)
|
||||
Public.clear_player_base = function (player)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local position = player.position
|
||||
local x, y = position.x, position.y
|
||||
local entities = player.surface.find_entities_filtered {force = player.force, area = {{x - 50, y - 50}, {x + 50, y + 50}}}
|
||||
local entities = player.surface.find_entities_filtered { force = player.force, area = { { x - 50, y - 50 }, { x + 50, y + 50 } } }
|
||||
|
||||
for i = 1, #entities do
|
||||
local e = entities[i]
|
||||
@ -202,7 +202,7 @@ end
|
||||
get_claims - Get all claims data points for given force.
|
||||
@param f_name - Force name.
|
||||
--]]
|
||||
Public.get_claims = function(f_name)
|
||||
Public.get_claims = function (f_name)
|
||||
if this._claims_info[f_name] == nil then
|
||||
return {}
|
||||
end
|
||||
@ -236,7 +236,7 @@ end
|
||||
set_visibility_to - Specifies who can see the claims and redraws.
|
||||
@param name - Name of a player.
|
||||
--]]
|
||||
Public.set_visibility_to = function(name)
|
||||
Public.set_visibility_to = function (name)
|
||||
for _, p in pairs(this._claims_visible_to) do
|
||||
if p == name then
|
||||
return
|
||||
@ -251,7 +251,7 @@ end
|
||||
remove_visibility_from - Remove the claim visibility from the player.
|
||||
@param name - Name of a player.
|
||||
--]]
|
||||
Public.remove_visibility_from = function(name)
|
||||
Public.remove_visibility_from = function (name)
|
||||
for i = 1, #this._claims_visible_to do
|
||||
local p = this._claims_visible_to[i]
|
||||
if p == name then
|
||||
|
@ -167,8 +167,8 @@ remove_character = function (unit_number)
|
||||
if data.entity and data.entity.valid then
|
||||
data.entity.destroy()
|
||||
end
|
||||
if rendering.is_valid(data.render_id) then
|
||||
rendering.destroy(data.render_id)
|
||||
if data.render_id then
|
||||
data.render_id.destroy()
|
||||
end
|
||||
remove(this.characters, index)
|
||||
end
|
||||
|
@ -8,7 +8,7 @@ local this = {
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
function(t)
|
||||
function (t)
|
||||
this = t
|
||||
end
|
||||
)
|
||||
@ -44,24 +44,23 @@ local function compute_fullness(player, position)
|
||||
local damage = ceil((warn_player.count / 2) * warn_player.count)
|
||||
if player.character.health >= damage then
|
||||
player.character.damage(damage, 'player', 'explosion')
|
||||
player.character.surface.create_entity({name = 'water-splash', position = player.position})
|
||||
player.character.surface.create_entity({ name = 'water-splash', position = player.position })
|
||||
local messages = {
|
||||
'Ouch.. That hurt! Better be careful now.',
|
||||
'Just a fleshwound.',
|
||||
'Better keep those hands to yourself or you might loose them.'
|
||||
}
|
||||
player.surface.create_entity(
|
||||
player.create_local_flying_text(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = {position.x, position.y + 0.6},
|
||||
position = { position.x, position.y + 0.6 },
|
||||
text = messages[random(1, #messages)],
|
||||
color = {r = 0.75, g = 0.0, b = 0.0}
|
||||
color = { r = 0.75, g = 0.0, b = 0.0 }
|
||||
}
|
||||
)
|
||||
else
|
||||
player.character.die('enemy')
|
||||
is_player_warned(player, true)
|
||||
game.print(player.name .. ' should have emptied their pockets.', {r = 0.75, g = 0.0, b = 0.0})
|
||||
game.print(player.name .. ' should have emptied their pockets.', { r = 0.75, g = 0.0, b = 0.0 })
|
||||
return free_slots
|
||||
end
|
||||
end
|
||||
@ -70,12 +69,11 @@ local function compute_fullness(player, position)
|
||||
end
|
||||
if free_slots > 1 then
|
||||
if floor(inventory_size / free_slots) == 10 then -- When player has 10% free slots
|
||||
player.surface.create_entity(
|
||||
player.create_local_flying_text(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = {position.x, position.y + 0.6},
|
||||
position = { position.x, position.y + 0.6 },
|
||||
text = 'You are feeling heavy',
|
||||
color = {r = 1.0, g = 0.5, b = 0.0}
|
||||
color = { r = 1.0, g = 0.5, b = 0.0 }
|
||||
}
|
||||
)
|
||||
end
|
||||
@ -113,7 +111,7 @@ local check_fullness = Public.check_fullness
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_mined_entity,
|
||||
function(event)
|
||||
function (event)
|
||||
local entity = event.entity
|
||||
if not entity or not entity.valid then
|
||||
return
|
||||
|
@ -12,7 +12,7 @@ local this = {
|
||||
}
|
||||
Global.register(
|
||||
this,
|
||||
function(tbl)
|
||||
function (tbl)
|
||||
this = tbl
|
||||
end
|
||||
)
|
||||
@ -25,7 +25,7 @@ local direction_reverse = {
|
||||
}
|
||||
|
||||
local directions = {
|
||||
['north'] = function(position, reverse)
|
||||
['north'] = function (position, reverse)
|
||||
local surface_index = this.surface_index
|
||||
if not surface_index then
|
||||
return
|
||||
@ -45,14 +45,14 @@ local directions = {
|
||||
local a = width * 0.5 + 4
|
||||
|
||||
if not reverse then
|
||||
this.vector = {0, -1}
|
||||
this.area = {{position.x - a, position.y - 1}, {position.x + a, position.y}}
|
||||
this.vector = { 0, -1 }
|
||||
this.area = { { position.x - a, position.y - 1 }, { position.x + a, position.y } }
|
||||
else
|
||||
this.reverse_vector = {0, -1}
|
||||
this.reverse_area = {{position.x - a, position.y - 1}, {position.x + a, position.y}}
|
||||
this.reverse_vector = { 0, -1 }
|
||||
this.reverse_area = { { position.x - a, position.y - 1 }, { position.x + a, position.y } }
|
||||
end
|
||||
end,
|
||||
['south'] = function(position, reverse)
|
||||
['south'] = function (position, reverse)
|
||||
local surface_index = this.surface_index
|
||||
if not surface_index then
|
||||
return
|
||||
@ -71,14 +71,14 @@ local directions = {
|
||||
end
|
||||
local a = width * 0.5
|
||||
if not reverse then
|
||||
this.vector = {0, 1}
|
||||
this.area = {{position.x - a, position.y}, {position.x + a, position.y + 1}}
|
||||
this.vector = { 0, 1 }
|
||||
this.area = { { position.x - a, position.y }, { position.x + a, position.y + 1 } }
|
||||
else
|
||||
this.reverse_vector = {0, 1}
|
||||
this.reverse_area = {{position.x - a, position.y}, {position.x + a, position.y + 1}}
|
||||
this.reverse_vector = { 0, 1 }
|
||||
this.reverse_area = { { position.x - a, position.y }, { position.x + a, position.y + 1 } }
|
||||
end
|
||||
end,
|
||||
['west'] = function(position, reverse)
|
||||
['west'] = function (position, reverse)
|
||||
local surface_index = this.surface_index
|
||||
if not surface_index then
|
||||
return
|
||||
@ -97,14 +97,14 @@ local directions = {
|
||||
end
|
||||
local a = width * 0.5 + 1
|
||||
if not reverse then
|
||||
this.vector = {-1, 0}
|
||||
this.area = {{position.x - 1, position.y - a}, {position.x, position.y + a}}
|
||||
this.vector = { -1, 0 }
|
||||
this.area = { { position.x - 1, position.y - a }, { position.x, position.y + a } }
|
||||
else
|
||||
this.reverse_vector = {-1, 0}
|
||||
this.reverse_area = {{position.x - 1, position.y - a}, {position.x, position.y + a}}
|
||||
this.reverse_vector = { -1, 0 }
|
||||
this.reverse_area = { { position.x - 1, position.y - a }, { position.x, position.y + a } }
|
||||
end
|
||||
end,
|
||||
['east'] = function(position, reverse)
|
||||
['east'] = function (position, reverse)
|
||||
local surface_index = this.surface_index
|
||||
if not surface_index then
|
||||
return
|
||||
@ -123,11 +123,11 @@ local directions = {
|
||||
end
|
||||
local a = width * 0.5 + 1
|
||||
if not reverse then
|
||||
this.vector = {1, 0}
|
||||
this.area = {{position.x, position.y - a}, {position.x + 1, position.y + a}}
|
||||
this.vector = { 1, 0 }
|
||||
this.area = { { position.x, position.y - a }, { position.x + 1, position.y + a } }
|
||||
else
|
||||
this.reverse_vector = {1, 0}
|
||||
this.reverse_area = {{position.x, position.y - a}, {position.x + 1, position.y + a}}
|
||||
this.reverse_vector = { 1, 0 }
|
||||
this.reverse_area = { { position.x, position.y - a }, { position.x + 1, position.y + a } }
|
||||
end
|
||||
end
|
||||
}
|
||||
@ -144,7 +144,7 @@ local function set_collapse_tiles(surface)
|
||||
print_debug(45)
|
||||
end
|
||||
game.forces.player.chart(surface, this.area)
|
||||
this.tiles = surface.find_tiles_filtered({area = this.area, name = 'out-of-map', invert = true})
|
||||
this.tiles = surface.find_tiles_filtered({ area = this.area, name = 'out-of-map', invert = true })
|
||||
|
||||
if not this.tiles then
|
||||
return
|
||||
@ -153,11 +153,11 @@ local function set_collapse_tiles(surface)
|
||||
if this.size_of_tiles > 0 then
|
||||
table_shuffle_table(this.tiles)
|
||||
end
|
||||
this.position = {x = this.position.x + this.vector[1], y = this.position.y + this.vector[2]}
|
||||
this.position = { x = this.position.x + this.vector[1], y = this.position.y + this.vector[2] }
|
||||
local v = this.vector
|
||||
local area = this.area
|
||||
this.area = {{area[1][1] + v[1], area[1][2] + v[2]}, {area[2][1] + v[1], area[2][2] + v[2]}}
|
||||
local chart_area = {{area[1][1] + v[1] - 4, area[1][2] + v[2] - 4}, {area[2][1] + v[1] + 4, area[2][2] + v[2] + 4}}
|
||||
this.area = { { area[1][1] + v[1], area[1][2] + v[2] }, { area[2][1] + v[1], area[2][2] + v[2] } }
|
||||
local chart_area = { { area[1][1] + v[1] - 4, area[1][2] + v[2] - 4 }, { area[2][1] + v[1] + 4, area[2][2] + v[2] + 4 } }
|
||||
game.forces.player.chart(surface, chart_area)
|
||||
end
|
||||
|
||||
@ -166,7 +166,7 @@ local function set_reverse_collapse_tiles(surface)
|
||||
if not surface or surface.valid then
|
||||
print_debug(45)
|
||||
end
|
||||
this.reverse_tiles = surface.find_tiles_filtered({area = this.reverse_area, name = 'out-of-map', invert = true})
|
||||
this.reverse_tiles = surface.find_tiles_filtered({ area = this.reverse_area, name = 'out-of-map', invert = true })
|
||||
|
||||
if not this.reverse_tiles then
|
||||
return
|
||||
@ -175,11 +175,11 @@ local function set_reverse_collapse_tiles(surface)
|
||||
if this.reverse_size_of_tiles > 0 then
|
||||
table_shuffle_table(this.reverse_tiles)
|
||||
end
|
||||
this.reverse_position = {x = this.reverse_position.x + this.reverse_vector[1], y = this.reverse_position.y + this.reverse_vector[2]}
|
||||
this.reverse_position = { x = this.reverse_position.x + this.reverse_vector[1], y = this.reverse_position.y + this.reverse_vector[2] }
|
||||
local v = this.reverse_vector
|
||||
local area = this.reverse_area
|
||||
this.reverse_area = {{area[1][1] + v[1], area[1][2] + v[2]}, {area[2][1] + v[1], area[2][2] + v[2]}}
|
||||
local chart_area = {{area[1][1] + v[1] - 4, area[1][2] + v[2] - 10}, {area[2][1] + v[1] + 4, area[2][2] + v[2] + 10}}
|
||||
this.reverse_area = { { area[1][1] + v[1], area[1][2] + v[2] }, { area[2][1] + v[1], area[2][2] + v[2] } }
|
||||
local chart_area = { { area[1][1] + v[1] - 4, area[1][2] + v[2] - 10 }, { area[2][1] + v[1] + 4, area[2][2] + v[2] + 10 } }
|
||||
local force = game.forces.player
|
||||
|
||||
force.chart(surface, chart_area)
|
||||
@ -221,9 +221,9 @@ local function progress()
|
||||
return
|
||||
end
|
||||
if this.specific_entities.enabled then
|
||||
local position = {tile.position.x + 0.5, tile.position.y + 0.5}
|
||||
local position = { tile.position.x + 0.5, tile.position.y + 0.5 }
|
||||
local entities = this.specific_entities.entities
|
||||
for _, e in pairs(surface.find_entities_filtered({area = {{position[1] - 4, position[2] - 2}, {position[1] + 4, position[2] + 2}}})) do
|
||||
for _, e in pairs(surface.find_entities_filtered({ area = { { position[1] - 4, position[2] - 2 }, { position[1] + 4, position[2] + 2 } } })) do
|
||||
if entities[e.name] and e.valid and e.health then
|
||||
e.die()
|
||||
elseif e.valid then
|
||||
@ -232,14 +232,14 @@ local function progress()
|
||||
end
|
||||
end
|
||||
if this.kill then
|
||||
local position = {tile.position.x + 0.5, tile.position.y + 0.5}
|
||||
for _, e in pairs(surface.find_entities_filtered({area = {{position[1] - 4, position[2] - 2}, {position[1] + 4, position[2] + 2}}})) do
|
||||
local position = { tile.position.x + 0.5, tile.position.y + 0.5 }
|
||||
for _, e in pairs(surface.find_entities_filtered({ area = { { position[1] - 4, position[2] - 2 }, { position[1] + 4, position[2] + 2 } } })) do
|
||||
if e.valid and e.health then
|
||||
e.die()
|
||||
end
|
||||
end
|
||||
end
|
||||
surface.set_tiles({{name = 'out-of-map', position = tile.position}}, true)
|
||||
surface.set_tiles({ { name = 'out-of-map', position = tile.position } }, true)
|
||||
end
|
||||
end
|
||||
|
||||
@ -278,9 +278,9 @@ local function progress_reverse()
|
||||
return
|
||||
end
|
||||
if this.specific_entities.enabled then
|
||||
local position = {tile.position.x + 0.5, tile.position.y + 0.5}
|
||||
local position = { tile.position.x + 0.5, tile.position.y + 0.5 }
|
||||
local entities = this.specific_entities.entities
|
||||
for _, e in pairs(surface.find_entities_filtered({area = {{position[1] - 4, position[2] - 2}, {position[1] + 4, position[2] + 2}}})) do
|
||||
for _, e in pairs(surface.find_entities_filtered({ area = { { position[1] - 4, position[2] - 2 }, { position[1] + 4, position[2] + 2 } } })) do
|
||||
if entities[e.name] and e.valid and e.health then
|
||||
e.die()
|
||||
elseif e.valid then
|
||||
@ -289,14 +289,14 @@ local function progress_reverse()
|
||||
end
|
||||
end
|
||||
if this.kill then
|
||||
local position = {tile.position.x + 0.5, tile.position.y + 0.5}
|
||||
for _, e in pairs(surface.find_entities_filtered({area = {{position[1] - 4, position[2] - 2}, {position[1] + 4, position[2] + 2}}})) do
|
||||
local position = { tile.position.x + 0.5, tile.position.y + 0.5 }
|
||||
for _, e in pairs(surface.find_entities_filtered({ area = { { position[1] - 4, position[2] - 2 }, { position[1] + 4, position[2] + 2 } } })) do
|
||||
if e.valid and e.health then
|
||||
e.die()
|
||||
end
|
||||
end
|
||||
end
|
||||
surface.set_tiles({{name = 'out-of-map', position = tile.position}}, true)
|
||||
surface.set_tiles({ { name = 'out-of-map', position = tile.position } }, true)
|
||||
end
|
||||
end
|
||||
|
||||
@ -351,7 +351,7 @@ function Public.set_reverse_position(position)
|
||||
if position.y then
|
||||
y = position.y
|
||||
end
|
||||
this.reverse_position = {x = x, y = y}
|
||||
this.reverse_position = { x = x, y = y }
|
||||
end
|
||||
|
||||
function Public.set_reverse_direction()
|
||||
@ -419,7 +419,7 @@ function Public.set_position(position)
|
||||
if position.y then
|
||||
y = position.y
|
||||
end
|
||||
this.position = {x = x, y = y}
|
||||
this.position = { x = x, y = y }
|
||||
end
|
||||
|
||||
function Public.get_position()
|
||||
@ -504,7 +504,7 @@ end
|
||||
|
||||
local function on_init()
|
||||
Public.set_surface_index(game.surfaces.nauvis.index)
|
||||
Public.set_position({0, 32})
|
||||
Public.set_position({ 0, 32 })
|
||||
Public.set_max_line_size(256)
|
||||
Public.set_direction('north')
|
||||
Public.set_kill_entities(true)
|
||||
|
@ -1,98 +0,0 @@
|
||||
local function draw_map_tag(surface, force, position, name)
|
||||
local t = force.add_chart_tag(surface, {icon = {type = 'item', name = 'heavy-armor'}, position = position, text = ' '})
|
||||
if t and name then
|
||||
t.last_user = name
|
||||
end
|
||||
end
|
||||
|
||||
local function is_tag_valid(tag)
|
||||
if not tag.icon then
|
||||
return
|
||||
end
|
||||
if tag.icon.type ~= 'item' then
|
||||
return
|
||||
end
|
||||
if tag.icon.name ~= 'heavy-armor' then
|
||||
return
|
||||
end
|
||||
if tag.text ~= ' ' then
|
||||
return
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function get_corpse_force(corpse)
|
||||
if corpse.character_corpse_player_index then
|
||||
if game.players[corpse.character_corpse_player_index] then
|
||||
return game.players[corpse.character_corpse_player_index].force
|
||||
end
|
||||
end
|
||||
return game.forces.neutral
|
||||
end
|
||||
|
||||
local function destroy_all_tags()
|
||||
for _, force in pairs(game.forces) do
|
||||
for _, surface in pairs(game.surfaces) do
|
||||
for _, tag in pairs(force.find_chart_tags(surface)) do
|
||||
if is_tag_valid(tag) then
|
||||
tag.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function redraw_all_tags()
|
||||
for _, surface in pairs(game.surfaces) do
|
||||
for _, corpse in pairs(surface.find_entities_filtered({name = 'character-corpse'})) do
|
||||
if corpse.character_corpse_player_index then
|
||||
local player = game.get_player(corpse.character_corpse_player_index)
|
||||
if player and player.valid then
|
||||
draw_map_tag(corpse.surface, get_corpse_force(corpse), corpse.position, player.name)
|
||||
end
|
||||
else
|
||||
draw_map_tag(corpse.surface, get_corpse_force(corpse), corpse.position)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function find_and_destroy_tag(corpse)
|
||||
local force = get_corpse_force(corpse)
|
||||
for _, tag in pairs(force.find_chart_tags(corpse.surface, {{corpse.position.x - 0.1, corpse.position.y - 0.1}, {corpse.position.x + 0.1, corpse.position.y + 0.1}})) do
|
||||
if is_tag_valid(tag) then
|
||||
tag.destroy()
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function on_player_died(event)
|
||||
local player = game.players[event.player_index]
|
||||
draw_map_tag(player.surface, player.force, player.position, player.name)
|
||||
end
|
||||
|
||||
local function on_character_corpse_expired(event)
|
||||
if find_and_destroy_tag(event.corpse) then
|
||||
return
|
||||
end
|
||||
destroy_all_tags()
|
||||
redraw_all_tags()
|
||||
end
|
||||
|
||||
local function on_pre_player_mined_item(event)
|
||||
if event.entity.name ~= 'character-corpse' then
|
||||
return
|
||||
end
|
||||
if find_and_destroy_tag(event.entity) then
|
||||
return
|
||||
end
|
||||
destroy_all_tags()
|
||||
redraw_all_tags()
|
||||
end
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.add(defines.events.on_player_died, on_player_died)
|
||||
event.add(defines.events.on_character_corpse_expired, on_character_corpse_expired)
|
||||
event.add(defines.events.on_pre_player_mined_item, on_pre_player_mined_item)
|
@ -212,7 +212,7 @@ local function damage_area(cell)
|
||||
end
|
||||
end
|
||||
|
||||
local tile = surface.get_tile(cell.position)
|
||||
local tile = surface.get_tile(cell.position.x, cell.position.y)
|
||||
if not tile or not tile.valid then return end
|
||||
if this.explosives.destructible_tiles[tile.name] then
|
||||
local key = pos_to_key(tile.position)
|
||||
|
@ -27,7 +27,7 @@ local function on_console_chat(event)
|
||||
local y_offset = -4
|
||||
|
||||
if this.player_floaty_chat[player.index] then
|
||||
rendering.get_object_by_id(this.player_floaty_chat[player.index]).destroy()
|
||||
this.player_floaty_chat[player.index].destroy()
|
||||
this.player_floaty_chat[player.index] = nil
|
||||
end
|
||||
|
||||
|
@ -25,7 +25,6 @@ local item_worths = {
|
||||
['inserter'] = 4,
|
||||
['long-handed-inserter'] = 8,
|
||||
['fast-inserter'] = 16,
|
||||
['bulk-inserter'] = 128,
|
||||
['bulk-inserter'] = 160,
|
||||
['small-electric-pole'] = 2,
|
||||
['medium-electric-pole'] = 32,
|
||||
@ -240,7 +239,7 @@ local function roll_item_stack(entity, wave)
|
||||
end
|
||||
end
|
||||
|
||||
entity.surface.spill_item_stack(entity.position, { name = item_name, count = random(1, item_count) }, true)
|
||||
entity.surface.spill_item_stack({ position = entity.position, stack = { item_name = entity.name, count = random(1, item_count), quality = 'normal' } })
|
||||
|
||||
return { name = item_name, count = item_count }
|
||||
end
|
||||
|
@ -57,7 +57,7 @@ function Public:new_render()
|
||||
end
|
||||
|
||||
if self.render_id then
|
||||
rendering.destroy(self.render_id)
|
||||
self.render_id.destroy()
|
||||
end
|
||||
|
||||
self.render_id = rendering.draw_sprite { target = self.position, sprite = self.sprite, surface = surface }
|
||||
@ -107,16 +107,9 @@ function Public:set_render_scalar_size()
|
||||
return self:validate()
|
||||
end
|
||||
|
||||
rendering.set_y_scale(self.render_id, 3.5) -- 1.5
|
||||
rendering.set_x_scale(self.render_id, 7) -- 2
|
||||
rendering.set_color(
|
||||
self.render_id,
|
||||
{
|
||||
r = 1,
|
||||
g = 0.7,
|
||||
b = 0.7
|
||||
}
|
||||
)
|
||||
self.render_id.y_scale = 3.5 -- 1.5
|
||||
self.render_id.x_scale = 7 -- 2
|
||||
self.render_id.color = { r = 1, g = 0.7, b = 0.7 }
|
||||
end
|
||||
|
||||
--- Gets a random position.
|
||||
@ -227,7 +220,7 @@ function Public:set_new_position()
|
||||
end
|
||||
|
||||
if self:validate() then
|
||||
rendering.set_target(self.render_id, self.position)
|
||||
self.render_id.target = self.position
|
||||
self:set_render_scalar_size()
|
||||
end
|
||||
end
|
||||
@ -290,7 +283,7 @@ function Public:validate()
|
||||
self:new_render()
|
||||
return false
|
||||
end
|
||||
if rendering.is_valid(self.render_id) then
|
||||
if self.render_id.valid then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
@ -298,8 +291,8 @@ end
|
||||
|
||||
--- Destroys a render.
|
||||
function Public:destroy_render()
|
||||
if rendering.is_valid(self.render_id) then
|
||||
rendering.destroy(self.render_id)
|
||||
if self.render_id and self.render_id.valid then
|
||||
self.render_id.destroy()
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
@ -77,10 +77,19 @@ local tier_damage = {
|
||||
}
|
||||
|
||||
local commands = {
|
||||
['flee'] = 'goto',
|
||||
['flee'] = 'attack',
|
||||
['goto'] = 'attack_area',
|
||||
['attack'] = 'attack',
|
||||
['attack_area'] = 'attack_area',
|
||||
['attack'] = 'flee',
|
||||
['attack_area'] = 'goto',
|
||||
}
|
||||
|
||||
local pf_flags = {
|
||||
allow_destroy_friendly_entities = true,
|
||||
allow_paths_through_own_entities = true,
|
||||
cache = true,
|
||||
prefer_straight_paths = false,
|
||||
low_priority = false,
|
||||
no_break = false,
|
||||
}
|
||||
|
||||
--- A token to register tasks that entities are given
|
||||
@ -502,7 +511,7 @@ local function on_entity_damaged(event)
|
||||
state:spawn_children()
|
||||
end
|
||||
|
||||
if random(1, 128) == 1 then
|
||||
if random(1, 64) == 1 then
|
||||
state:flee_command()
|
||||
end
|
||||
|
||||
@ -514,7 +523,7 @@ local function on_entity_damaged(event)
|
||||
end
|
||||
end
|
||||
|
||||
--- Creates a new state for a boss unit.
|
||||
|
||||
---@param data table
|
||||
---@return table|nil
|
||||
function Public.new(data)
|
||||
@ -535,6 +544,7 @@ function Public.new(data)
|
||||
state.teleported = 0
|
||||
state.uid = uid
|
||||
state.command = 'goto'
|
||||
state.last_command = 0
|
||||
state.id = state.entity.unit_number
|
||||
state.update_rate = this.settings.update_rate + (10 * state.uid)
|
||||
state.ttl = data.ttl or tick + (5 * 3600) -- 5 minutes duration
|
||||
@ -860,7 +870,7 @@ function Public._esp:find_targets()
|
||||
self.commands[#self.commands + 1] = {
|
||||
type = defines.command.attack,
|
||||
target = obstacles[ii],
|
||||
distraction = defines.distraction.none
|
||||
distraction = defines.distraction.by_anything
|
||||
}
|
||||
end
|
||||
end
|
||||
@ -983,11 +993,26 @@ function Public._esp:go_to_location_command()
|
||||
self:check_unit_group()
|
||||
end
|
||||
|
||||
self.group.set_command {
|
||||
local group_commands = {}
|
||||
|
||||
group_commands[#group_commands + 1] = {
|
||||
type = defines.command.go_to_location,
|
||||
destination_entity = unit,
|
||||
radius = 3
|
||||
pathfind_flags = pf_flags,
|
||||
destination = unit.position,
|
||||
distraction = defines.distraction.by_enemy
|
||||
}
|
||||
|
||||
if not self.command_added then
|
||||
self.command_added = true
|
||||
|
||||
self.group.set_command(
|
||||
{
|
||||
type = defines.command.compound,
|
||||
structure_type = defines.compound_command.return_last,
|
||||
commands = group_commands
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
function Public._esp:attack_command()
|
||||
@ -1000,10 +1025,27 @@ function Public._esp:attack_command()
|
||||
self:check_unit_group()
|
||||
end
|
||||
|
||||
self.group.set_command {
|
||||
local group_commands = {}
|
||||
|
||||
group_commands[#group_commands + 1] = {
|
||||
type = defines.command.go_to_location,
|
||||
pathfind_flags = pf_flags,
|
||||
destination = unit.position,
|
||||
distraction = defines.distraction.by_enemy
|
||||
}
|
||||
|
||||
group_commands[#group_commands + 1] = {
|
||||
type = defines.command.attack,
|
||||
target = unit
|
||||
}
|
||||
|
||||
self.group.set_command(
|
||||
{
|
||||
type = defines.command.compound,
|
||||
structure_type = defines.compound_command.return_last,
|
||||
commands = group_commands
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
function Public._esp:attack_area_command()
|
||||
@ -1016,12 +1058,29 @@ function Public._esp:attack_area_command()
|
||||
self:check_unit_group()
|
||||
end
|
||||
|
||||
self.group.set_command {
|
||||
local group_commands = {}
|
||||
|
||||
group_commands[#group_commands + 1] = {
|
||||
type = defines.command.go_to_location,
|
||||
pathfind_flags = pf_flags,
|
||||
destination = unit.position,
|
||||
distraction = defines.distraction.by_enemy
|
||||
}
|
||||
|
||||
group_commands[#group_commands + 1] = {
|
||||
type = defines.command.attack_area,
|
||||
destination = { x = unit.position.x, y = unit.position.y },
|
||||
radius = 30,
|
||||
distraction = defines.distraction.none
|
||||
distraction = defines.distraction.by_anything
|
||||
}
|
||||
|
||||
self.group.set_command(
|
||||
{
|
||||
type = defines.command.compound,
|
||||
structure_type = defines.compound_command.return_last,
|
||||
commands = group_commands
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
function Public._esp:flee_command()
|
||||
@ -1034,10 +1093,25 @@ function Public._esp:flee_command()
|
||||
self:check_unit_group()
|
||||
end
|
||||
|
||||
self.group.set_command {
|
||||
local group_commands = {}
|
||||
|
||||
group_commands[#group_commands + 1] = {
|
||||
type = defines.command.flee,
|
||||
from = unit,
|
||||
}
|
||||
|
||||
group_commands[#group_commands + 1] = {
|
||||
type = defines.command.flee,
|
||||
from = unit,
|
||||
}
|
||||
|
||||
self.group.set_command(
|
||||
{
|
||||
type = defines.command.compound,
|
||||
structure_type = defines.compound_command.return_last,
|
||||
commands = group_commands
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
function Public._esp:work(tick)
|
||||
@ -1045,12 +1119,21 @@ function Public._esp:work(tick)
|
||||
self:set_frenzy()
|
||||
end
|
||||
|
||||
if self.command == 'goto' then
|
||||
self:go_to_location_command()
|
||||
elseif self.command == 'attack' then
|
||||
self:attack_command()
|
||||
elseif self.command == 'attack_area' then
|
||||
self:attack_area_command()
|
||||
if self.last_command < tick then
|
||||
if self.command == 'goto' then
|
||||
self:go_to_location_command()
|
||||
elseif self.command == 'attack' then
|
||||
-- self:attack_command()
|
||||
-- self:go_to_location_command()
|
||||
elseif self.command == 'attack_area' then
|
||||
self:attack_area_command()
|
||||
-- self:go_to_location_command()
|
||||
end
|
||||
self.last_command = tick + 500
|
||||
|
||||
if this.target_settings.main_target and this.target_settings.main_target.valid and this.target_settings.main_target.name == 'character' then
|
||||
Event.raise(Public.events.on_primary_target_missing)
|
||||
end
|
||||
end
|
||||
|
||||
if self.go_havoc and self.clear_go_havoc > tick then
|
||||
|
@ -173,10 +173,12 @@ local function get_spawn_pos()
|
||||
local located_position = find_initial_spot(surface, initial_position)
|
||||
local valid_position = surface.find_non_colliding_position('stone-furnace', located_position, 32, 1)
|
||||
local debug = Public.get('debug')
|
||||
if valid_position then
|
||||
local x = valid_position.x
|
||||
local y = valid_position.y
|
||||
game.print('[gps=' .. x .. ',' .. y .. ',' .. surface.name .. ']')
|
||||
if debug then
|
||||
if valid_position then
|
||||
local x = valid_position.x
|
||||
local y = valid_position.y
|
||||
game.print('[gps=' .. x .. ',' .. y .. ',' .. surface.name .. ']')
|
||||
end
|
||||
end
|
||||
|
||||
if not valid_position then
|
||||
@ -330,7 +332,6 @@ local function set_main_target()
|
||||
local target = Public.get('target')
|
||||
if target then
|
||||
if target.valid then
|
||||
raise(Public.events.on_target_aquired, { target = target })
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -346,7 +347,6 @@ local function set_main_target()
|
||||
sec_target = get_random_character()
|
||||
end
|
||||
if not sec_target then
|
||||
raise(Public.events.on_target_aquired, { target = target })
|
||||
return
|
||||
end
|
||||
|
||||
@ -893,6 +893,7 @@ local function get_main_command(group)
|
||||
|
||||
local target = Public.get('target')
|
||||
if not valid(target) then
|
||||
Event.raise(Public.events.on_primary_target_missing)
|
||||
return
|
||||
end
|
||||
|
||||
@ -1058,6 +1059,7 @@ local function give_side_commands_to_group()
|
||||
|
||||
local target = Public.get('target')
|
||||
if not valid(target) then
|
||||
Event.raise(Public.events.on_primary_target_missing)
|
||||
return
|
||||
end
|
||||
|
||||
@ -1076,9 +1078,13 @@ end
|
||||
local function give_main_command_to_group()
|
||||
local target = Public.get('target')
|
||||
if not valid(target) then
|
||||
Event.raise(Public.events.on_primary_target_missing)
|
||||
return
|
||||
end
|
||||
|
||||
-- This is called even if the target is valid
|
||||
Event.raise(Public.events.on_primary_target_missing)
|
||||
|
||||
local generated_units = Public.get('generated_units')
|
||||
for _, group in pairs(generated_units.unit_groups) do
|
||||
if type(group) ~= 'number' then
|
||||
@ -1337,6 +1343,7 @@ local function check_group_positions()
|
||||
local generated_units = Public.get('generated_units')
|
||||
local target = Public.get('target')
|
||||
if not valid(target) then
|
||||
Event.raise(Public.events.on_primary_target_missing)
|
||||
return
|
||||
end
|
||||
|
||||
@ -1437,9 +1444,6 @@ Event.on_nth_tick(
|
||||
return
|
||||
end
|
||||
|
||||
-- local generated_units = Public.get('generated_units')
|
||||
-- game.print(serpent.block(generated_units.unit_groups))
|
||||
|
||||
local paused = Public.get('paused')
|
||||
if paused then
|
||||
local players = game.connected_players
|
||||
|
@ -177,7 +177,7 @@ local function damage_player(player, kill, print_to_all)
|
||||
'Just a fleshwound.',
|
||||
'Better keep those hands to yourself or you might loose them.'
|
||||
}
|
||||
player.print(messages[random(1, #messages)], Color.yellow)
|
||||
player.print(messages[random(1, #messages)], { color = Color.yellow })
|
||||
if player.character.health <= 0 then
|
||||
player.character.die('enemy')
|
||||
game.print(player.name .. msg, Color.yellow)
|
||||
@ -235,7 +235,7 @@ local function on_marked_for_deconstruction(event)
|
||||
end
|
||||
if playtime < this.required_playtime then
|
||||
event.entity.cancel_deconstruction(game.get_player(event.player_index).force.name)
|
||||
player.print('You have not grown accustomed to this technology yet.', { r = 0.22, g = 0.99, b = 0.99 })
|
||||
player.print('You have not grown accustomed to this technology yet.', { color = { r = 0.22, g = 0.99, b = 0.99 } })
|
||||
end
|
||||
end
|
||||
|
||||
@ -350,7 +350,7 @@ local function on_built_entity(event)
|
||||
|
||||
if playtime < this.required_playtime then
|
||||
created_entity.destroy()
|
||||
player.print('You have not grown accustomed to this technology yet.', { r = 0.22, g = 0.99, b = 0.99 })
|
||||
player.print('You have not grown accustomed to this technology yet.', { color = { r = 0.22, g = 0.99, b = 0.99 } })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -11,7 +11,7 @@ local this = {
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
function(tbl)
|
||||
function (tbl)
|
||||
this = tbl
|
||||
end
|
||||
)
|
||||
@ -19,14 +19,14 @@ Global.register(
|
||||
local Public = {}
|
||||
|
||||
local brain = {
|
||||
[1] = {'Our Discord server is at: https://getcomfy.eu/discord'},
|
||||
[1] = { 'Our Discord server is at: https://getcomfy.eu/discord' },
|
||||
[2] = {
|
||||
'Need an admin? Join our discord at: https://getcomfy.eu/discord,',
|
||||
'and report it in #i-need-halp',
|
||||
'If you have played for more than 5h in our maps then,',
|
||||
'you are eligible to run the command /jail and /free'
|
||||
},
|
||||
[3] = {'Scenario repository for download:', 'https://github.com/ComfyFactory/ComfyFactorio'},
|
||||
[3] = { 'Scenario repository for download:', 'https://github.com/ComfyFactory/ComfyFactorio' },
|
||||
[4] = {
|
||||
'If you feel like the server is lagging, run the following command:',
|
||||
'/server-ups',
|
||||
@ -65,12 +65,12 @@ local links = {
|
||||
local function on_player_created(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if this.settings.enable_classic_print then
|
||||
player.print('[font=default-game]' .. 'Join the comfy discord >> getcomfy.eu/discord <<' .. '[/font]', {r = 150, g = 100, b = 255, a = 255})
|
||||
player.print('[font=default-game]' .. 'Join the comfy discord >> getcomfy.eu/discord <<' .. '[/font]', { color = { r = 150, g = 100, b = 255, a = 255 } })
|
||||
else
|
||||
player.print(
|
||||
'[font=heading-1]' ..
|
||||
'[color=#E99696]J[/color][color=#E9A296]o[/color][color=#E9AF96]i[/color][color=#E9BB96]n[/color] [color=#E9C896]t[/color][color=#E9D496]h[/color][color=#E9E096]e[/color] ☕[color=#E5E996]c[/color][color=#D8E996]o[/color][color=#CCE996]m[/color][color=#BFE996]f[/color][color=#B3E996]y[/color] [color=#A6E996]d[/color][color=#9AE996]i[/color][color=#96E99E]s[/color][color=#96E9AB]c[/color][color=#96E9B7]o[/color][color=#96E9C3]r[/color][color=#96E9D0]d[/color] [color=#96E9DC]>[/color][color=#96E9E9]>[/color] [color=#96DCE9]g[/color][color=#96D0E9]e[/color][color=#96C3E9]t[/color][color=#96B7E9]c[/color][color=#96ABE9]o[/color][color=#969EE9]m[/color][color=#9A96E9]f[/color][color=#A696E9]y[/color][color=#B396E9].[/color][color=#BF96E9]e[/color][color=#CC96E9]u[/color][color=#D896E9]/[/color][color=#E596E9]d[/color][color=#E996E0]i[/color][color=#E996D4]s[/color][color=#E996C8]c[/color][color=#E996BB]o[/color][color=#E996AF]r[/color][color=#E996A2]d[/color]' ..
|
||||
'[/font]'
|
||||
'[color=#E99696]J[/color][color=#E9A296]o[/color][color=#E9AF96]i[/color][color=#E9BB96]n[/color] [color=#E9C896]t[/color][color=#E9D496]h[/color][color=#E9E096]e[/color] ☕[color=#E5E996]c[/color][color=#D8E996]o[/color][color=#CCE996]m[/color][color=#BFE996]f[/color][color=#B3E996]y[/color] [color=#A6E996]d[/color][color=#9AE996]i[/color][color=#96E99E]s[/color][color=#96E9AB]c[/color][color=#96E9B7]o[/color][color=#96E9C3]r[/color][color=#96E9D0]d[/color] [color=#96E9DC]>[/color][color=#96E9E9]>[/color] [color=#96DCE9]g[/color][color=#96D0E9]e[/color][color=#96C3E9]t[/color][color=#96B7E9]c[/color][color=#96ABE9]o[/color][color=#969EE9]m[/color][color=#9A96E9]f[/color][color=#A696E9]y[/color][color=#B396E9].[/color][color=#BF96E9]e[/color][color=#CC96E9]u[/color][color=#D896E9]/[/color][color=#E596E9]d[/color][color=#E996E0]i[/color][color=#E996D4]s[/color][color=#E996C8]c[/color][color=#E996BB]o[/color][color=#E996AF]r[/color][color=#E996A2]d[/color]' ..
|
||||
'[/font]'
|
||||
)
|
||||
end
|
||||
end
|
||||
@ -85,7 +85,7 @@ local function process_bot_answers(event)
|
||||
for word in string.gmatch(message, '%g+') do
|
||||
if links[word] then
|
||||
for _, bot_answer in pairs(links[word]) do
|
||||
player.print('[font=heading-1]' .. bot_answer .. '[/font]', Color.warning)
|
||||
player.print('[font=heading-1]' .. bot_answer .. '[/font]', { color = Color.warning })
|
||||
end
|
||||
return
|
||||
end
|
||||
|
@ -72,16 +72,25 @@ Event.add(defines.events.on_console_command, on_console_command)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_promoted,
|
||||
function(event)
|
||||
function (event)
|
||||
local admins = Server.get_admins_data()
|
||||
local player = game.get_player(event.player_index)
|
||||
local server_name = Server.get_server_name() or 'CommandHandler'
|
||||
Discord.send_notification_raw(server_name, player.name .. ' was promoted.')
|
||||
if not game.is_multiplayer() then
|
||||
return
|
||||
end
|
||||
|
||||
if not admins[player.name] then
|
||||
player.admin = false
|
||||
return
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_demoted,
|
||||
function(event)
|
||||
function (event)
|
||||
local player = game.get_player(event.player_index)
|
||||
local server_name = Server.get_server_name() or 'CommandHandler'
|
||||
Discord.send_notification_raw(server_name, player.name .. ' was demoted.')
|
||||
@ -90,7 +99,7 @@ Event.add(
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_kicked,
|
||||
function(event)
|
||||
function (event)
|
||||
local player = game.get_player(event.player_index)
|
||||
local server_name = Server.get_server_name() or 'CommandHandler'
|
||||
Discord.send_notification_raw(server_name, player.name .. ' was kicked.')
|
||||
|
@ -498,6 +498,19 @@ function Public:add_parameter(name, optional, as_type)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Adds an alias to the command.
|
||||
---@param name string
|
||||
---@return MetaCommand
|
||||
function Public:add_alias(name)
|
||||
if self.aliases[name] then
|
||||
error('Alias: ' .. name .. ' already exists for command: ' .. self.name, 2)
|
||||
end
|
||||
|
||||
self.aliases[name] = name
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Sets the command as default if marking paramaters as optional.
|
||||
---@param defaults any
|
||||
---@return MetaCommand
|
||||
@ -553,6 +566,7 @@ end
|
||||
|
||||
Public.new('get', 'Hover over an object to get its name.')
|
||||
:require_admin()
|
||||
:add_alias('entity')
|
||||
:callback(
|
||||
function (player)
|
||||
local entity = player.selected
|
||||
|
@ -301,15 +301,15 @@ local function clear_corpses(cmd)
|
||||
end
|
||||
end
|
||||
if param == nil then
|
||||
player.print('[ERROR] Must specify radius!', Color.fail)
|
||||
player.print('[ERROR] Must specify radius!', { color = Color.fail })
|
||||
return
|
||||
end
|
||||
if param < 0 then
|
||||
player.print('[ERROR] Value is too low.', Color.fail)
|
||||
player.print('[ERROR] Value is too low.', { color = Color.fail })
|
||||
return
|
||||
end
|
||||
if param > 500 then
|
||||
player.print('[ERROR] Value is too big.', Color.fail)
|
||||
player.print('[ERROR] Value is too big.', { color = Color.fail })
|
||||
return
|
||||
end
|
||||
local pos = player.position
|
||||
@ -330,9 +330,9 @@ local function clear_corpses(cmd)
|
||||
corpse = 'corpses'
|
||||
end
|
||||
if i == 0 then
|
||||
player.print('[color=blue][Cleaner][/color] No corpses to clear!', Color.warning)
|
||||
player.print('[color=blue][Cleaner][/color] No corpses to clear!', { color = Color.warning })
|
||||
else
|
||||
player.print('[color=blue][Cleaner][/color] Cleared ' .. i .. ' ' .. corpse .. '!', Color.success)
|
||||
player.print('[color=blue][Cleaner][/color] Cleared ' .. i .. ' ' .. corpse .. '!', { color = Color.success })
|
||||
end
|
||||
end
|
||||
|
||||
@ -391,7 +391,7 @@ function Public.insert_all_items(player)
|
||||
if _k and _v.type ~= 'mining-tool' then
|
||||
player.character_inventory_slots_bonus = Modifiers.get_single_modifier(player, 'character_inventory_slots_bonus', 'creative')
|
||||
player.insert { name = _k, count = _v.stack_size, quality = quality }
|
||||
player.print('[CREATIVE] Inserted all base items.', Color.success)
|
||||
player.print('[CREATIVE] Inserted all base items.', { color = Color.success })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -154,7 +154,7 @@ Commands.new('where', 'Locates a player')
|
||||
create_mini_camera_gui(player, target)
|
||||
else
|
||||
remove_player_data(player)
|
||||
player.print('[Where] Please type a name of a player who is connected.', Color.warning)
|
||||
player.print('[Where] Please type a name of a player who is connected.', { color = Color.warning })
|
||||
end
|
||||
end
|
||||
)
|
||||
|
@ -60,7 +60,7 @@ Commands.new('save-color', "Save your personal color preset so it's always the s
|
||||
local chat = player.chat_color
|
||||
|
||||
set_data(color_data_set, player.name, { color = { color }, chat = { chat } })
|
||||
player.print('Your personal color has been saved to the datastore.', Color.success)
|
||||
player.print('Your personal color has been saved to the datastore.', { color = Color.success })
|
||||
end
|
||||
)
|
||||
|
||||
@ -69,7 +69,7 @@ Commands.new('remove-color', 'Removes your saved color from the datastore.')
|
||||
:callback(
|
||||
function (player)
|
||||
set_data(color_data_set, player.name, nil)
|
||||
player.print('Your personal color has been removed from the datastore.', Color.success)
|
||||
player.print('Your personal color has been removed from the datastore.', { color = Color.success })
|
||||
end
|
||||
)
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- created by Gerkiz for ComfyFactorio
|
||||
|
||||
local Token = require 'utils.token'
|
||||
local Task = require 'utils.task_token'
|
||||
local Color = require 'utils.color_presets'
|
||||
local Server = require 'utils.server'
|
||||
local Event = require 'utils.event'
|
||||
@ -36,20 +36,79 @@ Global.register(
|
||||
|
||||
local Public = {}
|
||||
|
||||
local function apply_stash(player)
|
||||
local stash = this.logistics[player.name]
|
||||
if stash then
|
||||
for i, slot in pairs(stash) do
|
||||
if slot and slot.name then
|
||||
player.set_personal_logistic_slot(i, { name = slot.name, min = slot.min, max = slot.max })
|
||||
local function check_if_item_exists(item)
|
||||
if not prototypes.item[item] then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function apply_logistic_network(player, saved_data)
|
||||
if not saved_data then
|
||||
return
|
||||
end
|
||||
if player.get_requester_point() then
|
||||
if saved_data[1] and saved_data[1].name then
|
||||
local old_section = player.get_requester_point().get_section(1)
|
||||
if old_section then
|
||||
old_section.group = 'Migrated from old format'
|
||||
old_section.active = true
|
||||
for i, slot in pairs(saved_data) do
|
||||
if slot and slot.name and check_if_item_exists(slot.name) then
|
||||
local item_stack = { min = slot.min, max = slot.max, value = { comparator = "=", name = slot.name, quality = "normal", type = slot.type or nil } }
|
||||
old_section.set_slot(i, item_stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
return true
|
||||
else
|
||||
for index, section in pairs(saved_data) do
|
||||
local new_section = player.get_requester_point().get_section(index) or player.get_requester_point().add_section()
|
||||
|
||||
if section and new_section then
|
||||
local slots = section.slots
|
||||
new_section.group = section.group
|
||||
new_section.active = section.active
|
||||
if slots and type(slots) == 'table' then
|
||||
for i, slot in pairs(slots) do
|
||||
if slot and slot.name and check_if_item_exists(slot.name) then
|
||||
local item_stack = { min = slot.min, max = slot.max, value = { comparator = "=", name = slot.name, quality = "normal", type = slot.type or nil } }
|
||||
new_section.set_slot(i, item_stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
this.logistics[player.name] = nil
|
||||
else
|
||||
if this.logistics[player.name] and this.logistics[player.name] == 1 then
|
||||
return false
|
||||
end
|
||||
|
||||
this.logistics[player.name] = saved_data
|
||||
end
|
||||
end
|
||||
|
||||
local function apply_stash(player)
|
||||
local saved_data = this.logistics[player.name]
|
||||
apply_logistic_network(player, saved_data)
|
||||
this.logistics[player.name] = nil
|
||||
end
|
||||
|
||||
local post_apply_token =
|
||||
Task.register(
|
||||
function ()
|
||||
Core.iter_connected_players(
|
||||
function (player)
|
||||
apply_stash(player)
|
||||
end
|
||||
)
|
||||
end
|
||||
)
|
||||
|
||||
local fetch_quickbar =
|
||||
Token.register(
|
||||
Task.register(
|
||||
function (data)
|
||||
local key = data.key
|
||||
local value = data.value
|
||||
@ -68,28 +127,16 @@ local fetch_quickbar =
|
||||
)
|
||||
|
||||
local fetch_logistics =
|
||||
Token.register(
|
||||
Task.register(
|
||||
function (data)
|
||||
local key = data.key
|
||||
local value = data.value
|
||||
local player = game.players[key]
|
||||
local saved_data = data.value
|
||||
local player = game.get_player(key)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
local tech = player.force.technologies['logistic-robotics'].researched
|
||||
if value then
|
||||
for i, slot in pairs(value) do
|
||||
if slot and slot.name then
|
||||
if tech then
|
||||
player.set_personal_logistic_slot(i, { name = slot.name, min = slot.min, max = slot.max })
|
||||
else
|
||||
if not this.logistics[player.name] then
|
||||
this.logistics[player.name] = {}
|
||||
end
|
||||
this.logistics[player.name][i] = { name = slot.name, min = slot.min, max = slot.max }
|
||||
end
|
||||
end
|
||||
end
|
||||
if saved_data then
|
||||
apply_logistic_network(player, saved_data)
|
||||
end
|
||||
end
|
||||
)
|
||||
@ -138,7 +185,7 @@ function Public.save_quickbar(player)
|
||||
end
|
||||
if next(slots) then
|
||||
set_data(dataset, player.name, slots)
|
||||
player.print('Your quickbar has been saved.', Color.success)
|
||||
player.print('Your quickbar has been saved.', { color = Color.success })
|
||||
end
|
||||
end
|
||||
|
||||
@ -147,22 +194,45 @@ end
|
||||
function Public.save_logistics(player)
|
||||
local dataset = logistics_dataset
|
||||
|
||||
if not player.get_requester_point() then
|
||||
return false
|
||||
end
|
||||
|
||||
local game_has_mods = is_game_modded()
|
||||
if game_has_mods then
|
||||
dataset = logistics_dataset_modded
|
||||
end
|
||||
|
||||
local slots = {}
|
||||
local sections = {}
|
||||
|
||||
for i = 1, 400 do
|
||||
local slot = player.get_personal_logistic_slot(i)
|
||||
if slot and slot.name then
|
||||
slots[i] = { name = slot.name, min = slot.min, max = slot.max }
|
||||
|
||||
for sec = 1, 4 do
|
||||
local section = player.get_requester_point().get_section(sec)
|
||||
if section then
|
||||
if not sections[section.index] then
|
||||
sections[section.index] = {}
|
||||
end
|
||||
local slots = {}
|
||||
for i = 1, 100 do
|
||||
local slot = section.get_slot(i)
|
||||
if slot and next(slot) then
|
||||
slots[i] = { name = slot.value.name, min = slot.min, max = slot.max, quality = slot.value.quality, type = slot.value.type, comparator = slot.value.comparator }
|
||||
end
|
||||
end
|
||||
if next(slots) then
|
||||
sections[section.index].group = section.group
|
||||
sections[section.index].active = section.active
|
||||
sections[section.index].slots = slots
|
||||
end
|
||||
end
|
||||
end
|
||||
if next(slots) then
|
||||
set_data(dataset, player.name, slots)
|
||||
player.print('Your personal logistics has been saved.', Color.success)
|
||||
|
||||
if next(sections) then
|
||||
set_data(dataset, player.name, sections)
|
||||
player.print('Your personal logistics has been saved.', { color = Color.success })
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
@ -177,7 +247,7 @@ function Public.remove_quickbar(player)
|
||||
end
|
||||
|
||||
set_data(dataset, player.name, nil)
|
||||
player.print('Your quickbar has been removed.', Color.success)
|
||||
player.print('Your quickbar has been removed.', { color = Color.success })
|
||||
end
|
||||
|
||||
--- Removes the logistics key from the webpanel.
|
||||
@ -191,7 +261,7 @@ function Public.remove_logistics(player)
|
||||
end
|
||||
|
||||
set_data(dataset, player.name, nil)
|
||||
player.print('Your personal logistics has been removed.', Color.success)
|
||||
player.print('Your personal logistics has been removed.', { color = Color.success })
|
||||
end
|
||||
|
||||
local fetch_quickbar_on_join = Public.fetch_quickbar
|
||||
@ -214,12 +284,12 @@ Commands.new('save-logistics', 'Save your personal logistics preset so it´s alw
|
||||
:require_backend()
|
||||
:callback(
|
||||
function (player)
|
||||
local success, _ = pcall(save_logistics, player)
|
||||
player.print('Notice: only the first 400 slots are saved.', Color.warning)
|
||||
local success = save_logistics(player)
|
||||
if not success then
|
||||
player.print('An error occured while trying to save your logistics slots.', Color.warning)
|
||||
player.print('An error occured while trying to save your logistics slots.', { color = { color = Color.warning } })
|
||||
return false
|
||||
end
|
||||
player.print('Notice: only the first 400 slots are saved.', { color = { color = Color.warning } })
|
||||
player.print('Logistics saved.')
|
||||
end
|
||||
)
|
||||
@ -266,11 +336,7 @@ Event.add(
|
||||
function (event)
|
||||
local research = event.research
|
||||
if research.name == 'logistic-robotics' then
|
||||
Core.iter_connected_players(
|
||||
function (player)
|
||||
apply_stash(player)
|
||||
end
|
||||
)
|
||||
Task.set_timeout_in_ticks(10, post_apply_token)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
@ -16,9 +16,9 @@ local set_timeout_in_ticks = Task.set_timeout_in_ticks
|
||||
local this = {
|
||||
settings = {
|
||||
enabled = false,
|
||||
reset_after = 7, -- 7 days
|
||||
reset_after = 7, -- 7 days
|
||||
required_level_to_progress = 99, -- higher than 99 to be able to save
|
||||
limit = 39600, -- level 100
|
||||
limit = 39600, -- level 100
|
||||
dataset = 'rpg_v2_dataset',
|
||||
reset_key = 'reset_by_this_date'
|
||||
},
|
||||
@ -33,7 +33,7 @@ local round = math.round
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
function(tbl)
|
||||
function (tbl)
|
||||
this = tbl
|
||||
end
|
||||
)
|
||||
@ -48,7 +48,7 @@ local function eligible(player)
|
||||
if player_level <= this.settings.required_level_to_progress then
|
||||
return false
|
||||
else
|
||||
player.print('[RPG] Prestige system resets after 7 days.', Color.warning)
|
||||
player.print('[RPG] Prestige system resets after 7 days.', { color = Color.warning })
|
||||
return true
|
||||
end
|
||||
end
|
||||
@ -67,102 +67,102 @@ end
|
||||
|
||||
local clear_all_data_token =
|
||||
Token.register(
|
||||
function(data)
|
||||
local entries = data.entries
|
||||
if not entries then
|
||||
return
|
||||
end
|
||||
function (data)
|
||||
local entries = data.entries
|
||||
if not entries then
|
||||
return
|
||||
end
|
||||
|
||||
for key, _ in pairs(entries) do
|
||||
if key ~= this.settings.reset_key then
|
||||
this.data[key] = nil
|
||||
set_data(this.settings.dataset, key, nil)
|
||||
for key, _ in pairs(entries) do
|
||||
if key ~= this.settings.reset_key then
|
||||
this.data[key] = nil
|
||||
set_data(this.settings.dataset, key, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
)
|
||||
|
||||
local try_download_amount_of_resets_token =
|
||||
Token.register(
|
||||
function(data)
|
||||
local old_value = data.value
|
||||
if old_value then
|
||||
old_value = tonumber(old_value)
|
||||
local new_value = Server.get_current_date()
|
||||
local time_to_reset = (new_value - old_value)
|
||||
if not time_to_reset then
|
||||
return
|
||||
end
|
||||
function (data)
|
||||
local old_value = data.value
|
||||
if old_value then
|
||||
old_value = tonumber(old_value)
|
||||
local new_value = Server.get_current_date()
|
||||
local time_to_reset = (new_value - old_value)
|
||||
if not time_to_reset then
|
||||
return
|
||||
end
|
||||
|
||||
if time_to_reset < this.settings.reset_after then
|
||||
this.data[this.settings.reset_key] = new_value
|
||||
if time_to_reset < this.settings.reset_after then
|
||||
this.data[this.settings.reset_key] = new_value
|
||||
else
|
||||
this.data[this.settings.reset_key] = 0
|
||||
set_data(this.settings.dataset, this.settings.reset_key, tonumber(new_value))
|
||||
try_get_all_data(this.settings.dataset, clear_all_data_token)
|
||||
end
|
||||
else
|
||||
this.data[this.settings.reset_key] = 0
|
||||
set_data(this.settings.dataset, this.settings.reset_key, tonumber(new_value))
|
||||
try_get_all_data(this.settings.dataset, clear_all_data_token)
|
||||
end
|
||||
else
|
||||
local new_value = Server.get_current_date()
|
||||
local new_value = Server.get_current_date()
|
||||
|
||||
if new_value then
|
||||
set_data(this.settings.dataset, this.settings.reset_key, tonumber(new_value))
|
||||
else
|
||||
set_data(this.settings.dataset, this.settings.reset_key, 0)
|
||||
if new_value then
|
||||
set_data(this.settings.dataset, this.settings.reset_key, tonumber(new_value))
|
||||
else
|
||||
set_data(this.settings.dataset, this.settings.reset_key, 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
)
|
||||
|
||||
local try_download_data_token =
|
||||
Token.register(
|
||||
function(data)
|
||||
local key = data.key
|
||||
local value = data.value
|
||||
local player = game.get_player(key)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
function (data)
|
||||
local key = data.key
|
||||
local value = data.value
|
||||
local player = game.get_player(key)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if value then
|
||||
if value < this.settings.limit then
|
||||
this.data[player.name] = value
|
||||
RPG.set_value_to_player(player.index, 'xp', value)
|
||||
else
|
||||
set_data(this.settings.dataset, key, nil)
|
||||
if value then
|
||||
if value < this.settings.limit then
|
||||
this.data[player.name] = value
|
||||
RPG.set_value_to_player(player.index, 'xp', value)
|
||||
else
|
||||
set_data(this.settings.dataset, key, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
)
|
||||
|
||||
local try_upload_data_token =
|
||||
Token.register(
|
||||
function(data)
|
||||
local key = data.key
|
||||
local value = data.value
|
||||
local player = game.get_player(key)
|
||||
function (data)
|
||||
local key = data.key
|
||||
local value = data.value
|
||||
local player = game.get_player(key)
|
||||
|
||||
if value then
|
||||
if not eligible(player) then
|
||||
return
|
||||
end
|
||||
local old_xp = value
|
||||
if value then
|
||||
if not eligible(player) then
|
||||
return
|
||||
end
|
||||
local old_xp = value
|
||||
|
||||
local new_xp = old_xp + get_progression(player)
|
||||
if new_xp <= 0 then
|
||||
return
|
||||
end
|
||||
local new_xp = old_xp + get_progression(player)
|
||||
if new_xp <= 0 then
|
||||
return
|
||||
end
|
||||
|
||||
new_xp = round(new_xp, 0)
|
||||
new_xp = round(new_xp, 0)
|
||||
|
||||
set_data(this.settings.dataset, key, new_xp)
|
||||
this.data[key] = new_xp
|
||||
else
|
||||
if eligible(player) then
|
||||
set_data(this.settings.dataset, key, get_progression(player))
|
||||
set_data(this.settings.dataset, key, new_xp)
|
||||
this.data[key] = new_xp
|
||||
else
|
||||
if eligible(player) then
|
||||
set_data(this.settings.dataset, key, get_progression(player))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
)
|
||||
|
||||
--- Tries to update amount of resets, if the threshold is reached nil the bonuses.
|
||||
function Public.try_dl_resets()
|
||||
@ -258,7 +258,7 @@ end
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_joined_game,
|
||||
function(event)
|
||||
function (event)
|
||||
if not this.settings.enabled then
|
||||
return
|
||||
end
|
||||
@ -274,7 +274,7 @@ Event.add(
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_left_game,
|
||||
function(event)
|
||||
function (event)
|
||||
if not this.settings.enabled then
|
||||
return
|
||||
end
|
||||
@ -290,14 +290,14 @@ Event.add(
|
||||
|
||||
local nth_tick_token =
|
||||
Token.register(
|
||||
function(data)
|
||||
local index = data.index
|
||||
local player = game.get_player(index)
|
||||
if player and player.valid then
|
||||
Public.try_ul_data(player.name)
|
||||
function (data)
|
||||
local index = data.index
|
||||
local player = game.get_player(index)
|
||||
if player and player.valid then
|
||||
Public.try_ul_data(player.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
)
|
||||
|
||||
--- Saves all eligible players to the web-panel
|
||||
function Public.save_all_players()
|
||||
@ -312,7 +312,7 @@ function Public.save_all_players()
|
||||
if eligible(player) then
|
||||
local count = 0
|
||||
count = count + 10
|
||||
set_timeout_in_ticks(count, nth_tick_token, {index = player.index})
|
||||
set_timeout_in_ticks(count, nth_tick_token, { index = player.index })
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -329,7 +329,7 @@ function Public.restore_xp_on_reset()
|
||||
local player = game.get_player(key)
|
||||
if player and player.valid then
|
||||
RPG.set_value_to_player(player.index, 'xp', value)
|
||||
player.print('[RPG] Prestige system has been applied.', Color.success)
|
||||
player.print('[RPG] Prestige system has been applied.', { color = Color.success })
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -348,7 +348,7 @@ end
|
||||
|
||||
Event.add(
|
||||
Server.events.on_server_started,
|
||||
function()
|
||||
function ()
|
||||
Public.try_dl_resets()
|
||||
end
|
||||
)
|
||||
|
@ -122,7 +122,7 @@ local function validate_action(player, action)
|
||||
if not admin_button_validation[action][player.name] then
|
||||
admin_button_validation[action][player.name] = true
|
||||
Task.set_timeout_in_ticks(200, clear_validation_token, { player_name = player.name, action = action })
|
||||
player.print('Please run this again if you are certain that you want to run this action[' .. action .. '].', Color.warning)
|
||||
player.print('Please run this again if you are certain that you want to run this action[' .. action .. '].', { color = Color.warning })
|
||||
return true
|
||||
end
|
||||
return false
|
||||
@ -131,7 +131,7 @@ end
|
||||
local function admin_only_message(str)
|
||||
for _, player in pairs(game.connected_players) do
|
||||
if player.admin == true then
|
||||
player.print('Admins-only-message: ' .. str, { r = 0.88, g = 0.88, b = 0.88 })
|
||||
player.print('Admins-only-message: ' .. str, { color = { r = 0.88, g = 0.88, b = 0.88 } })
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -142,7 +142,7 @@ local function jail(player, source_player)
|
||||
end
|
||||
|
||||
if player.name == source_player.name then
|
||||
player.print("You can't select yourself!", { r = 1, g = 0.5, b = 0.1 })
|
||||
player.print("You can't select yourself!", { color = { r = 1, g = 0.5, b = 0.1 } })
|
||||
clear_validation_action(source_player.name, 'jail')
|
||||
return
|
||||
end
|
||||
@ -166,7 +166,7 @@ local function clear_biters(player)
|
||||
end
|
||||
end
|
||||
|
||||
player.print('Cleared: ' .. count .. ' biters.', Color.warning)
|
||||
player.print('Cleared: ' .. count .. ' biters.', { color = Color.warning })
|
||||
|
||||
clear_validation_action(player.name, 'clear_biters')
|
||||
end
|
||||
@ -177,7 +177,7 @@ local function mute(player, source_player)
|
||||
end
|
||||
|
||||
if player.name == source_player.name then
|
||||
player.print("You can't select yourself!", { r = 1, g = 0.5, b = 0.1 })
|
||||
player.print("You can't select yourself!", { color = { r = 1, g = 0.5, b = 0.1 } })
|
||||
clear_validation_action(source_player.name, 'mute')
|
||||
return
|
||||
end
|
||||
@ -194,7 +194,7 @@ local function free(player, source_player)
|
||||
end
|
||||
|
||||
if player.name == source_player.name then
|
||||
player.print("You can't select yourself!", { r = 1, g = 0.5, b = 0.1 })
|
||||
player.print("You can't select yourself!", { color = { r = 1, g = 0.5, b = 0.1 } })
|
||||
clear_validation_action(source_player.name, 'free')
|
||||
return
|
||||
end
|
||||
@ -214,12 +214,12 @@ local function bring_player(player, source_player)
|
||||
end
|
||||
|
||||
if player.name == source_player.name then
|
||||
player.print("You can't select yourself!", { r = 1, g = 0.5, b = 0.1 })
|
||||
player.print("You can't select yourself!", { color = { r = 1, g = 0.5, b = 0.1 } })
|
||||
clear_validation_action(source_player.name, 'bring_player')
|
||||
return
|
||||
end
|
||||
if player.driving == true then
|
||||
source_player.print('Target player is in a vehicle, teleport not available.', { r = 0.88, g = 0.88, b = 0.88 })
|
||||
source_player.print('Target player is in a vehicle, teleport not available.', { color = { r = 0.88, g = 0.88, b = 0.88 } })
|
||||
clear_validation_action(source_player.name, 'bring_player')
|
||||
return
|
||||
end
|
||||
@ -241,7 +241,7 @@ local function go_to_player(player, source_player)
|
||||
end
|
||||
|
||||
if player.name == source_player.name then
|
||||
player.print("You can't select yourself!", { r = 1, g = 0.5, b = 0.1 })
|
||||
player.print("You can't select yourself!", { color = { r = 1, g = 0.5, b = 0.1 } })
|
||||
clear_validation_action(source_player.name, 'go_to_player')
|
||||
return
|
||||
end
|
||||
@ -255,7 +255,7 @@ end
|
||||
|
||||
local function spank(player, source_player)
|
||||
if player.name == source_player.name then
|
||||
return player.print("You can't select yourself!", { r = 1, g = 0.5, b = 0.1 })
|
||||
return player.print("You can't select yourself!", { color = { r = 1, g = 0.5, b = 0.1 } })
|
||||
end
|
||||
if player.character then
|
||||
if player.character.health > 1 then
|
||||
@ -273,7 +273,7 @@ local damage_messages = {
|
||||
}
|
||||
local function damage(player, source_player)
|
||||
if player.name == source_player.name then
|
||||
return player.print("You can't select yourself!", { r = 1, g = 0.5, b = 0.1 })
|
||||
return player.print("You can't select yourself!", { color = { r = 1, g = 0.5, b = 0.1 } })
|
||||
end
|
||||
if player.character then
|
||||
if player.character.health > 1 then
|
||||
@ -297,7 +297,7 @@ local function kill(player, source_player)
|
||||
return
|
||||
end
|
||||
if player.name == source_player.name then
|
||||
player.print("You can't select yourself!", { r = 1, g = 0.5, b = 0.1 })
|
||||
player.print("You can't select yourself!", { color = { r = 1, g = 0.5, b = 0.1 } })
|
||||
clear_validation_action(source_player.name, 'kill')
|
||||
return
|
||||
end
|
||||
@ -319,7 +319,7 @@ local function enemy(player, source_player)
|
||||
end
|
||||
|
||||
if player.name == source_player.name then
|
||||
player.print("You can't select yourself!", { r = 1, g = 0.5, b = 0.1 })
|
||||
player.print("You can't select yourself!", { color = { r = 1, g = 0.5, b = 0.1 } })
|
||||
clear_validation_action(source_player.name, 'enemy')
|
||||
return
|
||||
end
|
||||
@ -338,7 +338,7 @@ local function ally(player, source_player)
|
||||
end
|
||||
|
||||
if player.name == source_player.name then
|
||||
player.print("You can't select yourself!", { r = 1, g = 0.5, b = 0.1 })
|
||||
player.print("You can't select yourself!", { color = { r = 1, g = 0.5, b = 0.1 } })
|
||||
clear_validation_action(source_player.name, 'ally')
|
||||
return
|
||||
end
|
||||
@ -439,10 +439,10 @@ local function clear_items_on_ground(player)
|
||||
end
|
||||
end
|
||||
if i == 0 then
|
||||
return player.print('No items to clear!', Color.warning)
|
||||
return player.print('No items to clear!', { color = Color.warning })
|
||||
end
|
||||
|
||||
player.print('Cleared: ' .. i .. ' items.', Color.success)
|
||||
player.print('Cleared: ' .. i .. ' items.', { color = Color.success })
|
||||
clear_validation_action(player.name, 'clear_items_on_ground')
|
||||
end
|
||||
|
||||
@ -1115,7 +1115,7 @@ local function on_gui_click(event)
|
||||
return
|
||||
end
|
||||
if target_player_name == 'Select Player' then
|
||||
player.print('[AdminGui] No target player selected.', { r = 0.88, g = 0.88, b = 0.88 })
|
||||
player.print('[AdminGui] No target player selected.', { color = { r = 0.88, g = 0.88, b = 0.88 } })
|
||||
return
|
||||
end
|
||||
local target_player = game.players[target_player_name]
|
||||
@ -1306,7 +1306,7 @@ Gui.on_click(
|
||||
if current_page == 1 then
|
||||
current_page = 1
|
||||
player_data.current_page = current_page
|
||||
player.print('[Admin] There are no more pages beyond this point.', Color.warning)
|
||||
player.print('[Admin] There are no more pages beyond this point.', { color = Color.warning })
|
||||
return
|
||||
end
|
||||
|
||||
@ -1359,7 +1359,7 @@ Gui.on_click(
|
||||
if current_page == last_page then
|
||||
current_page = last_page
|
||||
player_data.current_page = current_page
|
||||
player.print('[Admin] There are no more pages beyond this point.', Color.warning)
|
||||
player.print('[Admin] There are no more pages beyond this point.', { color = Color.warning })
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -51,10 +51,10 @@ local function build_group_gui(data)
|
||||
local t = frame.add({ type = 'table', column_count = 5 })
|
||||
|
||||
local headings = {
|
||||
{ { 'gui.title' }, group_name_width },
|
||||
{ { 'gui.title' }, group_name_width },
|
||||
{ { 'gui.description' }, description_width },
|
||||
{ { 'gui.members' }, members_width * member_columns },
|
||||
{ '', actions_width }
|
||||
{ { 'gui.members' }, members_width * member_columns },
|
||||
{ '', actions_width }
|
||||
}
|
||||
for _, h in pairs(headings) do
|
||||
local l = t.add({ type = 'label', caption = h[1] })
|
||||
@ -283,23 +283,23 @@ local function on_gui_click(event)
|
||||
if new_group_name ~= '' and new_group_name ~= 'Name' and new_group_description ~= 'Description' then
|
||||
if this.alphanumeric then
|
||||
if alphanumeric(new_group_name) then
|
||||
player.print('Group name is not valid.', { r = 0.90, g = 0.0, b = 0.0 })
|
||||
player.print('Group name is not valid.', { color = { r = 0.90, g = 0.0, b = 0.0 } })
|
||||
return
|
||||
end
|
||||
|
||||
if alphanumeric(new_group_description) then
|
||||
player.print('Group description is not valid.', { r = 0.90, g = 0.0, b = 0.0 })
|
||||
player.print('Group description is not valid.', { color = { r = 0.90, g = 0.0, b = 0.0 } })
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if string.len(new_group_name) > 64 then
|
||||
player.print('Group name is too long. 64 characters maximum.', { r = 0.90, g = 0.0, b = 0.0 })
|
||||
player.print('Group name is too long. 64 characters maximum.', { color = { r = 0.90, g = 0.0, b = 0.0 } })
|
||||
return
|
||||
end
|
||||
|
||||
if string.len(new_group_description) > 128 then
|
||||
player.print('Description is too long. 128 characters maximum.', { r = 0.90, g = 0.0, b = 0.0 })
|
||||
player.print('Description is too long. 128 characters maximum.', { color = { r = 0.90, g = 0.0, b = 0.0 } })
|
||||
return
|
||||
end
|
||||
|
||||
@ -360,7 +360,7 @@ local function on_gui_click(event)
|
||||
|
||||
if element.type == 'button' and caption == 'gui.delete' then
|
||||
if this.tag_groups[element.parent.name] and this.tag_groups[element.parent.name].static then
|
||||
player.print('Static groups cannot be deleted.', Color.warning)
|
||||
player.print('Static groups cannot be deleted.', { color = Color.warning })
|
||||
return
|
||||
end
|
||||
for _, players in pairs(game.players) do
|
||||
|
@ -65,6 +65,8 @@ function Public.init_player_table(player, reset)
|
||||
this.score_table[player.force.name].players = {}
|
||||
end
|
||||
|
||||
if not player.name then return end
|
||||
|
||||
if not this.score_table[player.force.name].players[player.name] then
|
||||
this.score_table[player.force.name].players[player.name] = {
|
||||
built_entities = 0,
|
||||
@ -500,6 +502,10 @@ Gui.on_click(
|
||||
end
|
||||
)
|
||||
|
||||
Event.on_init(function ()
|
||||
Public.reset_tbl()
|
||||
end)
|
||||
|
||||
Event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
|
||||
Event.add(defines.events.on_player_crafted_item, on_player_crafted_item)
|
||||
Event.add(defines.events.on_player_died, on_player_died)
|
||||
|
Loading…
x
Reference in New Issue
Block a user