1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-09-16 09:06:21 +02:00

tweaks and minor fixes

This commit is contained in:
Gerkiz
2020-07-30 17:47:50 +02:00
parent e449e827ee
commit 0e8945d7f7
15 changed files with 875 additions and 33 deletions

View File

@@ -8,10 +8,12 @@ local Global = require 'utils.global'
local Utils = require 'utils.core'
local Color = require 'utils.color_presets'
local Server = require 'utils.server'
local Jail = require 'utils.jail_data'
local Public = {}
local match = string.match
local capsule_bomb_threshold = 8
local damage_entity_threshold = 20
local format = string.format
@@ -24,11 +26,13 @@ local this = {
cancel_crafting_history = {},
whitelist_types = {},
players_warned = {},
player_count = {},
punish_cancel_craft = false,
log_tree_harvest = false,
do_not_check_trusted = true,
enable_autokick = true,
enable_autokick = false,
enable_autoban = false,
enable_jail = false,
enable_capsule_warning = false,
enable_capsule_cursor_warning = false
}
@@ -145,7 +149,9 @@ local function do_action(player, prefix, msg, ban_msg, kill)
end
elseif this.players_warned[player.index] == 1 then
this.players_warned[player.index] = 2
if this.enable_autokick then
if this.enable_jail then
Jail.try_ul_data(player, true, 'script')
elseif this.enable_autokick then
game.kick_player(player, msg)
end
else
@@ -352,6 +358,97 @@ local function on_player_used_capsule(event)
end
end
-- Damage things
local function on_entity_damaged(event)
local cause = event.cause
if not cause or not cause.player then
return
end
local entity = event.entity
if not entity or not entity.valid then
return
end
if not entity.force.index == 1 then
return
end
local trusted = session.get_trusted_table()
local player = game.players[event.cause.player.index]
if player.admin then
return
end
if trusted[player.name] and this.do_not_check_trusted then
return
end
local name = entity.name
local e_type = entity.type
local position = entity.position
local msg
if this.enable_capsule_warning then
if not this.player_count[player.index] then
this.player_count[player.index] = {}
this.player_count[player.index].targets = ''
this.player_count[player.index].count = 0
end
if name ~= 'entity-ghost' and name ~= 'character' and not blacklisted_types[e_type] then
name = name:gsub('-', ' ')
local index = this.player_count[player.index].targets:find(name)
if not index then
this.player_count[player.index].targets = this.player_count[player.index].targets .. name .. ', '
end
this.player_count[player.index].count = this.player_count[player.index].count + 1
end
if this.player_count[player.index].count <= damage_entity_threshold then
return
end
local target_names = this.player_count[player.index].targets
local prefix = '{Friendly Fire}'
msg =
format(player.name .. ' damaged: %s counted times: %s', target_names, this.player_count[player.index].count)
local ban_msg =
format(
'Damaged: %s counted times: %s. This action was performed automatically. Visit getcomfy.eu/discord for forgiveness',
target_names,
this.player_count[player.index].count
)
do_action(player, prefix, msg, ban_msg, true)
else
msg = player.name .. ' used ' .. name
end
this.player_count[player.index].count = 0
this.player_count[player.index].targets = ''
if not this.friendly_fire_history[player.index] then
this.friendly_fire_history[player.index] = {}
end
if #this.friendly_fire_history[player.index] > 100 then
this.friendly_fire_history[player.index] = {}
end
local t = math.abs(math.floor((game.tick) / 3600))
local str = '[' .. t .. '] '
str = str .. msg
str = str .. ' at X:'
str = str .. math.floor(position.x)
str = str .. ' Y:'
str = str .. math.floor(position.y)
str = str .. ' '
str = str .. 'surface:' .. player.surface.index
increment(this.friendly_fire_history, player.index, str)
end
--Friendly Fire History
local function on_entity_died(event)
local cause = event.cause
@@ -710,7 +807,7 @@ local function on_init()
end
end
--- This will reset the table of this
--- This will reset the table of antigrief
function Public.reset_tables()
this.landfill_history = {}
this.capsule_history = {}
@@ -771,6 +868,16 @@ function Public.enable_capsule_cursor_warning(value)
return this.enable_capsule_cursor_warning
end
--- If the script should jail a person instead of kicking them
---@param value <string>
function Public.enable_jail(value)
if value then
this.enable_jail = value
end
return this.enable_jail
end
--- This is used for the RPG module, when casting capsules.
---@param player <LuaPlayer>
---@param position <EventPosition>
@@ -807,6 +914,7 @@ end
Event.on_init(on_init)
Event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
Event.add(defines.events.on_entity_died, on_entity_died)
Event.add(defines.events.on_entity_damaged, on_entity_damaged)
Event.add(defines.events.on_built_entity, on_built_entity)
Event.add(defines.events.on_gui_opened, on_gui_opened)
Event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)

