Skip to content

Action Codeblocks

Amp63 edited this page Dec 22, 2025 · 2 revisions

Player Action

PlayerAction.[action_name]((args...), (target), (tags))

Example:

# Gives the player a Diamond Pickaxe when they join the plot
from dfpyre import *

PlayerEvent.Join([
    PlayerAction.GiveItems(Item('diamond_pickaxe'))
])

Entity Action

EntityAction.[action_name]((args...), (target), (tags))

Example:

# Heals an entity for 20 HP whenever it takes damage
from dfpyre import *

EntityEvent.EntityDmg([
    EntityAction.Heal(20)
])

Game Action

GameAction.[action_name]((args...), (tags))

Example:

# Spawns a sheep whenever a player joins the plot
from dfpyre import *

PlayerEvent.Join([
    GameAction.SpawnMob(Item('sheep_spawn_egg'), Location(10.5, 50.5, 10.5))
])

Set Variable

SetVariable.[action_name]((args...), (tags))

Example:

# Sets the variable `max` to either `a` or `b` depending on which is larger
from dfpyre import *

Function('GetMax', codeblocks=[
    SetVariable.MaxNumber(Variable('max'), [Variable('a'), Variable('b')])
])

Select Object

SelectObject.[action_name]((args...), (tags), (sub_action), (inverted))

Example:

# Selects all players that do not have a diamond, then gives one to them
from dfpyre import *

Function('CheckDiamond', codeblocks=[
    SelectObject.PlayersCond(Item('diamond'), sub_action='HasItem', inverted=True),
    PlayerAction.GiveItems(Item('diamond'))
])

Control

Control.[action_name((args...), (tags))

# Sends a message to the player, then plays a sound 1 second later
from dfpyre import *

PlayerEvent.Join([
    PlayerAction.SendMessage(Text('Hello!')),
    Control.Wait(20),
    PlayerAction.PlaySound(Sound('Harp', 1.0, 2.0))
])