Topic: dofile confusion

I have a question regarding dofile. I heard that you couldn't have more than one script in a scene which is a bit sad for me but I guess it's alright if you can do dofile (it actually saves time so you don't have to keep adding all the scripts to a scene).

The only problem is that (I think) when you call it it will run all the code in the script. I only want to run the general stuff once so that memory is allocated and variables have an initial value etc and a value is kept until the next time (say, velocity) and not have it reset every time. So I was thinking maybe there was a way to first call dofile. And then call a function (update) in every file that I want to update. How would I approach this? Or maybe it works that way even if I do dofile over and over again? I'm a bit rusty with the Lua smile

Re: dofile confusion

Maybe it's better to use require?

Re: dofile confusion

just write doFile one time on top of the main script,
then you can call the functions

Re: dofile confusion

Thanks! smile