mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 04:21:41 +09:00
Store bug fixes
This commit is contained in:
@@ -326,7 +326,7 @@ Tasks.on_update(function(task,task_id)
|
||||
local players
|
||||
if task then
|
||||
local force = game.forces[task.force_name]
|
||||
players = force.players
|
||||
players = force.connected_players
|
||||
else
|
||||
players = game.connected_players
|
||||
end
|
||||
@@ -338,6 +338,9 @@ Tasks.on_update(function(task,task_id)
|
||||
end
|
||||
end)
|
||||
|
||||
--- Update the tasks when the player joins
|
||||
Event.add(defines.events.on_player_joined_game,task_list 'redraw')
|
||||
|
||||
--- Makes sure the right buttons are present when roles change
|
||||
Event.add(Roles.events.on_role_assigned,task_list 'redraw')
|
||||
Event.add(Roles.events.on_role_unassigned,task_list 'redraw')
|
||||
|
||||
@@ -94,7 +94,7 @@ end)
|
||||
Warps.teleport_player(warp_id,player)
|
||||
|
||||
-- Reset the warp cooldown if the player does not have unlimited warps
|
||||
if config.bypass_warp_limits_permision and not Roles.player_allowed(player,config.bypass_warp_limits_permision) then
|
||||
if config.bypass_warp_limits_permission and not Roles.player_allowed(player,config.bypass_warp_limits_permission) then
|
||||
warp_timer:set_store(player.name,0)
|
||||
Store.trigger(player_in_range_store,player)
|
||||
end
|
||||
@@ -436,6 +436,11 @@ end)
|
||||
--- When the name of a warp is updated this is triggered
|
||||
Warps.on_update(warp_list 'update_all')
|
||||
|
||||
--- Update the warps when the player joins
|
||||
Event.add(defines.events.on_player_joined_game,warp_list 'redraw')
|
||||
Event.add(Roles.events.on_role_assigned,warp_list 'redraw')
|
||||
Event.add(Roles.events.on_role_unassigned,warp_list 'redraw')
|
||||
|
||||
--- When the player leaves or enters range of a warp this is triggered
|
||||
Store.watch(player_in_range_store,function(value,player_name)
|
||||
local player = game.players[player_name]
|
||||
@@ -459,7 +464,7 @@ Store.watch(player_in_range_store,function(value,player_name)
|
||||
if element and element.valid then
|
||||
element.enabled = state
|
||||
if state then
|
||||
local position = Warps.get_details(warp_id).position
|
||||
local position = Warps.get_warp(warp_id).position
|
||||
element.tooltip = {'warp-list.goto-tooltip',position.x,position.y}
|
||||
else
|
||||
element.tooltip = {'warp-list.goto-disabled'}
|
||||
@@ -483,7 +488,7 @@ Event.on_nth_tick(math.floor(60/config.update_smoothing),function()
|
||||
local was_in_range = Store.get(player_in_range_store,player)
|
||||
|
||||
-- Get the ids of all the warps on the players force
|
||||
local force_name = player.force
|
||||
local force_name = player.force.name
|
||||
local warp_ids = force_warps[force_name]
|
||||
if not warp_ids then
|
||||
warp_ids = Warps.get_force_warp_ids(force_name)
|
||||
@@ -497,11 +502,11 @@ Event.on_nth_tick(math.floor(60/config.update_smoothing),function()
|
||||
local px,py = pos.x,pos.y
|
||||
|
||||
-- Loop over each warp
|
||||
for _,warp_id in pairs(warp_ids) do
|
||||
for _,warp_id in ipairs(warp_ids) do
|
||||
-- Check if warp id is chached
|
||||
local warp = warps[warp_id]
|
||||
if not warp then
|
||||
warp = Warps.get(warp_id)
|
||||
warp = Warps.get_warp(warp_id)
|
||||
warps[warp_id] = warp
|
||||
end
|
||||
|
||||
@@ -509,11 +514,12 @@ Event.on_nth_tick(math.floor(60/config.update_smoothing),function()
|
||||
local warp_pos = warp.position
|
||||
if warp.surface == surface then
|
||||
local dx, dy = px-warp_pos.x, py-warp_pos.y
|
||||
if (dx*dx)+(dy*dy) < rs2 or (dx*dx)+(dy*dy) < r2 then
|
||||
if (warp_id == warp_ids.spawn and (dx*dx)+(dy*dy) < rs2) or (dx*dx)+(dy*dy) < r2 then
|
||||
-- Set in range to true if the player was preiovusly out of range
|
||||
if not was_in_range then
|
||||
Store.set(player_in_range_store,player,true)
|
||||
end
|
||||
was_in_range = false -- stops setting back to false below
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user