This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Create table within another table
#2
Hi,

That is rather easy to do:

mytable = { mysecondtable = { mythirttable = { final = 'end' } } }

Code:
--or add afterwards

mytable = {}
mytable.mysecondtable = {}
mytable.mysecondtable.mythirttable = {}
mytable.mysecondtable.mythirttable.final = 'end'

log(mytable)
Sample:
Code:
profiles = {
  climate = {
    mode = 'comfort',
    temperature = 21.3,
    fanmode = 1
  },
  occupation = {
    unoccupied = {
        cool = 25,
        heat = 18
    },
    occupied = {
      cool = 25,
        heat = 18
    }
  },
  curtain = {
    runtime = 90,
    closed = {
      hour = 17,
      min = 45
    },
    opened = {
      hour = 7,
      min = 30
    }
  },
  reserved = 'not used yet'
}

log(profiles)
log(profiles.climate)
log(profiles.curtain.runtime)
See also: https://www.lua.org/pil/2.5.html

BR,

Erwin
Reply


Messages In This Thread
RE: Create table within another table - by Erwin van der Zwart - 03.08.2020, 20:45

Forum Jump: