# This is a simple example of how a Viewmodel connects to data. # In the editor, you do this with buttons. In Verse, we write it. using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/UI } # We define a simple Verse device to manage the connection. viewmodel_example := class(creative_device): # A reference to a tracker device placed in the level. # Wire this up in the editor's Details panel. @editable MyTracker : tracker_device = tracker_device{} # OnBegin runs when the game starts. OnBegin() : void = # Get the current score value from the tracker device. # tracker_device exposes GetValue to read its total tracked value. CurrentCount := MyTracker.GetValue() # Print the value so we can confirm the connection works. # In a full project you would pass this to a UI widget instead. # note: Verse UI text binding uses message types; direct widget # health-bar calls are authored in the Widget Blueprint via # View Bindings, not in Verse code directly. Print("Tracker value: {CurrentCount}")