Using dofile() ?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Ensayia
Party member
Posts: 399
Joined: Sat Jun 12, 2010 7:57 pm

Re: Using dofile() ?

Post by Ensayia »

is there some specific reason you need to use dofile()? Otherwise, what's wrong with simply requiring a file? Perhaps you can explain a bit better why you require the function and include a .love? (Really though, read the forum rules)

Also I know I'm a nitpicking asshole but the word is spelled Lua and not LUA. It is its own word and not an acronym. For some reason it really grinds my gears when people do that...
Wombat
Prole
Posts: 31
Joined: Mon Oct 03, 2011 8:38 pm

Re: Using dofile() ?

Post by Wombat »

is there some specific reason you need to use dofile()?
I want to close the script, i am currently in and want to open a new script. This is simply what i want to do.^^
User avatar
miko
Party member
Posts: 410
Joined: Fri Nov 26, 2010 2:25 pm
Location: PL

Re: Using dofile() ?

Post by miko »

Wombat wrote:
is there some specific reason you need to use dofile()?
I want to close the script, i am currently in and want to open a new script. This is simply what i want to do.^^
But why? Or, what you really want to do? Please follow the 5 Whys path: http://en.wikipedia.org/wiki/5_Whys
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
User avatar
kraftman
Party member
Posts: 277
Joined: Sat May 14, 2011 10:18 am

Re: Using dofile() ?

Post by kraftman »

Yeh please try and provide a bit more information with your questions, as you'll get more help, and the help you get will be more relevant.
Wombat
Prole
Posts: 31
Joined: Mon Oct 03, 2011 8:38 pm

Re: Using dofile() ?

Post by Wombat »

Ok, i created a game with many scripts for another lua wrapper. Now i am going to convert my scripts for LÖVE andru it´s still works good.

I did my code in different scripts to have a better overview of my big project. With the lua wrapper i used before, changing the scripts where no problem, simply dofile("Script.lua"). But now for me, it is a bit complicated to change the script. Yes there´s is require, but require doesn´t close the current script and open a new one it only open a new script besides the current running.

Yes, i could write my code in a way that works with require. But it would be more work to convert it to LÖVE. So i simply ask you if it´s possible to simply change the scripts in LÖVE and close the current one.

When not, then it´s ok. Then i have to make the code with require. But first i have to check out if i can manage this with less work^^.

Thanks in advance and thanks for your help so far. :)
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Using dofile() ?

Post by bartbes »

dofile does not end the execution of the script any more than either l.fs.load()() or require does.
Wombat
Prole
Posts: 31
Joined: Mon Oct 03, 2011 8:38 pm

Re: Using dofile() ?

Post by Wombat »

yes, but when you combine dofile() with collectgarbage() and with setting all non-relevant variables to nil...
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Using dofile() ?

Post by Robin »

Still nothing magic about dofile().
Help us help you: attach a .love.
Wombat
Prole
Posts: 31
Joined: Mon Oct 03, 2011 8:38 pm

Re: Using dofile() ?

Post by Wombat »

Ok, can you tell me a way to solve my problem then? ^^
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Using dofile() ?

Post by bartbes »

Well,

Code: Select all

dofile("some.lua")
is technically equal to:

Code: Select all

love.filesystem.load("some.lua")()
Post Reply

Who is online

Users browsing this forum: No registered users and 83 guests