If you read my last post, you would know that in my game (as of right now) it determines which block is selected by the X position of the white selection box on the hot bar. This means that the "ID"s of the tiles are random numbers such as 202 or 372, so in order to make it easier to use, I made variables for each tile, like this:
Code: Select all
planks = 202
emeraldore = 236
dirt = 270
stone = 304
grass = 338
wood = 372
leaves = 406
Code: Select all
blockdata[block_y][block_x] = grass
Code: Select all
main.lua:195 attempted to index field '?' (a nil value)
What am I doing wrong? It uses the exact same technique to place tiles, I don't understand why it's not working.
Before you download the .love file, here are some things to note while you are looking at it:
in love.update(), the map_load() function is set to only repeat 256 times, (which would give 256 columns of terrain).
I do this by having a variable (called "swag" for now) that increases every cycle, and as long as it's less than 256, it repeats the map_load() every cycle.
I also have it so the block placing function (love.keypressed()) is only functional while "swag" is GREATER than 256, which means you can't place tiles until the world is finished generating.
Just some extra info in case you need it.
I've marked where the error is with --ERROR HERE, at line 195 in main.lua.