Some LUA syntax help

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
jangoisbaddest
Lieutenant General
Lieutenant General
Posts: 661
Joined: Mon Feb 27, 2006 12:10 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: All Along The Watchtower

Some LUA syntax help

Post by jangoisbaddest »

I just wanted to clear up some basic syntax questions I have as I read over the plethora of material both in the assets and on this site:

1) Normally I would have thought that if you say "TestVariable = 3", that would set the value of that variable to 3....but I have used a code from Archer01 (that works) which does the following: "local supportTeam = 3", which means that 3 is indeed a variable in this case; and if that is the case, how then, can one store a new variable with a value of 3?

2) What is the purpose of using "local" before defining a variable?

I probably had more questions, but I'm too tired to remember them at the moment.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Post by Maveritchell »

variable = [insertnumber]

Not sure what the confusion is, since in both cases the variable is on the left side of the equality.

I dunno about "local," it probably just denotes a variable specific to a small section of code.
User avatar
jangoisbaddest
Lieutenant General
Lieutenant General
Posts: 661
Joined: Mon Feb 27, 2006 12:10 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: All Along The Watchtower

Post by jangoisbaddest »

Maveritchell wrote:Not sure what the confusion is, since in both cases the variable is on the left side of the equality.
As I said, it appears to me that 3 is meant to be taken as the 3rd team, rather than an actual value for the variable. That is what is confusing me (it may have something to do with the "local" statement though).
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Post by Ace_Azzameen_5 »

local means inside that function only (ScriptInit?) and not available to the rest of the LUA, as far as I know.

Support team? Is that from my post asking of linking two teams together? Maybe some more code is needed for us to get the context.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Post by Maveritchell »

jangoisbaddest wrote:
Maveritchell wrote:Not sure what the confusion is, since in both cases the variable is on the left side of the equality.
As I said, it appears to me that 3 is meant to be taken as the 3rd team, rather than an actual value for the variable. That is what is confusing me (it may have something to do with the "local" statement though).
The number "3" is still just a numeric value. It's just that when the game asks for a team and is given a variable equal to 3, it equates it to the third team.
Post Reply