Scripts / [LUA Video Tutorial] Here's how to access LUA tables (arrays) and using them to kill 5 zombies to open door

Author
Message
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 9th Sep 2017 11:25 Edited at: 26th Sep 2017 08:01
If you want to learn LUA and want to know how to put LUA tables (can also be referred to as lists or arrays) to practical use, here's a link to a video showing how to set up global tables and access the key identifiers/elements within those tables. In this tutorial, I have set up a small GameGuru level with 5 zombies. Upon killing all of the zombies, the door opens allowing you to get to the next level. Not that exciting but might help shed some light on how to get independant scripts talking to each other if you are finding LUA a bit baffling. The video goes into FPI scripts a little bit, so you can skip to the LUA part if you want.

https://forum.game-guru.com/thread/218497#msg2585569
Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, C#, VB, SQL, PL-SQL, JavaScript, HTML, Three.js, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; 12GB.
FPSC to GameGuru Tools: AutoWelder/SegAutoWelder, Entity+Weapon Welder, FPEtoBAT
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 9th Sep 2017 12:29
Lists, they're called Lists not tables or arrays, Lists!
Been there, done that, got all the T-Shirts!
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 9th Sep 2017 12:51
Quote: "Lists, they're called Lists not tables or arrays, Lists! "

if you say so
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 9th Sep 2017 12:56 Edited at: 9th Sep 2017 12:56
ha NO, they are called tables (representing lists etc):

an excerpt from LUA.ORG:

Quote: "
Tables are the sole data-structuring mechanism in Lua; they can be used to represent ordinary arrays, lists, symbol tables, sets, records, graphs, trees, etc. To represent records, Lua uses the field name as an index. The language supports this representation by providing a.name as syntactic sugar for a["name"]. There are several convenient ways to create tables in Lua (see §3.4.9).

Like indices, the values of table fields can be of any type. In particular, because functions are first-class values, table fields can contain functions. Thus tables can also carry methods (see §3.4.11).

The indexing of tables follows the definition of raw equality in the language. The expressions a[i] and a[j] denote the same table element if and only if i and j are raw equal (that is, equal without metamethods). In particular, floats with integral values are equal to their respective integers (e.g., 1.0 == 1). To avoid ambiguities, any float with integral value used as a key is converted to its respective integer. For instance, if you write a[2.0] = true, the actual key inserted into the table will be the integer 2. (On the other hand, 2 and "2" are different Lua values and therefore denote different table entries.)

"


they don't call em LISTS, but LISTS, ARRAYS, TABLES, it's the same thing.. and as it's my thread I'm calling em tables ha
Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, C#, VB, SQL, PL-SQL, JavaScript, HTML, Three.js, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; 12GB.
FPSC to GameGuru Tools: AutoWelder/SegAutoWelder, Entity+Weapon Welder, FPEtoBAT
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 9th Sep 2017 13:13
Roberto only has himself to blame, just took a look back at the early reference manual and indeed he refers to them as tables and 'associative arrays' but in his later material he prefers to refer to them as lists, probably to try and stop people confusing them with similar structures in other languages (although Python also uses 'lists' to refer to something different).

Oh well, if the great man himself can refer to them by different names then I suppose everyone else can as well.

Been there, done that, got all the T-Shirts!
PM

Login to post a reply

Server time is: 2024-04-26 03:50:44
Your offset time is: 2024-04-26 03:50:44