View File

@@ -280,26 +280,28 @@ local function draw_events(data)
return
end
for _, value in pairs(history_index[history][target_player]) do
if search_text then
local success = contains_text(value, nil, search_text)
if not success then
goto continue
for k, value in pairs(history_index[history][target_player]) do
if value:find(target_player_name) then
if search_text then
local success = contains_text(value, nil, search_text)
if not success then
goto continue
end
end
end
frame.datalog.add(
{
type = 'label',
caption = value,
tooltip = 'Click to open mini camera.'
}
)
::continue::
frame.datalog.add(
{
type = 'label',
caption = value,
tooltip = 'Click to open mini camera.'
}
)
::continue::
end
end
else
for key, value in pairs(history_index[history]) do
for t = 1, #value do
for t = #value, 1, -1 do
if search_text then
local success = contains_text(value, t, search_text)
if not success then
@@ -310,7 +312,7 @@ local function draw_events(data)
frame.datalog.add(
{
type = 'label',
caption = history_index[history][key][t],
caption = value[t],
tooltip = 'Click to open mini camera.'
}
)

View File

@@ -226,7 +226,7 @@ local function redraw_poll_viewer_content(data)
local poll_enabled = do_remaining_time(poll, remaining_time_label)
local question_flow = poll_viewer_content.add {type = 'table', column_count = 2}
if trusted[player.name] or player.admin then
if player.admin then
local edit_button =
question_flow.add {
type = 'sprite-button',

View File

@@ -235,7 +235,8 @@ function Public.get_random_item(rarity, sell, buy)
['locomotive'] = true,
['artillery-wagon'] = true,
['fluid-wagon'] = true,
['land-mine'] = true
['land-mine'] = true,
['car'] = true
}
for i = 1, math.random(5, 10), 1 do

View File

