Hi,
First test
When I try this script all the lines adds as item in the dropdown list 26 times. What am I doing wrong?
extends OptionButton
onready var file = 'res://bilhandtering.txt'
func _ready():
load_file(file)
func load_file(file):
var f = File.new()
f.open(file, File.READ)
while not f.eof_reached():
var line = f.get_line()
for item in line:
add_item(line)
f.close()
return
Second test
When I use csv below the dropdown list gets populated ok except for that there is a space gap of 32 options and then it repeat the first items in the csv file.
extends OptionButton
var LevelFileName="res://bilhandtering.csv"
func _ready():
var riga = []
var csv=File.new()
csv.open("res://bilhandtering.csv",File.READ)
riga=csv.get_csv_line(";")
while not csv.eof_reached():
for item in riga:
add_item(item)
riga=csv.get_csv_line(";")
pass