1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-03-03 14:53:01 +02:00

Minor additions

Research message on research finished
Chart tags sync with all forces
- Needs refactoring
Quadrants labeled with a number
Evolution factors halved (except: Pollution from 150 -> 50)

Fixed linting

Added position to item_to_chest to override player position
This commit is contained in:
SimonFlapse 2019-03-03 11:20:56 +01:00
parent 8d7ca6e558
commit 949e902101
4 changed files with 87 additions and 27 deletions

View File

@ -33,7 +33,7 @@ local function console_chat(event)
end
end
--[[local function create_tag(creating_force, data, remove)
local function create_tag(creating_force, data, remove)
local surface = RS.get_surface()
local tags
for _, force in pairs(game.forces) do
@ -48,17 +48,22 @@ end
if remove then
old_tag.destroy()
else
old_tag.icon = data.icon
old_tag.last_user = data.last_user
old_tag.text = data.text
if data.icon ~= nil then
old_tag.icon = data.icon
end
if data.last_user ~= nil then
old_tag.last_user = data.last_user
end
if data.text ~= nil then
old_tag.text = data.text
end
end
else
elseif not remove then
force.add_chart_tag(surface, data)
end
end
end
end
return tags
end
local function chart_tag_event(event, remove)
@ -72,7 +77,7 @@ local function chart_tag_event(event, remove)
if string.find(force.name, 'quadrant') == nil then
return
end
if chart_tags.position ~= nil and not modify then
if chart_tags.position ~= nil and not modify and not remove then
if chart_tags.position.x == tag.position.x and chart_tags.position.y == tag.position.y then
return
end
@ -80,6 +85,9 @@ local function chart_tag_event(event, remove)
return
end
chart_tags = {icon = tag.icon, position = tag.position, text = tag.text, last_user = tag.last_user}
if remove then
chart_tags['remove'] = remove
end
create_tag(force, chart_tags, remove)
end
@ -88,12 +96,27 @@ local function chart_tag_modified(event)
end
local function chart_tag_remove(event)
chart_tags = {}
chart_tag_event(event, true)
end
Event.add(defines.events.on_chart_tag_added, chart_tag_event)
Event.add(defines.events.on_chart_tag_modified, chart_tag_modified)
Event.add(defines.events.on_chart_tag_removed, chart_tag_remove)]]
Event.add(defines.events.on_chart_tag_removed, chart_tag_remove)
local function research_finished(event)
if event.by_script then
return
end
local technology = event.research
local player_force = technology.force
for _, force in pairs(game.forces) do
if (string.find(force.name, 'quadrant')) ~= nil then
force.print(
'[img=item/automation-science-pack] New research complete: [technology=' .. technology.name .. ']'
)
end
end
end
Event.add(defines.events.on_console_chat, console_chat)
Event.add(defines.events.on_research_finished, research_finished)

View File

@ -4,20 +4,21 @@ local Event = require 'utils.event'
local Public = {}
local function create_chest(player)
local function create_chest(player, position)
local surface = RS.get_surface()
local pos = surface.find_non_colliding_position('steel-chest', player.position, 0, 1)
position = position ~= nil and position or player.position
local pos = surface.find_non_colliding_position('steel-chest', position, 0, 1)
local chest = surface.create_entity { name = 'steel-chest', position = pos, force = player.force }
chest.minable = false
return chest
end
function Public.transfer_inventory(player_index, inventories)
function Public.transfer_inventory(player_index, inventories, position)
if inventories == nil or player_index == nil then
return 'You need to specify a player index and a table of define.inventory'
end
local player = Game.get_player_by_index(player_index)
local chest = create_chest(player)
local chest = create_chest(player, position)
for _, inventory in pairs(inventories) do
inventory = player.get_inventory(inventory)
for name, count in pairs(inventory.get_contents()) do

View File

