V
V
Valery Albertovich Zhmyshenko2020-10-15 20:40:16
Lua
Valery Albertovich Zhmyshenko, 2020-10-15 20:40:16

Can I cast objects to a two dimensional lua array?

there is an object like

box = {
    x = 400,
    y = 96,
    w = 16,
    h = 16,
    ySpeed = 0,
    yMaxSpeed = 400,
    onGround = false,
    texture = love.graphics.newImage("box.png")
  }

can I make a two-dimensional array from such objects (to have box1, box2, etc.)?
if I can, how can I get for example the X of the fifth box?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Valery Albertovich Zhmyshenko, 2020-10-15
@DIvan2000

the answer was found by scientific poke, if someone needs this code

box = {{x = 400, y = 96, w = 16, h = 16, ySpeed = 0, yMaxSpeed = 400, onGround = false, texture = love.graphics.newImage("box.png")},{x = 400, y = 96, w = 16, h = 16, ySpeed = 0, yMaxSpeed = 400, onGround = false, texture = love.graphics.newImage("box.png")}}

getting variable X from box with index N
love.graphics.print(box[N].x, 10, 10)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question