0 votes

Hello,
I'm trying to extract from a file a float and an int
for the float I have nothing in return and for the int wrong values in 8,16,32 bits

a file;

0.1/r
4/r

func chargement_fichier():
file = File.new()
file.open("/Users/pat 1/Desktop/manglais.txt",File.READ)
i=file.get_error()

vers = file.get_float()
nbrenr = file.get_8()

I'm looking for examples
Thank you.

asked Nov 18, 2019 in Engine by vivid (27 points)

1 Answer

0 votes

The get_float() and get_8() methods are for getting binary stored data. Your file is obviously a text file. So just read the strings with get_line() and assign them to your variables.

https://docs.godotengine.org/en/3.1/classes/class_file.html#class-file-method-get-float

answered Nov 18, 2019 by wombatstampede (3,193 points)

of course !! .. yes load them in 'string' to convert them to 'int'
thank you for waking me up :-)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.