Jump to content




Return table n, at table[q]


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

#1 libraryaddict

  • New Members
  • 195 posts

Posted 25 April 2012 - 09:59 PM

A piece of code wants to know if there is anything at table 4, row 14, And there is! But I cant call on it..
if Data4[14] then return Data4[14] end
Thats what I want the program to see

Closest I can get to that is

function checkData(y, x)
  local temp = "Data"..y.."["..x.."]"
  if temp then
	return temp
  else
	return false
  end
end
Data3 = {}
Data3[5] = "hello"
if checkData(3, 5) then
  print(checkData(3, 5))
end

Ofc its churning out Data3[5] not "hello"
So how do I churn out "hello"?

#2 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 25 April 2012 - 10:21 PM

You can try with loadstring, but I don't think it will work.
I think the best way would be to have a Data table, wich has tables inside. Something like this:
local Data = {}
Data[3] = {}
Data[3][5] = "hello"
print(Data[3][5])


#3 libraryaddict

  • New Members
  • 195 posts

Posted 25 April 2012 - 10:34 PM

I think I agree with you MysticT.

It didn't even occur to me to try it that way.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users