Accessing table elements

Post Reply
azure_glass
Posts: 97
Joined: Wed Jul 25, 2012 12:35 pm

Accessing table elements

Post by azure_glass »

Hi, I have something like that:
Code: [show] | [select all] lua
Table = getSpecialExits(RoomNumber)
display(Table)

output: 

 {
  [3069] = {
    ["climb on the wall"] = "0"
  }
}
How i can have acces to "climb on the wall"? To get that in variable?
English is not my native language. If you don't understand what im writing ask. :)
Ubuntu 17.04, Mudlet 3.1

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Accessing table elements

Post by Vadi »

You can either iterate the table or use next() to get a random next key, so:
Code: [show] | [select all] lua
exit = next(select(2, next(getSpecialExits(mmp.currentroom))))
print(exit)

Post Reply