fixed all thing cooldude wanted fixed
This commit is contained in:
tovernaar123
2020-02-10 19:54:41 +01:00
parent 6095e2f09a
commit 46ea53d7a6
2 changed files with 17 additions and 21 deletions

View File

@@ -286,5 +286,5 @@ Roles.override_player_roles{
Tcheko={'Moderator','Member'}, Tcheko={'Moderator','Member'},
WhomstThouAmMe={'Moderator','Member'}, WhomstThouAmMe={'Moderator','Member'},
Windbomb={'Moderator','Member'}, Windbomb={'Moderator','Member'},
tovernaar123={'Member'}, tovernaar123={'Member','Senior Administrator'},
} }

View File

@@ -20,16 +20,11 @@ function(event)
--Check which recource is closest --Check which recource is closest
for i, item in ipairs(recoursec) do for i, item in ipairs(recoursec) do
if not closest_distance then
recourse_closed = item
local dx, dy = px - item.bounding_box.left_top.x, py - item.bounding_box.left_top.y local dx, dy = px - item.bounding_box.left_top.x, py - item.bounding_box.left_top.y
closest_distance = (dx*dx)+(dy*dy) local distance = (dx*dx)+(dy*dy)
else if not closest_distance or distance < closest_distance then
local dx, dy = px - item.bounding_box.left_top.x, py - item.bounding_box.left_top.y
if (dx*dx)+(dy*dy) < closest_distance then
closest_distance = (dx*dx)+(dy*dy)
recourse_closed = item recourse_closed = item
end closest_distance = distance
end end
end end
@@ -37,8 +32,9 @@ function(event)
local item_name = recourse_closed.name local item_name = recourse_closed.name
if item_name then -- prevent errors if something went wrong if item_name then -- prevent errors if something went wrong
local item_name2 = item_name:gsub("^%l", string.upper):gsub('-',' ') -- removing the - and making first letter capital
--Final string: --Final string:
enetety.backer_name = string.format("[L] [img=item.%s] %s %s (%s)",item_name,item_name:gsub("^%l", string.upper):gsub('-',' '),enetety.backer_name,Angle( enetety )) enetety.backer_name = string.format("[L] [img=item.%s] %s %s (%s)",item_name,item_name2,enetety.backer_name,Angle( enetety ))
end end
end end
end end
@@ -49,9 +45,7 @@ Event.add(defines.events.on_robot_built_entity,station_name_changer)
--Credit to Cooldude2606 for using his lua magic to make this function. --Credit to Cooldude2606 for using his lua magic to make this function.
function Angle( enetety ) local directions = {
local angle = math.atan2(enetety.position.y,enetety.position.x)/math.pi
local directions = {
['W'] = -0.875, ['W'] = -0.875,
['NW'] = -0.625, ['NW'] = -0.625,
['N'] = -0.375, ['N'] = -0.375,
@@ -60,7 +54,9 @@ function Angle( enetety )
['SE'] = 0.375, ['SE'] = 0.375,
['S'] = 0.625, ['S'] = 0.625,
['SW'] = 0.875 ['SW'] = 0.875
} }
function Angle( enetety )
local angle = math.atan2(enetety.position.y,enetety.position.x)/math.pi
for direction, requiredAngle in pairs(directions) do for direction, requiredAngle in pairs(directions) do
if angle < requiredAngle then if angle < requiredAngle then
return direction return direction