@@ -0,0 +1,549 @@
local Public = {}
local IC = require 'maps.mountain_fortress_v3.ic.table'
function Public.request_reconstruction(ic)
ic.rebuild_tick = game.tick + 30
end
local function validate_entity(entity)
if not entity then
return false
end
if not entity.valid then
return false
end
return true
end
local function validate_player(player)
if not player then
return false
end
if not player.valid then
return false
end
if not player.character then
return false
end
if not player.connected then
return false
end
if not game.players[player.name] then
return false
end
return true
end
local function delete_empty_surfaces(ic)
for k, surface in pairs(ic.surfaces) do
if not ic.cars[tonumber(surface.name)] then
game.delete_surface(surface)
ic.surfaces[k] = nil
end
end
end
local function kick_players_out_of_vehicles(car)
for _, player in pairs(game.connected_players) do
local character = player.character
if character and character.valid and character.driving then
if car.surface == player.surface then
character.driving = false
end
end
end
end
local function recreate_players()
for _, player in pairs(game.connected_players) do
if not player.character then
player.set_controller({type = defines.controllers.god})
player.create_character()
end
end
end
local function input_filtered(car_inv, chest, chest_inv, free_slots)
local request_stacks = {}
local prototypes = game.item_prototypes
for slot_index = 1, 30, 1 do
local stack = chest.get_request_slot(slot_index)
if stack then
request_stacks[stack.name] = 10 * prototypes[stack.name].stack_size
end
end
for i = 1, #car_inv - 1, 1 do
if free_slots <= 0 then
return
end
local stack = car_inv[i]
if stack.valid_for_read then
local request_stack = request_stacks[stack.name]
if request_stack and request_stack > chest_inv.get_item_count(stack.name) then
chest_inv.insert(stack)
stack.clear()
free_slots = free_slots - 1
end
end
end
end
local function input_cargo(car, chest)
if not chest.request_from_buffers then
return
end
local car_entity = car.entity
if not validate_entity(car_entity) then
car.transfer_entities = nil
return
end
local car_inventory = car_entity.get_inventory(defines.inventory.car_trunk)
if car_inventory.is_empty() then
return
end
local chest_inventory = chest.get_inventory(defines.inventory.chest)
local free_slots = 0
for i = 1, chest_inventory.get_bar() - 1, 1 do
if not chest_inventory[i].valid_for_read then
free_slots = free_slots + 1
end
end
if chest.get_request_slot(1) then
input_filtered(car_inventory, chest, chest_inventory, free_slots)
return
end
for i = 1, #car_inventory - 1, 1 do
if free_slots <= 0 then
return
end
if car_inventory[i].valid_for_read then
chest_inventory.insert(car_inventory[i])
car_inventory[i].clear()
free_slots = free_slots - 1
end
end
end
local function output_cargo(car, passive_chest)
if not validate_entity(car.entity) then
return
end
if not passive_chest.valid then
return
end
local chest1 = passive_chest.get_inventory(defines.inventory.chest)
local chest2 = car.entity.get_inventory(defines.inventory.car_trunk)
for k, v in pairs(chest1.get_contents()) do
local t = {name = k, count = v}
local c = chest2.insert(t)
if (c > 0) then
chest1.remove({name = k, count = c})
end
end
end
local transfer_functions = {
['logistic-chest-requester'] = input_cargo,
['logistic-chest-passive-provider'] = output_cargo
}
local function kill_doors(ic, car)
if not validate_entity(car.entity) then
return
end
for k, e in pairs(car.doors) do
ic.doors[e.unit_number] = nil
e.destroy()
car.doors[k] = nil
end
end
local function construct_doors(ic, car)
local area = car.area
local surface = car.surface
local main_tile_name = 'black-refined-concrete'
for _, x in pairs({area.left_top.x - 1, area.right_bottom.x + 0.5}) do
local p = {x, area.left_top.y + 10}
surface.set_tiles({{name = main_tile_name, position = p}}, true)
local e =
surface.create_entity(
{
name = 'player-port',
position = {x, area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5)},
force = 'neutral',
create_build_effect_smoke = false
}
)
e.destructible = false
e.minable = false
e.operable = false
ic.doors[e.unit_number] = car.entity.unit_number
car.doors[#car.doors + 1] = e
end
end
local function get_player_data(ic, player)
local player_data = ic.players[player.index]
if ic.players[player.index] then
return player_data
end
ic.players[player.index] = {
surface = 1,
fallback_surface = 1,
zoom = 0.30,
map_size = 360
}
return ic.players[player.index]
end
function Public.kill_car(ic, entity)
if not validate_entity(entity) then
return
end
local entity_type = IC.get('entity_type')
if not entity_type[entity.type] then
return
end
local car = ic.cars[entity.unit_number]
local surface = car.surface
kick_players_out_of_vehicles(car)
kill_doors(ic, car)
for _, e in pairs(surface.find_entities_filtered({area = car.area})) do
if e and e.valid and e.name == 'character' and e.player then
local p = car.entity.surface.find_non_colliding_position('character', car.entity.position, 128, 0.5)
if p then
e.player.teleport(p, car.entity.surface)
else
e.player.teleport(car.entity.position, car.entity.surface)
end
else
e.destroy()
recreate_players()
end
end
for _, tile in pairs(surface.find_tiles_filtered({area = car.area})) do
surface.set_tiles({{name = 'out-of-map', position = tile.position}}, true)
end
car.entity.force.chart(surface, car.area)
ic.cars[entity.unit_number] = nil
Public.request_reconstruction(ic)
end
function Public.create_room_surface(ic, unit_number)
if game.surfaces[tostring(unit_number)] then
return game.surfaces[tostring(unit_number)]
end
local map_gen_settings = {
['width'] = 2,
['height'] = 2,
['water'] = 0,
['starting_area'] = 1,
['cliff_settings'] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0},
['default_enable_all_autoplace_controls'] = true,
['autoplace_settings'] = {
['entity'] = {treat_missing_as_default = false},
['tile'] = {treat_missing_as_default = true},
['decorative'] = {treat_missing_as_default = false}
}
}
local surface = game.create_surface(tostring(unit_number), map_gen_settings)
surface.freeze_daytime = true
surface.daytime = 0.1
surface.request_to_generate_chunks({16, 16}, 1)
surface.force_generate_chunk_requests()
for _, tile in pairs(surface.find_tiles_filtered({area = {{-2, -2}, {2, 2}}})) do
surface.set_tiles({{name = 'out-of-map', position = tile.position}}, true)
end
ic.surfaces[#ic.surfaces + 1] = surface
return surface
end
function Public.create_car_room(ic, car)
local surface = car.surface
local area = car.area
local main_tile_name = 'black-refined-concrete'
local tiles = {}
for x = area.left_top.x, area.right_bottom.x - 1, 1 do
for y = area.left_top.y + 2, area.right_bottom.y - 3, 1 do
tiles[#tiles + 1] = {name = main_tile_name, position = {x, y}}
end
end
for x = -3, 2, 1 do
for y = 1, 3, 1 do
tiles[#tiles + 1] = {name = main_tile_name, position = {x, y}}
end
for y = area.right_bottom.y - 4, area.right_bottom.y - 2, 1 do
tiles[#tiles + 1] = {name = main_tile_name, position = {x, y}}
end
end
surface.set_tiles(tiles, true)
construct_doors(ic, car)
local car_areas = IC.get('car_areas')
local c = car_areas['car']
local position1 = {c.left_top.x + 4, c.left_top.y + 1}
local position2 = {c.right_bottom.x - 5, c.left_top.y + 1}
local e1 =
surface.create_entity(
{
name = 'logistic-chest-requester',
position = position1,
force = 'neutral',
create_build_effect_smoke = false
}
)
e1.destructible = false
e1.minable = false
local e2 =
surface.create_entity(
{
name = 'logistic-chest-passive-provider',
position = position2,
force = 'neutral',
create_build_effect_smoke = false
}
)
e2.destructible = false
e2.minable = false
car.transfer_entities = {e1, e2}
return
end
function Public.create_car(ic, created_entity)
if not validate_entity(created_entity) then
return
end
local entity_type = IC.get('entity_type')
local car_areas = IC.get('car_areas')
if not created_entity.unit_number then
return
end
if not entity_type[created_entity.type] then
return
end
local car_area = car_areas[created_entity.type]
ic.cars[created_entity.unit_number] = {
entity = created_entity,
area = {
left_top = {x = car_area.left_top.x, y = car_area.left_top.y},
right_bottom = {x = car_area.right_bottom.x, y = car_area.right_bottom.y}
},
doors = {}
}
local car = ic.cars[created_entity.unit_number]
car.surface = Public.create_room_surface(ic, created_entity.unit_number)
Public.create_car_room(ic, ic.cars[created_entity.unit_number])
Public.request_reconstruction(ic)
return car
end
function Public.teleport_players_around(ic)
for _, player in pairs(game.connected_players) do
if not validate_player(player) then
return
end
if player.surface.find_entity('player-port', player.position) then
local door = player.surface.find_entity('player-port', player.position)
if door and door.valid then
local doors = ic.doors
local cars = ic.cars
local car = false
if doors[door.unit_number] then
car = cars[doors[door.unit_number]]
end
if cars[door.unit_number] then
car = cars[door.unit_number]
end
if not car then
return
end
local player_data = get_player_data(ic, player)
if player_data.state then
player_data.state = player_data.state - 1
if player_data.state == 0 then
player_data.state = nil
end
return
end
if car.entity.surface.name ~= player.surface.name then
local surface = car.entity.surface
local x_vector = (door.position.x / math.abs(door.position.x)) * 2
local position = {car.entity.position.x + x_vector, car.entity.position.y}
local surface_position = surface.find_non_colliding_position('character', position, 128, 0.5)
if car.entity.type == 'car' then
player.teleport(surface_position, surface)
player_data.state = 2
player.driving = true
else
player.teleport(surface_position, surface)
end
player_data.surface = surface.index
elseif car.entity.type == 'car' and player.driving then
player.driving = false
else
local surface = car.surface
local area = car.area
local x_vector = door.position.x - player.position.x
local position
if x_vector > 0 then
position = {
area.left_top.x + 0.5,
area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5)
}
else
position = {
area.right_bottom.x - 0.5,
area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5)
}
end
local p = surface.find_non_colliding_position('character', position, 128, 0.5)
if p then
player.teleport(p, surface)
else
player.teleport(position, surface)
end
player_data.surface = surface.index
end
end
end
end
end
function Public.use_door_with_entity(ic, player, door)
local player_data = get_player_data(ic, player)
if player_data.state then
player_data.state = player_data.state - 1
if player_data.state == 0 then
player_data.state = nil
end
return
end
if not door then
return
end
if not door.valid then
return
end
local doors = ic.doors
local cars = ic.cars
local car = false
if doors[door.unit_number] then
car = cars[doors[door.unit_number]]
end
if cars[door.unit_number] then
car = cars[door.unit_number]
end
if not car then
return
end
player_data.fallback_surface = car.entity.surface.index
player_data.fallback_position = {car.entity.position.x, car.entity.position.y}
if car.entity.surface.name ~= player.surface.name then
local surface = car.entity.surface
local x_vector = (door.position.x / math.abs(door.position.x)) * 2
local position = {car.entity.position.x + x_vector, car.entity.position.y}
local surface_position = surface.find_non_colliding_position('character', position, 128, 0.5)
if not position then
return
end
if not surface_position then
surface.request_to_generate_chunks({-20, 22}, 1)
if player.character and player.character.valid and player.character.driving then
if car.surface == player.surface then
player.character.driving = false
end
end
return
end
if car.entity.type == 'car' then
player.teleport(surface_position, surface)
player_data.state = 2
player.driving = true
else
player.teleport(surface_position, surface)
end
player_data.surface = surface.index
else
local surface = car.surface
local area = car.area
local x_vector = door.position.x - player.position.x
local position
if x_vector > 0 then
position = {area.left_top.x + 0.5, area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5)}
else
position = {area.right_bottom.x - 0.5, area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5)}
end
local p = surface.find_non_colliding_position('character', position, 128, 0.5)
if p then
player.teleport(p, surface)
else
player.teleport(position, surface)
end
player_data.surface = surface.index
end
end
function Public.reconstruct_all_cars(ic)
for unit_number, car in pairs(ic.cars) do
if not validate_entity(car.entity) then
ic.cars[unit_number] = nil
Public.request_reconstruction(ic)
return
end
if not car.surface then
car.surface = Public.create_room_surface(ic, unit_number)
Public.create_car_room(ic, car)
end
end
delete_empty_surfaces(ic)
end
function Public.item_transfer(ic)
for _, car in pairs(ic.cars) do
if not validate_entity(car.entity) then
return
end
if car.transfer_entities then
for k, e in pairs(car.transfer_entities) do
transfer_functions[e.name](car, e)
end
end
end
end
return Public

