Skip to content

Instantly share code, notes, and snippets.

@rootVIII
Created May 17, 2023 23:38
Show Gist options
  • Save rootVIII/5faf9da9c4fb78e1de42fa2d28816a00 to your computer and use it in GitHub Desktop.
Save rootVIII/5faf9da9c4fb78e1de42fa2d28816a00 to your computer and use it in GitHub Desktop.
Verse arrays and maps
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Verse }
using { /UnrealEngine.com/Temporary/Diagnostics }
arrays_maps := class(creative_device):
Words : []string = array{"zero", "one", "two", "three", "four"}
var Result1 : []string = array{}
var Result2 : [string]string = map{
"one" => "1",
"two" => "2",
"three" => "3",
"four" => "4"
}
GetResult1() : string =
# for (Word : Result):
# Print("Word: {Word}")
return Join(Result1, " ")
AddToResult1() : void =
# for (Word : Words):
# if (Word.Length > 5):
# set Result += array{Word}
for (Word : Words; Word.Length > 5):
set Result1 += array{Word}
if (set Result1[0] = "Replaced") {}
var x : string = "hello"
GetResult2() : string =
# for (Key->Val : Result2):
# Print("{Key}: {Val}")
var index : int = 0
var concat : string = ""
for (Key->Val : Result2):
if (index < (Result2.Length - 1)):
set concat += "{Key}: {Val}, "
else:
set concat += "{Key}: {Val}"
set index += 1
return concat
AddToResult2(key: string, val : int) : void =
if (set Result2[key] = ToString(val)) {}
OnBegin<override>()<suspends>:void =
AddToResult1()
Print(GetResult1())
Print("- - - - - - - - - - -")
AddToResult2("five", 5)
Print(GetResult2())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment