I’m trying to connect the function in UEFN using a susbcribe, but I can’t do it, it tells me that “this funtion parameter expects a value of type agent->void, but this argument is incompatible value of type void”.
Is there a way to subscribe the function?
These are the line that mark error
ActionMenu.InteractedWithEvent.Subscribe(OpenActionMenu) for (Selector : Selectors) { Selector.InteractedWithEvent.Subscribe(StartCompleteAction)
Here is the full script
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /UnrealEngine.com/Temporary/UI }
using { /Fortnite.com/Devices }
using { /Fortnite.com/UI }
using { /Fortnite.com/Characters}
action_device := class(creative_device):
@editable
ActionMenu:button_device = button_device{}
@editable
Selectors:[]button_device = array{}
@editable
ValidFx:[]vfx_spawner_device = array{}
var Canvas:?canvas = false
OnBegin<override>()<suspends>:void = {
ActionMenu.InteractedWithEvent.Subscribe(OpenActionMenu)
for (Selector : Selectors) {
Selector.InteractedWithEvent.Subscribe(StartCompleteAction)
}
}
StartCompleteAction(Player:player): void =
spawn { CompleteAction() }
return
CompleteAction()<suspends>:void = {
for (Fx : ValidFx) { Fx.Disable() }
for (Selector : Selectors) { Selector.Disable() }
Sleep(2.0)
ActionMenu.Enable()
return
}
OpenActionMenu(Player:player):void = {
Print("Button Interacted With!")
if (PlayerUI := GetPlayerUI[Player]) {
if (TmpCanvas := Canvas?) {
Print("Removing Canvas")
PlayerUI.RemoveWidget(TmpCanvas)
set Canvas = false
} else {
ActionMenu.Disable()
Print("Create New Canvas")
NewCanvas := MakeCanvas()
# Add the canvas and set input mode to UI (ie mouse controls cursor and not game)
PlayerUI.AddWidget(NewCanvas, player_ui_slot{ InputMode := ui_input_mode.All })
set Canvas = option{NewCanvas}
}
}
return
}
MoveForUICanvas<localizes>:message:= "Move"
AttackForUICanvas<localizes>:message := "Atttack"
CancelForUICanvas<localizes>:message := "Cancel"
MakeCanvas():canvas = {
Move:button_loud=button_loud{ DefaultText := MoveForUICanvas }
Attack:button_regular=button_regular{ DefaultText := AttackForUICanvas }
Cancel:button_quiet=button_quiet{ DefaultText := CancelForUICanvas }
Move.OnClick().Subscribe(MoveSelected)
Attack.OnClick().Subscribe(AttackSelected)
Cancel.OnClick().Subscribe(CancelSelected)
NewCanvas := canvas:
Slots := array:
canvas_slot:
Anchors := anchors{ Maximum:= vector2{X:=1.0, Y:=1.0} }
Offsets := margin{ Top:=100.0, Left:=100.0, Right:=100.0, Bottom := 100.0 }
Widget := stack_box:
Orientation := orientation.Vertical
Slots := array:
stack_box_slot:
Widget := Move
stack_box_slot:
Widget := Attack
stack_box_slot:
Widget := Cancel
return NewCanvas
}
MoveText<localizes>:message := "Moving"
MoveSelected(Message:widget_message):void = {
Print("Move Selected")
if (Button := text_button_base[Message.Source]) {
Button.SetText(MoveText)
}
for (Selector : Selectors) { Selector.Enable() }
for (Fx : ValidFx) { Fx.Enable() }
if (TmpPlayerUI := GetPlayerUI[Message.Player], TmpCanvas := Canvas?) {
TmpPlayerUI.RemoveWidget(TmpCanvas)
set Canvas = false
}
return
}
AttackText<localizes>:message := "Ataque no ha sido implementado"
AttackSelected(Message:widget_message):void = {
Print("Attack Selected")
if (Button := text_button_base[Message.Source]) {
Button.SetText(AttackText)
Button.SetEnabled(false)
}
return
}
CancelText<localizes>:message :="Mensaje Recibido C"
CancelSelected(Message:widget_message):void = {
Print("Cancel Clicked")
ActionMenu.Enable()
# Test remove the whole canvas in response to a click
if (TmpPlayerUI := GetPlayerUI[Message.Player], TmpCanvas := Canvas?) {
TmpPlayerUI.RemoveWidget(TmpCanvas)
set Canvas = false
}
if (Button := text_button_base[Message.Source]) {
Button.SetText(CancelText)
}
return
}