How to get Tables values from another Lua Module

I am working on a project. flashObjects.lua file has Table T. I am working with showObjects.lua which has Table S. I have require('flashObjects") in the flashObjects.lua file. However, I am unable to retireve the data from T.lua file from flashObjects.lua file.

Error message is attempt to index ‘t’ (a nil value)

stack traceback

Error message is in the image.

This is where I am getting the error from in showObjects…

-- Pulling only 6 frames from original Image Sheet s = {t[1],t[2],t[3],t[4],t[5],t[6]}

--------------showObjects.lua-------------------

local fruitShuffle = require("TableShuffle") local dragFruits = require("dragObject") local fruits = require("fruits") local flashObjects = ("flashObjects") local fruitSheet = graphics.newImageSheet( "fruits.png", fruits:getSheet() ) -- Pulling only 6 frames from original Image Sheet s = {t[1],t[2],t[3],t[4],t[5],t[6]} -- Shuffle 6 frames order from original Image Sheet shuffleTable = shuffle(s) -- Pulling frames from Shuffle table "s" showFruitsSeqData = {  {name="S1",sheet=fruitSheet,frames={s[1]} }, {name="S2",sheet=fruitSheet,frames={s[2]} }, {name="S3",sheet=fruitSheet,frames={s[3]} }, {name="S4",sheet=fruitSheet,frames={s[4]} }, {name="S5",sheet=fruitSheet,frames={s[5]} }, {name="S6",sheet=fruitSheet,frames={s[6]} } } -- configure size and placement for each frame store in table data showFruitsData =  { {frameIndex=s[1], width=80, height=80, x=50, y=25}, {frameIndex=s[2], width=80, height=80, x=display.contentCenterX, y=25 }, {frameIndex=s[3], width=80, height=80, x=270, y=25 }, {frameIndex=s[4], width=80, height=80, x=50, y=150 }, {frameIndex=s[5], width=80, height=80, x=display.contentCenterX, y=150 }, {frameIndex=s[6], width=80, height=80, x=270, y=150 } } -- Looping the data from the ShowFruitsData Table & enabling objects to to drag for i = 1,#showFruitsData do showFruits = display.newImageRect(  fruitSheet, showFruitsData[i].frameIndex, showFruitsData[i].width, showFruitsData[i].height ) showFruits.x=showFruitsData[i].x showFruits.y=showFruitsData[i].y -- Add touch sensitivity to object showFruits:addEventListener( "touch", dragObj ) end

The Table T is in flashObjects.lua

--------------flashObjects.lua-------------------

local fruitShuffle = require("TableShuffle") local dragFruits = require("dragObject") local fruits = require("fruits") local fruitSheet = graphics.newImageSheet( "fruits.png", fruits:getSheet() ) -- Original number of frames from Fruits Image Sheet  t = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32} return t -- Shuffle frames from orginal Image Sheet shuffleTable = shuffle(t) fruitSeqData = {name="level", sheet=fruitSheet, frames={t[1],t[2],t[3]}, time=1500, loopCount=1, loopdirection="forward"} flashFruits = display.newSprite(fruitSheet, fruitSeqData ) flashFruits.x = display.contentCenterX flashFruits.y = display.contentCenterY flashFruits:play() transition.dissolve( flashFruits, flashFruits, 1, 1250 )

Any help or guidance will be appreciated.

Use a common module as a scratch pad to share values
 
Common Scratch Pad Example
 

-- save as common.lua local public = {} return public

-- save as modA.lua local common = require "common" local public = {} function public.set() common.value = 10 end return public

-- save as modB.lua local common = require "common" local public = {} function public.print() print(common.value) end return public

-- Now test it local modA = require "modA" local modB = require "modB" modB.print() - Prints nil modA.set() modB.print() - Prints 10

You should stop using so many arbitrary  globals too.

One more thing.  Just to clarify.
 
If you want ANY part of your module or the contents of the fie to be visible, that part of the file has to either be attached to the table you return from the module or the thing has to be a global (not great).

-- save in bob.lua local someVar = 10 \_G.otherVar = 20 local public = {} public.yetAnotherVar = 30 public.someValues = {} public.someValues[1] = "a" public.someValues[2] = "b" public.someValues[3] = "c" return public

local bob = require "bob" print( someVar ) -- print nil print( otherVar ) -- prints 20 print( bob.yetAnotherVar ) -- prints 30 print( bob.someValues[2] ) -- prints b

@roaminggamer

The example above works. But when I am trying to show tables values it gives me a weird number and not the values from the table.

Use a common module as a scratch pad to share values
 
Common Scratch Pad Example
 

-- save as common.lua local public = {} return public

-- save as modA.lua local common = require "common" local public = {} function public.set() common.value = 10 end return public

-- save as modB.lua local common = require "common" local public = {} function public.print() print(common.value) end return public

-- Now test it local modA = require "modA" local modB = require "modB" modB.print() - Prints nil modA.set() modB.print() - Prints 10

You should stop using so many arbitrary  globals too.

One more thing.  Just to clarify.
 
If you want ANY part of your module or the contents of the fie to be visible, that part of the file has to either be attached to the table you return from the module or the thing has to be a global (not great).

-- save in bob.lua local someVar = 10 \_G.otherVar = 20 local public = {} public.yetAnotherVar = 30 public.someValues = {} public.someValues[1] = "a" public.someValues[2] = "b" public.someValues[3] = "c" return public

local bob = require "bob" print( someVar ) -- print nil print( otherVar ) -- prints 20 print( bob.yetAnotherVar ) -- prints 30 print( bob.someValues[2] ) -- prints b

@roaminggamer

The example above works. But when I am trying to show tables values it gives me a weird number and not the values from the table.