Skip to content

Instantly share code, notes, and snippets.

@kiranmaya
Last active March 25, 2023 19:38
Show Gist options
  • Save kiranmaya/6519a21d0d9667557a61effc3da08902 to your computer and use it in GitHub Desktop.
Save kiranmaya/6519a21d0d9667557a61effc3da08902 to your computer and use it in GitHub Desktop.
UEFN verse Cheat codes
There is no start,update ,oncoillisionEnter like Unity monobehavuour or Actor unreal,everything is subscribe event based .
OnBegin is there tough ,but its a class starting point.
Creating a New Device with Verse , Our code is also a device ,their framework is around dealing everything as a devices.
Not objects or actors,these device contain objects,components.
Every script is a device,
our code may not a be component. lets see.
Note:Logic is boolean ,logic as a type
Tought ,their class decleration is worst ,but they do provide a template to starting point . so blank class is not a option for us .
var is for variable ,undeclaring is constant
@editable
PropertyName : type = DefaultValue
GreetingMessage : string = "Hello, stranger"
IntroMessages : []string = array{"Welcome to the Game", "Have Fun!"}
for (Message : IntroMessages):
Print("{Message}")
@editable
Button:button_device = button_device{}
@editable
ItemSpawner:item_spawner_device = item_spawner_device{}
OnBegin<override>()<suspends>:void=
Button.InteractedWithEvent.Subscribe(OnButtonInteractedWith)
OnButtonInteractedWith(InPlayer:agent):void=
ItemSpawner.SpawnItem()
there is no string based taggin like unity , you need to create seperate class instance.
using { /Verse.org/Simulation/Tags }
# Derive from the `tag` class in the Verse.org/Simulation/Tags module to create a new gameplay tag.
mytag := class(tag){}
use verseTagmarkup component ,to select our tags
TaggedActors := GetCreativeObjectsWithTag(mytag{})
for (TaggedActor : TaggedActors):
if (LightDevice := customizable_light_device[TaggedActor]):
# If the tagged actor is a Customizable Light device, turn it off
LightDevice.TurnOff()
else if (BarrierDevice := barrier_device[TaggedActor]):
# If the tagged actor is a Barrier device, turn it off
BarrierDevice.Disable()
# find all actors with the all_tag
AllCreativeObjects : []creative_object_interface := GetCreativeObjectsWithTag(all_tag{})
# find all actors with the all_tag
AllCreativeObjects : []creative_object_interface := GetCreativeObjectsWithTag(all_tag{})
# Print the position of all creative_prop actors with the all_tag
for (Prop : AllCreativeObjects):
if (Prop := creative_prop[Prop]):
Print("Prop found with all_tag at position: {Prop.GetTransform().Translation}")
# Print the position of all device actors with the all_tag
for (Device:AllCreativeObjects):
if (Device := creative_device_base[Device]):
Print("Creative device found with all_tag at position: {Device.GetTransform().Translation}")
# Print the position of all verse-authored device actors with the all_tag
for (VerseAuthoredDevice : AllCreativeObjects):
if (VerseAuthoredDevice := creative_device[VerseAuthoredDevice]):
Print("User device found with all_tag at position: {VerseAuthoredDevice.GetTransform().Translation}")
A custom UI can only be added per player — a custom UI is associated with a specific player, and only that player can see it.
TextForUI<localizes> : message = "Option"
Widget := button_loud{DefaultText := TextForUI}
TextForUI<localizes> : message = "This is my text!"
Widget := text_block{ DefaultText := TextForUI}
MoveText<localizes> : message = "Move"
AttackText<localizes> : message = "Attack"
CancelText<localizes> : message = "Cancel"
Widget := stack_box:
Orientation := orientation.Horizontal
Slots := array:
stack_box_slot:
Widget := button_loud{DefaultText := MoveText}
stack_box_slot:
Widget := button_regular{DefaultText := AttackText}
stack_box_slot:
Widget := button_quiet{DefaultText := CancelText}
//widget
HandleButtonInteraction(Agent : agent) : void =
# Agents can be a player or AI, but you can only get the UI of a player
# so you must cast the Agent, who interacted with the Button device, to the player type
if (InPlayer := player[Agent], PlayerUI := GetPlayerUI[InPlayer]):
MyUI : text_block = text_block{DefaultText := TextForMyUI}
PlayerUI.AddWidget(MyUI)
PlayerUI.RemoveWidget(MyUI)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment