if exist variable?

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
commanderawesome
Field Commander
Field Commander
Posts: 971
Joined: Tue Aug 13, 2013 11:58 pm
Projects :: Skin Changer - Warfront - Other stuff
Games I'm Playing :: SWBF SWTOR KotOR EaW
xbox live or psn: AaTc_CmdrAwesome
Location: The Universe

if exist variable?

Post by commanderawesome »

Is there an lua variable for whether something exists or not?
Noobasaurus
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2006
Joined: Tue Aug 17, 2010 5:56 pm

Re: if exist variable?

Post by Noobasaurus »

Code: Select all

if ~= nil
User avatar
commanderawesome
Field Commander
Field Commander
Posts: 971
Joined: Tue Aug 13, 2013 11:58 pm
Projects :: Skin Changer - Warfront - Other stuff
Games I'm Playing :: SWBF SWTOR KotOR EaW
xbox live or psn: AaTc_CmdrAwesome
Location: The Universe

Re: if exist variable?

Post by commanderawesome »

Next question: Is there a command to stop reading something?
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: if exist variable?

Post by [RDH]Zerted »

You can exit early from a function using a "return" statement. Is that what you mean?
Noobasaurus
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2006
Joined: Tue Aug 17, 2010 5:56 pm

Re: if exist variable?

Post by Noobasaurus »

If you're talking about ReadDataFile, then no.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: if exist variable?

Post 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()
Post Reply