I’m not sure, not having a good grasp on python, but it looks like youre trying to import the blender section of python instead of the bge part. You cant use the blender modules in real time
He has a method to break out of the loop (the if len(line)==0) but you could just do while len(line) != 0 instead.
You might need to import things like file, and some sort of read/write function? I’ve always just used pickle.
A few things:
datetime is a weird, weird class, and it doesn’t seem to store the methods for creating instances inside of just datetime. In order to use the now() function, you have to do either
import datetime
a = datetime.datetime.now()
or
from datetime import *
a = datetime.now()
You also call your first variable data_recorded, but then try and write date_recorded.
To read again from the file, you have to re-open it with
It is better to give up this script, it very difficult. I’ll try another way. Does anyone know if this is possible:
I have a text, then write a name, I click enter, that line, write another name. If this line is equal to one of the previous lines triggers the actuator.
I apologize for the many doubts about python, because I do not understand almost nothing.
Thanks guys