mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 12:31:41 +09:00
Hopefully fixed cam desync this time
This commit is contained in:
@@ -89,12 +89,13 @@ Event.register(-1,function(event)
|
|||||||
end):on_event(defines.events.on_player_respawned,function(self,event)
|
end):on_event(defines.events.on_player_respawned,function(self,event)
|
||||||
if self.data.players[event.player_index] then
|
if self.data.players[event.player_index] then
|
||||||
local remove = {}
|
local remove = {}
|
||||||
|
local player = Game.get_player(event)
|
||||||
for index,cam in pairs(self.data.players[event.player_index]) do
|
for index,cam in pairs(self.data.players[event.player_index]) do
|
||||||
if not cam.valid then table.insert(remove,index)
|
if cam.valid then table.insert(self.data.cams,{cam=cam,entity=player.character,surface=player.surface})
|
||||||
else Gui.cam_link{cam=cam,entity=Game.get_player(event).character} end
|
else table.insert(remove,index) end
|
||||||
end
|
end
|
||||||
for _,index in pairs(remove) do
|
for n,index in pairs(remove) do
|
||||||
table.remove(self.data.players[event.player_index],index)
|
table.remove(self.data.players[event.player_index],index-n+1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end):open()
|
end):open()
|
||||||
@@ -160,40 +161,39 @@ function Gui.cam_link(data)
|
|||||||
return data.cam
|
return data.cam
|
||||||
end
|
end
|
||||||
|
|
||||||
Event.register(-1,function(event)
|
Event.register(defines.events.on_tick, function(event)
|
||||||
if not Server or not Server._thread then
|
if Gui.left and ((event.tick+10)/(3600*game.speed)) % 15 == 0 then
|
||||||
Event.register(defines.events.on_tick, function(event)
|
Gui.left.update()
|
||||||
if Gui.left and ((event.tick+10)/(3600*game.speed)) % 15 == 0 then
|
end
|
||||||
Gui.left.update()
|
if Server and Server._thread then return end
|
||||||
|
if Gui._global().cams and is_type(Gui._global().cams,'table') and #Gui._global().cams > 0 then
|
||||||
|
local update = 4
|
||||||
|
if Gui._global().cam_index >= #Gui._global().cams then Gui._global().cam_index = 1 end
|
||||||
|
if update > #Gui._global().cams then update = #Gui._global().cams end
|
||||||
|
for cam_offset = 0,update do
|
||||||
|
local _cam = Gui._global().cams[Gui._global().cam_index]
|
||||||
|
if not _cam then break end
|
||||||
|
if not _cam.cam.valid then table.remove(Gui._global().cams,Gui._global().cam_index)
|
||||||
|
elseif not _cam.entity.valid then table.remove(Gui._global().cams,Gui._global().cam_index)
|
||||||
|
else _cam.cam.position = _cam.entity.position if not _cam.surface then _cam.cam.surface_index = _cam.entity.surface.index end Gui._global().cam_index = Gui._global().cam_index+1
|
||||||
end
|
end
|
||||||
if Gui._global().cams and is_type(Gui._global().cams,'table') and #Gui._global().cams > 0 then
|
end
|
||||||
local update = 4
|
Gui._global().cam_index = Gui._global().cam_index+update
|
||||||
if Gui._global().cam_index >= #Gui._global().cams then Gui._global().cam_index = 1 end
|
end
|
||||||
if update > #Gui._global().cams then update = #Gui._global().cams end
|
end)
|
||||||
for cam_offset = 0,update do
|
|
||||||
local _cam = Gui._global().cams[Gui._global().cam_index]
|
|
||||||
if not _cam then break end
|
|
||||||
if not _cam.cam.valid then table.remove(Gui._global().cams,Gui._global().cam_index)
|
|
||||||
elseif not _cam.entity.valid then table.remove(Gui._global().cams,Gui._global().cam_index)
|
|
||||||
else _cam.cam.position = _cam.entity.position if not _cam.surface then _cam.cam.surface_index = _cam.entity.surface.index end Gui._global().cam_index = Gui._global().cam_index+1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Gui._global().cam_index = Gui._global().cam_index+update
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
Event.register(defines.events.on_player_respawned,function(event)
|
Event.register(defines.events.on_player_respawned,function(event)
|
||||||
if Gui._global().players and is_type(Gui._global().players,'table') and #Gui._global().players > 0 and Gui._global().players[event.player_index] then
|
if Server and Server._thread then return end
|
||||||
local remove = {}
|
if Gui._global().players and is_type(Gui._global().players,'table') and #Gui._global().players > 0 and Gui._global().players[event.player_index] then
|
||||||
for index,cam in pairs(Gui._global().players[event.player_index]) do
|
local remove = {}
|
||||||
if not cam.valid then table.insert(remove,index)
|
local player = Game.get_player(event)
|
||||||
else Gui.cam_link{cam=cam,entity=Game.get_player(event).character} end
|
for index,cam in pairs(Gui._global().players[event.player_index]) do
|
||||||
end
|
if cam.valid then table.insert(Gui._global().cams,{cam=cam,entity=player.character,surface=player.surface})
|
||||||
for _,index in pairs(remove) do
|
else table.insert(remove,index) end
|
||||||
table.remove(Gui._global().players[event.player_index],index)
|
end
|
||||||
end
|
for n,index in pairs(remove) do
|
||||||
end
|
table.remove(Gui._global().players[event.player_index],index-n+1)
|
||||||
end)
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user