Calling Device Functions: Giving the Verb What It Needs
Tutorial beginner compiles

Calling Device Functions: Giving the Verb What It Needs

Updated beginner Devices Code verified

Calling Device Functions: Giving the Verb What It Needs

You can now reach into a device with a dot and press a button: RoundTimer.Start(). This lesson zooms in on what goes inside the parentheses — because that is where most of a device's power lives.

A device function is a verb. The parentheses are where you hand the verb the information it needs to do its job.

Empty hands: ()

Some verbs need nothing from you. You just say do it:

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

machine := class(creative_device):

    @editable
    Spawner : item_spawner_device = item_spawner_device{}

    OnBegin<override>()<suspends> : void =
        # SpawnItem takes nothing. Just: "drop one item, now."
        Spawner.SpawnItem()

SpawnItem() is a complete sentence on its own. Empty () means "no extra information required."

Handing over a value

<!-- section-art:handing-over-a-value --> Calling Device Functions: Giving the Verb What It Needs: Handing over a value

Handing the Argument

Other verbs need a fact to work with. You put it inside the ():

OnBegin<override>()<suspends> : void =
        # SetActiveDuration needs to know HOW LONG. We hand it 45 seconds.
        RoundTimer.SetActiveDuration(45.0)

SetActiveDuration cannot do its job without a number of seconds, so you hand it 45.0. The value you pass is called an argument — think of it as the thing you hand the verb. Different verbs want different things: a number of seconds, a piece of text, or…

Handing over a player: the agent

This is the most important argument in all of devices. Many verbs need to know which player to act on. In Verse a player is an agent.

The classic example is the Item Granter — it gives an item to someone, so it must be told who:

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

reward_giver := class(creative_device):

    @editable
    Granter : item_granter_device = item_granter_device{}

    # We'll see in the events series WHERE this Player comes from.
    # For now: GiveReward needs an agent, and hands it straight on.
    GiveReward(Player : agent) : void =
        # Grant the granter's configured item to THIS player.
        Granter.GrantItem(Player)

GrantItem(Player) reads as: "reach into the Granter and grant its item to this player." The agent named Player is the who. (Where Player comes from is the whole subject of the next series — device events hand you the agent automatically.)

You will see agent everywhere: granting items, completing a timer for one player, teleporting someone. Whenever a verb acts on a person, it wants an agent.

Verbs that hand something back

Some verbs don't just do — they answer a question and hand you back a value. Reading a timer's remaining time is one:

GetActiveDuration() hands back a float (a decimal number). We catch the answer in a noun, TimeLeft : float, using the exact sentence shape from the Grammar lesson. The {TimeLeft} inside the text prints its value — curly braces in a string mean "drop the value of this noun in here."

A handy rule of thumb: verbs that start with Set… usually take a value, and verbs that start with Get… usually hand one back.

Looking up what a verb wants

<!-- section-art:looking-up-what-a-verb-wants --> Calling Device Functions: Giving the Verb What It Needs: Looking up what a verb wants

Shape Matching

You are never expected to memorize every verb and what it takes. You look it up. The Verse Cortex knowledge base and the Epic device docs list, for each device, every verb it has and exactly what goes in the parentheses. Reading that and matching the shape is the real skill — far more durable than memorizing.

For example, the Item Granter's page tells you GrantItem takes one agent. The Timer's page tells you SetActiveDuration takes one float. You read the shape, you match it, you move on.

Why this helps you direct an AI

The precise way to ask for behavior is to name the verb and what it takes: "call Granter.GrantItem with the player who pressed the button," or "set the timer's active duration to 45." That gives a helper the verb and the argument — no guessing about what goes in the parentheses.

Quick recap

  • A device function is a verb; the () is where you hand it information.
  • An argument is the value you hand a verb (a number, text, a player).
  • agent is a player — the who for any verb that acts on a person.
  • Some verbs hand a value back; catch it in a named noun (TimeLeft : float = …).
  • Set… usually takes a value; Get… usually hands one back.
  • Don't memorize — look up each verb's shape in the docs / knowledge base.

Next: Three Devices, End to End — the button, item granter, and timer working together.

References

Get the complete code — free

You've read the full walkthrough. The complete, copy-paste-ready Verse solution is free for members — sign in to unlock it.

Free with your BrainDead.TV / BrainDeadGuild Discord account. The walkthrough above is always free.

Verse source files

Check your understanding

Test yourself with an interactive quiz and track your progress + earn XP — free for members.

Up next · Devices with Verse Three Devices, End to End: A Reward Button Continue →

Turn this into a guided course

Add Devices in Verse — function arguments, agent, return values to your free study plan — we'll suggest related pages and stitch the lot into one compile-checked, self-guided lesson with worked examples and quizzes.

Original tutorial generated by Verse Island from the Verse/UEFN knowledge base, with references to the Epic Games sources above. Code is validated against the knowledge base.

Comments

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