View File

@@ -0,0 +1,97 @@
local Event = require 'utils.event'
local Functions = require 'maps.mountain_fortress_v3.ic.functions'
local IC = require 'maps.mountain_fortress_v3.ic.table'
local Public = {}
Public.reset = IC.reset
Public.get_table = IC.get
local function on_entity_died(event)
local entity = event.entity
if not entity and not entity.valid then
return
end
local entity_type = IC.get('entity_type')
if not entity_type[entity.type] then
return
end
local ic = IC.get()
Functions.kill_car(ic, entity)
end
local function on_player_mined_entity(event)
local entity = event.entity
if not entity and not entity.valid then
return
end
local ic = IC.get()
Functions.kill_car(ic, entity)
end
local function on_robot_mined_entity(event)
local entity = event.entity
if not entity and not entity.valid then
return
end
local ic = IC.get()
Functions.kill_car(ic, entity)
end
local function on_built_entity(event)
local ic = IC.get()
local created_entity = event.created_entity
Functions.create_car(ic, created_entity)
end
local function on_robot_built_entity(event)
local ic = IC.get()
local created_entity = event.created_entity
Functions.create_car(ic, created_entity)
end
local function on_player_driving_changed_state(event)
local ic = IC.get()
local player = game.players[event.player_index]
Functions.use_door_with_entity(ic, player, event.entity)
end
local function on_player_created(event)
local player = game.players[event.player_index]
player.insert({name = 'car', count = 5})
end
local function on_tick()
local ic = IC.get()
local tick = game.tick
if tick % 60 == 0 then
Functions.teleport_players_around(ic)
Functions.item_transfer(ic)
end
if not ic.rebuild_tick then
return
end
if ic.rebuild_tick ~= tick then
return
end
Functions.reconstruct_all_cars(ic)
ic.rebuild_tick = nil
end
local function on_init()
Public.reset()
end
Event.on_init(on_init)
Event.add(defines.events.on_tick, on_tick)
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)
Event.add(defines.events.on_robot_built_entity, on_robot_built_entity)
Event.add(defines.events.on_player_created, on_player_created)
Event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
Event.add(defines.events.on_robot_mined_entity, on_robot_mined_entity)
return Public

