-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnode_query_basic.ferris
More file actions
69 lines (62 loc) · 1.97 KB
/
node_query_basic.ferris
File metadata and controls
69 lines (62 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// TEST: node_query_basic
// CATEGORY: unit
// DESCRIPTION: Basic node query operations with get_node() and get_parent()
// EXPECT: success
// ASSERT: Found Player node
// ASSERT: Found UI node
// ASSERT: Got parent node
// ASSERT: Found OtherChild node
// ASSERT: Example Complete
//
// Example: Basic Node Query Operations
// Demonstrates get_node() and get_parent() usage
//
// GODOT SCENE SETUP:
// 1. Create a new 2D Scene
// 2. Add FerrisScriptNode as root, rename to "Main"
// 3. Attach this script to Main node (Inspector → Script Path)
// 4. Add child nodes to Main:
// - Node2D named "Player"
// - Node2D named "UI"
// - Camera2D named "Camera2D"
// - Node2D named "Enemy"
// - Node2D named "OtherChild"
//
// Scene Tree Structure:
// /root
// └─ Main (FerrisScriptNode with this script)
// ├─ Player
// ├─ UI
// ├─ Camera2D
// ├─ Enemy
// └─ OtherChild
//
// EXPECTED BEHAVIOR:
// - Script loads successfully
// - _ready() executes without errors
// - All node queries succeed (nodes found)
// - Console shows success markers (✓)
fn _ready() {
print("=== Basic Node Query Operations ===");
// Get a child node by relative path
let player = get_node("Player");
print("✓ Found Player node");
// Get a node by child path
let ui = get_node("UI");
print("✓ Found UI node");
// Get parent of this node
let parent = get_parent();
print("✓ Got parent node");
// Access sibling node
// Note: Method chaining like get_parent().get_node() not yet supported
// Use direct path or has_node validation instead
let sibling = get_node("OtherChild");
print("✓ Found OtherChild node");
print("=== Example Complete ===");
}
fn _process(delta: f32) {
// Note: This runs every frame, avoid logging here in real usage
// For testing, we just access nodes silently
let target = get_node("Enemy");
let camera = get_node("Camera2D");
}