if exist variable?
Moderator: Moderators
- commanderawesome
- Field Commander

- Posts: 971
- Joined: Tue Aug 13, 2013 11:58 pm
- Projects :: Skin Changer - Warfront - Other stuff
- xbox live or psn: AaTc_CmdrAwesome
- Location: The Universe
if exist variable?
Is there an lua variable for whether something exists or not?
-
Noobasaurus
- Droid Pilot Assassin

- Posts: 2006
- Joined: Tue Aug 17, 2010 5:56 pm
Re: if exist variable?
Code: Select all
if ~= nil- commanderawesome
- Field Commander

- Posts: 971
- Joined: Tue Aug 13, 2013 11:58 pm
- Projects :: Skin Changer - Warfront - Other stuff
- xbox live or psn: AaTc_CmdrAwesome
- Location: The Universe
Re: if exist variable?
Next question: Is there a command to stop reading something?
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: if exist variable?
You can exit early from a function using a "return" statement. Is that what you mean?
-
Noobasaurus
- Droid Pilot Assassin

- Posts: 2006
- Joined: Tue Aug 17, 2010 5:56 pm
Re: if exist variable?
If you're talking about ReadDataFile, then no.
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: if exist variable?
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:
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()