View File

@@ -0,0 +1,55 @@
local Global = require 'utils.global'
local this = {}
Global.register(
this,
function(tbl)
this = tbl
end
)
local Public = {}
function Public.reset()
if this.surfaces then
for k, surface in pairs(this.surfaces) do
if surface and surface.valid then
game.delete_surface(surface)
end
end
end
for k, _ in pairs(this) do
this[k] = nil
end
this.doors = {}
this.cars = {}
this.players = {}
this.surfaces = {}
this.entity_type = {
['car'] = true,
['tank'] = true
}
this.car_areas = {
['car'] = {left_top = {x = -20, y = 0}, right_bottom = {x = 20, y = 20}},
['tank'] = {left_top = {x = -20, y = 0}, right_bottom = {x = 20, y = 20}}
}
end
function Public.get(key)
if key then
return this[key]
else
return this
end
end
function Public.set_car_area(tbl)
if not tbl then
return
end
this.car_areas = tbl
end
return Public

View File

@@ -1814,6 +1814,14 @@ function Public.get_items()
upgrade = false,
static = true
}
main_market_items['car'] = {
stack = 1,
value = 'coin',
price = 1000,
tooltip = 'Speedy Car',
upgrade = false,
static = true
}
main_market_items['tank-cannon'] = {
stack = 1,
value = 'coin',

View File

@@ -1,6 +1,7 @@
require 'maps.mountain_fortress_v3.generate'
require 'maps.mountain_fortress_v3.commands'
require 'maps.mountain_fortress_v3.breached_wall'
-- require 'maps.mountain_fortress_v3.ic.main'
require 'modules.rpg.main'
require 'modules.autofill'
@@ -55,6 +56,7 @@ local disable_recipes = function()
local force = game.forces.player
force.recipes['cargo-wagon'].enabled = false
force.recipes['fluid-wagon'].enabled = false
force.recipes['car'].enabled = false
force.recipes['artillery-wagon'].enabled = false
force.recipes['locomotive'].enabled = false
force.recipes['pistol'].enabled = false
@@ -69,6 +71,7 @@ local collapse_kill = {
['landmine'] = true,
['locomotive'] = true,
['cargo-wagon'] = true,
['car'] = true,
['assembling-machine'] = true,
['furnace'] = true,
['steel-chest'] = true
@@ -264,6 +267,7 @@ function Public.reset_map()
AntiGrief.whitelist_types('tree', true)
AntiGrief.enable_capsule_warning(true)
AntiGrief.enable_capsule_cursor_warning(false)
AntiGrief.enable_jail(true)
PL.show_roles_in_list(true)

View File

@@ -62,10 +62,10 @@ end
local function mining_chances_ores()
local data = {
{name = 'iron-ore', chance = 545},
{name = 'copper-ore', chance = 545},
{name = 'copper-ore', chance = 540},
{name = 'coal', chance = 545},
{name = 'stone', chance = 545},
{name = 'uranium-ore', chance = 50}
{name = 'uranium-ore', chance = 45}
}
return data
end
@@ -73,7 +73,7 @@ end
local harvest_raffle_ores = {}
for _, t in pairs(mining_chances_ores()) do
for _ = 1, t.chance, 1 do
table.insert(harvest_raffle_ores, t.name)
harvest_raffle_ores[#harvest_raffle_ores + 1] = t.name
end
end

View File

@@ -1571,10 +1571,10 @@ local function process_level_1_position(x, y, data)
end
Public.levels = {
process_level_2_position,
process_level_1_position,
process_level_2_position,
process_level_3_position,
process_level_5_position,
process_level_4_position,
process_level_6_position,
process_level_2_position,
process_level_3_position,

View File

@@ -550,6 +550,7 @@ function Public.toggle(player, recreate)
end
local toggle = Public.toggle
Public.remove_main_frame = remove_main_frame
Gui.on_click(
draw_main_frame_name,

View File

@@ -1006,6 +1006,18 @@ local function on_player_used_capsule(event)
return
end
local function on_player_died(event)
local player = game.get_player(event.player_index)
if not player or not player.valid then
return
end
local left = player.gui.left
local screen = player.gui.screen
local main_frame = left[main_frame_name]
RPG_GUI.remove_main_frame(main_frame, screen)
end
local function tick()
local ticker = game.tick
local count = #game.connected_players
@@ -1063,6 +1075,7 @@ Event.add(defines.events.on_player_crafted_item, on_player_crafted_item)
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
Event.add(defines.events.on_player_repaired_entity, on_player_repaired_entity)
Event.add(defines.events.on_player_respawned, on_player_respawned)
Event.add(defines.events.on_player_died, on_player_died)
Event.add(defines.events.on_player_rotated_entity, on_player_rotated_entity)
Event.add(defines.events.on_pre_player_mined_item, on_pre_player_mined_item)
Event.add(defines.events.on_player_used_capsule, on_player_used_capsule)

View File

@@ -81,7 +81,7 @@ local validate_args = function(player, griefer)
return false
end
if player.name == griefer then
if player.name == griefer and not player.admin then
Utils.print_to(player, 'You can´t select yourself.')
return false
end
@@ -145,7 +145,6 @@ end
local jail = function(player, griefer)
player = player or 'script'
if jailed[griefer] then
Utils.print_to(player, griefer .. ' is already jailed!')
return false
end
@@ -188,7 +187,6 @@ end
local free = function(player, griefer)
player = player or 'script'
if not jailed[griefer] then
Utils.print_to(player, griefer .. ' is not jailed!')
return false
end
@@ -261,6 +259,10 @@ end
--- Tries to get data from the webpanel and updates the local table with values.
-- @param data_set player token
function Public.try_ul_data(key, value, player)
if type(key) == 'table' then
key = key.name
end
key = tostring(key)
local data = {
@@ -314,6 +316,7 @@ Event.add(
function(event)
local cmd = event.command
local five_days = 25920000 -- 5 days
local twenty_days = 103680000 -- 20 days
if not valid_commands[cmd] then
return
@@ -339,11 +342,11 @@ Event.add(
griefer = game.players[griefer].name
end
if not trusted or playtime <= five_days and not player.admin then
if not trusted and not player.admin or playtime <= five_days and not player.admin then
return Utils.print_to(player, 'You are not trusted enough to run this command.')
end
if trusted and playtime >= five_days and not player.admin then
if trusted and playtime >= five_days and playtime < twenty_days and not player.admin then
if cmd == 'jail' then
vote_to_jail(player, griefer)
return
@@ -353,7 +356,7 @@ Event.add(
end
end
if player.admin then
if player.admin or playtime >= twenty_days then
if cmd == 'jail' then
Public.try_ul_data(griefer, true, player.name)
return

View File

@@ -15,7 +15,8 @@ local trusted = {}
local set_data = Server.set_data
local try_get_data = Server.try_get_data
local concat = table.concat
local trusted_value = 2592000
-- local trusted_value = 2592000 -- 12h
local trusted_value = 5184000 -- 24h
local nth_tick = 18000 -- nearest prime to 5 minutes in ticks
Global.register(