diff --git a/PlayerScript.gd b/PlayerScript.gd index 597a469..013258b 100644 --- a/PlayerScript.gd +++ b/PlayerScript.gd @@ -60,6 +60,8 @@ var IntersectionDir = [] var IntersectionMove = 0 var IntOptions = [] var CurrentInt = "" +var InverNext = false +var InvertionArray = [] func _input(event): if Current_Position != TargetCord: @@ -99,6 +101,7 @@ func _process(delta): MoveAfterIntersection() IntersectionWaysAvailable() IntersectionDumping() + #print(InverNext) else: print("We Done!!!!!!!!!!!!!!!!!!!!!!!") @@ -277,7 +280,7 @@ func GiveOrder(): TrackIntersections() if Detail_Dict.Been_There == false: Ordered_Commands_Backward.push_back(Prev_dir_Opp) - if Detail_Dict.Type != "Plain Path": + if Detail_Dict.Type != "Plain Path" and Intersections.size() > 1: TakeOut = (Cords.size() - Cords.find(Intersections[-2])) var test = Ordered_Commands_Backward.slice(0 , TakeOut) test.reverse() @@ -294,23 +297,40 @@ func TrackIntersections(): func MoveAfterIntersection(): if move == IntersectionMove+1: - if Move_Check6 != move: - if TrackBack.size() != 1 and BackTrack_Array.size() > 1: - IntersectionDir.push_back(LogDumpOrdered[0]) - if BackTrack_Array[-1] - BackTrack_Array[-2] == 1: + if InverNext == false: + if Move_Check6 != move: + if TrackBack.size() != 1 and BackTrack_Array.size() > 1: + IntersectionDir.push_back(LogDumpOrdered[0]) + if BackTrack_Array.size() > 1 and BackTrack_Array[-1] - BackTrack_Array[-2] == 1: + InvertionArray.pop_back() + InverNext = true + else: + InverNext = false + else: + IntersectionDir.push_back(LogDump[0]) + if BackTrack_Array.size() > 1 and BackTrack_Array[-1] - BackTrack_Array[-2] == 1: + InvertionArray.pop_back() + InverNext = true + + elif BackTrack_Array.size() > 1 and BackTrack_Array[-1] - BackTrack_Array[-2] != 1: + InverNext = false + + InvertionArray.push_back(InverNext) + CallingDir() + if InvertionArray.size() > 1 and InvertionArray[-2] == true and InvertionArray[-1] == false: print(Prev_dir_Opp) + if InvertionArray.size() >1 and InvertionArray[-1] == true and InvertionArray[-2] == false: + print(Prev_dir_Opp) + else: print(Prev_dir) - else: - IntersectionDir.push_back(LogDump[0]) - if BackTrack_Array.size() > 1 and BackTrack_Array[-1] - BackTrack_Array[-2] == 1: - print(Prev_dir_Opp) - else: - print(Prev_dir) - CallingDir() - print("The Test is here !!!", IntOptions) - Move_Check6 = move - + print(InvertionArray) + #print("The Test is here !!!", IntOptions) + Move_Check6 = move + else: + InverNext = false + MoveAfterIntersection() + func CallingDir(): if Intersections.find(Current_Position) != -1 and IntOptions.size() > 1: print(IntOptions[Intersections.find(Current_Position)-1])