Merge remote-tracking branch 'gh/develop' into master
@ -61,8 +61,7 @@ globals = {
|
||||
'is_loaded',
|
||||
'is_game_modded',
|
||||
'is_mod_loaded',
|
||||
'require',
|
||||
'comfy_panel_tabs'
|
||||
'require'
|
||||
}
|
||||
max_line_length = LINE_LENGTH
|
||||
|
||||
@ -2010,7 +2009,7 @@ stds.factorio_defines = {
|
||||
}
|
||||
}
|
||||
}
|
||||
--))
|
||||
--))
|
||||
|
||||
--[[ Options
|
||||
"ignore", "std", "globals", "unused_args", "self", "compat", "global", "unused", "redefined",
|
||||
|
@ -1,285 +0,0 @@
|
||||
--[[
|
||||
Comfy Panel
|
||||
|
||||
To add a tab, insert into the "main_gui_tabs" table.
|
||||
|
||||
Example: main_gui_tabs["mapscores"] = {gui = draw_map_scores, admin = false}
|
||||
if admin = true, then tab is visible only for admins (usable for map-specific settings)
|
||||
|
||||
draw_map_scores would be a function with the player and the frame as arguments
|
||||
|
||||
]]
|
||||
local Event = require 'utils.event'
|
||||
local Server = require 'utils.server'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
local Token = require 'utils.token'
|
||||
local Global = require 'utils.global'
|
||||
local Gui = require 'utils.gui'
|
||||
|
||||
local main_gui_tabs = {}
|
||||
local Public = {}
|
||||
local screen_elements = {}
|
||||
local this = {
|
||||
settings = {
|
||||
mod_gui_top_frame = false
|
||||
}
|
||||
}
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
function(tbl)
|
||||
this = tbl
|
||||
end
|
||||
)
|
||||
|
||||
--- This adds the given gui to the top gui.
|
||||
---@param player <userdata>
|
||||
---@param frame <object>
|
||||
---@param name <string>
|
||||
function Public.add_mod_button(player, frame)
|
||||
if Gui.get_button_flow(player)[frame.name] and Gui.get_button_flow(player)[frame.name].valid then
|
||||
return
|
||||
end
|
||||
|
||||
Gui.get_button_flow(player).add(frame)
|
||||
end
|
||||
|
||||
---@param state <bool>
|
||||
--- If we should use the new mod gui or not
|
||||
function Public.set_mod_gui_top_frame(state)
|
||||
this.settings.mod_gui_top_frame = state or false
|
||||
end
|
||||
|
||||
--- Get mod_gui_top_frame
|
||||
function Public.get_mod_gui_top_frame()
|
||||
return this.settings.mod_gui_top_frame
|
||||
end
|
||||
|
||||
--- This adds the given gui to the main gui.
|
||||
---@param tbl
|
||||
function Public.add_tab_to_gui(tbl)
|
||||
if not tbl then
|
||||
return
|
||||
end
|
||||
if not tbl.name then
|
||||
return
|
||||
end
|
||||
if not tbl.id then
|
||||
return
|
||||
end
|
||||
local admin = tbl.admin or false
|
||||
local only_server_sided = tbl.only_server_sided or false
|
||||
|
||||
if not main_gui_tabs[tbl.name] then
|
||||
main_gui_tabs[tbl.name] = {id = tbl.id, admin = admin, only_server_sided = only_server_sided}
|
||||
else
|
||||
error('Given name: ' .. tbl.name .. ' already exists in table.')
|
||||
end
|
||||
end
|
||||
|
||||
function Public.screen_to_bypass(elem)
|
||||
screen_elements[elem] = true
|
||||
return screen_elements
|
||||
end
|
||||
|
||||
--- Fetches the main gui tabs. You are forbidden to write as this is local.
|
||||
---@param key
|
||||
function Public.get(key)
|
||||
if key then
|
||||
return main_gui_tabs[key]
|
||||
else
|
||||
return main_gui_tabs
|
||||
end
|
||||
end
|
||||
|
||||
function Public.comfy_panel_clear_gui(player)
|
||||
for _, child in pairs(player.gui.left.children) do
|
||||
child.destroy()
|
||||
end
|
||||
for _, child in pairs(player.gui.screen.children) do
|
||||
if not screen_elements[child.name] then
|
||||
child.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.comfy_panel_get_active_frame(player)
|
||||
local main_frame = player.gui.left.comfy_panel
|
||||
if not main_frame then
|
||||
return false
|
||||
end
|
||||
|
||||
local panel = main_frame.tabbed_pane
|
||||
if not panel then
|
||||
return
|
||||
end
|
||||
local index = panel.selected_tab_index
|
||||
if not index then
|
||||
return panel.tabs[1].content
|
||||
end
|
||||
return panel.tabs[index].content
|
||||
end
|
||||
|
||||
function Public.comfy_panel_refresh_active_tab(player)
|
||||
local frame = Public.comfy_panel_get_active_frame(player)
|
||||
if not frame then
|
||||
return
|
||||
end
|
||||
|
||||
local tab = main_gui_tabs[frame.name]
|
||||
if not tab then
|
||||
return
|
||||
end
|
||||
local id = tab.id
|
||||
if not id then
|
||||
return
|
||||
end
|
||||
local func = Token.get(id)
|
||||
|
||||
local data = {
|
||||
player = player,
|
||||
frame = frame
|
||||
}
|
||||
|
||||
return func(data)
|
||||
end
|
||||
|
||||
local function top_button(player)
|
||||
if this.settings.mod_gui_top_frame then
|
||||
Public.add_mod_button(player, {type = 'sprite-button', name = 'comfy_panel_top_button', sprite = 'item/raw-fish'}, 'comfy_panel_top_button')
|
||||
else
|
||||
if player.gui.top['comfy_panel_top_button'] then
|
||||
return
|
||||
end
|
||||
local button = player.gui.top.add({type = 'sprite-button', name = 'comfy_panel_top_button', sprite = 'item/raw-fish'})
|
||||
button.style.minimal_height = 38
|
||||
button.style.maximal_height = 38
|
||||
button.style.minimal_width = 40
|
||||
button.style.padding = -2
|
||||
end
|
||||
end
|
||||
|
||||
local function main_frame(player)
|
||||
local tabs = main_gui_tabs
|
||||
Public.comfy_panel_clear_gui(player)
|
||||
|
||||
local frame = player.gui.left.comfy_panel
|
||||
if not frame or not frame.valid then
|
||||
frame = player.gui.left.add({type = 'frame', name = 'comfy_panel'})
|
||||
end
|
||||
|
||||
frame.style.margin = 6
|
||||
|
||||
local tabbed_pane = frame.add({type = 'tabbed-pane', name = 'tabbed_pane'})
|
||||
|
||||
for name, func in pairs(tabs) do
|
||||
if func.only_server_sided then
|
||||
local secs = Server.get_current_time()
|
||||
if secs then
|
||||
local tab = tabbed_pane.add({type = 'tab', caption = name, name = 'tab_' .. name})
|
||||
local name_frame = tabbed_pane.add({type = 'frame', name = name, direction = 'vertical'})
|
||||
name_frame.style.minimal_height = 480
|
||||
name_frame.style.maximal_height = 480
|
||||
name_frame.style.minimal_width = 800
|
||||
name_frame.style.maximal_width = 800
|
||||
tabbed_pane.add_tab(tab, name_frame)
|
||||
end
|
||||
elseif func.admin == true then
|
||||
if player.admin then
|
||||
local tab = tabbed_pane.add({type = 'tab', caption = name, name = 'tab_' .. name})
|
||||
local name_frame = tabbed_pane.add({type = 'frame', name = name, direction = 'vertical'})
|
||||
name_frame.style.minimal_height = 480
|
||||
name_frame.style.maximal_height = 480
|
||||
name_frame.style.minimal_width = 800
|
||||
name_frame.style.maximal_width = 800
|
||||
tabbed_pane.add_tab(tab, name_frame)
|
||||
end
|
||||
else
|
||||
local tab = tabbed_pane.add({type = 'tab', caption = name, name = 'tab_' .. name})
|
||||
local name_frame = tabbed_pane.add({type = 'frame', name = name, direction = 'vertical'})
|
||||
name_frame.style.minimal_height = 480
|
||||
name_frame.style.maximal_height = 480
|
||||
name_frame.style.minimal_width = 800
|
||||
name_frame.style.maximal_width = 800
|
||||
tabbed_pane.add_tab(tab, name_frame)
|
||||
end
|
||||
end
|
||||
|
||||
local tab = tabbed_pane.add({type = 'tab', name = 'comfy_panel_close', caption = 'X'})
|
||||
tab.style.maximal_width = 32
|
||||
local t_frame = tabbed_pane.add({type = 'frame', direction = 'vertical'})
|
||||
tabbed_pane.add_tab(tab, t_frame)
|
||||
|
||||
for _, child in pairs(tabbed_pane.children) do
|
||||
child.style.padding = 8
|
||||
child.style.left_padding = 2
|
||||
child.style.right_padding = 2
|
||||
end
|
||||
|
||||
Public.comfy_panel_refresh_active_tab(player)
|
||||
end
|
||||
|
||||
function Public.comfy_panel_call_tab(player, name)
|
||||
main_frame(player)
|
||||
local tabbed_pane = player.gui.left.comfy_panel.tabbed_pane
|
||||
for key, v in pairs(tabbed_pane.tabs) do
|
||||
if v.tab.caption == name then
|
||||
tabbed_pane.selected_tab_index = key
|
||||
Public.comfy_panel_refresh_active_tab(player)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
top_button(player)
|
||||
end
|
||||
|
||||
local function on_gui_click(event)
|
||||
local element = event.element
|
||||
if not element or not element.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local player = game.get_player(event.player_index)
|
||||
|
||||
local name = element.name
|
||||
|
||||
if name == 'comfy_panel_top_button' then
|
||||
local is_spamming = SpamProtection.is_spamming(player, nil, 'Comfy Main GUI Click')
|
||||
if is_spamming then
|
||||
return
|
||||
end
|
||||
if player.gui.left.comfy_panel then
|
||||
player.gui.left.comfy_panel.destroy()
|
||||
return
|
||||
else
|
||||
main_frame(player)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if element.caption == 'X' and name == 'comfy_panel_close' then
|
||||
local is_spamming = SpamProtection.is_spamming(player, nil, 'Comfy Main Gui Close Button')
|
||||
if is_spamming then
|
||||
return
|
||||
end
|
||||
player.gui.left.comfy_panel.destroy()
|
||||
return
|
||||
end
|
||||
|
||||
if not element.caption then
|
||||
return
|
||||
end
|
||||
if element.type ~= 'tab' then
|
||||
return
|
||||
end
|
||||
|
||||
Public.comfy_panel_refresh_active_tab(player)
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
Event.add(defines.events.on_player_created, on_player_joined_game)
|
||||
Event.add(defines.events.on_gui_click, on_gui_click)
|
||||
|
||||
return Public
|
20
control.lua
@ -28,14 +28,14 @@ require 'modules.show_inventory'
|
||||
require 'modules.inserter_drops_pickup'
|
||||
require 'modules.autostash'
|
||||
|
||||
require 'comfy_panel.main'
|
||||
require 'comfy_panel.player_list'
|
||||
require 'comfy_panel.admin'
|
||||
require 'comfy_panel.group'
|
||||
require 'comfy_panel.poll'
|
||||
require 'comfy_panel.score'
|
||||
require 'comfy_panel.config'
|
||||
require 'comfy_panel.server_select'
|
||||
require 'utils.gui'
|
||||
require 'utils.gui.player_list'
|
||||
require 'utils.gui.admin'
|
||||
require 'utils.gui.group'
|
||||
require 'utils.gui.poll'
|
||||
require 'utils.gui.score'
|
||||
require 'utils.gui.config'
|
||||
require 'utils.gui.server_select'
|
||||
require 'utils.freeplay'
|
||||
|
||||
---------------- !ENABLE MODULES HERE ----------------
|
||||
@ -250,6 +250,10 @@ require 'utils.freeplay'
|
||||
--require 'terrain_layouts.scrap_towny_ffa'
|
||||
---------------------------------------------------------------
|
||||
|
||||
--- this file exists only for the panel to sync and start from within the panel
|
||||
-- it does nothing if it's not synced from within the panel
|
||||
require 'map_loader'
|
||||
|
||||
if _DUMP_ENV then
|
||||
require 'utils.dump_env'
|
||||
require 'utils.profiler'
|
||||
|
@ -6,7 +6,6 @@ blacklist - optional list of item names that can not be rolled. example: {["sub
|
||||
]]
|
||||
local Public = {}
|
||||
|
||||
local table_shuffle_table = table.shuffle_table
|
||||
local table_insert = table.insert
|
||||
local math_random = math.random
|
||||
local math_floor = math.floor
|
||||
@ -407,6 +406,15 @@ local tech_tier_list = {
|
||||
'rocket-silo'
|
||||
}
|
||||
|
||||
local function shuffle(tbl)
|
||||
local size = #tbl
|
||||
for i = size, 1, -1 do
|
||||
local rand = math_random(size)
|
||||
tbl[i], tbl[rand] = tbl[rand], tbl[i]
|
||||
end
|
||||
return tbl
|
||||
end
|
||||
|
||||
local item_names = {}
|
||||
for k, _ in pairs(item_worths) do
|
||||
table_insert(item_names, k)
|
||||
@ -431,7 +439,7 @@ local function get_raffle_keys()
|
||||
for i = 1, size_of_item_names, 1 do
|
||||
raffle_keys[i] = i
|
||||
end
|
||||
table_shuffle_table(raffle_keys)
|
||||
shuffle(raffle_keys)
|
||||
return raffle_keys
|
||||
end
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
[mountain_fortress_v3]
|
||||
map_info_main_caption=M O U N T A I N F O R T R E S S V3
|
||||
map_info_sub_caption= ~~ diggy diggy choo choo ~~
|
||||
map_info_text=[color=red]READ THIS!\nIf there are any code bugs or desyncs. Please report asap to @Gerkiz!\nIf there are any game breaking bugs then this map might be shutdown to hot-fix the issue.[/color]\n\nThe biters have caught the scent of fish in the cargo wagon.\nGuide the choo into the mountain and protect it as long as possible!\nThis however will not be an easy task,\nsince their strength and numbers increase over time.\n\nIn additon, the southern grounds collapse over time.\n\nDelve deep for greater treasures, but also face increased dangers.\nMining productivity research will overhaul your mining equipment, increasing the size of your backpack.\n\nAs you dig, you will encounter impassable dark chasms or rivers.\nArtillery will try to shoot you down! Dig fast, dig north!\n\nSome explosives may cause rocks to fall down the mountain, filling the void, creating new ways.\nAll they need is a container and a well aimed shot.\n\nEnter the cargo wagon to reveal the wagon surface!\n\nRandom buildings that generate resources can be found throughout the world.\n\nPlacing steel-chests near cargo-wagons enables you to quickly move content.\n\nStaying inside the locomotive aura prevents biters from spawning when mining entities.\n\nRPG GUI is disabled inside the locomotive.\nDisconnecting wagons is disabled.\nYou can't cancel crafting when standing inside the locomotive aura.\n\nDon't try to run north with your Spidertron if the train is not near you.\nYou have been warned.\n\nMining drills have great mining-bonus which also is increased after each research, use them when you can!\n\nThe mystical chest in the locomotive offers some rewards.\nOne must feed the chest to receive such rewards.\n\nGood luck on your journey!
|
||||
map_info_text=[color=red]READ THIS!\nIf there are any code bugs or desyncs. Please report asap to @Gerkiz!\nIf there are any game breaking bugs then this map might be shutdown to hot-fix the issue.[/color]\n\nThe biters have caught the scent of fish in the cargo wagon.\nGuide the choo into the mountain and protect it as long as possible!\nThis however will not be an easy task,\nsince their strength and numbers increase over time.\n\nIn additon, the southern grounds collapse over time.\n\nDelve deep for greater treasures, but also face increased dangers.\nMining productivity research will overhaul your mining equipment, increasing the size of your backpack.\n\nAs you dig, you will encounter impassable dark chasms or rivers.\nArtillery will try to shoot you down! Dig fast, dig north!\n\nSome explosives may cause rocks to fall down the mountain, filling the void, creating new ways.\nAll they need is a container and a well aimed shot.\n\nEnter the cargo wagon to reveal the wagon surface!\n\nRandom buildings that generate resources can be found throughout the world.\n\nPlacing steel-chests near cargo-wagons enables you to quickly move content.\n\nStaying inside the locomotive aura prevents biters from spawning when mining entities.\n\nRadars do not generate new areas.\n\nRPG GUI is disabled inside the locomotive.\n\nDisconnecting wagons is disabled.\nYou can't cancel crafting when standing inside the locomotive aura.\n\nDon't try to run north with your Spidertron if the train is not near you.\nYou have been warned.\n\nMining drills have great mining-bonus which also is increased after each research, use them when you can!\n\nThe mystical chest in the locomotive offers some rewards.\nOne must feed the chest to receive such rewards.\n\nGood luck on your journey!
|
||||
|
||||
[breached_wall]
|
||||
collapse_start=[color=blue]Mapkeeper:[/color]\nWarning, Collapse has begun!
|
||||
@ -51,7 +51,7 @@ map_off=OFF
|
||||
[locomotive]
|
||||
upgrades=Upgrades:
|
||||
items=Items:
|
||||
shoo=^-^ Please don't shoo at me ^-^
|
||||
shoo=[Desync Bro]
|
||||
not_trusted=You need to be trusted to purchase this.
|
||||
coins_left=Coins left: __1__
|
||||
market_name=Market
|
||||
|
@ -2,7 +2,7 @@
|
||||
no_valid_surface=No surface name given
|
||||
flame_boots_worn_out=Your flame boots have worn out.
|
||||
flame_mana_remaining=Mana remaining: __1__
|
||||
one_punch_text=ONE PUNCH
|
||||
aoe_punch_text=AOE PUNCH
|
||||
mana_casting_too_fast=There was a lot more to magic, as __1__ quickly found out, than waving their wand and saying a few funny words.
|
||||
low_level=You lack the level to cast this spell.
|
||||
not_inside_pos=You wave your wand but realize that it´s out of reach.
|
||||
@ -59,8 +59,8 @@ mana_max=This is your max mana. You can increase the regen by increasing your ma
|
||||
mining_name=MINING\nSPEED
|
||||
slot_name=SLOT\nBONUS
|
||||
melee_name=MELEE\nDAMAGE
|
||||
one_punch_chance=Life on-hit: __1__\nOne punch chance: __2__ % \n+__3__ [img=recipe.defender-capsule]
|
||||
one_punch_disabled=One Punch is disabled.
|
||||
aoe_punch_chance=Life on-hit: __1__\nAOE punch chance: __2__ % \n+__3__ [img=recipe.defender-capsule]
|
||||
aoe_punch_disabled=AOE punch is disabled.
|
||||
bonus_tooltip=Reach distance bonus: __1__\nBuild distance bonus: __2__\nItem drop distance bonus: __3__\nLoot pickup distance bonus: __4__\nItem pickup distance bonus: __5__\nResource reach distance bonus: __6__\nRepair speed: __7__
|
||||
reach_distance=REACH\nDISTANCE
|
||||
crafting_speed=CRAFTING\nSPEED
|
||||
@ -96,9 +96,9 @@ movement_text_label=Enable movement speed bonus?
|
||||
movement_text_tooltip=Don´t feeling like running like the flash?\nYou can toggle it here.
|
||||
stone_path_label=Enable stone-path when mining?
|
||||
stone_path_tooltip=Enabling this will automatically create stone-path when you mine.
|
||||
one_punch_label=Enable one-punch?
|
||||
one_punch_tooltip=Enabling this will have a chance of one-punching biters.\nOne-Punch only works if both ammo AND gun is unequipped.
|
||||
one_punch_globally=Enabled globally.\nOne-Punch only works if both ammo AND gun is unequipped.
|
||||
aoe_punch_label=Enable AOE punch?
|
||||
aoe_punch_tooltip=Enabling this will have a chance of creating a AOE punch against biters.\nAOE-Punch only works if both ammo AND gun is unequipped.
|
||||
aoe_punch_globally=Enabled globally.\nAOE-Punch only works if both ammo AND gun is unequipped.
|
||||
flameboots_label=Enable flame boots?
|
||||
flameboots_tooltip=When the bullets simply don´t bite.
|
||||
explosive_bullets_label=Enable explosive bullets?
|
||||
|
@ -2,7 +2,6 @@
|
||||
no_valid_surface=Название поверхности не указано
|
||||
flame_boots_worn_out=Ваши огненные сапоги износились.
|
||||
flame_mana_remaining=Маны осталось: __1__
|
||||
one_punch_text=ОДИН УДАР
|
||||
mana_casting_too_fast=Как быстро выяснил __1__, в магии было гораздо больше, чем просто взмахнуть палочкой и произнести несколько забавных слов.
|
||||
low_level=Вам не хватает уровня для произнесения этого заклинания.
|
||||
not_inside_pos=Вы машете палочкой, но понимаете, что это вне досягаемости.
|
||||
@ -59,8 +58,6 @@ mana_max=Это ваша максимальная мана. Вы можете у
|
||||
mining_name=СКОРОСТЬ\nДОБЫЧИ
|
||||
slot_name=БОНУС\nЯЧЕЕК
|
||||
melee_name=УРОН\nРУКАМИ
|
||||
one_punch_chance=Жизни за удар: __1__\nШанс "с одного удара": __2__%\n+__3__ [img=recipe.defender-capsule]
|
||||
one_punch_disabled="С одного удара" отключено.
|
||||
bonus_tooltip=Бонус дальности досягаемости: __1__\nБонус дистанции строительства: __2__\nБонус дальности выпадения предметов: __3__\nБонус дальности подбора добычи: __4__\nБонус дальности подбора предметов: __5__\nБонус дальности досягаемости ресурсов: __6__\nСкорость ремонта: __7__
|
||||
reach_distance=РАДИУС\nДЕЙСТВИЙ
|
||||
crafting_speed=СКОРОСТЬ\nКРАФТА
|
||||
@ -95,9 +92,6 @@ movement_text_label=Включить бонус скорости передви
|
||||
movement_text_tooltip=Хотите бегать, как Флэш?\nВы можете переключить это здесь.
|
||||
stone_path_label=Включить каменную тропу при добыче?
|
||||
stone_path_tooltip=Включение этого автоматически создаст тропу из камня при добыче.
|
||||
one_punch_label=Включить "С одного удара"?
|
||||
one_punch_tooltip=Включив это, вы будете иметь шанс убить кусаку с одного удара.\n"С одного удара" работает только в том случае, если не экипированы и боеприпасы, и оружие.
|
||||
one_punch_globally=Включить глобально.\n"С одного удара" работает только в том случае, если не экипированы и боеприпасы, и оружие.
|
||||
flameboots_label=Включить огненные сапоги?
|
||||
flameboots_tooltip=Когда пуль просто недостаточно.
|
||||
explosive_bullets_label=Включить разрывные пули?
|
||||
|
@ -2,7 +2,7 @@
|
||||
no_valid_surface=无效图层!
|
||||
flame_boots_worn_out=你的火焰鞋穿坏了.
|
||||
flame_mana_remaining=剩余魔法:__1__
|
||||
one_punch_text=暴击
|
||||
|
||||
mana_casting_too_fast= __1__ 魔法还有很多, 像 __2__ 迅速创建出, 然后挥舞着他们的魔杖,说一些难以理解的词.
|
||||
low_level=等级不够.
|
||||
not_inside_pos=你挥动你的魔杖, 但意识到它不能达到.
|
||||
@ -60,8 +60,6 @@ mana_max=这是你的最大魔力值。你可以通过增加你的魔法技能
|
||||
mining_name=挖掘\n速度
|
||||
slot_name=背包\n加成
|
||||
melee_name=近战\n伤害
|
||||
one_punch_chance=命中生命: __1__\n暴击几率: __2__ %\n +__3__ [img=recipe.defender-capsule]
|
||||
one_punch_disabled=暴击被禁用
|
||||
bonus_tooltip=到达距离加成: __1__\n建筑距离加成: __2__\n物品投掷距离加成: __3__\n拾取战利品距离加成: __4__\n物品拾取距离加成: __5__\n资源到达距离加成: __6__\n修理速度: __7__
|
||||
reach_distance=到达\n距离
|
||||
crafting_speed=制作\n速度
|
||||
@ -95,9 +93,6 @@ movement_text_label=启用移动速度加成?
|
||||
movement_text_tooltip=不想像闪电一样奔跑吗?\n你可以在这里切换。
|
||||
stone_path_label=采矿时启用石路?
|
||||
stone_path_tooltip=启用此选项将在您挖掘时,自动铺石砖
|
||||
one_punch_label=启用暴击?
|
||||
one_punch_tooltip=启用此选项将有一次击打敌人的机会,不能装备枪和子弹!
|
||||
one_punch_globally=启用全局。
|
||||
flameboots_label=启用火焰靴?
|
||||
flameboots_tooltip=当子弹未击中。
|
||||
magic_label=启用魔法(通过吃鱼施法)
|
||||
|
0
map_loader.lua
Normal file
@ -1,7 +1,7 @@
|
||||
-- Biter Battles -- mewmew made this --
|
||||
--luacheck:ignore
|
||||
local Server = require 'utils.server'
|
||||
local Score = require 'comfy_panel.score'
|
||||
local Score = require 'utils.gui.score'
|
||||
local Global = require 'utils.global'
|
||||
require 'modules.splice_double'
|
||||
require 'modules.explosive_biters'
|
||||
@ -525,15 +525,9 @@ end
|
||||
local function reveal_team(f)
|
||||
local m = 32
|
||||
if f == 'north' then
|
||||
game.forces['south'].chart(
|
||||
game.surfaces['surface'],
|
||||
{{x = global.force_area[f].x_top - m, y = global.force_area[f].y_top - m}, {x = global.force_area[f].x_bot + m, y = global.force_area[f].y_bot + m}}
|
||||
)
|
||||
game.forces['south'].chart(game.surfaces['surface'], {{x = global.force_area[f].x_top - m, y = global.force_area[f].y_top - m}, {x = global.force_area[f].x_bot + m, y = global.force_area[f].y_bot + m}})
|
||||
else
|
||||
game.forces['north'].chart(
|
||||
game.surfaces['surface'],
|
||||
{{x = global.force_area[f].x_top - m, y = global.force_area[f].y_top - m}, {x = global.force_area[f].x_bot + m, y = global.force_area[f].y_bot + m}}
|
||||
)
|
||||
game.forces['north'].chart(game.surfaces['surface'], {{x = global.force_area[f].x_top - m, y = global.force_area[f].y_top - m}, {x = global.force_area[f].x_bot + m, y = global.force_area[f].y_bot + m}})
|
||||
end
|
||||
end
|
||||
|
||||
@ -851,10 +845,7 @@ local function on_gui_click(event)
|
||||
join_team(player, global.team_chosen[player.name])
|
||||
end
|
||||
if (name == 'biter_battle_leave_spectate') and game.tick - global.spectator_spam_protection[player.name] < 1800 then
|
||||
player.print(
|
||||
'Not ready to return to your team yet. Please wait ' .. 30 - (math.round((game.tick - global.spectator_spam_protection[player.name]) / 60, 0)) .. ' seconds.',
|
||||
{r = 0.98, g = 0.66, b = 0.22}
|
||||
)
|
||||
player.print('Not ready to return to your team yet. Please wait ' .. 30 - (math.round((game.tick - global.spectator_spam_protection[player.name]) / 60, 0)) .. ' seconds.', {r = 0.98, g = 0.66, b = 0.22})
|
||||
end
|
||||
|
||||
if (name == 'biter_battle_hide_players') then
|
||||
@ -1053,15 +1044,11 @@ local function biter_attack_silo(team, requested_amount, mode)
|
||||
|
||||
if math_random(1, 6) == 1 then
|
||||
for _, biter in pairs(biters_selected_for_attack) do
|
||||
biter.set_command(
|
||||
{type = defines.command.attack_area, destination = global.biter_attack_main_target[team], radius = 12, distraction = defines.distraction.by_anything}
|
||||
)
|
||||
biter.set_command({type = defines.command.attack_area, destination = global.biter_attack_main_target[team], radius = 12, distraction = defines.distraction.by_anything})
|
||||
end
|
||||
else
|
||||
for _, biter in pairs(biters_selected_for_attack) do
|
||||
biter.set_command(
|
||||
{type = defines.command.attack_area, destination = global.biter_attack_main_target[team], radius = 12, distraction = defines.distraction.by_enemy}
|
||||
)
|
||||
biter.set_command({type = defines.command.attack_area, destination = global.biter_attack_main_target[team], radius = 12, distraction = defines.distraction.by_enemy})
|
||||
end
|
||||
end
|
||||
if global.biter_battles_debug then
|
||||
@ -1279,15 +1266,11 @@ local function biter_attack_silo(team, requested_amount, mode)
|
||||
if t > 8 then
|
||||
if math_random(1, 6) ~= 1 then
|
||||
for _, biter in pairs(biters_selected_for_attack) do
|
||||
biter.set_command(
|
||||
{type = defines.command.attack_area, destination = global.biter_attack_main_target[team], radius = 12, distraction = defines.distraction.by_enemy}
|
||||
)
|
||||
biter.set_command({type = defines.command.attack_area, destination = global.biter_attack_main_target[team], radius = 12, distraction = defines.distraction.by_enemy})
|
||||
end
|
||||
else
|
||||
for _, biter in pairs(biters_selected_for_attack) do
|
||||
biter.set_command(
|
||||
{type = defines.command.attack_area, destination = global.biter_attack_main_target[team], radius = 12, distraction = defines.distraction.by_anything}
|
||||
)
|
||||
biter.set_command({type = defines.command.attack_area, destination = global.biter_attack_main_target[team], radius = 12, distraction = defines.distraction.by_anything})
|
||||
end
|
||||
end
|
||||
if global.biter_battles_debug then
|
||||
@ -1298,9 +1281,7 @@ local function biter_attack_silo(team, requested_amount, mode)
|
||||
for _, biter in pairs(biters_selected_for_attack) do
|
||||
biter_attack_group.add_member(biter)
|
||||
end
|
||||
biter_attack_group.set_command(
|
||||
{type = defines.command.attack_area, destination = global.biter_attack_main_target[team], radius = 12, distraction = defines.distraction.by_enemy}
|
||||
)
|
||||
biter_attack_group.set_command({type = defines.command.attack_area, destination = global.biter_attack_main_target[team], radius = 12, distraction = defines.distraction.by_enemy})
|
||||
if global.biter_battles_debug then
|
||||
game.players[1].print(#valid_biters .. ' valid biters found.')
|
||||
game.players[1].print(#biters_selected_for_attack .. ' gathering at (x: ' .. gathering_point_x .. ' y: ' .. gathering_point_y .. ')')
|
||||
|
@ -2,7 +2,7 @@
|
||||
local Functions = require 'maps.biter_battles_v2.functions'
|
||||
local Gui = require 'maps.biter_battles_v2.gui'
|
||||
local Init = require 'maps.biter_battles_v2.init'
|
||||
local Score = require 'comfy_panel.score'
|
||||
local Score = require 'utils.gui.score'
|
||||
local Server = require 'utils.server'
|
||||
local Discord = require 'utils.discord'
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
--luacheck:ignore
|
||||
local Terrain = require 'maps.biter_battles_v2.terrain'
|
||||
local Force_health_booster = require 'modules.force_health_booster'
|
||||
local Score = require 'comfy_panel.score'
|
||||
local Score = require 'utils.gui.score'
|
||||
|
||||
local Public = {}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
--luacheck: ignore
|
||||
-- science logs tab --
|
||||
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local Tabs = require 'utils.gui'
|
||||
local tables = require 'maps.biter_battles_v2.tables'
|
||||
local event = require 'utils.event'
|
||||
local bb_config = require 'maps.biter_battles_v2.config'
|
||||
@ -13,8 +13,7 @@ local science_list = tables.science_list
|
||||
local evofilter_list = tables.evofilter_list
|
||||
local food_value_table_version = tables.food_value_table_version
|
||||
local Token = require 'utils.token'
|
||||
|
||||
local module_name = 'MutagenLog'
|
||||
local module_name = Tabs.uid_name()
|
||||
|
||||
local function initialize_dropdown_users_choice()
|
||||
global.dropdown_users_choice_force = {}
|
||||
@ -27,8 +26,7 @@ local function get_science_text(food_name, food_short_name)
|
||||
end
|
||||
|
||||
local function add_science_logs(player, element)
|
||||
local science_scrollpanel =
|
||||
element.add {type = 'scroll-pane', name = 'scroll_pane', direction = 'vertical', horizontal_scroll_policy = 'never', vertical_scroll_policy = 'auto'}
|
||||
local science_scrollpanel = element.add {type = 'scroll-pane', name = 'scroll_pane', direction = 'vertical', horizontal_scroll_policy = 'never', vertical_scroll_policy = 'auto'}
|
||||
science_scrollpanel.style.maximal_height = 530
|
||||
|
||||
if global.science_logs_category_potion == nil then
|
||||
@ -129,8 +127,7 @@ local function add_science_logs(player, element)
|
||||
|
||||
local dropdown_force = t_filter.add {name = 'dropdown-force', type = 'drop-down', items = forces_list, selected_index = global.dropdown_users_choice_force[player.name]}
|
||||
local dropdown_science = t_filter.add {name = 'dropdown-science', type = 'drop-down', items = science_list, selected_index = global.dropdown_users_choice_science[player.name]}
|
||||
local dropdown_evofilter =
|
||||
t_filter.add {name = 'dropdown-evofilter', type = 'drop-down', items = evofilter_list, selected_index = global.dropdown_users_choice_evo_filter[player.name]}
|
||||
local dropdown_evofilter = t_filter.add {name = 'dropdown-evofilter', type = 'drop-down', items = evofilter_list, selected_index = global.dropdown_users_choice_evo_filter[player.name]}
|
||||
|
||||
local t = science_scrollpanel.add {type = 'table', name = 'science_logs_header_table', column_count = 4}
|
||||
local column_widths = {tonumber(75), tonumber(310), tonumber(165), tonumber(230)}
|
||||
@ -171,13 +168,9 @@ local function add_science_logs(player, element)
|
||||
|
||||
if dropdown_force.selected_index == 1 or real_force_name:match(dropdown_force.get_item(dropdown_force.selected_index)) then
|
||||
if
|
||||
dropdown_science.selected_index == 1 or
|
||||
(dropdown_science.selected_index == 2 and (easy_food_name:match('space') or easy_food_name:match('utility') or easy_food_name:match('production'))) or
|
||||
(dropdown_science.selected_index == 3 and
|
||||
(easy_food_name:match('space') or easy_food_name:match('utility') or easy_food_name:match('production') or easy_food_name:match('chemical'))) or
|
||||
(dropdown_science.selected_index == 4 and
|
||||
(easy_food_name:match('space') or easy_food_name:match('utility') or easy_food_name:match('production') or easy_food_name:match('chemical') or
|
||||
easy_food_name:match('military'))) or
|
||||
dropdown_science.selected_index == 1 or (dropdown_science.selected_index == 2 and (easy_food_name:match('space') or easy_food_name:match('utility') or easy_food_name:match('production'))) or
|
||||
(dropdown_science.selected_index == 3 and (easy_food_name:match('space') or easy_food_name:match('utility') or easy_food_name:match('production') or easy_food_name:match('chemical'))) or
|
||||
(dropdown_science.selected_index == 4 and (easy_food_name:match('space') or easy_food_name:match('utility') or easy_food_name:match('production') or easy_food_name:match('chemical') or easy_food_name:match('military'))) or
|
||||
easy_food_name:match(dropdown_science.get_item(dropdown_science.selected_index))
|
||||
then
|
||||
if
|
||||
@ -221,19 +214,9 @@ local function add_science_logs(player, element)
|
||||
end
|
||||
end
|
||||
|
||||
local function comfy_panel_get_active_frame(player)
|
||||
if not player.gui.left.comfy_panel then
|
||||
return false
|
||||
end
|
||||
if not player.gui.left.comfy_panel.tabbed_pane.selected_tab_index then
|
||||
return player.gui.left.comfy_panel.tabbed_pane.tabs[1].content
|
||||
end
|
||||
return player.gui.left.comfy_panel.tabbed_pane.tabs[player.gui.left.comfy_panel.tabbed_pane.selected_tab_index].content
|
||||
end
|
||||
|
||||
local function build_config_gui(data)
|
||||
local player = data.player
|
||||
local frame_sciencelogs = comfy_panel_get_active_frame(player)
|
||||
local frame_sciencelogs = Gui.get_player_active_frame(player)
|
||||
if not frame_sciencelogs then
|
||||
return
|
||||
end
|
||||
@ -268,4 +251,12 @@ end
|
||||
|
||||
event.add(defines.events.on_gui_selection_state_changed, on_gui_selection_state_changed)
|
||||
|
||||
Tabs.add_tab_to_gui({name = module_name, id = build_config_gui_token, admin = false})
|
||||
Tabs.add_tab_to_gui({name = module_name, caption = 'MutagenLog', id = build_config_gui_token, admin = false})
|
||||
|
||||
Tabs.on_click(
|
||||
module_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
Tabs.reload_active_tab(player)
|
||||
end
|
||||
)
|
||||
|
@ -1,8 +1,8 @@
|
||||
--luacheck: ignore
|
||||
require 'modules.no_turrets'
|
||||
require 'modules.no_acid_puddles'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local Map_score = require 'comfy_panel.map_score'
|
||||
local Gui = require 'utils.gui'
|
||||
local Map_score = require 'utils.gui.map_score'
|
||||
local unit_raffle = require 'maps.biter_hatchery.raffle_tables'
|
||||
local Terrain = require 'maps.biter_hatchery.terrain'
|
||||
local Gui = require 'maps.biter_hatchery.gui'
|
||||
@ -310,7 +310,7 @@ local function on_entity_died(event)
|
||||
for _, child in pairs(player.gui.left.children) do
|
||||
child.destroy()
|
||||
end
|
||||
Tabs.comfy_panel_call_tab(player, 'Map Scores')
|
||||
Gui.call_existing_tab(player, 'Map Scores')
|
||||
end
|
||||
|
||||
for _, e in pairs(entity.surface.find_entities_filtered({type = 'unit'})) do
|
||||
|
@ -1,6 +1,6 @@
|
||||
local Chrono_table = require 'maps.chronosphere.table'
|
||||
local Balance = require 'maps.chronosphere.balance'
|
||||
local Score = require 'comfy_panel.score'
|
||||
local Score = require 'utils.gui.score'
|
||||
local Difficulty = require 'modules.difficulty_vote'
|
||||
local Upgrades = require 'maps.chronosphere.upgrade_list'
|
||||
local List = require 'maps.chronosphere.production_list'
|
||||
@ -120,48 +120,48 @@ function Public.restart_settings()
|
||||
global.mining_history = {}
|
||||
get_score.score_table = {}
|
||||
|
||||
game.difficulty_settings.technology_price_multiplier = Balance.Tech_price_multiplier
|
||||
game.map_settings.enemy_evolution.destroy_factor = 0.005
|
||||
game.map_settings.enemy_evolution.pollution_factor = 0
|
||||
game.map_settings.enemy_evolution.time_factor = 7e-05
|
||||
game.map_settings.enemy_expansion.enabled = false
|
||||
-- game.map_settings.enemy_expansion.max_expansion_cooldown = 3600
|
||||
-- game.map_settings.enemy_expansion.min_expansion_cooldown = 3600
|
||||
-- game.map_settings.enemy_expansion.settler_group_max_size = 30
|
||||
-- game.map_settings.enemy_expansion.settler_group_min_size = 10
|
||||
-- game.map_settings.enemy_expansion.max_expansion_distance = 9
|
||||
game.map_settings.pollution.enabled = true
|
||||
game.map_settings.pollution.expected_max_per_chunk = 400
|
||||
game.map_settings.pollution.min_to_show_per_chunk = 40
|
||||
game.map_settings.pollution.pollution_restored_per_tree_damage = 0.02
|
||||
game.map_settings.pollution.min_pollution_to_damage_trees = 1
|
||||
game.map_settings.pollution.max_pollution_to_restore_trees = 0
|
||||
game.map_settings.pollution.pollution_with_max_forest_damage = 10
|
||||
game.map_settings.pollution.pollution_per_tree_damage = 0.1
|
||||
game.map_settings.pollution.ageing = 0.1
|
||||
game.map_settings.pollution.diffusion_ratio = 0.1
|
||||
game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 5
|
||||
game.map_settings.unit_group.min_group_gathering_time = 1800
|
||||
game.map_settings.unit_group.max_group_gathering_time = 18000
|
||||
game.map_settings.unit_group.max_wait_time_for_late_members = 600
|
||||
game.map_settings.path_finder.general_entity_collision_penalty = 1
|
||||
game.map_settings.path_finder.general_entity_subsequent_collision_penalty = 1
|
||||
game.map_settings.path_finder.short_cache_size = 20
|
||||
game.map_settings.path_finder.long_cache_size = 100
|
||||
game.map_settings.unit_group.max_gathering_unit_groups = 10
|
||||
game.forces.neutral.character_inventory_slots_bonus = 500
|
||||
game.forces.enemy.evolution_factor = 0.0001
|
||||
game.forces.scrapyard.set_friend('enemy', true)
|
||||
game.forces.enemy.set_friend('scrapyard', true)
|
||||
game.forces.enemy.set_ammo_damage_modifier("rocket", -0.5)
|
||||
game.forces.player.technologies["land-mine"].enabled = false
|
||||
game.forces.player.technologies["landfill"].enabled = false
|
||||
game.forces.player.technologies["cliff-explosives"].enabled = false
|
||||
game.forces.player.technologies["fusion-reactor-equipment"].enabled = false
|
||||
game.forces.player.technologies["power-armor-mk2"].enabled = false
|
||||
game.forces.player.technologies["railway"].researched = true
|
||||
game.forces.player.recipes["pistol"].enabled = false
|
||||
game.forces.player.ghost_time_to_live = 15 * 60 * 60
|
||||
game.difficulty_settings.technology_price_multiplier = Balance.Tech_price_multiplier
|
||||
game.map_settings.enemy_evolution.destroy_factor = 0.005
|
||||
game.map_settings.enemy_evolution.pollution_factor = 0
|
||||
game.map_settings.enemy_evolution.time_factor = 7e-05
|
||||
game.map_settings.enemy_expansion.enabled = false
|
||||
-- game.map_settings.enemy_expansion.max_expansion_cooldown = 3600
|
||||
-- game.map_settings.enemy_expansion.min_expansion_cooldown = 3600
|
||||
-- game.map_settings.enemy_expansion.settler_group_max_size = 30
|
||||
-- game.map_settings.enemy_expansion.settler_group_min_size = 10
|
||||
-- game.map_settings.enemy_expansion.max_expansion_distance = 9
|
||||
game.map_settings.pollution.enabled = true
|
||||
game.map_settings.pollution.expected_max_per_chunk = 400
|
||||
game.map_settings.pollution.min_to_show_per_chunk = 40
|
||||
game.map_settings.pollution.pollution_restored_per_tree_damage = 0.02
|
||||
game.map_settings.pollution.min_pollution_to_damage_trees = 1
|
||||
game.map_settings.pollution.max_pollution_to_restore_trees = 0
|
||||
game.map_settings.pollution.pollution_with_max_forest_damage = 10
|
||||
game.map_settings.pollution.pollution_per_tree_damage = 0.1
|
||||
game.map_settings.pollution.ageing = 0.1
|
||||
game.map_settings.pollution.diffusion_ratio = 0.1
|
||||
game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 5
|
||||
game.map_settings.unit_group.min_group_gathering_time = 1800
|
||||
game.map_settings.unit_group.max_group_gathering_time = 18000
|
||||
game.map_settings.unit_group.max_wait_time_for_late_members = 600
|
||||
game.map_settings.path_finder.general_entity_collision_penalty = 1
|
||||
game.map_settings.path_finder.general_entity_subsequent_collision_penalty = 1
|
||||
game.map_settings.path_finder.short_cache_size = 20
|
||||
game.map_settings.path_finder.long_cache_size = 100
|
||||
game.map_settings.unit_group.max_gathering_unit_groups = 10
|
||||
game.forces.neutral.character_inventory_slots_bonus = 500
|
||||
game.forces.enemy.evolution_factor = 0.0001
|
||||
game.forces.scrapyard.set_friend('enemy', true)
|
||||
game.forces.enemy.set_friend('scrapyard', true)
|
||||
game.forces.enemy.set_ammo_damage_modifier('rocket', -0.5)
|
||||
game.forces.player.technologies['land-mine'].enabled = false
|
||||
game.forces.player.technologies['landfill'].enabled = false
|
||||
game.forces.player.technologies['cliff-explosives'].enabled = false
|
||||
game.forces.player.technologies['fusion-reactor-equipment'].enabled = false
|
||||
game.forces.player.technologies['power-armor-mk2'].enabled = false
|
||||
game.forces.player.technologies['railway'].researched = true
|
||||
game.forces.player.recipes['pistol'].enabled = false
|
||||
game.forces.player.ghost_time_to_live = 15 * 60 * 60
|
||||
end
|
||||
|
||||
function Public.set_difficulty_settings()
|
||||
@ -244,8 +244,7 @@ function Public.process_jump()
|
||||
objective.chronojumps = objective.chronojumps + 1
|
||||
objective.passivetimer = 0
|
||||
objective.chronochargesneeded = Balance.MJ_needed_for_full_charge(Difficulty.get().difficulty_vote_value, objective.chronojumps)
|
||||
objective.passive_chronocharge_rate =
|
||||
Balance.MJ_needed_for_full_charge(Difficulty.get().difficulty_vote_value, objective.chronojumps) / Balance.passive_planet_jumptime(objective.chronojumps)
|
||||
objective.passive_chronocharge_rate = Balance.MJ_needed_for_full_charge(Difficulty.get().difficulty_vote_value, objective.chronojumps) / Balance.passive_planet_jumptime(objective.chronojumps)
|
||||
bitertable.active_biters = {}
|
||||
bitertable.unit_groups = {}
|
||||
bitertable.biter_raffle = {}
|
||||
@ -274,10 +273,7 @@ function Public.process_jump()
|
||||
objective.computermessage = 5
|
||||
game.play_sound {path = 'utility/new_objective', volume_modifier = 0.85}
|
||||
end
|
||||
if
|
||||
(objective.passivetimer - 180) * objective.passive_chronocharge_rate > objective.chronochargesneeded * 0.75 and
|
||||
objective.chronojumps >= Balance.jumps_until_overstay_is_on(Difficulty.get().difficulty_vote_value)
|
||||
then
|
||||
if (objective.passivetimer - 180) * objective.passive_chronocharge_rate > objective.chronochargesneeded * 0.75 and objective.chronojumps >= Balance.jumps_until_overstay_is_on(Difficulty.get().difficulty_vote_value) then
|
||||
game.print({'chronosphere.message_overstay'}, {r = 0.98, g = 0.36, b = 0.22})
|
||||
end
|
||||
if objective.world.id == 2 and objective.world.variant.id == 2 then
|
||||
@ -407,7 +403,12 @@ local function create_chunk_list(surface)
|
||||
chunks[#chunks + 1] = {pos = {x, y}, generated = surface.is_chunk_generated({x, y}), distance = math.sqrt(x * x + y * y)}
|
||||
end
|
||||
end
|
||||
for k, v in Rand.spairs(chunks, function(t, a, b) return t[b].distance > t[a].distance end) do
|
||||
for k, v in Rand.spairs(
|
||||
chunks,
|
||||
function(t, a, b)
|
||||
return t[b].distance > t[a].distance
|
||||
end
|
||||
) do
|
||||
if v.generated == false then
|
||||
schedule.chunks_to_generate[#schedule.chunks_to_generate + 1] = v
|
||||
end
|
||||
@ -415,24 +416,24 @@ local function create_chunk_list(surface)
|
||||
end
|
||||
|
||||
function Public.setup_world(surface)
|
||||
local objective = Chrono_table.get_table()
|
||||
local world = objective.world
|
||||
if objective.chronojumps <= 2 then
|
||||
surface.min_brightness = 0.5
|
||||
else
|
||||
surface.min_brightness = 0
|
||||
end
|
||||
surface.brightness_visual_weights = {1, 1, 1}
|
||||
objective.surface = surface
|
||||
surface.daytime = world.daytime
|
||||
local timer = world.dayspeed.timer
|
||||
if timer == 0 then
|
||||
surface.freeze_daytime = true
|
||||
timer = timer + 1
|
||||
else
|
||||
surface.freeze_daytime = false
|
||||
end
|
||||
surface.ticks_per_day = timer * 250
|
||||
local objective = Chrono_table.get_table()
|
||||
local world = objective.world
|
||||
if objective.chronojumps <= 2 then
|
||||
surface.min_brightness = 0.5
|
||||
else
|
||||
surface.min_brightness = 0
|
||||
end
|
||||
surface.brightness_visual_weights = {1, 1, 1}
|
||||
objective.surface = surface
|
||||
surface.daytime = world.daytime
|
||||
local timer = world.dayspeed.timer
|
||||
if timer == 0 then
|
||||
surface.freeze_daytime = true
|
||||
timer = timer + 1
|
||||
else
|
||||
surface.freeze_daytime = false
|
||||
end
|
||||
surface.ticks_per_day = timer * 250
|
||||
|
||||
local moisture = world.variant.moisture
|
||||
if moisture ~= 0 then
|
||||
|
@ -3,9 +3,10 @@
|
||||
local Chrono_table = require 'maps.chronosphere.table'
|
||||
local Chrono = require 'maps.chronosphere.chrono'
|
||||
local Token = require 'utils.token'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local Event = require 'utils.event'
|
||||
local Gui = require 'utils.gui'
|
||||
|
||||
local module_name = 'ChronoTrain'
|
||||
local module_name = Gui.uid_name()
|
||||
|
||||
local functions = {
|
||||
['comfy_panel_offline_accidents'] = function(event)
|
||||
@ -230,7 +231,14 @@ local function on_gui_click(event)
|
||||
end
|
||||
end
|
||||
|
||||
Tabs.add_tab_to_gui({name = module_name, id = build_config_gui_token, admin = true})
|
||||
Gui.add_tab_to_gui({name = module_name, caption = 'ChronoTrain', id = build_config_gui_token, admin = true})
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.add(defines.events.on_gui_click, on_gui_click)
|
||||
Gui.on_click(
|
||||
module_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
Gui.reload_active_tab(player)
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(defines.events.on_gui_click, on_gui_click)
|
||||
|
@ -16,10 +16,10 @@ local Map = require 'modules.map_info'
|
||||
local Event = require 'utils.event'
|
||||
local Reset = require 'functions.soft_reset'
|
||||
local Server = require 'utils.server'
|
||||
local Poll = require 'comfy_panel.poll'
|
||||
local Poll = require 'utils.gui.poll'
|
||||
local boss_biter = require 'maps.crab_defender.boss_biters'
|
||||
local FDT = require 'maps.crab_defender.table'
|
||||
local Score = require 'comfy_panel.score'
|
||||
local Score = require 'utils.gui.score'
|
||||
local math_random = math.random
|
||||
local insert = table.insert
|
||||
local enable_start_grace_period = true
|
||||
|
@ -195,7 +195,7 @@ local function teleport_player_out(arena, player)
|
||||
local surface = arenatable.previous_position[arena].surface
|
||||
local position = arenatable.previous_position[arena].position
|
||||
local rpg = RPG.get('rpg_t')
|
||||
rpg[player.index].one_punch = true
|
||||
rpg[player.index].aoe_punch = true
|
||||
hide_rpg(player, true)
|
||||
player.teleport(surface.find_non_colliding_position('character', position, 20, 0.5), surface)
|
||||
arenatable.previous_position[arena].position = nil
|
||||
@ -212,7 +212,7 @@ local function teleport_player_in(arena, player)
|
||||
arenatable.previous_position[arena].surface = player.surface
|
||||
arenatable.timer[arena] = game.tick
|
||||
local rpg = RPG.get('rpg_t')
|
||||
rpg[player.index].one_punch = false
|
||||
rpg[player.index].aoe_punch = false
|
||||
rpg[player.index].enable_entity_spawn = false
|
||||
hide_rpg(player, false)
|
||||
|
||||
|
@ -21,10 +21,10 @@ local Map = require 'modules.map_info'
|
||||
local Event = require 'utils.event'
|
||||
local Reset = require 'functions.soft_reset'
|
||||
local Server = require 'utils.server'
|
||||
local Poll = require 'comfy_panel.poll'
|
||||
local Poll = require 'utils.gui.poll'
|
||||
local boss_biter = require 'maps.fish_defender.boss_biters'
|
||||
local FDT = require 'maps.fish_defender.table'
|
||||
local Score = require 'comfy_panel.score'
|
||||
local Score = require 'utils.gui.score'
|
||||
local math_random = math.random
|
||||
local insert = table.insert
|
||||
local enable_start_grace_period = true
|
||||
|
@ -17,7 +17,7 @@ require 'modules.biter_evasion_hp_increaser'
|
||||
local event = require 'utils.event'
|
||||
local Server = require 'utils.server'
|
||||
local boss_biter = require 'maps.fish_defender.boss_biters'
|
||||
local Score = require 'comfy_panel.score'
|
||||
local Score = require 'utils.gui.score'
|
||||
require 'functions.boss_unit'
|
||||
local map_functions = require 'tools.map_functions'
|
||||
local Difficulty = require 'modules.difficulty_vote'
|
||||
|
@ -14,8 +14,8 @@ local Event = require 'utils.event'
|
||||
local Reset = require 'functions.soft_reset'
|
||||
local Server = require 'utils.server'
|
||||
local Session = require 'utils.datastore.session_data'
|
||||
local Poll = require 'comfy_panel.poll'
|
||||
local Score = require 'comfy_panel.score'
|
||||
local Poll = require 'utils.gui.poll'
|
||||
local Score = require 'utils.gui.score'
|
||||
local AntiGrief = require 'utils.antigrief'
|
||||
local Core = require 'utils.core'
|
||||
local format_number = require 'util'.format_number
|
||||
|
@ -1,8 +1,8 @@
|
||||
--luacheck: ignore
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local Gui = require 'utils.gui'
|
||||
local Map_score = require 'modules.map_score'
|
||||
local Terrain = require 'maps.junkyard_pvp.terrain'
|
||||
local Gui = require 'maps.junkyard_pvp.gui'
|
||||
local MapGui = require 'maps.junkyard_pvp.gui'
|
||||
require 'maps.junkyard_pvp.surrounded_by_worms'
|
||||
require 'modules.flashlight_toggle_button'
|
||||
require 'modules.rocks_heal_over_time'
|
||||
@ -65,7 +65,7 @@ function Public.reset_map()
|
||||
Team.set_player_to_spectator(player)
|
||||
end
|
||||
for _, player in pairs(game.forces.spectator.players) do
|
||||
Gui.rejoin_question(player)
|
||||
MapGui.rejoin_question(player)
|
||||
end
|
||||
|
||||
set_player_colors()
|
||||
@ -119,7 +119,7 @@ local function on_entity_died(event)
|
||||
for _, child in pairs(player.gui.left.children) do
|
||||
child.destroy()
|
||||
end
|
||||
Tabs.comfy_panel_call_tab(player, 'Map Scores')
|
||||
Gui.call_existing_tab(player, 'Map Scores')
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -129,7 +129,7 @@ local function on_player_joined_game(event)
|
||||
local surface = game.surfaces[global.active_surface_index]
|
||||
|
||||
set_player_colors()
|
||||
Gui.spectate_button(player)
|
||||
MapGui.spectate_button(player)
|
||||
|
||||
if player.surface.index ~= global.active_surface_index then
|
||||
if player.force.name == 'spectator' then
|
||||
|
@ -10,11 +10,11 @@ local Server = require 'utils.server'
|
||||
local Global = require 'utils.global'
|
||||
local map_functions = require 'tools.map_functions'
|
||||
local simplex_noise = require 'utils.simplex_noise'.d2
|
||||
local Score = require 'comfy_panel.score'
|
||||
local Score = require 'utils.gui.score'
|
||||
local unique_rooms = require 'maps.labyrinth_unique_rooms'
|
||||
local SoftReset = require 'functions.soft_reset'
|
||||
local Autostash = require 'modules.autostash'
|
||||
local BottomFrame = require 'comfy_panel.bottom_frame'
|
||||
local BottomFrame = require 'utils.gui.bottom_frame'
|
||||
local this = {
|
||||
settings = {
|
||||
labyrinth_size = 1,
|
||||
@ -517,10 +517,7 @@ local function grow_cell(chunk_position, surface) -- luacheck: ignore
|
||||
end
|
||||
end
|
||||
end
|
||||
placed_enemies =
|
||||
#entities_to_place.biters * 0.35 + #entities_to_place.spitters * 0.35 + #entities_to_place.enemy_buildings * 2 + #entities_to_place.worms * 3 +
|
||||
#entities_to_place.gun_turrets * 3 +
|
||||
#entities_to_place.allied_entities
|
||||
placed_enemies = #entities_to_place.biters * 0.35 + #entities_to_place.spitters * 0.35 + #entities_to_place.enemy_buildings * 2 + #entities_to_place.worms * 3 + #entities_to_place.gun_turrets * 3 + #entities_to_place.allied_entities
|
||||
end
|
||||
|
||||
for x = 0, 31, 1 do --luacheck: ignore
|
||||
@ -570,10 +567,7 @@ local function grow_cell(chunk_position, surface) -- luacheck: ignore
|
||||
table.insert(entities_to_place.spitters, {left_top_x + e.position.x, left_top_y + e.position.y})
|
||||
break
|
||||
end
|
||||
table.insert(
|
||||
entities_to_place.misc,
|
||||
{name = e.name, position = {left_top_x + e.position.x, left_top_y + e.position.y}, direction = e.direction, force = e.force}
|
||||
)
|
||||
table.insert(entities_to_place.misc, {name = e.name, position = {left_top_x + e.position.x, left_top_y + e.position.y}, direction = e.direction, force = e.force})
|
||||
break
|
||||
end
|
||||
end
|
||||
@ -1055,8 +1049,7 @@ local function on_entity_died(event)
|
||||
if game.forces.enemy.evolution_factor < 0.5 then
|
||||
local evolution_drop_modifier = (0.1 - game.forces.enemy.evolution_factor) * 10
|
||||
if evolution_drop_modifier > 0 then
|
||||
local amount =
|
||||
math.ceil(math.random(entity_drop_amount[event.entity.name].low, entity_drop_amount[event.entity.name].high) * evolution_drop_modifier)
|
||||
local amount = math.ceil(math.random(entity_drop_amount[event.entity.name].low, entity_drop_amount[event.entity.name].high) * evolution_drop_modifier)
|
||||
event.entity.surface.spill_item_stack(event.entity.position, {name = ore_spill_raffle[math.random(1, #ore_spill_raffle)], count = amount}, true)
|
||||
end
|
||||
end
|
||||
@ -1291,8 +1284,7 @@ local function on_built_entity(event)
|
||||
if get_score then
|
||||
if get_score[player.force.name] then
|
||||
if get_score[player.force.name].players[player.name] then
|
||||
get_score[player.force.name].players[player.name].built_entities =
|
||||
get_score[player.force.name].players[player.name].built_entities - 1
|
||||
get_score[player.force.name].players[player.name].built_entities = get_score[player.force.name].players[player.name].built_entities - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -13,7 +13,7 @@ Cell Values:
|
||||
require 'modules.satellite_score'
|
||||
|
||||
local Functions = require 'maps.minesweeper.functions'
|
||||
local Map_score = require 'comfy_panel.map_score'
|
||||
local Map_score = require 'utils.gui.map_score'
|
||||
local Map = require 'modules.map_info'
|
||||
local Global = require 'utils.global'
|
||||
|
||||
|
@ -7,8 +7,8 @@ local darkness = false
|
||||
require 'functions.soft_reset'
|
||||
require 'functions.basic_markets'
|
||||
|
||||
local ComfyPanel = require 'comfy_panel.main'
|
||||
local Map_score = require 'comfy_panel.map_score'
|
||||
local Gui = require 'utils.gui'
|
||||
local Map_score = require 'utils.gui.map_score'
|
||||
local Collapse = require 'modules.collapse'
|
||||
local RPG = require 'modules.rpg'
|
||||
require 'modules.wave_defense.main'
|
||||
@ -54,7 +54,7 @@ local function game_over()
|
||||
global.game_reset_tick = game.tick + 1800
|
||||
for _, player in pairs(game.connected_players) do
|
||||
player.play_sound {path = 'utility/game_lost', volume_modifier = 0.80}
|
||||
ComfyPanel.comfy_panel_call_tab(player, 'Map Scores')
|
||||
Gui.call_existing_tab(player, 'Map Scores')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
local Collapse = require 'modules.collapse'
|
||||
local Terrain = require 'maps.mountain_fortress_v3.terrain'
|
||||
local Balance = require 'maps.mountain_fortress_v3.balance'
|
||||
local RPG = require 'modules.rpg.main'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
@ -15,21 +14,7 @@ local abs = math.abs
|
||||
local random = math.random
|
||||
local sub = string.sub
|
||||
local sqrt = math.sqrt
|
||||
local level_depth = WPT.level_depth
|
||||
|
||||
local forest = {
|
||||
[2] = true,
|
||||
[10] = true,
|
||||
[13] = true,
|
||||
[17] = true,
|
||||
[19] = true,
|
||||
[21] = true
|
||||
}
|
||||
|
||||
local scrap = {
|
||||
[5] = true,
|
||||
[15] = true
|
||||
}
|
||||
local zone_settings = WPT.zone_settings
|
||||
|
||||
local clear_breach_text_and_render = function()
|
||||
local beam1 = WPT.get('zone1_beam1')
|
||||
@ -140,8 +125,14 @@ end
|
||||
local compare_player_pos = function(player)
|
||||
local p = player.position
|
||||
local index = player.index
|
||||
local zone = floor((abs(p.y / level_depth)) % 22)
|
||||
if scrap[zone] then
|
||||
local adjusted_zones = WPT.get('adjusted_zones')
|
||||
if not adjusted_zones.size then
|
||||
return
|
||||
end
|
||||
|
||||
local zone = floor((abs(p.y / zone_settings.zone_depth)) % adjusted_zones.size) + 1
|
||||
|
||||
if adjusted_zones.scrap[zone] then
|
||||
RPG.set_value_to_player(index, 'scrap_zone', true)
|
||||
else
|
||||
local has_scrap = RPG.get_value_from_player(index, 'scrap_zone')
|
||||
@ -150,7 +141,7 @@ local compare_player_pos = function(player)
|
||||
end
|
||||
end
|
||||
|
||||
if forest[zone] then
|
||||
if adjusted_zones.forest[zone] then
|
||||
RPG.set_value_to_player(index, 'forest_zone', true)
|
||||
else
|
||||
local is_in_forest = RPG.get_value_from_player(index, 'forest_zone')
|
||||
@ -186,13 +177,13 @@ local compare_player_and_train = function(player, entity)
|
||||
if c_y - t_y <= spidertron_warning_position then
|
||||
local surface = player.surface
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = position,
|
||||
text = 'Warning!!! You are too far from the train!!!',
|
||||
color = {r = 0.9, g = 0.0, b = 0.0}
|
||||
}
|
||||
)
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = position,
|
||||
text = 'Warning! You are too far away from the main locomotive!',
|
||||
color = {r = 0.9, g = 0.0, b = 0.0}
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
if c_y - t_y <= gap_between_zones.neg_gap then
|
||||
@ -228,14 +219,14 @@ local function distance(player)
|
||||
|
||||
compare_player_pos(player)
|
||||
|
||||
local distance_to_center = floor(sqrt(p.x ^ 2 + p.y ^ 2))
|
||||
local distance_to_center = floor(sqrt(p.y ^ 2))
|
||||
local location = distance_to_center
|
||||
if location < Terrain.level_depth * bonus - 10 then
|
||||
if location < zone_settings.zone_depth * bonus - 10 then
|
||||
return
|
||||
end
|
||||
|
||||
local max = Terrain.level_depth * bonus
|
||||
local breach_max = Terrain.level_depth * breached_wall
|
||||
local max = zone_settings.zone_depth * bonus
|
||||
local breach_max = zone_settings.zone_depth * breached_wall
|
||||
local breach_max_times = location >= breach_max
|
||||
local max_times = location >= max
|
||||
if max_times then
|
||||
@ -245,10 +236,8 @@ local function distance(player)
|
||||
rpg_extra.breached_walls = rpg_extra.breached_walls + 1
|
||||
rpg_extra.reward_new_players = bonus_xp_on_join * rpg_extra.breached_walls
|
||||
WPT.set('breached_wall', breached_wall + 1)
|
||||
placed_trains_in_zone.placed = 0
|
||||
biters.amount = 0
|
||||
placed_trains_in_zone.randomized = false
|
||||
placed_trains_in_zone.positions = {}
|
||||
raise_event(Balance.events.breached_wall, {})
|
||||
if WPT.get('breached_wall') == WPT.get('spidertron_unlocked_at_zone') then
|
||||
local main_market_items = WPT.get('main_market_items')
|
||||
@ -258,7 +247,7 @@ local function distance(player)
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = rng,
|
||||
tooltip = 'Chonk Spidertron',
|
||||
tooltip = 'BiterStunner 9000',
|
||||
upgrade = false,
|
||||
static = true
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ commands.add_command(
|
||||
|
||||
commands.add_command(
|
||||
'disable_biters',
|
||||
'Usable only for admins - sets the queue speed of this map!',
|
||||
'Usable only for admins - disables wave defense!',
|
||||
function()
|
||||
local player = game.player
|
||||
|
||||
|
@ -7,14 +7,13 @@ local Loot = require 'maps.mountain_fortress_v3.loot'
|
||||
local RPG = require 'modules.rpg.main'
|
||||
local Callbacks = require 'maps.mountain_fortress_v3.functions'
|
||||
local Mining = require 'maps.mountain_fortress_v3.mining'
|
||||
local Terrain = require 'maps.mountain_fortress_v3.terrain'
|
||||
local Traps = require 'maps.mountain_fortress_v3.traps'
|
||||
local Locomotive = require 'maps.mountain_fortress_v3.locomotive'
|
||||
local DefenseSystem = require 'maps.mountain_fortress_v3.locomotive.defense_system'
|
||||
local Collapse = require 'modules.collapse'
|
||||
local Alert = require 'utils.alert'
|
||||
local Task = require 'utils.task'
|
||||
local Score = require 'comfy_panel.score'
|
||||
local Score = require 'utils.gui.score'
|
||||
local Token = require 'utils.token'
|
||||
-- local HS = require 'maps.mountain_fortress_v3.highscore'
|
||||
local Discord = require 'utils.discord'
|
||||
@ -26,6 +25,7 @@ local RPG_Progression = require 'utils.datastore.rpg_data'
|
||||
-- tables
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local zone_settings = WPT.zone_settings
|
||||
|
||||
-- module
|
||||
local Public = {}
|
||||
@ -394,7 +394,7 @@ local function angry_tree(entity, cause, player)
|
||||
return
|
||||
end
|
||||
|
||||
if abs(entity.position.y) < Terrain.level_depth then
|
||||
if abs(entity.position.y) < zone_settings.zone_depth then
|
||||
return
|
||||
end
|
||||
if random(1, 6) == 1 then
|
||||
@ -1153,8 +1153,7 @@ local function show_mvps(player)
|
||||
local miners_label = t.add({type = 'label', caption = 'Miners >> '})
|
||||
miners_label.style.font = 'default-listbox'
|
||||
miners_label.style.font_color = {r = 0.22, g = 0.77, b = 0.44}
|
||||
local miners_label_text =
|
||||
t.add({type = 'label', caption = mvp.mined_entities.name .. ' mined a total of ' .. mvp.mined_entities.score .. ' entities!'})
|
||||
local miners_label_text = t.add({type = 'label', caption = mvp.mined_entities.name .. ' mined a total of ' .. mvp.mined_entities.score .. ' entities!'})
|
||||
miners_label_text.style.font = 'default-bold'
|
||||
miners_label_text.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
|
||||
|
||||
|
@ -13,6 +13,8 @@ local Difficulty = require 'modules.difficulty_vote_by_amount'
|
||||
local ICW_Func = require 'maps.mountain_fortress_v3.icw.functions'
|
||||
local math2d = require 'math2d'
|
||||
local Misc = require 'utils.commands.misc'
|
||||
local Core = require 'utils.core'
|
||||
local zone_settings = WPT.zone_settings
|
||||
|
||||
local this = {
|
||||
power_sources = {index = 1},
|
||||
@ -149,19 +151,6 @@ local function do_refill_turrets()
|
||||
end
|
||||
end
|
||||
|
||||
--[[ local function do_turret_energy()
|
||||
local power_sources = this.power_sources
|
||||
|
||||
for index = 1, #power_sources do
|
||||
local ps_data = power_sources[index]
|
||||
if not (ps_data and ps_data.valid) then
|
||||
fast_remove(power_sources, index)
|
||||
return
|
||||
end
|
||||
|
||||
ps_data.energy = 0xfffff
|
||||
end
|
||||
end ]]
|
||||
local function do_magic_crafters()
|
||||
local magic_crafters = this.magic_crafters
|
||||
local limit = #magic_crafters
|
||||
@ -171,7 +160,7 @@ local function do_magic_crafters()
|
||||
|
||||
local index = magic_crafters.index
|
||||
|
||||
for i = 1, magic_crafters_per_tick do
|
||||
for _ = 1, magic_crafters_per_tick do
|
||||
if index > limit then
|
||||
index = 1
|
||||
end
|
||||
@ -223,7 +212,7 @@ local function do_magic_fluid_crafters()
|
||||
|
||||
local index = magic_fluid_crafters.index
|
||||
|
||||
for i = 1, magic_fluid_crafters_per_tick do
|
||||
for _ = 1, magic_fluid_crafters_per_tick do
|
||||
if index > limit then
|
||||
index = 1
|
||||
end
|
||||
@ -367,7 +356,7 @@ local function add_magic_crafter_output(entity, output, distance)
|
||||
local fluidbox_index = output.fluidbox_index
|
||||
local data = {
|
||||
entity = entity,
|
||||
last_tick = round(game.tick),
|
||||
last_tick = game.tick,
|
||||
base_rate = round(rate, 8),
|
||||
rate = round(rate, 8),
|
||||
item = output.item,
|
||||
@ -442,7 +431,7 @@ Public.disable_minable_and_ICW_callback =
|
||||
function(entity)
|
||||
if entity and entity.valid then
|
||||
entity.minable = false
|
||||
ICW.register_wagon(entity, true)
|
||||
ICW.register_wagon(entity)
|
||||
end
|
||||
end
|
||||
)
|
||||
@ -546,10 +535,12 @@ Public.magic_item_crafting_callback =
|
||||
local force = game.forces.player
|
||||
|
||||
local tech = callback_data.tech
|
||||
if tech then
|
||||
if not force.technologies[tech].researched then
|
||||
entity.destroy()
|
||||
return
|
||||
if not callback_data.testing then
|
||||
if tech then
|
||||
if not force.technologies[tech].researched then
|
||||
entity.destroy()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -616,11 +607,13 @@ Public.magic_item_crafting_callback_weighted =
|
||||
local force = game.forces.player
|
||||
|
||||
local tech = stack.tech
|
||||
if tech then
|
||||
if force.technologies[tech] then
|
||||
if not force.technologies[tech].researched then
|
||||
entity.destroy()
|
||||
return
|
||||
if not callback_data.testing then
|
||||
if tech then
|
||||
if force.technologies[tech] then
|
||||
if not force.technologies[tech].researched then
|
||||
entity.destroy()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -799,12 +792,13 @@ local function calc_players()
|
||||
return #players
|
||||
end
|
||||
local total = 0
|
||||
for i = 1, #players do
|
||||
local player = players[i]
|
||||
if player.afk_time < 36000 then
|
||||
total = total + 1
|
||||
Core.iter_connected_players(
|
||||
function(player)
|
||||
if player.afk_time < 36000 then
|
||||
total = total + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
if total <= 0 then
|
||||
total = #players
|
||||
end
|
||||
@ -1103,8 +1097,8 @@ function Public.render_direction(surface)
|
||||
scale_with_zoom = false
|
||||
}
|
||||
|
||||
local x_min = -WPT.level_width / 2
|
||||
local x_max = WPT.level_width / 2
|
||||
local x_min = -zone_settings.zone_width / 2
|
||||
local x_max = zone_settings.zone_width / 2
|
||||
|
||||
surface.create_entity({name = 'electric-beam', position = {x_min, 74}, source = {x_min, 74}, target = {x_max, 74}})
|
||||
surface.create_entity({name = 'electric-beam', position = {x_min, 74}, source = {x_min, 74}, target = {x_max, 74}})
|
||||
@ -1139,57 +1133,22 @@ function Public.boost_difficulty()
|
||||
|
||||
local force = game.forces.player
|
||||
|
||||
if name == "I'm too young to die" then
|
||||
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 0.5
|
||||
force.character_running_speed_modifier = 0.15
|
||||
force.manual_crafting_speed_modifier = 0.15
|
||||
WPT.set('coin_amount', 1)
|
||||
WPT.set('upgrades').flame_turret.limit = 12
|
||||
WPT.set('upgrades').landmine.limit = 50
|
||||
WPT.set('locomotive_health', 10000)
|
||||
WPT.set('locomotive_max_health', 10000)
|
||||
WPT.set('bonus_xp_on_join', 500)
|
||||
WD.set('next_wave', game.tick + 3600 * 15)
|
||||
WPT.set('spidertron_unlocked_at_zone', 10)
|
||||
WD.set_normal_unit_current_health(1.0)
|
||||
WD.set_unit_health_increment_per_wave(0.15)
|
||||
WD.set_boss_unit_current_health(2)
|
||||
WD.set_boss_health_increment_per_wave(1.5)
|
||||
WPT.set('difficulty_set', true)
|
||||
elseif name == 'Hurt me plenty' then
|
||||
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 0.25
|
||||
force.character_running_speed_modifier = 0.1
|
||||
force.manual_crafting_speed_modifier = 0.1
|
||||
WPT.set('coin_amount', 2)
|
||||
WPT.set('upgrades').flame_turret.limit = 10
|
||||
WPT.set('upgrades').landmine.limit = 50
|
||||
WPT.set('locomotive_health', 7000)
|
||||
WPT.set('locomotive_max_health', 7000)
|
||||
WPT.set('bonus_xp_on_join', 300)
|
||||
WD.set('next_wave', game.tick + 3600 * 8)
|
||||
WPT.set('spidertron_unlocked_at_zone', 8)
|
||||
WD.set_normal_unit_current_health(1.6)
|
||||
WD.set_unit_health_increment_per_wave(0.5)
|
||||
WD.set_boss_unit_current_health(3)
|
||||
WD.set_boss_health_increment_per_wave(5)
|
||||
WPT.set('difficulty_set', true)
|
||||
elseif name == 'Ultra-violence' then
|
||||
force.character_running_speed_modifier = 0
|
||||
force.manual_crafting_speed_modifier = 0
|
||||
WPT.set('coin_amount', 4)
|
||||
WPT.set('upgrades').flame_turret.limit = 3
|
||||
WPT.set('upgrades').landmine.limit = 10
|
||||
WPT.set('locomotive_health', 5000)
|
||||
WPT.set('locomotive_max_health', 5000)
|
||||
WPT.set('bonus_xp_on_join', 50)
|
||||
WD.set('next_wave', game.tick + 3600 * 5)
|
||||
WPT.set('spidertron_unlocked_at_zone', 6)
|
||||
WD.set_normal_unit_current_health(2)
|
||||
WD.set_unit_health_increment_per_wave(1)
|
||||
WD.set_boss_unit_current_health(4)
|
||||
WD.set_boss_health_increment_per_wave(10)
|
||||
WPT.set('difficulty_set', true)
|
||||
end
|
||||
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 0.5
|
||||
force.character_running_speed_modifier = 0.15
|
||||
force.manual_crafting_speed_modifier = 0.15
|
||||
WPT.set('coin_amount', 1)
|
||||
WPT.set('upgrades').flame_turret.limit = 12
|
||||
WPT.set('upgrades').landmine.limit = 50
|
||||
WPT.set('locomotive_health', 10000)
|
||||
WPT.set('locomotive_max_health', 10000)
|
||||
WPT.set('bonus_xp_on_join', 500)
|
||||
WD.set('next_wave', game.tick + 3600 * 15)
|
||||
WPT.set('spidertron_unlocked_at_zone', 10)
|
||||
WD.set_normal_unit_current_health(1.0)
|
||||
WD.set_unit_health_increment_per_wave(0.15)
|
||||
WD.set_boss_unit_current_health(2)
|
||||
WD.set_boss_health_increment_per_wave(1.5)
|
||||
WPT.set('difficulty_set', true)
|
||||
end
|
||||
|
||||
function Public.set_spawn_position()
|
||||
@ -1325,10 +1284,10 @@ function Public.on_player_joined_game(event)
|
||||
end
|
||||
end
|
||||
|
||||
local top = player.gui.top
|
||||
if top['mod_gui_top_frame'] then
|
||||
top['mod_gui_top_frame'].destroy()
|
||||
end
|
||||
-- local top = player.gui.top
|
||||
-- if top['mod_gui_top_frame'] then
|
||||
-- top['mod_gui_top_frame'].destroy()
|
||||
-- end
|
||||
|
||||
if player.surface.index ~= active_surface_index then
|
||||
player.teleport(surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5), surface)
|
||||
@ -1556,6 +1515,5 @@ Event.add(defines.events.on_player_changed_position, on_player_changed_position)
|
||||
Event.add(defines.events.on_pre_player_left_game, on_pre_player_left_game)
|
||||
Event.add(defines.events.on_player_respawned, on_player_respawned)
|
||||
Event.on_nth_tick(10, tick)
|
||||
-- Event.on_nth_tick(5, do_turret_energy)
|
||||
|
||||
return Public
|
||||
|
@ -19,6 +19,7 @@ local tiles_per_call = 8
|
||||
local total_calls = ceil(1024 / tiles_per_call)
|
||||
local regen_decoratives = false
|
||||
local generate_map = Terrain.heavy_functions
|
||||
local winter_mode = false
|
||||
local wintery_type = {
|
||||
['simple-entity'] = true,
|
||||
['tree'] = true,
|
||||
@ -299,7 +300,6 @@ local function do_place_buildings(data)
|
||||
end
|
||||
|
||||
local function wintery(ent, extra_lights)
|
||||
local winter_mode = WPT.get('winter_mode')
|
||||
if not winter_mode then
|
||||
return false
|
||||
end
|
||||
|
@ -73,6 +73,12 @@ local noises = {
|
||||
{modifier = 0.05, weight = 0.23},
|
||||
{modifier = 0.1, weight = 0.11}
|
||||
},
|
||||
['scrapyard_modified'] = {
|
||||
{modifier = 0.006, weight = 1},
|
||||
{modifier = 0.04, weight = 0.15},
|
||||
{modifier = 0.22, weight = 0.05},
|
||||
{modifier = 0.05, weight = 0.32}
|
||||
},
|
||||
['big_cave'] = {
|
||||
{modifier = 0.003, weight = 1},
|
||||
{modifier = 0.02, weight = 0.05},
|
||||
|
@ -3,6 +3,7 @@ local RPG = require 'modules.rpg.main'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local IC_Gui = require 'maps.mountain_fortress_v3.ic.gui'
|
||||
local IC_Minimap = require 'maps.mountain_fortress_v3.ic.minimap'
|
||||
local Difficulty = require 'modules.difficulty_vote_by_amount'
|
||||
local Gui = require 'utils.gui'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
|
||||
@ -195,7 +196,7 @@ local function on_gui_click(event)
|
||||
if player.gui.top[main_frame_name] then
|
||||
local info = player.gui.top[main_frame_name]
|
||||
local wd = player.gui.top['wave_defense']
|
||||
local diff = player.gui.top['difficulty_gui']
|
||||
local diff = player.gui.top[Difficulty.top_button_name]
|
||||
|
||||
if info and info.visible then
|
||||
if wd then
|
||||
@ -256,7 +257,7 @@ local function on_player_changed_surface(event)
|
||||
local rpg_b = player.gui.top[rpg_button]
|
||||
local rpg_f = player.gui.screen[rpg_frame]
|
||||
local rpg_s = player.gui.screen[rpg_settings]
|
||||
local diff = player.gui.top['difficulty_gui']
|
||||
local diff = player.gui.top[Difficulty.top_button_name]
|
||||
local charging = player.gui.top['charging_station']
|
||||
local frame = player.gui.top[main_frame_name]
|
||||
local spell_gui_frame_name = RPG.spell_gui_frame_name
|
||||
@ -356,7 +357,7 @@ local function enable_guis(event)
|
||||
local info = player.gui.top[main_button_name]
|
||||
local wd = player.gui.top['wave_defense']
|
||||
local rpg_b = player.gui.top[rpg_button]
|
||||
local diff = player.gui.top['difficulty_gui']
|
||||
local diff = player.gui.top[Difficulty.top_button_name]
|
||||
local charging = player.gui.top['charging_station']
|
||||
|
||||
IC_Gui.remove_toolbar(player)
|
||||
@ -437,8 +438,7 @@ function Public.update_gui(player)
|
||||
gui.landmine.caption = ' [img=entity.land-mine]: ' .. format_number(upgrades.landmine.built, true) .. ' / ' .. format_number(upgrades.landmine.limit, true)
|
||||
gui.landmine.tooltip = ({'gui.land_mine_placed'})
|
||||
|
||||
gui.flame_turret.caption =
|
||||
' [img=entity.flamethrower-turret]: ' .. format_number(upgrades.flame_turret.built, true) .. ' / ' .. format_number(upgrades.flame_turret.limit, true)
|
||||
gui.flame_turret.caption = ' [img=entity.flamethrower-turret]: ' .. format_number(upgrades.flame_turret.built, true) .. ' / ' .. format_number(upgrades.flame_turret.limit, true)
|
||||
gui.flame_turret.tooltip = ({'gui.flamethrowers_placed'})
|
||||
|
||||
gui.train_upgrades.caption = ' [img=entity.locomotive]: ' .. format_number(train_upgrades, true)
|
||||
|
@ -2,14 +2,14 @@ local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
local Server = require 'utils.server'
|
||||
local Token = require 'utils.token'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local Score = require 'comfy_panel.score'
|
||||
local Gui = require 'utils.gui'
|
||||
local Score = require 'utils.gui.score'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local Core = require 'utils.core'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
|
||||
local module_name = 'Highscore'
|
||||
local module_name = Gui.uid_name()
|
||||
local score_dataset = 'highscores'
|
||||
local score_key = 'mountain_fortress_v3_scores'
|
||||
local set_data = Server.set_data
|
||||
@ -609,22 +609,18 @@ end
|
||||
local show_score_token = Token.register(show_score)
|
||||
|
||||
local function on_gui_click(event)
|
||||
if not event then
|
||||
return
|
||||
end
|
||||
if not event.element then
|
||||
return
|
||||
end
|
||||
if not event.element.valid then
|
||||
local element = event.element
|
||||
if not element or not element.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local player = game.players[event.element.player_index]
|
||||
local frame = Tabs.comfy_panel_get_active_frame(player)
|
||||
local player = game.get_player(event.element.player_index)
|
||||
|
||||
local frame = Gui.get_player_active_frame(player)
|
||||
if not frame then
|
||||
return
|
||||
end
|
||||
if frame.name ~= module_name then
|
||||
if frame.name ~= 'Highscore' then
|
||||
return
|
||||
end
|
||||
|
||||
@ -681,7 +677,15 @@ Server.on_data_set_changed(
|
||||
end
|
||||
)
|
||||
|
||||
Tabs.add_tab_to_gui({name = module_name, id = show_score_token, admin = false, only_server_sided = true})
|
||||
Gui.add_tab_to_gui({name = module_name, caption = 'Highscore', id = show_score_token, admin = false, only_server_sided = true})
|
||||
|
||||
Gui.on_click(
|
||||
module_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
Gui.reload_active_tab(player)
|
||||
end
|
||||
)
|
||||
|
||||
Event.on_init(on_init)
|
||||
Event.add(defines.events.on_player_left_game, on_player_left_game)
|
||||
|
@ -2,7 +2,7 @@ local ICT = require 'maps.mountain_fortress_v3.ic.table'
|
||||
local Functions = require 'maps.mountain_fortress_v3.ic.functions'
|
||||
local Color = require 'utils.color_presets'
|
||||
local Gui = require 'utils.gui'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local Tabs = require 'utils.gui'
|
||||
local Event = require 'utils.event'
|
||||
local Token = require 'utils.token'
|
||||
local Task = require 'utils.task'
|
||||
@ -464,7 +464,7 @@ local function toggle(player, recreate)
|
||||
if main_frame then
|
||||
remove_main_frame(main_frame)
|
||||
else
|
||||
Tabs.comfy_panel_clear_gui(player)
|
||||
Tabs.clear_all_active_frames(player)
|
||||
draw_main_frame(player)
|
||||
end
|
||||
end
|
||||
@ -813,10 +813,7 @@ Gui.on_click(
|
||||
|
||||
if not misc_settings[player.index].final_warning then
|
||||
misc_settings[player.index].final_warning = true
|
||||
player.print(
|
||||
'[IC] WARNING! WARNING WARNING! Pressing the save button ONE MORE TIME will DELETE your surface. This action is irreversible!',
|
||||
Color.red
|
||||
)
|
||||
player.print('[IC] WARNING! WARNING WARNING! Pressing the save button ONE MORE TIME will DELETE your surface. This action is irreversible!', Color.red)
|
||||
Task.set_timeout_in_ticks(600, clear_misc_settings, {player_index = player.index})
|
||||
return
|
||||
end
|
||||
|
@ -85,7 +85,7 @@ local function validate_player(player)
|
||||
return true
|
||||
end
|
||||
|
||||
local function property_boost(data)
|
||||
local function give_passive_xp(data)
|
||||
local xp_floating_text_color = {r = 188, g = 201, b = 63}
|
||||
local visuals_delay = 1800
|
||||
local loco_surface = WPT.get('loco_surface')
|
||||
@ -430,7 +430,7 @@ function Public.boost_players_around_train()
|
||||
locomotive_surface = locomotive_surface,
|
||||
rpg = rpg
|
||||
}
|
||||
property_boost(data)
|
||||
give_passive_xp(data)
|
||||
end
|
||||
|
||||
function Public.is_around_train(entity)
|
||||
|
@ -104,7 +104,7 @@ function Public.spawn_biter()
|
||||
target = this.locomotive_biter,
|
||||
target_offset = {0, -3.5},
|
||||
scale = 1.05,
|
||||
font = 'default-large-semibold',
|
||||
font = 'heading-2',
|
||||
color = {r = 175, g = 75, b = 255},
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
|
@ -19,6 +19,7 @@ local Public = {}
|
||||
local concat = table.concat
|
||||
|
||||
local main_frame_name = Gui.uid_name()
|
||||
local close_market_gui_name = Gui.uid_name()
|
||||
local random = math.random
|
||||
local round = math.round
|
||||
|
||||
@ -518,12 +519,14 @@ local function redraw_market_items(gui, player, search_text)
|
||||
return
|
||||
end
|
||||
|
||||
gui.add(
|
||||
local upgrades_label =
|
||||
gui.add(
|
||||
{
|
||||
type = 'label',
|
||||
caption = ({'locomotive.upgrades'})
|
||||
}
|
||||
)
|
||||
upgrades_label.style.font = 'heading-2'
|
||||
|
||||
local upgrade_table = gui.add({type = 'table', column_count = 6})
|
||||
|
||||
@ -550,6 +553,7 @@ local function redraw_market_items(gui, player, search_text)
|
||||
frame.add(
|
||||
{
|
||||
type = 'sprite-button',
|
||||
---@diagnostic disable-next-line: ambiguity-1
|
||||
sprite = data.sprite or 'item/' .. item,
|
||||
number = item_count,
|
||||
name = item,
|
||||
@ -573,12 +577,14 @@ local function redraw_market_items(gui, player, search_text)
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
gui.add(
|
||||
local items_label =
|
||||
gui.add(
|
||||
{
|
||||
type = 'label',
|
||||
caption = ({'locomotive.items'})
|
||||
}
|
||||
)
|
||||
items_label.style.font = 'heading-2'
|
||||
|
||||
local slider_value = ceil(players[player.index].data.slider.slider_value)
|
||||
local items_table = gui.add({type = 'table', column_count = 6})
|
||||
@ -606,6 +612,7 @@ local function redraw_market_items(gui, player, search_text)
|
||||
frame.add(
|
||||
{
|
||||
type = 'sprite-button',
|
||||
---@diagnostic disable-next-line: ambiguity-1
|
||||
sprite = data.sprite or 'item/' .. item,
|
||||
number = item_count,
|
||||
name = item,
|
||||
@ -793,31 +800,22 @@ local function gui_opened(event)
|
||||
if data.frame then
|
||||
data.frame = nil
|
||||
end
|
||||
local frame =
|
||||
player.gui.screen.add(
|
||||
{
|
||||
type = 'frame',
|
||||
caption = ({'locomotive.market_name'}),
|
||||
direction = 'vertical',
|
||||
name = main_frame_name
|
||||
}
|
||||
)
|
||||
|
||||
local frame, inside_table = Gui.add_main_frame_with_toolbar(player, 'screen', main_frame_name, nil, close_market_gui_name, 'Market')
|
||||
frame.auto_center = true
|
||||
|
||||
player.opened = frame
|
||||
frame.style.minimal_width = 325
|
||||
frame.style.minimal_height = 250
|
||||
|
||||
local search_table = frame.add({type = 'table', column_count = 2})
|
||||
search_table.add({type = 'label', caption = ({'locomotive.search_text'})})
|
||||
local search_table = inside_table.add({type = 'table', column_count = 2})
|
||||
local search_name = search_table.add({type = 'label', caption = ({'locomotive.search_text'})})
|
||||
search_name.style.font = 'heading-2'
|
||||
local search_text = search_table.add({type = 'textfield'})
|
||||
search_text.style.width = 140
|
||||
|
||||
add_space(frame)
|
||||
add_space(inside_table)
|
||||
|
||||
local pane =
|
||||
frame.add {
|
||||
inside_table.add {
|
||||
type = 'scroll-pane',
|
||||
direction = 'vertical',
|
||||
vertical_scroll_policy = 'always',
|
||||
@ -828,11 +826,11 @@ local function gui_opened(event)
|
||||
pane.style.minimal_height = 200
|
||||
pane.style.right_padding = 0
|
||||
|
||||
local flow = frame.add({type = 'flow'})
|
||||
local flow = inside_table.add({type = 'flow'})
|
||||
|
||||
add_space(flow)
|
||||
|
||||
local bottom_grid = frame.add({type = 'table', column_count = 4})
|
||||
local bottom_grid = inside_table.add({type = 'table', column_count = 4})
|
||||
bottom_grid.style.vertically_stretchable = false
|
||||
|
||||
local bg = bottom_grid.add({type = 'label', caption = ({'locomotive.quantity_text'})})
|
||||
@ -848,7 +846,7 @@ local function gui_opened(event)
|
||||
text_input.style.maximal_height = 28
|
||||
|
||||
local slider =
|
||||
frame.add(
|
||||
inside_table.add(
|
||||
{
|
||||
type = 'slider',
|
||||
minimum_value = 1,
|
||||
@ -859,7 +857,7 @@ local function gui_opened(event)
|
||||
slider.style.width = 115
|
||||
text_input.style.width = 60
|
||||
|
||||
local coinsleft = frame.add({type = 'flow'})
|
||||
local coinsleft = inside_table.add({type = 'flow'})
|
||||
|
||||
coinsleft.add(
|
||||
{
|
||||
@ -871,7 +869,7 @@ local function gui_opened(event)
|
||||
players[player.index].data.search_text = search_text
|
||||
players[player.index].data.text_input = text_input
|
||||
players[player.index].data.slider = slider
|
||||
players[player.index].data.frame = frame
|
||||
players[player.index].data.frame = inside_table
|
||||
players[player.index].data.item_frame = pane
|
||||
players[player.index].data.coins_left = coinsleft
|
||||
|
||||
@ -1480,6 +1478,17 @@ local function tick()
|
||||
end
|
||||
end
|
||||
|
||||
Gui.on_click(
|
||||
close_market_gui_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
if not player or not player.valid or not player.character then
|
||||
return
|
||||
end
|
||||
close_market_gui(player)
|
||||
end
|
||||
)
|
||||
|
||||
Event.on_nth_tick(5, tick)
|
||||
Event.add(defines.events.on_gui_click, gui_click)
|
||||
Event.add(defines.events.on_gui_value_changed, slider_changed)
|
||||
|
@ -72,6 +72,7 @@ local set_loco_tiles =
|
||||
|
||||
local p = {}
|
||||
|
||||
---@diagnostic disable-next-line: count-down-loop
|
||||
for x = position.x - 5, 1, 3 do
|
||||
for y = 1, position.y + 5, 2 do
|
||||
if random(1, 4) == 1 then
|
||||
|
@ -13,8 +13,8 @@ local Discord = require 'utils.discord'
|
||||
local IC = require 'maps.mountain_fortress_v3.ic.table'
|
||||
local ICMinimap = require 'maps.mountain_fortress_v3.ic.minimap'
|
||||
local Autostash = require 'modules.autostash'
|
||||
local Group = require 'comfy_panel.group'
|
||||
local PL = require 'comfy_panel.player_list'
|
||||
local Group = require 'utils.gui.group'
|
||||
local PL = require 'utils.gui.player_list'
|
||||
local CS = require 'maps.mountain_fortress_v3.surface'
|
||||
local Server = require 'utils.server'
|
||||
local Explosives = require 'modules.explosives'
|
||||
@ -29,14 +29,14 @@ local Event = require 'utils.event'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local Locomotive = require 'maps.mountain_fortress_v3.locomotive'
|
||||
local SpawnLocomotive = require 'maps.mountain_fortress_v3.locomotive.spawn_locomotive'
|
||||
local Score = require 'comfy_panel.score'
|
||||
local Poll = require 'comfy_panel.poll'
|
||||
local Score = require 'utils.gui.score'
|
||||
local Poll = require 'utils.gui.poll'
|
||||
local Collapse = require 'modules.collapse'
|
||||
local Difficulty = require 'modules.difficulty_vote_by_amount'
|
||||
local Task = require 'utils.task'
|
||||
local Token = require 'utils.token'
|
||||
local Alert = require 'utils.alert'
|
||||
local BottomFrame = require 'comfy_panel.bottom_frame'
|
||||
local BottomFrame = require 'utils.gui.bottom_frame'
|
||||
local AntiGrief = require 'utils.antigrief'
|
||||
local Misc = require 'utils.commands.misc'
|
||||
local Modifiers = require 'utils.player_modifiers'
|
||||
@ -174,8 +174,8 @@ function Public.reset_map()
|
||||
RPG.enable_flame_boots(true)
|
||||
RPG.personal_tax_rate(0.4)
|
||||
RPG.enable_stone_path(true)
|
||||
RPG.enable_one_punch(true)
|
||||
RPG.enable_one_punch_globally(false)
|
||||
RPG.enable_aoe_punch(true)
|
||||
RPG.enable_aoe_punch_globally(false)
|
||||
RPG.enable_range_buffs(true)
|
||||
RPG.enable_auto_allocate(true)
|
||||
RPG.disable_cooldowns_on_spells()
|
||||
@ -252,7 +252,7 @@ function Public.reset_map()
|
||||
Collapse.set_kill_specific_entities(collapse_kill)
|
||||
Collapse.set_speed(8)
|
||||
Collapse.set_amount(1)
|
||||
-- Collapse.set_max_line_size(WPT.level_width)
|
||||
-- Collapse.set_max_line_size(zone_settings.zone_width)
|
||||
Collapse.set_max_line_size(540)
|
||||
Collapse.set_surface(surface)
|
||||
Collapse.set_position({0, 130})
|
||||
@ -313,7 +313,8 @@ end
|
||||
|
||||
local is_player_valid = function()
|
||||
local players = game.connected_players
|
||||
for _, player in pairs(players) do
|
||||
for i = 1, #players do
|
||||
local player = players[i]
|
||||
if player.connected and player.controller_type == 2 then
|
||||
player.set_controller {type = defines.controllers.god}
|
||||
player.create_character()
|
||||
@ -467,9 +468,11 @@ end
|
||||
local on_tick = function()
|
||||
local update_gui = Gui_mf.update_gui
|
||||
local tick = game.tick
|
||||
local players = game.connected_players
|
||||
|
||||
if tick % 40 == 0 then
|
||||
for _, player in pairs(game.connected_players) do
|
||||
for i = 1, #players do
|
||||
local player = players[i]
|
||||
update_gui(player)
|
||||
end
|
||||
lock_locomotive_positions()
|
||||
@ -537,5 +540,24 @@ end
|
||||
Event.on_nth_tick(10, on_tick)
|
||||
Event.on_init(on_init)
|
||||
Event.add(WPT.events.reset_map, Public.reset_map)
|
||||
Event.add(
|
||||
defines.events.on_sector_scanned,
|
||||
function(event)
|
||||
local radar = event.radar
|
||||
if not radar or not radar.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local radars_reveal_new_chunks = WPT.get('radars_reveal_new_chunks')
|
||||
if radars_reveal_new_chunks then
|
||||
return
|
||||
end
|
||||
|
||||
local pos = event.chunk_position
|
||||
|
||||
radar.force.cancel_charting(radar.surface.index)
|
||||
radar.force.unchart_chunk(pos, radar.surface.index)
|
||||
end
|
||||
)
|
||||
|
||||
return Public
|
||||
|
@ -177,7 +177,7 @@ local function create_particles(surface, name, position, amount, cause_position)
|
||||
d2 = (cause_position.y - position.y) * 0.025
|
||||
end
|
||||
|
||||
for i = 1, amount, 1 do
|
||||
for _ = 1, amount, 1 do
|
||||
local m = random(4, 10)
|
||||
local m2 = m * 0.005
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
local Color = require 'utils.color_presets'
|
||||
local Event = require 'utils.event'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local RPG = require 'modules.rpg.main'
|
||||
local Alert = require 'utils.alert'
|
||||
local Task = require 'utils.task'
|
||||
@ -157,7 +156,6 @@ local item_worths = {
|
||||
['explosive-uranium-cannon-shell'] = 64,
|
||||
['rocket'] = 8,
|
||||
['explosive-rocket'] = 8,
|
||||
['atomic-bomb'] = 16384,
|
||||
['flamethrower-ammo'] = 32,
|
||||
['grenade'] = 16,
|
||||
['cluster-grenade'] = 64,
|
||||
@ -266,17 +264,6 @@ local function roll_item_stacks(remaining_budget, max_slots, blacklist)
|
||||
return item_stack_set, item_stack_set_worth
|
||||
end
|
||||
|
||||
local pause_wd_token =
|
||||
Token.register(
|
||||
function()
|
||||
WD.pause(false)
|
||||
local mc_rewards = WPT.get('mc_rewards')
|
||||
mc_rewards.temp_boosts.wave_defense = nil
|
||||
local message = ({'locomotive.wd_resumed'})
|
||||
Alert.alert_all_players(15, message, nil, 'achievement/tech-maniac')
|
||||
end
|
||||
)
|
||||
|
||||
local restore_mining_speed_token =
|
||||
Token.register(
|
||||
function()
|
||||
@ -380,19 +367,6 @@ local mc_random_rewards = {
|
||||
end),
|
||||
512
|
||||
},
|
||||
{
|
||||
name = 'Inventory Bonus',
|
||||
color = {r = 0.00, g = 0.00, b = 0.25},
|
||||
tooltip = 'Selecting this will grant the team permanent inventory bonus!',
|
||||
func = (function(player)
|
||||
local force = game.forces.player
|
||||
force.character_inventory_slots_bonus = force.character_inventory_slots_bonus + 1
|
||||
local message = ({'locomotive.inventory_bonus', player.name})
|
||||
Alert.alert_all_players(15, message, nil, 'achievement/tech-maniac')
|
||||
return true
|
||||
end),
|
||||
512
|
||||
},
|
||||
{
|
||||
name = 'Heal Locomotive',
|
||||
color = {r = 0.00, g = 0.00, b = 0.25},
|
||||
@ -405,26 +379,6 @@ local mc_random_rewards = {
|
||||
return true
|
||||
end),
|
||||
256
|
||||
},
|
||||
{
|
||||
name = 'Wave Defense',
|
||||
str = 'wave_defense',
|
||||
color = {r = 0.35, g = 0.00, b = 0.00},
|
||||
tooltip = 'Selecting this will pause the wave defense for 5 minutes. Ideal if you want to take a break!',
|
||||
func = (function(player)
|
||||
local mc_rewards = WPT.get('mc_rewards')
|
||||
if mc_rewards.temp_boosts.wave_defense then
|
||||
return false, '[Rewards] Wave Defense break is already applied. Please choose another reward.'
|
||||
end
|
||||
mc_rewards.temp_boosts.wave_defense = true
|
||||
|
||||
WD.pause(true)
|
||||
Task.set_timeout_in_ticks(18000, pause_wd_token)
|
||||
local message = ({'locomotive.wd_paused', player.name})
|
||||
Alert.alert_all_players(15, message, nil, 'achievement/tech-maniac')
|
||||
return true
|
||||
end),
|
||||
64
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,11 +8,24 @@ local types = {
|
||||
'furnace'
|
||||
}
|
||||
|
||||
local testing = false
|
||||
|
||||
local testing_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'speed-module-2',
|
||||
tech = 'speed-module-2',
|
||||
output = {item = 'speed-module-2', min_rate = 1 / 8 / 60 / 2, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 4
|
||||
}
|
||||
}
|
||||
|
||||
local science_loot = {
|
||||
{
|
||||
stack = {
|
||||
recipe = 'automation-science-pack',
|
||||
output = {item = 'automation-science-pack', min_rate = 0.5 / 8 / 60, distance_factor = 1 / 5 / 60 / 512}
|
||||
output = {item = 'automation-science-pack', min_rate = 3 / 800, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 4
|
||||
},
|
||||
@ -20,7 +33,7 @@ local science_loot = {
|
||||
stack = {
|
||||
recipe = 'logistic-science-pack',
|
||||
tech = 'logistic-science-pack',
|
||||
output = {item = 'logistic-science-pack', min_rate = 0.5 / 8 / 60, distance_factor = 1 / 15 / 60 / 512}
|
||||
output = {item = 'logistic-science-pack', min_rate = 2 / 800, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 2
|
||||
}
|
||||
@ -31,21 +44,21 @@ local ammo_loot = {
|
||||
stack = {
|
||||
recipe = 'piercing-rounds-magazine',
|
||||
tech = 'military-2',
|
||||
output = {item = 'piercing-rounds-magazine', min_rate = 1 / 2 / 60, distance_factor = 1 / 10 / 60 / 512}
|
||||
output = {item = 'piercing-rounds-magazine', min_rate = 1 / 800, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 1
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'firearm-magazine',
|
||||
output = {item = 'firearm-magazine', min_rate = 1 / 2 / 60, distance_factor = 1 / 4 / 60 / 512}
|
||||
output = {item = 'firearm-magazine', min_rate = 2 / 800, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 4
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'shotgun-shell',
|
||||
output = {item = 'shotgun-shell', min_rate = 1 / 2 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
output = {item = 'shotgun-shell', min_rate = 2 / 800, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 4
|
||||
},
|
||||
@ -53,7 +66,7 @@ local ammo_loot = {
|
||||
stack = {
|
||||
recipe = 'uranium-rounds-magazine',
|
||||
tech = 'uranium-ammo',
|
||||
output = {item = 'uranium-rounds-magazine', min_rate = 0.1 / 8 / 60, distance_factor = 1 / 25 / 60 / 512}
|
||||
output = {item = 'uranium-rounds-magazine', min_rate = 2 / 1800, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 0.25
|
||||
}
|
||||
@ -66,7 +79,7 @@ local oil_loot = {
|
||||
tech = 'oil-processing',
|
||||
output = {
|
||||
min_rate = 1 / 60,
|
||||
distance_factor = 1 / 10 / 60 / 512,
|
||||
distance_factor = 1 / 8 / 60 / 20480,
|
||||
item = 'petroleum-gas',
|
||||
fluidbox_index = 2
|
||||
}
|
||||
@ -78,9 +91,9 @@ local oil_loot = {
|
||||
recipe = 'advanced-oil-processing',
|
||||
tech = 'advanced-oil-processing',
|
||||
output = {
|
||||
{min_rate = 0.7 / 60, distance_factor = 3.125 / 60 / 512, item = 'heavy-oil', fluidbox_index = 3},
|
||||
{min_rate = 0.82 / 60, distance_factor = 5.625 / 60 / 512, item = 'light-oil', fluidbox_index = 4},
|
||||
{min_rate = 0.83 / 60, distance_factor = 6.875 / 60 / 512, item = 'petroleum-gas', fluidbox_index = 5}
|
||||
{min_rate = 0.7 / 60, distance_factor = 1 / 8 / 60 / 20480, item = 'heavy-oil', fluidbox_index = 3},
|
||||
{min_rate = 0.82 / 60, distance_factor = 1 / 8 / 60 / 20480, item = 'light-oil', fluidbox_index = 4},
|
||||
{min_rate = 0.83 / 60, distance_factor = 1 / 8 / 60 / 20480, item = 'petroleum-gas', fluidbox_index = 5}
|
||||
}
|
||||
},
|
||||
weight = 0.1
|
||||
@ -95,7 +108,7 @@ local oil_prod_loot = {
|
||||
output = {
|
||||
item = 'lubricant',
|
||||
min_rate = 0.7 / 60,
|
||||
distance_factor = 1 / 10 / 60 / 512,
|
||||
distance_factor = 1 / 8 / 60 / 20480,
|
||||
fluidbox_index = 2
|
||||
}
|
||||
},
|
||||
@ -108,7 +121,7 @@ local oil_prod_loot = {
|
||||
output = {
|
||||
item = 'solid-fuel',
|
||||
min_rate = 0.7 / 60,
|
||||
distance_factor = 1 / 4 / 60 / 512
|
||||
distance_factor = 1 / 8 / 60 / 20480
|
||||
}
|
||||
},
|
||||
weight = 4
|
||||
@ -120,7 +133,7 @@ local oil_prod_loot = {
|
||||
output = {
|
||||
item = 'sulfuric-acid',
|
||||
min_rate = 0.8 / 60,
|
||||
distance_factor = 1 / 8 / 60 / 512,
|
||||
distance_factor = 1 / 8 / 60 / 20480,
|
||||
fluidbox_index = 2
|
||||
}
|
||||
},
|
||||
@ -133,7 +146,7 @@ local oil_prod_loot = {
|
||||
output = {
|
||||
item = 'battery',
|
||||
min_rate = 0.6 / 60,
|
||||
distance_factor = 1 / 25 / 60 / 512
|
||||
distance_factor = 1 / 8 / 60 / 20480
|
||||
}
|
||||
},
|
||||
weight = 0.75
|
||||
@ -145,7 +158,7 @@ local oil_prod_loot = {
|
||||
output = {
|
||||
item = 'sulfur',
|
||||
min_rate = 0.8 / 60,
|
||||
distance_factor = 1 / 25 / 60 / 512
|
||||
distance_factor = 1 / 8 / 60 / 20480
|
||||
}
|
||||
},
|
||||
weight = 0.55
|
||||
@ -157,7 +170,7 @@ local oil_prod_loot = {
|
||||
output = {
|
||||
item = 'plastic-bar',
|
||||
min_rate = 0.8 / 60,
|
||||
distance_factor = 1 / 25 / 60 / 512
|
||||
distance_factor = 1 / 8 / 60 / 20480
|
||||
}
|
||||
},
|
||||
weight = 0.25
|
||||
@ -169,7 +182,7 @@ local oil_prod_loot = {
|
||||
output = {
|
||||
item = 'explosives',
|
||||
min_rate = 0.8 / 60,
|
||||
distance_factor = 1 / 25 / 60 / 512
|
||||
distance_factor = 1 / 8 / 60 / 20480
|
||||
}
|
||||
},
|
||||
weight = 0.20
|
||||
@ -181,7 +194,7 @@ local resource_loot = {
|
||||
stack = {
|
||||
recipe = 'stone-wall',
|
||||
tech = 'stone-walls',
|
||||
output = {item = 'stone-wall', min_rate = 0.6 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
output = {item = 'stone-wall', min_rate = 0.6 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 10
|
||||
},
|
||||
@ -189,21 +202,21 @@ local resource_loot = {
|
||||
stack = {
|
||||
recipe = 'concrete',
|
||||
tech = 'concrete',
|
||||
output = {item = 'concrete', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
output = {item = 'concrete', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 6
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'iron-gear-wheel',
|
||||
output = {item = 'iron-gear-wheel', min_rate = 0.6 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
output = {item = 'iron-gear-wheel', min_rate = 0.6 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 12
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'inserter',
|
||||
output = {item = 'inserter', min_rate = 0.6 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
output = {item = 'inserter', min_rate = 0.6 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 12
|
||||
},
|
||||
@ -211,14 +224,14 @@ local resource_loot = {
|
||||
stack = {
|
||||
recipe = 'fast-inserter',
|
||||
tech = 'fast-inserter',
|
||||
output = {item = 'fast-inserter', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
output = {item = 'fast-inserter', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 4
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'electronic-circuit',
|
||||
output = {item = 'electronic-circuit', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
output = {item = 'electronic-circuit', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 2
|
||||
},
|
||||
@ -226,7 +239,7 @@ local resource_loot = {
|
||||
stack = {
|
||||
recipe = 'advanced-circuit',
|
||||
tech = 'advanced-electronics',
|
||||
output = {item = 'advanced-circuit', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
output = {item = 'advanced-circuit', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 1
|
||||
},
|
||||
@ -234,28 +247,28 @@ local resource_loot = {
|
||||
stack = {
|
||||
recipe = 'processing-unit',
|
||||
tech = 'advanced-electronics-2',
|
||||
output = {item = 'processing-unit', min_rate = 1 / 10 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
output = {item = 'processing-unit', min_rate = 1 / 10 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 2
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'transport-belt',
|
||||
output = {item = 'transport-belt', min_rate = 0.6 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
output = {item = 'transport-belt', min_rate = 0.6 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 8
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'underground-belt',
|
||||
output = {item = 'underground-belt', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
output = {item = 'underground-belt', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 8
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
recipe = 'small-electric-pole',
|
||||
output = {item = 'small-electric-pole', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
output = {item = 'small-electric-pole', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 8
|
||||
},
|
||||
@ -263,7 +276,7 @@ local resource_loot = {
|
||||
stack = {
|
||||
recipe = 'fast-transport-belt',
|
||||
tech = 'logistics-2',
|
||||
output = {item = 'fast-transport-belt', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
output = {item = 'fast-transport-belt', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 5
|
||||
},
|
||||
@ -271,7 +284,7 @@ local resource_loot = {
|
||||
stack = {
|
||||
recipe = 'fast-underground-belt',
|
||||
tech = 'logistics-2',
|
||||
output = {item = 'fast-underground-belt', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
output = {item = 'fast-underground-belt', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 5
|
||||
},
|
||||
@ -279,7 +292,7 @@ local resource_loot = {
|
||||
stack = {
|
||||
recipe = 'solar-panel',
|
||||
tech = 'solar-energy',
|
||||
output = {item = 'solar-panel', min_rate = 1 / 6 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
output = {item = 'solar-panel', min_rate = 1 / 15 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 3
|
||||
},
|
||||
@ -287,7 +300,7 @@ local resource_loot = {
|
||||
stack = {
|
||||
recipe = 'productivity-module',
|
||||
tech = 'productivity-module',
|
||||
output = {item = 'productivity-module', min_rate = 1 / 6 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
output = {item = 'productivity-module', min_rate = 1 / 10 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 0.9
|
||||
},
|
||||
@ -295,7 +308,7 @@ local resource_loot = {
|
||||
stack = {
|
||||
recipe = 'effectivity-module',
|
||||
tech = 'effectivity-module',
|
||||
output = {item = 'effectivity-module', min_rate = 1 / 6 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
output = {item = 'effectivity-module', min_rate = 1 / 10 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 0.9
|
||||
},
|
||||
@ -303,7 +316,7 @@ local resource_loot = {
|
||||
stack = {
|
||||
recipe = 'speed-module',
|
||||
tech = 'speed-module',
|
||||
output = {item = 'speed-module', min_rate = 1 / 6 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
output = {item = 'speed-module', min_rate = 1 / 10 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 0.8
|
||||
},
|
||||
@ -311,7 +324,7 @@ local resource_loot = {
|
||||
stack = {
|
||||
recipe = 'productivity-module-2',
|
||||
tech = 'productivity-module-2',
|
||||
output = {item = 'productivity-module-2', min_rate = 1 / 8 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
output = {item = 'productivity-module-2', min_rate = 1 / 15 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 0.5
|
||||
},
|
||||
@ -319,7 +332,7 @@ local resource_loot = {
|
||||
stack = {
|
||||
recipe = 'effectivity-module-2',
|
||||
tech = 'effectivity-module-2',
|
||||
output = {item = 'effectivity-module-2', min_rate = 1 / 8 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
output = {item = 'effectivity-module-2', min_rate = 1 / 15 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 0.5
|
||||
},
|
||||
@ -327,7 +340,7 @@ local resource_loot = {
|
||||
stack = {
|
||||
recipe = 'speed-module-2',
|
||||
tech = 'speed-module-2',
|
||||
output = {item = 'speed-module-2', min_rate = 1 / 8 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
output = {item = 'speed-module-2', min_rate = 1 / 15 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 0.5
|
||||
},
|
||||
@ -335,7 +348,7 @@ local resource_loot = {
|
||||
stack = {
|
||||
recipe = 'productivity-module-3',
|
||||
tech = 'productivity-module-3',
|
||||
output = {item = 'productivity-module-3', min_rate = 1 / 10 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
output = {item = 'productivity-module-3', min_rate = 1 / 20 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 0.25
|
||||
},
|
||||
@ -343,7 +356,7 @@ local resource_loot = {
|
||||
stack = {
|
||||
recipe = 'effectivity-module-3',
|
||||
tech = 'effectivity-module-3',
|
||||
output = {item = 'effectivity-module-3', min_rate = 1 / 10 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
output = {item = 'effectivity-module-3', min_rate = 1 / 20 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 0.25
|
||||
},
|
||||
@ -351,7 +364,7 @@ local resource_loot = {
|
||||
stack = {
|
||||
recipe = 'speed-module-3',
|
||||
tech = 'speed-module-3',
|
||||
output = {item = 'speed-module-3', min_rate = 1 / 10 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
output = {item = 'speed-module-3', min_rate = 1 / 20 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 0.10
|
||||
}
|
||||
@ -361,14 +374,14 @@ local furnace_loot = {
|
||||
{
|
||||
stack = {
|
||||
furance_item = 'iron-plate',
|
||||
output = {item = 'iron-plate', min_rate = 2.0 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
output = {item = 'iron-plate', min_rate = 2.0 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 4
|
||||
},
|
||||
{
|
||||
stack = {
|
||||
furance_item = 'copper-plate',
|
||||
output = {item = 'copper-plate', min_rate = 2.0 / 60, distance_factor = 1 / 6 / 60 / 512}
|
||||
output = {item = 'copper-plate', min_rate = 2.0 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 4
|
||||
},
|
||||
@ -376,12 +389,13 @@ local furnace_loot = {
|
||||
stack = {
|
||||
furance_item = 'steel-plate',
|
||||
tech = 'steel-processing',
|
||||
output = {item = 'steel-plate', min_rate = 1.0 / 60, distance_factor = 1 / 8 / 60 / 512}
|
||||
output = {item = 'steel-plate', min_rate = 1.0 / 60, distance_factor = 1 / 8 / 60 / 20480}
|
||||
},
|
||||
weight = 1
|
||||
}
|
||||
}
|
||||
|
||||
local testing_weights = Functions.prepare_weighted_loot(testing_loot)
|
||||
local science_weights = Functions.prepare_weighted_loot(science_loot)
|
||||
local building_weights = Functions.prepare_weighted_loot(ammo_loot)
|
||||
local oil_weights = Functions.prepare_weighted_loot(oil_loot)
|
||||
@ -389,6 +403,15 @@ local oil_prod_weights = Functions.prepare_weighted_loot(oil_prod_loot)
|
||||
local resource_weights = Functions.prepare_weighted_loot(resource_loot)
|
||||
local furnace_weights = Functions.prepare_weighted_loot(furnace_loot)
|
||||
|
||||
local testing_callback = {
|
||||
callback = Functions.magic_item_crafting_callback_weighted,
|
||||
data = {
|
||||
loot = testing_loot,
|
||||
weights = testing_weights,
|
||||
testing = true
|
||||
}
|
||||
}
|
||||
|
||||
local science_callback = {
|
||||
callback = Functions.magic_item_crafting_callback_weighted,
|
||||
data = {
|
||||
@ -437,6 +460,12 @@ local furnace_callback = {
|
||||
}
|
||||
}
|
||||
|
||||
local testing_list = {
|
||||
[1] = {name = 'assembling-machine-1', callback = testing_callback},
|
||||
[2] = {name = 'assembling-machine-2', callback = testing_callback},
|
||||
[3] = {name = 'assembling-machine-3', callback = testing_callback}
|
||||
}
|
||||
|
||||
local science_list = {
|
||||
[1] = {name = 'assembling-machine-1', callback = science_callback},
|
||||
[2] = {name = 'assembling-machine-2', callback = science_callback},
|
||||
@ -469,6 +498,19 @@ local furnace_list = {
|
||||
[3] = {name = 'electric-furnace', callback = furnace_callback}
|
||||
}
|
||||
|
||||
local function spawn_testing_buildings(entities, p, probability)
|
||||
local callback = testing_list[probability].callback
|
||||
|
||||
entities[#entities + 1] = {
|
||||
name = testing_list[probability].name,
|
||||
position = p,
|
||||
force = 'neutral',
|
||||
callback = callback,
|
||||
collision = true,
|
||||
e_type = types
|
||||
}
|
||||
end
|
||||
|
||||
local function spawn_science_buildings(entities, p, probability)
|
||||
local callback = science_list[probability].callback
|
||||
|
||||
@ -556,6 +598,12 @@ local buildings = {
|
||||
[6] = spawn_oil_prod_buildings
|
||||
}
|
||||
|
||||
if testing then
|
||||
buildings = {
|
||||
[1] = spawn_testing_buildings
|
||||
}
|
||||
end
|
||||
|
||||
local function spawn_random_buildings(entities, p, depth)
|
||||
local randomizer = random(1, #buildings)
|
||||
local low = random(1, 2)
|
||||
|
@ -2,6 +2,7 @@ local Global = require 'utils.global'
|
||||
local surface_name = 'mountain_fortress_v3'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local Reset = require 'maps.mountain_fortress_v3.soft_reset'
|
||||
local zone_settings = WPT.zone_settings
|
||||
|
||||
local Public = {}
|
||||
|
||||
@ -22,7 +23,7 @@ local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['rail'] = 16
|
||||
function Public.create_surface()
|
||||
local map_gen_settings = {
|
||||
['seed'] = math.random(10000, 99999),
|
||||
['width'] = WPT.level_width,
|
||||
['width'] = zone_settings.zone_width,
|
||||
['water'] = 0.001,
|
||||
['starting_area'] = 1,
|
||||
['cliff_settings'] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0},
|
||||
|
@ -17,8 +17,10 @@ Global.register(
|
||||
end
|
||||
)
|
||||
|
||||
Public.level_depth = 704
|
||||
Public.level_width = 510
|
||||
Public.zone_settings = {
|
||||
zone_depth = 704,
|
||||
zone_width = 510
|
||||
}
|
||||
|
||||
Public.pickaxe_upgrades = {
|
||||
'Wood',
|
||||
@ -167,10 +169,9 @@ function Public.reset_table()
|
||||
this.chests_linked_to = {}
|
||||
this.chest_limit_outside_upgrades = 1
|
||||
this.placed_trains_in_zone = {
|
||||
placed = 0,
|
||||
positions = {},
|
||||
limit = 2,
|
||||
randomized = false
|
||||
randomized = false,
|
||||
zones = {}
|
||||
}
|
||||
this.marked_fixed_prices = {
|
||||
chest_limit_cost = 3000,
|
||||
@ -226,7 +227,14 @@ function Public.reset_table()
|
||||
current = {},
|
||||
temp_boosts = {}
|
||||
}
|
||||
this.adjusted_zones = {
|
||||
scrap = {},
|
||||
forest = {},
|
||||
size = nil,
|
||||
shuffled_zones = nil
|
||||
}
|
||||
this.alert_zone_1 = false -- alert the players
|
||||
this.radars_reveal_new_chunks = false -- allows for the player to explore the map instead
|
||||
|
||||
for k, _ in pairs(this.players) do
|
||||
this.players[k] = {}
|
||||
@ -264,10 +272,6 @@ function Public.remove(key, sub_key)
|
||||
end
|
||||
end
|
||||
|
||||
local on_init = function()
|
||||
Public.reset_table()
|
||||
end
|
||||
|
||||
Event.on_init(on_init)
|
||||
Event.on_init(Public.reset_table)
|
||||
|
||||
return Public
|
||||
|
@ -11,17 +11,9 @@ local abs = math.abs
|
||||
local floor = math.floor
|
||||
local ceil = math.ceil
|
||||
|
||||
Public.level_depth = WPT.level_depth
|
||||
Public.level_width = WPT.level_width
|
||||
local zone_settings = WPT.zone_settings
|
||||
local worm_level_modifier = 0.19
|
||||
|
||||
-- local start_ground_tiles = {
|
||||
-- 'dirt-1',
|
||||
-- 'grass-1',
|
||||
-- 'grass-2',
|
||||
-- 'dirt-2'
|
||||
-- }
|
||||
|
||||
local wagon_raffle = {
|
||||
'cargo-wagon',
|
||||
'cargo-wagon',
|
||||
@ -133,6 +125,15 @@ local function get_scrap_mineable_entities()
|
||||
return scrap_mineable_entities, scrap_mineable_entities_index
|
||||
end
|
||||
|
||||
local function shuffle(tbl)
|
||||
local size = #tbl
|
||||
for i = size, 1, -1 do
|
||||
local rand = random(size)
|
||||
tbl[i], tbl[rand] = tbl[rand], tbl[i]
|
||||
end
|
||||
return tbl
|
||||
end
|
||||
|
||||
local function is_position_near(area, table_to_check)
|
||||
local status = false
|
||||
local function inside(pos)
|
||||
@ -143,7 +144,7 @@ local function is_position_near(area, table_to_check)
|
||||
end
|
||||
|
||||
for i = 1, #table_to_check do
|
||||
if inside(table_to_check[i], area) then
|
||||
if inside(table_to_check[i]) then
|
||||
status = true
|
||||
end
|
||||
end
|
||||
@ -151,7 +152,7 @@ local function is_position_near(area, table_to_check)
|
||||
return status
|
||||
end
|
||||
|
||||
local function place_wagon(data)
|
||||
local function place_wagon(data, adjusted_zones)
|
||||
local placed_trains_in_zone = WPT.get('placed_trains_in_zone')
|
||||
if not placed_trains_in_zone.randomized then
|
||||
placed_trains_in_zone.limit = random(1, 2)
|
||||
@ -159,7 +160,33 @@ local function place_wagon(data)
|
||||
placed_trains_in_zone = WPT.get('placed_trains_in_zone')
|
||||
end
|
||||
|
||||
if placed_trains_in_zone.placed >= placed_trains_in_zone.limit then
|
||||
if not data.new_zone then
|
||||
data.new_zone = 1
|
||||
end
|
||||
|
||||
if data.new_zone == adjusted_zones.size then
|
||||
data.new_zone = 1
|
||||
end
|
||||
|
||||
if data.current_zone == adjusted_zones.size then
|
||||
local new_zone = placed_trains_in_zone.zones[data.new_zone]
|
||||
if new_zone then
|
||||
new_zone.placed = 0
|
||||
new_zone.positions = {}
|
||||
data.new_zone = data.new_zone + 1
|
||||
end
|
||||
end
|
||||
|
||||
local zone = placed_trains_in_zone.zones[data.current_zone]
|
||||
if not zone then
|
||||
placed_trains_in_zone.zones[data.current_zone] = {
|
||||
placed = 0,
|
||||
positions = {}
|
||||
}
|
||||
zone = placed_trains_in_zone.zones[data.current_zone]
|
||||
end
|
||||
|
||||
if zone.placed >= placed_trains_in_zone.limit then
|
||||
return
|
||||
end
|
||||
|
||||
@ -182,12 +209,13 @@ local function place_wagon(data)
|
||||
right_bottom = {x = position.x + radius, y = position.y + radius}
|
||||
}
|
||||
|
||||
if is_position_near(area, placed_trains_in_zone.positions) then
|
||||
if is_position_near(area, zone.positions) then
|
||||
return
|
||||
end
|
||||
|
||||
local location
|
||||
local direction
|
||||
|
||||
local r1 = random(2, 4) * 2
|
||||
local r2 = random(2, 4) * 2
|
||||
|
||||
@ -199,7 +227,7 @@ local function place_wagon(data)
|
||||
direction = 2
|
||||
end
|
||||
|
||||
for k, tile in pairs(location) do
|
||||
for _, tile in pairs(location) do
|
||||
tiles[#tiles + 1] = {name = 'nuclear-ground', position = tile.position}
|
||||
if tile.position.y % 1 == 0 and tile.position.x % 1 == 0 then
|
||||
entities[#entities + 1] = {
|
||||
@ -217,8 +245,9 @@ local function place_wagon(data)
|
||||
force = 'player',
|
||||
callback = wagon_mineable
|
||||
}
|
||||
placed_trains_in_zone.placed = placed_trains_in_zone.placed + 1
|
||||
placed_trains_in_zone.positions[#placed_trains_in_zone.positions + 1] = position
|
||||
|
||||
zone.placed = zone.placed + 1
|
||||
zone.positions[#zone.positions + 1] = position
|
||||
|
||||
return true
|
||||
end
|
||||
@ -313,16 +342,10 @@ local function wall(p, data)
|
||||
callback = stone_wall
|
||||
}
|
||||
if not alert_zone_1 then
|
||||
local x_min = -WPT.level_width / 2
|
||||
local x_max = WPT.level_width / 2
|
||||
WPT.set(
|
||||
'zone1_beam1',
|
||||
surface.create_entity({name = 'electric-beam', position = {x_min, p.y}, source = {x_min, p.y}, target = {x_max, p.y}})
|
||||
)
|
||||
WPT.set(
|
||||
'zone1_beam2',
|
||||
surface.create_entity({name = 'electric-beam', position = {x_min, p.y}, source = {x_min, p.y}, target = {x_max, p.y}})
|
||||
)
|
||||
local x_min = -zone_settings.zone_width / 2
|
||||
local x_max = zone_settings.zone_width / 2
|
||||
WPT.set('zone1_beam1', surface.create_entity({name = 'electric-beam', position = {x_min, p.y}, source = {x_min, p.y}, target = {x_max, p.y}}))
|
||||
WPT.set('zone1_beam2', surface.create_entity({name = 'electric-beam', position = {x_min, p.y}, source = {x_min, p.y}, target = {x_max, p.y}}))
|
||||
WPT.set('alert_zone_1', true)
|
||||
WPT.set(
|
||||
'zone1_text1',
|
||||
@ -399,36 +422,36 @@ local function wall(p, data)
|
||||
end
|
||||
|
||||
if random(1, 25) == 1 then
|
||||
if abs(p.y) < Public.level_depth * 1.5 then
|
||||
if abs(p.y) < zone_settings.zone_depth * 1.5 then
|
||||
if random(1, 16) == 1 then
|
||||
spawn_turret(entities, p, 1)
|
||||
else
|
||||
spawn_turret(entities, p, 2)
|
||||
end
|
||||
elseif abs(p.y) < Public.level_depth * 2.5 then
|
||||
elseif abs(p.y) < zone_settings.zone_depth * 2.5 then
|
||||
if random(1, 8) == 1 then
|
||||
spawn_turret(entities, p, 3)
|
||||
end
|
||||
elseif abs(p.y) < Public.level_depth * 3.5 then
|
||||
elseif abs(p.y) < zone_settings.zone_depth * 3.5 then
|
||||
if random(1, 4) == 1 then
|
||||
spawn_turret(entities, p, 4)
|
||||
else
|
||||
spawn_turret(entities, p, 3)
|
||||
end
|
||||
elseif abs(p.y) < Public.level_depth * 4.5 then
|
||||
elseif abs(p.y) < zone_settings.zone_depth * 4.5 then
|
||||
if random(1, 4) == 1 then
|
||||
spawn_turret(entities, p, 4)
|
||||
else
|
||||
spawn_turret(entities, p, 5)
|
||||
end
|
||||
elseif abs(p.y) < Public.level_depth * 5.5 then
|
||||
elseif abs(p.y) < zone_settings.zone_depth * 5.5 then
|
||||
if random(1, 4) == 1 then
|
||||
spawn_turret(entities, p, 4)
|
||||
elseif random(1, 2) == 1 then
|
||||
spawn_turret(entities, p, 5)
|
||||
end
|
||||
end
|
||||
elseif abs(p.y) > Public.level_depth * 5.5 then
|
||||
elseif abs(p.y) > zone_settings.zone_depth * 5.5 then
|
||||
if random(1, 15) == 1 then
|
||||
spawn_turret(entities, p, random(3, enable_arties))
|
||||
end
|
||||
@ -436,7 +459,7 @@ local function wall(p, data)
|
||||
end
|
||||
end
|
||||
|
||||
local function process_level_14_position(x, y, data)
|
||||
local function zone_14(x, y, data, _, adjusted_zones)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -451,7 +474,7 @@ local function process_level_14_position(x, y, data)
|
||||
--Resource Spots
|
||||
if smol_areas < -0.71 then
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
end
|
||||
|
||||
@ -488,7 +511,7 @@ local function process_level_14_position(x, y, data)
|
||||
|
||||
if small_caves > -0.41 and small_caves < 0.41 then
|
||||
if noise_cave_ponds > 0.35 then
|
||||
local success = place_wagon(data)
|
||||
local success = place_wagon(data, adjusted_zones)
|
||||
if success then
|
||||
return
|
||||
end
|
||||
@ -516,7 +539,7 @@ local function process_level_14_position(x, y, data)
|
||||
tiles[#tiles + 1] = {name = 'water-shallow', position = p}
|
||||
end
|
||||
|
||||
local function process_level_13_position(x, y, data)
|
||||
local function zone_13(x, y, data, _, adjusted_zones)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -531,7 +554,7 @@ local function process_level_13_position(x, y, data)
|
||||
--Resource Spots
|
||||
if smol_areas < -0.72 then
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
end
|
||||
|
||||
@ -568,7 +591,7 @@ local function process_level_13_position(x, y, data)
|
||||
|
||||
if small_caves > -0.40 and small_caves < 0.40 then
|
||||
if noise_cave_ponds > 0.35 then
|
||||
local success = place_wagon(data)
|
||||
local success = place_wagon(data, adjusted_zones)
|
||||
if success then
|
||||
return
|
||||
end
|
||||
@ -596,7 +619,7 @@ local function process_level_13_position(x, y, data)
|
||||
tiles[#tiles + 1] = {name = 'water-shallow', position = p}
|
||||
end
|
||||
|
||||
local function process_level_12_position(x, y, data, void_or_lab)
|
||||
local function zone_12(x, y, data, void_or_lab, adjusted_zones)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -612,7 +635,7 @@ local function process_level_12_position(x, y, data, void_or_lab)
|
||||
--Resource Spots
|
||||
if smol_areas < -0.72 then
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
end
|
||||
|
||||
@ -631,7 +654,7 @@ local function process_level_12_position(x, y, data, void_or_lab)
|
||||
end
|
||||
|
||||
if noise_1 < -0.72 then
|
||||
local success = place_wagon(data)
|
||||
local success = place_wagon(data, adjusted_zones)
|
||||
if success then
|
||||
return
|
||||
end
|
||||
@ -682,7 +705,7 @@ local function process_level_12_position(x, y, data, void_or_lab)
|
||||
tiles[#tiles + 1] = {name = 'tutorial-grid', position = p}
|
||||
end
|
||||
|
||||
local function process_level_11_position(x, y, data)
|
||||
local function zone_11(x, y, data, _, adjusted_zones)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -706,7 +729,7 @@ local function process_level_11_position(x, y, data)
|
||||
--Resource Spots
|
||||
if smol_areas < -0.72 then
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
end
|
||||
|
||||
@ -745,7 +768,7 @@ local function process_level_11_position(x, y, data)
|
||||
}
|
||||
end
|
||||
|
||||
local success = place_wagon(data)
|
||||
local success = place_wagon(data, adjusted_zones)
|
||||
if success then
|
||||
return
|
||||
end
|
||||
@ -778,7 +801,7 @@ local function process_level_11_position(x, y, data)
|
||||
end
|
||||
end
|
||||
|
||||
local function process_level_10_position(x, y, data)
|
||||
local function zone_10(x, y, data, _, adjusted_zones)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -804,7 +827,7 @@ local function process_level_10_position(x, y, data)
|
||||
--Resource Spots
|
||||
if smol_areas < -0.72 then
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
end
|
||||
|
||||
@ -822,7 +845,7 @@ local function process_level_10_position(x, y, data)
|
||||
return
|
||||
end
|
||||
if abs(scrapyard) > 0.25 and abs(scrapyard) < 0.40 then
|
||||
local success = place_wagon(data)
|
||||
local success = place_wagon(data, adjusted_zones)
|
||||
if success then
|
||||
return
|
||||
end
|
||||
@ -892,7 +915,7 @@ local function process_level_10_position(x, y, data)
|
||||
tiles[#tiles + 1] = {name = 'grass-2', position = p}
|
||||
end
|
||||
|
||||
local function process_level_9_position(x, y, data)
|
||||
local function zone_9(x, y, data, _, adjusted_zones)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -927,7 +950,7 @@ local function process_level_9_position(x, y, data)
|
||||
end
|
||||
|
||||
if maze_noise > 0 and maze_noise < 0.45 then
|
||||
local success = place_wagon(data)
|
||||
local success = place_wagon(data, adjusted_zones)
|
||||
if success then
|
||||
return
|
||||
end
|
||||
@ -946,7 +969,7 @@ local function process_level_9_position(x, y, data)
|
||||
--Resource Spots
|
||||
if smol_areas < -0.72 then
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
end
|
||||
|
||||
@ -965,13 +988,143 @@ local function process_level_9_position(x, y, data)
|
||||
end
|
||||
|
||||
--SCRAPYARD
|
||||
local function process_scrap_zone_1(x, y, data, void_or_lab)
|
||||
local function zone_scrap_2(x, y, data, void_or_lab, adjusted_zones)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
local entities = data.entities
|
||||
local buildings = data.buildings
|
||||
local treasure = data.treasure
|
||||
data.scrap_zone = true
|
||||
|
||||
local scrapyard_modified = get_perlin('scrapyard_modified', p, seed)
|
||||
local cave_rivers = get_perlin('cave_rivers', p, seed + 65030)
|
||||
|
||||
--Chasms
|
||||
local noise_cave_ponds = get_perlin('cave_ponds', p, seed)
|
||||
local small_caves = get_perlin('small_caves', p, seed)
|
||||
if noise_cave_ponds < 0.15 and noise_cave_ponds > -0.15 then
|
||||
if small_caves > 0.35 then
|
||||
tiles[#tiles + 1] = {name = void_or_lab, position = p}
|
||||
return
|
||||
end
|
||||
|
||||
if small_caves < -0.35 then
|
||||
tiles[#tiles + 1] = {name = void_or_lab, position = p}
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if scrapyard_modified < -0.25 or scrapyard_modified > 0.25 then
|
||||
if random(1, 256) == 1 then
|
||||
if random(1, 8) == 1 then
|
||||
spawn_turret(entities, p, 3)
|
||||
else
|
||||
spawn_turret(entities, p, 4)
|
||||
end
|
||||
if random(1, 2048) == 1 then
|
||||
treasure[#treasure + 1] = {position = p, chest = 'wooden-chest'}
|
||||
end
|
||||
end
|
||||
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
|
||||
if scrapyard_modified < -0.55 or scrapyard_modified > 0.55 then
|
||||
if random(1, 2) == 1 then
|
||||
entities[#entities + 1] = {name = rock_raffle[random(1, size_of_rock_raffle)], position = p}
|
||||
end
|
||||
return
|
||||
end
|
||||
if scrapyard_modified < -0.28 or scrapyard_modified > 0.28 then
|
||||
local success = place_wagon(data, adjusted_zones)
|
||||
if success then
|
||||
return
|
||||
end
|
||||
if random(1, 128) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
|
||||
entities[#entities + 1] = {
|
||||
name = Biters.wave_defense_roll_worm_name(),
|
||||
position = p,
|
||||
force = 'enemy',
|
||||
note = true
|
||||
}
|
||||
end
|
||||
if random(1, 96) == 1 then
|
||||
entities[#entities + 1] = {
|
||||
name = scrap_entities[random(1, scrap_entities_index)],
|
||||
position = p,
|
||||
force = 'enemy'
|
||||
}
|
||||
end
|
||||
if random(1, 96) == 1 then
|
||||
entities[#entities + 1] = {
|
||||
name = scrap_entities_friendly[random(1, scrap_entities_friendly_index)],
|
||||
position = p,
|
||||
force = 'neutral'
|
||||
}
|
||||
end
|
||||
|
||||
local scrap_mineable_entities, scrap_mineable_entities_index = get_scrap_mineable_entities()
|
||||
|
||||
if random(1, 5) > 1 then
|
||||
entities[#entities + 1] = {name = scrap_mineable_entities[random(1, scrap_mineable_entities_index)], position = p, force = 'neutral'}
|
||||
end
|
||||
|
||||
if random(1, 256) == 1 then
|
||||
entities[#entities + 1] = {name = 'land-mine', position = p, force = 'enemy'}
|
||||
end
|
||||
return
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local cave_ponds = get_perlin('cave_ponds', p, seed)
|
||||
if cave_ponds < -0.6 and scrapyard_modified > -0.2 and scrapyard_modified < 0.2 then
|
||||
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
|
||||
if random(1, 128) == 1 then
|
||||
entities[#entities + 1] = {name = 'fish', position = p}
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
--Resource Spots
|
||||
if cave_rivers < -0.72 then
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
end
|
||||
|
||||
local large_caves = get_perlin('large_caves', p, seed)
|
||||
if scrapyard_modified > -0.15 and scrapyard_modified < 0.15 then
|
||||
if floor(large_caves * 10) % 4 < 3 then
|
||||
tiles[#tiles + 1] = {name = 'dirt-7', position = p}
|
||||
if random(1, 2) == 1 then
|
||||
entities[#entities + 1] = {name = rock_raffle[random(1, size_of_rock_raffle)], position = p}
|
||||
end
|
||||
if random(1, 2048) == 1 then
|
||||
treasure[#treasure + 1] = {position = p, chest = 'wooden-chest'}
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if random(1, 64) == 1 and cave_ponds > 0.6 then
|
||||
entities[#entities + 1] = {name = 'crude-oil', position = p, amount = get_oil_amount(p)}
|
||||
end
|
||||
|
||||
tiles[#tiles + 1] = {name = 'nuclear-ground', position = p}
|
||||
if random(1, 256) == 1 then
|
||||
entities[#entities + 1] = {name = 'land-mine', position = p, force = 'enemy'}
|
||||
end
|
||||
end
|
||||
|
||||
--SCRAPYARD
|
||||
local function zone_scrap_1(x, y, data, void_or_lab, adjusted_zones)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
local entities = data.entities
|
||||
local buildings = data.buildings
|
||||
local treasure = data.treasure
|
||||
data.scrap_zone = true
|
||||
|
||||
local scrapyard = get_perlin('scrapyard', p, seed)
|
||||
local smol_areas = get_perlin('smol_areas', p, seed + 35000)
|
||||
@ -1010,7 +1163,7 @@ local function process_scrap_zone_1(x, y, data, void_or_lab)
|
||||
return
|
||||
end
|
||||
if scrapyard < -0.28 or scrapyard > 0.28 then
|
||||
local success = place_wagon(data)
|
||||
local success = place_wagon(data, adjusted_zones)
|
||||
if success then
|
||||
return
|
||||
end
|
||||
@ -1034,7 +1187,7 @@ local function process_scrap_zone_1(x, y, data, void_or_lab)
|
||||
entities[#entities + 1] = {
|
||||
name = scrap_entities_friendly[random(1, scrap_entities_friendly_index)],
|
||||
position = p,
|
||||
force = 'player'
|
||||
force = 'neutral'
|
||||
}
|
||||
end
|
||||
|
||||
@ -1064,7 +1217,7 @@ local function process_scrap_zone_1(x, y, data, void_or_lab)
|
||||
--Resource Spots
|
||||
if smol_areas < -0.72 then
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1092,7 +1245,7 @@ local function process_scrap_zone_1(x, y, data, void_or_lab)
|
||||
end
|
||||
end
|
||||
|
||||
local function process_level_7_position(x, y, data, void_or_lab)
|
||||
local function zone_7(x, y, data, void_or_lab, adjusted_zones)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -1152,7 +1305,7 @@ local function process_level_7_position(x, y, data, void_or_lab)
|
||||
if cave_rivers_4 > -0.20 and cave_rivers_4 < 0.20 then
|
||||
tiles[#tiles + 1] = {name = 'grass-' .. floor(cave_rivers_4 * 32) % 3 + 1, position = p}
|
||||
if cave_rivers_4 > -0.10 and cave_rivers_4 < 0.10 then
|
||||
local success = place_wagon(data)
|
||||
local success = place_wagon(data, adjusted_zones)
|
||||
if success then
|
||||
return
|
||||
end
|
||||
@ -1196,7 +1349,7 @@ local function process_level_7_position(x, y, data, void_or_lab)
|
||||
--Resource Spots
|
||||
if smol_areas < -0.72 then
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1209,7 +1362,7 @@ local function process_level_7_position(x, y, data, void_or_lab)
|
||||
end
|
||||
end
|
||||
|
||||
local function process_forest_zone_2(x, y, data, void_or_lab)
|
||||
local function zone_forest_2(x, y, data, void_or_lab, adjusted_zones)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -1217,6 +1370,7 @@ local function process_forest_zone_2(x, y, data, void_or_lab)
|
||||
local buildings = data.buildings
|
||||
local markets = data.markets
|
||||
local treasure = data.treasure
|
||||
data.forest_zone = true
|
||||
|
||||
local large_caves = get_perlin('large_caves', p, seed)
|
||||
local cave_rivers = get_perlin('cave_rivers', p, seed)
|
||||
@ -1249,7 +1403,7 @@ local function process_forest_zone_2(x, y, data, void_or_lab)
|
||||
if smol_areas < 0.055 and smol_areas > -0.025 then
|
||||
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
if random(1, 128) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
|
||||
@ -1265,7 +1419,7 @@ local function process_forest_zone_2(x, y, data, void_or_lab)
|
||||
end
|
||||
local noise_forest_location = get_perlin('forest_location', p, seed)
|
||||
if cave_rivers > -0.1 and cave_rivers < 0.1 then
|
||||
local success = place_wagon(data)
|
||||
local success = place_wagon(data, adjusted_zones)
|
||||
if success then
|
||||
return
|
||||
end
|
||||
@ -1344,7 +1498,7 @@ local function process_forest_zone_2(x, y, data, void_or_lab)
|
||||
end
|
||||
end
|
||||
|
||||
local function process_level_5_position(x, y, data, void_or_lab)
|
||||
local function zone_5(x, y, data, void_or_lab, adjusted_zones)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -1391,7 +1545,7 @@ local function process_level_5_position(x, y, data, void_or_lab)
|
||||
if smol_areas < 0.055 and smol_areas > -0.025 then
|
||||
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
if random(1, 128) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
|
||||
@ -1408,7 +1562,7 @@ local function process_level_5_position(x, y, data, void_or_lab)
|
||||
|
||||
if small_caves > -0.40 and small_caves < 0.40 then
|
||||
if noise_cave_ponds > 0.35 then
|
||||
local success = place_wagon(data)
|
||||
local success = place_wagon(data, adjusted_zones)
|
||||
if success then
|
||||
return
|
||||
end
|
||||
@ -1436,7 +1590,7 @@ local function process_level_5_position(x, y, data, void_or_lab)
|
||||
tiles[#tiles + 1] = {name = void_or_lab, position = p}
|
||||
end
|
||||
|
||||
local function process_level_4_position(x, y, data, void_or_lab)
|
||||
local function zone_4(x, y, data, void_or_lab, adjusted_zones)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -1479,7 +1633,7 @@ local function process_level_4_position(x, y, data, void_or_lab)
|
||||
note = true
|
||||
}
|
||||
end
|
||||
local success = place_wagon(data)
|
||||
local success = place_wagon(data, adjusted_zones)
|
||||
if success then
|
||||
return
|
||||
end
|
||||
@ -1527,7 +1681,7 @@ local function process_level_4_position(x, y, data, void_or_lab)
|
||||
if smol_areas < 0.055 and smol_areas > -0.025 then
|
||||
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
if random(1, 128) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
|
||||
@ -1567,7 +1721,7 @@ local function process_level_4_position(x, y, data, void_or_lab)
|
||||
tiles[#tiles + 1] = {name = void_or_lab, position = p}
|
||||
end
|
||||
|
||||
local function process_level_3_position(x, y, data, void_or_lab)
|
||||
local function zone_3(x, y, data, void_or_lab, adjusted_zones)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -1587,7 +1741,7 @@ local function process_level_3_position(x, y, data, void_or_lab)
|
||||
if smol_areas < 0.055 and smol_areas > -0.025 then
|
||||
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
if random(1, 128) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
|
||||
@ -1704,7 +1858,7 @@ local function process_level_3_position(x, y, data, void_or_lab)
|
||||
--Main Rock Terrain
|
||||
local no_rocks_2 = get_perlin('no_rocks_2', p, seed + 75000)
|
||||
if no_rocks_2 > 0.80 or no_rocks_2 < -0.80 then
|
||||
local success = place_wagon(data)
|
||||
local success = place_wagon(data, adjusted_zones)
|
||||
if success then
|
||||
return
|
||||
end
|
||||
@ -1733,7 +1887,7 @@ local function process_level_3_position(x, y, data, void_or_lab)
|
||||
end
|
||||
end
|
||||
|
||||
local function process_level_2_position(x, y, data, void_or_lab)
|
||||
local function zone_2(x, y, data, void_or_lab, adjusted_zones)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local tiles = data.tiles
|
||||
@ -1750,7 +1904,7 @@ local function process_level_2_position(x, y, data, void_or_lab)
|
||||
if smol_areas < 0.055 and smol_areas > -0.025 then
|
||||
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
if random(1, 128) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
|
||||
@ -1852,7 +2006,7 @@ local function process_level_2_position(x, y, data, void_or_lab)
|
||||
--Main Rock Terrain
|
||||
local no_rocks_2 = get_perlin('no_rocks_2', p, seed + 75000)
|
||||
if no_rocks_2 > 0.80 or no_rocks_2 < -0.80 then
|
||||
local success = place_wagon(data)
|
||||
local success = place_wagon(data, adjusted_zones)
|
||||
if success then
|
||||
return
|
||||
end
|
||||
@ -1877,7 +2031,7 @@ local function process_level_2_position(x, y, data, void_or_lab)
|
||||
tiles[#tiles + 1] = {name = void_or_lab, position = p}
|
||||
end
|
||||
|
||||
local function process_forest_zone_1(x, y, data, void_or_lab)
|
||||
local function zone_forest_1(x, y, data, void_or_lab, adjusted_zones)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local buildings = data.buildings
|
||||
@ -1885,6 +2039,7 @@ local function process_forest_zone_1(x, y, data, void_or_lab)
|
||||
local entities = data.entities
|
||||
local markets = data.markets
|
||||
local treasure = data.treasure
|
||||
data.forest_zone = true
|
||||
|
||||
local small_caves = get_perlin('dungeons', p, seed + 33322)
|
||||
local noise_cave_ponds = get_perlin('cave_ponds', p, seed)
|
||||
@ -1894,7 +2049,7 @@ local function process_forest_zone_1(x, y, data, void_or_lab)
|
||||
if smol_areas < 0.055 and smol_areas > -0.025 then
|
||||
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
if random(1, 128) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
|
||||
@ -1995,7 +2150,7 @@ local function process_forest_zone_1(x, y, data, void_or_lab)
|
||||
--Main Rock Terrain
|
||||
local no_rocks_2 = get_perlin('no_rocks_2', p, seed + 5000)
|
||||
if no_rocks_2 > 0.64 or no_rocks_2 < -0.64 then
|
||||
local success = place_wagon(data)
|
||||
local success = place_wagon(data, adjusted_zones)
|
||||
if success then
|
||||
return
|
||||
end
|
||||
@ -2060,7 +2215,7 @@ local function process_forest_zone_1(x, y, data, void_or_lab)
|
||||
end
|
||||
end
|
||||
|
||||
local function process_level_1_position(x, y, data, void_or_lab)
|
||||
local function zone_1(x, y, data, void_or_lab, adjusted_zones)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local buildings = data.buildings
|
||||
@ -2076,7 +2231,7 @@ local function process_level_1_position(x, y, data, void_or_lab)
|
||||
if smol_areas < 0.055 and smol_areas > -0.025 then
|
||||
tiles[#tiles + 1] = {name = 'deepwater-green', position = p}
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
if random(1, 32) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
|
||||
@ -2177,7 +2332,7 @@ local function process_level_1_position(x, y, data, void_or_lab)
|
||||
--Main Rock Terrain
|
||||
local no_rocks_2 = get_perlin('no_rocks_2', p, seed + 75000)
|
||||
if no_rocks_2 > 0.66 or no_rocks_2 < -0.66 then
|
||||
local success = place_wagon(data)
|
||||
local success = place_wagon(data, adjusted_zones)
|
||||
if success then
|
||||
return
|
||||
end
|
||||
@ -2224,7 +2379,7 @@ local function process_level_1_position(x, y, data, void_or_lab)
|
||||
end
|
||||
end
|
||||
|
||||
local function process_level_0_position(x, y, data, void_or_lab)
|
||||
local function starting_zone(x, y, data, void_or_lab, adjusted_zones)
|
||||
local p = {x = x, y = y}
|
||||
local seed = data.seed
|
||||
local buildings = data.buildings
|
||||
@ -2243,7 +2398,7 @@ local function process_level_0_position(x, y, data, void_or_lab)
|
||||
if smol_areas < 0.055 and smol_areas > -0.025 then
|
||||
entities[#entities + 1] = {name = rock_raffle[random(1, size_of_rock_raffle)], position = p}
|
||||
if random(1, 32) == 1 then
|
||||
Generate_resources(buildings, p, Public.level_depth)
|
||||
Generate_resources(buildings, p, zone_settings.zone_depth)
|
||||
end
|
||||
if random(1, 128) == 1 then
|
||||
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
|
||||
@ -2338,7 +2493,7 @@ local function process_level_0_position(x, y, data, void_or_lab)
|
||||
|
||||
--Main Rock Terrain
|
||||
if no_rocks_2 > 0.334 and no_rocks_2 < 0.544 then
|
||||
local success = place_wagon(data)
|
||||
local success = place_wagon(data, adjusted_zones)
|
||||
if success then
|
||||
return
|
||||
end
|
||||
@ -2362,31 +2517,37 @@ local function process_level_0_position(x, y, data, void_or_lab)
|
||||
end
|
||||
end
|
||||
|
||||
Public.levels = {
|
||||
process_level_0_position,
|
||||
process_level_1_position,
|
||||
process_forest_zone_1, -- zone 3
|
||||
process_level_3_position,
|
||||
process_level_5_position,
|
||||
process_scrap_zone_1, -- zone 6
|
||||
process_level_9_position,
|
||||
process_level_4_position,
|
||||
process_level_2_position,
|
||||
process_level_3_position,
|
||||
process_forest_zone_2, -- zone 11
|
||||
process_level_4_position,
|
||||
process_level_5_position,
|
||||
process_forest_zone_2, -- zone 14
|
||||
process_level_7_position,
|
||||
process_scrap_zone_1, -- zone 16
|
||||
process_level_9_position,
|
||||
process_level_10_position,
|
||||
process_level_11_position,
|
||||
process_level_12_position,
|
||||
process_level_13_position,
|
||||
process_level_14_position
|
||||
local zones = {
|
||||
['zone_1'] = zone_1,
|
||||
['zone_2'] = zone_2,
|
||||
['zone_3'] = zone_3,
|
||||
['zone_4'] = zone_4,
|
||||
['zone_5'] = zone_5,
|
||||
['zone_forest_1'] = zone_forest_1,
|
||||
['zone_forest_2'] = zone_forest_2,
|
||||
['zone_scrap_1'] = zone_scrap_1,
|
||||
['zone_scrap_2'] = zone_scrap_2,
|
||||
['zone_7'] = zone_7,
|
||||
['zone_9'] = zone_9,
|
||||
['zone_10'] = zone_10,
|
||||
['zone_11'] = zone_11,
|
||||
['zone_12'] = zone_12,
|
||||
['zone_13'] = zone_13,
|
||||
['zone_14'] = zone_14
|
||||
}
|
||||
|
||||
local function shuffle_terrains(adjusted_zones, new_zone)
|
||||
if not adjusted_zones.shuffled_terrains then
|
||||
shuffle(adjusted_zones.shuffled_zones)
|
||||
adjusted_zones.shuffled_terrains = new_zone
|
||||
end
|
||||
|
||||
-- if adjusted_zones.shuffled_terrains and adjusted_zones.shuffled_terrains ~= new_zone then
|
||||
-- table.shuffle_table(zones)
|
||||
-- adjusted_zones.shuffled_terrains = new_zone
|
||||
-- end
|
||||
end
|
||||
|
||||
local function is_out_of_map(p)
|
||||
if p.x < 480 and p.x >= -480 then
|
||||
return
|
||||
@ -2394,13 +2555,49 @@ local function is_out_of_map(p)
|
||||
return true
|
||||
end
|
||||
|
||||
local function process_bits(p, data)
|
||||
local levels = Public.levels
|
||||
local function init_terrain(adjusted_zones)
|
||||
if adjusted_zones.init_terrain then
|
||||
return
|
||||
end
|
||||
|
||||
local count = 1
|
||||
local shuffled_zones = {}
|
||||
|
||||
for zone_name, _ in pairs(zones) do
|
||||
shuffled_zones[count] = zone_name
|
||||
count = count + 1
|
||||
end
|
||||
|
||||
adjusted_zones.size = count
|
||||
adjusted_zones.shuffled_zones = shuffled_zones
|
||||
adjusted_zones.init_terrain = true
|
||||
end
|
||||
|
||||
local function process_bits(p, data, adjusted_zones)
|
||||
local left_top_y = data.area.left_top.y
|
||||
local index = floor((abs(left_top_y / Public.level_depth)) % 22) + 1
|
||||
local process_level = levels[index]
|
||||
if not process_level then
|
||||
process_level = levels[#levels]
|
||||
|
||||
local index = floor((abs(left_top_y / zone_settings.zone_depth)) % adjusted_zones.size) + 1
|
||||
|
||||
shuffle_terrains(adjusted_zones, index)
|
||||
|
||||
local generate_zone
|
||||
if left_top_y >= -zone_settings.zone_depth then
|
||||
generate_zone = starting_zone
|
||||
else
|
||||
generate_zone = zones[adjusted_zones.shuffled_zones[index]]
|
||||
if not generate_zone then
|
||||
generate_zone = zones[adjusted_zones.shuffled_zones[adjusted_zones.size]]
|
||||
end
|
||||
end
|
||||
|
||||
data.current_zone = index
|
||||
|
||||
if data.forest_zone and not adjusted_zones.forest[index] then
|
||||
adjusted_zones.forest[index] = true
|
||||
end
|
||||
|
||||
if data.scrap_zone and not adjusted_zones.scrap[index] then
|
||||
adjusted_zones.scrap[index] = true
|
||||
end
|
||||
|
||||
local void_or_tile = WPT.get('void_or_tile')
|
||||
@ -2408,7 +2605,7 @@ local function process_bits(p, data)
|
||||
local x = p.x
|
||||
local y = p.y
|
||||
|
||||
process_level(x, y, data, void_or_tile)
|
||||
generate_zone(x, y, data, void_or_tile, adjusted_zones)
|
||||
end
|
||||
|
||||
local function border_chunk(p, data)
|
||||
@ -2500,6 +2697,9 @@ function Public.heavy_functions(data)
|
||||
local p = data.position
|
||||
local get_tile = surface.get_tile(p)
|
||||
|
||||
local adjusted_zones = WPT.get('adjusted_zones')
|
||||
init_terrain(adjusted_zones)
|
||||
|
||||
local map_name = 'mountain_fortress_v3'
|
||||
|
||||
if string.sub(surface.name, 0, #map_name) ~= map_name then
|
||||
@ -2514,13 +2714,13 @@ function Public.heavy_functions(data)
|
||||
return
|
||||
end
|
||||
|
||||
if top_y % Public.level_depth == 0 and top_y < 0 then
|
||||
WPT.set().left_top = data.left_top
|
||||
if top_y % zone_settings.zone_depth == 0 and top_y < 0 then
|
||||
WPT.set('left_top', data.left_top)
|
||||
return wall(p, data)
|
||||
end
|
||||
|
||||
if top_y < 0 then
|
||||
return process_bits(p, data)
|
||||
return process_bits(p, data, adjusted_zones)
|
||||
end
|
||||
|
||||
if top_y > 120 then
|
||||
@ -2574,9 +2774,7 @@ Event.add(
|
||||
local locomotive = WPT.get('locomotive')
|
||||
if locomotive and locomotive.valid then
|
||||
local position = locomotive.position
|
||||
for _, entity in pairs(
|
||||
surface.find_entities_filtered({area = {{position.x - 5, position.y - 6}, {position.x + 5, position.y + 10}}, type = 'simple-entity'})
|
||||
) do
|
||||
for _, entity in pairs(surface.find_entities_filtered({area = {{position.x - 5, position.y - 6}, {position.x + 5, position.y + 10}}, type = 'simple-entity'})) do
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
|
@ -2,7 +2,7 @@
|
||||
require 'modules.biters_yield_ore'
|
||||
require 'modules.rocks_yield_ore_veins'
|
||||
|
||||
local Map_score = require 'comfy_panel.map_score'
|
||||
local Map_score = require 'utils.gui.map_score'
|
||||
local Collapse = require 'modules.collapse'
|
||||
local Immersive_cargo_wagons = require 'modules.immersive_cargo_wagons.main'
|
||||
local Terrain = require 'maps.mountain_race.terrain'
|
||||
|
@ -2,12 +2,12 @@
|
||||
require 'modules.biter_reanimator'
|
||||
require 'maps.native_war.share_chat'
|
||||
require 'maps.native_war.mineable_wreckage_yields_scrap'
|
||||
require 'maps.native_war.gui'
|
||||
local Global = require 'utils.global'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local Gui = require 'utils.gui'
|
||||
local Map_score = require 'modules.map_score'
|
||||
local Team = require 'maps.native_war.team'
|
||||
local Terrain = require 'maps.native_war.terrain'
|
||||
local Gui = require 'maps.native_war.gui'
|
||||
local Init = require 'maps.native_war.init'
|
||||
local Settings = require 'maps.native_war.settings'
|
||||
local Reset = require 'functions.soft_reset'
|
||||
@ -343,7 +343,7 @@ local function on_entity_died(event)
|
||||
for _, child in pairs(player.gui.left.children) do
|
||||
child.destroy()
|
||||
end
|
||||
Tabs.comfy_panel_call_tab(player, 'Map Scores')
|
||||
Gui.call_existing_tab(player, 'Map Scores')
|
||||
end
|
||||
end
|
||||
|
||||
@ -549,12 +549,10 @@ local function on_entity_damaged(event)
|
||||
if entity.type == 'unit' or entity.type == 'turret' then
|
||||
if cause.type == 'unit' then
|
||||
if cause.name == 'small-biter' or cause.name == 'medium-biter' or cause.name == 'big-biter' or cause.name == 'behemoth-biter' then
|
||||
local modified_damage =
|
||||
event.original_damage_amount * global.map_forces[cause.force.name].modifier.damage * global.map_forces[entity.force.name].modifier.resistance
|
||||
local modified_damage = event.original_damage_amount * global.map_forces[cause.force.name].modifier.damage * global.map_forces[entity.force.name].modifier.resistance
|
||||
entity.health = entity.health - modified_damage
|
||||
elseif cause.name == 'small-spitter' or cause.name == 'medium-spitter' or cause.name == 'big-spitter' or cause.name == 'behemoth-spitter' then
|
||||
local modified_damage =
|
||||
event.original_damage_amount * global.map_forces[cause.force.name].modifier.splash * global.map_forces[entity.force.name].modifier.resistance
|
||||
local modified_damage = event.original_damage_amount * global.map_forces[cause.force.name].modifier.splash * global.map_forces[entity.force.name].modifier.resistance
|
||||
entity.health = entity.health - modified_damage
|
||||
end
|
||||
end
|
||||
|
@ -15,10 +15,10 @@ local Map = require 'modules.map_info'
|
||||
local Event = require 'utils.event'
|
||||
local Reset = require 'functions.soft_reset'
|
||||
local Server = require 'utils.server'
|
||||
local Poll = require 'comfy_panel.poll'
|
||||
local Poll = require 'utils.gui.poll'
|
||||
local boss_biter = require 'maps.pidgeotto.boss_biters'
|
||||
local FDT = require 'maps.pidgeotto.table'
|
||||
local Score = require 'comfy_panel.score'
|
||||
local Score = require 'utils.gui.score'
|
||||
local AntiGrief = require 'utils.antigrief'
|
||||
local math_random = math.random
|
||||
local insert = table.insert
|
||||
|
@ -838,15 +838,7 @@ local function on_gui_click(e)
|
||||
return
|
||||
end
|
||||
|
||||
if elem.name == 'comfy_panel_top_button' then
|
||||
if not p.admin then
|
||||
if p.gui.left['comfy_panel'] and p.gui.left['comfy_panel'].valid then
|
||||
p.gui.left['comfy_panel'].destroy()
|
||||
end
|
||||
redraw_gui(p)
|
||||
return p.print('Comfy panel is disabled in this scenario.', Color.fail)
|
||||
end
|
||||
elseif elem.name == 'chat_toggle' then
|
||||
if elem.name == 'chat_toggle' then
|
||||
if perks.chat_global then
|
||||
elem.caption = 'NAP chat'
|
||||
perks.chat_global = false
|
||||
|
@ -20,7 +20,7 @@ require 'modules.scrap_towny_ffa.turrets_drop_ammo'
|
||||
require 'modules.scrap_towny_ffa.combat_balance'
|
||||
|
||||
local Autostash = require 'modules.autostash'
|
||||
local BottomFrame = require 'comfy_panel.bottom_frame'
|
||||
local BottomFrame = require 'utils.gui.bottom_frame'
|
||||
local Table = require 'modules.scrap_towny_ffa.table'
|
||||
local Nauvis = require 'modules.scrap_towny_ffa.nauvis'
|
||||
local Biters = require 'modules.scrap_towny_ffa.biters'
|
||||
@ -40,11 +40,17 @@ local max_ticks_between_spawns = 60 * 10
|
||||
local min_players_for_enabling_towns = 0
|
||||
|
||||
local function load_buffs(player)
|
||||
if player.force.name ~= 'player' and player.force.name ~= 'rogue' then return end
|
||||
if player.force.name ~= 'player' and player.force.name ~= 'rogue' then
|
||||
return
|
||||
end
|
||||
local ffatable = Table.get_table()
|
||||
local player_index = player.index
|
||||
if player.character == nil then return end
|
||||
if ffatable.buffs[player_index] == nil then ffatable.buffs[player_index] = {} end
|
||||
if player.character == nil then
|
||||
return
|
||||
end
|
||||
if ffatable.buffs[player_index] == nil then
|
||||
ffatable.buffs[player_index] = {}
|
||||
end
|
||||
if ffatable.buffs[player_index].character_inventory_slots_bonus ~= nil then
|
||||
player.character.character_inventory_slots_bonus = ffatable.buffs[player_index].character_inventory_slots_bonus
|
||||
end
|
||||
@ -65,14 +71,14 @@ local function on_player_joined_game(event)
|
||||
player.game_view_settings.show_map_view_options = false
|
||||
player.game_view_settings.show_entity_info = true
|
||||
player.map_view_settings = {
|
||||
["show-logistic-network"] = false,
|
||||
["show-electric-network"] = false,
|
||||
["show-turret-range"] = false,
|
||||
["show-pollution"] = false,
|
||||
["show-train-station-names"] = false,
|
||||
["show-player-names"] = false,
|
||||
["show-networkless-logistic-members"] = false,
|
||||
["show-non-standard-map-info"] = false
|
||||
['show-logistic-network'] = false,
|
||||
['show-electric-network'] = false,
|
||||
['show-turret-range'] = false,
|
||||
['show-pollution'] = false,
|
||||
['show-train-station-names'] = false,
|
||||
['show-player-names'] = false,
|
||||
['show-networkless-logistic-members'] = false,
|
||||
['show-non-standard-map-info'] = false
|
||||
}
|
||||
player.show_on_map = false
|
||||
--player.game_view_settings.show_side_menu = false
|
||||
@ -89,19 +95,21 @@ local function on_player_joined_game(event)
|
||||
ffatable.towns_enabled = true
|
||||
else
|
||||
ffatable.players = ffatable.players + 1
|
||||
if ffatable.players >= min_players_for_enabling_towns then ffatable.towns_enabled = true end
|
||||
if ffatable.players >= min_players_for_enabling_towns then
|
||||
ffatable.towns_enabled = true
|
||||
end
|
||||
end
|
||||
|
||||
player.teleport({0, 0}, game.surfaces['limbo'])
|
||||
Team.set_player_to_outlander(player)
|
||||
Team.give_player_items(player)
|
||||
player.insert{name="coin", count="100"}
|
||||
player.insert{name="stone-furnace", count="1"}
|
||||
player.insert {name = 'coin', count = '100'}
|
||||
player.insert {name = 'stone-furnace', count = '1'}
|
||||
Team.give_key(player.index)
|
||||
if (testing_mode == true) then
|
||||
player.cheat_mode = true
|
||||
player.force.research_all_technologies()
|
||||
player.insert{name="coin", count="9900"}
|
||||
player.insert {name = 'coin', count = '9900'}
|
||||
end
|
||||
-- first time spawn point
|
||||
local spawn_point = Spawn.get_new_spawn_point(player, surface)
|
||||
@ -150,7 +158,9 @@ end
|
||||
local function on_player_died(event)
|
||||
local ffatable = Table.get_table()
|
||||
local player = game.players[event.player_index]
|
||||
if ffatable.strikes[player.name] == nil then ffatable.strikes[player.name] = 0 end
|
||||
if ffatable.strikes[player.name] == nil then
|
||||
ffatable.strikes[player.name] = 0
|
||||
end
|
||||
|
||||
local ticks_elapsed = game.tick - ffatable.last_respawn[player.name]
|
||||
if ticks_elapsed < max_ticks_between_spawns then
|
||||
|
@ -4,8 +4,8 @@
|
||||
local Global = require 'utils.global'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
local Event = require 'utils.event'
|
||||
local BottomFrame = require 'comfy_panel.bottom_frame'
|
||||
local ComfyGui = require 'comfy_panel.main'
|
||||
local BottomFrame = require 'utils.gui.bottom_frame'
|
||||
local ComfyGui = require 'utils.gui'
|
||||
local floor = math.floor
|
||||
local print_color = {r = 120, g = 255, b = 0}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
local Event = require 'utils.event'
|
||||
local Gui = require 'utils.gui'
|
||||
local Server = require 'utils.server'
|
||||
local Global = require 'utils.global'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
@ -6,6 +7,11 @@ local SpamProtection = require 'utils.spam_protection'
|
||||
local max = math.max
|
||||
local round = math.round
|
||||
|
||||
local main_frame_name = Gui.uid_name()
|
||||
local selection_button_name = Gui.uid_name()
|
||||
local close_main_frame = Gui.uid_name()
|
||||
local top_button_name = Gui.uid_name()
|
||||
|
||||
local this = {
|
||||
difficulties = {
|
||||
[1] = {
|
||||
@ -64,21 +70,29 @@ Global.register(
|
||||
end
|
||||
)
|
||||
|
||||
local function clear_main_frame(player)
|
||||
local screen = player.gui.center
|
||||
if screen[main_frame_name] and screen[main_frame_name].valid then
|
||||
screen[main_frame_name].destroy()
|
||||
end
|
||||
end
|
||||
|
||||
function Public.difficulty_gui()
|
||||
local tooltip = 'Current difficulty of the map is ' .. this.difficulties[this.difficulty_vote_index].name .. '.'
|
||||
|
||||
for _, player in pairs(game.connected_players) do
|
||||
if player.gui.top['difficulty_gui'] then
|
||||
player.gui.top['difficulty_gui'].caption = this.difficulties[this.difficulty_vote_index].name
|
||||
player.gui.top['difficulty_gui'].tooltip = this.button_tooltip or tooltip
|
||||
player.gui.top['difficulty_gui'].style.font_color = this.difficulties[this.difficulty_vote_index].print_color
|
||||
local top = player.gui.top
|
||||
if top[top_button_name] then
|
||||
top[top_button_name].caption = this.difficulties[this.difficulty_vote_index].name
|
||||
top[top_button_name].tooltip = this.button_tooltip or tooltip
|
||||
top[top_button_name].style.font_color = this.difficulties[this.difficulty_vote_index].print_color
|
||||
else
|
||||
local b =
|
||||
player.gui.top.add {
|
||||
top.add {
|
||||
type = 'button',
|
||||
caption = this.difficulties[this.difficulty_vote_index].name,
|
||||
tooltip = tooltip,
|
||||
name = 'difficulty_gui'
|
||||
name = top_button_name
|
||||
}
|
||||
b.style.font = 'heading-2'
|
||||
b.style.font_color = this.difficulties[this.difficulty_vote_index].print_color
|
||||
@ -130,10 +144,10 @@ local function highest_count(tbl)
|
||||
end
|
||||
|
||||
local function poll_difficulty(player)
|
||||
if player.gui.center['difficulty_poll'] then
|
||||
player.gui.center['difficulty_poll'].destroy()
|
||||
return
|
||||
if player.gui.center[main_frame_name] then
|
||||
clear_main_frame(player)
|
||||
end
|
||||
|
||||
if game.tick > this.difficulty_poll_closing_timeout then
|
||||
if player.online_time ~= 0 then
|
||||
local t = math.abs(math.floor((this.difficulty_poll_closing_timeout - game.tick) / 3600))
|
||||
@ -148,32 +162,49 @@ local function poll_difficulty(player)
|
||||
return
|
||||
end
|
||||
|
||||
local frame =
|
||||
player.gui.center.add {
|
||||
type = 'frame',
|
||||
caption = 'Vote difficulty:',
|
||||
name = 'difficulty_poll',
|
||||
direction = 'vertical'
|
||||
}
|
||||
local _, inside_frame = Gui.add_main_frame_with_toolbar(player, 'center', main_frame_name, nil, close_main_frame, 'Difficulty')
|
||||
|
||||
for i = 1, #this.difficulties, 1 do
|
||||
local b = frame.add({type = 'button', name = tostring(i), caption = this.difficulties[i].name})
|
||||
local button_flow =
|
||||
inside_frame.add {
|
||||
type = 'flow',
|
||||
name = tostring(i)
|
||||
}
|
||||
local b = button_flow.add({type = 'button', name = selection_button_name, caption = this.difficulties[i].name})
|
||||
b.style.font_color = this.difficulties[i].color
|
||||
b.style.font = 'heading-2'
|
||||
b.style.minimal_width = 160
|
||||
b.tooltip = this.tooltip[i]
|
||||
end
|
||||
frame.add({type = 'label', caption = '- - - - - - - - - - - - - - - - - -'})
|
||||
|
||||
local label_flow =
|
||||
inside_frame.add {
|
||||
type = 'flow'
|
||||
}
|
||||
|
||||
label_flow.add({type = 'label', caption = '- - - - - - - - - - - - - - - - - -'})
|
||||
|
||||
label_flow.style.horizontal_align = 'center'
|
||||
label_flow.style.horizontally_stretchable = true
|
||||
|
||||
local timeleft_flow =
|
||||
inside_frame.add {
|
||||
type = 'flow'
|
||||
}
|
||||
timeleft_flow.style.horizontal_align = 'center'
|
||||
timeleft_flow.style.horizontally_stretchable = true
|
||||
|
||||
local b =
|
||||
frame.add(
|
||||
timeleft_flow.add(
|
||||
{
|
||||
type = 'button',
|
||||
name = 'close',
|
||||
caption = 'Close (' .. math.floor((this.difficulty_poll_closing_timeout - game.tick) / 3600) .. ' minutes left)'
|
||||
caption = math.floor((this.difficulty_poll_closing_timeout - game.tick) / 3600) .. ' minutes left.'
|
||||
}
|
||||
)
|
||||
b.style.font_color = {r = 0.66, g = 0.0, b = 0.66}
|
||||
b.style.font = 'heading-3'
|
||||
b.style.minimal_width = 96
|
||||
b.enabled = false
|
||||
end
|
||||
|
||||
local function set_difficulty()
|
||||
@ -200,8 +231,8 @@ function Public.reset_difficulty_poll(tbl)
|
||||
this.difficulty_player_votes = {}
|
||||
this.difficulty_poll_closing_timeout = tbl.difficulty_poll_closing_timeout or game.tick + 54000
|
||||
for _, p in pairs(game.connected_players) do
|
||||
if p.gui.center['difficulty_poll'] then
|
||||
p.gui.center['difficulty_poll'].destroy()
|
||||
if p.gui.center[main_frame_name] then
|
||||
clear_main_frame(p)
|
||||
end
|
||||
poll_difficulty(p)
|
||||
end
|
||||
@ -215,8 +246,8 @@ function Public.reset_difficulty_poll(tbl)
|
||||
this.difficulty_player_votes = {}
|
||||
this.difficulty_poll_closing_timeout = game.tick + 54000
|
||||
for _, p in pairs(game.connected_players) do
|
||||
if p.gui.center['difficulty_poll'] then
|
||||
p.gui.center['difficulty_poll'].destroy()
|
||||
if p.gui.center[main_frame_name] then
|
||||
clear_main_frame(p)
|
||||
end
|
||||
poll_difficulty(p)
|
||||
end
|
||||
@ -228,15 +259,13 @@ function Public.reset_difficulty_poll(tbl)
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
local player = game.get_player(event.player_index)
|
||||
if game.tick < this.difficulty_poll_closing_timeout then
|
||||
if not this.difficulty_player_votes[player.name] then
|
||||
poll_difficulty(player)
|
||||
end
|
||||
else
|
||||
if player.gui.center['difficulty_poll'] then
|
||||
player.gui.center['difficulty_poll'].destroy()
|
||||
end
|
||||
clear_main_frame(player)
|
||||
end
|
||||
Public.difficulty_gui()
|
||||
end
|
||||
@ -245,7 +274,7 @@ local function on_player_left_game(event)
|
||||
if game.tick > this.difficulty_poll_closing_timeout then
|
||||
return
|
||||
end
|
||||
local player = game.players[event.player_index]
|
||||
local player = game.get_player(event.player_index)
|
||||
if not this.difficulty_player_votes[player.name] then
|
||||
return
|
||||
end
|
||||
@ -259,73 +288,6 @@ local function on_player_left_game(event)
|
||||
Public.difficulty_gui()
|
||||
end
|
||||
|
||||
local function on_gui_click(event)
|
||||
if not event then
|
||||
return
|
||||
end
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
if not event.element then
|
||||
return
|
||||
end
|
||||
if not event.element.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if event.element.name == 'difficulty_gui' then
|
||||
local is_spamming = SpamProtection.is_spamming(player, nil, 'Difficulty Vote Gui Click')
|
||||
if is_spamming then
|
||||
return
|
||||
end
|
||||
poll_difficulty(player)
|
||||
return
|
||||
end
|
||||
if event.element.type ~= 'button' then
|
||||
return
|
||||
end
|
||||
if event.element.parent.name ~= 'difficulty_poll' then
|
||||
return
|
||||
end
|
||||
if event.element.name == 'close' then
|
||||
event.element.parent.destroy()
|
||||
return
|
||||
end
|
||||
if game.tick > this.difficulty_poll_closing_timeout then
|
||||
event.element.parent.destroy()
|
||||
return
|
||||
end
|
||||
|
||||
local is_spamming = SpamProtection.is_spamming(player, nil, 'Difficulty Gui No Func')
|
||||
if is_spamming then
|
||||
return
|
||||
end
|
||||
|
||||
local i = tonumber(event.element.name)
|
||||
|
||||
if this.difficulty_player_votes[player.name] and this.difficulty_player_votes[player.name].index == i then
|
||||
player.print('You have already voted for ' .. this.difficulties[i].name .. '.', this.difficulties[i].print_color)
|
||||
return event.element.parent.destroy()
|
||||
end
|
||||
|
||||
if this.difficulty_player_votes[player.name] then
|
||||
local index = this.difficulty_player_votes[player.name].index
|
||||
this.difficulties[index].count = this.difficulties[index].count - 1
|
||||
if this.difficulties[index].count <= 0 then
|
||||
this.difficulties[index].count = 0
|
||||
end
|
||||
end
|
||||
|
||||
this.difficulties[i].count = this.difficulties[i].count + 1
|
||||
this.difficulty_player_votes[player.name] = {voted = true, index = i}
|
||||
|
||||
set_difficulty()
|
||||
Public.difficulty_gui()
|
||||
event.element.parent.destroy()
|
||||
local message = '*** ' .. player.name .. ' has voted for ' .. this.difficulties[i].name .. ' difficulty! ***'
|
||||
game.print(message, this.difficulties[i].print_color)
|
||||
Server.to_discord_embed(message)
|
||||
end
|
||||
|
||||
function Public.set_tooltip(...)
|
||||
if type(...) == 'table' then
|
||||
this.tooltip = ...
|
||||
@ -358,9 +320,95 @@ function Public.get(key)
|
||||
end
|
||||
end
|
||||
|
||||
Gui.on_click(
|
||||
selection_button_name,
|
||||
function(event)
|
||||
local is_spamming = SpamProtection.is_spamming(event.player, nil, 'Poll difficulty selection frame name')
|
||||
if is_spamming then
|
||||
return
|
||||
end
|
||||
local element = event.element
|
||||
if not element or not element.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local player = event.player
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local i = tonumber(element.parent.name)
|
||||
|
||||
if this.difficulty_player_votes[player.name] and this.difficulty_player_votes[player.name].index == i then
|
||||
player.print('You have already voted for ' .. this.difficulties[i].name .. '.', this.difficulties[i].print_color)
|
||||
clear_main_frame(player)
|
||||
return
|
||||
end
|
||||
|
||||
if this.difficulty_player_votes[player.name] then
|
||||
local index = this.difficulty_player_votes[player.name].index
|
||||
this.difficulties[index].count = this.difficulties[index].count - 1
|
||||
if this.difficulties[index].count <= 0 then
|
||||
this.difficulties[index].count = 0
|
||||
end
|
||||
end
|
||||
|
||||
this.difficulties[i].count = this.difficulties[i].count + 1
|
||||
this.difficulty_player_votes[player.name] = {voted = true, index = i}
|
||||
|
||||
set_difficulty()
|
||||
Public.difficulty_gui()
|
||||
clear_main_frame(player)
|
||||
local message = '*** ' .. player.name .. ' has voted for ' .. this.difficulties[i].name .. ' difficulty! ***'
|
||||
game.print(message, this.difficulties[i].print_color)
|
||||
Server.to_discord_embed(message)
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
top_button_name,
|
||||
function(event)
|
||||
local is_spamming = SpamProtection.is_spamming(event.player, nil, 'Poll difficulty top button')
|
||||
if is_spamming then
|
||||
return
|
||||
end
|
||||
local player = event.player
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
if game.tick > this.difficulty_poll_closing_timeout then
|
||||
clear_main_frame(player)
|
||||
return
|
||||
end
|
||||
|
||||
local screen = player.gui.center
|
||||
if screen[main_frame_name] and screen[main_frame_name].valid then
|
||||
clear_main_frame(player)
|
||||
else
|
||||
poll_difficulty(player)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
close_main_frame,
|
||||
function(event)
|
||||
local is_spamming = SpamProtection.is_spamming(event.player, nil, 'Poll difficulty close button')
|
||||
if is_spamming then
|
||||
return
|
||||
end
|
||||
local player = event.player
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
clear_main_frame(player)
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(defines.events.on_player_created, on_player_joined_game)
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
Event.add(defines.events.on_player_left_game, on_player_left_game)
|
||||
Event.add(defines.events.on_gui_click, on_gui_click)
|
||||
|
||||
Public.top_button_name = top_button_name
|
||||
|
||||
return Public
|
||||
|
@ -1,10 +1,9 @@
|
||||
local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
local Gui = require 'utils.gui'
|
||||
local Token = require 'utils.token'
|
||||
|
||||
local module_name = 'Map Info'
|
||||
local module_name = Gui.uid_name()
|
||||
|
||||
local map_info = {
|
||||
localised_category = false,
|
||||
@ -85,14 +84,6 @@ local function create_map_intro(data)
|
||||
l_3.style.minimal_width = 780
|
||||
l_3.style.horizontal_align = 'center'
|
||||
l_3.style.vertical_align = 'center'
|
||||
|
||||
local b = frame.add {type = 'button', caption = 'CLOSE', name = 'close_map_intro'}
|
||||
b.style.font = 'heading-2'
|
||||
b.style.padding = 2
|
||||
b.style.top_margin = 3
|
||||
b.style.left_margin = 333
|
||||
b.style.horizontal_align = 'center'
|
||||
b.style.vertical_align = 'center'
|
||||
end
|
||||
|
||||
local create_map_intro_token = Token.register(create_map_intro)
|
||||
@ -100,52 +91,20 @@ local create_map_intro_token = Token.register(create_map_intro)
|
||||
local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
if player.online_time == 0 then
|
||||
Tabs.comfy_panel_call_tab(player, 'Map Info')
|
||||
Gui.call_existing_tab(player, 'Map Info')
|
||||
end
|
||||
end
|
||||
|
||||
local function on_gui_click(event)
|
||||
if not event then
|
||||
return
|
||||
end
|
||||
local player = game.get_player(event.player_index)
|
||||
if not (player and player.valid) then
|
||||
return
|
||||
end
|
||||
|
||||
if not event.element then
|
||||
return
|
||||
end
|
||||
if not event.element.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local name = event.element.name
|
||||
|
||||
if not name then
|
||||
return
|
||||
end
|
||||
|
||||
if name == 'tab_' .. module_name then
|
||||
local is_spamming = SpamProtection.is_spamming(player, nil, 'Map Info Main Button')
|
||||
if is_spamming then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if name == 'close_map_intro' then
|
||||
local is_spamming = SpamProtection.is_spamming(player, nil, 'Map Info Close Button')
|
||||
if is_spamming then
|
||||
return
|
||||
end
|
||||
player.gui.left.comfy_panel.destroy()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
Tabs.add_tab_to_gui({name = module_name, id = create_map_intro_token, admin = false})
|
||||
Gui.add_tab_to_gui({name = module_name, caption = 'Map Info', id = create_map_intro_token, admin = false})
|
||||
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
Event.add(defines.events.on_gui_click, on_gui_click)
|
||||
|
||||
Gui.on_click(
|
||||
module_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
Gui.reload_active_tab(player)
|
||||
end
|
||||
)
|
||||
|
||||
return Public
|
||||
|
@ -5,7 +5,7 @@
|
||||
local Event = require 'utils.event'
|
||||
local Token = require 'utils.token'
|
||||
local Task = require 'utils.task'
|
||||
local Score = require 'comfy_panel.score'
|
||||
local Score = require 'utils.gui.score'
|
||||
local floor = math.floor
|
||||
local sqrt = math.sqrt
|
||||
local insert = table.insert
|
||||
@ -197,14 +197,10 @@ local function reward_messages(data)
|
||||
end
|
||||
local print_text = ''
|
||||
|
||||
player.surface.create_entity(
|
||||
{name = 'flying-text', position = {player.position.x, player.position.y}, text = 'Reached Combat Level: ' .. data.next_level, color = {r = 0.2, g = 1.0, b = 0.1}}
|
||||
)
|
||||
player.surface.create_entity({name = 'flying-text', position = {player.position.x, player.position.y}, text = 'Reached Combat Level: ' .. data.next_level, color = {r = 0.2, g = 1.0, b = 0.1}})
|
||||
-- Loop through all of the rewards for this level and print out flying text
|
||||
for i = 1, #item_rewards, 1 do
|
||||
player.surface.create_entity(
|
||||
{name = 'flying-text', position = {player.position.x, player.position.y + (i * 0.5)}, text = item_rewards[i].text, color = {r = 1.0, g = 1.0, b = 1.0}}
|
||||
)
|
||||
player.surface.create_entity({name = 'flying-text', position = {player.position.x, player.position.y + (i * 0.5)}, text = item_rewards[i].text, color = {r = 1.0, g = 1.0, b = 1.0}})
|
||||
if i > 1 then
|
||||
print_text = item_rewards[i].text .. ' ' .. print_text
|
||||
else
|
||||
|
@ -17,7 +17,7 @@ local math_random = math.random
|
||||
local math_sqrt = math.sqrt
|
||||
local math_floor = math.floor
|
||||
local Global = require 'utils.global'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local Tabs = require 'utils.gui'
|
||||
local P = require 'utils.player_modifiers'
|
||||
local visuals_delay = 1800
|
||||
local level_up_floating_text_color = {0, 205, 0}
|
||||
@ -119,7 +119,7 @@ local function get_one_punch_chance(player)
|
||||
if rpg_t[player.index].strength < 100 then
|
||||
return 0
|
||||
end
|
||||
local chance = math.round(rpg_t[player.index].strength * 0.01, 1)
|
||||
local chance = math.round(rpg_t[player.index].strength * 0.007, 1)
|
||||
if chance > 100 then
|
||||
chance = 100
|
||||
end
|
||||
@ -152,8 +152,8 @@ end
|
||||
|
||||
local function update_player_stats(player)
|
||||
local strength = rpg_t[player.index].strength - 10
|
||||
P.update_single_modifier(player, 'character_inventory_slots_bonus', 'rpg', math.round(strength * 0.2, 3))
|
||||
P.update_single_modifier(player, 'character_mining_speed_modifier', 'rpg', math.round(strength * 0.008, 3))
|
||||
P.update_single_modifier(player, 'character_inventory_slots_bonus', 'rpg', math.round(strength * 0.1, 3))
|
||||
P.update_single_modifier(player, 'character_mining_speed_modifier', 'rpg', math.round(strength * 0.007, 3))
|
||||
|
||||
local magic = rpg_t[player.index].magic - 10
|
||||
local v = magic * 0.15
|
||||
@ -251,7 +251,7 @@ local function draw_gui(player, forced)
|
||||
end
|
||||
end
|
||||
|
||||
Tabs.comfy_panel_clear_gui(player)
|
||||
Tabs.clear_all_active_frames(player)
|
||||
|
||||
if player.gui.left.rpg then
|
||||
player.gui.left.rpg.destroy()
|
||||
@ -831,10 +831,7 @@ local function on_entity_damaged(event)
|
||||
if not event.entity.valid then
|
||||
return
|
||||
end
|
||||
if
|
||||
event.cause.get_inventory(defines.inventory.character_ammo)[event.cause.selected_gun_index].valid_for_read and
|
||||
event.cause.get_inventory(defines.inventory.character_guns)[event.cause.selected_gun_index].valid_for_read
|
||||
then
|
||||
if event.cause.get_inventory(defines.inventory.character_ammo)[event.cause.selected_gun_index].valid_for_read and event.cause.get_inventory(defines.inventory.character_guns)[event.cause.selected_gun_index].valid_for_read then
|
||||
return
|
||||
end
|
||||
if not event.cause.player then
|
||||
@ -873,9 +870,7 @@ local function on_entity_damaged(event)
|
||||
event.cause.surface.create_entity({name = 'blood-explosion-huge', position = event.entity.position})
|
||||
else
|
||||
damage = damage * math_random(100, 125) * 0.01
|
||||
event.cause.player.create_local_flying_text(
|
||||
{text = math.floor(damage), position = event.entity.position, color = {150, 150, 150}, time_to_live = 90, speed = 2}
|
||||
)
|
||||
event.cause.player.create_local_flying_text({text = math.floor(damage), position = event.entity.position, color = {150, 150, 150}, time_to_live = 90, speed = 2})
|
||||
end
|
||||
|
||||
--Handle the custom health pool of the biter health booster, if it is used in the map.
|
||||
@ -960,10 +955,7 @@ local function on_pre_player_mined_item(event)
|
||||
end
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
if
|
||||
rpg_t[player.index].last_mined_entity_position.x == event.entity.position.x and
|
||||
rpg_t[player.index].last_mined_entity_position.y == event.entity.position.y
|
||||
then
|
||||
if rpg_t[player.index].last_mined_entity_position.x == event.entity.position.x and rpg_t[player.index].last_mined_entity_position.y == event.entity.position.y then
|
||||
return
|
||||
end
|
||||
rpg_t[player.index].last_mined_entity_position.x = entity.position.x
|
||||
|
@ -171,7 +171,7 @@ if _DEBUG then
|
||||
)
|
||||
|
||||
commands.add_command(
|
||||
'rpg_debug_one_punch',
|
||||
'rpg_debug_aoe_punch',
|
||||
'',
|
||||
function()
|
||||
local player = game.player
|
||||
@ -184,7 +184,7 @@ if _DEBUG then
|
||||
return
|
||||
end
|
||||
|
||||
Public.toggle_debug_one_punch()
|
||||
Public.toggle_debug_aoe_punch()
|
||||
end
|
||||
)
|
||||
|
||||
@ -212,7 +212,7 @@ if _DEBUG then
|
||||
data[k].mana = 50000
|
||||
data[k].mana_max = 50000
|
||||
data[k].debug_mode = true
|
||||
data[k].one_punch = true
|
||||
data[k].aoe_punch = true
|
||||
data[k].stone_path = true
|
||||
data[k].strength = 3000
|
||||
data[k].vitality = 3000
|
||||
|
@ -119,12 +119,12 @@ local function level_up(player)
|
||||
return
|
||||
end
|
||||
|
||||
-- automatically enable one_punch and stone_path,
|
||||
-- automatically enable aoe_punch and stone_path,
|
||||
-- but do so only once.
|
||||
if rpg_t.level >= settings_level['one_punch_label'] then
|
||||
if not rpg_t.auto_toggle_features.one_punch then
|
||||
rpg_t.auto_toggle_features.one_punch = true
|
||||
rpg_t.one_punch = true
|
||||
if rpg_t.level >= settings_level['aoe_punch_label'] then
|
||||
if not rpg_t.auto_toggle_features.aoe_punch then
|
||||
rpg_t.auto_toggle_features.aoe_punch = true
|
||||
rpg_t.aoe_punch = true
|
||||
end
|
||||
end
|
||||
if rpg_t.level >= settings_level['stone_path_label'] then
|
||||
@ -520,7 +520,7 @@ function Public.update_player_stats(player)
|
||||
local rpg_t = Public.get_value_from_player(player.index)
|
||||
local strength = rpg_t.strength - 10
|
||||
P.update_single_modifier(player, 'character_inventory_slots_bonus', 'rpg', round(strength * 0.2, 3))
|
||||
P.update_single_modifier(player, 'character_mining_speed_modifier', 'rpg', round(strength * 0.007, 3))
|
||||
P.update_single_modifier(player, 'character_mining_speed_modifier', 'rpg', round(strength * 0.006, 3))
|
||||
P.update_single_modifier(player, 'character_maximum_following_robot_count_bonus', 'rpg', round(strength / 2 * 0.03, 3))
|
||||
|
||||
local magic = rpg_t.magicka - 10
|
||||
@ -555,7 +555,24 @@ function Public.level_up_effects(player)
|
||||
}
|
||||
player.surface.create_entity({name = 'flying-text', position = p, text = '✚', color = {255, math.random(0, 100), 0}})
|
||||
end
|
||||
player.play_sound {path = 'utility/achievement_unlocked', volume_modifier = 0.40}
|
||||
player.play_sound {path = 'utility/achievement_unlocked', volume_modifier = 0.50}
|
||||
end
|
||||
|
||||
function Public.cast_spell(player, failed)
|
||||
local position = {x = player.position.x - 0.75, y = player.position.y - 1}
|
||||
local b = 0.75
|
||||
if not failed then
|
||||
for _ = 1, 3, 1 do
|
||||
local p = {
|
||||
(position.x + 0.4) + (b * -1 + math.random(0, b * 20) * 0.1),
|
||||
position.y + (b * -1 + math.random(0, b * 20) * 0.1)
|
||||
}
|
||||
player.surface.create_entity({name = 'flying-text', position = p, text = '✔️', color = {255, math.random(0, 100), 0}})
|
||||
end
|
||||
player.play_sound {path = 'utility/scenario_message', volume_modifier = 0.50}
|
||||
else
|
||||
player.play_sound {path = 'utility/cannot_build', volume_modifier = 0.50}
|
||||
end
|
||||
end
|
||||
|
||||
function Public.xp_effects(player)
|
||||
@ -569,7 +586,7 @@ function Public.xp_effects(player)
|
||||
}
|
||||
player.surface.create_entity({name = 'flying-text', position = p, text = '✚', color = {255, math.random(0, 100), 0}})
|
||||
end
|
||||
player.play_sound {path = 'utility/achievement_unlocked', volume_modifier = 0.40}
|
||||
player.play_sound {path = 'utility/achievement_unlocked', volume_modifier = 0.50}
|
||||
end
|
||||
|
||||
function Public.get_range_modifier(player)
|
||||
@ -677,12 +694,12 @@ function Public.get_life_on_hit(player)
|
||||
return (rpg_t.vitality - 10) * 0.4
|
||||
end
|
||||
|
||||
function Public.get_one_punch_chance(player)
|
||||
function Public.get_aoe_punch_chance(player)
|
||||
local rpg_t = Public.get_value_from_player(player.index)
|
||||
if rpg_t.strength < 100 then
|
||||
return 0
|
||||
end
|
||||
local chance = round(rpg_t.strength * 0.012, 1)
|
||||
local chance = round(rpg_t.strength * 0.007, 1)
|
||||
if chance > 100 then
|
||||
chance = 100
|
||||
end
|
||||
@ -765,10 +782,10 @@ function Public.rpg_reset_player(player, one_time_reset)
|
||||
last_mined_entity_position = {x = 0, y = 0},
|
||||
show_bars = false,
|
||||
stone_path = false,
|
||||
one_punch = false,
|
||||
aoe_punch = false,
|
||||
auto_toggle_features = {
|
||||
stone_path = false,
|
||||
one_punch = false
|
||||
aoe_punch = false
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -807,10 +824,10 @@ function Public.rpg_reset_player(player, one_time_reset)
|
||||
last_mined_entity_position = {x = 0, y = 0},
|
||||
show_bars = false,
|
||||
stone_path = false,
|
||||
one_punch = false,
|
||||
aoe_punch = false,
|
||||
auto_toggle_features = {
|
||||
stone_path = false,
|
||||
one_punch = false
|
||||
aoe_punch = false
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@ -1,4 +1,4 @@
|
||||
local ComfyGui = require 'comfy_panel.main'
|
||||
local ComfyGui = require 'utils.gui'
|
||||
local Session = require 'utils.datastore.session_data'
|
||||
local P = require 'utils.player_modifiers'
|
||||
local Gui = require 'utils.gui'
|
||||
@ -15,6 +15,7 @@ local experience_levels = Public.experience_levels
|
||||
--RPG Frames
|
||||
local main_frame_name = Public.main_frame_name
|
||||
local draw_main_frame_name = Public.draw_main_frame_name
|
||||
local close_main_frame_name = Public.close_main_frame_name
|
||||
local settings_button_name = Public.settings_button_name
|
||||
local settings_frame_name = Public.settings_frame_name
|
||||
local discard_button_name = Public.discard_button_name
|
||||
@ -102,20 +103,6 @@ local function add_gui_stat(element, value, width, tooltip, name, color)
|
||||
return e
|
||||
end
|
||||
|
||||
local function add_elem_stat(element, value, width, height, font, tooltip, name, color)
|
||||
local e = element.add({type = 'sprite-button', name = name or nil, caption = value})
|
||||
e.tooltip = tooltip or ''
|
||||
e.style.maximal_width = width
|
||||
e.style.minimal_width = width
|
||||
e.style.maximal_height = height
|
||||
e.style.minimal_height = height
|
||||
e.style.font = font or 'default-bold'
|
||||
e.style.horizontal_align = 'center'
|
||||
e.style.vertical_align = 'center'
|
||||
e.style.font_color = color or {222, 222, 222}
|
||||
return e
|
||||
end
|
||||
|
||||
local function add_gui_increase_stat(element, name, player)
|
||||
local rpg_t = Public.get_value_from_player(player.index)
|
||||
local sprite = 'virtual-signal/signal-red'
|
||||
@ -147,9 +134,9 @@ local function add_separator(element, width)
|
||||
return e
|
||||
end
|
||||
|
||||
local function remove_settings_frame(settings_frame)
|
||||
Gui.remove_data_recursively(settings_frame)
|
||||
settings_frame.destroy()
|
||||
local function remove_target_frame(target_frame)
|
||||
Gui.remove_data_recursively(target_frame)
|
||||
target_frame.destroy()
|
||||
end
|
||||
|
||||
local function remove_main_frame(main_frame, screen)
|
||||
@ -158,7 +145,7 @@ local function remove_main_frame(main_frame, screen)
|
||||
|
||||
local settings_frame = screen[settings_frame_name]
|
||||
if settings_frame and settings_frame.valid then
|
||||
remove_settings_frame(settings_frame)
|
||||
remove_target_frame(settings_frame)
|
||||
end
|
||||
end
|
||||
|
||||
@ -167,15 +154,8 @@ local function draw_main_frame(player, location)
|
||||
return
|
||||
end
|
||||
|
||||
local main_frame =
|
||||
player.gui.screen.add(
|
||||
{
|
||||
type = 'frame',
|
||||
name = main_frame_name,
|
||||
caption = 'RPG',
|
||||
direction = 'vertical'
|
||||
}
|
||||
)
|
||||
local main_frame, inside_frame = Gui.add_main_frame_with_toolbar(player, 'screen', main_frame_name, settings_button_name, close_main_frame_name, 'RPG')
|
||||
|
||||
if location then
|
||||
main_frame.location = location
|
||||
else
|
||||
@ -186,23 +166,8 @@ local function draw_main_frame(player, location)
|
||||
local rpg_extra = Public.get('rpg_extra')
|
||||
local rpg_t = Public.get_value_from_player(player.index)
|
||||
|
||||
local inside_frame =
|
||||
main_frame.add {
|
||||
type = 'frame',
|
||||
style = 'deep_frame_in_shallow_frame'
|
||||
}
|
||||
local inside_frame_style = inside_frame.style
|
||||
inside_frame_style.padding = 0
|
||||
inside_frame_style.maximal_height = 800
|
||||
|
||||
local inside_table =
|
||||
inside_frame.add {
|
||||
type = 'table',
|
||||
column_count = 1
|
||||
}
|
||||
|
||||
local scroll_pane =
|
||||
inside_table.add {
|
||||
inside_frame.add {
|
||||
type = 'scroll-pane',
|
||||
vertical_scroll_policy = 'never',
|
||||
horizontal_scroll_policy = 'never'
|
||||
@ -222,8 +187,6 @@ local function draw_main_frame(player, location)
|
||||
local rank = add_gui_stat(main_table, get_class(player), 200, ({'rpg_gui.class_info', get_class(player)}))
|
||||
rank.style.font = 'default-large-bold'
|
||||
|
||||
add_elem_stat(main_table, ({'rpg_gui.settings_name'}), 200, 35, nil, ({'rpg_gui.settings_frame'}), settings_button_name)
|
||||
|
||||
add_separator(scroll_pane, 400)
|
||||
|
||||
--!sub top table
|
||||
@ -286,12 +249,7 @@ local function draw_main_frame(player, location)
|
||||
add_gui_description(left_bottom_table, ({'rpg_gui.life_name'}), w1, ({'rpg_gui.life_tooltip'}))
|
||||
local health_gui = add_gui_stat(left_bottom_table, floor(player.character.health), w2, ({'rpg_gui.life_increase'}))
|
||||
data.health = health_gui
|
||||
add_gui_stat(
|
||||
left_bottom_table,
|
||||
floor(player.character.prototype.max_health + player.character_health_bonus + player.force.character_health_bonus),
|
||||
w2,
|
||||
({'rpg_gui.life_maximum'})
|
||||
)
|
||||
add_gui_stat(left_bottom_table, floor(player.character.prototype.max_health + player.character_health_bonus + player.force.character_health_bonus), w2, ({'rpg_gui.life_maximum'}))
|
||||
|
||||
local shield = 0
|
||||
local shield_max = 0
|
||||
@ -356,15 +314,15 @@ local function draw_main_frame(player, location)
|
||||
add_gui_description(right_bottom_table, ({'rpg_gui.melee_name'}), w1)
|
||||
local melee_damage_value = round(100 * (1 + Public.get_melee_modifier(player))) .. '%'
|
||||
local melee_damage_tooltip
|
||||
if rpg_extra.enable_one_punch then
|
||||
if rpg_extra.enable_aoe_punch then
|
||||
melee_damage_tooltip = ({
|
||||
'rpg_gui.one_punch_chance',
|
||||
'rpg_gui.aoe_punch_chance',
|
||||
Public.get_life_on_hit(player),
|
||||
Public.get_one_punch_chance(player),
|
||||
Public.get_aoe_punch_chance(player),
|
||||
Public.get_extra_following_robots(player)
|
||||
})
|
||||
else
|
||||
melee_damage_tooltip = ({'rpg_gui.one_punch_disabled'})
|
||||
melee_damage_tooltip = ({'rpg_gui.aoe_punch_disabled'})
|
||||
end
|
||||
add_gui_stat(right_bottom_table, melee_damage_value, w2, melee_damage_tooltip)
|
||||
|
||||
@ -487,7 +445,7 @@ function Public.toggle(player, recreate)
|
||||
if main_frame then
|
||||
remove_main_frame(main_frame, screen)
|
||||
else
|
||||
ComfyGui.comfy_panel_clear_gui(player)
|
||||
ComfyGui.clear_all_active_frames(player)
|
||||
draw_main_frame(player)
|
||||
end
|
||||
end
|
||||
@ -547,7 +505,7 @@ Gui.on_click(
|
||||
local explosive_bullets_gui_input = data.explosive_bullets_gui_input
|
||||
local enable_entity_gui_input = data.enable_entity_gui_input
|
||||
local stone_path_gui_input = data.stone_path_gui_input
|
||||
local one_punch_gui_input = data.one_punch_gui_input
|
||||
local aoe_punch_gui_input = data.aoe_punch_gui_input
|
||||
local auto_allocate_gui_input = data.auto_allocate_gui_input
|
||||
|
||||
local rpg_t = Public.get_value_from_player(player.index)
|
||||
@ -557,11 +515,11 @@ Gui.on_click(
|
||||
rpg_t.allocate_index = auto_allocate_gui_input.selected_index
|
||||
end
|
||||
|
||||
if one_punch_gui_input and one_punch_gui_input.valid then
|
||||
if not one_punch_gui_input.state then
|
||||
rpg_t.one_punch = false
|
||||
elseif one_punch_gui_input.state then
|
||||
rpg_t.one_punch = true
|
||||
if aoe_punch_gui_input and aoe_punch_gui_input.valid then
|
||||
if not aoe_punch_gui_input.state then
|
||||
rpg_t.aoe_punch = false
|
||||
elseif aoe_punch_gui_input.state then
|
||||
rpg_t.aoe_punch = true
|
||||
end
|
||||
end
|
||||
|
||||
@ -661,7 +619,7 @@ Gui.on_click(
|
||||
end
|
||||
end
|
||||
|
||||
remove_settings_frame(event.element)
|
||||
remove_target_frame(event.element)
|
||||
|
||||
if player.gui.screen[main_frame_name] then
|
||||
toggle(player, true)
|
||||
@ -690,6 +648,30 @@ Gui.on_click(
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
close_main_frame_name,
|
||||
function(event)
|
||||
local is_spamming = SpamProtection.is_spamming(event.player, nil, 'RPG Close Button')
|
||||
if is_spamming then
|
||||
return
|
||||
end
|
||||
local player = event.player
|
||||
local screen = player.gui.screen
|
||||
if not player or not player.valid or not player.character then
|
||||
return
|
||||
end
|
||||
|
||||
local main_frame = screen[main_frame_name]
|
||||
if main_frame and main_frame.valid then
|
||||
remove_target_frame(main_frame)
|
||||
end
|
||||
local settings_frame = screen[settings_frame_name]
|
||||
if settings_frame and settings_frame.valid then
|
||||
remove_target_frame(settings_frame)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
settings_button_name,
|
||||
function(event)
|
||||
|
@ -3,7 +3,6 @@ local Public = require 'modules.rpg.core'
|
||||
local Gui = require 'utils.gui'
|
||||
local Event = require 'utils.event'
|
||||
local AntiGrief = require 'utils.antigrief'
|
||||
local Color = require 'utils.color_presets'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
local BiterHealthBooster = require 'modules.biter_health_booster_v2'
|
||||
local Explosives = require 'modules.explosives'
|
||||
@ -27,8 +26,8 @@ local random = math.random
|
||||
local sqrt = math.sqrt
|
||||
local abs = math.abs
|
||||
|
||||
local function log_one_punch(callback)
|
||||
local debug = Public.get('rpg_extra').debug_one_punch
|
||||
local function log_aoe_punch(callback)
|
||||
local debug = Public.get('rpg_extra').debug_aoe_punch
|
||||
if not debug then
|
||||
return
|
||||
end
|
||||
@ -542,7 +541,7 @@ local function set_health_boost(entity, damage, cause)
|
||||
end
|
||||
|
||||
--Melee damage modifier
|
||||
local function one_punch(character, target, damage, get_health_pool)
|
||||
local function aoe_punch(character, target, damage, get_health_pool)
|
||||
if not (target and target.valid) then
|
||||
return
|
||||
end
|
||||
@ -557,7 +556,7 @@ local function one_punch(character, target, damage, get_health_pool)
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = {character.position.x + base_vector[1] * 0.5, character.position.y + base_vector[2] * 0.5},
|
||||
text = ({'rpg_main.one_punch_text'}),
|
||||
text = ({'rpg_main.aoe_punch_text'}),
|
||||
color = {255, 0, 0}
|
||||
}
|
||||
)
|
||||
@ -680,10 +679,7 @@ local function on_entity_damaged(event)
|
||||
local original_damage_amount = event.original_damage_amount
|
||||
local final_damage_amount = event.final_damage_amount
|
||||
|
||||
if
|
||||
cause.get_inventory(defines.inventory.character_ammo)[cause.selected_gun_index].valid_for_read or
|
||||
cause.get_inventory(defines.inventory.character_guns)[cause.selected_gun_index].valid_for_read
|
||||
then
|
||||
if cause.get_inventory(defines.inventory.character_ammo)[cause.selected_gun_index].valid_for_read or cause.get_inventory(defines.inventory.character_guns)[cause.selected_gun_index].valid_for_read then
|
||||
local is_explosive_bullets_enabled = Public.get_explosive_bullets()
|
||||
if is_explosive_bullets_enabled then
|
||||
Public.explosive_bullets(event)
|
||||
@ -731,7 +727,7 @@ local function on_entity_damaged(event)
|
||||
|
||||
--Calculate modified damage.
|
||||
local damage = Public.get_final_damage(cause.player, entity, original_damage_amount)
|
||||
local enable_one_punch = Public.get('rpg_extra').enable_one_punch
|
||||
local enable_aoe_punch = Public.get('rpg_extra').enable_aoe_punch
|
||||
local rpg_t = Public.get_value_from_player(cause.player.index)
|
||||
|
||||
--Floating messages and particle effects.
|
||||
@ -762,12 +758,12 @@ local function on_entity_damaged(event)
|
||||
local get_health_pool = has_health_boost(entity, damage, final_damage_amount, cause)
|
||||
|
||||
--Cause a one punch.
|
||||
if enable_one_punch then
|
||||
if rpg_t.one_punch then
|
||||
local chance = Public.get_one_punch_chance(cause.player) * 10
|
||||
if enable_aoe_punch then
|
||||
if rpg_t.aoe_punch then
|
||||
local chance = Public.get_aoe_punch_chance(cause.player) * 10
|
||||
local chance_to_hit = random(0, 999)
|
||||
local success = chance_to_hit < chance
|
||||
log_one_punch(
|
||||
log_aoe_punch(
|
||||
function()
|
||||
if success then
|
||||
print('[OnePunch]: Chance: ' .. chance .. ' Chance to hit: ' .. chance_to_hit .. ' Success: true' .. ' Damage: ' .. damage)
|
||||
@ -777,7 +773,7 @@ local function on_entity_damaged(event)
|
||||
end
|
||||
)
|
||||
if success then
|
||||
one_punch(cause, entity, damage, get_health_pool) -- only kill the biters if their health is below or equal to zero
|
||||
aoe_punch(cause, entity, damage, get_health_pool) -- only kill the biters if their health is below or equal to zero
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -1157,10 +1153,8 @@ local function on_player_used_capsule(event)
|
||||
return
|
||||
end
|
||||
|
||||
local p = player.print
|
||||
|
||||
if rpg_t.last_spawned >= game.tick then
|
||||
return p(({'rpg_main.mana_casting_too_fast', player.name}), Color.warning)
|
||||
return Public.cast_spell(player, true)
|
||||
end
|
||||
|
||||
local mana = rpg_t.mana
|
||||
@ -1183,7 +1177,7 @@ local function on_player_used_capsule(event)
|
||||
}
|
||||
|
||||
if rpg_t.level < object.level then
|
||||
return p(({'rpg_main.low_level'}), Color.fail)
|
||||
return Public.cast_spell(player, true)
|
||||
end
|
||||
|
||||
if not object.enabled then
|
||||
@ -1191,12 +1185,12 @@ local function on_player_used_capsule(event)
|
||||
end
|
||||
|
||||
if not Math2D.bounding_box.contains_point(area, player.position) then
|
||||
player.print(({'rpg_main.not_inside_pos'}), Color.fail)
|
||||
Public.cast_spell(player, true)
|
||||
return
|
||||
end
|
||||
|
||||
if mana < object.mana_cost then
|
||||
return p(({'rpg_main.no_mana'}), Color.fail)
|
||||
return Public.cast_spell(player, true)
|
||||
end
|
||||
|
||||
local target_pos
|
||||
@ -1223,11 +1217,11 @@ local function on_player_used_capsule(event)
|
||||
|
||||
if object.entityName == 'suicidal_comfylatron' then
|
||||
Public.suicidal_comfylatron(position, surface)
|
||||
p(({'rpg_main.suicidal_comfylatron', 'Suicidal Comfylatron'}), Color.success)
|
||||
Public.cast_spell(player)
|
||||
Public.remove_mana(player, object.mana_cost)
|
||||
elseif object.entityName == 'repair_aoe' then
|
||||
local ents = Public.repair_aoe(player, position)
|
||||
p(({'rpg_main.repair_aoe', ents}), Color.success)
|
||||
Public.repair_aoe(player, position)
|
||||
Public.cast_spell(player)
|
||||
Public.remove_mana(player, object.mana_cost)
|
||||
elseif object.entityName == 'pointy_explosives' then
|
||||
local entities =
|
||||
@ -1245,11 +1239,9 @@ local function on_player_used_capsule(event)
|
||||
if detonate_chest and detonate_chest.valid then
|
||||
local success = Explosives.detonate_chest(detonate_chest)
|
||||
if success then
|
||||
player.print(({'rpg_main.detonate_chest'}), Color.success)
|
||||
Public.remove_mana(player, object.mana_cost)
|
||||
else
|
||||
player.print(({'rpg_main.detonate_chest_failed'}), Color.fail)
|
||||
end
|
||||
Public.cast_spell(player)
|
||||
end
|
||||
elseif object.entityName == 'warp-gate' then
|
||||
local pos = surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5)
|
||||
@ -1262,10 +1254,10 @@ local function on_player_used_capsule(event)
|
||||
Public.remove_mana(player, 999999)
|
||||
Public.damage_player_over_time(player, random(8, 16))
|
||||
player.play_sound {path = 'utility/armor_insert', volume_modifier = 1}
|
||||
p(({'rpg_main.warped_ok'}), Color.info)
|
||||
Public.cast_spell(player)
|
||||
elseif object.capsule then -- spawn in capsules i.e objects that are usable with mouse-click
|
||||
player.insert({name = object.entityName, count = object.amount})
|
||||
p(({'rpg_main.object_spawned', object.entityName}), Color.success)
|
||||
Public.cast_spell(player)
|
||||
Public.remove_mana(player, object.mana_cost)
|
||||
elseif projectile_types[object.entityName] then -- projectiles
|
||||
for i = 1, object.amount do
|
||||
@ -1280,12 +1272,12 @@ local function on_player_used_capsule(event)
|
||||
end
|
||||
end
|
||||
end
|
||||
p(({'rpg_main.object_spawned', object.entityName}), Color.success)
|
||||
Public.cast_spell(player)
|
||||
Public.remove_mana(player, object.mana_cost)
|
||||
else
|
||||
if object.target then -- rockets and such
|
||||
surface.create_entity({name = object.entityName, position = position, force = force, target = target_pos, speed = 1})
|
||||
p(({'rpg_main.object_spawned', object.entityName}), Color.success)
|
||||
Public.cast_spell(player)
|
||||
Public.remove_mana(player, object.mana_cost)
|
||||
elseif surface.can_place_entity {name = object.entityName, position = position} then
|
||||
if object.biter then
|
||||
@ -1311,9 +1303,9 @@ local function on_player_used_capsule(event)
|
||||
e.direction = player.character.direction
|
||||
Public.remove_mana(player, object.mana_cost)
|
||||
end
|
||||
p(({'rpg_main.object_spawned', object.entityName}), Color.success)
|
||||
Public.cast_spell(player)
|
||||
else
|
||||
p(({'rpg_main.out_of_reach'}), Color.fail)
|
||||
Public.cast_spell(player, true)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
@ -330,7 +330,7 @@ function Public.extra_settings(player)
|
||||
local flame_boots_gui_input
|
||||
local explosive_bullets_gui_input
|
||||
local stone_path_gui_input
|
||||
local one_punch_gui_input
|
||||
local aoe_punch_gui_input
|
||||
local auto_allocate_gui_input
|
||||
|
||||
if rpg_extra.enable_stone_path then
|
||||
@ -370,44 +370,44 @@ function Public.extra_settings(player)
|
||||
end
|
||||
end
|
||||
|
||||
if rpg_extra.enable_one_punch then
|
||||
local one_punch_label =
|
||||
if rpg_extra.enable_aoe_punch then
|
||||
local aoe_punch_label =
|
||||
setting_grid.add(
|
||||
{
|
||||
type = 'label',
|
||||
caption = ({'rpg_settings.one_punch_label'}),
|
||||
tooltip = ({'rpg_settings.one_punch_tooltip'})
|
||||
caption = ({'rpg_settings.aoe_punch_label'}),
|
||||
tooltip = ({'rpg_settings.aoe_punch_tooltip'})
|
||||
}
|
||||
)
|
||||
|
||||
local one_punch_label_style = one_punch_label.style
|
||||
one_punch_label_style.horizontally_stretchable = true
|
||||
one_punch_label_style.height = 35
|
||||
one_punch_label_style.vertical_align = 'center'
|
||||
local aoe_punch_label_style = aoe_punch_label.style
|
||||
aoe_punch_label_style.horizontally_stretchable = true
|
||||
aoe_punch_label_style.height = 35
|
||||
aoe_punch_label_style.vertical_align = 'center'
|
||||
|
||||
local one_punch_input = setting_grid.add({type = 'flow'})
|
||||
local one_punch_input_style = one_punch_input.style
|
||||
one_punch_input_style.height = 35
|
||||
one_punch_input_style.vertical_align = 'center'
|
||||
local one_punch
|
||||
if rpg_t.one_punch then
|
||||
one_punch = rpg_t.one_punch
|
||||
local aoe_punch_input = setting_grid.add({type = 'flow'})
|
||||
local aoe_punch_input_style = aoe_punch_input.style
|
||||
aoe_punch_input_style.height = 35
|
||||
aoe_punch_input_style.vertical_align = 'center'
|
||||
local aoe_punch
|
||||
if rpg_t.aoe_punch then
|
||||
aoe_punch = rpg_t.aoe_punch
|
||||
else
|
||||
one_punch = false
|
||||
aoe_punch = false
|
||||
end
|
||||
one_punch_gui_input = create_input_element(one_punch_input, 'boolean', one_punch)
|
||||
aoe_punch_gui_input = create_input_element(aoe_punch_input, 'boolean', aoe_punch)
|
||||
|
||||
if rpg_extra.enable_one_punch_globally then
|
||||
one_punch_gui_input.state = true
|
||||
one_punch_gui_input.enabled = false
|
||||
one_punch_gui_input.tooltip = ({'rpg_settings.one_punch_globally'})
|
||||
if rpg_extra.enable_aoe_punch_globally then
|
||||
aoe_punch_gui_input.state = true
|
||||
aoe_punch_gui_input.enabled = false
|
||||
aoe_punch_gui_input.tooltip = ({'rpg_settings.aoe_punch_globally'})
|
||||
else
|
||||
if rpg_t.level < settings_level['one_punch_label'] then
|
||||
one_punch_gui_input.enabled = false
|
||||
one_punch_gui_input.tooltip = ({'rpg_settings.low_level', 30})
|
||||
if rpg_t.level < settings_level['aoe_punch_label'] then
|
||||
aoe_punch_gui_input.enabled = false
|
||||
aoe_punch_gui_input.tooltip = ({'rpg_settings.low_level', 30})
|
||||
else
|
||||
one_punch_gui_input.enabled = true
|
||||
one_punch_gui_input.tooltip = ({'rpg_settings.tooltip_check'})
|
||||
aoe_punch_gui_input.enabled = true
|
||||
aoe_punch_gui_input.tooltip = ({'rpg_settings.tooltip_check'})
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -698,8 +698,8 @@ function Public.extra_settings(player)
|
||||
data.stone_path_gui_input = stone_path_gui_input
|
||||
end
|
||||
|
||||
if rpg_extra.enable_one_punch then
|
||||
data.one_punch_gui_input = one_punch_gui_input
|
||||
if rpg_extra.enable_aoe_punch then
|
||||
data.aoe_punch_gui_input = aoe_punch_gui_input
|
||||
end
|
||||
|
||||
if rpg_extra.enable_auto_allocate then
|
||||
|
@ -15,6 +15,7 @@ local settings_frame_name = Gui.uid_name()
|
||||
local save_button_name = Gui.uid_name()
|
||||
local discard_button_name = Gui.uid_name()
|
||||
local draw_main_frame_name = Gui.uid_name()
|
||||
local close_main_frame_name = Gui.uid_name()
|
||||
local main_frame_name = Gui.uid_name()
|
||||
local settings_button_name = Gui.uid_name()
|
||||
local spell_gui_button_name = Gui.uid_name()
|
||||
@ -43,7 +44,7 @@ end
|
||||
Public.gui_settings_levels = {
|
||||
['reset_text_label'] = 50,
|
||||
['stone_path_label'] = 20,
|
||||
['one_punch_label'] = 30,
|
||||
['aoe_punch_label'] = 30,
|
||||
['flameboots_label'] = 100,
|
||||
['explosive_bullets_label'] = 50
|
||||
}
|
||||
@ -113,8 +114,8 @@ function Public.reset_table()
|
||||
this.rpg_extra.force_mana_per_tick = false
|
||||
this.rpg_extra.enable_stone_path = false
|
||||
this.rpg_extra.enable_auto_allocate = false
|
||||
this.rpg_extra.enable_one_punch = true
|
||||
this.rpg_extra.enable_one_punch_globally = false
|
||||
this.rpg_extra.enable_aoe_punch = true
|
||||
this.rpg_extra.enable_aoe_punch_globally = false
|
||||
this.rpg_extra.disable_get_heal_modifier_from_using_fish = false
|
||||
this.rpg_extra.tweaked_crafting_items = {
|
||||
['red-wire'] = true,
|
||||
@ -238,14 +239,14 @@ function Public.toggle_debug()
|
||||
end
|
||||
|
||||
--- Toggle debug - when you need to troubleshoot.
|
||||
function Public.toggle_debug_one_punch()
|
||||
if this.rpg_extra.debug_one_punch then
|
||||
this.rpg_extra.debug_one_punch = false
|
||||
function Public.toggle_debug_aoe_punch()
|
||||
if this.rpg_extra.debug_aoe_punch then
|
||||
this.rpg_extra.debug_aoe_punch = false
|
||||
else
|
||||
this.rpg_extra.debug_one_punch = true
|
||||
this.rpg_extra.debug_aoe_punch = true
|
||||
end
|
||||
|
||||
return this.rpg_extra.debug_one_punch
|
||||
return this.rpg_extra.debug_aoe_punch
|
||||
end
|
||||
|
||||
--- Debug only - when you need to troubleshoot.
|
||||
@ -366,20 +367,20 @@ function Public.enable_auto_allocate(value)
|
||||
return this.rpg_extra.enable_auto_allocate
|
||||
end
|
||||
|
||||
--- Enables/disabled stone-path-tile creation on mined.
|
||||
--- Enables/disabled aoe_punch.
|
||||
---@param value <boolean>
|
||||
function Public.enable_one_punch(value)
|
||||
this.rpg_extra.enable_one_punch = value or false
|
||||
function Public.enable_aoe_punch(value)
|
||||
this.rpg_extra.enable_aoe_punch = value or false
|
||||
|
||||
return this.rpg_extra.enable_one_punch
|
||||
return this.rpg_extra.enable_aoe_punch
|
||||
end
|
||||
|
||||
--- Enables/disabled stone-path-tile creation on mined.
|
||||
--- Enables/disabled aoe_punch.
|
||||
---@param value <boolean>
|
||||
function Public.enable_one_punch_globally(value)
|
||||
this.rpg_extra.enable_one_punch_globally = value or false
|
||||
function Public.enable_aoe_punch_globally(value)
|
||||
this.rpg_extra.enable_aoe_punch_globally = value or false
|
||||
|
||||
return this.rpg_extra.enable_one_punch_globally
|
||||
return this.rpg_extra.enable_aoe_punch_globally
|
||||
end
|
||||
|
||||
--- Retrieves the spells table or a given spell.
|
||||
@ -515,6 +516,7 @@ Public.settings_frame_name = settings_frame_name
|
||||
Public.save_button_name = save_button_name
|
||||
Public.discard_button_name = discard_button_name
|
||||
Public.draw_main_frame_name = draw_main_frame_name
|
||||
Public.close_main_frame_name = close_main_frame_name
|
||||
Public.main_frame_name = main_frame_name
|
||||
Public.settings_button_name = settings_button_name
|
||||
Public.spell_gui_button_name = spell_gui_button_name
|
||||
|
@ -69,8 +69,7 @@ function Public.main_gui(player, text)
|
||||
inside_table.add(
|
||||
{
|
||||
type = 'label',
|
||||
caption = 'We have played for ' ..
|
||||
Server.format_time(game.ticks_played) .. ' now.\nIf you want to take a quick break,\nplease vote to pause the waves for 5 minutes.'
|
||||
caption = 'We have played for ' .. Server.format_time(game.ticks_played) .. ' now.\nIf you want to take a quick break,\nplease vote to pause the waves for 5 minutes.'
|
||||
}
|
||||
)
|
||||
local info_sub_style = info_sub.style
|
||||
@ -200,6 +199,10 @@ Event.on_nth_tick(
|
||||
return
|
||||
end
|
||||
|
||||
if Server.format_time(game.ticks_played) == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local greeting = random_greetings[random(1, random_greetings_size)]
|
||||
|
||||
local players = game.connected_players
|
||||
|
@ -88,7 +88,7 @@ end
|
||||
|
||||
-- Removes the first 100 entries of a table
|
||||
local function overflow(t)
|
||||
for _=1,100,1 do
|
||||
for _ = 1, 100, 1 do
|
||||
table.remove(t, 1)
|
||||
end
|
||||
end
|
||||
@ -352,12 +352,7 @@ local function on_player_used_capsule(event)
|
||||
|
||||
local prefix = '[Capsule]'
|
||||
msg = format(player.name .. ' damaged: %s with: %s', get_entities(name, entities), name)
|
||||
local ban_msg =
|
||||
format(
|
||||
'Damaged: %s with: %s. This action was performed automatically. Visit getcomfy.eu/discord for forgiveness',
|
||||
get_entities(name, entities),
|
||||
name
|
||||
)
|
||||
local ban_msg = format('Damaged: %s with: %s. This action was performed automatically. Visit getcomfy.eu/discord for forgiveness', get_entities(name, entities), name)
|
||||
|
||||
do_action(player, prefix, msg, ban_msg, true)
|
||||
else
|
||||
@ -736,13 +731,7 @@ local function on_player_cancelled_crafting(event)
|
||||
|
||||
player.character.die('player')
|
||||
|
||||
Utils.action_warning(
|
||||
'[Crafting]',
|
||||
player.name ..
|
||||
' canceled their craft of item ' ..
|
||||
event.recipe.name ..
|
||||
' of total count ' .. crafting_queue_item_count .. ' in raw items (' .. crafted_items .. ' slots) but had no inventory left.'
|
||||
)
|
||||
Utils.action_warning('[Crafting]', player.name .. ' canceled their craft of item ' .. event.recipe.name .. ' of total count ' .. crafting_queue_item_count .. ' in raw items (' .. crafted_items .. ' slots) but had no inventory left.')
|
||||
end
|
||||
|
||||
if not this.cancel_crafting_history then
|
||||
@ -865,9 +854,9 @@ local function on_permission_string_imported(event)
|
||||
end
|
||||
|
||||
--- This is used for the RPG module, when casting capsules.
|
||||
---@param player <LuaPlayer>
|
||||
---@param position <EventPosition>
|
||||
---@param msg <string>
|
||||
---@param player userdata
|
||||
---@param position table
|
||||
---@param msg string
|
||||
function Public.insert_into_capsule_history(player, position, msg)
|
||||
if not this.capsule_history then
|
||||
this.capsule_history = {}
|
||||
@ -901,8 +890,8 @@ function Public.reset_tables()
|
||||
end
|
||||
|
||||
--- Add entity type to the whitelist so it gets logged.
|
||||
---@param key <string>
|
||||
---@param value <string>
|
||||
---@param key string
|
||||
---@param value string
|
||||
function Public.whitelist_types(key, value)
|
||||
if key and value then
|
||||
this.whitelist_types[key] = value
|
||||
@ -912,35 +901,35 @@ function Public.whitelist_types(key, value)
|
||||
end
|
||||
|
||||
--- If the event should also check trusted players.
|
||||
---@param value <string>
|
||||
---@param value string
|
||||
function Public.do_not_check_trusted(value)
|
||||
this.do_not_check_trusted = value or false
|
||||
return this.do_not_check_trusted
|
||||
end
|
||||
|
||||
--- If ANY actions should be performed when a player misbehaves.
|
||||
---@param value <string>
|
||||
---@param value string
|
||||
function Public.enable_capsule_warning(value)
|
||||
this.enable_capsule_warning = value or false
|
||||
return this.enable_capsule_warning
|
||||
end
|
||||
|
||||
--- If ANY actions should be performed when a player misbehaves.
|
||||
---@param value <string>
|
||||
---@param value string
|
||||
function Public.enable_capsule_cursor_warning(value)
|
||||
this.enable_capsule_cursor_warning = value or false
|
||||
return this.enable_capsule_cursor_warning
|
||||
end
|
||||
|
||||
--- If the script should jail a person instead of kicking them
|
||||
---@param value <string>
|
||||
---@param value string
|
||||
function Public.enable_jail(value)
|
||||
this.enable_jail = value or false
|
||||
return this.enable_jail
|
||||
end
|
||||
|
||||
--- Defines what the threshold for amount of explosives in chest should be - logged or not.
|
||||
---@param value <string>
|
||||
---@param value string
|
||||
function Public.explosive_threshold(value)
|
||||
if value then
|
||||
this.explosive_threshold = value
|
||||
@ -950,7 +939,7 @@ function Public.explosive_threshold(value)
|
||||
end
|
||||
|
||||
--- Defines what the threshold for amount of times before the script should take action.
|
||||
---@param value <string>
|
||||
---@param value string
|
||||
function Public.damage_entity_threshold(value)
|
||||
if value then
|
||||
this.damage_entity_threshold = value
|
||||
|
@ -103,6 +103,16 @@ function Public.get_actor()
|
||||
return '<server>'
|
||||
end
|
||||
|
||||
--- Iterates over all connected players
|
||||
---@param callback function
|
||||
function Public.iter_connected_players(callback)
|
||||
local players = game.connected_players
|
||||
for i = 1, #players do
|
||||
local player = players[i]
|
||||
callback(player)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.cast_bool(var)
|
||||
if var then
|
||||
return true
|
||||
|
@ -1,6 +1,6 @@
|
||||
local Server = require 'utils.server'
|
||||
local Event = require 'utils.event'
|
||||
local ComfyGui = require 'comfy_panel.main'
|
||||
local Gui = require 'utils.gui'
|
||||
local Color = require 'utils.color_presets'
|
||||
|
||||
local current_time_label = 'current_time_label'
|
||||
@ -111,7 +111,7 @@ commands.add_command(
|
||||
end
|
||||
)
|
||||
|
||||
ComfyGui.screen_to_bypass(current_time_label)
|
||||
Gui.screen_to_bypass(current_time_label)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_display_resolution_changed,
|
||||
|
@ -1,6 +1,6 @@
|
||||
local Server = require 'utils.server'
|
||||
local Event = require 'utils.event'
|
||||
local ComfyGui = require 'comfy_panel.main'
|
||||
local Gui = require 'utils.gui'
|
||||
local Color = require 'utils.color_presets'
|
||||
|
||||
local ups_label = 'ups_label'
|
||||
@ -106,7 +106,7 @@ commands.add_command(
|
||||
end
|
||||
)
|
||||
|
||||
ComfyGui.screen_to_bypass(ups_label)
|
||||
Gui.screen_to_bypass(ups_label)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_display_resolution_changed,
|
||||
|
@ -477,7 +477,7 @@ function Event.remove_removable_nth_tick_function(tick, name)
|
||||
local handlers = on_nth_tick_event_handlers[tick]
|
||||
local f = function_nth_tick_table[name]
|
||||
|
||||
for k, v in pairs(function_nth_tick_table[name]) do
|
||||
for _, v in pairs(function_nth_tick_table[name]) do
|
||||
local t = v.tick
|
||||
if t == tick then
|
||||
f = v.handler
|
||||
|
BIN
utils/files/arrow-down.png
Normal file
After Width: | Height: | Size: 364 B |
BIN
utils/files/arrow-up.png
Normal file
After Width: | Height: | Size: 373 B |
BIN
utils/files/infinity.png
Normal file
After Width: | Height: | Size: 524 B |
BIN
utils/files/pin-black.png
Normal file
After Width: | Height: | Size: 741 B |
BIN
utils/files/pin-white.png
Normal file
After Width: | Height: | Size: 780 B |
BIN
utils/files/settings-black.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
utils/files/settings-white.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
@ -1,6 +1,6 @@
|
||||
local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
local BottomFrame = require 'comfy_panel.bottom_frame'
|
||||
local BottomFrame = require 'utils.gui.bottom_frame'
|
||||
local Task = require 'utils.task'
|
||||
local Token = require 'utils.token'
|
||||
|
||||
|
506
utils/gui.lua
@ -2,17 +2,28 @@ local Token = require 'utils.token'
|
||||
local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
local mod_gui = require('__core__/lualib/mod-gui')
|
||||
local Server = require 'utils.server'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
|
||||
local tostring = tostring
|
||||
local next = next
|
||||
|
||||
local Gui = {}
|
||||
local Public = {}
|
||||
|
||||
-- local to this file
|
||||
local main_gui_tabs = {}
|
||||
local screen_elements = {}
|
||||
local on_visible_handlers = {}
|
||||
local on_pre_hidden_handlers = {}
|
||||
|
||||
-- global
|
||||
local data = {}
|
||||
local element_map = {}
|
||||
local settings = {}
|
||||
local settings = {
|
||||
mod_gui_top_frame = false
|
||||
}
|
||||
|
||||
Gui.token =
|
||||
Public.token =
|
||||
Global.register(
|
||||
{data = data, element_map = element_map, settings = settings},
|
||||
function(tbl)
|
||||
@ -22,19 +33,28 @@ Gui.token =
|
||||
end
|
||||
)
|
||||
|
||||
local on_visible_handlers = {}
|
||||
local on_pre_hidden_handlers = {}
|
||||
Public.settings_white_icon = 'file/utils/files/settings-white.png'
|
||||
Public.settings_black_icon = 'file/utils/files/settings-black.png'
|
||||
Public.pin_white_icon = 'file/utils/files/pin-white.png'
|
||||
Public.pin_black_icon = 'file/utils/files/pin-black.png'
|
||||
Public.infinite_icon = 'file/utils/files/infinity.png'
|
||||
Public.arrow_up_icon = 'file/utils/files/arrow-up.png'
|
||||
Public.arrow_down_icon = 'file/utils/files/arrow-down.png'
|
||||
|
||||
function Gui.uid_name()
|
||||
function Public.uid_name()
|
||||
return tostring(Token.uid())
|
||||
end
|
||||
|
||||
function Gui.uid()
|
||||
function Public.uid()
|
||||
return Token.uid()
|
||||
end
|
||||
|
||||
local main_frame_name = Public.uid_name()
|
||||
local main_button_name = Public.uid_name()
|
||||
local close_button_name = Public.uid_name()
|
||||
|
||||
-- Associates data with the LuaGuiElement. If data is nil then removes the data
|
||||
function Gui.set_data(element, value)
|
||||
function Public.set_data(element, value)
|
||||
local player_index = element.player_index
|
||||
local values = data[player_index]
|
||||
|
||||
@ -57,10 +77,10 @@ function Gui.set_data(element, value)
|
||||
values[element.index] = value
|
||||
end
|
||||
end
|
||||
local set_data = Gui.set_data
|
||||
local set_data = Public.set_data
|
||||
|
||||
-- Gets the Associated data with this LuaGuiElement if any.
|
||||
function Gui.get_data(element)
|
||||
function Public.get_data(element)
|
||||
if not element then
|
||||
return
|
||||
end
|
||||
@ -75,9 +95,97 @@ function Gui.get_data(element)
|
||||
return values[element.index]
|
||||
end
|
||||
|
||||
-- Adds a gui that is alike the factorio native gui.
|
||||
function Public.add_main_frame_with_toolbar(player, align, set_frame_name, set_settings_button_name, close_main_frame_name, name)
|
||||
if not align then
|
||||
return
|
||||
end
|
||||
local main_frame
|
||||
if align == 'left' then
|
||||
main_frame = player.gui.left.add {type = 'frame', name = set_frame_name, direction = 'vertical'}
|
||||
elseif align == 'center' then
|
||||
main_frame = player.gui.center.add {type = 'frame', name = set_frame_name, direction = 'vertical'}
|
||||
elseif align == 'screen' then
|
||||
main_frame = player.gui.screen.add {type = 'frame', name = set_frame_name, direction = 'vertical'}
|
||||
end
|
||||
|
||||
local titlebar = main_frame.add {type = 'flow', name = 'titlebar', direction = 'horizontal'}
|
||||
titlebar.style.horizontal_spacing = 8
|
||||
titlebar.style = 'horizontal_flow'
|
||||
|
||||
if align == 'screen' then
|
||||
titlebar.drag_target = main_frame
|
||||
end
|
||||
|
||||
titlebar.add {
|
||||
type = 'label',
|
||||
name = 'main_label',
|
||||
style = 'frame_title',
|
||||
caption = name,
|
||||
ignored_by_interaction = true
|
||||
}
|
||||
local widget = titlebar.add {type = 'empty-widget', style = 'draggable_space', ignored_by_interaction = true}
|
||||
widget.style.left_margin = 4
|
||||
widget.style.right_margin = 4
|
||||
widget.style.height = 24
|
||||
widget.style.horizontally_stretchable = true
|
||||
|
||||
if set_settings_button_name then
|
||||
titlebar.add {
|
||||
type = 'sprite-button',
|
||||
name = set_settings_button_name,
|
||||
style = 'frame_action_button',
|
||||
sprite = Public.settings_white_icon,
|
||||
mouse_button_filter = {'left'},
|
||||
hovered_sprite = Public.settings_black_icon,
|
||||
clicked_sprite = Public.settings_black_icon,
|
||||
tooltip = 'Settings',
|
||||
tags = {
|
||||
action = 'open_settings_gui'
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
if close_main_frame_name then
|
||||
titlebar.add {
|
||||
type = 'sprite-button',
|
||||
name = close_main_frame_name,
|
||||
style = 'frame_action_button',
|
||||
mouse_button_filter = {'left'},
|
||||
sprite = 'utility/close_white',
|
||||
hovered_sprite = 'utility/close_black',
|
||||
clicked_sprite = 'utility/close_black',
|
||||
tooltip = 'Close',
|
||||
tags = {
|
||||
action = 'close_main_frame_gui'
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
local inside_frame =
|
||||
main_frame.add {
|
||||
type = 'frame',
|
||||
style = 'b_inner_frame'
|
||||
}
|
||||
|
||||
local inside_frame_style = inside_frame.style
|
||||
inside_frame_style.vertically_stretchable = true
|
||||
inside_frame_style.maximal_height = 800
|
||||
|
||||
local inside_table =
|
||||
inside_frame.add {
|
||||
type = 'table',
|
||||
column_count = 1,
|
||||
name = 'inside_frame'
|
||||
}
|
||||
inside_table.style.padding = 3
|
||||
|
||||
return main_frame, inside_table
|
||||
end
|
||||
|
||||
local remove_data_recursively
|
||||
-- Removes data associated with LuaGuiElement and its children recursively.
|
||||
function Gui.remove_data_recursively(element)
|
||||
function Public.remove_data_recursively(element)
|
||||
set_data(element, nil)
|
||||
|
||||
local children = element.children
|
||||
@ -92,10 +200,10 @@ function Gui.remove_data_recursively(element)
|
||||
end
|
||||
end
|
||||
end
|
||||
remove_data_recursively = Gui.remove_data_recursively
|
||||
remove_data_recursively = Public.remove_data_recursively
|
||||
|
||||
local remove_children_data
|
||||
function Gui.remove_children_data(element)
|
||||
function Public.remove_children_data(element)
|
||||
local children = element.children
|
||||
|
||||
if not children then
|
||||
@ -109,14 +217,14 @@ function Gui.remove_children_data(element)
|
||||
end
|
||||
end
|
||||
end
|
||||
remove_children_data = Gui.remove_children_data
|
||||
remove_children_data = Public.remove_children_data
|
||||
|
||||
function Gui.destroy(element)
|
||||
function Public.destroy(element)
|
||||
remove_data_recursively(element)
|
||||
element.destroy()
|
||||
end
|
||||
|
||||
function Gui.clear(element)
|
||||
function Public.clear(element)
|
||||
remove_children_data(element)
|
||||
element.clear()
|
||||
end
|
||||
@ -190,6 +298,7 @@ local function custom_handler_factory(handlers)
|
||||
end
|
||||
|
||||
--luacheck: ignore custom_raise
|
||||
---@diagnostic disable-next-line: unused-function, unused-local
|
||||
local function custom_raise(handlers, element, player)
|
||||
local handler = handlers[element.name]
|
||||
if not handler then
|
||||
@ -200,78 +309,351 @@ local function custom_raise(handlers, element, player)
|
||||
end
|
||||
|
||||
-- Disabled the handler so it does not clean then data table of invalid data.
|
||||
function Gui.set_disable_clear_invalid_data(value)
|
||||
function Public.set_disable_clear_invalid_data(value)
|
||||
settings.disable_clear_invalid_data = value or false
|
||||
end
|
||||
|
||||
-- Gets state if the cleaner handler is active or false
|
||||
function Gui.get_disable_clear_invalid_data()
|
||||
function Public.get_disable_clear_invalid_data()
|
||||
return settings.disable_clear_invalid_data
|
||||
end
|
||||
|
||||
-- Fetches the main frame name
|
||||
function Public.get_main_frame(player)
|
||||
if not player then
|
||||
return false
|
||||
end
|
||||
|
||||
local left = player.gui.left
|
||||
local frame = left[main_frame_name]
|
||||
|
||||
if frame and frame.valid then
|
||||
local inside_frame = frame.children[2]
|
||||
if inside_frame and inside_frame.valid then
|
||||
local inside_table = inside_frame.children[1]
|
||||
if inside_table and inside_table.valid then
|
||||
return inside_table
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Fetches the parent frame name
|
||||
function Public.get_parent_frame(player)
|
||||
if not player then
|
||||
return false
|
||||
end
|
||||
|
||||
local left = player.gui.left
|
||||
local frame = left[main_frame_name]
|
||||
|
||||
if frame and frame.valid then
|
||||
return frame
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--- This adds the given gui to the top gui.
|
||||
---@param player userdata
|
||||
---@param frame userdata
|
||||
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
|
||||
return
|
||||
end
|
||||
|
||||
Public.get_button_flow(player).add(frame)
|
||||
end
|
||||
|
||||
---@param state boolean
|
||||
--- If we should use the new mod gui or not
|
||||
function Public.set_mod_gui_top_frame(state)
|
||||
settings.mod_gui_top_frame = state or false
|
||||
end
|
||||
|
||||
--- Get mod_gui_top_frame
|
||||
function Public.get_mod_gui_top_frame()
|
||||
return settings.mod_gui_top_frame
|
||||
end
|
||||
|
||||
--- This adds the given gui to the main gui.
|
||||
---@param tbl table
|
||||
function Public.add_tab_to_gui(tbl)
|
||||
if not tbl then
|
||||
return
|
||||
end
|
||||
|
||||
if not tbl.name then
|
||||
return
|
||||
end
|
||||
|
||||
if not tbl.caption then
|
||||
return
|
||||
end
|
||||
|
||||
if not tbl.id then
|
||||
return
|
||||
end
|
||||
|
||||
local admin = tbl.admin or false
|
||||
local only_server_sided = tbl.only_server_sided or false
|
||||
|
||||
if not main_gui_tabs[tbl.caption] then
|
||||
main_gui_tabs[tbl.caption] = {id = tbl.id, name = tbl.name, admin = admin, only_server_sided = only_server_sided}
|
||||
else
|
||||
error('Given name: ' .. tbl.caption .. ' already exists in table.')
|
||||
end
|
||||
end
|
||||
|
||||
function Public.screen_to_bypass(elem)
|
||||
screen_elements[elem] = true
|
||||
return screen_elements
|
||||
end
|
||||
|
||||
--- Fetches the main gui tabs. You are forbidden to write as this is local.
|
||||
---@param key string
|
||||
function Public.get(key)
|
||||
if key then
|
||||
return main_gui_tabs[key]
|
||||
else
|
||||
return main_gui_tabs
|
||||
end
|
||||
end
|
||||
|
||||
function Public.clear_main_frame(player)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
local frame = Public.get_main_frame(player)
|
||||
if frame then
|
||||
frame.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
function Public.clear_all_active_frames(player)
|
||||
for _, child in pairs(player.gui.left.children) do
|
||||
child.destroy()
|
||||
end
|
||||
for _, child in pairs(player.gui.screen.children) do
|
||||
if not screen_elements[child.name] then
|
||||
child.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.get_player_active_frame(player)
|
||||
local main_frame = Public.get_main_frame(player)
|
||||
if not main_frame then
|
||||
return false
|
||||
end
|
||||
|
||||
local panel = main_frame.tabbed_pane
|
||||
if not panel then
|
||||
return
|
||||
end
|
||||
local index = panel.selected_tab_index
|
||||
if not index then
|
||||
return panel.tabs[1].content
|
||||
end
|
||||
|
||||
return panel.tabs[index].content
|
||||
end
|
||||
|
||||
local function get_player_active_tab(player)
|
||||
local main_frame = Public.get_main_frame(player)
|
||||
if not main_frame then
|
||||
return false
|
||||
end
|
||||
|
||||
local panel = main_frame.tabbed_pane
|
||||
if not panel then
|
||||
return
|
||||
end
|
||||
local index = panel.selected_tab_index
|
||||
if not index then
|
||||
return panel.tabs[1].tab, panel.tabs[1].content
|
||||
end
|
||||
|
||||
return panel.tabs[index].tab, panel.tabs[index].content
|
||||
end
|
||||
|
||||
function Public.reload_active_tab(player, forced)
|
||||
local is_spamming = SpamProtection.is_spamming(player, nil, 'Reload active tab')
|
||||
if is_spamming and not forced then
|
||||
return
|
||||
end
|
||||
|
||||
local frame, main_tab = get_player_active_tab(player)
|
||||
if not frame then
|
||||
return
|
||||
end
|
||||
|
||||
local tab = main_gui_tabs[frame.caption]
|
||||
if not tab then
|
||||
return
|
||||
end
|
||||
local id = tab.id
|
||||
if not id then
|
||||
return
|
||||
end
|
||||
local func = Token.get(id)
|
||||
|
||||
local d = {
|
||||
player = player,
|
||||
frame = main_tab
|
||||
}
|
||||
|
||||
return func(d)
|
||||
end
|
||||
|
||||
local function top_button(player)
|
||||
if settings.mod_gui_top_frame then
|
||||
Public.add_mod_button(player, {type = 'sprite-button', name = main_button_name, sprite = 'item/raw-fish'})
|
||||
else
|
||||
if player.gui.top[main_button_name] then
|
||||
return
|
||||
end
|
||||
local button = player.gui.top.add({type = 'sprite-button', name = main_button_name, sprite = 'item/raw-fish'})
|
||||
button.style.minimal_height = 38
|
||||
button.style.maximal_height = 38
|
||||
button.style.minimal_width = 40
|
||||
button.style.padding = -2
|
||||
end
|
||||
end
|
||||
|
||||
local function draw_main_frame(player)
|
||||
local tabs = main_gui_tabs
|
||||
Public.clear_all_active_frames(player)
|
||||
|
||||
if Public.get_main_frame(player) then
|
||||
Public.get_main_frame(player).destroy()
|
||||
end
|
||||
|
||||
local frame, inside_frame = Public.add_main_frame_with_toolbar(player, 'left', main_frame_name, nil, close_button_name, 'Comfy Panel')
|
||||
|
||||
local tabbed_pane = inside_frame.add({type = 'tabbed-pane', name = 'tabbed_pane'})
|
||||
|
||||
for name, func in pairs(tabs) do
|
||||
if func.only_server_sided then
|
||||
local secs = Server.get_current_time()
|
||||
if secs then
|
||||
local tab = tabbed_pane.add({type = 'tab', caption = name, name = func.name})
|
||||
local name_frame = tabbed_pane.add({type = 'frame', name = name, direction = 'vertical'})
|
||||
name_frame.style.minimal_height = 480
|
||||
name_frame.style.maximal_height = 480
|
||||
name_frame.style.minimal_width = 800
|
||||
name_frame.style.maximal_width = 800
|
||||
tabbed_pane.add_tab(tab, name_frame)
|
||||
end
|
||||
elseif func.admin == true then
|
||||
if player.admin then
|
||||
local tab = tabbed_pane.add({type = 'tab', caption = name, name = func.name})
|
||||
local name_frame = tabbed_pane.add({type = 'frame', name = name, direction = 'vertical'})
|
||||
name_frame.style.minimal_height = 480
|
||||
name_frame.style.maximal_height = 480
|
||||
name_frame.style.minimal_width = 800
|
||||
name_frame.style.maximal_width = 800
|
||||
tabbed_pane.add_tab(tab, name_frame)
|
||||
end
|
||||
else
|
||||
local tab = tabbed_pane.add({type = 'tab', caption = name, name = func.name})
|
||||
local name_frame = tabbed_pane.add({type = 'frame', name = name, direction = 'vertical'})
|
||||
name_frame.style.minimal_height = 480
|
||||
name_frame.style.maximal_height = 480
|
||||
name_frame.style.minimal_width = 800
|
||||
name_frame.style.maximal_width = 800
|
||||
tabbed_pane.add_tab(tab, name_frame)
|
||||
end
|
||||
end
|
||||
|
||||
for _, child in pairs(tabbed_pane.children) do
|
||||
child.style.padding = 8
|
||||
child.style.left_padding = 2
|
||||
child.style.right_padding = 2
|
||||
end
|
||||
|
||||
Public.reload_active_tab(player, true)
|
||||
return frame, inside_frame
|
||||
end
|
||||
|
||||
function Public.call_existing_tab(player, name)
|
||||
local frame, inside_frame = draw_main_frame(player)
|
||||
if not frame then
|
||||
return
|
||||
end
|
||||
local tabbed_pane = inside_frame.tabbed_pane
|
||||
for key, v in pairs(tabbed_pane.tabs) do
|
||||
if v.tab.caption == name then
|
||||
tabbed_pane.selected_tab_index = key
|
||||
Public.reload_active_tab(player, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Register a handler for the on_gui_checked_state_changed event for LuaGuiElements with element_name.
|
||||
-- Can only have one handler per element name.
|
||||
-- Guarantees that the element and the player are valid when calling the handler.
|
||||
-- Adds a player field to the event table.
|
||||
Gui.on_checked_state_changed = handler_factory(defines.events.on_gui_checked_state_changed)
|
||||
Public.on_checked_state_changed = handler_factory(defines.events.on_gui_checked_state_changed)
|
||||
|
||||
-- Register a handler for the on_gui_click event for LuaGuiElements with element_name.
|
||||
-- Can only have one handler per element name.
|
||||
-- Guarantees that the element and the player are valid when calling the handler.
|
||||
-- Adds a player field to the event table.
|
||||
Gui.on_click = handler_factory(defines.events.on_gui_click)
|
||||
Public.on_click = handler_factory(defines.events.on_gui_click)
|
||||
|
||||
-- Register a handler for the on_gui_closed event for a custom LuaGuiElements with element_name.
|
||||
-- Can only have one handler per element name.
|
||||
-- Guarantees that the element and the player are valid when calling the handler.
|
||||
-- Adds a player field to the event table.
|
||||
Gui.on_custom_close = handler_factory(defines.events.on_gui_closed)
|
||||
Public.on_custom_close = handler_factory(defines.events.on_gui_closed)
|
||||
|
||||
-- Register a handler for the on_gui_elem_changed event for LuaGuiElements with element_name.
|
||||
-- Can only have one handler per element name.
|
||||
-- Guarantees that the element and the player are valid when calling the handler.
|
||||
-- Adds a player field to the event table.
|
||||
Gui.on_elem_changed = handler_factory(defines.events.on_gui_elem_changed)
|
||||
Public.on_elem_changed = handler_factory(defines.events.on_gui_elem_changed)
|
||||
|
||||
-- Register a handler for the on_gui_selection_state_changed event for LuaGuiElements with element_name.
|
||||
-- Can only have one handler per element name.
|
||||
-- Guarantees that the element and the player are valid when calling the handler.
|
||||
-- Adds a player field to the event table.
|
||||
Gui.on_selection_state_changed = handler_factory(defines.events.on_gui_selection_state_changed)
|
||||
Public.on_selection_state_changed = handler_factory(defines.events.on_gui_selection_state_changed)
|
||||
|
||||
-- Register a handler for the on_gui_text_changed event for LuaGuiElements with element_name.
|
||||
-- Can only have one handler per element name.
|
||||
-- Guarantees that the element and the player are valid when calling the handler.
|
||||
-- Adds a player field to the event table.
|
||||
Gui.on_text_changed = handler_factory(defines.events.on_gui_text_changed)
|
||||
Public.on_text_changed = handler_factory(defines.events.on_gui_text_changed)
|
||||
|
||||
-- Register a handler for the on_gui_value_changed event for LuaGuiElements with element_name.
|
||||
-- Can only have one handler per element name.
|
||||
-- Guarantees that the element and the player are valid when calling the handler.
|
||||
-- Adds a player field to the event table.
|
||||
Gui.on_value_changed = handler_factory(defines.events.on_gui_value_changed)
|
||||
Public.on_value_changed = handler_factory(defines.events.on_gui_value_changed)
|
||||
|
||||
-- Register a handler for when the player shows the top LuaGuiElements with element_name.
|
||||
-- Assuming the element_name has been added with Gui.allow_player_to_toggle_top_element_visibility.
|
||||
-- Assuming the element_name has been added with Public.allow_player_to_toggle_top_element_visibility.
|
||||
-- Can only have one handler per element name.
|
||||
-- Guarantees that the element and the player are valid when calling the handler.
|
||||
-- Adds a player field to the event table.
|
||||
Gui.on_player_show_top = custom_handler_factory(on_visible_handlers)
|
||||
Public.on_player_show_top = custom_handler_factory(on_visible_handlers)
|
||||
|
||||
-- Register a handler for when the player hides the top LuaGuiElements with element_name.
|
||||
-- Assuming the element_name has been added with Gui.allow_player_to_toggle_top_element_visibility.
|
||||
-- Assuming the element_name has been added with Public.allow_player_to_toggle_top_element_visibility.
|
||||
-- Can only have one handler per element name.
|
||||
-- Guarantees that the element and the player are valid when calling the handler.
|
||||
-- Adds a player field to the event table.
|
||||
Gui.on_pre_player_hide_top = custom_handler_factory(on_pre_hidden_handlers)
|
||||
Public.on_pre_player_hide_top = custom_handler_factory(on_pre_hidden_handlers)
|
||||
|
||||
if _DEBUG then
|
||||
local concat = table.concat
|
||||
|
||||
local names = {}
|
||||
Gui.names = names
|
||||
Public.names = names
|
||||
|
||||
function Gui.uid_name()
|
||||
function Public.uid_name()
|
||||
local info = debug.getinfo(2, 'Sl')
|
||||
local filepath = info.source:match('^.+/currently%-playing/(.+)$'):sub(1, -5)
|
||||
local line = info.currentline
|
||||
@ -284,7 +666,7 @@ if _DEBUG then
|
||||
return token
|
||||
end
|
||||
|
||||
function Gui.set_data(element, value)
|
||||
function Public.set_data(element, value)
|
||||
local player_index = element.player_index
|
||||
local values = data[player_index]
|
||||
|
||||
@ -311,18 +693,66 @@ if _DEBUG then
|
||||
element_map[index] = element
|
||||
end
|
||||
end
|
||||
set_data = Gui.set_data
|
||||
set_data = Public.set_data
|
||||
|
||||
function Gui.data()
|
||||
function Public.data()
|
||||
return data
|
||||
end
|
||||
|
||||
function Gui.element_map()
|
||||
function Public.element_map()
|
||||
return element_map
|
||||
end
|
||||
end
|
||||
|
||||
Gui.get_button_flow = mod_gui.get_button_flow
|
||||
Gui.mod_button = mod_gui.get_button_flow
|
||||
Public.get_button_flow = mod_gui.get_button_flow
|
||||
Public.mod_button = mod_gui.get_button_flow
|
||||
|
||||
return Gui
|
||||
Public.on_click(
|
||||
main_button_name,
|
||||
function(event)
|
||||
local is_spamming = SpamProtection.is_spamming(event.player, nil, 'Main button')
|
||||
if is_spamming then
|
||||
return
|
||||
end
|
||||
local player = event.player
|
||||
local frame = Public.get_parent_frame(player)
|
||||
if frame then
|
||||
frame.destroy()
|
||||
else
|
||||
draw_main_frame(player)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Public.on_click(
|
||||
close_button_name,
|
||||
function(event)
|
||||
local is_spamming = SpamProtection.is_spamming(event.player, nil, 'Main button')
|
||||
if is_spamming then
|
||||
return
|
||||
end
|
||||
local player = event.player
|
||||
local frame = Public.get_parent_frame(player)
|
||||
if frame then
|
||||
frame.destroy()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_created,
|
||||
function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
top_button(player)
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_joined_game,
|
||||
function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
top_button(player)
|
||||
end
|
||||
)
|
||||
|
||||
return Public
|
||||
|
@ -2,13 +2,13 @@
|
||||
|
||||
local Event = require 'utils.event'
|
||||
local Jailed = require 'utils.datastore.jail_data'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local Gui = require 'utils.gui'
|
||||
local AntiGrief = require 'utils.antigrief'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
local Token = require 'utils.token'
|
||||
|
||||
local lower = string.lower
|
||||
local module_name = 'Admin'
|
||||
local module_name = Gui.uid_name()
|
||||
|
||||
local function admin_only_message(str)
|
||||
for _, player in pairs(game.connected_players) do
|
||||
@ -49,10 +49,7 @@ local function bring_player(player, source_player)
|
||||
local pos = source_player.surface.find_non_colliding_position('character', source_player.position, 50, 1)
|
||||
if pos then
|
||||
player.teleport(pos, source_player.surface)
|
||||
game.print(
|
||||
player.name .. ' has been teleported to ' .. source_player.name .. '. ' .. bring_player_messages[math.random(1, #bring_player_messages)],
|
||||
{r = 0.98, g = 0.66, b = 0.22}
|
||||
)
|
||||
game.print(player.name .. ' has been teleported to ' .. source_player.name .. '. ' .. bring_player_messages[math.random(1, #bring_player_messages)], {r = 0.98, g = 0.66, b = 0.22})
|
||||
end
|
||||
end
|
||||
|
||||
@ -67,10 +64,7 @@ local function go_to_player(player, source_player)
|
||||
local pos = player.surface.find_non_colliding_position('character', player.position, 50, 1)
|
||||
if pos then
|
||||
source_player.teleport(pos, player.surface)
|
||||
game.print(
|
||||
source_player.name .. ' is visiting ' .. player.name .. '. ' .. go_to_player_messages[math.random(1, #go_to_player_messages)],
|
||||
{r = 0.98, g = 0.66, b = 0.22}
|
||||
)
|
||||
game.print(source_player.name .. ' is visiting ' .. player.name .. '. ' .. go_to_player_messages[math.random(1, #go_to_player_messages)], {r = 0.98, g = 0.66, b = 0.22})
|
||||
end
|
||||
end
|
||||
|
||||
@ -338,11 +332,11 @@ local function text_changed(event)
|
||||
local antigrief = AntiGrief.get()
|
||||
local player = game.get_player(event.player_index)
|
||||
|
||||
local frame = Tabs.comfy_panel_get_active_frame(player)
|
||||
local frame = Gui.get_player_active_frame(player)
|
||||
if not frame then
|
||||
return
|
||||
end
|
||||
if frame.name ~= module_name then
|
||||
if frame.name ~= 'Admin' then
|
||||
return
|
||||
end
|
||||
|
||||
@ -644,15 +638,12 @@ local function on_gui_click(event)
|
||||
|
||||
local name = event.element.name
|
||||
|
||||
if name == 'tab_' .. module_name then
|
||||
local is_spamming = SpamProtection.is_spamming(player, nil, 'Admin tab_Admin')
|
||||
if is_spamming then
|
||||
return
|
||||
end
|
||||
local frame = Gui.get_player_active_frame(player)
|
||||
if not frame then
|
||||
return
|
||||
end
|
||||
|
||||
local frame = Tabs.comfy_panel_get_active_frame(player)
|
||||
if not frame then
|
||||
if frame.name ~= 'Admin' then
|
||||
return
|
||||
end
|
||||
|
||||
@ -661,10 +652,6 @@ local function on_gui_click(event)
|
||||
return
|
||||
end
|
||||
|
||||
if frame.name ~= module_name then
|
||||
return
|
||||
end
|
||||
|
||||
local is_spamming = SpamProtection.is_spamming(player, nil, 'Admin Gui Click')
|
||||
if is_spamming then
|
||||
return
|
||||
@ -727,11 +714,11 @@ local function on_gui_selection_state_changed(event)
|
||||
end
|
||||
global.admin_panel_selected_history_index[player.name] = event.element.selected_index
|
||||
|
||||
local frame = Tabs.comfy_panel_get_active_frame(player)
|
||||
local frame = Gui.get_player_active_frame(player)
|
||||
if not frame then
|
||||
return
|
||||
end
|
||||
if frame.name ~= module_name then
|
||||
if frame.name ~= 'Admin' then
|
||||
return
|
||||
end
|
||||
|
||||
@ -748,11 +735,11 @@ local function on_gui_selection_state_changed(event)
|
||||
end
|
||||
global.admin_panel_selected_player_index[player.name] = event.element.selected_index
|
||||
|
||||
local frame = Tabs.comfy_panel_get_active_frame(player)
|
||||
local frame = Gui.get_player_active_frame(player)
|
||||
if not frame then
|
||||
return
|
||||
end
|
||||
if frame.name ~= module_name then
|
||||
if frame.name ~= 'Admin' then
|
||||
return
|
||||
end
|
||||
|
||||
@ -766,7 +753,15 @@ local function on_gui_selection_state_changed(event)
|
||||
end
|
||||
end
|
||||
|
||||
Tabs.add_tab_to_gui({name = module_name, id = create_admin_panel_token, admin = true})
|
||||
Gui.add_tab_to_gui({name = module_name, caption = 'Admin', id = create_admin_panel_token, admin = true})
|
||||
|
||||
Gui.on_click(
|
||||
module_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
Gui.reload_active_tab(player)
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(defines.events.on_gui_text_changed, text_changed)
|
||||
Event.add(defines.events.on_gui_click, on_gui_click)
|
@ -1,7 +1,6 @@
|
||||
local Misc = require 'utils.commands.misc'
|
||||
local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
local ComfyGui = require 'comfy_panel.main'
|
||||
local Gui = require 'utils.gui'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
|
||||
@ -212,7 +211,7 @@ local function set_location(player, state)
|
||||
end
|
||||
|
||||
--- Activates the custom buttons
|
||||
---@param boolean
|
||||
---@param value boolean
|
||||
function Public.activate_custom_buttons(value)
|
||||
if value then
|
||||
this.activate_custom_buttons = value
|
||||
@ -288,6 +287,6 @@ Event.add(
|
||||
|
||||
Public.bottom_guis_frame = bottom_guis_frame
|
||||
Public.set_location = set_location
|
||||
ComfyGui.screen_to_bypass(bottom_guis_frame)
|
||||
Gui.screen_to_bypass(bottom_guis_frame)
|
||||
|
||||
return Public
|
@ -3,14 +3,13 @@ local Event = require 'utils.event'
|
||||
local Color = require 'utils.color_presets'
|
||||
local SessionData = require 'utils.datastore.session_data'
|
||||
local Utils = require 'utils.core'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
local BottomFrame = require 'comfy_panel.bottom_frame'
|
||||
local BottomFrame = require 'utils.gui.bottom_frame'
|
||||
local Token = require 'utils.token'
|
||||
local Global = require 'utils.global'
|
||||
local Gui = require 'utils.gui'
|
||||
|
||||
local module_name = 'Config'
|
||||
local module_name = Gui.uid_name()
|
||||
|
||||
local Public = {}
|
||||
|
||||
@ -120,14 +119,14 @@ local function trust_connected_players()
|
||||
end
|
||||
|
||||
local functions = {
|
||||
['comfy_panel_spectator_switch'] = function(event)
|
||||
['spectator_switch'] = function(event)
|
||||
if event.element.switch_state == 'left' then
|
||||
game.get_player(event.player_index).spectator = true
|
||||
else
|
||||
game.get_player(event.player_index).spectator = false
|
||||
end
|
||||
end,
|
||||
['comfy_panel_bottom_location'] = function(event)
|
||||
['bottom_location'] = function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if event.element.switch_state == 'left' then
|
||||
BottomFrame.set_location(player, 'bottom_left')
|
||||
@ -135,7 +134,7 @@ local functions = {
|
||||
BottomFrame.set_location(player, 'bottom_right')
|
||||
end
|
||||
end,
|
||||
['comfy_panel_middle_location'] = function(event)
|
||||
['middle_location'] = function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
local data = BottomFrame.get_player_data(player)
|
||||
if event.element.switch_state == 'left' then
|
||||
@ -151,7 +150,7 @@ local functions = {
|
||||
|
||||
BottomFrame.set_location(player, data.bottom_state)
|
||||
end,
|
||||
['comfy_panel_portable_button'] = function(event)
|
||||
['portable_button'] = function(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
local data = BottomFrame.get_player_data(player)
|
||||
if event.element.switch_state == 'left' then
|
||||
@ -168,14 +167,14 @@ local functions = {
|
||||
|
||||
BottomFrame.set_location(player, data.bottom_state)
|
||||
end,
|
||||
['comfy_panel_auto_hotbar_switch'] = function(event)
|
||||
['auto_hotbar_switch'] = function(event)
|
||||
if event.element.switch_state == 'left' then
|
||||
global.auto_hotbar_enabled[event.player_index] = true
|
||||
else
|
||||
global.auto_hotbar_enabled[event.player_index] = false
|
||||
end
|
||||
end,
|
||||
['comfy_panel_blueprint_toggle'] = function(event)
|
||||
['blueprint_toggle'] = function(event)
|
||||
if event.element.switch_state == 'left' then
|
||||
game.permissions.get_group('Default').set_allows_action(defines.input_action.open_blueprint_library_gui, true)
|
||||
game.permissions.get_group('Default').set_allows_action(defines.input_action.import_blueprint_string, true)
|
||||
@ -186,7 +185,7 @@ local functions = {
|
||||
get_actor(event, '[Blueprints]', 'has disabled blueprints!')
|
||||
end
|
||||
end,
|
||||
['comfy_panel_spaghett_toggle'] = function(event)
|
||||
['spaghett_toggle'] = function(event)
|
||||
if event.element.switch_state == 'left' then
|
||||
this.gui_config.spaghett.enabled = true
|
||||
get_actor(event, '[Spaghett]', 'has enabled spaghett mode!')
|
||||
@ -225,7 +224,7 @@ local functions = {
|
||||
}
|
||||
|
||||
local poll_function = {
|
||||
['comfy_panel_poll_trusted_toggle'] = function(event)
|
||||
['poll_trusted_toggle'] = function(event)
|
||||
if event.element.switch_state == 'left' then
|
||||
this.gui_config.poll_trusted = true
|
||||
get_actor(event, '[Poll Mode]', 'has disabled non-trusted people to do polls.')
|
||||
@ -234,8 +233,8 @@ local poll_function = {
|
||||
get_actor(event, '[Poll Mode]', 'has allowed non-trusted people to do polls.')
|
||||
end
|
||||
end,
|
||||
['comfy_panel_poll_no_notify_toggle'] = function(event)
|
||||
local poll = is_loaded('comfy_panel.poll')
|
||||
['poll_no_notify_toggle'] = function(event)
|
||||
local poll = is_loaded('utils.gui.poll')
|
||||
local poll_table = poll.get_no_notify_players()
|
||||
if event.element.switch_state == 'left' then
|
||||
poll_table[event.player_index] = false
|
||||
@ -246,7 +245,7 @@ local poll_function = {
|
||||
}
|
||||
|
||||
local antigrief_functions = {
|
||||
['comfy_panel_disable_antigrief'] = function(event)
|
||||
['disable_antigrief'] = function(event)
|
||||
local AG = Antigrief.get()
|
||||
if event.element.switch_state == 'left' then
|
||||
AG.enabled = true
|
||||
@ -260,7 +259,7 @@ local antigrief_functions = {
|
||||
}
|
||||
|
||||
local fortress_functions = {
|
||||
['comfy_panel_disable_fullness'] = function(event)
|
||||
['disable_fullness'] = function(event)
|
||||
local Fullness = is_loaded('modules.check_fullness')
|
||||
local Module = Fullness.get()
|
||||
if event.element.switch_state == 'left' then
|
||||
@ -271,7 +270,7 @@ local fortress_functions = {
|
||||
get_actor(event, '[Fullness]', 'has disabled the inventory fullness function.')
|
||||
end
|
||||
end,
|
||||
['comfy_panel_offline_players'] = function(event)
|
||||
['offline_players'] = function(event)
|
||||
local WPT = is_loaded('maps.mountain_fortress_v3.table')
|
||||
local Module = WPT.get()
|
||||
if event.element.switch_state == 'left' then
|
||||
@ -282,7 +281,7 @@ local fortress_functions = {
|
||||
get_actor(event, '[Offline Players]', 'has disabled the offline player function.')
|
||||
end
|
||||
end,
|
||||
['comfy_panel_collapse_grace'] = function(event)
|
||||
['collapse_grace'] = function(event)
|
||||
local WPT = is_loaded('maps.mountain_fortress_v3.table')
|
||||
local Module = WPT.get()
|
||||
if event.element.switch_state == 'left' then
|
||||
@ -293,7 +292,7 @@ local fortress_functions = {
|
||||
get_actor(event, '[Collapse]', 'has disabled the collapse function. You must breach the first zone for collapse to occur!')
|
||||
end
|
||||
end,
|
||||
['comfy_panel_spill_items_to_surface'] = function(event)
|
||||
['spill_items_to_surface'] = function(event)
|
||||
local WPT = is_loaded('maps.mountain_fortress_v3.table')
|
||||
local Module = WPT.get()
|
||||
if event.element.switch_state == 'left' then
|
||||
@ -304,7 +303,7 @@ local fortress_functions = {
|
||||
get_actor(event, '[Item Spill]', 'has disabled the item spillage function. Ores no longer drop to surface when mining.')
|
||||
end
|
||||
end,
|
||||
['comfy_panel_void_or_tile'] = function(event)
|
||||
['void_or_tile'] = function(event)
|
||||
local WPT = is_loaded('maps.mountain_fortress_v3.table')
|
||||
local Module = WPT.get()
|
||||
if event.element.switch_state == 'left' then
|
||||
@ -315,7 +314,7 @@ local fortress_functions = {
|
||||
get_actor(event, '[Void]', 'has changes the tiles of the zones to: dark-tiles (flammable tiles)')
|
||||
end
|
||||
end,
|
||||
['comfy_panel_trusted_only_car_tanks'] = function(event)
|
||||
['trusted_only_car_tanks'] = function(event)
|
||||
local WPT = is_loaded('maps.mountain_fortress_v3.table')
|
||||
local Module = WPT.get()
|
||||
if event.element.switch_state == 'left' then
|
||||
@ -326,7 +325,7 @@ local fortress_functions = {
|
||||
get_actor(event, '[Market]', 'has changed so everybody can buy car/tanks.', true)
|
||||
end
|
||||
end,
|
||||
['comfy_panel_allow_decon'] = function(event)
|
||||
['allow_decon'] = function(event)
|
||||
local WPT = is_loaded('maps.mountain_fortress_v3.table')
|
||||
if event.element.switch_state == 'left' then
|
||||
local limited_group = game.permissions.get_group('limited')
|
||||
@ -344,7 +343,7 @@ local fortress_functions = {
|
||||
get_actor(event, '[Decon]', 'has disabled decon on car/tanks/trains.', true)
|
||||
end
|
||||
end,
|
||||
['comfy_panel_christmas_mode'] = function(event)
|
||||
['christmas_mode'] = function(event)
|
||||
local WPT = is_loaded('maps.mountain_fortress_v3.table')
|
||||
if event.element.switch_state == 'left' then
|
||||
WPT.set('winter_mode', true)
|
||||
@ -425,13 +424,7 @@ local function build_config_gui(data)
|
||||
if player.spectator then
|
||||
switch_state = 'left'
|
||||
end
|
||||
add_switch(
|
||||
scroll_pane,
|
||||
switch_state,
|
||||
'comfy_panel_spectator_switch',
|
||||
{'gui.spectator_mode'},
|
||||
{'gui-description.spectator_mode'}
|
||||
)
|
||||
add_switch(scroll_pane, switch_state, 'spectator_switch', {'gui.spectator_mode'}, {'gui-description.spectator_mode'})
|
||||
|
||||
scroll_pane.add({type = 'line'})
|
||||
|
||||
@ -440,24 +433,18 @@ local function build_config_gui(data)
|
||||
if global.auto_hotbar_enabled[player.index] then
|
||||
switch_state = 'left'
|
||||
end
|
||||
add_switch(scroll_pane, switch_state, 'comfy_panel_auto_hotbar_switch', 'AutoHotbar', 'Automatically fills your hotbar with placeable items.')
|
||||
add_switch(scroll_pane, switch_state, 'auto_hotbar_switch', 'AutoHotbar', 'Automatically fills your hotbar with placeable items.')
|
||||
scroll_pane.add({type = 'line'})
|
||||
end
|
||||
|
||||
local poll = is_loaded('comfy_panel.poll')
|
||||
local poll = is_loaded('utils.gui.poll')
|
||||
if poll then
|
||||
local poll_table = poll.get_no_notify_players()
|
||||
switch_state = 'right'
|
||||
if not poll_table[player.index] then
|
||||
switch_state = 'left'
|
||||
end
|
||||
add_switch(
|
||||
scroll_pane,
|
||||
switch_state,
|
||||
'comfy_panel_poll_no_notify_toggle',
|
||||
{'gui.notify_on_polls'},
|
||||
{'gui-description.notify_on_polls'}
|
||||
)
|
||||
add_switch(scroll_pane, switch_state, 'poll_no_notify_toggle', {'gui.notify_on_polls'}, {'gui-description.notify_on_polls'})
|
||||
scroll_pane.add({type = 'line'})
|
||||
end
|
||||
|
||||
@ -478,13 +465,7 @@ local function build_config_gui(data)
|
||||
if bottom_frame and bottom_frame.bottom_state == 'bottom_left' then
|
||||
switch_state = 'left'
|
||||
end
|
||||
add_switch(
|
||||
scroll_pane,
|
||||
switch_state,
|
||||
'comfy_panel_bottom_location',
|
||||
'Position - bottom',
|
||||
'Toggle to select if you want the bottom button on the left side or the right side.'
|
||||
)
|
||||
add_switch(scroll_pane, switch_state, 'bottom_location', 'Position - bottom', 'Toggle to select if you want the bottom button on the left side or the right side.')
|
||||
|
||||
scroll_pane.add({type = 'line'})
|
||||
|
||||
@ -492,13 +473,7 @@ local function build_config_gui(data)
|
||||
if bottom_frame and bottom_frame.above then
|
||||
switch_state = 'left'
|
||||
end
|
||||
add_switch(
|
||||
scroll_pane,
|
||||
switch_state,
|
||||
'comfy_panel_middle_location',
|
||||
'Position - middle',
|
||||
'Toggle to select if you want the bottom button above the quickbar or the side of the quickbar.'
|
||||
)
|
||||
add_switch(scroll_pane, switch_state, 'middle_location', 'Position - middle', 'Toggle to select if you want the bottom button above the quickbar or the side of the quickbar.')
|
||||
|
||||
scroll_pane.add({type = 'line'})
|
||||
|
||||
@ -506,13 +481,7 @@ local function build_config_gui(data)
|
||||
if bottom_frame and bottom_frame.portable then
|
||||
switch_state = 'left'
|
||||
end
|
||||
add_switch(
|
||||
scroll_pane,
|
||||
switch_state,
|
||||
'comfy_panel_portable_button',
|
||||
'Position - portable',
|
||||
'Toggle to select if you want the bottom button to be portable or not.'
|
||||
)
|
||||
add_switch(scroll_pane, switch_state, 'portable_button', 'Position - portable', 'Toggle to select if you want the bottom button to be portable or not.')
|
||||
scroll_pane.add({type = 'line'})
|
||||
end
|
||||
|
||||
@ -532,7 +501,7 @@ local function build_config_gui(data)
|
||||
if game.permissions.get_group('Default').allows_action(defines.input_action.open_blueprint_library_gui) then
|
||||
switch_state = 'left'
|
||||
end
|
||||
add_switch(scroll_pane, switch_state, 'comfy_panel_blueprint_toggle', 'Blueprint Library', 'Toggles the usage of blueprint strings and the library.')
|
||||
add_switch(scroll_pane, switch_state, 'blueprint_toggle', 'Blueprint Library', 'Toggles the usage of blueprint strings and the library.')
|
||||
|
||||
scroll_pane.add({type = 'line'})
|
||||
|
||||
@ -548,13 +517,7 @@ local function build_config_gui(data)
|
||||
if this.gui_config.spaghett.enabled then
|
||||
switch_state = 'left'
|
||||
end
|
||||
add_switch(
|
||||
scroll_pane,
|
||||
switch_state,
|
||||
'comfy_panel_spaghett_toggle',
|
||||
{'gui.spaghett_mode'},
|
||||
{'gui-description.spaghett_mode'}
|
||||
)
|
||||
add_switch(scroll_pane, switch_state, 'spaghett_toggle', {'gui.spaghett_mode'}, {'gui-description.spaghett_mode'})
|
||||
|
||||
if poll then
|
||||
scroll_pane.add({type = 'line'})
|
||||
@ -562,7 +525,7 @@ local function build_config_gui(data)
|
||||
if this.gui_config.poll_trusted then
|
||||
switch_state = 'left'
|
||||
end
|
||||
add_switch(scroll_pane, switch_state, 'comfy_panel_poll_trusted_toggle', 'Poll mode', 'Disables non-trusted plebs to create polls.')
|
||||
add_switch(scroll_pane, switch_state, 'poll_trusted_toggle', 'Poll mode', 'Disables non-trusted plebs to create polls.')
|
||||
end
|
||||
|
||||
scroll_pane.add({type = 'line'})
|
||||
@ -580,7 +543,7 @@ local function build_config_gui(data)
|
||||
if AG.enabled then
|
||||
switch_state = 'left'
|
||||
end
|
||||
add_switch(scroll_pane, switch_state, 'comfy_panel_disable_antigrief', 'Antigrief', 'Toggle antigrief function.')
|
||||
add_switch(scroll_pane, switch_state, 'disable_antigrief', 'Antigrief', 'Toggle antigrief function.')
|
||||
scroll_pane.add({type = 'line'})
|
||||
|
||||
if is_loaded('maps.biter_battles_v2.main') then
|
||||
@ -599,14 +562,7 @@ local function build_config_gui(data)
|
||||
if global.bb_settings.team_balancing then
|
||||
team_balancing_state = 'left'
|
||||
end
|
||||
local switch =
|
||||
add_switch(
|
||||
scroll_pane,
|
||||
team_balancing_state,
|
||||
'bb_team_balancing_toggle',
|
||||
'Team Balancing',
|
||||
'Players can only join a team that has less or equal players than the opposing.'
|
||||
)
|
||||
local switch = add_switch(scroll_pane, team_balancing_state, 'bb_team_balancing_toggle', 'Team Balancing', 'Players can only join a team that has less or equal players than the opposing.')
|
||||
if not admin then
|
||||
switch.ignored_by_interaction = true
|
||||
end
|
||||
@ -617,14 +573,7 @@ local function build_config_gui(data)
|
||||
if global.bb_settings.only_admins_vote then
|
||||
only_admins_vote_state = 'left'
|
||||
end
|
||||
local only_admins_vote_switch =
|
||||
add_switch(
|
||||
scroll_pane,
|
||||
only_admins_vote_state,
|
||||
'bb_only_admins_vote',
|
||||
'Admin Vote',
|
||||
'Only admins can vote for map difficulty. Clears all currently existing votes.'
|
||||
)
|
||||
local only_admins_vote_switch = add_switch(scroll_pane, only_admins_vote_state, 'bb_only_admins_vote', 'Admin Vote', 'Only admins can vote for map difficulty. Clears all currently existing votes.')
|
||||
if not admin then
|
||||
only_admins_vote_switch.ignored_by_interaction = true
|
||||
end
|
||||
@ -648,13 +597,7 @@ local function build_config_gui(data)
|
||||
if full.fullness_enabled then
|
||||
switch_state = 'left'
|
||||
end
|
||||
add_switch(
|
||||
scroll_pane,
|
||||
switch_state,
|
||||
'comfy_panel_disable_fullness',
|
||||
'Inventory Fullness',
|
||||
'On = Enables inventory fullness.\nOff = Disables inventory fullness.'
|
||||
)
|
||||
add_switch(scroll_pane, switch_state, 'disable_fullness', 'Inventory Fullness', 'On = Enables inventory fullness.\nOff = Disables inventory fullness.')
|
||||
|
||||
scroll_pane.add({type = 'line'})
|
||||
|
||||
@ -664,13 +607,7 @@ local function build_config_gui(data)
|
||||
if Module.offline_players_enabled then
|
||||
switch_state = 'left'
|
||||
end
|
||||
add_switch(
|
||||
scroll_pane,
|
||||
switch_state,
|
||||
'comfy_panel_offline_players',
|
||||
'Offline Players',
|
||||
'On = Enables offline player inventory drop.\nOff = Disables offline player inventory drop.'
|
||||
)
|
||||
add_switch(scroll_pane, switch_state, 'offline_players', 'Offline Players', 'On = Enables offline player inventory drop.\nOff = Disables offline player inventory drop.')
|
||||
|
||||
scroll_pane.add({type = 'line'})
|
||||
|
||||
@ -678,13 +615,7 @@ local function build_config_gui(data)
|
||||
if Module.collapse_grace then
|
||||
switch_state = 'left'
|
||||
end
|
||||
add_switch(
|
||||
scroll_pane,
|
||||
switch_state,
|
||||
'comfy_panel_collapse_grace',
|
||||
'Collapse',
|
||||
'On = Enables collapse after wave 100.\nOff = Disables collapse - you must breach the first zone for collapse to occur.'
|
||||
)
|
||||
add_switch(scroll_pane, switch_state, 'collapse_grace', 'Collapse', 'On = Enables collapse after wave 100.\nOff = Disables collapse - you must breach the first zone for collapse to occur.')
|
||||
|
||||
scroll_pane.add({type = 'line'})
|
||||
|
||||
@ -692,57 +623,33 @@ local function build_config_gui(data)
|
||||
if Module.spill_items_to_surface then
|
||||
switch_state = 'left'
|
||||
end
|
||||
add_switch(
|
||||
scroll_pane,
|
||||
switch_state,
|
||||
'comfy_panel_spill_items_to_surface',
|
||||
'Spill Ores',
|
||||
'On = Enables ore spillage to surface when mining.\nOff = Disables ore spillage to surface when mining.'
|
||||
)
|
||||
add_switch(scroll_pane, switch_state, 'spill_items_to_surface', 'Spill Ores', 'On = Enables ore spillage to surface when mining.\nOff = Disables ore spillage to surface when mining.')
|
||||
scroll_pane.add({type = 'line'})
|
||||
|
||||
switch_state = 'right'
|
||||
if Module.void_or_tile then
|
||||
switch_state = 'left'
|
||||
end
|
||||
add_switch(
|
||||
scroll_pane,
|
||||
switch_state,
|
||||
'comfy_panel_void_or_tile',
|
||||
'Void Tiles',
|
||||
'On = Changes the tiles to out-of-map.\nOff = Changes the tiles to lab-dark-2'
|
||||
)
|
||||
add_switch(scroll_pane, switch_state, 'void_or_tile', 'Void Tiles', 'On = Changes the tiles to out-of-map.\nOff = Changes the tiles to lab-dark-2')
|
||||
scroll_pane.add({type = 'line'})
|
||||
|
||||
switch_state = 'right'
|
||||
if Module.trusted_only_car_tanks then
|
||||
switch_state = 'left'
|
||||
end
|
||||
add_switch(
|
||||
scroll_pane,
|
||||
switch_state,
|
||||
'comfy_panel_trusted_only_car_tanks',
|
||||
'Market Purchase',
|
||||
'On = Allows only trusted people to buy car/tanks.\nOff = Allows everyone to buy car/tanks.'
|
||||
)
|
||||
add_switch(scroll_pane, switch_state, 'trusted_only_car_tanks', 'Market Purchase', 'On = Allows only trusted people to buy car/tanks.\nOff = Allows everyone to buy car/tanks.')
|
||||
scroll_pane.add({type = 'line'})
|
||||
|
||||
switch_state = 'right'
|
||||
if Module.allow_decon then
|
||||
switch_state = 'left'
|
||||
end
|
||||
add_switch(
|
||||
scroll_pane,
|
||||
switch_state,
|
||||
'comfy_panel_allow_decon',
|
||||
'Deconstruct',
|
||||
'On = Allows decon on car/tanks/trains.\nOff = Disables decon on car/tanks/trains.'
|
||||
)
|
||||
add_switch(scroll_pane, switch_state, 'allow_decon', 'Deconstruct', 'On = Allows decon on car/tanks/trains.\nOff = Disables decon on car/tanks/trains.')
|
||||
scroll_pane.add({type = 'line'})
|
||||
if Module.christmas_mode then
|
||||
switch_state = 'left'
|
||||
end
|
||||
add_switch(scroll_pane, switch_state, 'comfy_panel_christmas_mode', 'Wintery Mode', 'On = Enables wintery mode.\nOff = Disables wintery mode.')
|
||||
add_switch(scroll_pane, switch_state, 'christmas_mode', 'Wintery Mode', 'On = Enables wintery mode.\nOff = Disables wintery mode.')
|
||||
scroll_pane.add({type = 'line'})
|
||||
end
|
||||
end
|
||||
@ -790,7 +697,7 @@ local function on_gui_switch_state_changed(event)
|
||||
end
|
||||
fortress_functions[event.element.name](event)
|
||||
return
|
||||
elseif is_loaded('comfy_panel.poll') then
|
||||
elseif is_loaded('utils.gui.poll') then
|
||||
local is_spamming = SpamProtection.is_spamming(player, nil, 'Config Poll Elem')
|
||||
if is_spamming then
|
||||
return
|
||||
@ -814,35 +721,16 @@ local function on_robot_built_entity(event)
|
||||
spaghett_deny_building(event)
|
||||
end
|
||||
|
||||
local function on_gui_click(event)
|
||||
if not event then
|
||||
return
|
||||
end
|
||||
local player = game.get_player(event.player_index)
|
||||
if not (player and player.valid) then
|
||||
return
|
||||
end
|
||||
Gui.add_tab_to_gui({name = module_name, caption = 'Config', id = build_config_gui_token, admin = false})
|
||||
|
||||
if not event.element then
|
||||
return
|
||||
end
|
||||
if not event.element.valid then
|
||||
return
|
||||
Gui.on_click(
|
||||
module_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
Gui.reload_active_tab(player)
|
||||
end
|
||||
)
|
||||
|
||||
local name = event.element.name
|
||||
|
||||
if name == 'tab_' .. module_name then
|
||||
local is_spamming = SpamProtection.is_spamming(player, nil, 'Config Main Button')
|
||||
if is_spamming then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Tabs.add_tab_to_gui({name = module_name, id = build_config_gui_token, admin = false})
|
||||
|
||||
Event.add(defines.events.on_gui_click, on_gui_click)
|
||||
Event.add(defines.events.on_gui_switch_state_changed, on_gui_switch_state_changed)
|
||||
Event.add(defines.events.on_force_created, on_force_created)
|
||||
Event.add(defines.events.on_built_entity, on_built_entity)
|
@ -1,12 +1,12 @@
|
||||
-- this script adds a group button to create groups for your players --
|
||||
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local Gui = require 'utils.gui'
|
||||
local Global = require 'utils.global'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
local Event = require 'utils.event'
|
||||
local Token = require 'utils.token'
|
||||
|
||||
local module_name = 'Groups'
|
||||
local module_name = Gui.uid_name()
|
||||
|
||||
local this = {
|
||||
player_group = {},
|
||||
@ -30,8 +30,8 @@ local function build_group_gui(data)
|
||||
local group_name_width = 150
|
||||
local description_width = 240
|
||||
local members_width = 90
|
||||
local member_columns = 3
|
||||
local actions_width = 80
|
||||
local member_columns = 2
|
||||
local actions_width = 130
|
||||
local total_height = frame.style.minimal_height - 60
|
||||
|
||||
frame.clear()
|
||||
@ -46,11 +46,12 @@ local function build_group_gui(data)
|
||||
for _, h in pairs(headings) do
|
||||
local l = t.add({type = 'label', caption = h[1]})
|
||||
l.style.font_color = {r = 0.98, g = 0.66, b = 0.22}
|
||||
l.style.font = 'default-listbox'
|
||||
l.style.font = 'heading-2'
|
||||
l.style.top_padding = 6
|
||||
l.style.minimal_height = 40
|
||||
l.style.minimal_width = h[2]
|
||||
l.style.maximal_width = h[2]
|
||||
l.style.horizontal_align = 'center'
|
||||
end
|
||||
|
||||
local scroll_pane =
|
||||
@ -76,11 +77,12 @@ local function build_group_gui(data)
|
||||
for _, group in pairs(this.tag_groups) do
|
||||
if (group.name and group.founder and group.description) then
|
||||
local l = t.add({type = 'label', caption = group.name})
|
||||
l.style.font = 'default-bold'
|
||||
l.style.top_padding = 16
|
||||
l.style.bottom_padding = 16
|
||||
l.style.minimal_width = group_name_width
|
||||
l.style.maximal_width = group_name_width
|
||||
l.style.font = 'heading-3'
|
||||
l.style.horizontal_align = 'center'
|
||||
local color
|
||||
if game.players[group.founder] and game.players[group.founder].color then
|
||||
color = game.players[group.founder].color
|
||||
@ -97,11 +99,17 @@ local function build_group_gui(data)
|
||||
l.style.maximal_width = description_width
|
||||
l.style.font_color = {r = 0.90, g = 0.90, b = 0.90}
|
||||
l.style.single_line = false
|
||||
l.style.font = 'heading-3'
|
||||
l.style.horizontal_align = 'center'
|
||||
|
||||
local tt = t.add({type = 'table', column_count = member_columns})
|
||||
local tt = t.add({type = 'table', column_count = 2})
|
||||
local flow = tt.add({type = 'flow'})
|
||||
flow.style.left_padding = 65
|
||||
local ttt = tt.add({type = 'table', column_count = member_columns})
|
||||
ttt.style.minimal_width = members_width * 2 - 25
|
||||
for _, p in pairs(game.connected_players) do
|
||||
if group.name == this.player_group[p.name] then
|
||||
l = tt.add({type = 'label', caption = p.name})
|
||||
l = ttt.add({type = 'label', caption = p.name})
|
||||
color = {
|
||||
r = p.color.r * 0.6 + 0.4,
|
||||
g = p.color.g * 0.6 + 0.4,
|
||||
@ -109,8 +117,10 @@ local function build_group_gui(data)
|
||||
a = 1
|
||||
}
|
||||
l.style.font_color = color
|
||||
--l.style.minimal_width = members_width
|
||||
l.style.maximal_width = members_width * 2
|
||||
l.style.maximal_width = members_width * 2 - 60
|
||||
l.style.single_line = false
|
||||
l.style.font = 'heading-3'
|
||||
l.style.horizontal_align = 'center'
|
||||
end
|
||||
end
|
||||
|
||||
@ -153,10 +163,12 @@ end
|
||||
local build_group_gui_token = Token.register(build_group_gui)
|
||||
|
||||
local function refresh_gui()
|
||||
for _, p in pairs(game.connected_players) do
|
||||
local frame = Tabs.comfy_panel_get_active_frame(p)
|
||||
local players = game.connected_players
|
||||
for i = 1, #players do
|
||||
local player = players[i]
|
||||
local frame = Gui.get_player_active_frame(player)
|
||||
if frame then
|
||||
if frame.name == module_name then
|
||||
if frame.frame2 and frame.frame2.valid then
|
||||
local new_group_name = frame.frame2.group_table.new_group_name.text
|
||||
local new_group_description = frame.frame2.group_table.new_group_description.text
|
||||
|
||||
@ -168,10 +180,10 @@ local function refresh_gui()
|
||||
new_group_description = ''
|
||||
end
|
||||
|
||||
local data = {player = p, frame = frame}
|
||||
local data = {player = player, frame = frame}
|
||||
build_group_gui(data)
|
||||
|
||||
frame = Tabs.comfy_panel_get_active_frame(p)
|
||||
frame = Gui.get_player_active_frame(player)
|
||||
frame.frame2.group_table.new_group_name.text = new_group_name
|
||||
frame.frame2.group_table.new_group_description.text = new_group_description
|
||||
end
|
||||
@ -235,18 +247,11 @@ local function on_gui_click(event)
|
||||
|
||||
local name = element.name
|
||||
|
||||
if name and name == 'tab_' .. module_name then
|
||||
local is_spamming = SpamProtection.is_spamming(player, nil, 'Groups tab_Groups')
|
||||
if is_spamming then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local frame = Tabs.comfy_panel_get_active_frame(player)
|
||||
local frame = Gui.get_player_active_frame(player)
|
||||
if not frame then
|
||||
return
|
||||
end
|
||||
if frame.name ~= module_name then
|
||||
if frame.name ~= 'Groups' then
|
||||
return
|
||||
end
|
||||
|
||||
@ -380,7 +385,15 @@ function Public.reset_groups()
|
||||
this.tag_groups = {}
|
||||
end
|
||||
|
||||
Tabs.add_tab_to_gui({name = module_name, id = build_group_gui_token, admin = false})
|
||||
Gui.add_tab_to_gui({name = module_name, caption = 'Groups', id = build_group_gui_token, admin = false})
|
||||
|
||||
Gui.on_click(
|
||||
module_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
Gui.reload_active_tab(player)
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(defines.events.on_gui_click, on_gui_click)
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
@ -1,7 +1,8 @@
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local Gui = require 'utils.gui'
|
||||
local Event = require 'utils.event'
|
||||
local Token = require 'utils.token'
|
||||
|
||||
local module_name = 'Map Scores'
|
||||
local module_name = Gui.uid_name()
|
||||
|
||||
local Public = {}
|
||||
|
||||
@ -100,9 +101,16 @@ local function on_init()
|
||||
}
|
||||
end
|
||||
|
||||
Tabs.add_tab_to_gui({name = module_name, id = score_list_token, admin = false})
|
||||
Gui.add_tab_to_gui({name = module_name, caption = 'Map Scores', id = score_list_token, admin = false})
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.on_init(on_init)
|
||||
Gui.on_click(
|
||||
module_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
Gui.reload_active_tab(player)
|
||||
end
|
||||
)
|
||||
|
||||
Event.on_init(on_init)
|
||||
|
||||
return Public
|
@ -17,7 +17,7 @@ local Where = require 'utils.commands.where'
|
||||
local Session = require 'utils.datastore.session_data'
|
||||
local Jailed = require 'utils.datastore.jail_data'
|
||||
local Supporters = require 'utils.datastore.supporters'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local Gui = require 'utils.gui'
|
||||
local Global = require 'utils.global'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
local RPG = require 'modules.rpg.table'
|
||||
@ -25,7 +25,7 @@ local Token = require 'utils.token'
|
||||
|
||||
local Public = {}
|
||||
|
||||
local module_name = 'Players'
|
||||
local module_name = Gui.uid_name()
|
||||
|
||||
local this = {
|
||||
player_list = {
|
||||
@ -576,7 +576,7 @@ local function player_list_show(data)
|
||||
name = 'player_list_panel_header_' .. k,
|
||||
caption = v
|
||||
}
|
||||
header_label.style.font = 'default-bold'
|
||||
header_label.style.font = 'heading-2'
|
||||
header_label.style.font_color = {r = 0.98, g = 0.66, b = 0.22}
|
||||
end
|
||||
|
||||
@ -677,6 +677,7 @@ local function player_list_show(data)
|
||||
}
|
||||
name_label.style.minimal_width = column_widths['name_label']
|
||||
name_label.style.maximal_width = column_widths['name_label']
|
||||
name_label.style.font = 'heading-3'
|
||||
|
||||
-- RPG level
|
||||
if this.rpg_enabled then
|
||||
@ -689,6 +690,7 @@ local function player_list_show(data)
|
||||
}
|
||||
rpg_level_label.style.minimal_width = column_widths['rpg_level_label']
|
||||
rpg_level_label.style.maximal_width = column_widths['rpg_level_label']
|
||||
rpg_level_label.style.font = 'heading-3'
|
||||
end
|
||||
|
||||
-- Total time
|
||||
@ -700,6 +702,7 @@ local function player_list_show(data)
|
||||
}
|
||||
total_label.style.minimal_width = column_widths['total_label']
|
||||
total_label.style.maximal_width = column_widths['total_label']
|
||||
total_label.style.font = 'heading-3'
|
||||
|
||||
-- Current time
|
||||
local current_label =
|
||||
@ -710,6 +713,7 @@ local function player_list_show(data)
|
||||
}
|
||||
current_label.style.minimal_width = column_widths['current_label']
|
||||
current_label.style.maximal_width = column_widths['current_label']
|
||||
current_label.style.font = 'heading-3'
|
||||
|
||||
-- Poke
|
||||
local flow = player_list_panel_table.add {type = 'flow', name = 'button_flow_' .. i, direction = 'horizontal'}
|
||||
@ -740,18 +744,11 @@ local function on_gui_click(event)
|
||||
local name = element.name
|
||||
local player = game.get_player(event.player_index)
|
||||
|
||||
if name == 'tab_' .. module_name then
|
||||
local is_spamming = SpamProtection.is_spamming(player, nil, 'PlayerList tab_Players')
|
||||
if is_spamming then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local frame = Tabs.comfy_panel_get_active_frame(player)
|
||||
local frame = Gui.get_player_active_frame(player)
|
||||
if not frame then
|
||||
return
|
||||
end
|
||||
if frame.name ~= module_name then
|
||||
if frame.name ~= 'Players' then
|
||||
return
|
||||
end
|
||||
|
||||
@ -900,9 +897,9 @@ end
|
||||
|
||||
local function refresh()
|
||||
for _, player in pairs(game.connected_players) do
|
||||
local frame = Tabs.comfy_panel_get_active_frame(player)
|
||||
local frame = Gui.get_player_active_frame(player)
|
||||
if frame then
|
||||
if frame.name ~= module_name then
|
||||
if frame.name ~= 'Players' then
|
||||
return
|
||||
end
|
||||
local data = {player = player, frame = frame, sort_by = this.player_list.sorting_method[player.index]}
|
||||
@ -938,7 +935,15 @@ function Public.rpg_enabled(value)
|
||||
return this.rpg_enabled
|
||||
end
|
||||
|
||||
Tabs.add_tab_to_gui({name = module_name, id = player_list_show_token, admin = false})
|
||||
Gui.add_tab_to_gui({name = module_name, caption = 'Players', id = player_list_show_token, admin = false})
|
||||
|
||||
Gui.on_click(
|
||||
module_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
Gui.reload_active_tab(player)
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
Event.add(defines.events.on_player_left_game, on_player_left_game)
|
@ -3,9 +3,8 @@ local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
local Game = require 'utils.game'
|
||||
local Server = require 'utils.server'
|
||||
local ComfyGui = require 'comfy_panel.main'
|
||||
local session = require 'utils.datastore.session_data'
|
||||
local Config = require 'comfy_panel.config'
|
||||
local Config = require 'utils.gui.config'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
|
||||
local Class = {}
|
||||
@ -293,11 +292,11 @@ local function update_poll_viewer(data)
|
||||
redraw_poll_viewer_content(data)
|
||||
end
|
||||
|
||||
local function draw_main_frame(left, player)
|
||||
local function draw_main_frame(_, player)
|
||||
local trusted = session.get_trusted_table()
|
||||
local frame = left.add {type = 'frame', name = main_frame_name, caption = 'Polls', direction = 'vertical'}
|
||||
local main_frame, inside_frame = Gui.add_main_frame_with_toolbar(player, 'left', main_frame_name, nil, main_button_name, 'Polls')
|
||||
|
||||
local poll_viewer_top_flow = frame.add {type = 'table', column_count = 5}
|
||||
local poll_viewer_top_flow = inside_frame.add {type = 'table', column_count = 5}
|
||||
poll_viewer_top_flow.style.horizontal_spacing = 0
|
||||
|
||||
local back_button = poll_viewer_top_flow.add {type = 'button', name = poll_view_back_name, caption = '◀'}
|
||||
@ -314,9 +313,9 @@ local function draw_main_frame(left, player)
|
||||
|
||||
local remaining_time_label = poll_viewer_top_flow.add {type = 'label'}
|
||||
|
||||
local poll_viewer_content = frame.add {type = 'scroll-pane'}
|
||||
local poll_viewer_content = inside_frame.add {type = 'scroll-pane'}
|
||||
poll_viewer_content.style.maximal_height = 480
|
||||
poll_viewer_content.style.width = 295
|
||||
poll_viewer_content.style.width = 274
|
||||
|
||||
local poll_index = player_poll_index[player.index] or #polls
|
||||
|
||||
@ -329,27 +328,24 @@ local function draw_main_frame(left, player)
|
||||
poll_index = poll_index
|
||||
}
|
||||
|
||||
Gui.set_data(frame, data)
|
||||
Gui.set_data(main_frame, data)
|
||||
Gui.set_data(back_button, data)
|
||||
Gui.set_data(forward_button, data)
|
||||
|
||||
update_poll_viewer(data)
|
||||
|
||||
local bottom_flow = frame.add {type = 'flow', direction = 'horizontal'}
|
||||
local bottom_flow = inside_frame.add {type = 'flow', direction = 'horizontal'}
|
||||
|
||||
local left_flow = bottom_flow.add {type = 'flow'}
|
||||
left_flow.style.horizontal_align = 'left'
|
||||
left_flow.style.horizontally_stretchable = true
|
||||
|
||||
local close_button = left_flow.add {type = 'button', name = main_button_name, caption = 'Close'}
|
||||
apply_button_style(close_button)
|
||||
|
||||
local right_flow = bottom_flow.add {type = 'flow'}
|
||||
right_flow.style.horizontal_align = 'right'
|
||||
|
||||
local comfy_panel_config = Config.get('gui_config')
|
||||
local config = Config.get('gui_config')
|
||||
|
||||
if (trusted[player.name] or player.admin) or comfy_panel_config.poll_trusted == false then
|
||||
if (trusted[player.name] or player.admin) or config.poll_trusted == false then
|
||||
local create_poll_button = right_flow.add {type = 'button', name = create_poll_button_name, caption = 'Create Poll'}
|
||||
apply_button_style(create_poll_button)
|
||||
else
|
||||
@ -403,7 +399,7 @@ local function toggle(event)
|
||||
if main_frame then
|
||||
remove_main_frame(main_frame, left, event.player)
|
||||
else
|
||||
ComfyGui.comfy_panel_clear_gui(event.player)
|
||||
Gui.clear_all_active_frames(event.player)
|
||||
draw_main_frame(left, event.player)
|
||||
end
|
||||
end
|
||||
@ -420,7 +416,7 @@ local function update_duration(slider)
|
||||
if value == 0 then
|
||||
label.caption = 'Endless Poll.'
|
||||
else
|
||||
label.caption = value * duration_step .. ' seconds.'
|
||||
label.caption = value * duration_step .. ' sec.'
|
||||
end
|
||||
end
|
||||
|
||||
@ -551,6 +547,7 @@ local function draw_create_poll_frame(parent, player, previous_data)
|
||||
local scroll_pane = frame.add {type = 'scroll-pane', vertical_scroll_policy = 'always'}
|
||||
scroll_pane.style.maximal_height = 250
|
||||
scroll_pane.style.maximal_width = 300
|
||||
scroll_pane.style.padding = 3
|
||||
|
||||
local grid = scroll_pane.add {type = 'table', column_count = 3}
|
||||
|
||||
@ -766,8 +763,8 @@ local function player_joined(event)
|
||||
return
|
||||
end
|
||||
|
||||
if ComfyGui.get_mod_gui_top_frame() then
|
||||
ComfyGui.add_mod_button(
|
||||
if Gui.get_mod_gui_top_frame() then
|
||||
Gui.add_mod_button(
|
||||
player,
|
||||
{
|
||||
type = 'sprite-button',
|
||||
@ -936,6 +933,10 @@ Gui.on_text_changed(
|
||||
end
|
||||
|
||||
if textfield and textfield.valid then
|
||||
if string.len(textfield.text) >= 50 then
|
||||
textfield.text = ''
|
||||
return
|
||||
end
|
||||
data.question = textfield.text
|
||||
end
|
||||
end
|
||||
@ -952,6 +953,10 @@ Gui.on_text_changed(
|
||||
end
|
||||
|
||||
if textfield and textfield.valid then
|
||||
if string.len(textfield.text) >= 50 then
|
||||
textfield.text = ''
|
||||
return
|
||||
end
|
||||
data.answers[data.count].text = textfield.text
|
||||
end
|
||||
end
|
@ -1,10 +1,12 @@
|
||||
--scoreboard by mewmew
|
||||
-- modified by Gerkiz
|
||||
|
||||
local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
local Gui = require 'utils.gui'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
local Token = require 'utils.token'
|
||||
local format_number = require 'util'.format_number
|
||||
|
||||
local Public = {}
|
||||
local this = {
|
||||
@ -12,7 +14,7 @@ local this = {
|
||||
sort_by = {}
|
||||
}
|
||||
|
||||
local module_name = 'Scoreboard'
|
||||
local module_name = Gui.uid_name()
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
@ -125,22 +127,22 @@ local function add_global_stats(frame, player)
|
||||
local t = frame.add {type = 'table', column_count = 5}
|
||||
|
||||
local l = t.add {type = 'label', caption = 'Rockets launched: '}
|
||||
l.style.font = 'default-game'
|
||||
l.style.font = 'heading-2'
|
||||
l.style.font_color = {r = 175, g = 75, b = 255}
|
||||
l.style.minimal_width = 140
|
||||
|
||||
local rocketsLaunched_label = t.add {type = 'label', caption = player.force.rockets_launched}
|
||||
rocketsLaunched_label.style.font = 'default-listbox'
|
||||
local rocketsLaunched_label = t.add {type = 'label', caption = format_number(player.force.rockets_launched, true)}
|
||||
rocketsLaunched_label.style.font = 'heading-3'
|
||||
rocketsLaunched_label.style.font_color = {r = 0.9, g = 0.9, b = 0.9}
|
||||
rocketsLaunched_label.style.minimal_width = 123
|
||||
|
||||
local bugs_dead_label = t.add {type = 'label', caption = 'Dead bugs: '}
|
||||
bugs_dead_label.style.font = 'default-game'
|
||||
bugs_dead_label.style.font = 'heading-2'
|
||||
bugs_dead_label.style.font_color = {r = 0.90, g = 0.3, b = 0.3}
|
||||
bugs_dead_label.style.minimal_width = 100
|
||||
|
||||
local killcount_label = t.add {type = 'label', caption = tostring(get_total_biter_killcount(player.force))}
|
||||
killcount_label.style.font = 'default-listbox'
|
||||
local killcount_label = t.add {type = 'label', caption = format_number(tonumber(get_total_biter_killcount(player.force)), true)}
|
||||
killcount_label.style.font = 'heading-3'
|
||||
killcount_label.style.font_color = {r = 0.9, g = 0.9, b = 0.9}
|
||||
killcount_label.style.minimal_width = 145
|
||||
end
|
||||
@ -189,10 +191,10 @@ local function show_score(data)
|
||||
caption = cap,
|
||||
name = header.name
|
||||
}
|
||||
label.style.font = 'default-listbox'
|
||||
label.style.font = 'heading-2'
|
||||
label.style.font_color = {r = 0.98, g = 0.66, b = 0.22} -- yellow
|
||||
label.style.minimal_width = 150
|
||||
label.style.horizontal_align = 'right'
|
||||
label.style.horizontal_align = 'center'
|
||||
end
|
||||
|
||||
-- Score list
|
||||
@ -227,10 +229,10 @@ local function show_score(data)
|
||||
}
|
||||
local lines = {
|
||||
{caption = entry.name, color = special_color},
|
||||
{caption = tostring(entry.killscore)},
|
||||
{caption = tostring(entry.deaths)},
|
||||
{caption = tostring(entry.built_entities)},
|
||||
{caption = tostring(entry.mined_entities)}
|
||||
{caption = format_number(tonumber(entry.killscore), true)},
|
||||
{caption = format_number(tonumber(entry.deaths), true)},
|
||||
{caption = format_number(tonumber(entry.built_entities), true)},
|
||||
{caption = format_number(tonumber(entry.mined_entities), true)}
|
||||
}
|
||||
local default_color = {r = 0.9, g = 0.9, b = 0.9}
|
||||
|
||||
@ -241,10 +243,10 @@ local function show_score(data)
|
||||
caption = column.caption,
|
||||
color = column.color or default_color
|
||||
}
|
||||
label.style.font = 'default'
|
||||
label.style.font = 'heading-3'
|
||||
label.style.minimal_width = 150
|
||||
label.style.maximal_width = 150
|
||||
label.style.horizontal_align = 'right'
|
||||
label.style.horizontal_align = 'center'
|
||||
end -- foreach column
|
||||
end -- foreach entry
|
||||
end
|
||||
@ -253,11 +255,12 @@ local show_score_token = Token.register(show_score)
|
||||
|
||||
local function refresh_score_full()
|
||||
for _, player in pairs(game.connected_players) do
|
||||
local frame = Tabs.comfy_panel_get_active_frame(player)
|
||||
local frame = Gui.get_player_active_frame(player)
|
||||
if frame then
|
||||
if frame.name == module_name then
|
||||
show_score({player = player, frame = frame})
|
||||
if frame.name ~= 'Scoreboard' then
|
||||
return
|
||||
end
|
||||
show_score({player = player, frame = frame})
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -278,18 +281,11 @@ local function on_gui_click(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
local name = event.element.name
|
||||
|
||||
if name == 'tab_' .. module_name then
|
||||
local is_spamming = SpamProtection.is_spamming(player, nil, 'Scoreboard tab_Scoreboard')
|
||||
if is_spamming then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local frame = Tabs.comfy_panel_get_active_frame(player)
|
||||
local frame = Gui.get_player_active_frame(player)
|
||||
if not frame then
|
||||
return
|
||||
end
|
||||
if frame.name ~= module_name then
|
||||
if frame.name ~= 'Scoreboard' then
|
||||
return
|
||||
end
|
||||
|
||||
@ -460,7 +456,15 @@ local function on_built_entity(event)
|
||||
score.built_entities = 1 + (score.built_entities or 0)
|
||||
end
|
||||
|
||||
Tabs.add_tab_to_gui({name = module_name, id = show_score_token, admin = false})
|
||||
Gui.add_tab_to_gui({name = module_name, caption = 'Scoreboard', id = show_score_token, admin = false})
|
||||
|
||||
Gui.on_click(
|
||||
module_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
Gui.reload_active_tab(player)
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
|
||||
Event.add(defines.events.on_player_died, on_player_died)
|
@ -1,7 +1,6 @@
|
||||
local Event = require 'utils.event'
|
||||
local Gui = require 'utils.gui'
|
||||
local Server = require 'utils.server'
|
||||
local ComfyGui = require 'comfy_panel.main'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
|
||||
local main_frame_name = Gui.uid_name()
|
||||
@ -33,21 +32,16 @@ local function apply_button_style(button)
|
||||
end
|
||||
|
||||
local function draw_main_frame(player)
|
||||
Gui.clear_all_active_frames(player)
|
||||
local instance = get_instance()
|
||||
local left = player.gui.left
|
||||
|
||||
local frame = left.add {type = 'frame', name = main_frame_name, caption = 'Comfy Servers', direction = 'vertical'}
|
||||
local main_frame, inside_frame = Gui.add_main_frame_with_toolbar(player, 'left', main_frame_name, nil, discard_button_name, 'Comfy Servers')
|
||||
|
||||
local inside_frame =
|
||||
frame.add {
|
||||
type = 'frame',
|
||||
style = 'deep_frame_in_shallow_frame'
|
||||
}
|
||||
local inside_frame_style = inside_frame.style
|
||||
inside_frame_style.padding = 0
|
||||
inside_frame_style.maximal_height = 800
|
||||
|
||||
player.opened = frame
|
||||
player.opened = main_frame
|
||||
|
||||
local instances = {}
|
||||
local server_instances = Server.get_instances()
|
||||
@ -72,65 +66,57 @@ local function draw_main_frame(player)
|
||||
}
|
||||
else
|
||||
for _, i in ipairs(instances) do
|
||||
viewer_table.add {
|
||||
type = 'label',
|
||||
caption = 'Name: ' .. i.name,
|
||||
tooltip = i.connected .. '\nVersion: ' .. i.version,
|
||||
style = 'caption_label'
|
||||
}
|
||||
local flow = viewer_table.add {type = 'flow'}
|
||||
flow.style.horizontal_align = 'right'
|
||||
flow.style.horizontally_stretchable = true
|
||||
local empty_flow = viewer_table.add {type = 'flow'}
|
||||
local button =
|
||||
empty_flow.add {
|
||||
type = 'button',
|
||||
caption = 'Connect',
|
||||
tooltip = 'Click to connect to this server.\n' .. i.connected .. '\nVersion: ' .. i.version,
|
||||
name = instance_id_name
|
||||
}
|
||||
Gui.set_data(button, i.id)
|
||||
apply_button_style(button)
|
||||
if string.len(i.name) > 1 then
|
||||
viewer_table.add {
|
||||
type = 'label',
|
||||
caption = i.name,
|
||||
tooltip = i.connected .. '\nVersion: ' .. i.version,
|
||||
style = 'caption_label'
|
||||
}
|
||||
local flow = viewer_table.add {type = 'flow'}
|
||||
flow.style.horizontal_align = 'right'
|
||||
flow.style.horizontally_stretchable = true
|
||||
local empty_flow = viewer_table.add {type = 'flow'}
|
||||
local button =
|
||||
empty_flow.add {
|
||||
type = 'button',
|
||||
caption = 'Connect',
|
||||
tooltip = 'Click to connect to this server.\n' .. i.connected .. '\nVersion: ' .. i.version,
|
||||
name = instance_id_name
|
||||
}
|
||||
Gui.set_data(button, i.id)
|
||||
apply_button_style(button)
|
||||
|
||||
if i.id == instance.id then
|
||||
button.enabled = false
|
||||
button.tooltip = 'You are here'
|
||||
elseif i.status == 'unknown' then
|
||||
button.enabled = i.game_port ~= nil
|
||||
button.style.font_color = {r = 0.65}
|
||||
button.style.hovered_font_color = {r = 0.65}
|
||||
button.style.clicked_font_color = {r = 0.65}
|
||||
button.style.disabled_font_color = {r = 0.75, g = 0.1, b = 0.1}
|
||||
button.tooltip = 'Unknown status for this server'
|
||||
elseif i.status ~= 'running' then
|
||||
button.enabled = false
|
||||
button.tooltip = 'This server is offline'
|
||||
elseif i.version ~= instance.version then
|
||||
button.enabled = false
|
||||
button.tooltip = "We're on version: " .. instance.version .. '\nDestination server is on version: ' .. i.version
|
||||
if i.id == instance.id then
|
||||
button.enabled = false
|
||||
button.tooltip = 'You are here'
|
||||
elseif i.status == 'unknown' then
|
||||
button.enabled = i.game_port ~= nil
|
||||
button.style.font_color = {r = 0.65}
|
||||
button.style.hovered_font_color = {r = 0.65}
|
||||
button.style.clicked_font_color = {r = 0.65}
|
||||
button.style.disabled_font_color = {r = 0.75, g = 0.1, b = 0.1}
|
||||
button.tooltip = 'Unknown status for this server'
|
||||
elseif i.status ~= 'running' then
|
||||
button.enabled = false
|
||||
button.tooltip = 'This server is offline'
|
||||
elseif i.version ~= instance.version then
|
||||
button.enabled = false
|
||||
button.tooltip = "We're on version: " .. instance.version .. '\nDestination server is on version: ' .. i.version
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local bottom_flow = frame.add {type = 'flow', direction = 'horizontal'}
|
||||
|
||||
local left_flow = bottom_flow.add {type = 'flow'}
|
||||
left_flow.style.horizontal_align = 'left'
|
||||
left_flow.style.horizontally_stretchable = true
|
||||
|
||||
local close_button = left_flow.add {type = 'button', name = discard_button_name, caption = 'Close'}
|
||||
apply_button_style(close_button)
|
||||
|
||||
local right_flow = bottom_flow.add {type = 'flow'}
|
||||
right_flow.style.horizontal_align = 'right'
|
||||
end
|
||||
|
||||
local function toggle(player)
|
||||
local left = player.gui.left
|
||||
local frame = left[main_frame_name]
|
||||
|
||||
if not player or not player.valid or not player.character then
|
||||
return
|
||||
end
|
||||
|
||||
if frame and frame.valid then
|
||||
Gui.remove_data_recursively(frame)
|
||||
frame.destroy()
|
||||
@ -140,9 +126,14 @@ local function toggle(player)
|
||||
end
|
||||
|
||||
local function create_main_button(event)
|
||||
local multiplayer = game.is_multiplayer()
|
||||
if not multiplayer then
|
||||
return
|
||||
end
|
||||
|
||||
local player = game.get_player(event.player_index)
|
||||
if ComfyGui.get_mod_gui_top_frame() then
|
||||
ComfyGui.add_mod_button(
|
||||
if Gui.get_mod_gui_top_frame() then
|
||||
Gui.add_mod_button(
|
||||
player,
|
||||
{
|
||||
type = 'sprite-button',
|
@ -8,7 +8,8 @@ local round = math.round
|
||||
|
||||
local this = {
|
||||
modifiers = {},
|
||||
disabled_modifier = {}
|
||||
disabled_modifier = {},
|
||||
rpg_inventory_slot_limit = 320 -- huge inventory lags the server, this fixes it
|
||||
}
|
||||
|
||||
Global.register(
|
||||
@ -74,7 +75,7 @@ function Public.update_player_modifiers(player)
|
||||
if disabled_modifiers and disabled_modifiers[k] then
|
||||
player[modifier] = 0
|
||||
else
|
||||
player[modifier] = round(sum_value, 8)
|
||||
player[modifier] = round(sum_value, 4)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -92,9 +93,13 @@ function Public.update_single_modifier(player, modifier, category, value)
|
||||
if modifiers[k] == modifier and player_modifiers[k] then
|
||||
if category then
|
||||
if not player_modifiers[k][category] then
|
||||
player_modifiers[k][category] = {}
|
||||
player_modifiers[k][category] = 0
|
||||
end
|
||||
player_modifiers[k][category] = value
|
||||
|
||||
if category == 'rpg' and modifiers[k] == 'character_inventory_slots_bonus' and player_modifiers[k][category] >= this.rpg_inventory_slot_limit then
|
||||
player_modifiers[k][category] = this.rpg_inventory_slot_limit - player.force.character_inventory_slots_bonus
|
||||
end
|
||||
else
|
||||
player_modifiers[k] = value
|
||||
end
|
||||
|
@ -286,11 +286,6 @@ for i = 0, 511 do
|
||||
perm[i + 1] = p[bit32_band(i, 255) + 1]
|
||||
end
|
||||
|
||||
-- special case of dot with 3 inputs
|
||||
local function dot2(g, x, y)
|
||||
return x * g[1] + y * g[2]
|
||||
end
|
||||
|
||||
local F2 = 0.5 * (math.sqrt(3.0) - 1.0)
|
||||
local G2 = (3.0 - math.sqrt(3.0)) / 6.0
|
||||
|
||||
@ -317,6 +312,7 @@ function Simplex.d2(xin, yin, seed)
|
||||
i1 = 0
|
||||
j1 = 1
|
||||
end
|
||||
|
||||
-- upper triangle, YX order: (0,0)->(0,1)->(1,1)
|
||||
-- A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and
|
||||
-- a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where
|
||||
@ -339,7 +335,7 @@ function Simplex.d2(xin, yin, seed)
|
||||
n0 = 0.0
|
||||
else
|
||||
t0 = t0 * t0
|
||||
n0 = t0 * t0 * dot2(grad3[gi0 + 1], x0, y0) -- (x,y) of grad3 used for 2D gradient
|
||||
n0 = t0 * t0 * (x0 * grad3[gi0 + 1][1] + y0 * grad3[gi0 + 1][2]) -- (x,y) of grad3 used for 2D gradient
|
||||
end
|
||||
|
||||
local t1 = 0.5 - x1 * x1 - y1 * y1
|
||||
@ -347,7 +343,7 @@ function Simplex.d2(xin, yin, seed)
|
||||
n1 = 0.0
|
||||
else
|
||||
t1 = t1 * t1
|
||||
n1 = t1 * t1 * dot2(grad3[gi1 + 1], x1, y1)
|
||||
n1 = t1 * t1 * (x1 * grad3[gi1 + 1][1] + y1 * grad3[gi1 + 1][2])
|
||||
end
|
||||
|
||||
local t2 = 0.5 - x2 * x2 - y2 * y2
|
||||
@ -355,7 +351,7 @@ function Simplex.d2(xin, yin, seed)
|
||||
n2 = 0.0
|
||||
else
|
||||
t2 = t2 * t2
|
||||
n2 = t2 * t2 * dot2(grad3[gi2 + 1], x2, y2)
|
||||
n2 = t2 * t2 * (x2 * grad3[gi2 + 1][1] + y2 * grad3[gi2 + 1][2])
|
||||
end
|
||||
|
||||
-- Add contributions from each corner to get the final noise value.
|
||||
|
@ -1,3 +1,4 @@
|
||||
---@diagnostic disable: undefined-field
|
||||
--luacheck: globals table
|
||||
local Stats = require 'utils.stats'
|
||||
local random = math.random
|
||||
|
1
utils/templates/Biter_Battles_v2/map_loader.lua
Normal file
@ -0,0 +1 @@
|
||||
return require 'maps.biter_battles_v2.main'
|
1
utils/templates/Biter_Hatchery/map_loader.lua
Normal file
@ -0,0 +1 @@
|
||||
return require 'maps.biter_hatchery.main'
|
1
utils/templates/Choppy_dx/map_loader.lua
Normal file
@ -0,0 +1 @@
|
||||
return require 'maps.choppy_dx'
|
1
utils/templates/Chronosphere/map_loader.lua
Normal file
@ -0,0 +1 @@
|
||||
return require 'maps.chronosphere.main'
|
1
utils/templates/Develop/map_loader.lua
Normal file
@ -0,0 +1 @@
|
||||
_DEBUG = true
|
1
utils/templates/Fish_Defender/map_loader.lua
Normal file
@ -0,0 +1 @@
|
||||
return require 'maps.fish_defender_v2.main'
|
1
utils/templates/Journey/map_loader.lua
Normal file
@ -0,0 +1 @@
|
||||
return require 'maps.journey.main'
|
1
utils/templates/Labyrinth/map_loader.lua
Normal file
@ -0,0 +1 @@
|
||||
return require 'maps.labyrinth'
|
1
utils/templates/Minesweeper/map_loader.lua
Normal file
@ -0,0 +1 @@
|
||||
return require 'maps.minesweeper.main'
|
1
utils/templates/Mountain_Fortress_v3/map_loader.lua
Normal file
@ -0,0 +1 @@
|
||||
return require 'maps.mountain_fortress_v3.main'
|
1
utils/templates/Planet_Prison/map_loader.lua
Normal file
@ -0,0 +1 @@
|
||||
return require 'maps.planet_prison'
|