mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-04 00:15:45 +02:00
tweaks and desync fix
This commit is contained in:
parent
39bfe6edbf
commit
a6bba87606
@ -232,10 +232,21 @@ local fortress_functions = {
|
|||||||
local this = WPT.get()
|
local this = WPT.get()
|
||||||
if event.element.switch_state == 'left' then
|
if event.element.switch_state == 'left' then
|
||||||
this.void_or_tile = 'out-of-map'
|
this.void_or_tile = 'out-of-map'
|
||||||
get_actor(event, '{Void}', 'has changes the the tiles of the zones to: out-of-map (void)')
|
get_actor(event, '{Void}', 'has changes the tiles of the zones to: out-of-map (void)')
|
||||||
else
|
else
|
||||||
this.void_or_tile = 'lab-dark-2'
|
this.void_or_tile = 'lab-dark-2'
|
||||||
get_actor(event, '{Void}', 'has changes the the tiles of the zones to: dark-tiles (flammable tiles)')
|
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)
|
||||||
|
local WPT = package.loaded['maps.mountain_fortress_v3.table']
|
||||||
|
local this = WPT.get()
|
||||||
|
if event.element.switch_state == 'left' then
|
||||||
|
this.trusted_only_car_tanks = true
|
||||||
|
get_actor(event, '{Market}', 'has changed so only trusted people can buy car/tanks.', true)
|
||||||
|
else
|
||||||
|
this.trusted_only_car_tanks = false
|
||||||
|
get_actor(event, '{Void}', 'has changed so everybody can buy car/tanks.', true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
@ -420,7 +431,7 @@ local build_config_gui = (function(player, frame)
|
|||||||
switch_state,
|
switch_state,
|
||||||
'comfy_panel_disable_antigrief',
|
'comfy_panel_disable_antigrief',
|
||||||
'Antigrief',
|
'Antigrief',
|
||||||
'Left = enables antigrief / Right = disables antigrief'
|
'Left = Enables antigrief / Right = Disables antigrief'
|
||||||
)
|
)
|
||||||
scroll_pane.add({type = 'line'})
|
scroll_pane.add({type = 'line'})
|
||||||
if package.loaded['maps.mountain_fortress_v3.main'] then
|
if package.loaded['maps.mountain_fortress_v3.main'] then
|
||||||
@ -444,7 +455,7 @@ local build_config_gui = (function(player, frame)
|
|||||||
switch_state,
|
switch_state,
|
||||||
'comfy_panel_disable_fullness',
|
'comfy_panel_disable_fullness',
|
||||||
'Inventory Fullness',
|
'Inventory Fullness',
|
||||||
'Left = enables inventory fullness.\nRight = disables inventory fullness.'
|
'Left = Enables inventory fullness.\nRight = Disables inventory fullness.'
|
||||||
)
|
)
|
||||||
|
|
||||||
scroll_pane.add({type = 'line'})
|
scroll_pane.add({type = 'line'})
|
||||||
@ -460,7 +471,7 @@ local build_config_gui = (function(player, frame)
|
|||||||
switch_state,
|
switch_state,
|
||||||
'comfy_panel_offline_players',
|
'comfy_panel_offline_players',
|
||||||
'Offline Players',
|
'Offline Players',
|
||||||
'Left = enables offline player inventory drop.\nRight = disables offline player inventory drop.'
|
'Left = Enables offline player inventory drop.\nRight = Disables offline player inventory drop.'
|
||||||
)
|
)
|
||||||
|
|
||||||
scroll_pane.add({type = 'line'})
|
scroll_pane.add({type = 'line'})
|
||||||
@ -474,7 +485,7 @@ local build_config_gui = (function(player, frame)
|
|||||||
switch_state,
|
switch_state,
|
||||||
'comfy_panel_collapse_grace',
|
'comfy_panel_collapse_grace',
|
||||||
'Collapse',
|
'Collapse',
|
||||||
'Left = enables collapse after wave 100.\nRight = disables collapse - you must reach zone 2 for collapse to occur.'
|
'Left = Enables collapse after wave 100.\nRight = Disables collapse - you must reach zone 2 for collapse to occur.'
|
||||||
)
|
)
|
||||||
|
|
||||||
scroll_pane.add({type = 'line'})
|
scroll_pane.add({type = 'line'})
|
||||||
@ -488,7 +499,7 @@ local build_config_gui = (function(player, frame)
|
|||||||
switch_state,
|
switch_state,
|
||||||
'comfy_panel_spill_items_to_surface',
|
'comfy_panel_spill_items_to_surface',
|
||||||
'Spill Ores',
|
'Spill Ores',
|
||||||
'Left = enables ore spillage to surface when mining.\nRight = disables ore spillage to surface when mining.'
|
'Left = Enables ore spillage to surface when mining.\nRight = Disables ore spillage to surface when mining.'
|
||||||
)
|
)
|
||||||
scroll_pane.add({type = 'line'})
|
scroll_pane.add({type = 'line'})
|
||||||
|
|
||||||
@ -501,7 +512,20 @@ local build_config_gui = (function(player, frame)
|
|||||||
switch_state,
|
switch_state,
|
||||||
'comfy_panel_void_or_tile',
|
'comfy_panel_void_or_tile',
|
||||||
'Void Tiles',
|
'Void Tiles',
|
||||||
'Left = changes the tiles to out-of-map.\nRight = changes the tiles to lab-dark-2'
|
'Left = Changes the tiles to out-of-map.\nRight = Changes the tiles to lab-dark-2'
|
||||||
|
)
|
||||||
|
scroll_pane.add({type = 'line'})
|
||||||
|
|
||||||
|
switch_state = 'right'
|
||||||
|
if this.trusted_only_car_tanks then
|
||||||
|
switch_state = 'left'
|
||||||
|
end
|
||||||
|
add_switch(
|
||||||
|
scroll_pane,
|
||||||
|
switch_state,
|
||||||
|
'comfy_panel_trusted_only_car_tanks',
|
||||||
|
'Market Purchase',
|
||||||
|
'Left = Allows only trusted people to buy car/tanks.\nRight = Allows everyone to buy car/tanks.'
|
||||||
)
|
)
|
||||||
scroll_pane.add({type = 'line'})
|
scroll_pane.add({type = 'line'})
|
||||||
end
|
end
|
||||||
|
@ -142,7 +142,7 @@ local function on_gui_click(event)
|
|||||||
|
|
||||||
if name == main_button_name then
|
if name == main_button_name then
|
||||||
if player.surface ~= locomotive.surface then
|
if player.surface ~= locomotive.surface then
|
||||||
local minimap = player.gui.left.icw_map
|
local minimap = player.gui.left.icw_main_frame
|
||||||
if minimap and minimap.visible then
|
if minimap and minimap.visible then
|
||||||
minimap.visible = false
|
minimap.visible = false
|
||||||
return
|
return
|
||||||
@ -240,7 +240,7 @@ local function on_player_changed_surface(event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if player.surface == main.surface then
|
if player.surface == main.surface then
|
||||||
local minimap = player.gui.left.icw_map
|
local minimap = player.gui.left.icw_main_frame
|
||||||
if minimap and minimap.visible then
|
if minimap and minimap.visible then
|
||||||
minimap.visible = false
|
minimap.visible = false
|
||||||
end
|
end
|
||||||
|
@ -34,6 +34,8 @@ local function on_player_mined_entity(event)
|
|||||||
|
|
||||||
local ic = IC.get()
|
local ic = IC.get()
|
||||||
|
|
||||||
|
Minimap.kill_minimap(game.players[event.player_index])
|
||||||
|
|
||||||
if entity.type == 'car' or entity.name == 'spidertron' then
|
if entity.type == 'car' or entity.name == 'spidertron' then
|
||||||
Functions.save_car(ic, event)
|
Functions.save_car(ic, event)
|
||||||
end
|
end
|
||||||
@ -105,6 +107,50 @@ local function on_tick()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function on_gui_closed(event)
|
||||||
|
local entity = event.entity
|
||||||
|
if not entity then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if not entity.valid then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if not entity.unit_number then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local ic = IC.get()
|
||||||
|
if not ic.cars[entity.unit_number] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
Minimap.kill_minimap(game.players[event.player_index])
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_gui_opened(event)
|
||||||
|
local entity = event.entity
|
||||||
|
if not entity or not entity.valid then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if not entity.unit_number then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local ic = IC.get()
|
||||||
|
local car = ic.cars[entity.unit_number]
|
||||||
|
if not car then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
Minimap.minimap(
|
||||||
|
game.players[event.player_index],
|
||||||
|
car.surface,
|
||||||
|
{
|
||||||
|
car.area.left_top.x + (car.area.right_bottom.x - car.area.left_top.x) * 0.5,
|
||||||
|
car.area.left_top.y + (car.area.right_bottom.y - car.area.left_top.y) * 0.5
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
local function on_gui_click(event)
|
local function on_gui_click(event)
|
||||||
local element = event.element
|
local element = event.element
|
||||||
if not element or not element.valid then
|
if not element or not element.valid then
|
||||||
@ -140,6 +186,8 @@ local changed_surface = Minimap.changed_surface
|
|||||||
|
|
||||||
Event.on_init(on_init)
|
Event.on_init(on_init)
|
||||||
Event.add(defines.events.on_tick, on_tick)
|
Event.add(defines.events.on_tick, on_tick)
|
||||||
|
Event.add(defines.events.on_gui_opened, on_gui_opened)
|
||||||
|
Event.add(defines.events.on_gui_closed, on_gui_closed)
|
||||||
Event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state)
|
Event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state)
|
||||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||||
Event.add(defines.events.on_built_entity, on_built_entity)
|
Event.add(defines.events.on_built_entity, on_built_entity)
|
||||||
|
@ -67,7 +67,7 @@ end
|
|||||||
|
|
||||||
function Public.toggle_auto(player)
|
function Public.toggle_auto(player)
|
||||||
local ic = ICT.get()
|
local ic = ICT.get()
|
||||||
local switch = player.gui.screen.minimap_toggle_frame['switch_auto_map']
|
local switch = player.gui.left.minimap_toggle_frame['switch_auto_map']
|
||||||
if not switch or not switch.valid then
|
if not switch or not switch.valid then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -80,18 +80,18 @@ function Public.toggle_auto(player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function kill_minimap(player)
|
local function kill_minimap(player)
|
||||||
local element = player.gui.screen.minimap_toggle_frame
|
local frame = player.gui.left.minimap_toggle_frame
|
||||||
if not element or not element.valid then
|
if not frame or not frame.valid then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if element.visible then
|
if frame.visible then
|
||||||
element.visible = false
|
frame.destroy()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function kill_frame(player)
|
local function kill_frame(player)
|
||||||
if player.gui.screen.minimap_toggle_frame then
|
if player.gui.left.minimap_toggle_frame then
|
||||||
local element = player.gui.screen.minimap_toggle_frame.minimap_frame
|
local element = player.gui.left.minimap_toggle_frame.minimap_frame
|
||||||
if not element or not element.valid then
|
if not element or not element.valid then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -99,36 +99,37 @@ local function kill_frame(player)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function draw_minimap(player)
|
local function draw_minimap(player, surface, position)
|
||||||
local ic = ICT.get()
|
local ic = ICT.get()
|
||||||
local surface = game.surfaces[ic.allowed_surface]
|
surface = surface or game.surfaces[ic.allowed_surface]
|
||||||
if not surface or not surface.valid then
|
if not surface or not surface.valid then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local cars = ic.cars
|
local cars = ic.cars
|
||||||
|
|
||||||
local entity = Functions.get_entity_from_player_surface(cars, player)
|
local entity = Functions.get_entity_from_player_surface(cars, player)
|
||||||
if not entity or not entity.valid then
|
if not position then
|
||||||
kill_minimap(player)
|
if not entity or not entity.valid then
|
||||||
kill_frame(player)
|
kill_minimap(player)
|
||||||
return
|
kill_frame(player)
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local position = entity.position
|
position = position or entity.position
|
||||||
local player_data = get_player_data(player)
|
local player_data = get_player_data(player)
|
||||||
local frame = player.gui.screen.minimap_toggle_frame
|
local frame = player.gui.left.minimap_toggle_frame
|
||||||
if not frame then
|
if not frame then
|
||||||
frame =
|
frame =
|
||||||
player.gui.screen.add(
|
player.gui.left.add(
|
||||||
{type = 'frame', direction = 'vertical', name = 'minimap_toggle_frame', caption = 'Outside View'}
|
{type = 'frame', direction = 'vertical', name = 'minimap_toggle_frame', caption = 'Minimap'}
|
||||||
)
|
)
|
||||||
frame.location = {x = 10, y = 45}
|
|
||||||
end
|
end
|
||||||
frame.visible = true
|
frame.visible = true
|
||||||
local element = frame['minimap_frame']
|
local element = frame['minimap_frame']
|
||||||
if not element then
|
if not element then
|
||||||
element =
|
element =
|
||||||
player.gui.screen.minimap_toggle_frame.add(
|
player.gui.left.minimap_toggle_frame.add(
|
||||||
{
|
{
|
||||||
type = 'camera',
|
type = 'camera',
|
||||||
name = 'minimap_frame',
|
name = 'minimap_frame',
|
||||||
@ -146,21 +147,16 @@ local function draw_minimap(player)
|
|||||||
element.position = position
|
element.position = position
|
||||||
end
|
end
|
||||||
|
|
||||||
function Public.minimap(player, autoaction)
|
function Public.minimap(player, surface, position)
|
||||||
local player_data = get_player_data(player)
|
local frame = player.gui.left['minimap_toggle_frame']
|
||||||
local frame = player.gui.screen['minimap_toggle_frame']
|
|
||||||
local ic = ICT.get()
|
local ic = ICT.get()
|
||||||
if frame and frame.visible then
|
if frame and frame.visible then
|
||||||
kill_minimap(player)
|
kill_minimap(player)
|
||||||
else
|
else
|
||||||
if Functions.get_player_surface(ic, player) then
|
if Functions.get_player_surface(ic, player) and not surface and not position then
|
||||||
if autoaction then
|
draw_minimap(player)
|
||||||
if player_data.auto_map then
|
else
|
||||||
draw_minimap(player)
|
draw_minimap(player, surface, position)
|
||||||
end
|
|
||||||
else
|
|
||||||
draw_minimap(player)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -168,7 +164,7 @@ end
|
|||||||
function Public.update_minimap()
|
function Public.update_minimap()
|
||||||
local ic = ICT.get()
|
local ic = ICT.get()
|
||||||
for k, player in pairs(game.connected_players) do
|
for k, player in pairs(game.connected_players) do
|
||||||
if Functions.get_player_surface(ic, player) and player.gui.screen.minimap_toggle_frame then
|
if Functions.get_player_surface(ic, player) and player.gui.left.minimap_toggle_frame then
|
||||||
kill_frame(player)
|
kill_frame(player)
|
||||||
draw_minimap(player)
|
draw_minimap(player)
|
||||||
end
|
end
|
||||||
@ -252,4 +248,6 @@ function Public.changed_surface(event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Public.kill_minimap = kill_minimap
|
||||||
|
|
||||||
return Public
|
return Public
|
||||||
|
@ -356,7 +356,7 @@ local function get_player_data(icw, player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Public.kill_minimap(player)
|
function Public.kill_minimap(player)
|
||||||
local element = player.gui.left.icw_map
|
local element = player.gui.left.icw_main_frame
|
||||||
if element then
|
if element then
|
||||||
element.destroy()
|
element.destroy()
|
||||||
end
|
end
|
||||||
@ -1043,15 +1043,20 @@ function Public.item_transfer(icw)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Public.draw_minimap(icw, player, surface, position)
|
function Public.draw_minimap(icw, player, surface, position)
|
||||||
local element = player.gui.left.icw_map
|
local frame = player.gui.left.icw_main_frame
|
||||||
|
if not frame then
|
||||||
|
frame =
|
||||||
|
player.gui.left.add({type = 'frame', direction = 'vertical', name = 'icw_main_frame', caption = 'Minimap'})
|
||||||
|
end
|
||||||
|
local element = frame['icw_sub_frame']
|
||||||
if not element then
|
if not element then
|
||||||
local player_data = get_player_data(icw, player)
|
local player_data = get_player_data(icw, player)
|
||||||
element =
|
element =
|
||||||
player.gui.left.add(
|
player.gui.left.icw_main_frame.add(
|
||||||
{
|
{
|
||||||
type = 'camera',
|
type = 'camera',
|
||||||
name = 'icw_map',
|
|
||||||
position = position,
|
position = position,
|
||||||
|
name = 'icw_sub_frame',
|
||||||
surface_index = surface.index,
|
surface_index = surface.index,
|
||||||
zoom = player_data.zoom,
|
zoom = player_data.zoom,
|
||||||
tooltip = 'LMB: Increase zoom level.\nRMB: Decrease zoom level.\nMMB: Toggle camera size.'
|
tooltip = 'LMB: Increase zoom level.\nRMB: Decrease zoom level.\nMMB: Toggle camera size.'
|
||||||
@ -1084,7 +1089,7 @@ function Public.toggle_minimap(icw, event)
|
|||||||
if not element.valid then
|
if not element.valid then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if element.name ~= 'icw_map' then
|
if element.name ~= 'icw_sub_frame' then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local player = game.players[event.player_index]
|
local player = game.players[event.player_index]
|
||||||
|
@ -406,6 +406,7 @@ local function redraw_market_items(gui, player, search_text)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local players = WPT.get('players')
|
local players = WPT.get('players')
|
||||||
|
local trusted = Session.get_trusted_table()
|
||||||
|
|
||||||
if gui and gui.valid then
|
if gui and gui.valid then
|
||||||
gui.clear()
|
gui.clear()
|
||||||
@ -510,6 +511,19 @@ local function redraw_market_items(gui, player, search_text)
|
|||||||
enabled = data.enabled
|
enabled = data.enabled
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
if WPT.get('trusted_only_car_tanks') then
|
||||||
|
if not trusted[player.name] then
|
||||||
|
if item == 'tank' then
|
||||||
|
button.enabled = false
|
||||||
|
button.tooltip = 'You need to be trusted to purchase this.'
|
||||||
|
end
|
||||||
|
if item == 'car' then
|
||||||
|
button.enabled = false
|
||||||
|
button.tooltip = 'You need to be trusted to purchase this.'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local label =
|
local label =
|
||||||
frame.add(
|
frame.add(
|
||||||
{
|
{
|
||||||
@ -569,7 +583,7 @@ local function slider_changed(event)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
slider_value = ceil(slider_value)
|
slider_value = ceil(slider_value)
|
||||||
this.players[player.index].data.quantity_input.text = slider_value
|
this.players[player.index].data.text_input.text = slider_value
|
||||||
redraw_market_items(this.players[player.index].data.item_frame, player, this.players[player.index].data.search_text)
|
redraw_market_items(this.players[player.index].data.item_frame, player, this.players[player.index].data.search_text)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -590,25 +604,25 @@ local function text_changed(event)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not data.quantity_input or not data.quantity_input.valid then
|
if not data.text_input or not data.text_input.valid then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not data.quantity_input.text then
|
if not data.text_input.text then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local value = tonumber(data.quantity_input.text)
|
local value = tonumber(data.text_input.text)
|
||||||
|
|
||||||
if not value then
|
if not value then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if (value > 1e2) then
|
if (value > 1e2) then
|
||||||
data.quantity_input.text = '100'
|
data.text_input.text = '100'
|
||||||
value = 1e2
|
value = 1e2
|
||||||
elseif (value <= 0) then
|
elseif (value <= 0) then
|
||||||
data.quantity_input.text = '1'
|
data.text_input.text = '1'
|
||||||
value = 1
|
value = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -695,25 +709,14 @@ local function gui_opened(event)
|
|||||||
|
|
||||||
bottom_grid.add({type = 'label', caption = 'Quantity: '}).style.font = 'default-bold'
|
bottom_grid.add({type = 'label', caption = 'Quantity: '}).style.font = 'default-bold'
|
||||||
|
|
||||||
local quantity_input =
|
local text_input =
|
||||||
bottom_grid.add(
|
bottom_grid.add(
|
||||||
{
|
{
|
||||||
type = 'text-box',
|
type = 'text-box',
|
||||||
text = 1
|
text = 1
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
quantity_input.style.maximal_height = 28
|
text_input.style.maximal_height = 28
|
||||||
local less = bottom_grid.add {type = 'button', caption = '-', name = 'less'}
|
|
||||||
local more = bottom_grid.add {type = 'button', caption = '+', name = 'more'}
|
|
||||||
-- Tom Fyuri: Ideally I'd make some fancy icon for this but alas 32 sized button will do for now
|
|
||||||
more.style.width = 32
|
|
||||||
more.style.height = 32
|
|
||||||
more.style.horizontal_align = 'center'
|
|
||||||
more.style.vertical_align = 'center'
|
|
||||||
less.style.width = 32
|
|
||||||
less.style.height = 32
|
|
||||||
less.style.horizontal_align = 'center'
|
|
||||||
less.style.vertical_align = 'center'
|
|
||||||
|
|
||||||
local slider =
|
local slider =
|
||||||
frame.add(
|
frame.add(
|
||||||
@ -725,7 +728,7 @@ local function gui_opened(event)
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
slider.style.width = 115
|
slider.style.width = 115
|
||||||
quantity_input.style.width = 60
|
text_input.style.width = 60
|
||||||
|
|
||||||
local coinsleft = frame.add({type = 'flow'})
|
local coinsleft = frame.add({type = 'flow'})
|
||||||
|
|
||||||
@ -737,7 +740,7 @@ local function gui_opened(event)
|
|||||||
)
|
)
|
||||||
|
|
||||||
this.players[player.index].data.search_text = search_text
|
this.players[player.index].data.search_text = search_text
|
||||||
this.players[player.index].data.quantity_input = quantity_input
|
this.players[player.index].data.text_input = text_input
|
||||||
this.players[player.index].data.slider = slider
|
this.players[player.index].data.slider = slider
|
||||||
this.players[player.index].data.frame = frame
|
this.players[player.index].data.frame = frame
|
||||||
this.players[player.index].data.item_frame = pane
|
this.players[player.index].data.item_frame = pane
|
||||||
@ -769,24 +772,6 @@ local function gui_click(event)
|
|||||||
end
|
end
|
||||||
local name = element.name
|
local name = element.name
|
||||||
|
|
||||||
if name == 'less' then
|
|
||||||
local slider_value = this.players[player.index].data.slider.slider_value
|
|
||||||
if slider_value > 1 then
|
|
||||||
data.slider.slider_value = slider_value - 1
|
|
||||||
data.quantity_input.text = data.slider.slider_value
|
|
||||||
redraw_market_items(data.item_frame, player, data.search_text)
|
|
||||||
end
|
|
||||||
return
|
|
||||||
elseif name == 'more' then
|
|
||||||
local slider_value = data.slider.slider_value
|
|
||||||
if slider_value <= 1e2 then
|
|
||||||
data.slider.slider_value = slider_value + 1
|
|
||||||
data.quantity_input.text = data.slider.slider_value
|
|
||||||
redraw_market_items(data.item_frame, player, data.search_text)
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if not player.opened then
|
if not player.opened then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -1032,7 +1017,6 @@ local function gui_click(event)
|
|||||||
player.play_sound({path = 'entity-close/stone-furnace', volume_modifier = 0.65})
|
player.play_sound({path = 'entity-close/stone-furnace', volume_modifier = 0.65})
|
||||||
local inserted_count = player.insert({name = name, count = item_count})
|
local inserted_count = player.insert({name = name, count = item_count})
|
||||||
if inserted_count < item_count then
|
if inserted_count < item_count then
|
||||||
--player.print("Original cost: "..cost..". New price: "..ceil((item.price * (inserted_count / item.stack)))..".") -- debug
|
|
||||||
player.play_sound({path = 'utility/cannot_build', volume_modifier = 0.65})
|
player.play_sound({path = 'utility/cannot_build', volume_modifier = 0.65})
|
||||||
player.print(
|
player.print(
|
||||||
"Your pockets are now filled to the brim. So you've only bought " ..
|
"Your pockets are now filled to the brim. So you've only bought " ..
|
||||||
@ -1044,10 +1028,7 @@ local function gui_click(event)
|
|||||||
{r = 0.98, g = 0.66, b = 0.22}
|
{r = 0.98, g = 0.66, b = 0.22}
|
||||||
)
|
)
|
||||||
player.insert({name = name, count = inserted_count})
|
player.insert({name = name, count = inserted_count})
|
||||||
-- example is say you have 12k coins, your storage is 80 slots and you have 4 items, you try to buy 80 iron-ore stacks, you get 76 stacks of ore instead and you only pay for them!
|
|
||||||
-- so the count = 12 * 50 * 76 instead of 12 * 50 * 80!
|
|
||||||
-- but wait, what if the player tries to buy 3 iron ore (3/50s of a stack)? that's 0.72 of a single coin!? no worries, player will pay 1 coin for that, the price is adjusted upwards.
|
|
||||||
-- shopkeeper will not divide his coins, so don't try to buy item amount less than 1 coin worth, your loss.
|
|
||||||
player.remove_item({name = item.value, count = ceil(item.price * (inserted_count / item.stack))})
|
player.remove_item({name = item.value, count = ceil(item.price * (inserted_count / item.stack))})
|
||||||
else
|
else
|
||||||
player.remove_item({name = item.value, count = cost})
|
player.remove_item({name = item.value, count = cost})
|
||||||
@ -2043,7 +2024,7 @@ function Public.get_items()
|
|||||||
main_market_items['car'] = {
|
main_market_items['car'] = {
|
||||||
stack = 1,
|
stack = 1,
|
||||||
value = 'coin',
|
value = 'coin',
|
||||||
price = 1000,
|
price = 3000,
|
||||||
tooltip = 'Portable Car Surface\nCan be killed easily.',
|
tooltip = 'Portable Car Surface\nCan be killed easily.',
|
||||||
upgrade = false,
|
upgrade = false,
|
||||||
static = true
|
static = true
|
||||||
@ -2051,7 +2032,7 @@ function Public.get_items()
|
|||||||
main_market_items['tank'] = {
|
main_market_items['tank'] = {
|
||||||
stack = 1,
|
stack = 1,
|
||||||
value = 'coin',
|
value = 'coin',
|
||||||
price = 5000,
|
price = 10000,
|
||||||
tooltip = 'Portable Tank Surface\nChonk tank, can resist heavy damage.',
|
tooltip = 'Portable Tank Surface\nChonk tank, can resist heavy damage.',
|
||||||
upgrade = false,
|
upgrade = false,
|
||||||
static = true
|
static = true
|
||||||
@ -2188,7 +2169,6 @@ local function tick()
|
|||||||
if ticker % 1200 == 0 then
|
if ticker % 1200 == 0 then
|
||||||
set_player_spawn()
|
set_player_spawn()
|
||||||
refill_fish()
|
refill_fish()
|
||||||
Public.get_items()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if ticker % 2500 == 0 then
|
if ticker % 2500 == 0 then
|
||||||
|
@ -15,6 +15,11 @@ local valid_rocks = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local valid_trees = {
|
local valid_trees = {
|
||||||
|
['dead-tree-desert'] = true,
|
||||||
|
['dead-dry-hairy-tree'] = true,
|
||||||
|
['dry-hairy-tree'] = true,
|
||||||
|
['tree-06'] = true,
|
||||||
|
['tree-06-brown'] = true,
|
||||||
['dry-tree'] = true,
|
['dry-tree'] = true,
|
||||||
['tree-01'] = true,
|
['tree-01'] = true,
|
||||||
['tree-02-red'] = true,
|
['tree-02-red'] = true,
|
||||||
@ -23,6 +28,15 @@ local valid_trees = {
|
|||||||
['tree-08-brown'] = true
|
['tree-08-brown'] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local reward_wood = {
|
||||||
|
['dead-tree-desert'] = true,
|
||||||
|
['dead-dry-hairy-tree'] = true,
|
||||||
|
['dry-hairy-tree'] = true,
|
||||||
|
['tree-06'] = true,
|
||||||
|
['tree-06-brown'] = true,
|
||||||
|
['dry-tree'] = true
|
||||||
|
}
|
||||||
|
|
||||||
local rock_yield = {
|
local rock_yield = {
|
||||||
['rock-big'] = 1,
|
['rock-big'] = 1,
|
||||||
['rock-huge'] = 2,
|
['rock-huge'] = 2,
|
||||||
@ -153,6 +167,8 @@ local function randomness(data)
|
|||||||
local harvest
|
local harvest
|
||||||
local harvest_amount
|
local harvest_amount
|
||||||
|
|
||||||
|
harvest_amount = get_amount(data)
|
||||||
|
|
||||||
local n = entity.name
|
local n = entity.name
|
||||||
if n == 'tree-08-brown' then
|
if n == 'tree-08-brown' then
|
||||||
harvest = 'stone'
|
harvest = 'stone'
|
||||||
@ -164,12 +180,12 @@ local function randomness(data)
|
|||||||
harvest = 'iron-ore'
|
harvest = 'iron-ore'
|
||||||
elseif n == 'tree-03' then
|
elseif n == 'tree-03' then
|
||||||
harvest = 'coal'
|
harvest = 'coal'
|
||||||
elseif n == 'dry-tree' then
|
elseif reward_wood[n] then
|
||||||
harvest = 'wood'
|
harvest = 'wood'
|
||||||
|
harvest_amount = random(1, 20)
|
||||||
else
|
else
|
||||||
harvest = harvest_raffle_ores[random(1, size_of_ore_raffle)]
|
harvest = harvest_raffle_ores[random(1, size_of_ore_raffle)]
|
||||||
end
|
end
|
||||||
harvest_amount = get_amount(data)
|
|
||||||
|
|
||||||
local position = {x = entity.position.x, y = entity.position.y}
|
local position = {x = entity.position.x, y = entity.position.y}
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ function Public.reset_table()
|
|||||||
this.mined_scrap = 0
|
this.mined_scrap = 0
|
||||||
this.biters_killed = 0
|
this.biters_killed = 0
|
||||||
this.locomotive_xp_aura = 40
|
this.locomotive_xp_aura = 40
|
||||||
|
this.trusted_only_car_tanks = true
|
||||||
this.xp_points = 0
|
this.xp_points = 0
|
||||||
this.xp_points_upgrade = 0
|
this.xp_points_upgrade = 0
|
||||||
--!grief prevention
|
--!grief prevention
|
||||||
|
@ -90,11 +90,11 @@ local spawner_raffle = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local trees = {
|
local trees = {
|
||||||
'tree-08-brown',
|
'dead-tree-desert',
|
||||||
'tree-04',
|
'dead-dry-hairy-tree',
|
||||||
'tree-03',
|
'dry-hairy-tree',
|
||||||
'tree-02-red',
|
'tree-06',
|
||||||
'tree-01',
|
'tree-06-brown',
|
||||||
'dry-tree'
|
'dry-tree'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2269,11 +2269,7 @@ local function process_level_0_position(x, y, data, void_or_lab)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if random(1, 100) > 25 then
|
if random(1, 100) > 25 then
|
||||||
if random(1, 10) == 1 then
|
entities[#entities + 1] = {name = rock_raffle[random(1, size_of_rock_raffle)], position = p}
|
||||||
entities[#entities + 1] = {name = tree_raffle[random(1, size_of_tree_raffle)], position = p}
|
|
||||||
else
|
|
||||||
entities[#entities + 1] = {name = rock_raffle[random(1, size_of_rock_raffle)], position = p}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ local xp_floating_text_color = RPG.xp_floating_text_color
|
|||||||
local teller_level_limit = RPG.teller_level_limit
|
local teller_level_limit = RPG.teller_level_limit
|
||||||
local experience_levels = RPG.experience_levels
|
local experience_levels = RPG.experience_levels
|
||||||
local teller_global_pool = RPG.teller_global_pool
|
local teller_global_pool = RPG.teller_global_pool
|
||||||
local rpg_frame_icons = RPG.rpg_frame_icons
|
|
||||||
local points_per_level = RPG.points_per_level
|
local points_per_level = RPG.points_per_level
|
||||||
|
|
||||||
--RPG Frames
|
--RPG Frames
|
||||||
@ -121,7 +120,6 @@ local function level_up(player)
|
|||||||
RPG_GUI.draw_level_text(player)
|
RPG_GUI.draw_level_text(player)
|
||||||
rpg_t[player.index].points_to_distribute = rpg_t[player.index].points_to_distribute + distribute_points_gain
|
rpg_t[player.index].points_to_distribute = rpg_t[player.index].points_to_distribute + distribute_points_gain
|
||||||
RPG_GUI.update_char_button(player)
|
RPG_GUI.update_char_button(player)
|
||||||
table.shuffle_table(rpg_frame_icons)
|
|
||||||
if rpg_t[player.index].allocate_index ~= 1 then
|
if rpg_t[player.index].allocate_index ~= 1 then
|
||||||
local node = rpg_t[player.index].allocate_index
|
local node = rpg_t[player.index].allocate_index
|
||||||
local index = names[node]:lower()
|
local index = names[node]:lower()
|
||||||
|
@ -13,7 +13,6 @@ local gain_info_tooltip = 'XP gain from mining, moving, crafting, repairing and
|
|||||||
local classes = RPG.classes
|
local classes = RPG.classes
|
||||||
|
|
||||||
--RPG Settings
|
--RPG Settings
|
||||||
local rpg_frame_icons = RPG.rpg_frame_icons
|
|
||||||
local experience_levels = RPG.experience_levels
|
local experience_levels = RPG.experience_levels
|
||||||
|
|
||||||
--RPG Frames
|
--RPG Frames
|
||||||
@ -446,14 +445,6 @@ local function draw_main_frame(player, location)
|
|||||||
add_gui_stat(right_bottom_table, mana_bonus_value, w2, mana_bonus_tooltip)
|
add_gui_stat(right_bottom_table, mana_bonus_value, w2, mana_bonus_tooltip)
|
||||||
end
|
end
|
||||||
|
|
||||||
add_separator(scroll_pane, 400)
|
|
||||||
local t = scroll_pane.add({type = 'table', column_count = 14})
|
|
||||||
for iv = 1, 14, 1 do
|
|
||||||
local rpg_biter_icons = t.add({type = 'sprite', sprite = rpg_frame_icons[iv]})
|
|
||||||
rpg_biter_icons.style.maximal_width = 24
|
|
||||||
rpg_biter_icons.style.maximal_height = 24
|
|
||||||
rpg_biter_icons.style.padding = 0
|
|
||||||
end
|
|
||||||
add_separator(scroll_pane, 400)
|
add_separator(scroll_pane, 400)
|
||||||
|
|
||||||
Public.update_char_button(player)
|
Public.update_char_button(player)
|
||||||
@ -556,6 +547,16 @@ function Public.toggle(player, recreate)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Public.remove_frame(player)
|
||||||
|
local screen = player.gui.screen
|
||||||
|
local main_frame = screen[main_frame_name]
|
||||||
|
|
||||||
|
if main_frame then
|
||||||
|
remove_main_frame(main_frame, screen)
|
||||||
|
Tabs.comfy_panel_restore_left_gui(player)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local toggle = Public.toggle
|
local toggle = Public.toggle
|
||||||
Public.remove_main_frame = remove_main_frame
|
Public.remove_main_frame = remove_main_frame
|
||||||
|
|
||||||
|
@ -658,6 +658,26 @@ local building_and_mining_blacklist = {
|
|||||||
['item-entity'] = true
|
['item-entity'] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local function on_player_died(event)
|
||||||
|
local player = game.players[event.player_index]
|
||||||
|
|
||||||
|
if not player or not player.valid then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
RPG_GUI.remove_frame(player)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_pre_player_left_game(event)
|
||||||
|
local player = game.players[event.player_index]
|
||||||
|
|
||||||
|
if not player or not player.valid then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
RPG_GUI.remove_frame(player)
|
||||||
|
end
|
||||||
|
|
||||||
local function on_pre_player_mined_item(event)
|
local function on_pre_player_mined_item(event)
|
||||||
local entity = event.entity
|
local entity = event.entity
|
||||||
if not entity.valid then
|
if not entity.valid then
|
||||||
@ -1093,6 +1113,8 @@ if _DEBUG then
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Event.add(defines.events.on_pre_player_left_game, on_pre_player_left_game)
|
||||||
|
Event.add(defines.events.on_player_died, on_player_died)
|
||||||
Event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
Event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
||||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||||
Event.add(defines.events.on_gui_click, on_gui_click)
|
Event.add(defines.events.on_gui_click, on_gui_click)
|
||||||
|
@ -27,25 +27,6 @@ Global.register(
|
|||||||
|
|
||||||
local Public = {}
|
local Public = {}
|
||||||
|
|
||||||
Public.rpg_frame_icons = {
|
|
||||||
'entity/small-worm-turret',
|
|
||||||
'entity/medium-worm-turret',
|
|
||||||
'entity/big-worm-turret',
|
|
||||||
'entity/behemoth-worm-turret',
|
|
||||||
'entity/small-biter',
|
|
||||||
'entity/small-biter',
|
|
||||||
'entity/small-spitter',
|
|
||||||
'entity/medium-biter',
|
|
||||||
'entity/medium-biter',
|
|
||||||
'entity/medium-spitter',
|
|
||||||
'entity/big-biter',
|
|
||||||
'entity/big-biter',
|
|
||||||
'entity/big-spitter',
|
|
||||||
'entity/behemoth-biter',
|
|
||||||
'entity/behemoth-biter',
|
|
||||||
'entity/behemoth-spitter'
|
|
||||||
}
|
|
||||||
|
|
||||||
Public.points_per_level = 5
|
Public.points_per_level = 5
|
||||||
|
|
||||||
Public.experience_levels = {0}
|
Public.experience_levels = {0}
|
||||||
|
@ -89,12 +89,18 @@ end
|
|||||||
|
|
||||||
--- Prints out game.tick to real hour/minute
|
--- Prints out game.tick to real hour/minute
|
||||||
---@param int
|
---@param int
|
||||||
function Public.format_time(ticks)
|
function Public.format_time(ticks, h, m)
|
||||||
local seconds = ticks / 60
|
local seconds = ticks / 60
|
||||||
local minutes = math.floor((seconds) / 60)
|
local minutes = math.floor((seconds) / 60)
|
||||||
local hours = math.floor((minutes) / 60)
|
local hours = math.floor((minutes) / 60)
|
||||||
local min = math.floor(minutes - 60 * hours)
|
local min = math.floor(minutes - 60 * hours)
|
||||||
return string.format('%dh:%02dm', hours, minutes, min)
|
if h and m then
|
||||||
|
return string.format('%dh:%02dm', hours, minutes, min)
|
||||||
|
elseif h then
|
||||||
|
return string.format('%dh', hours)
|
||||||
|
elseif m then
|
||||||
|
return string.format('%02dm', minutes, min)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Tries to get data from the webpanel and updates the local table with values.
|
--- Tries to get data from the webpanel and updates the local table with values.
|
||||||
@ -159,6 +165,12 @@ function Public.get_trusted_table()
|
|||||||
return trusted
|
return trusted
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Returns the table of settings
|
||||||
|
-- @return <table>
|
||||||
|
function Public.get_settings_table()
|
||||||
|
return settings
|
||||||
|
end
|
||||||
|
|
||||||
--- Clears a given player from the session tables.
|
--- Clears a given player from the session tables.
|
||||||
-- @param LuaPlayer
|
-- @param LuaPlayer
|
||||||
function Public.clear_player(player)
|
function Public.clear_player(player)
|
||||||
|
Loading…
Reference in New Issue
Block a user