Skip to content
This repository has been archived by the owner on Aug 28, 2021. It is now read-only.

Commit

Permalink
session_data update
Browse files Browse the repository at this point in the history
  • Loading branch information
MewMew committed Dec 30, 2018
1 parent 4723466 commit 3f508d7
Show file tree
Hide file tree
Showing 63 changed files with 3,114 additions and 92 deletions.
8 changes: 4 additions & 4 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ require "score"
---- enable modules here ----
--require "maps.tools.map_pregen"
--require "maps.modules.hunger"
require "maps.tools.cheat_mode"
--require "maps.tools.cheat_mode"
--require "maps.modules.dynamic_landfill"
--require "maps.modules.restrictive_fluid_mining"
require "maps.modules.fluids_are_explosive"
require "maps.modules.explosives_are_explosive"
--require "maps.modules.fluids_are_explosive"
--require "maps.modules.explosives_are_explosive"
--require "maps.modules.railgun_enhancer"
-----------------------------

Expand All @@ -33,7 +33,7 @@ require "maps.modules.explosives_are_explosive"
--require "maps.crossing"
--require "maps.spooky_forest"
--require "maps.atoll"
--require "maps.tank_battles"
require "maps.tank_battles"
--require "maps.empty_map"
--require "maps.custom_start"
-----------------------------
Expand Down
56 changes: 28 additions & 28 deletions maps/modules/fluids_are_explosive.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,48 +56,48 @@ local function shuffle(tbl)
end

local function process_explosion_tile(pos, explosion_index, current_radius)
local surface = game.surfaces[global.explosion_schedule[explosion_index].surface]
local surface = game.surfaces[global.fluid_explosion_schedule[explosion_index].surface]
local target_entities = surface.find_entities_filtered({area={{pos.x - 0.5, pos.y - 0.5},{pos.x + 0.499, pos.y + 0.499}}})
local explosion_animation = "explosion"

local tile = surface.get_tile(pos)
if tile.name == "out-of-map" then
if global.explosion_schedule[explosion_index].damage_remaining >= out_of_map_tile_health then
if global.fluid_explosion_schedule[explosion_index].damage_remaining >= out_of_map_tile_health then
explosion_animation = "big-explosion"
surface.set_tiles({{name = "dirt-5", position = pos}}, true)
end
global.explosion_schedule[explosion_index].damage_remaining = global.explosion_schedule[explosion_index].damage_remaining - out_of_map_tile_health
global.fluid_explosion_schedule[explosion_index].damage_remaining = global.fluid_explosion_schedule[explosion_index].damage_remaining - out_of_map_tile_health
else
local decay_explosion = true
for _, entity in pairs(target_entities) do
if entity.health then
decay_explosion = false
end
end
if decay_explosion then global.explosion_schedule[explosion_index].damage_remaining = global.explosion_schedule[explosion_index].damage_remaining - empty_tile_damage_decay end
if decay_explosion then global.fluid_explosion_schedule[explosion_index].damage_remaining = global.fluid_explosion_schedule[explosion_index].damage_remaining - empty_tile_damage_decay end
end

for _, entity in pairs(target_entities) do
if entity.valid then
if entity.health then
if entity.health <= global.explosion_schedule[explosion_index].damage_remaining then
if entity.health <= global.fluid_explosion_schedule[explosion_index].damage_remaining then
explosion_animation = "big-explosion"
if entity.health > 500 then explosion_animation = "big-artillery-explosion" end
global.explosion_schedule[explosion_index].damage_remaining = global.explosion_schedule[explosion_index].damage_remaining - entity.health
global.fluid_explosion_schedule[explosion_index].damage_remaining = global.fluid_explosion_schedule[explosion_index].damage_remaining - entity.health
if entity.name ~= "player" then
entity.damage(2097152, "player", "explosion")
else
entity.die("player")
end
else
entity.damage(global.explosion_schedule[explosion_index].damage_remaining, "player", "explosion")
global.explosion_schedule[explosion_index].damage_remaining = 0
entity.damage(global.fluid_explosion_schedule[explosion_index].damage_remaining, "player", "explosion")
global.fluid_explosion_schedule[explosion_index].damage_remaining = 0
end
end
end
end

if global.explosion_schedule[explosion_index].damage_remaining > 5000 and current_radius < 2 then
if global.fluid_explosion_schedule[explosion_index].damage_remaining > 5000 and current_radius < 2 then
if math.random(1,2) == 1 then
explosion_animation = "big-explosion"
else
Expand All @@ -107,7 +107,7 @@ local function process_explosion_tile(pos, explosion_index, current_radius)

surface.create_entity({name = explosion_animation, position = pos})

if global.explosion_schedule[explosion_index].damage_remaining <= 0 then return false end
if global.fluid_explosion_schedule[explosion_index].damage_remaining <= 0 then return false end

return true
end
Expand All @@ -118,11 +118,11 @@ local function create_explosion_schedule(entity)
if explosives_amount < 1 then return end
local center_position = entity.position

