1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-13 13:49:33 +02:00

Merge pull request #434 from ComfyFactory/modifications

Some modifications to files
This commit is contained in:
Gerkiz 2023-11-12 00:08:50 +01:00 committed by GitHub
commit 5fd9eecb25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 1282 additions and 992 deletions

View File

@ -35,7 +35,7 @@ strength_tooltip=Increases inventory slots, mining speed.\nIncreases melee damag
magic_name=MAGIC
magic_tooltip=Increases reach distance.\nIncreases repair speed.\nEnables spawning entities.
dexterity_name=DEXTERITY
dexterity_tooltip=Increases running and crafting speed.\nHas a chance to grant a temporary speed buff when crafting items.\nHas a chance to dupe items that gets handcrafted.
dexterity_tooltip=Increases running and crafting speed.\nHas a chance to grant a temporary speed buff when crafting items.\nHas a chance to dupe items that gets handcrafted.\nDuped items: __1__
vitality_name=VITALITY
vitality_tooltip=Increases health.\nIncreases melee life on-hit.\nIncreases healing power by using fish.
points_to_dist=POINTS LEFT

View File

@ -100,6 +100,7 @@ local function refresh_market_offers()
{price = {{'coin', 125}}, offer = {type = 'give-item', item = 'night-vision-equipment', count = 1}},
{price = {{'coin', 200}}, offer = {type = 'give-item', item = 'belt-immunity-equipment', count = 1}},
{price = {{'coin', 250}}, offer = {type = 'give-item', item = 'personal-roboport-equipment', count = 1}},
{price = {{'coin', 350}}, offer = {type = 'give-item', item = 'roboport', count = 1}},
{price = {{'coin', 35}}, offer = {type = 'give-item', item = 'construction-robot', count = 1}},
{price = {{'coin', 25}}, offer = {type = 'give-item', item = 'cliff-explosives', count = 1}}
}

View File

@ -270,6 +270,9 @@ local function initial_cargo_boxes()
{name = 'gun-turret', count = 1},
{name = 'gun-turret', count = 1},
{name = 'gun-turret', count = 1},
{name = 'logistic-chest-storage', count = 1},
{name = 'logistic-chest-storage', count = 1},
{name = 'logistic-chest-storage', count = 1},
{name = 'shotgun-shell', count = random(4, 5)},
{name = 'shotgun-shell', count = random(4, 5)},
{name = 'shotgun-shell', count = random(4, 5)},

View File

@ -280,7 +280,7 @@ function Public.mountain_market(surface, position, rarity, buy)
if #items > 0 then
table.shuffle_table(items)
end
local mrk = surface.create_entity({name = 'market', position = position, force = 'neutral'})
local mrk = surface.create_entity({name = 'market', position = position, force = 'neutral', create_build_effect_smoke = false})
for i = 1, random(5, 10), 1 do
local item = items[i]

View File

@ -1096,7 +1096,7 @@ function Public.boost_difficulty()
WD.set('next_wave', game.tick + 3600 * 15)
Public.set('spidertron_unlocked_at_zone', 10)
WD.set_normal_unit_current_health(1.2)
WD.set_unit_health_increment_per_wave(0.35)
WD.set_unit_health_increment_per_wave(0.30)
WD.set_boss_unit_current_health(2)
WD.set_boss_health_increment_per_wave(1.5)
WD.set('death_mode', false)

View File

