-
Notifications
You must be signed in to change notification settings - Fork 2
Bracket Codeblocks
Amp63 edited this page Dec 22, 2025
·
3 revisions
To create code inside of brackets, use the codeblocks parameter.
# Prints 'clicked' when a player right clicks with a stick in their hand
from dfpyre import *
PlayerEvent.RightClick([
IfPlayer.IsHolding(Item('stick'), codeblocks=[
PlayerAction.SendMessage('clicked')
])
])To create an else block, use the else_ function:
# Says the player is 'on the ground' when grounded and 'in the air' otherwise.
from dfpyre import *
Function('Grounded', codeblocks=[
IfPlayer.IsGrounded(codeblocks=[
PlayerAction.ActionBar('on the ground')
]),
Else([
PlayerAction.ActionBar('in the air')
])
])When creating loops, the syntax is the same:
# Prints numbers 1-5
from dfpyre import *
PlayerEvent.Join([
Repeat.Multiple(Variable('i'), 5, codeblocks=[
PlayerAction.SendMessage(Variable('i'))
])
])