positions should always be iterables, not separate X and Y values. #178

Closed
opened 2026-01-05 01:30:27 +00:00 by john · 1 comment
Owner

The ghost of #126 is haunting me.

Summary: Separate x, y Arguments in Python API

The investigation found several categories of separate x, y usage:

Callbacks (5 types)

All pass (x, y, button, action) or (x, y):

Callback Signature File
on_click (x: int, y: int, button: str, action: str) PyCallable.cpp:52
on_enter (x: int, y: int, button: str, action: str) UIDrawable.h:41
on_exit (x: int, y: int, button: str, action: str) UIDrawable.h:42
on_move (x: int, y: int, button: str, action: str) UIDrawable.h:43
on_cell_* (cell_x: int, cell_y: int) UIGrid.cpp:2085-2090

Grid Pathfinding Methods (8 methods)

All use separate coordinates:

  • Grid.at(x, y) - also accepts tuple
  • Grid.compute_fov(x, y, radius, ...)
  • Grid.is_in_fov(x, y)
  • Grid.find_path(x1, y1, x2, y2, ...)
  • Grid.compute_dijkstra(root_x, root_y, ...)
  • Grid.get_dijkstra_distance(x, y)
  • Grid.get_dijkstra_path(x, y)
  • Grid.compute_astar_path(x1, y1, x2, y2, ...)

Layer Methods (4 methods)

  • ColorLayer.at(x, y) / ColorLayer.set(x, y, color)
  • TileLayer.at(x, y) / TileLayer.set(x, y, index)

Automation Module (10+ functions)

All mouse operations use separate x, y:

  • moveTo(x, y), moveRel(xOffset, yOffset)
  • click(x, y), rightClick(x, y), doubleClick(x, y)
  • dragTo(x, y), dragRel(xOffset, yOffset)
  • scroll(clicks, x, y)
  • mouseDown(x, y), mouseUp(x, y)
  • onScreen(x, y) → bool
  • position() → returns (x, y) tuple (!)

Movement/Sizing Methods

  • Drawable.move(dx, dy) - PyDrawable.cpp:133
  • Drawable.resize(width, height) - PyDrawable.cpp:145

Entity Methods

  • Entity.at(x, y) - UIEntity.cpp:99
  • Entity.path_to(target_x, target_y) - UIEntity.cpp:597

Objective

mcrfpy.Vector or tuple are acceptable outputs; vector or iterables are preferred inputs.

Dual Input Support

Grid.at() is unique in accepting EITHER separate x, y OR a single (x, y) tuple. I think this pattern is acceptable only where (x, y) are the only inputs.

The ghost of #126 is haunting me. # Summary: Separate x, y Arguments in Python API The investigation found several categories of separate x, y usage: ## Callbacks (5 types) All pass (x, y, button, action) or (x, y): | Callback | Signature | File | |-----------|--------------------------------------------|----------------------| | on_click | (x: int, y: int, button: str, action: str) | PyCallable.cpp:52 | | on_enter | (x: int, y: int, button: str, action: str) | UIDrawable.h:41 | | on_exit | (x: int, y: int, button: str, action: str) | UIDrawable.h:42 | | on_move | (x: int, y: int, button: str, action: str) | UIDrawable.h:43 | | on_cell_* | (cell_x: int, cell_y: int) | UIGrid.cpp:2085-2090 | ## Grid Pathfinding Methods (8 methods) All use separate coordinates: - Grid.at(x, y) - also accepts tuple - Grid.compute_fov(x, y, radius, ...) - Grid.is_in_fov(x, y) - Grid.find_path(x1, y1, x2, y2, ...) - Grid.compute_dijkstra(root_x, root_y, ...) - Grid.get_dijkstra_distance(x, y) - Grid.get_dijkstra_path(x, y) - Grid.compute_astar_path(x1, y1, x2, y2, ...) ## Layer Methods (4 methods) - ColorLayer.at(x, y) / ColorLayer.set(x, y, color) - TileLayer.at(x, y) / TileLayer.set(x, y, index) ## Automation Module (10+ functions) All mouse operations use separate x, y: - moveTo(x, y), moveRel(xOffset, yOffset) - click(x, y), rightClick(x, y), doubleClick(x, y) - dragTo(x, y), dragRel(xOffset, yOffset) - scroll(clicks, x, y) - mouseDown(x, y), mouseUp(x, y) - onScreen(x, y) → bool - position() → returns (x, y) tuple (✅!) ## Movement/Sizing Methods - Drawable.move(dx, dy) - PyDrawable.cpp:133 - Drawable.resize(width, height) - PyDrawable.cpp:145 ## Entity Methods - Entity.at(x, y) - UIEntity.cpp:99 - Entity.path_to(target_x, target_y) - UIEntity.cpp:597 # Objective `mcrfpy.Vector` or `tuple` are acceptable outputs; vector or iterables are preferred inputs. ## Dual Input Support Grid.at() is unique in accepting EITHER separate x, y OR a single (x, y) tuple. I think this pattern is acceptable only where (x, y) are the only inputs.
john changed title from [Leader Issue] positions should always be iterables, not separate X and Y values. to positions should always be iterables, not separate X and Y values. 2026-01-05 15:10:23 +00:00
Author
Owner

commit: d2e4791

commit: d2e4791
john closed this issue 2026-01-05 18:13:47 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
john/McRogueFace#178
No description provided.