This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Left's profile picture

Find String in Table

Started by Left, 22 March 2013 - 10:37 PM
Left #1
Posted 22 March 2013 - 11:37 PM
I am having a mental BLANK. How can I find something in a table for example a randomally generated key which I have put in there.
LordIkol #2
Posted 23 March 2013 - 12:00 AM
This would give you the Place where the searched String is in the table.

local items = { "Hugo", "Karl", "Geerd", "Bananarama" }

for k, v in pairs(items) do
  if v == "Bananarama" then
	print(k)
break --delete this if there are multiple entries
  end
end

Greets Loki
Left #3
Posted 23 March 2013 - 12:08 AM
Thanks. Again about 2:30, I am tired. Goodnight! No moar dev for tonight. I may not be on until the 28th because I will not get my internet back until then!