mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-04 00:15:45 +02:00
updates
This commit is contained in:
parent
5232b7e779
commit
d696625f78
@ -42,11 +42,11 @@ require "on_tick_schedule"
|
||||
--require "maps.biter_battles"
|
||||
--require "maps.cave_miner"
|
||||
--require "maps.labyrinth"
|
||||
require "maps.junkyard"
|
||||
--require "maps.junkyard"
|
||||
--require "maps.spooky_forest"
|
||||
--require "maps.nightfall"
|
||||
--require "maps.atoll"
|
||||
--require "maps.choppy"
|
||||
require "maps.choppy"
|
||||
--require "maps.tank_battles"
|
||||
--require "maps.spiral_troopers"
|
||||
--require "maps.fish_defender"
|
||||
|
@ -3,6 +3,7 @@
|
||||
require "maps.modules.dynamic_landfill"
|
||||
require "maps.modules.satellite_score"
|
||||
require "maps.modules.spawners_contain_biters"
|
||||
require "maps.choppy_map_intro"
|
||||
|
||||
local unearthing_worm = require "functions.unearthing_worm"
|
||||
local unearthing_biters = require "functions.unearthing_biters"
|
||||
@ -191,15 +192,15 @@ local tree_yield = {
|
||||
local function get_amount(entity)
|
||||
local distance_to_center = math.sqrt(entity.position.x^2 + entity.position.y^2)
|
||||
local amount = 35 + (distance_to_center * 0.33)
|
||||
if amount > 250 then amount = 250 end
|
||||
if amount > 500 then amount = 500 end
|
||||
amount = math.random(math.ceil(amount * 0.5), math.ceil(amount * 1.5))
|
||||
return amount
|
||||
end
|
||||
|
||||
local function trap(entity)
|
||||
if math_random(1,1024) == 1 then tick_tack_trap(entity.surface, entity.position) return end
|
||||
if math_random(1,128) == 1 then unearthing_worm(entity.surface, entity.position) return end
|
||||
if math_random(1,128) == 1 then unearthing_biters(entity.surface, entity.position, math_random(4,12)) return end
|
||||
if math_random(1,256) == 1 then unearthing_worm(entity.surface, entity.position) end
|
||||
if math_random(1,128) == 1 then unearthing_biters(entity.surface, entity.position, math_random(4,8)) end
|
||||
end
|
||||
|
||||
local function on_player_mined_entity(event)
|
||||
@ -210,18 +211,26 @@ local function on_player_mined_entity(event)
|
||||
trap(entity)
|
||||
end
|
||||
|
||||
if tree_yield[entity.name] then
|
||||
if not event.player_index then return end
|
||||
if tree_yield[entity.name] then
|
||||
if event.buffer then event.buffer.clear() end
|
||||
|
||||
|
||||
local amount = get_amount(entity)
|
||||
local wood_amount = math_random(2,5)
|
||||
local second_item_amount = math_random(2,5)
|
||||
local second_item = "wood"
|
||||
|
||||
if entity.type == "simple-entity" then
|
||||
amount = amount * 2
|
||||
second_item_amount = math_random(8,16)
|
||||
second_item = "stone"
|
||||
end
|
||||
|
||||
entity.surface.create_entity({
|
||||
name = "flying-text",
|
||||
position = entity.position,
|
||||
text = "+" .. amount .. " [item=" .. tree_yield[entity.name] .. "] +" .. wood_amount .. " [item=wood]",
|
||||
text = "+" .. amount .. " [item=" .. tree_yield[entity.name] .. "] +" .. second_item_amount .. " [item=" .. second_item .. "]",
|
||||
color = {r=0.8,g=0.8,b=0.8}})
|
||||
|
||||
|
||||
if not event.player_index then return end
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
local inserted_count = player.insert({name = tree_yield[entity.name], count = amount})
|
||||
@ -229,11 +238,11 @@ local function on_player_mined_entity(event)
|
||||
if amount > 0 then
|
||||
entity.surface.spill_item_stack(entity.position,{name = tree_yield[entity.name], count = amount}, true)
|
||||
end
|
||||
|
||||
local inserted_count = player.insert({name = "wood", count = wood_amount})
|
||||
wood_amount = wood_amount - inserted_count
|
||||
if wood_amount > 0 then
|
||||
entity.surface.spill_item_stack(entity.position,{name = "wood", count = wood_amount}, true)
|
||||
|
||||
local inserted_count = player.insert({name = second_item, count = second_item_amount})
|
||||
second_item_amount = second_item_amount - inserted_count
|
||||
if second_item_amount > 0 then
|
||||
entity.surface.spill_item_stack(entity.position,{name = second_item, count = second_item_amount}, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
78
maps/choppy_map_intro.lua
Normal file
78
maps/choppy_map_intro.lua
Normal file
@ -0,0 +1,78 @@
|
||||
local event = require 'utils.event'
|
||||
|
||||
local info = [[
|
||||
You are a lumberjack with a passion to chop.
|
||||
|
||||
Different kinds of trees, yield different kinds of ore and wood.
|
||||
Yes, they seem to draw minerals out of the ground and manifesting it as "fruit".
|
||||
Their yield increases with distance and Mining Productivity Research will increase chopping speed and backpack size.
|
||||
|
||||
Beware, sometimes there are some bugs hiding underneath the trees.
|
||||
Even dangerous traps have been encountered before.
|
||||
|
||||
Also, these mysterious ore trees don't burn very well, so do not worry if some of them catch on fire.
|
||||
|
||||
Choppy Choppy Wood
|
||||
]]
|
||||
|
||||
local function create_map_intro_button(player)
|
||||
if player.gui.top["map_intro_button"] then return end
|
||||
local b = player.gui.top.add({type = "sprite-button", caption = "?", name = "map_intro_button", tooltip = "Map Info"})
|
||||
b.style.font_color = {r = 0.1, g = 0.8, b = 0.1}
|
||||
b.style.font = "heading-1"
|
||||
b.style.minimal_height = 38
|
||||
b.style.minimal_width = 38
|
||||
b.style.top_padding = 2
|
||||
b.style.left_padding = 4
|
||||
b.style.right_padding = 4
|
||||
b.style.bottom_padding = 2
|
||||
end
|
||||
|
||||
local function create_map_intro(player)
|
||||
if player.gui.left["map_intro_frame"] then player.gui.left["map_intro_frame"].destroy() end
|
||||
local frame = player.gui.left.add {type = "frame", name = "map_intro_frame", direction = "vertical"}
|
||||
|
||||
local t = frame.add {type = "table", column_count = 1}
|
||||
|
||||
local b = frame.add {type = "button", caption = "Close", name = "close_map_intro_frame", align = "right"}
|
||||
b.style.font = "default"
|
||||
b.style.minimal_height = 30
|
||||
b.style.minimal_width = 30
|
||||
b.style.top_padding = 2
|
||||
b.style.left_padding = 4
|
||||
b.style.right_padding = 4
|
||||
b.style.bottom_padding = 2
|
||||
|
||||
local frame = t.add {type = "frame"}
|
||||
local l = frame.add {type = "label", caption = info}
|
||||
l.style.single_line = false
|
||||
l.style.font = "heading-3"
|
||||
l.style.font_color = {r=0.95, g=0.95, b=0.95}
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
create_map_intro_button(player)
|
||||
if player.online_time == 0 then
|
||||
create_map_intro(player)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_gui_click(event)
|
||||
if not event then return end
|
||||
if not event.element then return end
|
||||
if not event.element.valid then return end
|
||||
local player = game.players[event.element.player_index]
|
||||
if event.element.name == "close_map_intro_frame" then player.gui.left["map_intro_frame"].destroy() return end
|
||||
if event.element.name == "map_intro_button" then
|
||||
if player.gui.left["map_intro_frame"] then
|
||||
player.gui.left["map_intro_frame"].destroy()
|
||||
else
|
||||
create_map_intro(player)
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
event.add(defines.events.on_gui_click, on_gui_click)
|
@ -406,7 +406,7 @@ local function on_chunk_charted(event)
|
||||
local distance_to_center = math.sqrt(pos.x^2 + pos.y^2)
|
||||
local size = 7 + math.floor(distance_to_center * 0.0075)
|
||||
if size > 20 then size = 20 end
|
||||
local amount = 100 + distance_to_center
|
||||
local amount = 200 + distance_to_center
|
||||
map_functions.draw_rainbow_patch_v2(pos, surface, size, amount)
|
||||
end
|
||||
|
||||
|
@ -27,7 +27,7 @@ local info = [[
|
||||
]]
|
||||
|
||||
local function create_map_intro_button(player)
|
||||
if player.gui.left["map_intro_button"] then return end
|
||||
if player.gui.top["map_intro_button"] then return end
|
||||
local b = player.gui.top.add({type = "sprite-button", caption = "?", name = "map_intro_button", tooltip = "Map Info"})
|
||||
b.style.font_color = {r = 0.8, g = 0.8, b = 0.8}
|
||||
b.style.font = "heading-1"
|
||||
|
@ -15,11 +15,11 @@ local function on_player_changed_position(event)
|
||||
for _, lamp in pairs(player.surface.find_entities_filtered({area={{player.position.x - 18, player.position.y - 18},{player.position.x + 18, player.position.y + 18}}, name="small-lamp"})) do
|
||||
local circuit = lamp.get_or_create_control_behavior()
|
||||
if circuit then
|
||||
if lamp.energy > 40 and circuit.disabled == false then
|
||||
if lamp.energy > 25 and circuit.disabled == false then
|
||||
return
|
||||
end
|
||||
else
|
||||
if lamp.energy > 40 then
|
||||
if lamp.energy > 25 then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
@ -19,9 +19,9 @@ local function on_tick()
|
||||
global.on_tick_schedule[game.tick] = nil
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local function on_init(event)
|
||||
if not global.on_tick_schedule then global.on_tick_schedule = {} end
|
||||
end
|
||||
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
event.on_init(on_init)
|
||||
event.add(defines.events.on_tick, on_tick)
|
@ -1,6 +1,6 @@
|
||||
local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
local Task = require 'utils.Task'
|
||||
local Task = require 'utils.task'
|
||||
local Game = require 'utils.game'
|
||||
local Token = require 'utils.token'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user