ボタンを押した回数表示

要件

  1. ボタンの仕掛けを設置する
  2. ボタンの仕掛けを押すとログとして押した回数を表示する

使用する仕掛け

  1. ボタンの仕掛け(x1)

使用する機能

  1. Print関数

回答

回答を見る
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

press_count_device := class(creative_device):
    @editable
    ButtonDevice:button_device = button_device{}

    var PressCount:int = 0

    OnBegin<override>()<suspends>:void=
        ButtonDevice.InteractedWithEvent.Subscribe(OnInteract)

    OnInteract(Agent:agent):void=
        set PressCount += 1
        Print("押した回数: {PressCount}")