OverviewFilesCommitsIssuesDocsReleasesPeers

hyper-tps / scenes / test / _repro_box_grid.gd

66 lines · gd ref:
extends SceneTree
## REPRO (user report 2026-10-02, 0.1295.0): with the box tool up (N), = / - "don't make
## the cube bigger". Real map_flat, a floor brush, a camera aimed at it; read the box
## operator's own status line before and after each key.
##   "$HYPER_TPS_GODOT" --headless --path . --script res://scenes/test/_repro_box_grid.gd

var _f := 0
var _map: Node
var _dock: Node
var _saved_grid: Variant = 5


func _press(code: Key) -> void:
	for pressed: bool in [true, false]:
		var e := InputEventKey.new()
		e.keycode = code
		e.physical_keycode = code
		e.pressed = pressed
		Input.parse_input_event(e)


func _status() -> String:
	var st: Node = _map.call("_ensure_ops")
	var op: Variant = st.get("active")
	return "(no tool)" if op == null else "%s  grid_idx=%d  units=%s" % [
		String(op.status()), int(_map.get("_grid_idx")), str(_map.grid_units())]


func _process(_d: float) -> bool:
	_f += 1
	match _f:
		1:
			_dock = root.get_node("/root/BuildDock")
			_saved_grid = _dock.pref("grid", 5)
			_dock.set_pref("grid", 5)
			_map = (load("res://scenes/maps/map_flat.tscn") as PackedScene).instantiate()
			root.add_child(_map)
		30:
			root.get_node("/root/GameMode").set_mode("build")
			var persist: Node = _map.get("_persist")
			persist.record("brush.create", {"planes": [1, 0, 0, 4, -1, 0, 0, 4, 0, 1, 0, 0.5, 0, -1, 0, 0,
				0, 0, 1, 4, 0, 0, -1, 4], "proj": [], "material_id": 1, "level_id": 0, "sky": false})
			persist.refold()
			var cam := Camera3D.new()
			root.add_child(cam)
			cam.look_at_from_position(Vector3(0, 3, 2), Vector3(0, 0.5, 0))
			cam.make_current()
		40:
			print("REPRO hit: %s" % str(_map.call("_crosshair_hit")))
			_press(KEY_N)
		45:
			print("REPRO after N        : %s" % _status())
			_press(KEY_EQUAL)
		48:
			print("REPRO after =        : %s" % _status())
			_press(KEY_MINUS)
		51:
			print("REPRO after -        : %s" % _status())
			_press(KEY_BRACKETRIGHT)
		54:
			print("REPRO after ]        : %s" % _status())
			_dock.set_pref("grid", _saved_grid)
			quit(0)
			return true
	return false