I'm trying to identify the name of the floor/tile I'm mining, but using my code below I'm only getting the name tile below the floor/tile I'm mining/picking up.
How should I adjust my code to give me the name of the tile being picked up vs. the tile underneath?
Code: Select all
local function Tile_Remove(event)
local player = game.players[event.player_index]
local robot = event.robot
local surface = player and player.surface or robot.surface
local position = event.positions
for i, position in ipairs(position) do
local currentTilename = surface.get_tile(position.x,position.y).name
writeDebug(currentTilename) <-- My function that prints the name
end
end
local remove_events = {defines.events.on_player_mined_tile, defines.events.on_robot_mined_tile}
script.on_event(remove_events, Tile_Remove)