diff --git a/maps/mountain_fortress_v3/entities.lua b/maps/mountain_fortress_v3/entities.lua index 4a9c768d..7cb59320 100644 --- a/maps/mountain_fortress_v3/entities.lua +++ b/maps/mountain_fortress_v3/entities.lua @@ -296,7 +296,7 @@ local function angry_tree(entity, cause) if random(1, 8) == 1 then hidden_worm(entity) end - if random(1, 16) ~= 1 then + if random(1, 32) ~= 1 then return end local position = false @@ -809,12 +809,7 @@ function Public.loco_died() return end - -- raise_event( - -- HD.events.reset_game, - -- { - -- surface = surface - -- } - -- ) + this.locomotive_health = 0 this.locomotive.color = {0.49, 0, 255, 1} rendering.set_text(this.health_text, 'HP: ' .. this.locomotive_health .. ' / ' .. this.locomotive_max_health) diff --git a/maps/mountain_fortress_v3/main.lua b/maps/mountain_fortress_v3/main.lua index a089dee5..7b557745 100644 --- a/maps/mountain_fortress_v3/main.lua +++ b/maps/mountain_fortress_v3/main.lua @@ -14,7 +14,6 @@ require 'modules.biters_yield_coins' require 'modules.wave_defense.main' require 'modules.mineable_wreckage_yields_scrap' require 'modules.charging_station' -require 'modules.admins_operate_biters' local IC = require 'maps.mountain_fortress_v3.ic.table' local Autostash = require 'modules.autostash' @@ -95,24 +94,6 @@ local init_new_force = function() enemy.set_friend('protectors', true) end -local collapse_kill = { - entities = { - ['laser-turret'] = true, - ['flamethrower-turret'] = true, - ['gun-turret'] = true, - ['artillery-turret'] = true, - ['landmine'] = true, - ['locomotive'] = true, - ['cargo-wagon'] = true, - ['car'] = true, - ['tank'] = true, - ['assembling-machine'] = true, - ['furnace'] = true, - ['steel-chest'] = true - }, - enabled = true -} - local disable_tech = function() game.forces.player.technologies['landfill'].enabled = false game.forces.player.technologies['spidertron'].enabled = false @@ -344,8 +325,7 @@ function Public.reset_map() game.map_settings.path_finder.max_work_done_per_tick = 4000 Diff.gui_width = 20 - Collapse.set_kill_entities(false) - Collapse.set_kill_specific_entities(collapse_kill) + Collapse.set_kill_entities(true) Collapse.set_speed(8) Collapse.set_amount(1) Collapse.set_max_line_size(Terrain.level_width) @@ -383,18 +363,10 @@ function Public.reset_map() game.forces.player.set_spawn_position({-27, 25}, surface) Task.start_queue() - Task.set_queue_speed(32) + Task.set_queue_speed(16) this.chunk_load_tick = game.tick + 1200 this.game_lost = false - - --HD.enable_auto_init = false - - --local pos = {x = this.icw_area.x, y = this.icw_area.y} - - --HD.init({position = pos, hd_surface = tostring(this.icw_locomotive.surface.name)}) - - --raise_event(HD.events.reset_game, {}) end local on_player_changed_position = function(event) @@ -418,18 +390,20 @@ local on_player_changed_position = function(event) local p = {x = player.position.x, y = player.position.y} local get_tile = surface.get_tile(p) - - if get_tile.valid and get_tile.name == 'lab-dark-2' then - if random(1, 2) == 1 then + local config_tile = WPT.get('void_or_tile') + if config_tile == 'lab-dark-2' then + if get_tile.valid and get_tile.name == 'lab-dark-2' then if random(1, 2) == 1 then - show_text('This path is not for players!', p, {r = 0.98, g = 0.66, b = 0.22}, surface) - end - player.surface.create_entity({name = 'fire-flame', position = player.position}) - player.character.health = player.character.health - tile_damage - if player.character.health == 0 then - player.character.die() - local message = player.name .. ' ' .. death_messages[random(1, #death_messages)] - game.print(message, {r = 0.98, g = 0.66, b = 0.22}) + if random(1, 2) == 1 then + show_text('This path is not for players!', p, {r = 0.98, g = 0.66, b = 0.22}, surface) + end + player.surface.create_entity({name = 'fire-flame', position = player.position}) + player.character.health = player.character.health - tile_damage + if player.character.health == 0 then + player.character.die() + local message = player.name .. ' ' .. death_messages[random(1, #death_messages)] + game.print(message, {r = 0.98, g = 0.66, b = 0.22}) + end end end end @@ -628,7 +602,7 @@ local on_research_finished = function(event) if not force_name then return end - this.flamethrower_damage[force_name] = -0.65 + this.flamethrower_damage[force_name] = -0.85 if research.name == 'military' then game.forces[force_name].set_turret_attack_modifier('flamethrower-turret', this.flamethrower_damage[force_name]) game.forces[force_name].set_ammo_damage_modifier('flamethrower', this.flamethrower_damage[force_name]) @@ -747,7 +721,6 @@ local boost_difficulty = function() WPT.set().bonus_xp_on_join = 700 WD.set().next_wave = game.tick + 3600 * 20 WPT.set().spidertron_unlocked_at_wave = 11 - WPT.set().math_difficulty = 4096 WPT.set().difficulty_set = true elseif name == 'Normal' then rpg_extra.difficulty = 0.5 @@ -763,7 +736,6 @@ local boost_difficulty = function() WPT.set().bonus_xp_on_join = 300 WD.set().next_wave = game.tick + 3600 * 15 WPT.set().spidertron_unlocked_at_wave = 16 - WPT.set().math_difficulty = 3072 WPT.set().difficulty_set = true elseif name == 'Hard' then rpg_extra.difficulty = 0 @@ -779,7 +751,6 @@ local boost_difficulty = function() WPT.set().bonus_xp_on_join = 50 WD.set().next_wave = game.tick + 3600 * 10 WPT.set().spidertron_unlocked_at_wave = 21 - WPT.set().math_difficulty = 2048 WPT.set().difficulty_set = true elseif name == 'Insane' then rpg_extra.difficulty = 0 @@ -795,7 +766,6 @@ local boost_difficulty = function() WPT.set().bonus_xp_on_join = 0 WD.set().next_wave = game.tick + 3600 * 5 WPT.set().spidertron_unlocked_at_wave = 26 - WPT.set().math_difficulty = 1024 WPT.set().difficulty_set = true end end @@ -805,7 +775,7 @@ local chunk_load = function() if chunk_load_tick then if chunk_load_tick < game.tick then WPT.get().chunk_load_tick = nil - Task.set_queue_speed(4) + Task.set_queue_speed(3) end end end @@ -875,10 +845,13 @@ local on_tick = function() boost_difficulty() collapse_after_wave_100() Entities.set_scores() - local collapse_pos = Collapse.get_position() - local position = surface.find_non_colliding_position('rocket-silo', collapse_pos, 128, 1) - if position then - WD.set_spawn_position(position) + local spawn_near_collapse = WPT.get('spawn_near_collapse') + if spawn_near_collapse then + local collapse_pos = Collapse.get_position() + local position = surface.find_non_colliding_position('rocket-silo', collapse_pos, 128, 1) + if position then + WD.set_spawn_position(position) + end end end end @@ -953,12 +926,11 @@ local on_init = function() ['mewmew'] = true, ['Gerkiz'] = true } + global.biter_command.enabled = false end - - global.biter_command.enabled = false end -Event.on_nth_tick(10, on_tick) +Event.on_nth_tick(15, on_tick) Event.on_init(on_init) Event.add(defines.events.on_player_joined_game, on_player_joined_game) Event.add(defines.events.on_player_left_game, on_player_left_game) diff --git a/maps/mountain_fortress_v3/table.lua b/maps/mountain_fortress_v3/table.lua index cf24544d..fe422318 100644 --- a/maps/mountain_fortress_v3/table.lua +++ b/maps/mountain_fortress_v3/table.lua @@ -5,11 +5,6 @@ local Event = require 'utils.event' local this = { players = {}, offline_players = {}, - --[[ hidden_dimension = { - logistic_research_level = 0, - reset_counter = 1 - }, - ]] breached_wall = 1, traps = {} } @@ -101,7 +96,7 @@ function Public.reset_table() this.explosive_bullets = false this.locomotive_biter = nil this.disconnect_wagon = false - this.math_difficulty = 9999 + this.spawn_near_collapse = false this.spidertron_unlocked_at_wave = 11 -- this.void_or_tile = 'lab-dark-2' this.void_or_tile = 'out-of-map' diff --git a/maps/mountain_fortress_v3/terrain.lua b/maps/mountain_fortress_v3/terrain.lua index 360eee4a..1ab6ba85 100644 --- a/maps/mountain_fortress_v3/terrain.lua +++ b/maps/mountain_fortress_v3/terrain.lua @@ -47,12 +47,6 @@ local tree_raffle = { } local size_of_tree_raffle = #tree_raffle -local spawner = { - 'biter-spawner', - 'spitter-spawner' -} -local size_of_spawner = #spawner - local scrap_entities = { 'crash-site-assembling-machine-1-broken', 'crash-site-assembling-machine-2-broken', @@ -440,17 +434,6 @@ local function process_level_14_position(x, y, data) return end - local value = WPT.get('math_difficulty') - - if random(1, value) == 1 then - entities[#entities + 1] = { - name = spawner[random(1, size_of_spawner)], - position = p, - force = 'protectors' - } - return - end - if small_caves > -0.41 and small_caves < 0.41 then if noise_cave_ponds > 0.35 then local success = place_wagon(data) @@ -511,17 +494,6 @@ local function process_level_13_position(x, y, data) return end - local value = WPT.get('math_difficulty') - - if random(1, value) == 1 then - entities[#entities + 1] = { - name = spawner[random(1, size_of_spawner)], - position = p, - force = 'protectors' - } - return - end - if small_caves < -0.35 or small_caves > 0.35 then tiles[#tiles + 1] = {name = 'deepwater-green', position = p} if random(1, 128) == 1 then @@ -601,17 +573,6 @@ local function process_level_12_position(x, y, data, void_or_lab) return end - local value = WPT.get('math_difficulty') - - if random(1, value) == 1 then - entities[#entities + 1] = { - name = spawner[random(1, size_of_spawner)], - position = p, - force = 'protectors' - } - return - end - if noise_1 < -0.72 then local success = place_wagon(data) if success then @@ -698,17 +659,6 @@ local function process_level_11_position(x, y, data) return end - local value = WPT.get('math_difficulty') - - if random(1, value) == 1 then - entities[#entities + 1] = { - name = spawner[random(1, size_of_spawner)], - position = p, - force = 'protectors' - } - return - end - if noise_1 > -0.30 and noise_1 < 0.30 then if noise_1 > -0.14 and noise_1 < 0.14 then tiles[#tiles + 1] = {name = 'dirt-7', position = p} @@ -794,18 +744,6 @@ local function process_level_10_position(x, y, data) tiles[#tiles + 1] = {name = 'water-green', position = p} return end - - local value = WPT.get('math_difficulty') - - if random(1, value) == 1 then - entities[#entities + 1] = { - name = spawner[random(1, size_of_spawner)], - position = p, - force = 'protectors' - } - return - end - --Resource Spots if smol_areas < -0.72 then if random(1, 8) == 1 then @@ -1216,17 +1154,6 @@ local function process_level_6_position(x, y, data, void_or_lab) return end - local value = WPT.get('math_difficulty') - - if random(1, value) == 1 then - entities[#entities + 1] = { - name = spawner[random(1, size_of_spawner)], - position = p, - force = 'protectors' - } - return - end - --Resource Spots if smol_areas < -0.72 then if random(1, 8) == 1 then @@ -1702,17 +1629,6 @@ local function process_level_2_position(x, y, data, void_or_lab) return end - local value = WPT.get('math_difficulty') - - if random(1, value) == 1 then - entities[#entities + 1] = { - name = spawner[random(1, size_of_spawner)], - position = p, - force = 'protectors' - } - return - end - --Market Spots if noise_cave_ponds < -0.80 then tiles[#tiles + 1] = {name = 'grass-' .. floor(noise_cave_ponds * 32) % 3 + 1, position = p} @@ -1834,17 +1750,6 @@ local function process_level_1_2_position(x, y, data, void_or_lab) end end - local value = WPT.get('math_difficulty') - - if random(1, value) == 1 then - entities[#entities + 1] = { - name = spawner[random(1, size_of_spawner)], - position = p, - force = 'protectors' - } - return - end - if noise_cave_ponds > 0.74 then tiles[#tiles + 1] = {name = 'grass-' .. random(1, 4), position = p} tiles[#tiles + 1] = {name = 'grass-1', position = p} @@ -2127,9 +2032,9 @@ local function process_level_0_position(x, y, data, void_or_lab) local markets = data.markets local treasure = data.treasure - local small_caves = get_noise('dungeons', p, seed + 33322) + local small_caves = get_noise('dungeons', p, seed + 24244) local noise_cave_ponds = get_noise('cave_ponds', p, seed) - local smol_areas = get_noise('smol_areas', p, seed + 33333) + local smol_areas = get_noise('smol_areas', p, seed + 23444) --Resource Spots if smol_areas < -0.71 then @@ -2139,7 +2044,7 @@ local function process_level_0_position(x, y, data, void_or_lab) end --Chasms - if noise_cave_ponds < 0.101 and noise_cave_ponds > -0.102 then + if noise_cave_ponds < 0.099 and noise_cave_ponds > -0.102 then if small_caves > 0.52 then tiles[#tiles + 1] = {name = void_or_lab, position = p} return @@ -2151,7 +2056,7 @@ local function process_level_0_position(x, y, data, void_or_lab) end --Water Ponds - if noise_cave_ponds > 0.790 then + if noise_cave_ponds > 0.770 then tiles[#tiles + 1] = {name = 'deepwater', position = p} if random(1, 16) == 1 then entities[#entities + 1] = {name = 'fish', position = p} @@ -2161,7 +2066,7 @@ local function process_level_0_position(x, y, data, void_or_lab) --Rivers local cave_rivers = get_noise('cave_rivers', p, seed + 200000) - if cave_rivers < 0.041 and cave_rivers > -0.042 then + if cave_rivers < 0.031 and cave_rivers > -0.032 then if noise_cave_ponds > 0 then tiles[#tiles + 1] = {name = 'water-shallow', position = p} if random(1, 64) == 1 then @@ -2171,7 +2076,7 @@ local function process_level_0_position(x, y, data, void_or_lab) end end - if noise_cave_ponds > 0.74 then + if noise_cave_ponds > 0.72 then tiles[#tiles + 1] = {name = 'grass-' .. random(1, 4), position = p} tiles[#tiles + 1] = {name = 'grass-1', position = p} if cave_rivers < -0.502 then @@ -2184,7 +2089,7 @@ local function process_level_0_position(x, y, data, void_or_lab) end --Market Spots - if noise_cave_ponds < -0.74 then + if noise_cave_ponds < -0.72 then tiles[#tiles + 1] = {name = 'grass-' .. floor(noise_cave_ponds * 32) % 3 + 1, position = p} if random(1, 32) == 1 then markets[#markets + 1] = p @@ -2195,7 +2100,7 @@ local function process_level_0_position(x, y, data, void_or_lab) return end - local no_rocks = get_noise('no_rocks', p, seed + 30000) + local no_rocks = get_noise('no_rocks', p, seed + 35000) --Worm oil Zones if p.y < -64 + noise_cave_ponds * 10 then if no_rocks < 0.11 and no_rocks > -0.11 then @@ -2244,30 +2149,6 @@ local function process_level_0_position(x, y, data, void_or_lab) if random(1, 2048) == 1 then treasure[#treasure + 1] = {position = p, chest = 'iron-chest'} end - local random_tiles = get_noise('forest_location', p, seed) - if random_tiles > 0.095 then - if random_tiles > 0.6 then - if random(1, 100) > 42 then - tiles[#tiles + 1] = {name = 'red-desert-0', position = p} - end - else - if random(1, 100) > 42 then - tiles[#tiles + 1] = {name = 'red-desert-1', position = p} - end - end - end - - if random_tiles < -0.095 then - if random_tiles < -0.6 then - if random(1, 100) > 42 then - tiles[#tiles + 1] = {name = 'red-desert-2', position = p} - end - else - if random(1, 100) > 42 then - tiles[#tiles + 1] = {name = 'red-desert-3', position = p} - end - end - end if random(1, 100) > 25 then entities[#entities + 1] = {name = rock_raffle[random(1, size_of_rock_raffle)], position = p} end diff --git a/modules/collapse.lua b/modules/collapse.lua index 07562a48..85eec3d2 100644 --- a/modules/collapse.lua +++ b/modules/collapse.lua @@ -106,19 +106,6 @@ local function progress() if not tile.valid then return end - if collapse.specific_entities.enabled then - local position = {tile.position.x + 0.5, tile.position.y + 0.5} - local entities = collapse.specific_entities.entities - for _, e in pairs( - surface.find_entities_filtered( - {area = {{position[1] - 2, position[2] - 2}, {position[1] + 2, position[2] + 2}}} - ) - ) do - if entities[e.name] and e.valid and e.health then - e.die() - end - end - end if collapse.kill then local position = {tile.position.x + 0.5, tile.position.y + 0.5} for _, e in pairs( @@ -128,6 +115,8 @@ local function progress() ) do if e.valid and e.health then e.die() + elseif e.valid then + e.destroy() end end end @@ -243,23 +232,12 @@ function Public.set_kill_entities(a) collapse.kill = a end -function Public.set_kill_specific_entities(tbl) - if tbl then - collapse.specific_entities = tbl - else - collapse.specific_entities = { - enabled = false - } - end -end - local function on_init() Public.set_surface(game.surfaces.nauvis) Public.set_position({0, 32}) Public.set_max_line_size(256) Public.set_direction('north') Public.set_kill_entities(true) - Public.set_kill_specific_entities() collapse.tiles = nil collapse.speed = 1 collapse.amount = 8 diff --git a/modules/portable_chest.lua b/modules/portable_chest.lua index 9b7c9eb7..456d3585 100644 --- a/modules/portable_chest.lua +++ b/modules/portable_chest.lua @@ -2,8 +2,6 @@ local Event = require 'utils.event' local Global = require 'utils.global' local Color = require 'utils.color_presets' local Gui = require 'utils.gui' -local m_gui = require 'mod-gui' -local mod = m_gui.get_button_flow local this = { inf_chests = {}, @@ -13,7 +11,9 @@ local this = { viewing_player = {}, editor = {}, ores_only = false, - allow_barrels = true + allow_barrels = true, + total_slots = {}, + stack_size = {} } local ore_names = { @@ -26,8 +26,10 @@ local ore_names = { } local format = string.format +local size = 35 local main_button_name = Gui.uid_name() local main_frame_name = Gui.uid_name() +local stack_slider_name = Gui.uid_name() local Public = {} @@ -48,6 +50,7 @@ local function clear_gui(player) return end if data.frame and data.frame.valid then + Gui.remove_data_recursively(data.frame) data.frame.destroy() end this.inf_gui[player.index] = nil @@ -57,13 +60,12 @@ local function clear_gui(player) end local function create_button(player) - mod(player).add( + player.gui.top.add( { type = 'sprite-button', sprite = 'item/logistic-chest-requester', name = main_button_name, - tooltip = 'Portable inventory stash!', - style = m_gui.button_style + tooltip = 'Portable inventory stash!' } ) end @@ -88,7 +90,14 @@ local function validate_player(player) end local function item(item_name, item_count, player, chest_id) - local item_stack = game.item_prototypes[item_name].stack_size + local stack_size = this.stack_size[player.index] + local item_stack + if stack_size then + item_stack = game.item_prototypes[item_name].stack_size * stack_size + else + item_stack = game.item_prototypes[item_name].stack_size + end + local diff = item_count - item_stack if not this.inf_storage[chest_id] then @@ -129,6 +138,9 @@ local function update_chest() end local inv = chest.get_inventory(defines.inventory.character_main) + if not inv or not inv.valid then + return + end local content = inv.get_contents() for item_name, item_count in pairs(content) do @@ -161,6 +173,9 @@ local function draw_main_frame(player, target, chest_id) name = main_frame_name } frame.auto_center = true + + local data = {} + local controls = frame.add {type = 'flow', direction = 'horizontal'} local items = frame.add {type = 'flow', direction = 'vertical'} @@ -168,7 +183,7 @@ local function draw_main_frame(player, target, chest_id) local btn = tbl.add { type = 'sprite-button', - tooltip = '[color=blue]Info![/color]\nYou can easily remove an item by left/right-clicking it.\n\nItems selected in the table below will remove all stacks except one from the player inventory.\nIf the stack-size is bigger in the personal stash than the players inventory stack then the players inventory will automatically refill from the personal stash.\n\n[color=red]Usage[/color]\nPressing the following keys will do the following actions:\nCTRL: Retrieves all stacks from clicked item\nSHIFT:Retrieves a stack from clicked item.', + tooltip = '[color=blue]Info![/color]\nYou can easily remove an item by left/right-clicking it.\n\nItems selected in the table below will remove all stacks except one from the player inventory.\nIf the stack-size is bigger in the personal stash than the players inventory stack then the players inventory will automatically refill from the personal stash.\n\n[color=red]Usage[/color]\nPressing the following keys will do the following actions:\nCTRL: Retrieves all stacks from clicked item\nSHIFT:Retrieves a stack from clicked item.\nStack-Size slider will always ensure that you have amounts of stacks in your inventory.', sprite = 'utility/questionmark' } btn.style.height = 20 @@ -176,11 +191,15 @@ local function draw_main_frame(player, target, chest_id) btn.enabled = false btn.focus() + if this.ores_only then + this.total_slots[player.index] = 6 + end + local amount_and_types if this.ores_only then - amount_and_types = '6 different ore' + amount_and_types = this.total_slots[player.index] .. ' different ore' else - amount_and_types = '48 different item' + amount_and_types = this.total_slots[player.index] .. ' different item' end local text = @@ -193,6 +212,27 @@ local function draw_main_frame(player, target, chest_id) } text.style.single_line = false + local tbl_2 = tbl.add {type = 'table', column_count = 2} + local stack_size = this.stack_size[player.index] + + local stack_value = tbl_2.add({type = 'label', caption = 'Stack Size: ' .. stack_size .. ' '}) + stack_value.style.font = 'default-bold' + data.stack_value = stack_value + + local slider = + tbl_2.add( + { + type = 'slider', + minimum_value = 1, + maximum_value = 10, + name = stack_slider_name, + value = stack_size + } + ) + data.slider = slider + slider.style.width = 115 + Gui.set_data(slider, data) + tbl.add({type = 'line'}) player.opened = frame @@ -257,26 +297,21 @@ local function update_gui() name = item_name } btn.enabled = true + btn.style.height = size + btn.style.width = size + btn.focus() end - if this.ores_only then - while total < 6 do - local btns = tbl.add {type = 'choose-elem-button', style = 'slot_button', elem_type = 'item'} - btns.enabled = true - if this.viewing_player[player.index] then - btns.enabled = false - end - total = total + 1 - end - else - while total < 48 do - local btns = tbl.add {type = 'choose-elem-button', style = 'slot_button', elem_type = 'item'} - btns.enabled = true - if this.viewing_player[player.index] then - btns.enabled = false - end - total = total + 1 + while total < this.total_slots[player.index] do + local btns = tbl.add {type = 'choose-elem-button', style = 'slot_button', elem_type = 'item'} + btns.enabled = true + btns.style.height = size + btns.style.width = size + btns.focus() + if this.viewing_player[player.index] then + btns.enabled = false end + total = total + 1 end this.inf_gui[player.index].updated = true @@ -443,7 +478,6 @@ local function on_gui_elem_changed(event) end storage[name] = 0 - element.tooltip = 'Right click to remove.' if this.editor[player.index] then storage[name] = 5000000 end @@ -467,11 +501,21 @@ local function on_player_joined_game(event) } end - if not this.inf_chests[player.index] then + chest_id = this.player_chests[player.index].chest_id + + if not this.inf_chests[chest_id] then this.inf_chests[chest_id] = player end - if not mod(player)[main_button_name] then + if not this.stack_size[player.index] then + this.stack_size[player.index] = 1 + end + + if not this.total_slots[player.index] then + this.total_slots[player.index] = 50 + end + + if not player.gui.top[main_button_name] then create_button(player) end end @@ -504,7 +548,7 @@ end Gui.on_click( main_button_name, function(event) - local player = event.player + local player = game.get_player(event.player_index) if not player or not player.valid or not player.character then return end @@ -519,6 +563,39 @@ Gui.on_click( end ) +Gui.on_value_changed( + stack_slider_name, + function(event) + local player = game.get_player(event.player_index) + if not player or not player.valid or not player.character then + return + end + + local element = event.element + if not element or not element.valid then + return + end + + local data = Gui.get_data(element) + local stack_value = data.stack_value + if not stack_value or not stack_value.valid then + return + end + + local slider = data.slider + if not slider or not slider.valid then + return + end + + local screen = player.gui.screen + local main_frame = screen[main_frame_name] + if main_frame and main_frame.valid then + this.stack_size[player.index] = element.slider_value + stack_value.caption = 'Stack Size: ' .. this.stack_size[player.index] .. ' ' + end + end +) + commands.add_command( 'open_stash', 'Opens a players private stash!', @@ -572,7 +649,7 @@ function Public.allow_barrels(value) return this.allow_barrels end -Event.on_nth_tick(15, tick) +Event.on_nth_tick(10, tick) Event.add(defines.events.on_gui_click, gui_click) Event.add(defines.events.on_gui_closed, gui_closed) Event.add(defines.events.on_player_joined_game, on_player_joined_game) diff --git a/modules/rpg/settings.lua b/modules/rpg/settings.lua index 8fd211f7..645ff277 100644 --- a/modules/rpg/settings.lua +++ b/modules/rpg/settings.lua @@ -18,7 +18,7 @@ local function create_input_element(frame, type, value, items, index) return frame.add({type = 'checkbox', state = value}) end if type == 'dropdown' then - return frame.add({type = 'drop-down', name = 'admin_player_select', items = items, selected_index = index}) + return frame.add({type = 'drop-down', items = items, selected_index = index}) end return frame.add({type = 'text-box', text = value}) end @@ -276,7 +276,7 @@ function Public.extra_settings(player) one_punch_gui_input.enabled = false one_punch_gui_input.tooltip = 'Enabled globally.' else - if rpg_t[player.index].level <= 30 then + if rpg_t[player.index].level <= 30 then one_punch_gui_input.enabled = false one_punch_gui_input.tooltip = 'Level requirement: 30\nChecked = true\nUnchecked = false' else diff --git a/utils/gui.lua b/utils/gui.lua index 4f2a8cf2..c3e84be4 100644 --- a/utils/gui.lua +++ b/utils/gui.lua @@ -27,6 +27,10 @@ function Gui.uid_name() return tostring(Token.uid()) end +function Gui.uid() + return Token.uid() +end + -- Associates data with the LuaGuiElement. If data is nil then removes the data function Gui.set_data(element, value) local player_index = element.player_index