Scripts / How to use [e], (e)

Author
Message
Mortt
8
Years of Service
User Offline
Joined: 16th May 2016
Location:
Posted: 28th May 2016 15:38
What is the difference of (e) and this [e]

I cannot find any ref to this [ ] . When is it used. How is it used.
Help on this would be good.

Still learning LUA script. But this is now problematic as the scripts are getting more complex.
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 28th May 2016 16:30
square brackets
Quote: "[ ]"
are used to show it's an array/table, basically a variable but it can store mutliple amounts of data by using the reference in the [ ] to show which index to use... think of it as a book
i.e. page_number[1] = intro
page_number[2] = "chapter 1"
page_number[3] = "chapter 2"
etc

round brackets
Quote: "( ) "
as used to show it's a function, this can be 1 line of code or more likely lots of code but it can be used lots as long as you supply any needed information (which would be supplied within the (), separated by any comma's if it needs more than 1 value supplied)

e in both (e) and [e] would mean the same thing - the entity number of the entity running/accessing the script at that time.
in the case of arrays e is used as it's the easiest method to remember which table to store that entity's data into rather than trying to keep track of a specific order (and as every entity is given a unique number by the engine there wont be any issues)
in the case of functions e is normally used to show that that specific entity is the one we want to affect by the function (though this would depend on the actual code being run by the function)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Mortt
8
Years of Service
User Offline
Joined: 16th May 2016
Location:
Posted: 28th May 2016 19:07
AH. Yes I think I got it now.
Thank you so much.
It got a bit confusing. When something doesn't work the way I think it should, then look for solutions and that then leads to looking at the smallest things.

Thank you so much.
PM

Login to post a reply

Server time is: 2024-12-22 17:17:45
Your offset time is: 2024-12-22 17:17:45