You've already forked ComfyFactorio
mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-11-25 22:32:18 +02:00
Changes for Mtn v3 and minor utils files
This commit is contained in:
@@ -4,8 +4,7 @@ local Collapse = require 'modules.collapse'
|
|||||||
local RPG = require 'modules.rpg.main'
|
local RPG = require 'modules.rpg.main'
|
||||||
local WD = require 'modules.wave_defense.table'
|
local WD = require 'modules.wave_defense.table'
|
||||||
local Alert = require 'utils.alert'
|
local Alert = require 'utils.alert'
|
||||||
local Task = require 'utils.task'
|
local Task = require 'utils.task_token'
|
||||||
local Token = require 'utils.token'
|
|
||||||
local Color = require 'utils.color_presets'
|
local Color = require 'utils.color_presets'
|
||||||
local ICF = require 'maps.mountain_fortress_v3.ic.functions'
|
local ICF = require 'maps.mountain_fortress_v3.ic.functions'
|
||||||
|
|
||||||
@@ -40,7 +39,7 @@ local clear_breach_text_and_render = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local collapse_message =
|
local collapse_message =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(data)
|
function(data)
|
||||||
local pos = data.position
|
local pos = data.position
|
||||||
local message = ({'breached_wall.collapse_start'})
|
local message = ({'breached_wall.collapse_start'})
|
||||||
@@ -52,7 +51,7 @@ local collapse_message =
|
|||||||
)
|
)
|
||||||
|
|
||||||
local driving_state_changed_token =
|
local driving_state_changed_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(event)
|
function(event)
|
||||||
local player_index = event.player_index
|
local player_index = event.player_index
|
||||||
local player = game.get_player(player_index)
|
local player = game.get_player(player_index)
|
||||||
@@ -81,7 +80,7 @@ local driving_state_changed_token =
|
|||||||
)
|
)
|
||||||
|
|
||||||
local spidertron_unlocked =
|
local spidertron_unlocked =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(event)
|
function(event)
|
||||||
if event then
|
if event then
|
||||||
local message = ({'breached_wall.spidertron_unlocked'})
|
local message = ({'breached_wall.spidertron_unlocked'})
|
||||||
@@ -94,7 +93,7 @@ local spidertron_unlocked =
|
|||||||
)
|
)
|
||||||
|
|
||||||
local first_player_to_zone =
|
local first_player_to_zone =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(data)
|
function(data)
|
||||||
local player = data.player
|
local player = data.player
|
||||||
if not player or not player.valid then
|
if not player or not player.valid then
|
||||||
@@ -108,7 +107,7 @@ local first_player_to_zone =
|
|||||||
)
|
)
|
||||||
|
|
||||||
local artillery_warning =
|
local artillery_warning =
|
||||||
Token.register(
|
Task.register(
|
||||||
function()
|
function()
|
||||||
local message = ({'breached_wall.artillery_warning'})
|
local message = ({'breached_wall.artillery_warning'})
|
||||||
Alert.alert_all_players(10, message)
|
Alert.alert_all_players(10, message)
|
||||||
@@ -137,7 +136,7 @@ local breach_wall_warning_teleport = function(player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local spidertron_too_far =
|
local spidertron_too_far =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(data)
|
function(data)
|
||||||
local player = data.player
|
local player = data.player
|
||||||
local message = ({'breached_wall.cheating_through', player.name})
|
local message = ({'breached_wall.cheating_through', player.name})
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ local Server = require 'utils.server'
|
|||||||
local RPG = require 'modules.rpg.main'
|
local RPG = require 'modules.rpg.main'
|
||||||
local Collapse = require 'modules.collapse'
|
local Collapse = require 'modules.collapse'
|
||||||
local Alert = require 'utils.alert'
|
local Alert = require 'utils.alert'
|
||||||
local Task = require 'utils.task'
|
local Task = require 'utils.task_token'
|
||||||
local Score = require 'utils.gui.score'
|
local Score = require 'utils.gui.score'
|
||||||
local Token = require 'utils.token'
|
|
||||||
local Discord = require 'utils.discord'
|
local Discord = require 'utils.discord'
|
||||||
local Core = require 'utils.core'
|
local Core = require 'utils.core'
|
||||||
local Diff = require 'modules.difficulty_vote_by_amount'
|
local Diff = require 'modules.difficulty_vote_by_amount'
|
||||||
@@ -81,7 +80,7 @@ local protect_types = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local reset_game =
|
local reset_game =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(data)
|
function(data)
|
||||||
local this = data.this
|
local this = data.this
|
||||||
if this.soft_reset then
|
if this.soft_reset then
|
||||||
@@ -442,7 +441,7 @@ local function angry_tree(entity, cause, player)
|
|||||||
if e.can_insert(Public.piercing_rounds_magazine_ammo) then
|
if e.can_insert(Public.piercing_rounds_magazine_ammo) then
|
||||||
e.insert(Public.piercing_rounds_magazine_ammo)
|
e.insert(Public.piercing_rounds_magazine_ammo)
|
||||||
end
|
end
|
||||||
local callback = Token.get(cbl)
|
local callback = Task.get(cbl)
|
||||||
callback(e, data)
|
callback(e, data)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -482,7 +481,7 @@ local function give_coin(player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local immunity_spawner =
|
local immunity_spawner =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(data)
|
function(data)
|
||||||
local entity = data.entity
|
local entity = data.entity
|
||||||
if not entity or not entity.valid then
|
if not entity or not entity.valid then
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Public = require 'maps.mountain_fortress_v3.table'
|
local Public = require 'maps.mountain_fortress_v3.table'
|
||||||
local Server = require 'utils.server'
|
local Server = require 'utils.server'
|
||||||
local Token = require 'utils.token'
|
local Task = require 'utils.task_token'
|
||||||
local Task = require 'utils.task'
|
|
||||||
local Color = require 'utils.color_presets'
|
local Color = require 'utils.color_presets'
|
||||||
local ICW = require 'maps.mountain_fortress_v3.icw.main'
|
local ICW = require 'maps.mountain_fortress_v3.icw.main'
|
||||||
local Global = require 'utils.global'
|
local Global = require 'utils.global'
|
||||||
@@ -138,7 +137,7 @@ local function fast_remove(tbl, index)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local pause_waves_custom_callback_token =
|
local pause_waves_custom_callback_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(status)
|
function(status)
|
||||||
Collapse.disable_collapse(status)
|
Collapse.disable_collapse(status)
|
||||||
local status_str = status and 'has stopped!' or 'is active once again!'
|
local status_str = status and 'has stopped!' or 'is active once again!'
|
||||||
@@ -278,7 +277,7 @@ local function do_magic_fluid_crafters()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local artillery_target_callback =
|
local artillery_target_callback =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(data)
|
function(data)
|
||||||
local position = data.position
|
local position = data.position
|
||||||
local entity = data.entity
|
local entity = data.entity
|
||||||
@@ -455,7 +454,7 @@ local function tick()
|
|||||||
end
|
end
|
||||||
|
|
||||||
Public.deactivate_callback =
|
Public.deactivate_callback =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(entity)
|
function(entity)
|
||||||
if entity and entity.valid then
|
if entity and entity.valid then
|
||||||
entity.active = false
|
entity.active = false
|
||||||
@@ -466,7 +465,7 @@ Public.deactivate_callback =
|
|||||||
)
|
)
|
||||||
|
|
||||||
Public.neutral_force =
|
Public.neutral_force =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(entity)
|
function(entity)
|
||||||
if entity and entity.valid then
|
if entity and entity.valid then
|
||||||
entity.force = 'neutral'
|
entity.force = 'neutral'
|
||||||
@@ -475,7 +474,7 @@ Public.neutral_force =
|
|||||||
)
|
)
|
||||||
|
|
||||||
Public.enemy_force =
|
Public.enemy_force =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(entity)
|
function(entity)
|
||||||
if entity and entity.valid then
|
if entity and entity.valid then
|
||||||
entity.force = 'enemy'
|
entity.force = 'enemy'
|
||||||
@@ -484,7 +483,7 @@ Public.enemy_force =
|
|||||||
)
|
)
|
||||||
|
|
||||||
Public.active_not_destructible_callback =
|
Public.active_not_destructible_callback =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(entity)
|
function(entity)
|
||||||
if entity and entity.valid then
|
if entity and entity.valid then
|
||||||
entity.active = true
|
entity.active = true
|
||||||
@@ -495,7 +494,7 @@ Public.active_not_destructible_callback =
|
|||||||
)
|
)
|
||||||
|
|
||||||
Public.disable_minable_callback =
|
Public.disable_minable_callback =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(entity)
|
function(entity)
|
||||||
if entity and entity.valid then
|
if entity and entity.valid then
|
||||||
entity.minable = false
|
entity.minable = false
|
||||||
@@ -504,7 +503,7 @@ Public.disable_minable_callback =
|
|||||||
)
|
)
|
||||||
|
|
||||||
Public.disable_minable_and_ICW_callback =
|
Public.disable_minable_and_ICW_callback =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(entity)
|
function(entity)
|
||||||
if entity and entity.valid then
|
if entity and entity.valid then
|
||||||
entity.minable = false
|
entity.minable = false
|
||||||
@@ -514,7 +513,7 @@ Public.disable_minable_and_ICW_callback =
|
|||||||
)
|
)
|
||||||
|
|
||||||
Public.disable_destructible_callback =
|
Public.disable_destructible_callback =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(entity)
|
function(entity)
|
||||||
if entity and entity.valid then
|
if entity and entity.valid then
|
||||||
entity.destructible = false
|
entity.destructible = false
|
||||||
@@ -523,7 +522,7 @@ Public.disable_destructible_callback =
|
|||||||
end
|
end
|
||||||
)
|
)
|
||||||
Public.disable_active_callback =
|
Public.disable_active_callback =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(entity)
|
function(entity)
|
||||||
if entity and entity.valid then
|
if entity and entity.valid then
|
||||||
entity.active = false
|
entity.active = false
|
||||||
@@ -534,7 +533,7 @@ Public.disable_active_callback =
|
|||||||
local disable_active_callback = Public.disable_active_callback
|
local disable_active_callback = Public.disable_active_callback
|
||||||
|
|
||||||
Public.refill_turret_callback =
|
Public.refill_turret_callback =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(turret, data)
|
function(turret, data)
|
||||||
local refill_turrets = this.refill_turrets
|
local refill_turrets = this.refill_turrets
|
||||||
local callback_data = data.callback_data
|
local callback_data = data.callback_data
|
||||||
@@ -545,7 +544,7 @@ Public.refill_turret_callback =
|
|||||||
)
|
)
|
||||||
|
|
||||||
Public.refill_artillery_turret_callback =
|
Public.refill_artillery_turret_callback =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(turret, data)
|
function(turret, data)
|
||||||
local refill_turrets = this.refill_turrets
|
local refill_turrets = this.refill_turrets
|
||||||
local art_table = this.art_table
|
local art_table = this.art_table
|
||||||
@@ -579,7 +578,7 @@ Public.refill_artillery_turret_callback =
|
|||||||
)
|
)
|
||||||
|
|
||||||
Public.refill_liquid_turret_callback =
|
Public.refill_liquid_turret_callback =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(turret, data)
|
function(turret, data)
|
||||||
local refill_turrets = this.refill_turrets
|
local refill_turrets = this.refill_turrets
|
||||||
local callback_data = data.callback_data
|
local callback_data = data.callback_data
|
||||||
@@ -590,7 +589,7 @@ Public.refill_liquid_turret_callback =
|
|||||||
)
|
)
|
||||||
|
|
||||||
Public.power_source_callback =
|
Public.power_source_callback =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(turret)
|
function(turret)
|
||||||
local power_sources = this.power_sources
|
local power_sources = this.power_sources
|
||||||
power_sources[#power_sources + 1] = turret
|
power_sources[#power_sources + 1] = turret
|
||||||
@@ -598,7 +597,7 @@ Public.power_source_callback =
|
|||||||
)
|
)
|
||||||
|
|
||||||
Public.magic_item_crafting_callback =
|
Public.magic_item_crafting_callback =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(entity, data)
|
function(entity, data)
|
||||||
local callback_data = data.callback_data
|
local callback_data = data.callback_data
|
||||||
if not (entity and entity.valid) then
|
if not (entity and entity.valid) then
|
||||||
@@ -653,7 +652,7 @@ Public.magic_item_crafting_callback =
|
|||||||
)
|
)
|
||||||
|
|
||||||
Public.magic_item_crafting_callback_weighted =
|
Public.magic_item_crafting_callback_weighted =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(entity, data)
|
function(entity, data)
|
||||||
local callback_data = data.callback_data
|
local callback_data = data.callback_data
|
||||||
if not (entity and entity.valid) then
|
if not (entity and entity.valid) then
|
||||||
@@ -800,7 +799,7 @@ local function calc_players()
|
|||||||
end
|
end
|
||||||
|
|
||||||
remove_boost_movement_speed_on_respawn =
|
remove_boost_movement_speed_on_respawn =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(data)
|
function(data)
|
||||||
local player = data.player
|
local player = data.player
|
||||||
if not player or not player.valid then
|
if not player or not player.valid then
|
||||||
@@ -821,7 +820,7 @@ remove_boost_movement_speed_on_respawn =
|
|||||||
)
|
)
|
||||||
|
|
||||||
local boost_movement_speed_on_respawn =
|
local boost_movement_speed_on_respawn =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(data)
|
function(data)
|
||||||
local player = data.player
|
local player = data.player
|
||||||
if not player or not player.valid then
|
if not player or not player.valid then
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Public = require 'maps.mountain_fortress_v3.table'
|
local Public = require 'maps.mountain_fortress_v3.table'
|
||||||
local Task = require 'utils.task'
|
local Task = require 'utils.task_token'
|
||||||
local Token = require 'utils.token'
|
|
||||||
local WD = require 'modules.wave_defense.table'
|
local WD = require 'modules.wave_defense.table'
|
||||||
local BiterHealthBooster = require 'modules.biter_health_booster_v2'
|
local BiterHealthBooster = require 'modules.biter_health_booster_v2'
|
||||||
|
|
||||||
@@ -233,10 +232,10 @@ local function do_place_buildings(data)
|
|||||||
if c then
|
if c then
|
||||||
local d = {callback_data = e.callback.data}
|
local d = {callback_data = e.callback.data}
|
||||||
if not d then
|
if not d then
|
||||||
callback = Token.get(c)
|
callback = Task.get(c)
|
||||||
callback(entity)
|
callback(entity)
|
||||||
else
|
else
|
||||||
callback = Token.get(c)
|
callback = Task.get(c)
|
||||||
callback(entity, d)
|
callback(entity, d)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -325,10 +324,10 @@ local function do_place_entities(data)
|
|||||||
end
|
end
|
||||||
local d = {callback_data = e.callback.data}
|
local d = {callback_data = e.callback.data}
|
||||||
if not d then
|
if not d then
|
||||||
callback = Token.get(c)
|
callback = Task.get(c)
|
||||||
callback(entity)
|
callback(entity)
|
||||||
else
|
else
|
||||||
callback = Token.get(c)
|
callback = Task.get(c)
|
||||||
callback(entity, d)
|
callback(entity, d)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -362,10 +361,10 @@ local function do_place_entities(data)
|
|||||||
if c then
|
if c then
|
||||||
local d = {callback_data = e.callback.data}
|
local d = {callback_data = e.callback.data}
|
||||||
if not d then
|
if not d then
|
||||||
callback = Token.get(c)
|
callback = Task.get(c)
|
||||||
callback(entity)
|
callback(entity)
|
||||||
else
|
else
|
||||||
callback = Token.get(c)
|
callback = Task.get(c)
|
||||||
callback(entity, d)
|
callback(entity, d)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -474,7 +473,7 @@ local function map_gen_action(data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local map_gen_action_token = Token.register(map_gen_action)
|
local map_gen_action_token = Task.register(map_gen_action)
|
||||||
|
|
||||||
--- Adds generation of a Chunk of the map to the queue
|
--- Adds generation of a Chunk of the map to the queue
|
||||||
-- @param event <table> the event table from on_chunk_generated
|
-- @param event <table> the event table from on_chunk_generated
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ local Event = require 'utils.event'
|
|||||||
local Public = require 'maps.mountain_fortress_v3.table'
|
local Public = require 'maps.mountain_fortress_v3.table'
|
||||||
local Global = require 'utils.global'
|
local Global = require 'utils.global'
|
||||||
local Server = require 'utils.server'
|
local Server = require 'utils.server'
|
||||||
local Token = require 'utils.token'
|
|
||||||
local Gui = require 'utils.gui'
|
local Gui = require 'utils.gui'
|
||||||
|
local Task = require 'utils.task_token'
|
||||||
local Score = require 'utils.gui.score'
|
local Score = require 'utils.gui.score'
|
||||||
local WD = require 'modules.wave_defense.table'
|
local WD = require 'modules.wave_defense.table'
|
||||||
local Core = require 'utils.core'
|
local Core = require 'utils.core'
|
||||||
@@ -431,7 +431,7 @@ local function write_additional_stats(key, difficulty)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local get_scores =
|
local get_scores =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(data)
|
function(data)
|
||||||
local value = data.value
|
local value = data.value
|
||||||
if not this.score_table['player'] then
|
if not this.score_table['player'] then
|
||||||
@@ -692,7 +692,7 @@ local function show_score(data)
|
|||||||
end -- foreach entry
|
end -- foreach entry
|
||||||
end
|
end
|
||||||
|
|
||||||
local show_score_token = Token.register(show_score)
|
local show_score_token = Task.register(show_score)
|
||||||
|
|
||||||
local function on_gui_click(event)
|
local function on_gui_click(event)
|
||||||
local element = event.element
|
local element = event.element
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
local Utils = require 'utils.core'
|
local Utils = require 'utils.core'
|
||||||
local Color = require 'utils.color_presets'
|
local Color = require 'utils.color_presets'
|
||||||
local Task = require 'utils.task'
|
local Task = require 'utils.task_token'
|
||||||
local Token = require 'utils.token'
|
|
||||||
local IC = require 'maps.mountain_fortress_v3.ic.table'
|
local IC = require 'maps.mountain_fortress_v3.ic.table'
|
||||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||||
local RPG = require 'modules.rpg.main'
|
local RPG = require 'modules.rpg.main'
|
||||||
@@ -624,7 +623,7 @@ local function get_persistent_player_data(player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local remove_car =
|
local remove_car =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(data)
|
function(data)
|
||||||
local player = data.player
|
local player = data.player
|
||||||
local car = data.car
|
local car = data.car
|
||||||
@@ -633,7 +632,7 @@ local remove_car =
|
|||||||
)
|
)
|
||||||
|
|
||||||
local find_remove_car =
|
local find_remove_car =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(data)
|
function(data)
|
||||||
local index = data.index
|
local index = data.index
|
||||||
local types = data.types
|
local types = data.types
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ local Color = require 'utils.color_presets'
|
|||||||
local Gui = require 'utils.gui'
|
local Gui = require 'utils.gui'
|
||||||
local Tabs = require 'utils.gui'
|
local Tabs = require 'utils.gui'
|
||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Token = require 'utils.token'
|
local Task = require 'utils.task_token'
|
||||||
local Task = require 'utils.task'
|
|
||||||
local SpamProtection = require 'utils.spam_protection'
|
local SpamProtection = require 'utils.spam_protection'
|
||||||
|
|
||||||
local Public = {}
|
local Public = {}
|
||||||
@@ -771,7 +770,7 @@ Gui.on_click(
|
|||||||
)
|
)
|
||||||
|
|
||||||
local clear_misc_settings =
|
local clear_misc_settings =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(data)
|
function(data)
|
||||||
local player_index = data.player_index
|
local player_index = data.player_index
|
||||||
local misc_settings = ICT.get('misc_settings')
|
local misc_settings = ICT.get('misc_settings')
|
||||||
|
|||||||
@@ -2,9 +2,8 @@ local Public = {}
|
|||||||
|
|
||||||
local ICW = require 'maps.mountain_fortress_v3.icw.table'
|
local ICW = require 'maps.mountain_fortress_v3.icw.table'
|
||||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||||
local Task = require 'utils.task'
|
local Task = require 'utils.task_token'
|
||||||
local Gui = require 'utils.gui'
|
local Gui = require 'utils.gui'
|
||||||
local Token = require 'utils.token'
|
|
||||||
local SpamProtection = require 'utils.spam_protection'
|
local SpamProtection = require 'utils.spam_protection'
|
||||||
local Core = require 'utils.core'
|
local Core = require 'utils.core'
|
||||||
local LinkedChests = require 'maps.mountain_fortress_v3.icw.linked_chests'
|
local LinkedChests = require 'maps.mountain_fortress_v3.icw.linked_chests'
|
||||||
@@ -30,7 +29,7 @@ end
|
|||||||
local size_of_debris = #fallout_debris
|
local size_of_debris = #fallout_debris
|
||||||
|
|
||||||
local add_chests_to_wagon_token =
|
local add_chests_to_wagon_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(data)
|
function(data)
|
||||||
local wagon = data.wagon
|
local wagon = data.wagon
|
||||||
local surface = data.surface
|
local surface = data.surface
|
||||||
@@ -108,7 +107,7 @@ local add_chests_to_wagon_token =
|
|||||||
)
|
)
|
||||||
|
|
||||||
local reconstruct_all_trains =
|
local reconstruct_all_trains =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(data)
|
function(data)
|
||||||
local icw = data.icw
|
local icw = data.icw
|
||||||
Public.reconstruct_all_trains(icw)
|
Public.reconstruct_all_trains(icw)
|
||||||
@@ -116,7 +115,7 @@ local reconstruct_all_trains =
|
|||||||
)
|
)
|
||||||
|
|
||||||
local remove_non_migrated_doors_token =
|
local remove_non_migrated_doors_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(data)
|
function(data)
|
||||||
local icw = data.icw
|
local icw = data.icw
|
||||||
for _, unit_data in pairs(icw.wagons) do
|
for _, unit_data in pairs(icw.wagons) do
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ local Event = require 'utils.event'
|
|||||||
local Color = require 'utils.color_presets'
|
local Color = require 'utils.color_presets'
|
||||||
local Global = require 'utils.global'
|
local Global = require 'utils.global'
|
||||||
local Gui = require 'utils.gui'
|
local Gui = require 'utils.gui'
|
||||||
local Task = require 'utils.task'
|
local Task = require 'utils.task_token'
|
||||||
local Token = require 'utils.token'
|
|
||||||
local Where = require 'utils.commands.where'
|
local Where = require 'utils.commands.where'
|
||||||
local Math2D = require 'math2d'
|
local Math2D = require 'math2d'
|
||||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||||
@@ -54,7 +53,7 @@ function Public.set(key, value)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local clear_chest_token =
|
local clear_chest_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(event)
|
function(event)
|
||||||
local entity = event.entity
|
local entity = event.entity
|
||||||
if not entity or not entity.valid then
|
if not entity or not entity.valid then
|
||||||
@@ -72,7 +71,7 @@ local clear_chest_token =
|
|||||||
)
|
)
|
||||||
|
|
||||||
local create_clear_chest_token =
|
local create_clear_chest_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(event)
|
function(event)
|
||||||
local surface = game.get_surface('gulag')
|
local surface = game.get_surface('gulag')
|
||||||
local entity = surface.create_entity {name = 'linked-chest', position = {x = -62, y = -6}, force = game.forces.player}
|
local entity = surface.create_entity {name = 'linked-chest', position = {x = -62, y = -6}, force = game.forces.player}
|
||||||
@@ -91,7 +90,7 @@ local create_clear_chest_token =
|
|||||||
)
|
)
|
||||||
|
|
||||||
local remove_all_linked_items_token =
|
local remove_all_linked_items_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(event)
|
function(event)
|
||||||
local player_index = event.player_index
|
local player_index = event.player_index
|
||||||
local player = game.get_player(player_index)
|
local player = game.get_player(player_index)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
local Public = require 'maps.mountain_fortress_v3.table'
|
local Public = require 'maps.mountain_fortress_v3.table'
|
||||||
local ICW = require 'maps.mountain_fortress_v3.icw.main'
|
local ICW = require 'maps.mountain_fortress_v3.icw.main'
|
||||||
local Task = require 'utils.task'
|
local Task = require 'utils.task_token'
|
||||||
local Token = require 'utils.token'
|
|
||||||
local MapFunctions = require 'tools.map_functions'
|
local MapFunctions = require 'tools.map_functions'
|
||||||
|
|
||||||
local random = math.random
|
local random = math.random
|
||||||
@@ -70,7 +69,7 @@ local function initial_cargo_boxes()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local place_tiles_token =
|
local place_tiles_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(event)
|
function(event)
|
||||||
local surface = event.surface
|
local surface = event.surface
|
||||||
if not surface or not surface.valid then
|
if not surface or not surface.valid then
|
||||||
@@ -86,7 +85,7 @@ local place_tiles_token =
|
|||||||
)
|
)
|
||||||
|
|
||||||
local set_loco_cargo =
|
local set_loco_cargo =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(data)
|
function(data)
|
||||||
local surface = data.surface
|
local surface = data.surface
|
||||||
if not surface or not surface.valid then
|
if not surface or not surface.valid then
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ local Score = require 'utils.gui.score'
|
|||||||
local Poll = require 'utils.gui.poll'
|
local Poll = require 'utils.gui.poll'
|
||||||
local Collapse = require 'modules.collapse'
|
local Collapse = require 'modules.collapse'
|
||||||
local Difficulty = require 'modules.difficulty_vote_by_amount'
|
local Difficulty = require 'modules.difficulty_vote_by_amount'
|
||||||
local Task = require 'utils.task'
|
local Task = require 'utils.task_token'
|
||||||
local Token = require 'utils.token'
|
|
||||||
local Alert = require 'utils.alert'
|
local Alert = require 'utils.alert'
|
||||||
local BottomFrame = require 'utils.gui.bottom_frame'
|
local BottomFrame = require 'utils.gui.bottom_frame'
|
||||||
local AntiGrief = require 'utils.antigrief'
|
local AntiGrief = require 'utils.antigrief'
|
||||||
@@ -106,7 +105,7 @@ local is_position_near_tbl = function(position, tbl)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local announce_new_map =
|
local announce_new_map =
|
||||||
Token.register(
|
Task.register(
|
||||||
function()
|
function()
|
||||||
local server_name = Server.check_server_name('Mtn Fortress')
|
local server_name = Server.check_server_name('Mtn Fortress')
|
||||||
if server_name then
|
if server_name then
|
||||||
@@ -400,7 +399,7 @@ local chunk_load = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local collapse_message =
|
local collapse_message =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(data)
|
function(data)
|
||||||
local pos = data.position
|
local pos = data.position
|
||||||
local message = data.message
|
local message = data.message
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ local Event = require 'utils.event'
|
|||||||
local Public = require 'maps.mountain_fortress_v3.table'
|
local Public = require 'maps.mountain_fortress_v3.table'
|
||||||
local RPG = require 'modules.rpg.main'
|
local RPG = require 'modules.rpg.main'
|
||||||
local Alert = require 'utils.alert'
|
local Alert = require 'utils.alert'
|
||||||
local Task = require 'utils.task'
|
local Task = require 'utils.task_token'
|
||||||
local Token = require 'utils.token'
|
|
||||||
|
|
||||||
local shuffle = table.shuffle_table
|
local shuffle = table.shuffle_table
|
||||||
local random = math.random
|
local random = math.random
|
||||||
@@ -264,7 +263,7 @@ local function roll_item_stacks(remaining_budget, max_slots, blacklist)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local restore_mining_speed_token =
|
local restore_mining_speed_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function()
|
function()
|
||||||
local mc_rewards = Public.get('mc_rewards')
|
local mc_rewards = Public.get('mc_rewards')
|
||||||
local force = game.forces.player
|
local force = game.forces.player
|
||||||
@@ -278,7 +277,7 @@ local restore_mining_speed_token =
|
|||||||
)
|
)
|
||||||
|
|
||||||
local restore_crafting_speed_token =
|
local restore_crafting_speed_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function()
|
function()
|
||||||
local mc_rewards = Public.get('mc_rewards')
|
local mc_rewards = Public.get('mc_rewards')
|
||||||
local force = game.forces.player
|
local force = game.forces.player
|
||||||
@@ -292,7 +291,7 @@ local restore_crafting_speed_token =
|
|||||||
)
|
)
|
||||||
|
|
||||||
local restore_movement_speed_token =
|
local restore_movement_speed_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function()
|
function()
|
||||||
local mc_rewards = Public.get('mc_rewards')
|
local mc_rewards = Public.get('mc_rewards')
|
||||||
local force = game.forces.player
|
local force = game.forces.player
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
local Public = require 'maps.mountain_fortress_v3.stateful.table'
|
local Public = require 'maps.mountain_fortress_v3.stateful.table'
|
||||||
local map_name = 'boss_room'
|
local map_name = 'boss_room'
|
||||||
local Token = require 'utils.token'
|
local Task = require 'utils.task_token'
|
||||||
local Task = require 'utils.task'
|
|
||||||
|
|
||||||
local blueprint_token =
|
local blueprint_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function()
|
function()
|
||||||
Public.blueprint()
|
Public.blueprint()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Task = require 'utils.task'
|
local Task = require 'utils.task_token'
|
||||||
local Token = require 'utils.token'
|
|
||||||
|
|
||||||
local Public = require 'maps.mountain_fortress_v3.stateful.table'
|
local Public = require 'maps.mountain_fortress_v3.stateful.table'
|
||||||
|
|
||||||
local ceil = math.ceil
|
local ceil = math.ceil
|
||||||
@@ -187,10 +185,10 @@ local function do_place_buildings(data)
|
|||||||
if c then
|
if c then
|
||||||
local d = {callback_data = e.callback.data}
|
local d = {callback_data = e.callback.data}
|
||||||
if not d then
|
if not d then
|
||||||
callback = Token.get(c)
|
callback = Task.get(c)
|
||||||
callback(entity)
|
callback(entity)
|
||||||
else
|
else
|
||||||
callback = Token.get(c)
|
callback = Task.get(c)
|
||||||
callback(entity, d)
|
callback(entity, d)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -235,7 +233,7 @@ local function do_place_entities(data)
|
|||||||
entity.amount = e.amount
|
entity.amount = e.amount
|
||||||
end
|
end
|
||||||
if e.callback then
|
if e.callback then
|
||||||
callback = Token.get(e.callback)
|
callback = Task.get(e.callback)
|
||||||
callback({entity = entity})
|
callback({entity = entity})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -259,7 +257,7 @@ local function do_place_entities(data)
|
|||||||
entity.amount = e.amount
|
entity.amount = e.amount
|
||||||
end
|
end
|
||||||
if e.callback then
|
if e.callback then
|
||||||
callback = Token.get(e.callback)
|
callback = Task.get(e.callback)
|
||||||
callback({entity = entity})
|
callback({entity = entity})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -329,7 +327,7 @@ local function map_gen_action(data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local map_gen_action_token = Token.register(map_gen_action)
|
local map_gen_action_token = Task.register(map_gen_action)
|
||||||
|
|
||||||
--- Adds generation of a Chunk of the map to the queue
|
--- Adds generation of a Chunk of the map to the queue
|
||||||
-- @param event <table> the event table from on_chunk_generated
|
-- @param event <table> the event table from on_chunk_generated
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ local Stateful = require 'maps.mountain_fortress_v3.stateful.table'
|
|||||||
local Gui = require 'utils.gui'
|
local Gui = require 'utils.gui'
|
||||||
local WD = require 'modules.wave_defense.table'
|
local WD = require 'modules.wave_defense.table'
|
||||||
local Collapse = require 'modules.collapse'
|
local Collapse = require 'modules.collapse'
|
||||||
local Token = require 'utils.token'
|
local Task = require 'utils.task_token'
|
||||||
local Task = require 'utils.task'
|
|
||||||
local Core = require 'utils.core'
|
local Core = require 'utils.core'
|
||||||
local Server = require 'utils.server'
|
local Server = require 'utils.server'
|
||||||
local LinkedChests = require 'maps.mountain_fortress_v3.icw.linked_chests'
|
local LinkedChests = require 'maps.mountain_fortress_v3.icw.linked_chests'
|
||||||
@@ -55,7 +54,7 @@ local function create_particles(surface, name, position, amount, cause_position)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local spread_particles_token =
|
local spread_particles_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(event)
|
function(event)
|
||||||
local player_index = event.player_index
|
local player_index = event.player_index
|
||||||
local player = game.get_player(player_index)
|
local player = game.get_player(player_index)
|
||||||
@@ -166,7 +165,7 @@ local function refresh_frames()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local warn_player_sound_token =
|
local warn_player_sound_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(event)
|
function(event)
|
||||||
local player_index = event.player_index
|
local player_index = event.player_index
|
||||||
local player = game.get_player(player_index)
|
local player = game.get_player(player_index)
|
||||||
@@ -299,7 +298,7 @@ local function objective_frames(stateful, player_frame, objective, data)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local callback = Token.get(objective.token)
|
local callback = Task.get(objective.token)
|
||||||
|
|
||||||
local _, objective_locale_left, objective_locale_right, tooltip_left, tooltip_right = callback()
|
local _, objective_locale_left, objective_locale_right, tooltip_left, tooltip_right = callback()
|
||||||
|
|
||||||
@@ -783,7 +782,7 @@ local function update_data()
|
|||||||
for objective_index = 1, #stateful.selected_objectives do
|
for objective_index = 1, #stateful.selected_objectives do
|
||||||
local objective = stateful.selected_objectives[objective_index]
|
local objective = stateful.selected_objectives[objective_index]
|
||||||
local objective_name = objective.name
|
local objective_name = objective.name
|
||||||
local callback = Token.get(objective.token)
|
local callback = Task.get(objective.token)
|
||||||
local _, _, objective_locale_right, _, objective_tooltip_right = callback()
|
local _, _, objective_locale_right, _, objective_tooltip_right = callback()
|
||||||
if name == objective_name and frame and frame.valid then
|
if name == objective_name and frame and frame.valid then
|
||||||
frame.caption = objective_locale_right
|
frame.caption = objective_locale_right
|
||||||
@@ -979,7 +978,7 @@ local function update_raw()
|
|||||||
for objective_index = 1, #stateful.selected_objectives do
|
for objective_index = 1, #stateful.selected_objectives do
|
||||||
local objective = stateful.selected_objectives[objective_index]
|
local objective = stateful.selected_objectives[objective_index]
|
||||||
local objective_name = objective.name
|
local objective_name = objective.name
|
||||||
local callback = Token.get(objective.token)
|
local callback = Task.get(objective.token)
|
||||||
local completed, _, _ = callback()
|
local completed, _, _ = callback()
|
||||||
if completed and completed == true and not stateful.objectives_completed[objective_name] then
|
if completed and completed == true and not stateful.objectives_completed[objective_name] then
|
||||||
stateful.objectives_completed[objective_name] = true
|
stateful.objectives_completed[objective_name] = true
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ local Global = require 'utils.global'
|
|||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Utils = require 'utils.utils'
|
local Utils = require 'utils.utils'
|
||||||
local Server = require 'utils.server'
|
local Server = require 'utils.server'
|
||||||
local Token = require 'utils.token'
|
local Task = require 'utils.task_token'
|
||||||
local shuffle = table.shuffle_table
|
local shuffle = table.shuffle_table
|
||||||
local WD = require 'modules.wave_defense.table'
|
local WD = require 'modules.wave_defense.table'
|
||||||
local format_number = require 'util'.format_number
|
local format_number = require 'util'.format_number
|
||||||
@@ -11,7 +11,6 @@ local ICWF = require 'maps.mountain_fortress_v3.icw.functions'
|
|||||||
local ICWT = require 'maps.mountain_fortress_v3.icw.table'
|
local ICWT = require 'maps.mountain_fortress_v3.icw.table'
|
||||||
local Core = require 'utils.core'
|
local Core = require 'utils.core'
|
||||||
local Public = require 'maps.mountain_fortress_v3.table'
|
local Public = require 'maps.mountain_fortress_v3.table'
|
||||||
local Task = require 'utils.task'
|
|
||||||
local Alert = require 'utils.alert'
|
local Alert = require 'utils.alert'
|
||||||
local IC = require 'maps.mountain_fortress_v3.ic.table'
|
local IC = require 'maps.mountain_fortress_v3.ic.table'
|
||||||
local RPG = require 'modules.rpg.table'
|
local RPG = require 'modules.rpg.table'
|
||||||
@@ -336,14 +335,14 @@ local function get_killed_enemies_count(primary, secondary)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local move_all_players_token =
|
local move_all_players_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function()
|
function()
|
||||||
Public.move_all_players()
|
Public.move_all_players()
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
local search_corpse_token =
|
local search_corpse_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(event)
|
function(event)
|
||||||
local player_index = event.player_index
|
local player_index = event.player_index
|
||||||
local player = game.get_player(player_index)
|
local player = game.get_player(player_index)
|
||||||
@@ -419,14 +418,14 @@ local function on_market_item_purchased(event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local empty_token =
|
local empty_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function()
|
function()
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
local killed_enemies_token =
|
local killed_enemies_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function()
|
function()
|
||||||
local actual = Public.get_killed_enemies_count('biter', 'spitter')
|
local actual = Public.get_killed_enemies_count('biter', 'spitter')
|
||||||
local expected = this.objectives.killed_enemies
|
local expected = this.objectives.killed_enemies
|
||||||
@@ -439,7 +438,7 @@ local killed_enemies_token =
|
|||||||
)
|
)
|
||||||
|
|
||||||
local research_level_selection_token =
|
local research_level_selection_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function()
|
function()
|
||||||
local actual = this.objectives.research_level_selection.research_count
|
local actual = this.objectives.research_level_selection.research_count
|
||||||
local expected = this.objectives.research_level_selection.count
|
local expected = this.objectives.research_level_selection.count
|
||||||
@@ -451,7 +450,7 @@ local research_level_selection_token =
|
|||||||
)
|
)
|
||||||
|
|
||||||
local locomotive_market_coins_spent_token =
|
local locomotive_market_coins_spent_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function()
|
function()
|
||||||
local coins = this.objectives.locomotive_market_coins_spent
|
local coins = this.objectives.locomotive_market_coins_spent
|
||||||
local actual = coins.spent
|
local actual = coins.spent
|
||||||
@@ -464,7 +463,7 @@ local locomotive_market_coins_spent_token =
|
|||||||
)
|
)
|
||||||
|
|
||||||
local trees_farmed_token =
|
local trees_farmed_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function()
|
function()
|
||||||
local actual = get_entity_mined_count('tree')
|
local actual = get_entity_mined_count('tree')
|
||||||
local expected = this.objectives.trees_farmed
|
local expected = this.objectives.trees_farmed
|
||||||
@@ -476,7 +475,7 @@ local trees_farmed_token =
|
|||||||
)
|
)
|
||||||
|
|
||||||
local rocks_farmed_token =
|
local rocks_farmed_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function()
|
function()
|
||||||
local actual = get_entity_mined_count('rock')
|
local actual = get_entity_mined_count('rock')
|
||||||
local expected = this.objectives.rocks_farmed
|
local expected = this.objectives.rocks_farmed
|
||||||
@@ -488,7 +487,7 @@ local rocks_farmed_token =
|
|||||||
)
|
)
|
||||||
|
|
||||||
local rockets_launched_token =
|
local rockets_launched_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function()
|
function()
|
||||||
local actual = game.forces.player.rockets_launched
|
local actual = game.forces.player.rockets_launched
|
||||||
local expected = this.objectives.rockets_launched
|
local expected = this.objectives.rockets_launched
|
||||||
@@ -809,7 +808,7 @@ local function apply_startup_settings(settings)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local apply_settings_token =
|
local apply_settings_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(data)
|
function(data)
|
||||||
local server_name_matches = Server.check_server_name('Mtn Fortress')
|
local server_name_matches = Server.check_server_name('Mtn Fortress')
|
||||||
local settings = data and data.value or nil
|
local settings = data and data.value or nil
|
||||||
@@ -912,7 +911,7 @@ end
|
|||||||
|
|
||||||
---@diagnostic disable-next-line: unused-local
|
---@diagnostic disable-next-line: unused-local
|
||||||
local apply_settings_dev_token =
|
local apply_settings_dev_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(data)
|
function(data)
|
||||||
local settings = data and data.value or nil
|
local settings = data and data.value or nil
|
||||||
local current_time = 1700509719
|
local current_time = 1700509719
|
||||||
@@ -1255,7 +1254,7 @@ Public.on_market_item_purchased = on_market_item_purchased
|
|||||||
if _DEBUG then
|
if _DEBUG then
|
||||||
Event.on_init(
|
Event.on_init(
|
||||||
function()
|
function()
|
||||||
local cbl = Token.get(apply_settings_dev_token)
|
local cbl = Task.get(apply_settings_dev_token)
|
||||||
local data = {
|
local data = {
|
||||||
rounds_survived = 20,
|
rounds_survived = 20,
|
||||||
season = 1,
|
season = 1,
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
local Public = require 'maps.mountain_fortress_v3.stateful.table'
|
local Public = require 'maps.mountain_fortress_v3.stateful.table'
|
||||||
local map_name = 'boss_room'
|
local map_name = 'boss_room'
|
||||||
|
local Task = require 'utils.task_token'
|
||||||
local random = math.random
|
local random = math.random
|
||||||
local ceil = math.ceil
|
local ceil = math.ceil
|
||||||
local floor = math.floor
|
local floor = math.floor
|
||||||
local Token = require 'utils.token'
|
|
||||||
|
|
||||||
local assign_locomotive_token =
|
local assign_locomotive_token =
|
||||||
Token.register(
|
Task.register(
|
||||||
function(event)
|
function(event)
|
||||||
local entity = event.entity
|
local entity = event.entity
|
||||||
if not entity or not entity.valid then
|
if not entity or not entity.valid then
|
||||||
|
|||||||
@@ -40,8 +40,6 @@ local nuclear_tiles = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local wagon_raffle = {
|
local wagon_raffle = {
|
||||||
'cargo-wagon',
|
|
||||||
'cargo-wagon',
|
|
||||||
'cargo-wagon',
|
'cargo-wagon',
|
||||||
'locomotive',
|
'locomotive',
|
||||||
'fluid-wagon'
|
'fluid-wagon'
|
||||||
|
|||||||
@@ -3,13 +3,15 @@
|
|||||||
|
|
||||||
local Global = require 'utils.global'
|
local Global = require 'utils.global'
|
||||||
local SpamProtection = require 'utils.spam_protection'
|
local SpamProtection = require 'utils.spam_protection'
|
||||||
|
local Color = require 'utils.color_presets'
|
||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local BottomFrame = require 'utils.gui.bottom_frame'
|
local BottomFrame = require 'utils.gui.bottom_frame'
|
||||||
local Gui = require 'utils.gui'
|
local Gui = require 'utils.gui'
|
||||||
local floor = math.floor
|
local Task = require 'utils.task_token'
|
||||||
local print_color = {r = 120, g = 255, b = 0}
|
|
||||||
|
|
||||||
local auto_stash_button_name = Gui.uid_name()
|
local auto_stash_button_name = Gui.uid_name()
|
||||||
|
local floor = math.floor
|
||||||
|
local module_name = '[color=blue][Autostash][/color] '
|
||||||
|
|
||||||
local this = {
|
local this = {
|
||||||
floating_text_y_offsets = {},
|
floating_text_y_offsets = {},
|
||||||
@@ -36,6 +38,54 @@ local bps_blacklist = {
|
|||||||
['blueprint'] = true
|
['blueprint'] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local on_init_token =
|
||||||
|
Task.register(
|
||||||
|
function()
|
||||||
|
local tooltip
|
||||||
|
if this.insert_into_furnace and this.insert_into_wagon then
|
||||||
|
tooltip =
|
||||||
|
'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.\nCTRL+RMB: Fill nearby furnaces.\nSHIFT+LMB: Everything onto filtered slots to wagon.\nSHIFT+RMB: Only ores to wagon'
|
||||||
|
elseif this.insert_into_furnace then
|
||||||
|
tooltip = 'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.\nCTRL+RMB: Fill nearby furnaces.'
|
||||||
|
elseif this.insert_into_wagon then
|
||||||
|
tooltip =
|
||||||
|
'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.\nSHIFT+LMB: Everything onto filtered slots to wagon.\nSHIFT+RMB: Only ores to wagon'
|
||||||
|
else
|
||||||
|
tooltip = 'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.'
|
||||||
|
end
|
||||||
|
|
||||||
|
this.tooltip = tooltip
|
||||||
|
if this.bottom_button then
|
||||||
|
local data = BottomFrame.get('bottom_quickbar_button_data')
|
||||||
|
data.sprite = 'item/wooden-chest'
|
||||||
|
data.tooltip = tooltip
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
local delay_tooltip_token =
|
||||||
|
Task.register(
|
||||||
|
function(event)
|
||||||
|
local player_index = event.player_index
|
||||||
|
local player = game.get_player(player_index)
|
||||||
|
if not player or not player.valid then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if Gui.get_mod_gui_top_frame() then
|
||||||
|
local frame = Gui.get_button_flow(player)[auto_stash_button_name]
|
||||||
|
if frame and frame.valid then
|
||||||
|
frame.tooltip = this.tooltip
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local frame = player.gui.top[auto_stash_button_name]
|
||||||
|
if frame and frame.valid then
|
||||||
|
frame.tooltip = this.tooltip
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
local function create_floaty_text(surface, position, name, count)
|
local function create_floaty_text(surface, position, name, count)
|
||||||
if this.floating_text_y_offsets[position.x .. '_' .. position.y] then
|
if this.floating_text_y_offsets[position.x .. '_' .. position.y] then
|
||||||
this.floating_text_y_offsets[position.x .. '_' .. position.y] = this.floating_text_y_offsets[position.x .. '_' .. position.y] - 0.5
|
this.floating_text_y_offsets[position.x .. '_' .. position.y] = this.floating_text_y_offsets[position.x .. '_' .. position.y] - 0.5
|
||||||
@@ -454,16 +504,16 @@ local function auto_stash(player, event)
|
|||||||
local ctrl = event.control
|
local ctrl = event.control
|
||||||
local shift = event.shift
|
local shift = event.shift
|
||||||
if not player.character then
|
if not player.character then
|
||||||
player.print('It seems that you are not in the realm of the living.', print_color)
|
player.print(module_name 'It seems that you are not in the realm of the living.', Color.warning)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if not player.character.valid then
|
if not player.character.valid then
|
||||||
player.print('It seems that you are not in the realm of the living.', print_color)
|
player.print(module_name 'It seems that you are not in the realm of the living.', Color.warning)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local inventory = player.get_main_inventory()
|
local inventory = player.get_main_inventory()
|
||||||
if inventory.is_empty() then
|
if inventory.is_empty() then
|
||||||
player.print('Inventory is empty.', print_color)
|
player.print(module_name 'Inventory is empty.', Color.warning)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -484,7 +534,7 @@ local function auto_stash(player, event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not chests.chest or not chests.chest[1] then
|
if not chests.chest or not chests.chest[1] then
|
||||||
player.print('No valid nearby containers found.', print_color)
|
player.print(module_name .. 'No valid nearby containers found.', Color.warning)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -565,71 +615,57 @@ local function auto_stash(player, event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function create_gui_button(player)
|
local function create_gui_button(player, bottom_frame_data)
|
||||||
local tooltip
|
local tooltip = this.tooltip
|
||||||
if this.insert_into_furnace and this.insert_into_wagon then
|
local button
|
||||||
tooltip =
|
if Gui.get_mod_gui_top_frame() then
|
||||||
'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.\nCTRL+RMB: Fill nearby furnaces.\nSHIFT+LMB: Everything onto filtered slots to wagon.\nSHIFT+RMB: Only ores to wagon'
|
button =
|
||||||
elseif this.insert_into_furnace then
|
Gui.add_mod_button(
|
||||||
tooltip = 'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.\nCTRL+RMB: Fill nearby furnaces.'
|
player,
|
||||||
elseif this.insert_into_wagon then
|
{
|
||||||
tooltip = 'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.\nSHIFT+LMB: Everything onto filtered slots to wagon.\nSHIFT+RMB: Only ores to wagon'
|
type = 'sprite-button',
|
||||||
|
name = auto_stash_button_name,
|
||||||
|
sprite = 'item/wooden-chest',
|
||||||
|
tooltip = tooltip,
|
||||||
|
style = Gui.button_style
|
||||||
|
}
|
||||||
|
)
|
||||||
else
|
else
|
||||||
tooltip = 'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.'
|
button =
|
||||||
|
player.gui.top[auto_stash_button_name] or
|
||||||
|
player.gui.top.add(
|
||||||
|
{
|
||||||
|
type = 'sprite-button',
|
||||||
|
sprite = 'item/wooden-chest',
|
||||||
|
name = auto_stash_button_name,
|
||||||
|
tooltip = tooltip,
|
||||||
|
style = Gui.button_style
|
||||||
|
}
|
||||||
|
)
|
||||||
|
button.style.font_color = {r = 0.11, g = 0.8, b = 0.44}
|
||||||
|
button.style.font = 'heading-1'
|
||||||
|
button.style.minimal_height = 40
|
||||||
|
button.style.maximal_width = 40
|
||||||
|
button.style.minimal_width = 38
|
||||||
|
button.style.maximal_height = 38
|
||||||
|
button.style.padding = 1
|
||||||
|
button.style.margin = 0
|
||||||
end
|
end
|
||||||
if this.bottom_button then
|
|
||||||
local data = BottomFrame.get('bottom_quickbar_button')
|
|
||||||
-- save it for later use
|
|
||||||
data.tooltip = tooltip
|
|
||||||
data.sprite = 'item/wooden-chest'
|
|
||||||
|
|
||||||
if data and data[player.index] then
|
bottom_frame_data = bottom_frame_data or BottomFrame.get_player_data(player)
|
||||||
local f = data[player.index]
|
if not (this.bottom_button and bottom_frame_data ~= nil and not bottom_frame_data.top) then
|
||||||
if f and f.frame and f.frame.valid then
|
if button and button.valid then
|
||||||
f.frame.sprite = 'item/wooden-chest'
|
button.visible = true
|
||||||
f.frame.tooltip = tooltip
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if Gui.get_mod_gui_top_frame() then
|
if button and button.valid then
|
||||||
Gui.add_mod_button(
|
button.visible = false
|
||||||
player,
|
|
||||||
{
|
|
||||||
type = 'sprite-button',
|
|
||||||
name = auto_stash_button_name,
|
|
||||||
sprite = 'item/wooden-chest',
|
|
||||||
tooltip = tooltip,
|
|
||||||
style = Gui.button_style
|
|
||||||
}
|
|
||||||
)
|
|
||||||
else
|
|
||||||
local tb = player.gui.top[auto_stash_button_name]
|
|
||||||
if tb and tb.valid then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local b =
|
|
||||||
player.gui.top.add(
|
|
||||||
{
|
|
||||||
type = 'sprite-button',
|
|
||||||
sprite = 'item/wooden-chest',
|
|
||||||
name = auto_stash_button_name,
|
|
||||||
tooltip = tooltip,
|
|
||||||
style = Gui.button_style
|
|
||||||
}
|
|
||||||
)
|
|
||||||
b.style.font_color = {r = 0.11, g = 0.8, b = 0.44}
|
|
||||||
b.style.font = 'heading-1'
|
|
||||||
b.style.minimal_height = 40
|
|
||||||
b.style.maximal_width = 40
|
|
||||||
b.style.minimal_width = 38
|
|
||||||
b.style.maximal_height = 38
|
|
||||||
b.style.padding = 1
|
|
||||||
b.style.margin = 0
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function do_whitelist()
|
local function do_whitelist()
|
||||||
|
Task.delay(on_init_token, {})
|
||||||
local resources = game.entity_prototypes
|
local resources = game.entity_prototypes
|
||||||
local items = game.item_prototypes
|
local items = game.item_prototypes
|
||||||
this.whitelist = {}
|
this.whitelist = {}
|
||||||
@@ -654,7 +690,9 @@ local function do_whitelist()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function on_player_joined_game(event)
|
local function on_player_joined_game(event)
|
||||||
create_gui_button(game.players[event.player_index])
|
local player = game.get_player(event.player_index)
|
||||||
|
create_gui_button(player)
|
||||||
|
Task.delay(delay_tooltip_token, {player_index = player.index})
|
||||||
end
|
end
|
||||||
|
|
||||||
Gui.on_click(
|
Gui.on_click(
|
||||||
@@ -714,4 +752,21 @@ Event.add(
|
|||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Event.add(
|
||||||
|
BottomFrame.events.bottom_quickbar_location_changed,
|
||||||
|
function(event)
|
||||||
|
local player_index = event.player_index
|
||||||
|
if not player_index then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local player = game.get_player(player_index)
|
||||||
|
if not player or not player.valid then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local bottom_frame_data = event.data
|
||||||
|
create_gui_button(player, bottom_frame_data)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
return Public
|
return Public
|
||||||
|
|||||||
@@ -565,7 +565,7 @@ function Public.get_parent_frame(player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- This adds the given gui to the top gui.
|
--- This adds the given gui to the top gui.
|
||||||
---@param player userdata
|
---@param player LuaPlayer
|
||||||
---@param frame userdata|table
|
---@param frame userdata|table
|
||||||
function Public.add_mod_button(player, frame)
|
function Public.add_mod_button(player, frame)
|
||||||
if Public.get_button_flow(player)[frame.name] and Public.get_button_flow(player)[frame.name].valid then
|
if Public.get_button_flow(player)[frame.name] and Public.get_button_flow(player)[frame.name].valid then
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ local SpamProtection = require 'utils.spam_protection'
|
|||||||
local this = {
|
local this = {
|
||||||
players = {},
|
players = {},
|
||||||
activate_custom_buttons = false,
|
activate_custom_buttons = false,
|
||||||
bottom_quickbar_button = {}
|
bottom_quickbar_button = {},
|
||||||
|
bottom_quickbar_button_data = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
Global.register(
|
Global.register(
|
||||||
@@ -21,7 +22,8 @@ local Public = {}
|
|||||||
|
|
||||||
Public.events = {
|
Public.events = {
|
||||||
bottom_quickbar_button_name = Event.generate_event_name('bottom_quickbar_button_name'),
|
bottom_quickbar_button_name = Event.generate_event_name('bottom_quickbar_button_name'),
|
||||||
bottom_quickbar_respawn_raise = Event.generate_event_name('bottom_quickbar_respawn_raise')
|
bottom_quickbar_respawn_raise = Event.generate_event_name('bottom_quickbar_respawn_raise'),
|
||||||
|
bottom_quickbar_location_changed = Event.generate_event_name('bottom_quickbar_location_changed')
|
||||||
}
|
}
|
||||||
|
|
||||||
local main_frame_name = Gui.uid_name()
|
local main_frame_name = Gui.uid_name()
|
||||||
@@ -36,7 +38,9 @@ function Public.get_player_data(player, remove_user_data)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
if not this.players[player.index] then
|
if not this.players[player.index] then
|
||||||
this.players[player.index] = {}
|
this.players[player.index] = {
|
||||||
|
state = 'bottom_right'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
return this.players[player.index]
|
return this.players[player.index]
|
||||||
end
|
end
|
||||||
@@ -80,6 +84,54 @@ end
|
|||||||
|
|
||||||
----! Gui Functions ! ----
|
----! Gui Functions ! ----
|
||||||
|
|
||||||
|
local function create_gui_button(player, frame_data)
|
||||||
|
local button
|
||||||
|
if Gui.get_mod_gui_top_frame() then
|
||||||
|
button =
|
||||||
|
Gui.add_mod_button(
|
||||||
|
player,
|
||||||
|
{
|
||||||
|
type = 'sprite-button',
|
||||||
|
name = clear_corpse_button_name,
|
||||||
|
sprite = 'entity/behemoth-biter',
|
||||||
|
tooltip = {'commands.clear_corpse'},
|
||||||
|
style = Gui.button_style
|
||||||
|
}
|
||||||
|
)
|
||||||
|
else
|
||||||
|
button =
|
||||||
|
player.gui.top[clear_corpse_button_name] or
|
||||||
|
player.gui.top.add(
|
||||||
|
{
|
||||||
|
type = 'sprite-button',
|
||||||
|
sprite = 'entity/behemoth-biter',
|
||||||
|
name = clear_corpse_button_name,
|
||||||
|
tooltip = {'commands.clear_corpse'},
|
||||||
|
style = Gui.button_style
|
||||||
|
}
|
||||||
|
)
|
||||||
|
button.style.font_color = {r = 0.11, g = 0.8, b = 0.44}
|
||||||
|
button.style.font = 'heading-1'
|
||||||
|
button.style.minimal_height = 40
|
||||||
|
button.style.maximal_width = 40
|
||||||
|
button.style.minimal_width = 38
|
||||||
|
button.style.maximal_height = 38
|
||||||
|
button.style.padding = 1
|
||||||
|
button.style.margin = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
frame_data = frame_data or Public.get_player_data(player)
|
||||||
|
if not (this.activate_custom_buttons and frame_data ~= nil and not frame_data.top) then
|
||||||
|
if button and button.valid then
|
||||||
|
button.visible = true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if button and button.valid then
|
||||||
|
button.visible = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function destroy_frame(player)
|
local function destroy_frame(player)
|
||||||
local gui = player.gui
|
local gui = player.gui
|
||||||
local frame = gui.screen[main_frame_name]
|
local frame = gui.screen[main_frame_name]
|
||||||
@@ -88,7 +140,7 @@ local function destroy_frame(player)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function create_frame(player, alignment, location, portable)
|
local function create_frame(player, alignment, location, data)
|
||||||
local gui = player.gui
|
local gui = player.gui
|
||||||
local frame = gui.screen[main_frame_name]
|
local frame = gui.screen[main_frame_name]
|
||||||
if frame and frame.valid then
|
if frame and frame.valid then
|
||||||
@@ -104,8 +156,6 @@ local function create_frame(player, alignment, location, portable)
|
|||||||
direction = alignment
|
direction = alignment
|
||||||
}
|
}
|
||||||
|
|
||||||
local data = Public.get_player_data(player)
|
|
||||||
|
|
||||||
if data.visible ~= nil then
|
if data.visible ~= nil then
|
||||||
if data.visible then
|
if data.visible then
|
||||||
frame.visible = true
|
frame.visible = true
|
||||||
@@ -117,12 +167,14 @@ local function create_frame(player, alignment, location, portable)
|
|||||||
frame.style.padding = 3
|
frame.style.padding = 3
|
||||||
frame.style.top_padding = 4
|
frame.style.top_padding = 4
|
||||||
|
|
||||||
|
global.a = frame
|
||||||
|
|
||||||
if alignment == 'vertical' then
|
if alignment == 'vertical' then
|
||||||
frame.style.minimal_height = 96
|
frame.style.minimal_height = 96
|
||||||
end
|
end
|
||||||
|
|
||||||
frame.location = location
|
frame.location = location
|
||||||
if portable then
|
if data.portable then
|
||||||
frame.caption = '•'
|
frame.caption = '•'
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -148,13 +200,15 @@ local function create_frame(player, alignment, location, portable)
|
|||||||
style = 'quick_bar_page_button'
|
style = 'quick_bar_page_button'
|
||||||
}
|
}
|
||||||
|
|
||||||
this.bottom_quickbar_button[player.index] = {name = bottom_quickbar_button_name, frame = bottom_quickbar_button}
|
if this.bottom_quickbar_button_data and this.bottom_quickbar_button_data.sprite and this.bottom_quickbar_button_data.tooltip and not data.top then
|
||||||
|
bottom_quickbar_button.sprite = this.bottom_quickbar_button_data.sprite
|
||||||
if this.bottom_quickbar_button.sprite and this.bottom_quickbar_button.tooltip then
|
bottom_quickbar_button.tooltip = this.bottom_quickbar_button_data.tooltip
|
||||||
bottom_quickbar_button.sprite = this.bottom_quickbar_button.sprite
|
else
|
||||||
bottom_quickbar_button.tooltip = this.bottom_quickbar_button.tooltip
|
frame.destroy()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
this.bottom_quickbar_button[player.index] = {name = bottom_quickbar_button_name, frame = bottom_quickbar_button}
|
||||||
|
|
||||||
return frame
|
return frame
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -203,9 +257,28 @@ local function set_location(player, state)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Event.raise(Public.events.bottom_quickbar_location_changed, {player_index = player.index, data = data})
|
||||||
|
|
||||||
data.state = state
|
data.state = state
|
||||||
|
|
||||||
create_frame(player, alignment, location, data.portable)
|
create_frame(player, alignment, location, data)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Sets then frame location of the given player
|
||||||
|
---@param player LuaPlayer?
|
||||||
|
---@param value boolean
|
||||||
|
local function set_top(player, value)
|
||||||
|
local data = Public.get_player_data(player)
|
||||||
|
data.top = value or false
|
||||||
|
Public.set_location(player, 'bottom_right')
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns the current frame location of the given player
|
||||||
|
---@param player LuaPlayer
|
||||||
|
---@return table|nil
|
||||||
|
local function get_location(player)
|
||||||
|
local data = Public.get_player_data(player)
|
||||||
|
return data and data.state or nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Activates the custom buttons
|
--- Activates the custom buttons
|
||||||
@@ -219,6 +292,22 @@ function Public.is_custom_buttons_enabled()
|
|||||||
return this.activate_custom_buttons
|
return this.activate_custom_buttons
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Toggles the player frame
|
||||||
|
function Public.toggle_player_frame(player, state)
|
||||||
|
local gui = player.gui
|
||||||
|
local frame = gui.screen[main_frame_name]
|
||||||
|
if frame and frame.valid then
|
||||||
|
local data = Public.get_player_data(player)
|
||||||
|
if state then
|
||||||
|
data.visible = true
|
||||||
|
frame.visible = true
|
||||||
|
else
|
||||||
|
data.visible = false
|
||||||
|
frame.visible = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Gui.on_click(
|
Gui.on_click(
|
||||||
clear_corpse_button_name,
|
clear_corpse_button_name,
|
||||||
function(event)
|
function(event)
|
||||||
@@ -237,7 +326,14 @@ Gui.on_click(
|
|||||||
if is_spamming then
|
if is_spamming then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
Event.raise(Public.events.bottom_quickbar_button_name, {player = event.player, event = event})
|
|
||||||
|
local data = Public.get_player_data(event.player)
|
||||||
|
if data and data.top then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
event.data = data
|
||||||
|
Event.raise(Public.events.bottom_quickbar_button_name, {event = event})
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -248,6 +344,7 @@ Event.add(
|
|||||||
local player = game.get_player(event.player_index)
|
local player = game.get_player(event.player_index)
|
||||||
local data = Public.get_player_data(player)
|
local data = Public.get_player_data(player)
|
||||||
set_location(player, data.state)
|
set_location(player, data.state)
|
||||||
|
create_gui_button(player, data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
@@ -310,24 +407,6 @@ Event.add(
|
|||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
function Public.toggle_player_frame(player, state)
|
|
||||||
local gui = player.gui
|
|
||||||
local frame = gui.screen[main_frame_name]
|
|
||||||
if frame and frame.valid then
|
|
||||||
local data = Public.get_player_data(player)
|
|
||||||
if state then
|
|
||||||
data.visible = true
|
|
||||||
frame.visible = true
|
|
||||||
else
|
|
||||||
data.visible = false
|
|
||||||
frame.visible = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Public.main_frame_name = main_frame_name
|
|
||||||
Public.set_location = set_location
|
|
||||||
Gui.screen_to_bypass(main_frame_name)
|
|
||||||
|
|
||||||
Event.add(
|
Event.add(
|
||||||
Public.events.bottom_quickbar_respawn_raise,
|
Public.events.bottom_quickbar_respawn_raise,
|
||||||
function(event)
|
function(event)
|
||||||
@@ -343,4 +422,25 @@ Event.add(
|
|||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Event.add(
|
||||||
|
Public.events.bottom_quickbar_location_changed,
|
||||||
|
function(event)
|
||||||
|
if not event or not event.player_index then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if this.activate_custom_buttons then
|
||||||
|
local player = game.get_player(event.player_index)
|
||||||
|
local data = Public.get_player_data(player)
|
||||||
|
create_gui_button(player, data)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
Public.main_frame_name = main_frame_name
|
||||||
|
Public.set_location = set_location
|
||||||
|
Public.get_location = get_location
|
||||||
|
Public.set_top = set_top
|
||||||
|
Gui.screen_to_bypass(main_frame_name)
|
||||||
|
|
||||||
return Public
|
return Public
|
||||||
|
|||||||
@@ -138,6 +138,15 @@ local functions = {
|
|||||||
Module[event.player_index].disabled = true
|
Module[event.player_index].disabled = true
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
['top_location'] = function(event)
|
||||||
|
local player = game.get_player(event.player_index)
|
||||||
|
local data = BottomFrame.get_player_data(player)
|
||||||
|
if data and data.state and not data.top then
|
||||||
|
BottomFrame.set_top(player, true)
|
||||||
|
else
|
||||||
|
BottomFrame.set_top(player, false)
|
||||||
|
end
|
||||||
|
end,
|
||||||
['bottom_location'] = function(event)
|
['bottom_location'] = function(event)
|
||||||
local player = game.get_player(event.player_index)
|
local player = game.get_player(event.player_index)
|
||||||
if event.element.switch_state == 'left' then
|
if event.element.switch_state == 'left' then
|
||||||
@@ -552,6 +561,17 @@ local function build_config_gui(data)
|
|||||||
label.style.vertical_align = 'bottom'
|
label.style.vertical_align = 'bottom'
|
||||||
label.style.font_color = Color.white_smoke
|
label.style.font_color = Color.white_smoke
|
||||||
|
|
||||||
|
local autostash = is_loaded('modules.autostash')
|
||||||
|
if autostash then
|
||||||
|
scroll_pane.add({type = 'line'})
|
||||||
|
|
||||||
|
switch_state = 'right'
|
||||||
|
local bottom_frame = BottomFrame.get_player_data(player)
|
||||||
|
if bottom_frame and bottom_frame.top then
|
||||||
|
switch_state = 'left'
|
||||||
|
end
|
||||||
|
add_switch(scroll_pane, switch_state, 'top_location', 'Position - top', 'Toggle to select if you want the autostash button at the top or the bottom.')
|
||||||
|
end
|
||||||
scroll_pane.add({type = 'line'})
|
scroll_pane.add({type = 'line'})
|
||||||
|
|
||||||
switch_state = 'right'
|
switch_state = 'right'
|
||||||
|
|||||||
21
utils/task_token.lua
Normal file
21
utils/task_token.lua
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
-- This file simply exists to reduce the amount of require that is done
|
||||||
|
|
||||||
|
local Token = require 'utils.token'
|
||||||
|
local Task = require 'utils.task'
|
||||||
|
|
||||||
|
local Public = {}
|
||||||
|
|
||||||
|
Public.register = Token.register
|
||||||
|
Public.get = Token.get
|
||||||
|
|
||||||
|
Public.set_timeout_in_ticks = Task.set_timeout_in_ticks
|
||||||
|
Public.set_timeout_in_ticks_text = Task.set_timeout_in_ticks_text
|
||||||
|
Public.set_timeout = Task.set_timeout
|
||||||
|
Public.queue_task = Task.queue_task
|
||||||
|
Public.get_queue_speed = Task.get_queue_speed
|
||||||
|
Public.set_queue_speed = Task.set_queue_speed
|
||||||
|
|
||||||
|
Public.delay = Task.queue_task
|
||||||
|
Public.priority_delay = Task.set_timeout_in_ticks
|
||||||
|
|
||||||
|
return Public
|
||||||
Reference in New Issue
Block a user