mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
Merge pull request #172 from tovernaar123/feature/rename_changes
This will fix the bug where already named station get renamed
This commit is contained in:
@@ -21,13 +21,29 @@ local function Angle(entity)
|
|||||||
return direction
|
return direction
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return 'W'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local custom_string = ' *'
|
||||||
|
local custom_string_len = #custom_string
|
||||||
|
|
||||||
local function station_name_changer(event)
|
local function station_name_changer(event)
|
||||||
local entity = event.created_entity
|
local entity = event.created_entity
|
||||||
local name = entity.name
|
local name = entity.name
|
||||||
|
if name == "entity-ghost" then
|
||||||
|
if entity.ghost_name ~= "train-stop" then return end
|
||||||
|
local backername = entity.backer_name
|
||||||
|
if backername ~= '' then
|
||||||
|
entity.backer_name = backername..custom_string
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif name == "train-stop" then --only do the event if its a train stop
|
||||||
|
local backername = entity.backer_name
|
||||||
|
if backername:sub(-custom_string_len) == custom_string then
|
||||||
|
entity.backer_name = backername:sub(1, -custom_string_len)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if name == "train-stop" then --only do the event if its a train stop
|
|
||||||
local boundingBox = entity.bounding_box
|
local boundingBox = entity.bounding_box
|
||||||
-- expanded box for recourse search:
|
-- expanded box for recourse search:
|
||||||
local bounding2 = { {boundingBox.left_top.x -100 ,boundingBox.left_top.y -100} , {boundingBox.right_bottom.x +100, boundingBox.right_bottom.y +100 } }
|
local bounding2 = { {boundingBox.left_top.x -100 ,boundingBox.left_top.y -100} , {boundingBox.right_bottom.x +100, boundingBox.right_bottom.y +100 } }
|
||||||
|
|||||||
Reference in New Issue
Block a user