Jump to content




How To Use Tables.


  • You cannot reply to this topic
37 replies to this topic

#21 Fedkiv

  • New Members
  • 2 posts

Posted 12 December 2013 - 09:13 PM

since I havent found anything clear enough I want to ask it here now -> how do you exactly use it? I know how to set it up but do you activate it when a SAM is trying to lock you, or after he shoot its missile? And if you really can confuse the missiles with the ECM and you are very low to the ground could the ECM make it crash against the ground?

My English isnt the best but hopefully understandable

Thanks

#22 SuperKomputerKid

  • Members
  • 10 posts
  • LocationThe US of A

Posted 08 March 2014 - 01:57 AM

Thanks for sharing!

#23 IsaacTBeast

  • Members
  • 86 posts
  • LocationI 'm inside your brian

Posted 16 March 2014 - 02:22 AM

How do you execute a table?

#24 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 16 March 2014 - 02:40 AM

View PostIsaacTBeast, on 16 March 2014 - 02:22 AM, said:

How do you execute a table?
I thought you knew Lua? You don't execute a table, in fact you don't 'execute' anything in programming; the term you're probably looking for is 'call' or 'invoke', but in either case you still do neither for a table. A table is a data structure similar to Associative Arrays in other languages, it is simply a place to store information.

Edited by theoriginalbit, 16 March 2014 - 02:40 AM.


#25 CometWolf

  • Members
  • 1,283 posts

Posted 16 March 2014 - 10:14 AM

Well technically you could call a table if it has a __call metamethod, but that's probably not very relevant to whatever Issac is doing.

#26 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 16 March 2014 - 10:15 AM

[redacted]

Edited by theoriginalbit, 16 March 2014 - 10:16 AM.


#27 sjones321

  • Members
  • 9 posts

Posted 16 March 2014 - 06:40 PM

While it might not have covered everything to do with tables, I still thought this was a very well written introductory tutorial to tables.

#28 MostwantedRBX

  • Members
  • 29 posts
  • LocationWell. I suppose between here and there.

Posted 19 March 2014 - 08:01 PM

View Posttheoriginalbit, on 16 March 2014 - 02:40 AM, said:

View PostIsaacTBeast, on 16 March 2014 - 02:22 AM, said:

How do you execute a table?
I thought you knew Lua? You don't execute a table, in fact you don't 'execute' anything in programming; the term you're probably looking for is 'call' or 'invoke', but in either case you still do neither for a table. A table is a data structure similar to Associative Arrays in other languages, it is simply a place to store information.

I thought you could do this, if you really wanted to:
MyTable = {
PrintStuff = function(Stuff)
print(Stuff)
end
}
MyTable.PrintStuff("Hello, World!")
That is technically calling a table. ;D

EDIT:
I think this is a great tutorial for beginners, OP. Good going.

Edited by MostwantedRBX, 19 March 2014 - 08:02 PM.


#29 CometWolf

  • Members
  • 1,283 posts

Posted 19 March 2014 - 08:06 PM

You're calling a function stored in a table, not the table itself. To call a table you'll need a __call metamethod.

#30 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 19 March 2014 - 10:49 PM

View PostMostwantedRBX, on 19 March 2014 - 08:01 PM, said:

MyTable = {
PrintStuff = function(Stuff)
print(Stuff)
end
}
MyTable.PrintStuff("Hello, World!")
That is technically calling a table. ;D
technically that is accessing an entry in a table and then if the entry exists and is a function it invokes said function.

#31 MostwantedRBX

  • Members
  • 29 posts
  • LocationWell. I suppose between here and there.

Posted 19 March 2014 - 10:58 PM

View Posttheoriginalbit, on 19 March 2014 - 10:49 PM, said:

View PostMostwantedRBX, on 19 March 2014 - 08:01 PM, said:

MyTable = {
PrintStuff = function(Stuff)
print(Stuff)
end
}
MyTable.PrintStuff("Hello, World!")
That is technically calling a table. ;D
technically that is accessing an entry in a table and then if the entry exists and is a function it invokes said function.

Lol, I suppose. From the computing definitions I've seen from google(Yep, I looked it up), calling is to cause the execution of, and accessing is to obtain, examine or retrieve. :P

Edited by MostwantedRBX, 19 March 2014 - 10:59 PM.


#32 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 19 March 2014 - 11:03 PM

View PostMostwantedRBX, on 19 March 2014 - 10:58 PM, said:

Lol, I suppose. From the computing definitions I've seen from google(Yep, I looked it up), calling is to cause the execution of, and accessing is to obtain, examine or retrieve. :P
Precisely. Take it from the Software Engineer, the code you've got there is definitely not invoking the table. Here's an example of some (advanced) code that invokes a table to get an index; i.e. allows tData(1) (normal brackets means invocation/calling) to work as though you typed tData[1] (square brackets means access)
local tData = setmetatable({"hello", "world"}, {
  __call = function(t, i)
	return t[i]
  end
})
As stated, it allows you do do the following
print(tData[1]) --# outputs: hello
print(tData(1)) --# outputs: hello

Edited by theoriginalbit, 19 March 2014 - 11:04 PM.


#33 MostwantedRBX

  • Members
  • 29 posts
  • LocationWell. I suppose between here and there.

Posted 19 March 2014 - 11:19 PM

View Posttheoriginalbit, on 19 March 2014 - 11:03 PM, said:

