Code: Select all
script.on_event(defines.events.on_built_entity, function(event)
if event.created_entity.type == "transport-belt" then
BB_var_name = event.created_entity.name
BB_var_X = event.created_entity.position.x
BB_var_Y = event.created_entity.position.Y
BB_var_dir = event.created_entity.direction
BB_var_force = event.created_entity.force
if game.get_surface(1).can_place_entity{name = BB_var_name, position = {x = (BB_var_X + 1), y = (BB_var_Y)}, direction = BB_var_dir, force = BB_var_force} then
game.get_surface(1).create_entity{name = BB_var_name, position = {x = (BB_var_X + 1), y = (BB_var_Y)}, direction = BB_var_dir, force = BB_var_force}
end
end
end)
Code: Select all
Error while running the event handler: __BeltBrush__/control.lua:11: bad argument #-1 to 'can_place_entity' (number expected, got nil)
Line 11 is the line with can_place_entity in it.
I tried changing the variable to 'defines.direction.north' just for testing, but the same error occurred.
What is it that I'm doing wrong?
Matjojo