forked from coderwilson/FFX_TAS_Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sphere_grid_reader.py
57 lines (49 loc) · 2.27 KB
/
sphere_grid_reader.py
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
# Libraries and Core Files
import memory.main
from memory.sphere_grid import SphereNodeType, sphere_grid
from players import Auron, Kimahri, Lulu, Rikku, Tidus, Wakka, Yuna
"""
NOTE! This file is intended as an example of how to use the sphere grid API,
it's a test file with its own main, and should not be imported into the TAS.
Use the sphere_grid object imported from memory.sphere_grid when implementing
the functionality in the TAS.
"""
if __name__ == "__main__":
# Wait for memory to finish loading
while not memory.main.start():
pass
# Example code to read a particular node at an arbitrary position
node_123 = sphere_grid.get_node_at(123)
print(f"Node at idx=123 is {node_123}")
last_node = 0
while True:
# ID of the node currently selected by the GUI
cur_node = sphere_grid.get_current_node_idx()
if cur_node != last_node:
# The actual node selected by the GUI
node = sphere_grid.get_current_node()
# Print the node indices of all the players
print(
"Positions: "
+ f"[Tidus={sphere_grid.get_player_node_idx(Tidus)}] "
+ f"[Yuna={sphere_grid.get_player_node_idx(Yuna)}] "
+ f"[Auron={sphere_grid.get_player_node_idx(Auron)}] "
+ f"[Kimahri={sphere_grid.get_player_node_idx(Kimahri)}] "
+ f"[Wakka={sphere_grid.get_player_node_idx(Wakka)}] "
+ f"[Lulu={sphere_grid.get_player_node_idx(Lulu)}] "
+ f"[Rikku={sphere_grid.get_player_node_idx(Rikku)}]"
)
# Print the currently selected node and
# a bitfield of what characters have activated it
print(
f"New node: {cur_node}, type {node}, "
+ f"activation: {hex(node.get_activated_by())}"
)
# Example check for activation by Yuna
if node.is_activated_by(Yuna):
print(f"Node {node} is activated by Yuna")
# Example comparison of current node to the enum list
if node.get_node_type() == SphereNodeType.Flare:
print("The currently selected node is the Flare spell!")
# Just to prevent spam, only print the info once
last_node = cur_node