View PostMostwantedRBX, on 19 March 2014 - 10:58 PM, said:

Lol, I suppose. From the computing definitions I've seen from google(Yep, I looked it up), calling is to cause the execution of, and accessing is to obtain, examine or retrieve. :P
Precisely. Take it from the Software Engineer, the code you've got there is definitely not invoking the table. Here's an example of some (advanced) code that invokes a table to get an index; i.e. allows tData(1) (normal brackets means invocation/calling) to work as though you typed tData[1] (square brackets means access)
local tData = setmetatable({"hello", "world"}, {
  __call = function(t, i)
	return t[i]
  end
})
As stated, it allows you do do the following
print(tData[1]) --# outputs: hello
print(tData(1)) --# outputs: hello

Ah, I haven't learned to use metatables effectively yet. I'm keeping busy learning other languages, too, like Java, C++ and Python, so I haven't really had the time. It may be worthwhile to do so, though. I shoot from place to place, lol.

#34 apemanzilla

  • Members
  • 1,421 posts

Posted 21 March 2014 - 04:48 PM

View PostMostwantedRBX, on 19 March 2014 - 11:19 PM, said:

View Posttheoriginalbit, on 19 March 2014 - 11:03 PM, said:

View PostMostwantedRBX, on 19 March 2014 - 10:58 PM, said:

Lol, I suppose. From the computing definitions I've seen from google(Yep, I looked it up), calling is to cause the execution of, and accessing is to obtain, examine or retrieve. :P
Precisely. Take it from the Software Engineer, the code you've got there is definitely not invoking the table. Here's an example of some (advanced) code that invokes a table to get an index; i.e. allows tData(1) (normal brackets means invocation/calling) to work as though you typed tData[1] (square brackets means access)
local tData = setmetatable({"hello", "world"}, {
  __call = function(t, i)
	return t[i]
  end
})
As stated, it allows you do do the following
print(tData[1]) --# outputs: hello
print(tData(1)) --# outputs: hello

Ah, I haven't learned to use metatables effectively yet. I'm keeping busy learning other languages, too, like Java, C++ and Python, so I haven't really had the time. It may be worthwhile to do so, though. I shoot from place to place, lol.
Meta tables are definitely some of the more powerful abilities of Lua. Technically, even with the code above, you're still not calling the table; you're calling it's __call metamethod. If that makes sense :P

#35 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 22 March 2014 - 12:22 AM

View PostApemanzilla, on 21 March 2014 - 04:48 PM, said:

Technically, even with the code above, you're still not calling the table; you're calling it's __call metamethod. If that makes sense :P
Yeah kinda, the metamethods are considered to be a part of the table however, so by sheer technicality you are correct.

Edited by theoriginalbit, 22 March 2014 - 12:23 AM.


#36 apemanzilla

  • Members
  • 1,421 posts

Posted 23 March 2014 - 03:59 PM

View Posttheoriginalbit, on 22 March 2014 - 12:22 AM, said:

View PostApemanzilla, on 21 March 2014 - 04:48 PM, said:

Technically, even with the code above, you're still not calling the table; you're calling it's __call metamethod. If that makes sense :P/>
Yeah kinda, the metamethods are considered to be a part of the table however, so by sheer technicality you are correct.
I guess it all depends on how technical you want to be :)

#37 ncfriend

  • New Members
  • 1 posts

Posted 29 March 2014 - 11:46 AM

When i use lua(), and run a function, it sometimes spits out "table: 2de4a71" (the numbers and letters are random) How do you get verbatim output out of it?

View PostApemanzilla, on 21 March 2014 - 04:48 PM, said:

View PostMostwantedRBX, on 19 March 2014 - 11:19 PM, said:

View Posttheoriginalbit, on 19 March 2014 - 11:03 PM, said:

View PostMostwantedRBX, on 19 March 2014 - 10:58 PM, said:

Lol, I suppose. From the computing definitions I've seen from google(Yep, I looked it up), calling is to cause the execution of, and accessing is to obtain, examine or retrieve. :P/>
Precisely. Take it from the Software Engineer, the code you've got there is definitely not invoking the table. Here's an example of some (advanced) code that invokes a table to get an index; i.e. allows tData(1) (normal brackets means invocation/calling) to work as though you typed tData[1] (square brackets means access)
local tData = setmetatable({"hello", "world"}, {
  __call = function(t, i)
	return t[i]
  end
})
As stated, it allows you do do the following
print(tData[1]) --# outputs: hello
print(tData(1)) --# outputs: hello

Ah, I haven't learned to use metatables effectively yet. I'm keeping busy learning other languages, too, like Java, C++ and Python, so I haven't really had the time. It may be worthwhile to do so, though. I shoot from place to place, lol.
Meta tables are definitely some of the more powerful abilities of Lua. Technically, even with the code above, you're still not calling the table; you're calling it's __call metamethod. If that makes sense :P/>
I haven't ever heard of metatables before, that's cool!

#38 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 29 March 2014 - 11:25 PM

View Postncfriend, on 29 March 2014 - 11:46 AM, said:

I haven't ever heard of metatables before, that's cool!
Yes metatables are very cool and can allow you to do some very powerful things; I do however suggest not using the code that I posted, while 'cool' it is very bad practise! I just made the code to prove a point :P

Edited by theoriginalbit, 29 March 2014 - 11:26 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users