@ -11,7 +11,7 @@ local ceil = math.ceil
local round = math.round
local queue_task = Task.queue_task
local tiles_per_call = 8
local total_calls = ceil(1024 / tiles_per_call)
local total_calls = ceil(1024 / tiles_per_call) + 5
local regen_decoratives = false
local generate_map = Public.heavy_functions
@ -39,7 +39,7 @@ local function get_position(data)
data.xv = data.xv + 1
end
data.position = {x = data.top_x + data.xv, y = data.top_y + data.yv}
data.position = {x = (data.top_x + data.xv), y = (data.top_y + data.yv)}
end
local function do_tile_inner(tiles, tile, pos)
@ -48,71 +48,6 @@ local function do_tile_inner(tiles, tile, pos)
end
end
local function do_tile(x, y, data, shape)
local pos = {x, y}
-- local coords need to be 'centered' to allow for correct rotation and scaling.
local tile = shape(data)
if type(tile) == 'table' then
do_tile_inner(data.tiles, tile.tile, pos)
local hidden_tile = tile.hidden_tile
if hidden_tile then
data.hidden_tiles[#data.hidden_tiles + 1] = {tile = hidden_tile, position = pos}
end
local entities = tile.entities
if entities then
for _, entity in ipairs(entities) do
if not entity.position then
entity.position = pos
end
data.entities[#data.entities + 1] = entity
end
end
local buildings = tile.buildings
if buildings then
for _, entity in ipairs(buildings) do
if not entity.position then
entity.position = pos
end
data.buildings[#data.buildings + 1] = entity
end
end
local decoratives = tile.decoratives
if decoratives then
for _, decorative in ipairs(decoratives) do
data.decoratives[#data.decoratives + 1] = decorative
end
end
local markets = tile.markets
if markets then
for _, t in ipairs(markets) do
if not t.position then
t.position = pos
end
data.markets[#data.markets + 1] = t
end
end
local treasure = tile.treasure
if treasure then
for _, t in ipairs(treasure) do
if not t.position then
t.position = pos
end
data.treasure[#data.treasure + 1] = t
end
end
else
do_tile_inner(data.tiles, tile, pos)
end
end
local function do_row(row, data, shape)
local y = data.top_y + row
local top_x = data.top_x
@ -240,7 +175,8 @@ local function do_place_tiles(data)
if not surface or not surface.valid then
return
end
surface.set_tiles(data.tiles, true)
surface.set_tiles(data.tiles)
end
local function do_place_hidden_tiles(data)
@ -248,7 +184,7 @@ local function do_place_hidden_tiles(data)
if not surface or not surface.valid then
return
end
surface.set_tiles(data.hidden_tiles, true)
surface.set_tiles(data.hidden_tiles)
end
local function do_place_decoratives(data)
@ -283,6 +219,7 @@ local function do_place_buildings(data)
limit = 1
} == 0
then
e.create_build_effect_smoke = false
entity = surface.create_entity(e)
if entity and entity.valid then
if e.direction then
@ -360,6 +297,7 @@ local function do_place_entities(data)
for _, e in ipairs(data.entities) do
if e.collision then
if surface.can_place_entity(e) then
e.create_build_effect_smoke = false
entity = surface.create_entity(e)
if entity then
if e.note then -- flamethrower-turret and artillery-turret are at default health, only gun-turret is modified
@ -397,6 +335,7 @@ local function do_place_entities(data)
end
end
else
e.create_build_effect_smoke = false
entity = surface.create_entity(e)
if entity then
if e.note then -- small-worm-turret, medium-worm-turret, big-worm-turret, behemoth-worm-turret
@ -480,7 +419,7 @@ local function map_gen_action(data)
repeat
count = count - 1
get_position(data)
do_tile(x, y, data, shape)
shape(data)
x = x + 1
@ -503,30 +442,33 @@ local function map_gen_action(data)
data.y = 33
return true
elseif state == 33 then
do_place_hidden_tiles(data)
data.y = 34
return true
elseif state == 34 then
do_place_entities(data)
do_place_hidden_tiles(data)
data.y = 35
return true
elseif state == 35 then
do_place_buildings(data)
do_place_entities(data)
data.y = 36
return true
elseif state == 36 then
do_place_markets(data)
do_place_buildings(data)
data.y = 37
return true
elseif state == 37 then
do_place_treasure(data)
do_place_markets(data)
data.y = 38
return true
elseif state == 38 then
do_place_decoratives(data)
do_place_treasure(data)
data.y = 39
return true
elseif state == 39 then
do_place_decoratives(data)
data.y = 40
return true
elseif state == 40 then
run_chart_update(data)
return false
end
@ -581,7 +523,7 @@ end
--- Generates a Chunk of map when called
-- @param event <table> the event table from on_chunk_generated
local function do_chunk(event)
local function force_do_chunk(event)
local surface = event.surface
local shape = generate_map
@ -641,7 +583,7 @@ local function on_chunk(event)
end
if force_chunk then
do_chunk(event)
force_do_chunk(event)
else
schedule_chunk(event)
end

View File

@ -3,47 +3,29 @@ local simplex_noise = require 'utils.simplex_noise'.d2
--add or use noise templates from here
local noises = {
['bb_biterland'] = {
{modifier = 0.0015, weight = 1.1},
{modifier = 0.009, weight = 0.34},
{modifier = 0.095, weight = 0.016}
},
['bb_ore'] = {{modifier = 0.0046, weight = 0.95}, {modifier = 0.03, weight = 0.077}, {modifier = 0.09, weight = 0.023}},
['cave_ponds'] = {{modifier = 0.011, weight = 0.74}, {modifier = 0.14, weight = 0.079}},
['smol_areas'] = {{modifier = 0.0042, weight = 0.81}, {modifier = 0.129, weight = 0.021}, {modifier = 0.119, weight = 0.03}},
['cave_worms'] = {{modifier = 0.0011, weight = 0.99}, {modifier = 0.09, weight = 0.059}},
['cave_ponds'] = {{modifier = 0.014, weight = 0.77}, {modifier = 0.18, weight = 0.085}},
['smol_areas'] = {{modifier = 0.0052, weight = 0.83}, {modifier = 0.139, weight = 0.022}, {modifier = 0.121, weight = 0.01}},
['cave_rivers'] = {
{modifier = 0.0077, weight = 0.74},
{modifier = 0.0089, weight = 0.29},
{modifier = 0.072, weight = 0.028}
{modifier = 0.0053, weight = 0.71},
{modifier = 0.0086, weight = 0.24},
{modifier = 0.070, weight = 0.025}
},
['cave_rivers_2'] = {
{modifier = 0.0033, weight = 0.99},
{modifier = 0.0099, weight = 0.2},
{modifier = 0.049, weight = 0.009}
{modifier = 0.0035, weight = 0.90},
{modifier = 0.0088, weight = 0.15},
{modifier = 0.051, weight = 0.011}
},
['cave_rivers_3'] = {
{modifier = 0.0022, weight = 0.99},
{modifier = 0.0099, weight = 0.14},
{modifier = 0.049, weight = 0.009}
},
['cave_rivers_4'] = {
{modifier = 0.0009, weight = 0.99},
{modifier = 0.0099, weight = 0.1},
{modifier = 0.049, weight = 0.009}
},
['decoratives'] = {{modifier = 0.031, weight = 1.05}, {modifier = 0.055, weight = 0.24}, {modifier = 0.11, weight = 0.055}},
['dungeons'] = {{modifier = 0.0033, weight = 1.05}, {modifier = 0.0066, weight = 0.24}},
['dungeons'] = {{modifier = 0.0028, weight = 0.99}, {modifier = 0.0059, weight = 0.21}},
['dungeon_sewer'] = {
{modifier = 0.00055, weight = 1.05},
{modifier = 0.0055, weight = 0.014},
{modifier = 0.0062, weight = 0.024},
{modifier = 0.0275, weight = 0.00135}
},
['large_caves'] = {
{modifier = 0.00363, weight = 1.05},
{modifier = 0.01, weight = 0.23},
{modifier = 0.055, weight = 0.045},
{modifier = 0.11, weight = 0.042}
{modifier = 0.11, weight = 0.042},
{modifier = 0.00363, weight = 1.05},
{modifier = 0.01, weight = 0.23}
},
['n1'] = {{modifier = 0.00011, weight = 1.1}},
['n2'] = {{modifier = 0.0011, weight = 1.1}},
@ -131,7 +113,7 @@ function Public.get_noise(name, pos, seed)
local d = 0
for i = 1, #noises[name] do
local mod = noises[name]
noise = noise + simplex_noise(pos.x * mod[i].modifier, pos.y * mod[i].modifier, seed, 0xF) * mod[i].weight
noise = noise + simplex_noise(pos.x * mod[i].modifier, pos.y * mod[i].modifier, seed) * mod[i].weight
d = d + mod[i].weight
seed = seed + seed / seed
end

View File

@ -50,7 +50,8 @@ local function create_button(player)
type = 'sprite-button',
name = main_button_name,
sprite = 'item/dummy-steel-axe',
tooltip = 'Shows statistics!'
tooltip = 'Shows statistics!',
style = Gui.button_style
}
)
b.style.minimal_height = 38
@ -71,7 +72,8 @@ local function spectate_button(player)
type = 'sprite-button',
name = spectate_button_name,
sprite = 'utility/ghost_time_to_live_modifier_icon',
tooltip = 'Spectate!\nThis will kill your character.'
tooltip = 'Spectate!\nThis will kill your character.',
style = Gui.button_style
}
b.style.maximal_height = 38

View File

@ -644,7 +644,12 @@ local function show_score(data)
t = scroll_pane.add {type = 'table', column_count = 5}
-- Score entries
local i = 0
for _, entry in pairs(score_list) do
i = i + 1
if i == 20 then
break
end
local p
if not (entry and entry.name) then
p = {color = {r = random(1, 255), g = random(1, 255), b = random(1, 255)}}

View File

@ -480,14 +480,18 @@ add_toolbar = function(player, remove)
end
local tooltip = ({'ic.control'})
local button =
player.gui.top.add(
{
type = 'sprite-button',
sprite = 'item/spidertron',
name = main_toolbar_name,
tooltip = tooltip
tooltip = tooltip,
style = Gui.button_style
}
)
button.style.minimal_height = 38
button.style.maximal_height = 38
end
remove_toolbar = function(player)

View File

@ -3,6 +3,7 @@ local Public = {}
local ICT = require 'maps.mountain_fortress_v3.ic.table'
local Functions = require 'maps.mountain_fortress_v3.ic.functions'
local Gui = require 'maps.mountain_fortress_v3.ic.gui'
local CoreGui = require 'utils.gui'
local function validate_player(player)
if not player then
@ -30,9 +31,12 @@ local function create_button(player)
type = 'sprite-button',
name = 'minimap_button',
sprite = 'utility/map',
tooltip = 'Open or close minimap.'
tooltip = 'Open or close minimap.',
style = CoreGui.button_style
}
)
button.style.minimal_height = 38
button.style.maximal_height = 38
button.visible = false
end

View File

@ -526,6 +526,7 @@ local function gui_opened(event)
local container = fetch_container(unit_number)
if not container then
player.opened = nil
return
end

View File

@ -285,10 +285,8 @@ local function give_passive_xp(data)
end
end
end
-- else
-- if player.character then
-- player.character_personal_logistic_requests_enabled = false
-- end
elseif player.afk_time > 200 and player.character and player.surface.index == loco_surface.index then
player.character_personal_logistic_requests_enabled = false
end
::pre_exit::
end

View File

@ -51,7 +51,7 @@ function Public.add_loot(surface, position, chest)
local slots = c.get_inventory_size(defines.inventory.chest)
local item_stacks = LootRaffle.roll(result, slots, blacklist)
local container = surface.create_entity({name = chest, position = position, force = 'neutral'})
local container = surface.create_entity({name = chest, position = position, force = 'neutral', create_build_effect_smoke = false})
for _, item_stack in pairs(item_stacks) do
container.insert(item_stack)
end
@ -103,7 +103,7 @@ function Public.add_loot_rare(surface, position, chest, magic)
local slots = c.get_inventory_size(defines.inventory.chest)
local item_stacks = LootRaffle.roll(result, slots, blacklist)
local container = surface.create_entity({name = chest, position = position, force = 'neutral'})
local container = surface.create_entity({name = chest, position = position, force = 'neutral', create_build_effect_smoke = false})
for _, item_stack in pairs(item_stacks) do
container.insert(item_stack)
end

View File

@ -16,6 +16,7 @@ require 'modules.wave_defense.main'
require 'modules.charging_station'
local Event = require 'utils.event'
local Gui = require 'utils.gui'
local Public = require 'maps.mountain_fortress_v3.core'
local Discord = require 'utils.discord'
local IC = require 'maps.mountain_fortress_v3.ic.table'
@ -57,6 +58,8 @@ local role_to_mention = Discord.role_mentions.mtn_fortress
local floor = math.floor
local remove = table.remove
RPG.disable_cooldowns_on_spells()
Gui.mod_gui_button_enabled = true
Gui.button_style = 'mod_gui_button'
local collapse_kill = {
entities = {

View File

@ -187,7 +187,8 @@ local function create_button(player)
type = 'sprite-button',
name = main_button_name,
sprite = 'utility/custom_tag_icon',
tooltip = 'Has information about all objectives that needs to be completed'
tooltip = 'Has information about all objectives that needs to be completed',
style = Gui.button_style
}
)
b.style.minimal_height = 38

View File

@ -139,17 +139,17 @@ local function get_random_buff()
{
name = 'manual_crafting_speed_modifier',
modifier = 'force',
state = 0.04
state = 0.06
},
{
name = 'xp_bonus',
modifier = 'rpg',
state = 0.02
state = 0.08
},
{
name = 'xp_level',
modifier = 'rpg',
state = 4
state = 8
},
{
name = 'supplies',
@ -169,6 +169,33 @@ local function get_random_buff()
{name = 'firearm-magazine', count = 100}
}
},
{
name = 'defense_2',
modifier = 'starting_items',
limit = nil,
items = {
{name = 'flamethrower', count = 1},
{name = 'flamethrower-ammo', count = 100}
}
},
{
name = 'defense_3',
modifier = 'starting_items',
limit = nil,
items = {
{name = 'grenade', count = 50},
{name = 'poison-capsule', count = 30}
}
},
{
name = 'defense_4',
modifier = 'starting_items',
limit = nil,
items = {
{name = 'rocket-launcher', count = 1},
{name = 'rocket', count = 100}
}
},
{
name = 'armor',
modifier = 'starting_items',
@ -177,6 +204,15 @@ local function get_random_buff()
{name = 'heavy-armor', count = 1}
}
},
{
name = 'armor_2',
modifier = 'starting_items',
limit = 1,
items = {
{name = 'modular-armor', count = 1},
{name = 'solar-panel-equipment', count = 2}
}
},
{
name = 'production',
modifier = 'starting_items',
@ -186,6 +222,15 @@ local function get_random_buff()
{name = 'coal', count = 100}
}
},
{
name = 'production_2',
modifier = 'starting_items',
limit = nil,
items = {
{name = 'stone-furnace', count = 4},
{name = 'coal', count = 100}
}
},
{
name = 'fast-startup',
modifier = 'starting_items',
@ -421,8 +466,6 @@ local function scale(setting, limit, factor)
if limit and scale_value >= limit then
return limit
end
local random_value = scale_value * 0.9
scale_value = random(random_value, scale_value)
return floor(scale_value)
end

View File

@ -26,6 +26,19 @@ local start_ground_tiles = {
'grass-4'
}
local nuclear_tiles = {
'nuclear-ground',
'nuclear-ground',
'black-refined-concrete',
'tutorial-grid',
'nuclear-ground',
'red-refined-concrete',
'tutorial-grid',
'red-refined-concrete',
'black-refined-concrete',
'red-refined-concrete'
}
local wagon_raffle = {
'cargo-wagon',
'cargo-wagon',
@ -379,7 +392,7 @@ local function wall(p, data)
tiles[#tiles + 1] = {name = 'water', position = p}
else
tiles[#tiles + 1] = {name = 'water-shallow', position = p}
if random(1, 26) == 1 then
if random(1, 20) == 1 then
entities[#entities + 1] = {
name = 'land-mine',
position = p,
@ -391,9 +404,11 @@ local function wall(p, data)
entities[#entities + 1] = {name = 'fish', position = p}
end
else
tiles[#tiles + 1] = {name = base_tile, position = p}
local noise = Public.get_noise('dungeon_sewer', p, data.seed)
local index = floor(noise * 32) % 9 + 1
tiles[#tiles + 1] = {name = nuclear_tiles[index], position = p}
if random(1, 5) ~= 1 then
if random(1, 4) ~= 1 then
entities[#entities + 1] = {name = rock_raffle[random(1, #rock_raffle)], position = p}
if random(1, 26) == 1 then
entities[#entities + 1] = {
@ -405,7 +420,9 @@ local function wall(p, data)
end
end
else
tiles[#tiles + 1] = {name = base_tile, position = p}
local noise = Public.get_noise('dungeon_sewer', p, data.seed)
local index = floor(noise * 32) % 9 + 1
tiles[#tiles + 1] = {name = nuclear_tiles[index], position = p}
if
surface.can_place_entity(
@ -423,8 +440,8 @@ local function wall(p, data)
treasure[#treasure + 1] = {position = p, chest = 'steel-chest'}
end
end
if y < 4 or y > 25 then
if y <= 23 then
if y < 4 or y > 24 then
if y <= 22 then
if random(1, y + 1) == 1 then
entities[#entities + 1] = {
name = 'stone-wall',
@ -1332,7 +1349,7 @@ local function zone_scrap_1(x, y, data, void_or_lab, adjusted_zones)
entities[#entities + 1] = {name = 'crude-oil', position = p, amount = get_oil_amount(p)}
end
tiles[#tiles + 1] = {name = 'stone-path', position = p}
tiles[#tiles + 1] = {name = 'red-refined-concrete', position = p}
if random(1, 256) == 1 then
entities[#entities + 1] = {name = 'land-mine', position = p, force = 'enemy'}
end
@ -1347,8 +1364,8 @@ local function zone_7(x, y, data, void_or_lab, adjusted_zones)
local markets = data.markets
local treasure = data.treasure
local cave_rivers_3 = Public.get_noise('cave_rivers_3', p, seed)
local cave_rivers_4 = Public.get_noise('cave_rivers_4', p, seed + seed)
local cave_rivers_3 = Public.get_noise('cave_rivers_2', p, seed)
local cave_rivers_4 = Public.get_noise('cave_rivers_2', p, seed + seed)
local no_rocks_2 = Public.get_noise('no_rocks_2', p, seed)
local smol_areas = Public.get_noise('smol_areas', p, seed + seed)
@ -2488,8 +2505,8 @@ local function starting_zone(x, y, data, void_or_lab, adjusted_zones)
local cave_rivers = Public.get_noise('cave_rivers', p, seed)
local no_rocks = Public.get_noise('no_rocks', p, seed)
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 smol_areas < 0.057 and smol_areas > -0.021 then
tiles[#tiles + 1] = {name = void_or_lab, position = p}
if random(1, 32) == 1 then
Public.spawn_random_buildings(buildings, p, zone_settings.zone_depth)
end
@ -2517,7 +2534,7 @@ local function starting_zone(x, y, data, void_or_lab, adjusted_zones)
end
--Water Ponds
if noise_cave_ponds > 0.64 then
if noise_cave_ponds > 0.6 then
if noise_cave_ponds > 0.74 then
tiles[#tiles + 1] = {name = 'acid-refined-concrete', position = p}
if random(1, 4) == 1 then
@ -2536,7 +2553,7 @@ local function starting_zone(x, y, data, void_or_lab, adjusted_zones)
end
--Rivers
if cave_rivers < 0.042 and cave_rivers > -0.062 then
if cave_rivers < 0.044 and cave_rivers > -0.072 then
if noise_cave_ponds > 0.1 then
tiles[#tiles + 1] = {name = 'water-shallow', position = p}
if random(1, 64) == 1 then
@ -2559,7 +2576,7 @@ local function starting_zone(x, y, data, void_or_lab, adjusted_zones)
end
--Worm oil Zones
if no_rocks < 0.035 and no_rocks > -0.145 then
if no_rocks < 0.029 and no_rocks > -0.245 then
if small_caves > 0.081 then
tiles[#tiles + 1] = {name = 'brown-refined-concrete', position = p}
if random(1, 250) == 1 then
@ -2808,7 +2825,6 @@ function Public.heavy_functions(data)
end
local p = data.position
local get_tile = surface.get_tile(p)
local adjusted_zones = Public.get('adjusted_zones')
init_terrain(adjusted_zones)
@ -2817,10 +2833,6 @@ function Public.heavy_functions(data)
data.seed = Public.get('random_seed')
end
if get_tile.valid and get_tile.name == 'out-of-map' then
return
end
if top_y % zone_settings.zone_depth == 0 and top_y < 0 then
Public.set('left_top', data.left_top)
return wall(p, data)
@ -2887,7 +2899,7 @@ Event.add(
end
end
if left_top.y > 32 then
if left_top.y < -32 then
game.forces.player.chart(surface, {{left_top.x, left_top.y}, {left_top.x + 31, left_top.y + 31}})
end
end

View File

@ -18,7 +18,8 @@ local this = {
insert_into_furnace = false,
insert_into_wagon = false,
bottom_button = false,
small_radius = 2
small_radius = 2,
limit_containers = 50
}
local Public = {}
@ -129,7 +130,7 @@ local function sort_entities_by_distance(position, entities)
local index
local size_of_entities = #entities
if size_of_entities < 2 then
return
return entities
end
for _, entity in pairs(entities) do
@ -142,12 +143,18 @@ local function sort_entities_by_distance(position, entities)
end
local i = 0
local containers = {}
for _, range in pairs(t) do
for _, entity in pairs(range) do
i = i + 1
entities[i] = entity
if i >= (this.limit_containers or 50) then
return containers
end
containers[i] = entity
end
end
return containers
end
local function get_nearby_chests(player, a, furnace, wagon)
@ -185,7 +192,7 @@ local function get_nearby_chests(player, a, furnace, wagon)
end
end
sort_entities_by_distance(player.position, containers)
containers = sort_entities_by_distance(player.position, containers)
for _, entity in pairs(containers) do
size_of_chests = size_of_chests + 1
chests[size_of_chests] = entity
@ -591,7 +598,8 @@ local function create_gui_button(player)
type = 'sprite-button',
name = auto_stash_button_name,
sprite = 'item/wooden-chest',
tooltip = tooltip
tooltip = tooltip,
style = Gui.button_style
}
)
else
@ -605,7 +613,8 @@ local function create_gui_button(player)
type = 'sprite-button',
sprite = 'item/wooden-chest',
name = auto_stash_button_name,
tooltip = tooltip
tooltip = tooltip,
style = Gui.button_style
}
)
b.style.font_color = {r = 0.11, g = 0.8, b = 0.44}
@ -676,6 +685,10 @@ function Public.bottom_button(value)
this.bottom_button = value or false
end
function Public.limit_containers(value)
this.limit_containers = value or 50
end
function Public.insert_to_neutral_chests(value)
this.insert_to_neutral_chests = value or false
end

View File

@ -3,11 +3,23 @@
--change global.charging_station_multiplier if you want different conversion rate than 1:1.
local Event = require 'utils.event'
local SpamProtection = require 'utils.spam_protection'
local Gui = require 'utils.gui'
local function draw_charging_gui()
for _, player in pairs(game.connected_players) do
if not player.gui.top.charging_station then
local b = player.gui.top.add({type = 'sprite-button', name = 'charging_station', sprite = 'item/battery-mk2-equipment', tooltip = {'modules.charging_station_tooltip'}})
local b =
player.gui.top.add(
{
type = 'sprite-button',
name = 'charging_station',
sprite = 'item/battery-mk2-equipment',
tooltip = {
'modules.charging_station_tooltip'
},
style = Gui.button_style
}
)
b.style.minimal_height = 38
b.style.maximal_height = 38
end

View File

@ -887,6 +887,19 @@ function Public.set_crafting_boost(player, get_dex_modifier)
Task.set_timeout_in_ticks(bonus_length, restore_crafting_boost_token, {player_index = player.index})
end
function Public.increment_duped_crafted_items(player)
local rpg_t = Public.get_value_from_player(player.index)
if not rpg_t then
return false
end
if not rpg_t.duped_items then
rpg_t.duped_items = 0
end
rpg_t.duped_items = rpg_t.duped_items + 1
end
function Public.restore_crafting_boost(player)
local rpg_t = Public.get_value_from_player(player.index)
if not rpg_t then

View File

@ -42,7 +42,8 @@ function Public.draw_gui_char_button(player)
type = 'sprite-button',
name = draw_main_frame_name,
caption = '[RPG]',
tooltip = 'RPG'
tooltip = 'RPG',
style = Gui.button_style
}
)
if b then
@ -58,8 +59,17 @@ function Public.draw_gui_char_button(player)
if player.gui.top[draw_main_frame_name] then
return
end
local b = player.gui.top.add({type = 'sprite-button', name = draw_main_frame_name, caption = '[RPG]', tooltip = 'RPG'})
b.style.font_color = {165, 165, 165}
local b =
player.gui.top.add(
{
type = 'sprite-button',
name = draw_main_frame_name,
caption = '[RPG]',
tooltip = 'RPG',
style = Gui.button_style
}
)
b.style.font_color = {0, 0, 0}
b.style.font = 'heading-3'
b.style.minimal_height = 38
b.style.maximal_height = 38
@ -79,7 +89,7 @@ function Public.update_char_button(player)
if rpg_t.points_left > 0 then
ComfyGui.get_button_flow(player)[draw_main_frame_name].style.font_color = {245, 0, 0}
else
ComfyGui.get_button_flow(player)[draw_main_frame_name].style.font_color = {175, 175, 175}
ComfyGui.get_button_flow(player)[draw_main_frame_name].style.font_color = {0, 0, 0}
end
else
if not player.gui.top[draw_main_frame_name] then
@ -88,7 +98,7 @@ function Public.update_char_button(player)
if rpg_t.points_left > 0 then
player.gui.top[draw_main_frame_name].style.font_color = {245, 0, 0}
else
player.gui.top[draw_main_frame_name].style.font_color = {175, 175, 175}
player.gui.top[draw_main_frame_name].style.font_color = {0, 0, 0}
end
end
end
@ -273,6 +283,8 @@ local function draw_main_frame(player, location)
local w1 = 85
local w2 = 63
local duped_items = rpg_t.duped_items or 0
add_gui_description(left_bottom_table, ({'rpg_gui.strength_name'}), w1, ({'rpg_gui.strength_tooltip'}))
add_gui_stat(left_bottom_table, rpg_t.strength, w2, ({'rpg_gui.strength_tooltip'}))
add_gui_increase_stat(left_bottom_table, 'strength', player)
@ -281,8 +293,8 @@ local function draw_main_frame(player, location)
add_gui_stat(left_bottom_table, rpg_t.magicka, w2, ({'rpg_gui.magic_tooltip'}))
add_gui_increase_stat(left_bottom_table, 'magicka', player)
add_gui_description(left_bottom_table, ({'rpg_gui.dexterity_name'}), w1, ({'rpg_gui.dexterity_tooltip'}))
add_gui_stat(left_bottom_table, rpg_t.dexterity, w2, ({'rpg_gui.dexterity_tooltip'}))
add_gui_description(left_bottom_table, ({'rpg_gui.dexterity_name'}), w1, ({'rpg_gui.dexterity_tooltip', duped_items}))
add_gui_stat(left_bottom_table, rpg_t.dexterity, w2, ({'rpg_gui.dexterity_tooltip', duped_items}))
add_gui_increase_stat(left_bottom_table, 'dexterity', player)

View File

@ -599,6 +599,7 @@ local function on_player_rotated_entity(event)
if rpg_t.rotated_entity_delay > game.tick then
return
end
rpg_t.rotated_entity_delay = game.tick + 20
Public.gain_xp(player, 0.20)
end
@ -749,6 +750,7 @@ local function on_player_crafted_item(event)
name = item.name,
count = 1
}
Public.increment_duped_crafted_items(player)
if player.can_insert(reward) then
player.insert(reward)
end

View File

@ -1,10 +1,11 @@
local Public = require 'modules.wave_defense.table'
local BiterHealthBooster = require 'modules.biter_health_booster_v2'
local Gui = require 'utils.gui'
local floor = math.floor
local function create_gui(player)
local frame = player.gui.top.add({type = 'frame', name = 'wave_defense'})
local frame = player.gui.top.add({type = 'frame', name = 'wave_defense', style = Gui.frame_style})
frame.style.maximal_height = 37
local label = frame.add({type = 'label', caption = ' ', name = 'label'})
@ -19,18 +20,11 @@ local function create_gui(player)
wave_number_label.style.font_color = {r = 0.33, g = 0.66, b = 0.9}
local progressbar = frame.add({type = 'progressbar', name = 'progressbar', value = 0})
local experimental = get_game_version()
if experimental then
progressbar.style = 'achievement_progressbar'
progressbar.style.minimal_width = 96
progressbar.style.maximal_width = 96
progressbar.style.padding = -1
progressbar.style.top_padding = 1
else
progressbar.style.minimal_width = 96
progressbar.style.maximal_width = 96
progressbar.style.top_padding = 10
end
local line = frame.add({type = 'line', direction = 'vertical'})
line.style.left_padding = 4

View File

@ -110,7 +110,7 @@ function Public.iter_connected_players(callback)
for i = 1, #players do
local player = players[i]
if player and player.valid then
callback(player)
callback(player, i)
end
end
end

View File

@ -1,3 +1,4 @@
-- created by Gerkiz for ComfyFactorio
local Event = require 'utils.event'
local Server = require 'utils.server'
local Token = require 'utils.token'

View File

@ -1,3 +1,4 @@
-- created by Gerkiz for ComfyFactorio
local Token = require 'utils.token'
local Color = require 'utils.color_presets'
local Server = require 'utils.server'

View File

@ -1,3 +1,4 @@
-- created by Gerkiz for ComfyFactorio
local Server = require 'utils.server'
local Event = require 'utils.event'
local Gui = require 'utils.gui'

View File

@ -1,3 +1,4 @@
-- created by Gerkiz for ComfyFactorio
local Global = require 'utils.global'
local Session = require 'utils.datastore.session_data'
local Game = require 'utils.game'
@ -20,8 +21,8 @@ local votejail = {}
local votefree = {}
local revoked_permissions = {}
local settings = {
playtime_for_vote = 25920000, -- 5 days
playtime_for_instant_jail = 207360000, -- 40 days
playtime_for_vote = 77760000, -- 15 days
playtime_for_instant_jail = 362880000, -- 70 days
-- playtime_for_instant_jail = 103680000, -- 20 days
clear_voted_player = 36000, -- remove player from vote-tbl after 10 minutes
clear_terms_tbl = 2000,

View File

@ -1,3 +1,4 @@
-- created by Gerkiz for ComfyFactorio
local Token = require 'utils.token'
local Color = require 'utils.color_presets'
local Server = require 'utils.server'

View File

@ -1,3 +1,4 @@
-- created by Gerkiz for ComfyFactorio
local Token = require 'utils.token'
local Color = require 'utils.color_presets'
local Server = require 'utils.server'

View File

@ -1,3 +1,5 @@
-- created by Gerkiz for ComfyFactorio
local Token = require 'utils.token'
local Color = require 'utils.color_presets'
local Server = require 'utils.server'
@ -25,14 +27,14 @@ Global.register(
local Public = {}
local function apply_stash(player)
local stash = this.logistics[player.index]
local stash = this.logistics[player.name]
if stash then
for i, slot in pairs(stash) do
if slot and slot.name then
player.set_personal_logistic_slot(i, {name = slot.name, min = slot.min, max = slot.max})
end
end
this.logistics[player.index] = nil
this.logistics[player.name] = nil
end
end
@ -71,10 +73,10 @@ local fetch_logistics =
if tech then
player.set_personal_logistic_slot(i, {name = slot.name, min = slot.min, max = slot.max})
else
if not this.logistics[player.index] then
this.logistics[player.index] = {}
if not this.logistics[player.name] then
this.logistics[player.name] = {}
end
this.logistics[player.index][i] = {name = slot.name, min = slot.min, max = slot.max}
this.logistics[player.name][i] = {name = slot.name, min = slot.min, max = slot.max}
end
end
end

View File

@ -1,3 +1,4 @@
-- created by Gerkiz for ComfyFactorio
local Global = require 'utils.global'
local Game = require 'utils.game'
local Token = require 'utils.token'

View File

@ -1,3 +1,4 @@
-- created by Gerkiz for ComfyFactorio
local Server = require 'utils.server'
local Event = require 'utils.event'
local Gui = require 'utils.gui'

View File

@ -1,3 +1,4 @@
-- created by Gerkiz for ComfyFactorio
local Global = require 'utils.global'
local Core = require 'utils.core'
local Color = require 'utils.color_presets'
@ -228,7 +229,7 @@ function Public.try_dl_data(player_index)
player_index = tostring(player_index)
local secs = Server.get_current_time()
if secs == nil then
session[player_index] = game.players[player_index].online_time
session[player_index] = game.get_player(player_index).online_time
return
else
try_get_data(session_data_set, player_index, try_download_data_token)

View File

@ -1,3 +1,4 @@
-- created by Gerkiz for ComfyFactorio
local Token = require 'utils.token'
local Global = require 'utils.global'
local Server = require 'utils.server'

View File

@ -1,3 +1,4 @@
-- created by Gerkiz for ComfyFactorio
local Token = require 'utils.token'
local Server = require 'utils.server'
local Event = require 'utils.event'

View File

@ -10,6 +10,7 @@ local tostring = tostring
local next = next
local Public = {}
Public.events = {on_gui_removal = Event.generate_event_name('on_gui_removal')}
-- local to this file
local main_gui_tabs = {}
@ -46,6 +47,7 @@ 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'
Public.info_icon = 'file/utils/files/info.png'
Public.mod_gui_button_enabled = false
function Public.uid_name()
return tostring(Token.uid())
@ -60,6 +62,11 @@ local main_button_name = Public.uid_name()
local close_button_name = Public.uid_name()
Public.button_style = 'mod_gui_button'
if not Public.mod_gui_button_enabled then
Public.button_style = nil
end
Public.frame_style = 'non_draggable_frame'
Public.top_main_gui_button = main_button_name
@ -259,23 +266,12 @@ function Public.add_main_frame_with_toolbar(player, align, set_frame_name, set_s
local inside_frame =
main_frame.add {
type = 'frame',
style = 'inside_shallow_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 or inside_table_count,
name = 'inside_frame'
}
inside_table.style.padding = 3
return main_frame, inside_table
return main_frame, inside_frame
end
-- Removes data associated with LuaGuiElement and its children recursively.
@ -467,14 +463,10 @@ function Public.get_main_frame(player)
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
return inside_frame
end
return false
end
@ -648,7 +640,6 @@ function Public.reload_active_tab(player, forced)
if not frame then
return
end
local tab = main_gui_tabs[frame.caption]
if not tab then
return
@ -657,24 +648,24 @@ function Public.reload_active_tab(player, forced)
if not id then
return
end
local func = Token.get(id)
local callback = Token.get(id)
local d = {
player = player,
frame = main_tab
}
return func(d)
return callback(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'})
Public.add_mod_button(player, {type = 'sprite-button', name = main_button_name, sprite = 'item/raw-fish', style = Public.button_style})
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'})
local button = player.gui.top.add({type = 'sprite-button', name = main_button_name, sprite = 'item/raw-fish', style = Public.button_style})
button.style.minimal_height = 38
button.style.maximal_height = 38
button.style.minimal_width = 40
@ -692,39 +683,27 @@ local function draw_main_frame(player)
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 frame, inside_frame = Public.add_main_frame_with_toolbar(player, 'left', main_frame_name, nil, close_button_name, 'Comfy Factorio')
local tabbed_pane = inside_frame.add({type = 'tabbed-pane', name = 'tabbed_pane'})
for name, func in pairs(tabs) do
for name, callback in pairs(tabs) do
if not settings.disabled_tabs[name] then
if func.only_server_sided then
if callback.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 tab = tabbed_pane.add({type = 'tab', caption = name, name = callback.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
elseif callback.admin == true then
if player.admin then
local tab = tabbed_pane.add({type = 'tab', caption = name, name = func.name})
local tab = tabbed_pane.add({type = 'tab', caption = name, name = callback.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 tab = tabbed_pane.add({type = 'tab', caption = name, name = callback.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
@ -740,6 +719,32 @@ local function draw_main_frame(player)
return frame, inside_frame
end
function Public.get_content(player)
local left_frame = Public.get_main_frame(player)
if not left_frame then
return false
end
return left_frame.tabbed_pane
end
function Public.refresh(player)
local frame = get_player_active_tab(player)
if not frame then
return false
end
local tabbed_pane = Public.get_content(player)
for _, tab in pairs(tabbed_pane.tabs) do
if tab.content.name ~= frame.name then
tab.content.clear()
end
end
Public.reload_active_tab(player, true)
return true
end
function Public.call_existing_tab(player, name)
local frame, inside_frame = draw_main_frame(player)
if not frame then
@ -908,6 +913,40 @@ Public.on_click(
end
)
Event.add(
defines.events.on_gui_click,
function(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 == main_button_name then
local is_spamming = SpamProtection.is_spamming(player, nil, 'Main GUI Click')
if is_spamming then
return
end
Public.refresh(player)
end
if not event.element.caption then
return
end
if event.element.type ~= 'tab' then
return
end
local success = Public.refresh(player)
if not success then
Public.reload_active_tab(player)
end
end
)
Event.add(
defines.events.on_player_created,
function(event)
@ -924,4 +963,22 @@ Event.add(
end
)
Event.add(
Public.events.on_gui_removal,
function(player)
local b =
Public.get_button_flow(player).add(
{
type = 'sprite-button',
name = main_button_name,
sprite = 'utility/expand_dots',
style = Public.button_style,
tooltip = 'The panel of all the goodies!'
}
)
b.style.padding = 2
b.style.width = 20
end
)
return Public

View File

@ -32,7 +32,7 @@ local function build_group_gui(data)
local members_width = 90
local member_columns = 2
local actions_width = 130
local total_height = frame.style.minimal_height - 60
local total_height = (frame.style.minimal_height or 500) - 60
frame.clear()

File diff suppressed because it is too large Load Diff

View File

@ -773,7 +773,8 @@ local function player_joined(event)
type = 'sprite-button',
name = main_button_name,
sprite = 'item/programmable-speaker',
tooltip = 'Let your question be heard!'
tooltip = 'Let your question be heard!',
style = Gui.button_style
}
)
else
@ -789,7 +790,8 @@ local function player_joined(event)
type = 'sprite-button',
name = main_button_name,
sprite = 'item/programmable-speaker',
tooltip = 'Let your question be heard!'
tooltip = 'Let your question be heard!',
style = Gui.button_style
}
b.style.maximal_height = 38
end

View File

@ -139,7 +139,8 @@ local function create_main_button(event)
type = 'sprite-button',
name = main_button_name,
sprite = 'utility/surface_editor_icon',
tooltip = 'Connect to another Comfy server!'
tooltip = 'Connect to another Comfy server!',
style = Gui.button_style
}
)
else
@ -151,7 +152,8 @@ local function create_main_button(event)
type = 'sprite-button',
sprite = 'utility/surface_editor_icon',
tooltip = 'Connect to another Comfy server!',
name = main_button_name
name = main_button_name,
style = Gui.button_style
}
)
main_button.style.font_color = {r = 0.11, g = 0.8, b = 0.44}

701
utils/player_list_vars.lua Normal file
View File

@ -0,0 +1,701 @@
local Public = {}
local Session = require 'utils.datastore.session_data'
local Jailed = require 'utils.datastore.jail_data'
local Supporters = require 'utils.datastore.supporters'
local Gui = require 'utils.gui'
Public.ranks = {
'item/burner-mining-drill',
'item/burner-mining-drill',
'item/burner-mining-drill',
'item/burner-inserter',
'item/burner-inserter',
'item/burner-inserter',
'item/stone-furnace',
'item/stone-furnace',
'item/stone-furnace',
'item/light-armor',
'item/light-armor',
'item/light-armor',
'item/steam-engine',
'item/steam-engine',
'item/steam-engine',
'item/inserter',
'item/inserter',
'item/inserter',
'item/transport-belt',
'item/transport-belt',
'item/transport-belt',
'item/underground-belt',
'item/underground-belt',
'item/underground-belt',
'item/splitter',
'item/splitter',
'item/splitter',
'item/assembling-machine-1',
'item/assembling-machine-1',
'item/assembling-machine-1',
'item/long-handed-inserter',
'item/long-handed-inserter',
'item/long-handed-inserter',
'item/electronic-circuit',
'item/electronic-circuit',
'item/electronic-circuit',
'item/electric-mining-drill',
'item/electric-mining-drill',
'item/electric-mining-drill',
'item/dummy-steel-axe',
'item/dummy-steel-axe',
'item/dummy-steel-axe',
'item/heavy-armor',
'item/heavy-armor',
'item/heavy-armor',
'item/steel-furnace',
'item/steel-furnace',
'item/steel-furnace',
'item/gun-turret',
'item/gun-turret',
'item/gun-turret',
'item/fast-transport-belt',
'item/fast-transport-belt',
'item/fast-transport-belt',
'item/fast-underground-belt',
'item/fast-underground-belt',
'item/fast-underground-belt',
'item/fast-splitter',
'item/fast-splitter',
'item/fast-splitter',
'item/assembling-machine-2',
'item/assembling-machine-2',
'item/assembling-machine-2',
'item/fast-inserter',
'item/fast-inserter',
'item/fast-inserter',
'item/radar',
'item/radar',
'item/radar',
'item/filter-inserter',
'item/filter-inserter',
'item/filter-inserter',
'item/defender-capsule',
'item/defender-capsule',
'item/defender-capsule',
'item/pumpjack',
'item/pumpjack',
'item/pumpjack',
'item/chemical-plant',
'item/chemical-plant',
'item/chemical-plant',
'item/chemical-plant',
'item/solar-panel',
'item/solar-panel',
'item/solar-panel',
'item/advanced-circuit',
'item/advanced-circuit',
'item/advanced-circuit',
'item/modular-armor',
'item/modular-armor',
'item/modular-armor',
'item/accumulator',
'item/accumulator',
'item/accumulator',
'item/construction-robot',
'item/construction-robot',
'item/construction-robot',
'item/distractor-capsule',
'item/distractor-capsule',
'item/distractor-capsule',
'item/stack-inserter',
'item/stack-inserter',
'item/stack-inserter',
'item/electric-furnace',
'item/electric-furnace',
'item/electric-furnace',
'item/express-transport-belt',
'item/express-transport-belt',
'item/express-transport-belt',
'item/express-transport-belt',
'item/express-underground-belt',
'item/express-underground-belt',
'item/express-underground-belt',
'item/express-splitter',
'item/express-splitter',
'item/express-splitter',
'item/assembling-machine-3',
'item/assembling-machine-3',
'item/assembling-machine-3',
'item/processing-unit',
'item/processing-unit',
'item/processing-unit',
'item/power-armor',
'item/power-armor',
'item/power-armor',
'item/logistic-robot',
'item/logistic-robot',
'item/logistic-robot',
'item/laser-turret',
'item/laser-turret',
'item/laser-turret',
'item/stack-filter-inserter',
'item/stack-filter-inserter',
'item/stack-filter-inserter',
'item/destroyer-capsule',
'item/destroyer-capsule',
'item/destroyer-capsule',
'item/power-armor-mk2',
'item/power-armor-mk2',
'item/power-armor-mk2',
'item/flamethrower-turret',
'item/flamethrower-turret',
'item/flamethrower-turret',
'item/beacon',
'item/beacon',
'item/beacon',
'item/steam-turbine',
'item/steam-turbine',
'item/steam-turbine',
'item/centrifuge',
'item/centrifuge',
'item/centrifuge',
'item/nuclear-reactor',
'item/nuclear-reactor',
'item/nuclear-reactor',
'item/cannon-shell',
'item/cannon-shell',
'item/cannon-shell',
'item/rocket',
'item/rocket',
'item/rocket',
'item/explosive-cannon-shell',
'item/explosive-cannon-shell',
'item/explosive-cannon-shell',
'item/explosive-rocket',
'item/explosive-rocket',
'item/explosive-rocket',
'item/uranium-cannon-shell',
'item/uranium-cannon-shell',
'item/uranium-cannon-shell',
'item/explosive-uranium-cannon-shell',
'item/explosive-uranium-cannon-shell',
'item/explosive-uranium-cannon-shell',
'item/atomic-bomb',
'item/atomic-bomb',
'item/atomic-bomb',
'achievement/so-long-and-thanks-for-all-the-fish',
'achievement/so-long-and-thanks-for-all-the-fish',
'achievement/so-long-and-thanks-for-all-the-fish',
'achievement/watch-your-step',
'achievement/watch-your-step',
'achievement/watch-your-step',
'achievement/golem',
'achievement/golem',
'achievement/golem',
'achievement/you-are-doing-it-right',
'achievement/you-are-doing-it-right',
'achievement/you-are-doing-it-right'
}
Public.pokemessages = {
'a stick',
'a leaf',
'a moldy carrot',
'a crispy slice of bacon',
'a french fry',
'a realistic toygun',
'a broomstick',
'a thirteen inch iron stick',
'a mechanical keyboard',
'a fly fishing cane',
'a selfie stick',
'an oversized fidget spinner',
'a thumb extender',
'a dirty straw',
'a green bean',
'a banana',
'an umbrella',
"grandpa's walking stick",
'live firework',
'a toilet brush',
'a fake hand',
'an undercooked hotdog',
"a slice of yesterday's microwaved pizza",
'bubblegum',
'a biter leg',
"grandma's toothbrush",
'charred octopus',
'a dollhouse bathtub',
'a length of copper wire',
'a decommissioned nuke',
'a smelly trout',
'an unopened can of deodorant',
'a stone brick',
'a half full barrel of lube',
'a half empty barrel of lube',
'an unexploded cannon shell',
'a blasting programmable speaker',
'a not so straight rail',
'a mismatched pipe to ground',
'a surplus box of landmines',
'decommissioned yellow rounds',
'an oily pumpjack shaft',
'a melted plastic bar in the shape of the virgin mary',
'a bottle of watermelon vitamin water',
'a slice of watermelon',
'a stegosaurus tibia',
"a basking musician's clarinet",
'a twig',
'an undisclosed pokey item',
'a childhood trophy everyone else got',
'a dead starfish',
'a titanium toothpick',
'a nail file',
'a stamp collection',
'a bucket of lego',
'a rolled up carpet',
'a rolled up WELCOME doormat',
"Bobby's favorite bone",
'an empty bottle of cheap vodka',
'a tattooing needle',
'a peeled cucumber',
'a stack of cotton candy',
'a signed baseball bat',
'that 5 dollar bill grandma sent for christmas',
'a stack of overdue phone bills',
"the 'relax' section of the white pages",
'a bag of gym clothes which never made it to the washing machine',
'a handful of peanut butter',
"a pheasant's feather",
'a rusty pickaxe',
'a diamond sword',
'the bill of rights of a banana republic',
"one of those giant airport Toblerone's",
'a long handed inserter',
'a wiimote',
'an easter chocolate rabbit',
'a ball of yarn the cat threw up',
'a slightly expired but perfectly edible cheese sandwich',
'conclusive proof of lizard people existence',
'a pen drive full of high res wallpapers',
'a pet hamster',
'an oversized goldfish',
'a one foot extension cord',
"a CD from Walmart's 1 dollar bucket",
'a magic wand',
'a list of disappointed people who believed in you',
'murder exhibit no. 3',
"a paperback copy of 'Great Expectations'",
'a baby biter',
'a little biter fang',
'the latest diet fad',
'a belt that no longer fits you',
'an abandoned pet rock',
'a lava lamp',
'some spirit herbs',
'a box of fish sticks found at the back of the freezer',
'a bowl of tofu rice',
'a bowl of ramen noodles',
'a live lobster!',
'a miniature golf cart',
'dunce cap',
'a fully furnished x-mas tree',
'an orphaned power pole',
'an horphaned power pole',
'an box of overpriced girl scout cookies',
'the cheapest item from the yard sale',
'a Sharpie',
'a glowstick',
'a thick unibrow hair',
'a very detailed map of Kazakhstan',
'the official Factorio installation DVD',
'a Liberal Arts degree',
'a pitcher of Kool-Aid',
'a 1/4 pound vegan burrito',
'a bottle of expensive wine',
'a hamster sized gravestone',
'a counterfeit Cuban cigar',
'an old Nokia phone',
'a huge inferiority complex',
'a dead real state agent',
'a deck of tarot cards',
'unreleased Wikileaks documents',
'a mean-looking garden dwarf',
'the actual mythological OBESE cat',
'a telescope used to spy on the MILF next door',
'a fancy candelabra',
'the comic version of the Kama Sutra',
"an inflatable 'Netflix & chill' doll",
'whatever it is redlabel gets high on',
"Obama's birth certificate",
'a deck of Cards Against Humanity',
'a copy of META MEME HUMOR for Dummies',
'an abandoned, not-so-young-anymore puppy',
'one of those useless items advertised on TV',
'a genetic blueprint of a Japanese teen idol'
}
Public.gui_data = function(data)
local header_label_name = data.header_label_name
local show_roles_in_list = data.show_roles_in_list
local locate_player_frame_name = data.locate_player_frame_name
local rpg_enabled = data.rpg_enabled
local poke_player_frame_name = data.poke_player_frame_name
local play_table = Session.get_trusted_table()
local jailed = Jailed.get_jailed_table()
local connected_players = #game.connected_players
local players = game.players
local gui_data = {}
gui_data[#gui_data + 1] = {
width = 40,
header_width = 35,
name = '[color=0.1,0.7,0.1]' .. tostring(connected_players) .. '[/color]',
func = function(player_list_panel_table, player, index)
local sprite =
player_list_panel_table.add {
type = 'sprite',
name = 'player_rank_sprite_' .. index,
sprite = player.rank
}
sprite.style.height = 32
sprite.style.width = 32
sprite.style.stretch_image_to_widget_size = true
end,
sorter = function(self, player_tbl)
local flow = player_tbl.add {type = 'flow'}
local header_label =
flow.add {
type = 'label',
name = header_label_name,
caption = self.name
}
header_label.style.font = 'heading-2'
header_label.style.font_color = {r = 0.98, g = 0.66, b = 0.22}
header_label.style.minimal_width = 36
header_label.style.maximal_width = 36
header_label.style.horizontal_align = 'right'
end
}
gui_data[#gui_data + 1] = {
width = 155,
header_width = 150,
header = 'username',
name = 'Online / [color=0.7,0.1,0.1]' .. tostring(#players - connected_players) .. '[/color]' .. ' Offline',
func = function(player_list_panel_table, player)
local supporter, supportertbl = Supporters.is_supporter(player.name)
local trusted = ''
local tooltip = ''
local minimap = '\nLeft-click to show this person on map! '
if supporter then
if supportertbl.monthly then
trusted = '[color=yellow][DM][/color]'
tooltip = '\nThis player is a monthly supporter.'
else
trusted = '[color=yellow][D][/color]'
tooltip = '\nThis player has supported us.'
end
end
if player.admin then
trusted = '[color=red][A][/color]' .. trusted
tooltip = 'This player is an admin of this server.' .. tooltip
elseif jailed[player.name] then
trusted = '[color=orange][J][/color]' .. trusted
tooltip = 'This player is currently jailed.' .. minimap .. tooltip
elseif play_table[player.name] then
trusted = '[color=green][T][/color]' .. trusted
tooltip = 'This player is trusted.' .. minimap .. tooltip
else
trusted = '[color=black][U][/color]' .. trusted
tooltip = 'This player is not trusted.' .. minimap .. tooltip
end
local caption
if show_roles_in_list or player.admin then
caption = player.name .. ' ' .. trusted
else
caption = player.name
end
-- Name
local name_flow =
player_list_panel_table.add {
type = 'flow'
}
local name_label =
name_flow.add {
type = 'label',
name = locate_player_frame_name,
caption = caption,
tooltip = tooltip
}
Gui.set_data(name_label, player.index)
name_label.style.font = 'default'
name_label.style.font_color = {
r = .4 + player.color.r * 0.6,
g = .4 + player.color.g * 0.6,
b = .4 + player.color.b * 0.6
}
name_label.style.minimal_width = 165
name_label.style.maximal_width = 165
name_label.style.font = 'heading-3'
end,
sorter = function(self, player_tbl)
local flow = player_tbl.add {type = 'flow', name = 'username'}
local header_label =
flow.add {
type = 'label',
name = header_label_name,
caption = self.name,
tooltip = 'Sort by name.'
}
header_label.style.font = 'heading-2'
header_label.style.font_color = {r = 0.98, g = 0.66, b = 0.22}
end
}
if rpg_enabled then
gui_data[#gui_data + 1] = {
width = 90,
header = 'rpg',
header_width = 90,
name = 'RPG level',
func = function(player_list_panel_table, player)
local rpg_level_label =
player_list_panel_table.add {
type = 'label',
caption = player.rpg_level
}
rpg_level_label.style.minimal_width = 90
rpg_level_label.style.maximal_width = 90
rpg_level_label.style.font = 'heading-3'
end,
sorter = function(self, player_tbl)
local flow = player_tbl.add {type = 'flow', name = 'rpg'}
local header_label =
flow.add {
type = 'label',
name = header_label_name,
caption = self.name,
tooltip = 'Sort by RPG level.'
}
header_label.style.font = 'heading-2'
header_label.style.font_color = {r = 0.98, g = 0.66, b = 0.22}
end
}
end
gui_data[#gui_data + 1] = {
width = 90,
header = 'coins',
header_width = 90,
name = 'Coins',
func = function(player_list_panel_table, player)
local coins_label =
player_list_panel_table.add {
type = 'label',
caption = player.coins
}
coins_label.style.minimal_width = 90
coins_label.style.maximal_width = 90
coins_label.style.font = 'heading-3'
end,
sorter = function(self, player_tbl)
local flow = player_tbl.add {type = 'flow', name = 'coins'}
local header_label =
flow.add {
type = 'label',
name = header_label_name,
caption = self.name,
tooltip = 'Sort by amount coins (currently only counts the amount of coins that are stored in the player inventory).'
}
header_label.style.font = 'heading-2'
header_label.style.font_color = {r = 0.98, g = 0.66, b = 0.22}
end
}
gui_data[#gui_data + 1] = {
width = 145,
header = 'total_time',
header_width = 150,
name = 'Total Time',
func = function(player_list_panel_table, player)
-- Total time
local total_label =
player_list_panel_table.add {
type = 'label',
caption = player.total_played_time,
tooltip = 'Total time played across all Comfy servers.'
}
total_label.style.minimal_width = 145
total_label.style.maximal_width = 145
total_label.style.font = 'heading-3'
end,
sorter = function(self, player_tbl)
local flow = player_tbl.add {type = 'flow', name = 'total_time'}
local header_label =
flow.add {
type = 'label',
name = header_label_name,
caption = self.name,
tooltip = 'Sort by total time played.'
}
header_label.style.font = 'heading-2'
header_label.style.font_color = {r = 0.98, g = 0.66, b = 0.22}
end
}
gui_data[#gui_data + 1] = {
width = 165,
header_width = 175,
header = 'current_time',
name = 'Current Time',
func = function(player_list_panel_table, player)
-- Current time
local current_label =
player_list_panel_table.add {
type = 'label',
caption = player.played_time,
tooltip = 'Current time played on this server.'
}
current_label.style.minimal_width = 165
current_label.style.maximal_width = 165
current_label.style.font = 'heading-3'
end,
sorter = function(self, player_tbl)
local flow = player_tbl.add {type = 'flow', name = 'current_time'}
local header_label =
flow.add {
type = 'label',
name = header_label_name,
caption = self.name,
tooltip = 'Sort by current time played.'
}
header_label.style.font = 'heading-2'
header_label.style.font_color = {r = 0.98, g = 0.66, b = 0.22}
end
}
gui_data[#gui_data + 1] = {
width = 50,
header_width = 60,
header = 'poke',
name = 'Poke',
func = function(player_list_panel_table, player, index)
-- Poke
local poke_flow = player_list_panel_table.add {type = 'flow', name = 'button_flow_' .. index, direction = 'horizontal'}
poke_flow.style.right_padding = 20
local poke_label = poke_flow.add {type = 'label', name = 'button_spacer_' .. index, caption = ''}
local poke_button = poke_flow.add {type = 'button', name = poke_player_frame_name, caption = player.pokes}
Gui.set_data(poke_button, player.index)
poke_button.style.font = 'default'
poke_button.tooltip = 'Poke ' .. player.name .. ' with a random message!\nDoes not work poking yourself :<'
poke_label.style.font_color = {r = 0.83, g = 0.83, b = 0.83}
poke_button.style.minimal_height = 30
poke_button.style.minimal_width = 30
poke_button.style.maximal_height = 30
poke_button.style.maximal_width = 30
poke_button.style.top_padding = 0
poke_button.style.left_padding = 0
poke_button.style.right_padding = 0
poke_button.style.bottom_padding = 0
end,
sorter = function(self, player_tbl)
local flow = player_tbl.add {type = 'flow', name = 'poke'}
local header_label =
flow.add {
type = 'label',
name = header_label_name,
caption = self.name,
tooltip = 'Sort by amount of pokes.'
}
header_label.style.font = 'heading-2'
header_label.style.font_color = {r = 0.98, g = 0.66, b = 0.22}
end
}
return gui_data
end
local comparators = {
['poke_asc'] = function(a, b)
if not a.pokes then
return
end
return a.pokes > b.pokes
end,
['poke_desc'] = function(a, b)
if not a.pokes then
return
end
return a.pokes < b.pokes
end,
['total_time_asc'] = function(a, b)
if not a.total_played_ticks then
return
end
return a.total_played_ticks < b.total_played_ticks
end,
['total_time_desc'] = function(a, b)
if not a.total_played_ticks then
return
end
return a.total_played_ticks > b.total_played_ticks
end,
['current_time_asc'] = function(a, b)
if not a.played_ticks then
return
end
return a.played_ticks < b.played_ticks
end,
['current_time_desc'] = function(a, b)
if not a.played_ticks then
return
end
return a.played_ticks > b.played_ticks
end,
['rpg_asc'] = function(a, b)
if not a.rpg_level then
return
end
return a.rpg_level < b.rpg_level
end,
['rpg_desc'] = function(a, b)
if not a.rpg_level then
return
end
return a.rpg_level > b.rpg_level
end,
['coins_asc'] = function(a, b)
if not a.coins then
return
end
return a.coins < b.coins
end,
['coins_desc'] = function(a, b)
if not a.coins then
return
end
return a.coins > b.coins
end,
['username_asc'] = function(a, b)
if not a.name then
return
end
return a.name:lower() < b.name:lower()
end,
['username_desc'] = function(a, b)
if not a.name then
return
end
return a.name:lower() > b.name:lower()
end
}
Public.get_comparator = function(sort_by)
return comparators[sort_by]
end
return Public

View File

@ -54,6 +54,66 @@ Module.cast_bool = function(var)
end
end
Module.get_formatted_playtime = function(x)
if x < 5184000 then
local y = x / 216000
y = tostring(y)
local h = ''
for i = 1, 10, 1 do
local z = string.sub(y, i, i)
if z == '.' then
break
else
h = h .. z
end
end
local m = x % 216000
m = m / 3600
m = math.floor(m)
m = tostring(m)
if h == '0' then
local str = m .. ' minutes'
return str
else
local str = h .. ' hours '
str = str .. m
str = str .. ' minutes'
return str
end
else
local y = x / 5184000
y = tostring(y)
local h = ''
for i = 1, 10, 1 do
local z = string.sub(y, i, i)
if z == '.' then
break
else
h = h .. z
end
end
local m = x % 5184000
m = m / 216000
m = math.floor(m)
m = tostring(m)
if h == '0' then
local str = m .. ' days'
return str
else
local str = h .. ' days '
str = str .. m
str = str .. ' hours'
return str
end
end
end
Module.find_entities_by_last_user = function(player, surface, filters)
if type(player) == 'string' or not player then
error("bad argument #1 to '" .. debug.getinfo(1, 'n').name .. "' (number or LuaPlayer expected, got " .. type(player) .. ')', 1)