[Help] Tables/Arrays
Posted: Mon Sep 17, 2012 2:14 am
I having troubles with this loadSprite function.
It says "Attempt to index field 'Down'"
Anyone can help?
It says "Attempt to index field 'Down'"
Anyone can help?
Code: Select all
myVar = Hello
print(myVar) --> nil
myVar = 'Hello'
print(myVar) --> 'Hello'
Code: Select all
world[char_name] = { Direction = Down, Down = {}, Up = {}, Left = {}, Right = {} }
Code: Select all
world[char_name] = { Direction = 'Down', Down = {}, Up = {}, Left = {}, Right = {} }
Code: Select all
...
v.Direction = Up
...
v.Direction = Down
...
v.Direction = Left
...
v.Direction = Right
...
Code: Select all
...
v.Direction = 'Up'
...
v.Direction = 'Down'
...
v.Direction = 'Left'
...
v.Direction = 'Right'
...
Code: Select all
for k, v in pairs(world) do -- Direction...
if v.still then
love.graphics.drawq(v.sprite, v.Direction[1], v.x, v.y)
else
local weit = math.floor(wait)
love.graphics.drawq(v.sprite, v.Direction[weit], v.x, v.y)
end
Code: Select all
for k, v in pairs(world) do -- Direction...
if v.still then
love.graphics.drawq(v.sprite, v[v.Direction][1], v.x, v.y)
else
local weit = math.floor(wait)
love.graphics.drawq(v.sprite, v[v.Direction][weit], v.x, v.y)
end