mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-02-13 13:49:35 +02:00
removed all on_tick event handlers and replaced it with designated file
This commit is contained in:
parent
5f96759833
commit
93d59ec14b
@ -16,6 +16,7 @@ require "map_layout"
|
||||
require "custom_commands"
|
||||
require "nuke_control"
|
||||
require "walk_distance"
|
||||
require "on_tick"
|
||||
|
||||
|
||||
|
||||
|
@ -285,11 +285,11 @@ end
|
||||
|
||||
if not global.pet_command_rotation then global.pet_command_rotation = 1 end
|
||||
|
||||
local function on_tick(event)
|
||||
function fish_market_on_180_ticks()
|
||||
|
||||
if game.tick % 200 == 0 then
|
||||
|
||||
if game.tick % 1000 == 0 then
|
||||
if game.tick % 180 == 0 then
|
||||
|
||||
if game.tick % 900 == 0 then
|
||||
if global.player_speed_boost_records then
|
||||
for k,v in pairs(global.player_speed_boost_records) do
|
||||
if game.tick - v.start_tick > 3000 then
|
||||
@ -332,4 +332,3 @@ end
|
||||
Event.register(defines.events.on_preplayer_mined_item, preplayer_mined_item)
|
||||
Event.register(defines.events.on_entity_died, fish_drop_entity_died)
|
||||
Event.register(defines.events.on_market_item_purchased, market_item_purchased)
|
||||
Event.register(defines.events.on_tick, on_tick)
|
||||
|
16
on_tick.lua
Normal file
16
on_tick.lua
Normal file
@ -0,0 +1,16 @@
|
||||
local function on_tick()
|
||||
if game.tick % 60 == 0 then
|
||||
poll_on_second()
|
||||
walk_distance_on_second()
|
||||
if game.tick % 120 == 0 then
|
||||
pet_on_120_ticks()
|
||||
if game.tick % 1200 == 0 then
|
||||
player_list_on_12_seconds()
|
||||
end
|
||||
elseif game.tick % 180 == 0 then
|
||||
fish_market_on_180_ticks()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Event.register(defines.events.on_tick, on_tick)
|
58
pet.lua
58
pet.lua
@ -1,8 +1,8 @@
|
||||
--[[local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
|
||||
if player.gui.top.pet_button == nil then
|
||||
local button = player.gui.top.add({ type = "sprite-button", name = "pet_button", sprite = "entity/small-biter" })
|
||||
local button = player.gui.top.add({ type = "sprite-button", name = "pet_button", sprite = "entity/small-biter" })
|
||||
button.style.minimal_height = 38
|
||||
button.style.minimal_width = 38
|
||||
button.style.top_padding = 0
|
||||
@ -13,8 +13,8 @@
|
||||
end
|
||||
|
||||
local function show_pet_panel(player)
|
||||
local frame = player.gui.left.add { type = "frame", name = "pet-panel", direction = "vertical" }
|
||||
|
||||
local frame = player.gui.left.add { type = "frame", name = "pet-panel", direction = "vertical" }
|
||||
|
||||
pet_table = frame.add { type = "table", name = "pet_panel_table", colspan = 2 }
|
||||
pet_table.add({ type = "sprite-button", name = "pet_button", sprite = "entity/small-biter" })
|
||||
end
|
||||
@ -25,19 +25,19 @@ function pet(player, entity_name)
|
||||
else
|
||||
player = game.players[player]
|
||||
end
|
||||
if not entity_name then
|
||||
if not entity_name then
|
||||
entity_name = "small-biter"
|
||||
end
|
||||
if not global.player_pets then global.player_pets = {} end
|
||||
|
||||
|
||||
local surface = game.surfaces[1]
|
||||
|
||||
|
||||
local pos = player.position
|
||||
pos.y = pos.y - 2
|
||||
|
||||
|
||||
local x = 1
|
||||
x = x + #global.player_pets
|
||||
|
||||
|
||||
global.player_pets[x] = {}
|
||||
global.player_pets[x].entity = surface.create_entity {name=entity_name, position=pos, force="player"}
|
||||
global.player_pets[x].owner = player.index
|
||||
@ -45,44 +45,18 @@ function pet(player, entity_name)
|
||||
|
||||
end
|
||||
|
||||
local function on_tick()
|
||||
if game.tick % 120 == 0 then
|
||||
for _, pets in pairs(global.player_pets) do
|
||||
local player = game.players[pets.owner]
|
||||
if pcall(function () local x = pets.entity.name end) then
|
||||
pets.entity.set_command({type=defines.command.go_to_location, destination=player.position,distraction=defines.distraction.none})
|
||||
else
|
||||
global.player_pets[pets.id] = nil
|
||||
local str = player.name .. "´s pet died ;_;"
|
||||
game.print(str)
|
||||
-- game.print(pets.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--[[
|
||||
local function try()
|
||||
local x = global.player_pets[1].entity.name
|
||||
end
|
||||
|
||||
function test()
|
||||
function pet_on_120_ticks()
|
||||
for _, pets in pairs(global.player_pets) do
|
||||
local str = " ID="
|
||||
str = str .. pets.id
|
||||
if pcall(function () local x = global.player_pets[pets.id].entity.name end) then
|
||||
str = str .. pets.entity.name
|
||||
local player = game.players[pets.owner]
|
||||
if pcall(function () local x = pets.entity.name end) then
|
||||
pets.entity.set_command({type=defines.command.go_to_location, destination=player.position,distraction=defines.distraction.none})
|
||||
else
|
||||
str = str .. "entity.. HAS.... NOOO... NAAAAAAMEEE"
|
||||
global.player_pets[pets.id] = nil
|
||||
local str = player.name .. "´s pet died ;_;"
|
||||
game.print(str)
|
||||
end
|
||||
|
||||
str = str .. " ownerID="
|
||||
str = str .. pets.owner
|
||||
|
||||
game.print(str)
|
||||
end
|
||||
end
|
||||
]]--
|
||||
|
||||
Event.register(defines.events.on_gui_click, on_gui_click)
|
||||
Event.register(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
Event.register(defines.events.on_tick, on_tick)
|
@ -351,26 +351,22 @@ local function on_gui_click(event)
|
||||
|
||||
end
|
||||
|
||||
|
||||
local function on_tick()
|
||||
if game.tick % 1200 == 0 then
|
||||
for _,player in pairs(game.connected_players) do
|
||||
if player.gui.left["player-list-panel"] then
|
||||
local sort_method
|
||||
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_2.caption, symbol_desc) then sort_method = "name_desc" end
|
||||
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_2.caption, symbol_asc) then sort_method = "name_asc" end
|
||||
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_3.caption, symbol_desc) then sort_method = "time_played_desc" end
|
||||
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_3.caption, symbol_asc) then sort_method = "time_played_asc" end
|
||||
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_4.caption, symbol_desc) then sort_method = "distance_desc" end
|
||||
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_4.caption, symbol_asc) then sort_method = "distance_asc" end
|
||||
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_5.caption, symbol_desc) then sort_method = "pokes_desc" end
|
||||
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_5.caption, symbol_asc) then sort_method = "pokes_asc" end
|
||||
player.gui.left["player-list-panel"].destroy()
|
||||
player_list_show(player,sort_method)
|
||||
end
|
||||
function player_list_on_12_seconds()
|
||||
for _,player in pairs(game.connected_players) do
|
||||
if player.gui.left["player-list-panel"] then
|
||||
local sort_method
|
||||
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_2.caption, symbol_desc) then sort_method = "name_desc" end
|
||||
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_2.caption, symbol_asc) then sort_method = "name_asc" end
|
||||
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_3.caption, symbol_desc) then sort_method = "time_played_desc" end
|
||||
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_3.caption, symbol_asc) then sort_method = "time_played_asc" end
|
||||
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_4.caption, symbol_desc) then sort_method = "distance_desc" end
|
||||
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_4.caption, symbol_asc) then sort_method = "distance_asc" end
|
||||
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_5.caption, symbol_desc) then sort_method = "pokes_desc" end
|
||||
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_5.caption, symbol_asc) then sort_method = "pokes_asc" end
|
||||
player.gui.left["player-list-panel"].destroy()
|
||||
player_list_show(player,sort_method)
|
||||
end
|
||||
end
|
||||
end
|
||||
Event.register(defines.events.on_tick, on_tick)
|
||||
Event.register(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
Event.register(defines.events.on_gui_click, on_gui_click)
|
||||
|
211
poll.lua
211
poll.lua
@ -1,11 +1,11 @@
|
||||
----------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Create Polls for your Factory Workers
|
||||
-- by MewMew -- with some help from RedLabel, Klonan, Morcup, BrainClot
|
||||
-- Create Polls for your Factory Workers
|
||||
-- by MewMew -- with some help from RedLabel, Klonan, Morcup, BrainClot
|
||||
----------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local function create_poll_gui(event)
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
|
||||
if player.gui.top.poll == nil then
|
||||
local button = player.gui.top.add { name = "poll", type = "sprite-button", sprite = "item/programmable-speaker" }
|
||||
button.style.font = "default-bold"
|
||||
@ -19,32 +19,32 @@ 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" }
|
||||
|
||||
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", colspan = 2 }
|
||||
|
||||
|
||||
local poll_panel_table = frame.poll_panel_table
|
||||
|
||||
|
||||
if not (global.poll_question == "") then
|
||||
|
||||
|
||||
local str = "Poll #" .. global.score_total_polls_created .. ":"
|
||||
if global.score_total_polls_created > 1 then
|
||||
local x = game.tick
|
||||
x = ((x / 60) / 60) / 60
|
||||
x = global.score_total_polls_created / x
|
||||
x = global.score_total_polls_created / x
|
||||
x = round(x, 0)
|
||||
str = str .. " (Polls/hour: "
|
||||
str = str .. x
|
||||
str = str .. ")"
|
||||
end
|
||||
|
||||
|
||||
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 { 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, single_line = false, name = "question_label" }
|
||||
poll_panel_table.question_label.style.maximal_width = 208
|
||||
poll_panel_table.question_label.style.maximal_height = 170
|
||||
@ -52,61 +52,61 @@ local function poll_show(player)
|
||||
poll_panel_table.question_label.style.font_color = { r=0.98, g=0.66, b=0.22}
|
||||
poll_panel_table.add { type = "label" }
|
||||
end
|
||||
|
||||
|
||||
local y = 1
|
||||
while (y < 4) do
|
||||
|
||||
if not (global.poll_answers[y] == "") then
|
||||
|
||||
if not (global.poll_answers[y] == "") then
|
||||
|
||||
local z = tostring(y)
|
||||
|
||||
|
||||
poll_panel_table.add { type = "label", caption = global.poll_answers[y], single_line = false, name = "answer_label_" .. z }
|
||||
local answer_label = poll_panel_table["answer_label_" .. z]
|
||||
answer_label.style.maximal_width = 208
|
||||
answer_label.style.minimal_width = 208
|
||||
answer_label.style.maximal_height = 165
|
||||
answer_label.style.font = "default"
|
||||
|
||||
local answerbutton = poll_panel_table.add { type = "button", caption = global.poll_button_votes[y], name = "answer_button_" .. z }
|
||||
|
||||
local answerbutton = poll_panel_table.add { type = "button", caption = global.poll_button_votes[y], name = "answer_button_" .. z }
|
||||
answerbutton.style.font = "default-listbox"
|
||||
end
|
||||
y = y + 1
|
||||
end
|
||||
|
||||
|
||||
frame.add { type = "table", name = "poll_panel_button_table", colspan = 3 }
|
||||
local poll_panel_button_table = frame.poll_panel_button_table
|
||||
poll_panel_button_table.add { type = "button", caption = "New Poll", name = "new_poll_assembler_button" }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
global.poll_panel_creation_time[player.index] = game.tick
|
||||
|
||||
|
||||
local str = "Hide (" .. global.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
|
||||
|
||||
poll_panel_button_table.poll_hide_button.style.minimal_width = 70
|
||||
poll_panel_button_table.new_poll_assembler_button.style.font = "default-bold"
|
||||
poll_panel_button_table.new_poll_assembler_button.style.minimal_height = 38
|
||||
poll_panel_button_table.poll_hide_button.style.font = "default-bold"
|
||||
poll_panel_button_table.poll_hide_button.style.minimal_height = 38
|
||||
poll_panel_button_table.add { type = "checkbox", caption = "Show Polls", state = global.autoshow_polls_for_player[player.name], name = "auto_show_polls_checkbox" }
|
||||
poll_panel_button_table.poll_hide_button.style.font = "default-bold"
|
||||
poll_panel_button_table.poll_hide_button.style.minimal_height = 38
|
||||
poll_panel_button_table.add { type = "checkbox", caption = "Show Polls", state = global.autoshow_polls_for_player[player.name], name = "auto_show_polls_checkbox" }
|
||||
end
|
||||
|
||||
local function poll(player)
|
||||
|
||||
|
||||
local frame = player.gui.left["poll-assembler"]
|
||||
frame = frame.table_poll_assembler
|
||||
|
||||
|
||||
global.poll_question = ""
|
||||
global.poll_question = frame.textfield_question.text
|
||||
if (global.poll_question == "") then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
global.poll_answers = {"","",""}
|
||||
global.poll_answers[1] = frame.textfield_answer_1.text
|
||||
global.poll_answers[2] = frame.textfield_answer_2.text
|
||||
@ -114,79 +114,79 @@ local function poll(player)
|
||||
if (global.poll_answers[3] .. global.poll_answers[2] .. global.poll_answers[1] == "") then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local msg = player.name
|
||||
msg = msg .. " has created a new Poll!"
|
||||
|
||||
|
||||
global.score_total_polls_created = global.score_total_polls_created + 1
|
||||
|
||||
|
||||
local frame = player.gui.left["poll-assembler"]
|
||||
frame.destroy()
|
||||
|
||||
global.poll_voted = nil
|
||||
|
||||
global.poll_voted = nil
|
||||
global.poll_voted = {}
|
||||
global.poll_button_votes = {0,0,0}
|
||||
|
||||
|
||||
local x = 1
|
||||
|
||||
|
||||
while (game.players[x] ~= nil) do
|
||||
|
||||
|
||||
local player = game.players[x]
|
||||
|
||||
local frame = player.gui.left["poll-panel"]
|
||||
|
||||
|
||||
local frame = player.gui.left["poll-panel"]
|
||||
|
||||
if (frame) then
|
||||
frame.destroy()
|
||||
end
|
||||
|
||||
|
||||
if (global.autoshow_polls_for_player[player.name] == true) then
|
||||
poll_show(player)
|
||||
end
|
||||
|
||||
|
||||
player.print(msg)
|
||||
|
||||
|
||||
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 x = 1
|
||||
|
||||
|
||||
while (game.players[x] ~= nil) do
|
||||
|
||||
|
||||
local player = game.players[x]
|
||||
|
||||
if (player.gui.left["poll-panel"]) then
|
||||
|
||||
if (player.gui.left["poll-panel"]) then
|
||||
local frame = player.gui.left["poll-panel"]
|
||||
frame = frame.poll_panel_table
|
||||
|
||||
if not (frame.answer_button_1 == nil) then
|
||||
|
||||
if not (frame.answer_button_1 == nil) then
|
||||
frame.answer_button_1.caption = global.poll_button_votes[1]
|
||||
end
|
||||
if not (frame.answer_button_2 == nil) then
|
||||
if not (frame.answer_button_2 == nil) then
|
||||
frame.answer_button_2.caption = global.poll_button_votes[2]
|
||||
end
|
||||
if not (frame.answer_button_3 == nil) then
|
||||
if not (frame.answer_button_3 == nil) then
|
||||
frame.answer_button_3.caption = global.poll_button_votes[3]
|
||||
end
|
||||
end
|
||||
end
|
||||
x = x + 1
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
local function poll_assembler(player)
|
||||
local frame = player.gui.left.add { type = "frame", name = "poll-assembler", caption = "" }
|
||||
local function poll_assembler(player)
|
||||
local frame = player.gui.left.add { type = "frame", name = "poll-assembler", caption = "" }
|
||||
local frame_table = frame.add { type = "table", name = "table_poll_assembler", colspan = 2 }
|
||||
frame_table.add { type = "label", caption = "Question:" }
|
||||
frame_table.add { type = "textfield", name = "textfield_question", text = "" }
|
||||
@ -212,25 +212,25 @@ function poll_sync_for_new_joining_player(event)
|
||||
if not global.poll_duration_in_seconds then global.poll_duration_in_seconds = 99 end
|
||||
if not global.poll_panel_creation_time then global.poll_panel_creation_time = {} end
|
||||
if not global.score_total_polls_created then global.score_total_polls_created = 0 end
|
||||
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
global.autoshow_polls_for_player[player.name] = true
|
||||
|
||||
local frame = player.gui.left["poll-panel"]
|
||||
|
||||
local frame = player.gui.left["poll-panel"]
|
||||
if (frame == nil) then
|
||||
if not (global.poll_question == "") then
|
||||
poll_show(player)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local function on_gui_click(event)
|
||||
if not (event and event.element and event.element.valid) then return end
|
||||
local player = game.players[event.element.player_index]
|
||||
local name = event.element.name
|
||||
|
||||
|
||||
if (name == "poll") then
|
||||
local frame = player.gui.left["poll-panel"]
|
||||
if (frame) then
|
||||
@ -238,13 +238,13 @@ local function on_gui_click(event)
|
||||
else
|
||||
poll_show(player)
|
||||
end
|
||||
|
||||
|
||||
local frame = player.gui.left["poll-assembler"]
|
||||
if (frame) then
|
||||
frame.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if (name == "new_poll_assembler_button") then
|
||||
local frame = player.gui.left["poll-assembler"]
|
||||
if (frame) then
|
||||
@ -253,11 +253,11 @@ local function on_gui_click(event)
|
||||
poll_assembler(player)
|
||||
end
|
||||
end
|
||||
|
||||
if (name == "create_new_poll_button") then
|
||||
|
||||
if (name == "create_new_poll_button") then
|
||||
poll(player)
|
||||
end
|
||||
|
||||
|
||||
if (name == "poll_hide_button") then
|
||||
local frame = player.gui.left["poll-panel"]
|
||||
if (frame) then
|
||||
@ -268,58 +268,55 @@ local function on_gui_click(event)
|
||||
frame.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if (name == "auto_show_polls_checkbox") then
|
||||
global.autoshow_polls_for_player[player.name] = event.element.state
|
||||
end
|
||||
|
||||
if global.poll_voted[event.player_index] == nil then
|
||||
|
||||
global.autoshow_polls_for_player[player.name] = event.element.state
|
||||
end
|
||||
|
||||
if global.poll_voted[event.player_index] == nil then
|
||||
|
||||
if(name == "answer_button_1") then
|
||||
global.poll_button_votes[1] = global.poll_button_votes[1] + 1
|
||||
global.poll_voted[event.player_index] = player.name
|
||||
poll_refresh()
|
||||
end
|
||||
|
||||
|
||||
if(name == "answer_button_2") then
|
||||
global.poll_button_votes[2] = global.poll_button_votes[2] + 1
|
||||
global.poll_voted[event.player_index] = player.name
|
||||
poll_refresh()
|
||||
end
|
||||
|
||||
|
||||
if(name == "answer_button_3") then
|
||||
global.poll_button_votes[3] = global.poll_button_votes[3] + 1
|
||||
global.poll_voted[event.player_index] = player.name
|
||||
poll_refresh()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
local function on_tick()
|
||||
if game.tick % 60 == 0 then
|
||||
for _, player in pairs(game.connected_players) do
|
||||
if global.poll_panel_creation_time[player.index] then
|
||||
local frame = player.gui.left["poll-panel"]
|
||||
if frame then
|
||||
local y = (game.tick - global.poll_panel_creation_time[player.index]) / 60
|
||||
local y = global.poll_duration_in_seconds - y
|
||||
y = round(y, 0)
|
||||
if y <= 0 then
|
||||
frame.destroy()
|
||||
global.poll_panel_creation_time[player.index] = nil
|
||||
else
|
||||
y = "Hide (" .. y
|
||||
y = y .. ")"
|
||||
frame.poll_panel_button_table.poll_hide_button.caption = y
|
||||
end
|
||||
function poll_on_second()
|
||||
for _, player in pairs(game.connected_players) do
|
||||
if global.poll_panel_creation_time[player.index] then
|
||||
local frame = player.gui.left["poll-panel"]
|
||||
if frame then
|
||||
local y = (game.tick - global.poll_panel_creation_time[player.index]) / 60
|
||||
local y = global.poll_duration_in_seconds - y
|
||||
y = round(y, 0)
|
||||
if y <= 0 then
|
||||
frame.destroy()
|
||||
global.poll_panel_creation_time[player.index] = nil
|
||||
else
|
||||
y = "Hide (" .. y
|
||||
y = y .. ")"
|
||||
frame.poll_panel_button_table.poll_hide_button.caption = y
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Event.register(defines.events.on_tick, on_tick)
|
||||
Event.register(defines.events.on_gui_click, on_gui_click)
|
||||
Event.register(defines.events.on_player_joined_game, create_poll_gui)
|
||||
Event.register(defines.events.on_player_joined_game, poll_sync_for_new_joining_player)
|
||||
Event.register(defines.events.on_player_joined_game, poll_sync_for_new_joining_player)
|
||||
|
@ -1,10 +1,4 @@
|
||||
local function on_tick()
|
||||
if game.tick % 60 == 0 then
|
||||
on_second()
|
||||
end
|
||||
end
|
||||
|
||||
function on_second()
|
||||
function walk_distance_on_second()
|
||||
local last_positions = global.scenario.variables.player_positions
|
||||
local d_x = 0
|
||||
local d_y = 0
|
||||
@ -34,5 +28,4 @@ local function init_player_position(event)
|
||||
end
|
||||
end
|
||||
|
||||
Event.register(defines.events.on_tick, on_tick)
|
||||
Event.register(defines.events.on_player_joined_game, init_player_position)
|
||||
|
Loading…
x
Reference in New Issue
Block a user