I need help with this strange programming language called lua.

principiafreak300 - Custom level - from Android
PlayEditOne player liked this.Log in to like this level.

Why does this not work? I need an 128x128 matrix filled with {0,0,0,1}.

Views: 176 Downloads: 28 Unique objects: 1 Total objects: 1

Parent

Discuss this level

Log in to comment on this level.
  • principiafreak300: @Chad64: Gah. Looked at a fixup in staxkoverflow, but it didn't work. Plus I wasn't notified for you commenting...
  • Chad64: Plus your code is messy, hxct's code is pretty much everything you want in a compact, clean manner
  • Chad64: The problem here is you set texels[128] only, and that means texels[1] and texels2 and so on are considered nil. And if its nil you cant just make a table out of it.

    Here's the code slightly edited:
    function initScreen()
    texels={}
    --game:message(texels[1])
    for i=1,128 do
    texels[i]={}
    texels[i][128]={}
    for j=1,128 do
    this:set_sprite_texel(i-1,j-1,0,0,0,1)
    texels[i][j]={0,0,0,1}
    end
    end
    --this:draw_sprite(0,0,0,20,20,0,0,127,127)
    end




    function init(is_sandbox)
    initScreen()
    end
    function step(count)
    this:draw_sprite(0,0,0,20,20,0,0,127,127)
    end
  • JupiterSky: I have tried tables in tables before, and had major issues. The main one is that we don't have access to everything in lua. That is a pain, however there are still many workarounds we can do, just look on the internet about lua tables in tables. Hope this helps. :D
  • HXCTCreations: texels={}
    for i=1,128 do
    texels[i] = {}
    for j=1,128 do
    this:set_sprite_texel(i-1,j-1,0,0,0,1)
    texels[i][j]={0,0,0,1}
    end
    end
  • JupiterSky: So I did some testing. Tables are not even close to straight forward in lua. You have some sort of error when making a table in a table. Strange...
  • JupiterSky: Strange indeed! Let me see...

LEVEL ID: 26110