if not global.explosion_schedule then global.explosion_schedule = {} end
global.explosion_schedule[#global.explosion_schedule + 1] = {}
global.explosion_schedule[#global.explosion_schedule].surface = entity.surface.name
if not global.fluid_explosion_schedule then global.fluid_explosion_schedule = {} end
global.fluid_explosion_schedule[#global.fluid_explosion_schedule + 1] = {}
global.fluid_explosion_schedule[#global.fluid_explosion_schedule].surface = entity.surface.name

global.explosion_schedule[#global.explosion_schedule].damage_remaining = fluid_damages[entity.fluidbox[1].name] * explosives_amount
global.fluid_explosion_schedule[#global.fluid_explosion_schedule].damage_remaining = fluid_damages[entity.fluidbox[1].name] * explosives_amount

local circle_coordinates = {
[1] = {{x = 0, y = 0}},
Expand All @@ -145,15 +145,15 @@ local function create_explosion_schedule(entity)

for current_radius = 1, 16, 1 do

global.explosion_schedule[#global.explosion_schedule][current_radius] = {}
global.explosion_schedule[#global.explosion_schedule][current_radius].trigger_tick = game.tick + (current_radius * 8)
global.fluid_explosion_schedule[#global.fluid_explosion_schedule][current_radius] = {}
global.fluid_explosion_schedule[#global.fluid_explosion_schedule][current_radius].trigger_tick = game.tick + (current_radius * 8)

local circle_coords = circle_coordinates[current_radius]
circle_coords = shuffle(circle_coords)

for index, tile_position in pairs(circle_coords) do
local pos = {x = center_position.x + tile_position.x, y = center_position.y + tile_position.y}
global.explosion_schedule[#global.explosion_schedule][current_radius][index] = {x = pos.x, y = pos.y}
global.fluid_explosion_schedule[#global.fluid_explosion_schedule][current_radius][index] = {x = pos.x, y = pos.y}
end

end
Expand All @@ -172,29 +172,29 @@ local function on_entity_damaged(event)
end

local function on_tick(event)
if global.explosion_schedule then
if global.fluid_explosion_schedule then
local tick = game.tick
local explosion_schedule_is_alive = false
for explosion_index = 1, #global.explosion_schedule, 1 do
if #global.explosion_schedule[explosion_index] > 0 then
for explosion_index = 1, #global.fluid_explosion_schedule, 1 do
if #global.fluid_explosion_schedule[explosion_index] > 0 then
explosion_schedule_is_alive = true
local surface = game.surfaces[global.explosion_schedule[explosion_index].surface]
for radius = 1, #global.explosion_schedule[explosion_index], 1 do
if global.explosion_schedule[explosion_index][radius].trigger_tick == tick then
for tile_index = 1, #global.explosion_schedule[explosion_index][radius], 1 do
local continue_explosion = process_explosion_tile(global.explosion_schedule[explosion_index][radius][tile_index], explosion_index, radius)
local surface = game.surfaces[global.fluid_explosion_schedule[explosion_index].surface]
for radius = 1, #global.fluid_explosion_schedule[explosion_index], 1 do
if global.fluid_explosion_schedule[explosion_index][radius].trigger_tick == tick then
for tile_index = 1, #global.fluid_explosion_schedule[explosion_index][radius], 1 do
local continue_explosion = process_explosion_tile(global.fluid_explosion_schedule[explosion_index][radius][tile_index], explosion_index, radius)
if not continue_explosion then
global.explosion_schedule[explosion_index] = {}
global.fluid_explosion_schedule[explosion_index] = {}
break
end
end
if radius == #global.explosion_schedule[explosion_index] then global.explosion_schedule[explosion_index] = {} end
if radius == #global.fluid_explosion_schedule[explosion_index] then global.fluid_explosion_schedule[explosion_index] = {} end
break
end
end
end
end
if not explosion_schedule_is_alive then global.explosion_schedule = nil end
if not explosion_schedule_is_alive then global.fluid_explosion_schedule = nil end
end
end

Expand Down
1 change: 1 addition & 0 deletions maps/tank_battles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ local function get_arena_layout_modifiers()
["water"] = true,
["deepwater"] = true,
["water-green"] = true,
["deepwater-green"] = true,
["out-of-map"] = true,
["hazard-concrete-left"] = true,
["hazard-concrete-right"] = true,
Expand Down
87 changes: 32 additions & 55 deletions poll.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
----------------------------------------------------------------------------------------------------------------------------------------
-- Create Polls for your Factory Workers
-- create polls for players to vote on
-- by MewMew -- with some help from RedLabel, Klonan, Morcup, BrainClot
----------------------------------------------------------------------------------------------------------------------------------------

local Event = require 'utils.event'
local poll_duration_in_seconds = 99

local function create_poll_gui(event)
local player = game.players[event.player_index]
Expand All @@ -21,8 +22,6 @@ local function create_poll_gui(event)
end

local function poll_show(player)

--player.gui.left.direction = "horizontal"
local frame = player.gui.left.add { type = "frame", name = "poll-panel", direction = "vertical" }

frame.add { type = "table", name = "poll_panel_table", column_count = 2 }
Expand All @@ -44,9 +43,7 @@ local function poll_show(player)

poll_panel_table.add { type = "label", caption = str, single_line = false, name = "poll_number_label" }
poll_panel_table.poll_number_label.style.font_color = { r=0.75, g=0.75, b=0.75}
poll_panel_table.add { type = "label"}
--poll_panel_table.add { caption = "----------------------------", type = "label" }
--poll_panel_table.add { type = "label" }
poll_panel_table.add { type = "label"}
poll_panel_table.add { type = "label", caption = global.poll_question, name = "question_label" }
poll_panel_table.question_label.style.maximal_width = 208
poll_panel_table.question_label.style.maximal_height = 170
Expand All @@ -58,18 +55,14 @@ local function poll_show(player)

local y = 1
while (y < 4) do

if not (global.poll_answers[y] == "") then

local z = tostring(y)

if not (global.poll_answers[y] == "") then
local z = tostring(y)
local l = poll_panel_table.add { type = "label", caption = global.poll_answers[y], name = "answer_label_" .. z }
l.style.maximal_width = 208
l.style.minimal_width = 208
l.style.maximal_height = 165
l.style.font = "default"
l.style.single_line = false

l.style.single_line = false
local answerbutton = poll_panel_table.add { type = "button", caption = global.poll_button_votes[y], name = "answer_button_" .. z }
answerbutton.style.font = "default-listbox"
answerbutton.style.minimal_width = 32
Expand All @@ -84,10 +77,9 @@ local function poll_show(player)
if not global.poll_panel_creation_times then global.poll_panel_creation_times = {} end
global.poll_panel_creation_times[player.index] = {player_index = player.index, tick = 5940}

local str = "Hide (" .. global.poll_duration_in_seconds
local str = "Hide (" .. poll_duration_in_seconds
str = str .. ")"



poll_panel_button_table.add { type = "button", caption = str, name = "poll_hide_button" }

poll_panel_button_table.poll_hide_button.style.minimal_width = 70
Expand Down Expand Up @@ -130,7 +122,7 @@ local function poll(player)
local frame = player.gui.left["poll-panel"]

if (frame) then
frame.destroy()
frame.destroy()
end

if (global.autoshow_polls_for_player[player.name] == true) then
Expand All @@ -141,29 +133,16 @@ local function poll(player)

x = x + 1
end


---------------------
-- data for score.lua
---------------------
--global.score_total_polls_created = global.score_total_polls_created + 1
--refresh_score()

end


local function poll_refresh()

local function poll_refresh()
local x = 1

while (game.players[x] ~= nil) do

local player = game.players[x]

local player = game.players[x]
if (player.gui.left["poll-panel"]) then
local frame = player.gui.left["poll-panel"]
frame = frame.poll_panel_table

frame = frame.poll_panel_table
if not (frame.answer_button_1 == nil) then
frame.answer_button_1.caption = global.poll_button_votes[1]
end
Expand All @@ -175,8 +154,7 @@ local function poll_refresh()
end
end
x = x + 1
end

end
end

local function poll_assembler(player)
Expand All @@ -192,31 +170,30 @@ local function poll_assembler(player)
frame_table.add { type = "textfield", name = "textfield_answer_3", text = "" }
frame_table.add { type = "label", caption = "" }
frame_table.add { type = "button", name = "create_new_poll_button", caption = "Create" }

end

function poll_sync_for_new_joining_player(event)

if not global.poll_voted then global.poll_voted = {} end
if not global.poll_question then global.poll_question = "" end
if not global.poll_answers then global.poll_answers = {"","",""} end
if not global.poll_button_votes then global.poll_button_votes = {0,0,0} end
if not global.poll_voted then global.poll_voted = {} end
if not global.autoshow_polls_for_player then global.autoshow_polls_for_player = {} end
if not global.poll_duration_in_seconds then global.poll_duration_in_seconds = 99 end
if not global.score_total_polls_created then global.score_total_polls_created = 0 end

function on_player_joined_game(event)
if not global.poll_init_done then
global.poll_voted = {}
global.poll_question = ""
global.poll_answers = {"","",""}
global.poll_button_votes = {0,0,0}
global.poll_voted = {}
global.autoshow_polls_for_player = {}
global.score_total_polls_created = 0
global.poll_init_done = true
end

local player = game.players[event.player_index]

global.autoshow_polls_for_player[player.name] = true
if global.autoshow_polls_for_player[player.name] == nil then
global.autoshow_polls_for_player[player.name] = true
end

local frame = player.gui.left["poll-panel"]
if (frame == nil) then
if not (global.poll_question == "") then
poll_show(player)
end
end
if player.gui.left["poll-panel"] then return end
if global.poll_question == "" then return end

poll_show(player)
end

local function on_gui_click(event)
Expand Down Expand Up @@ -323,4 +300,4 @@ end
Event.add(defines.events.on_tick, on_tick)
Event.add(defines.events.on_gui_click, on_gui_click)
Event.add(defines.events.on_player_joined_game, create_poll_gui)
Event.add(defines.events.on_player_joined_game, poll_sync_for_new_joining_player)
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
Loading

0 comments on commit 3f508d7

Please sign in to comment.