1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-09-16 09:16:22 +02:00

removed all on_tick event handlers and replaced it with designated file

This commit is contained in:
Valansch
2017-07-21 18:43:34 +02:00
parent 5f96759833
commit 93d59ec14b
7 changed files with 156 additions and 180 deletions

View File

@@ -16,6 +16,7 @@ require "map_layout"
require "custom_commands"
require "nuke_control"
require "walk_distance"
require "on_tick"

View File

@@ -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 % 180 == 0 then
if game.tick % 1000 == 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
View 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)

28
pet.lua
View File

@@ -45,8 +45,7 @@ function pet(player, entity_name)
end
local function on_tick()
if game.tick % 120 == 0 then
function pet_on_120_ticks()
for _, pets in pairs(global.player_pets) do
local player = game.players[pets.owner]
if pcall(function () local x = pets.entity.name end) then
@@ -55,34 +54,9 @@ local function on_tick()
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()
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
else
str = str .. "entity.. HAS.... NOOO... NAAAAAAMEEE"
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)

View File

@@ -351,9 +351,7 @@ local function on_gui_click(event)
end
local function on_tick()
if game.tick % 1200 == 0 then
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
@@ -370,7 +368,5 @@ local function on_tick()
end
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)

View File

@@ -296,8 +296,7 @@ local function on_gui_click(event)
end
end
local function on_tick()
if game.tick % 60 == 0 then
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"]
@@ -317,9 +316,7 @@ local function on_tick()
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)

View File

@@ -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)