Nested Table as 2d Array issue
Posted: Wed Jun 15, 2016 11:36 pm
Trying to get this to work. surface.get_tile is giving an error
https://forums.coronalabs.com/topic/174 ... alization/
Used this as a reference, I thought I did the reference correctly, but apperently not.
Code: Select all
bad argument #-2 to 'get_tile' (number expected, got nil)
Used this as a reference, I thought I did the reference correctly, but apperently not.
Code: Select all
if (game.tick % RanaMods.Fishing_Pole.config.spawn.tickRate) == 0 then
for z, surface in pairs(game.surfaces) do
for coord in surface.get_chunks() do
local X,Y = coord.x, coord.y
if surface.is_chunk_generated{X,Y} then
local area = {{X*32, Y*32}, {X*32 + 32, Y*32 + 32}}
-- Quick Method. Select random tile If deep water or Shallow water, 1/60 chance of fish
local selectedTile = {math.random(area[1][1],area[2][1])},{math.random(area[1][2],area[2][2])}
if math.random(1,60) == 60 then
local tileName = surface.get_tile(selectedTile[1],selectedTile[2]).name
if tileName == "water" or tileName == "deepwater" then
create_entity{name = "fish", position = selectedTile, force=game.forces.neutral}
end
end
end
end
end
end