@ -61,7 +61,7 @@ Version: v1.0
]]
)
redmew_config.paint.enabled = false
redmew_config.paint.enabled = true
redmew_config.player_create.starting_items = {
{name = 'iron-plate', count = 7},
@ -82,8 +82,17 @@ redmew_config.hail_hydra.hydras = {
-- worms
['small-worm-turret'] = {['small-biter'] = {min = 1.5, max = 2.5}},
['medium-worm-turret'] = {['small-biter'] = {min = 2.5, max = 3.5}, ['medium-biter'] = {min = 1.0, max = 2}},
['big-worm-turret'] = {['small-biter'] = {min = 2.5, max = 4.5}, ['medium-biter'] = {min = 1.5, max = 2.2}, ['big-biter'] = {min = 0.7, max = 1.5}},
['behemoth-worm-turret'] = {['small-biter'] = {min = 4.5, max = -1}, ['medium-biter'] = {min = 2.5, max = 3.8}, ['big-biter'] = {min = 1.2, max = 2.4}, ['behemoth-biter'] = {min = 0.8, max = -1}}
['big-worm-turret'] = {
['small-biter'] = {min = 2.5, max = 4.5},
['medium-biter'] = {min = 1.5, max = 2.2},
['big-biter'] = {min = 0.7, max = 1.5}
},
['behemoth-worm-turret'] = {
['small-biter'] = {min = 4.5, max = -1},
['medium-biter'] = {min = 2.5, max = 3.8},
['big-biter'] = {min = 1.2, max = 2.4},
['behemoth-biter'] = {min = 0.8, max = -1}
}
}
local function spawn_market(surface, force, position)
@ -103,8 +112,6 @@ local function spawn_market(surface, force, position)
end
end
force.add_chart_tag(surface, {icon = {type = 'item', name = 'coin'}, position = pos, text = 'Market'})
pos = surface.find_non_colliding_position('compilatron', position, 10, 1)
local compi = surface.create_entity {name = 'compilatron', position = pos, force = game.forces.neutral}
@ -153,14 +160,14 @@ local function on_init()
reset_recipes()
for _, force in pairs(game.forces) do
if (string.find(force.name, 'quadrant')) ~= nil then
if (string.find(force.name, 'quadrant')) ~= nil or force.name == 'player' then
force.share_chart = true
if force.name ~= 'quadrant1' then
force.disable_research()
end
for _, friend_force in pairs(game.forces) do
if (string.find(friend_force.name, 'quadrant')) ~= nil then
if (string.find(friend_force.name, 'quadrant')) ~= nil or friend_force.name == 'player' then
if friend_force ~= force then
force.set_friend(friend_force, true)
end
@ -168,6 +175,10 @@ local function on_init()
end
end
end
game.map_settings.enemy_evolution.time_factor = 0.0002
game.map_settings.enemy_evolution.destroy_factor = 0.0010
game.map_settings.enemy_evolution.pollution_factor = 0.0005
end
local function on_research_finished(event)
@ -186,11 +197,32 @@ end
local callback_token
local callback
local tile_numbers = {
[-26] = {22, -22, -21, -20, -19},
[-27] = {22, -22},
[-28] = {22, -22},
[-29] = {22, -22, -21, -20, -19},
[-30] = {22, -19},
[-31] = {22, -19},
[-32] = {22, -22, -21, -20, -19},
[25] = {19, 22, -22, -21, -20, -19},
[26] = {19, 22, -19},
[27] = {19, 22, -19},
[28] = {19, 20, 21, 22, -22, -21, -20, -19},
[29] = {22, -19},
[30] = {22, -19},
[31] = {22, -22, -21, -20, -19},
}
local function spawn_compilatron()
local pos = game.surfaces[2].find_non_colliding_position('compilatron', {-0.5, -0.5}, 1.5, 0.5)
local compi = game.surfaces[2].create_entity {name = 'compilatron', position = pos, force = game.forces.neutral}
CompiHandler.add_compilatron(compi, 'spawn')
for y, x_table in pairs(tile_numbers) do
for _, x in pairs(x_table) do
game.surfaces[2].set_tiles({{name = 'lab-white', position = {x = x, y = y}}}, true)
end
end
end
local function chunk_generated()

View File

@ -104,7 +104,7 @@ local function teleport(event, quadrant)
end
end
local function redraw_quadrant_button(data, player)
local function redraw_quadrant_button(data)
local left_flow = data.left_flow_btn1
local right_flow = data.right_flow_btn1
Gui.clear(left_flow)
@ -114,14 +114,16 @@ local function redraw_quadrant_button(data, player)
{
type = 'button',
name = 'Quadrants.Button.2',
caption = 'Intermediate and Mining (' .. #game.forces['quadrant2'].players .. ')'
caption = 'Intermediate and Mining (' .. #game.forces['quadrant2'].players .. ')',
tooltip = 'This is quadrant number 2'
}
)
right_flow.add(
{
type = 'button',
name = 'Quadrants.Button.1',
caption = 'Science and Military (' .. #game.forces['quadrant1'].players .. ')'
caption = 'Science and Military (' .. #game.forces['quadrant1'].players .. ')',
tooltip = 'This is quadrant number 1'
}
)
@ -134,14 +136,16 @@ local function redraw_quadrant_button(data, player)
{
type = 'button',
name = 'Quadrants.Button.3',
caption = 'Oil and High Tech (' .. #game.forces['quadrant3'].players .. ')'
caption = 'Oil and High Tech (' .. #game.forces['quadrant3'].players .. ')',
tooltip = 'This is quadrant number 3'
}
)
right_flow.add(
{
type = 'button',
name = 'Quadrants.Button.4',
caption = 'Logistics and Transport (' .. #game.forces['quadrant4'].players .. ')'
caption = 'Logistics and Transport (' .. #game.forces['quadrant4'].players .. ')',
tooltip = 'This is quadrant number 4aw'
}
)
end
@ -233,7 +237,7 @@ local function toggle(event)
chest_button_left_flow = chest_button_left_flow
}
redraw_quadrant_button(data, player)
redraw_quadrant_button(data)
redraw_chest_button(data, player)
Gui.set_data(frame, data)
@ -307,7 +311,7 @@ end
Event.add(
player_switched_force,
function(event)
function()
update_gui(nil, true)
end
)