- Edited
I am building a section that takes an array of rooms (filepaths) and shuffles them for randomness. My shuffling and arrays are working fine but I would like to find each level's filepath so it can figure out where it is in the array. Essentially, trying to find the index of an entry in an array for sorting. I have been trying bsearch()
to no avail. On Version 3.5 currently. The "DirectorNode" is a global that holds and shuffles the data and it's working fine.
Essentially, the index will determine what the next scene is to load for the doors. So I just need that number... but it is not working. For some reason I can't get the index number and anytime I search for filepath I am getting totally off variables. I have also tried find()
with no luck.
extends Node2D
var _filepath : String
var _digit : int
var _leftDestination : String
var _rightDestination : String
func _ready():
_population()
_filepath = str(self.filename)
_digit = DirectorNode._finalRoomsArray.bsearch(_filepath)
print(_digit)
func _population():
var _leftDoor = get_node("LeftDoorFinal")
var _rightDoor = get_node("RightDoorFinal")
var _leftDigit = int(_digit-1)
var _rightDigit = int(_digit+1)
if _leftDigit > -1:
_leftDoor._myDestination = DirectorNode._finalRoomsArray[_leftDigit]
else:
_leftDoor._myDestination = "res://scenes/final_area/Final_Start.tscn"
if _rightDigit < 11:
_rightDoor._myDestination = DirectorNode._finalRoomsArray[_rightDigit]
else:
_rightDoor._myDestination = "res://scenes/final_area/Final_End.tscn"