Page 1 of 1

if exist variable?

Posted: Sun Jan 25, 2015 10:23 pm
by commanderawesome
Is there an lua variable for whether something exists or not?

Re: if exist variable?

Posted: Sun Jan 25, 2015 10:55 pm
by Noobasaurus

Code: Select all

if ~= nil

Re: if exist variable?

Posted: Mon Jan 26, 2015 2:15 pm
by commanderawesome
Next question: Is there a command to stop reading something?

Re: if exist variable?

Posted: Thu Jan 29, 2015 11:38 pm
by [RDH]Zerted
You can exit early from a function using a "return" statement. Is that what you mean?

Re: if exist variable?

Posted: Fri Jan 30, 2015 12:04 am
by Noobasaurus
If you're talking about ReadDataFile, then no.

Re: if exist variable?

Posted: Fri Jan 30, 2015 12:39 pm
by [RDH]Zerted
You should also be able to put a return in the file. You can't stop ReadDataFile from the code that called it, but the file being read can say its finished by returning.

If doing a simple return doesn't work, then change the file being read to something like:

Code: Select all

local myFun = function()
    --(original file contents goes here)
    if we-want-to-skip-the-rest-of-the-file then
        return
    end
   --(more of the original file contents)
end

myFun()