Verse Library verse

01 Snippet

Creates editable map-like data structures with custom key/value types and lookup functionality for UEFN creators.

extracted-snippets/community/snippets/BdVK/fortnite-map-editable/01-snippet.verse

# Source URL: https://dev.epicgames.com/community/snippets/BdVK/fortnite-map-editable
# Local doc:  epic-docs/community/snippets/BdVK/fortnite-map-editable.md
  using { /Verse.org/Simulation }
  map_key<public> := interface:
  GetKey<public>()<transacts>:comparable
  map_value<public> := interface:
  DefaultMapKey := string_map_key
  DefaultMapValue := int_map_value
  string_map_key<public> := class<concrete>(map_key):
  @editable
  Key<public> : string = ""
  GetKey<override>()<transacts>:comparable=return Key
  int_map_value<public> := class<concrete>(map_value):
  @editable
  Value<public> : int = 0
  editable_map_item<public> := class<concrete>:
  @editable
  Key<public> : map_key = DefaultMapKey{}
  @editable
  Value<public> : map_value = DefaultMapValue{}
  editable_map<public> := class<concrete>:
  @editable
  Items<public> : []editable_map_item = array{}
  Find<public>(MapKey : map_key)<transacts><decides>:map_value=
  var ReturnMapValue : ?map_value = false
  for(Item : Items, not ReturnMapValue?, Item.Key.GetKey() = MapKey.GetKey()):
  set ReturnMapValue = option{Item.Value}
  return ReturnMapValue?

  Expand code  Copy full snippet(37 lines long)

Sign in free to read the full source 🌴

This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.

Sign in with Discord

Comments

    Sign in to vote, comment, or suggest an edit. Sign in