Created
July 26, 2023 15:53
-
-
Save Lootheo/39827249d76cfdfd92ebf2da610ac8b6 to your computer and use it in GitHub Desktop.
Global variable Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using { /Fortnite.com/Devices } | |
using { /Verse.org/Simulation } | |
using { /UnrealEngine.com/Temporary/Diagnostics } | |
# See https://dev.epicgames.com/documentation/en-us/uefn/create-your-own-device-in-verse for how to create a verse device. | |
var GlobalInt1:weak_map(session, int) = map{} | |
# A Verse-authored creative device that can be placed in a level | |
persistance_device := class(creative_device): | |
@editable | |
AddButton:button_device=button_device{} | |
@editable | |
EndRoundButton:button_device=button_device{} | |
@editable | |
Billboard:billboard_device=billboard_device{} | |
@editable | |
EndRoundDevice:end_game_device=end_game_device{} | |
GetBillboardMessage<localizes>(IntMessage : int) : message = "{IntMessage}" | |
# Runs when the device is started in a running game | |
OnBegin<override>()<suspends>:void= | |
Print("Round Starting") | |
UpdateBillboard() | |
AddButton.InteractedWithEvent.Subscribe(OnAddButtonPressed) | |
EndRoundButton.InteractedWithEvent.Subscribe(OnEndRoundButtonPressed) | |
UpdateBillboard():void= | |
Print("Updating Billboard") | |
if(SessionInt:=GlobalInt1[GetSession()]): | |
Billboard.SetText(GetBillboardMessage(SessionInt)) | |
else: | |
Print("No global int, resetting") | |
if(set GlobalInt1[GetSession()] = 0){} | |
OnAddButtonPressed(Agent:agent):void= | |
if (Y := GlobalInt1[GetSession()]): | |
Print("Setting global int {Y}") | |
if(set GlobalInt1[GetSession()] = Y+1){} | |
else: | |
if(set GlobalInt1[GetSession()] = 1){} | |
if (Y := GlobalInt1[GetSession()]): | |
Print("Global Int is now: {Y}") | |
Print("Add Button Pressed ") | |
UpdateBillboard() | |
OnEndRoundButtonPressed(Agent:agent):void= | |
EndRoundDevice.Activate(Agent) | |
Print("Add Button Pressed") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment