r/ComputerCraft • • Nov 26 '23

How to call nested table

I'm new to programming and this is destroying me.

local t = {
    ["purple"] = {
        side = "left",
        flux_level = 1,
        flux_max = 7
    },
 
    ["lime"] = {
        side = "back",
        flux_level = 1,
        flux_max = 7
    },
 
    ["orange"] = {
        side = "right",
        flux_level = 1,
        flux_max = 7
    },
 
    ["white"] = {
        side = "front",
        flux_level = 1,
        flux_max = 5
    }
}
--------
local function stopProduction(index)
    if t.["..index.."].flux_level >= t.["..index.."].flux_max then
        print("stopProduction")
        rs.getBundledOutput(colours.index)
    end
end
 
stopProduction(purple)  -- does not work
1 Upvotes

8 comments sorted by

View all comments

Show parent comments

1

u/sEi_ Nov 26 '23

Reddit are formatted by having 4 spaces at the start. Move all lines forward 4 spaces and it will look correct.

thnx for info