I am making a base defense game and I am storing data for my characters in one lua file, I need to access the information in the “units” and “sprites” table of this file:
local units = { local girl = {img = "sprites/girl.png", timeBetweenAtk = 2350} } local sprites = { local girlsprites = { local walkingsprite = { local walkingGirlSheetData = {width = 309, height = 494, numFrames = 10, sheetContentWidth = 1545, sheetContentHeight = 988} local walkingGirl = graphics.newImageSheet("sprites/walking-girl.png", walkingGirlSheetData) local walkingGirlSequenceData = {name = "walking", start = 1, count = 10, loopCount = 0, loopDirection = "forward"} local attackingsprite = { local meleeGirlSheetData = {width = 385, height = 477, numFrames = 10, sheetContentWidth = 1925, sheetContentHeight = 954} local meleeGirl = graphics.newImageSheet("sprites/melee-girl.png", meleeGirlSheetData) local meleeGirlSequenceData = {name = "melee", start = 1, count = 10, loopCount = 0, loopDirection} } } } }
I tried this:
local characters = require "characters" print(characters.units[1].timeBetweenAtk)
But it did not work. Thanks in advance!