mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2024-12-30 23:17:53 +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()
|
||||
if event.element.switch_state == 'left' then
|
||||
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
|
||||
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
|
||||
}
|
||||
@ -420,7 +431,7 @@ local build_config_gui = (function(player, frame)
|
||||
switch_state,
|
||||
'comfy_panel_disable_antigrief',
|
||||
'Antigrief',
|
||||
'Left = enables antigrief / Right = disables antigrief'
|
||||
'Left = Enables antigrief / Right = Disables antigrief'
|
||||
)
|
||||
scroll_pane.add({type = 'line'})
|
||||
if package.loaded['maps.mountain_fortress_v3.main'] then
|
||||
@ -444,7 +455,7 @@ local build_config_gui = (function(player, frame)
|
||||
switch_state,
|
||||
'comfy_panel_disable_fullness',
|
||||
'Inventory Fullness',
|
||||
'Left = enables inventory fullness.\nRight = disables inventory fullness.'
|
||||
'Left = Enables inventory fullness.\nRight = Disables inventory fullness.'
|
||||
)
|
||||
|
||||
scroll_pane.add({type = 'line'})
|
||||
@ -460,7 +471,7 @@ local build_config_gui = (function(player, frame)
|
||||
switch_state,
|
||||
'comfy_panel_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'})
|
||||
@ -474,7 +485,7 @@ local build_config_gui = (function(player, frame)
|
||||
switch_state,
|
||||
'comfy_panel_collapse_grace',
|
||||
'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'})
|
||||
@ -488,7 +499,7 @@ local build_config_gui = (function(player, frame)
|
||||
switch_state,
|
||||
'comfy_panel_spill_items_to_surface',
|
||||
'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'})
|
||||
|
||||
@ -501,7 +512,20 @@ local build_config_gui = (function(player, frame)
|
||||
switch_state,
|
||||
'comfy_panel_void_or_tile',
|
||||
'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'})
|
||||
end
|
||||
|
@ -142,7 +142,7 @@ local function on_gui_click(event)
|
||||
|
||||
if name == main_button_name 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
|
||||
minimap.visible = false
|
||||
return
|
||||
@ -240,7 +240,7 @@ local function on_player_changed_surface(event)
|
||||
end
|
||||
|
||||
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
|
||||
minimap.visible = false
|
||||
end
|
||||
|
@ -34,6 +34,8 @@ local function on_player_mined_entity(event)
|
||||
|
||||
local ic = IC.get()
|
||||
|
||||
Minimap.kill_minimap(game.players[event.player_index])
|
||||
|
||||
if entity.type == 'car' or entity.name == 'spidertron' then
|
||||
Functions.save_car(ic, event)
|
||||
end
|
||||
@ -105,6 +107,50 @@ local function on_tick()
|
||||
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 element = event.element
|
||||
if not element or not element.valid then
|
||||
@ -140,6 +186,8 @@ local changed_surface = Minimap.changed_surface
|
||||
|
||||
Event.on_init(on_init)
|
||||
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_entity_died, on_entity_died)
|
||||
Event.add(defines.events.on_built_entity, on_built_entity)
|
||||
|
@ -67,7 +67,7 @@ end
|
||||
|
||||
function Public.toggle_auto(player)
|
||||
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
|
||||
return
|
||||
end
|
||||
@ -80,18 +80,18 @@ function Public.toggle_auto(player)
|
||||
end
|
||||
|
||||
local function kill_minimap(player)
|
||||
local element = player.gui.screen.minimap_toggle_frame
|
||||
if not element or not element.valid then
|
||||
local frame = player.gui.left.minimap_toggle_frame
|
||||
if not frame or not frame.valid then
|
||||
return
|
||||
end
|
||||
if element.visible then
|
||||
element.visible = false
|
||||
if frame.visible then
|
||||
frame.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
local function kill_frame(player)
|
||||
if player.gui.screen.minimap_toggle_frame then
|
||||
local element = player.gui.screen.minimap_toggle_frame.minimap_frame
|
||||
if player.gui.left.minimap_toggle_frame then
|
||||
local element = player.gui.left.minimap_toggle_frame.minimap_frame
|
||||
if not element or not element.valid then
|
||||
return
|
||||
end
|
||||
@ -99,36 +99,37 @@ local function kill_frame(player)
|
||||
end
|
||||
end
|
||||
|
||||
local function draw_minimap(player)
|
||||
local function draw_minimap(player, surface, position)
|
||||
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
|
||||
return
|
||||
end
|
||||
local cars = ic.cars
|
||||
|
||||
local entity = Functions.get_entity_from_player_surface(cars, player)
|
||||
if not entity or not entity.valid then
|
||||
kill_minimap(player)
|
||||
kill_frame(player)
|
||||
return
|
||||
if not position then
|
||||
if not entity or not entity.valid then
|
||||
kill_minimap(player)
|
||||
kill_frame(player)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local position = entity.position
|
||||
position = position or entity.position
|
||||
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
|
||||
frame =
|
||||
player.gui.screen.add(
|
||||
{type = 'frame', direction = 'vertical', name = 'minimap_toggle_frame', caption = 'Outside View'}
|
||||
player.gui.left.add(
|
||||
{type = 'frame', direction = 'vertical', name = 'minimap_toggle_frame', caption = 'Minimap'}
|
||||
)
|
||||
frame.location = {x = 10, y = 45}
|
||||
end
|
||||
frame.visible = true
|
||||
local element = frame['minimap_frame']
|
||||
if not element then
|
||||
element =
|
||||
player.gui.screen.minimap_toggle_frame.add(
|
||||
player.gui.left.minimap_toggle_frame.add(
|
||||
{
|
||||
type = 'camera',
|
||||
name = 'minimap_frame',
|
||||
@ -146,21 +147,16 @@ local function draw_minimap(player)
|
||||
element.position = position
|
||||
end
|
||||
|
||||
function Public.minimap(player, autoaction)
|
||||
local player_data = get_player_data(player)
|
||||
local frame = player.gui.screen['minimap_toggle_frame']
|
||||
function Public.minimap(player, surface, position)
|
||||
local frame = player.gui.left['minimap_toggle_frame']
|
||||
local ic = ICT.get()
|
||||
if frame and frame.visible then
|
||||
kill_minimap(player)
|
||||
else
|
||||
if Functions.get_player_surface(ic, player) then
|
||||
if autoaction then
|
||||
if player_data.auto_map then
|
||||
draw_minimap(player)
|
||||
end
|
||||
else
|
||||
draw_minimap(player)
|
||||
end
|
||||
if Functions.get_player_surface(ic, player) and not surface and not position then
|
||||
draw_minimap(player)
|
||||
else
|
||||
draw_minimap(player, surface, position)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -168,7 +164,7 @@ end
|
||||
function Public.update_minimap()
|
||||
local ic = ICT.get()
|
||||
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)
|
||||
draw_minimap(player)
|
||||
end
|
||||
@ -252,4 +248,6 @@ function Public.changed_surface(event)
|
||||
end
|
||||
end
|
||||
|
||||
Public.kill_minimap = kill_minimap
|
||||
|
||||
return Public
|
||||
|
@ -356,7 +356,7 @@ local function get_player_data(icw, player)
|
||||
end
|
||||
|
||||
function Public.kill_minimap(player)
|
||||
local element = player.gui.left.icw_map
|
||||
local element = player.gui.left.icw_main_frame
|
||||
if element then
|
||||
element.destroy()
|
||||
end
|
||||
@ -1043,15 +1043,20 @@ function Public.item_transfer(icw)
|
||||
end
|
||||
|
||||
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
|
||||
local player_data = get_player_data(icw, player)
|
||||
element =
|
||||
player.gui.left.add(
|
||||
player.gui.left.icw_main_frame.add(
|
||||
{
|
||||
type = 'camera',
|
||||
name = 'icw_map',
|
||||
position = position,
|
||||
name = 'icw_sub_frame',
|
||||
surface_index = surface.index,
|
||||
zoom = player_data.zoom,
|
||||
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
|
||||
return
|
||||
end
|
||||
if element.name ~= 'icw_map' then
|
||||
if element.name ~= 'icw_sub_frame' then
|
||||
return
|
||||
end
|
||||
local player = game.players[event.player_index]
|
||||
|
@ -406,6 +406,7 @@ local function redraw_market_items(gui, player, search_text)
|
||||
return
|
||||
end
|
||||
local players = WPT.get('players')
|
||||
local trusted = Session.get_trusted_table()
|
||||
|
||||
if gui and gui.valid then
|
||||
gui.clear()
|
||||
@ -510,6 +511,19 @@ local function redraw_market_items(gui, player, search_text)
|
||||
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 =
|
||||
frame.add(
|
||||
{
|
||||
@ -569,7 +583,7 @@ local function slider_changed(event)
|
||||
return
|
||||
end
|
||||
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)
|
||||
end
|
||||
|
||||
@ -590,25 +604,25 @@ local function text_changed(event)
|
||||
return
|
||||
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
|
||||
end
|
||||
|
||||
if not data.quantity_input.text then
|
||||
if not data.text_input.text then
|
||||
return
|
||||
end
|
||||
|
||||
local value = tonumber(data.quantity_input.text)
|
||||
local value = tonumber(data.text_input.text)
|
||||
|
||||
if not value then
|
||||
return
|
||||
end
|
||||
|
||||
if (value > 1e2) then
|
||||
data.quantity_input.text = '100'
|
||||
data.text_input.text = '100'
|
||||
value = 1e2
|
||||
elseif (value <= 0) then
|
||||
data.quantity_input.text = '1'
|
||||
data.text_input.text = '1'
|
||||
value = 1
|
||||
end
|
||||
|
||||
@ -695,25 +709,14 @@ local function gui_opened(event)
|
||||
|
||||
bottom_grid.add({type = 'label', caption = 'Quantity: '}).style.font = 'default-bold'
|
||||
|
||||
local quantity_input =
|
||||
local text_input =
|
||||
bottom_grid.add(
|
||||
{
|
||||
type = 'text-box',
|
||||
text = 1
|
||||
}
|
||||
)
|
||||
quantity_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'
|
||||
text_input.style.maximal_height = 28
|
||||
|
||||
local slider =
|
||||
frame.add(
|
||||
@ -725,7 +728,7 @@ local function gui_opened(event)
|
||||
}
|
||||
)
|
||||
slider.style.width = 115
|
||||
quantity_input.style.width = 60
|
||||
text_input.style.width = 60
|
||||
|
||||
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.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.frame = frame
|
||||
this.players[player.index].data.item_frame = pane
|
||||
@ -769,24 +772,6 @@ local function gui_click(event)
|
||||
end
|
||||
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
|
||||
return
|
||||
end
|
||||
@ -1032,7 +1017,6 @@ local function gui_click(event)
|
||||
player.play_sound({path = 'entity-close/stone-furnace', volume_modifier = 0.65})
|
||||
local inserted_count = player.insert({name = name, count = item_count})
|
||||
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.print(
|
||||
"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}
|
||||
)
|
||||
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))})
|
||||
else
|
||||
player.remove_item({name = item.value, count = cost})
|
||||
@ -2043,7 +2024,7 @@ function Public.get_items()
|
||||
main_market_items['car'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = 1000,
|
||||
price = 3000,
|
||||
tooltip = 'Portable Car Surface\nCan be killed easily.',
|
||||
upgrade = false,
|
||||
static = true
|
||||
@ -2051,7 +2032,7 @@ function Public.get_items()
|
||||
main_market_items['tank'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = 5000,
|
||||
price = 10000,
|
||||
tooltip = 'Portable Tank Surface\nChonk tank, can resist heavy damage.',
|
||||
upgrade = false,
|
||||
static = true
|
||||
@ -2188,7 +2169,6 @@ local function tick()
|
||||
if ticker % 1200 == 0 then
|
||||
set_player_spawn()
|
||||
refill_fish()
|
||||
Public.get_items()
|
||||
end
|
||||
|
||||
if ticker % 2500 == 0 then
|
||||
|
@ -15,6 +15,11 @@ local valid_rocks = {
|
||||
}
|
||||
|
||||
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,
|
||||
['tree-01'] = true,
|
||||
['tree-02-red'] = true,
|
||||
@ -23,6 +28,15 @@ local valid_trees = {
|
||||
['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 = {
|
||||
['rock-big'] = 1,
|
||||
['rock-huge'] = 2,
|
||||
@ -153,6 +167,8 @@ local function randomness(data)
|
||||
local harvest
|
||||
local harvest_amount
|
||||
|
||||
harvest_amount = get_amount(data)
|
||||
|
||||
local n = entity.name
|
||||
if n == 'tree-08-brown' then
|
||||
harvest = 'stone'
|
||||
@ -164,12 +180,12 @@ local function randomness(data)
|
||||
harvest = 'iron-ore'
|
||||
elseif n == 'tree-03' then
|
||||
harvest = 'coal'
|
||||
elseif n == 'dry-tree' then
|
||||
elseif reward_wood[n] then
|
||||
harvest = 'wood'
|
||||
harvest_amount = random(1, 20)
|
||||
else
|
||||
harvest = harvest_raffle_ores[random(1, size_of_ore_raffle)]
|
||||
end
|
||||
harvest_amount = get_amount(data)
|
||||
|
||||
local position = {x = entity.position.x, y = entity.position.y}
|
||||
|
||||
|
@ -43,6 +43,7 @@ function Public.reset_table()
|
||||
this.mined_scrap = 0
|
||||
this.biters_killed = 0
|
||||
this.locomotive_xp_aura = 40
|
||||
this.trusted_only_car_tanks = true
|
||||
this.xp_points = 0
|
||||
this.xp_points_upgrade = 0
|
||||
--!grief prevention
|
||||
|
@ -90,11 +90,11 @@ local spawner_raffle = {
|
||||
}
|
||||
|
||||
local trees = {
|
||||
'tree-08-brown',
|
||||
'tree-04',
|
||||
'tree-03',
|
||||
'tree-02-red',
|
||||
'tree-01',
|
||||
'dead-tree-desert',
|
||||
'dead-dry-hairy-tree',
|
||||
'dry-hairy-tree',
|
||||
'tree-06',
|
||||
'tree-06-brown',
|
||||
'dry-tree'
|
||||
}
|
||||
|
||||
@ -2269,11 +2269,7 @@ local function process_level_0_position(x, y, data, void_or_lab)
|
||||
end
|
||||
end
|
||||
if random(1, 100) > 25 then
|
||||
if random(1, 10) == 1 then
|
||||
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
|
||||
entities[#entities + 1] = {name = rock_raffle[random(1, size_of_rock_raffle)], position = p}
|
||||
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 experience_levels = RPG.experience_levels
|
||||
local teller_global_pool = RPG.teller_global_pool
|
||||
local rpg_frame_icons = RPG.rpg_frame_icons
|
||||
local points_per_level = RPG.points_per_level
|
||||
|
||||
--RPG Frames
|
||||
@ -121,7 +120,6 @@ local function level_up(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_GUI.update_char_button(player)
|
||||
table.shuffle_table(rpg_frame_icons)
|
||||
if rpg_t[player.index].allocate_index ~= 1 then
|
||||
local node = rpg_t[player.index].allocate_index
|
||||
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
|
||||
|
||||
--RPG Settings
|
||||
local rpg_frame_icons = RPG.rpg_frame_icons
|
||||
local experience_levels = RPG.experience_levels
|
||||
|
||||
--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)
|
||||
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)
|
||||
|
||||
Public.update_char_button(player)
|
||||
@ -556,6 +547,16 @@ function Public.toggle(player, recreate)
|
||||
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
|
||||
Public.remove_main_frame = remove_main_frame
|
||||
|
||||
|
@ -658,6 +658,26 @@ local building_and_mining_blacklist = {
|
||||
['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 entity = event.entity
|
||||
if not entity.valid then
|
||||
@ -1093,6 +1113,8 @@ if _DEBUG then
|
||||
)
|
||||
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_died, on_entity_died)
|
||||
Event.add(defines.events.on_gui_click, on_gui_click)
|
||||
|
@ -27,25 +27,6 @@ Global.register(
|
||||
|
||||
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.experience_levels = {0}
|
||||
|
@ -89,12 +89,18 @@ end
|
||||
|
||||
--- Prints out game.tick to real hour/minute
|
||||
---@param int
|
||||
function Public.format_time(ticks)
|
||||
function Public.format_time(ticks, h, m)
|
||||
local seconds = ticks / 60
|
||||
local minutes = math.floor((seconds) / 60)
|
||||
local hours = math.floor((minutes) / 60)
|
||||
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
|
||||
|
||||
--- 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
|
||||
end
|
||||
|
||||
--- Returns the table of settings
|
||||
-- @return <table>
|
||||
function Public.get_settings_table()
|
||||
return settings
|
||||
end
|
||||
|
||||
--- Clears a given player from the session tables.
|
||||
-- @param LuaPlayer
|
||||
function Public.clear_player(player)
|
||||
|
Loading…
Reference in New Issue
Block a user