-
Notifications
You must be signed in to change notification settings - Fork 2
Code Items
This page contains documentation for all code items.
Represents a DiamondFire String item:
String('hello, world')If a string literal is passed to a method as a chest parameter, it will automatically be converted to a String object:
# These do the same thing:
PlayerAction.SendMessage(String('%default joined.'))
PlayerAction.SendMessage('%default joined.')Represents a DiamondFire Styled Text item:
Text('hello %default.')Alias: Num
Represents a DiamondFire Number item:
Number(5)
Number(3.14)If an integer or float literal is passed to a method as a chest parameter, it will automatically be converted to a Number object:
# These do the same thing:
SetVariable.Assign(Variable('number'), Number(10))
SetVariable.Assign(Variable('number'), 10)Alias: Var
Represents a DiamondFire Variable item:
Variable('num')
Variable('text1')You can set variable values by using the set_variable function:
SetVariable.Assign(Variable('num'), 12) # Sets 'num' to 12
SetVariable.Multiply(Variable('doubled'), [Variable('num'), 2]) # Sets 'doubled' to 24You can set the scope of the variable using the scope argument:
SetVariable.Assign(Variable('num1', scope='unsaved'), 12) # 'unsaved' is the same as a game variable.
SetVariable.Assign(Variable('num2', scope='saved'), 12)
SetVariable.Assign(Variable('num3', scope='local'), 12)Alias: Loc
Represents a DiamondFire location item:
Location(x=25.5, y=50, z=25.5, pitch=0, yaw=-90)Example:
# Teleport player on join
from dfpyre import *
PlayerEvent.Join([
PlayerAction.Teleport(Location(10, 50, 10))
])Represents a Minecraft item:
Item('stick', count=5)
Item('stone', 64)To further modify an Item, you can use any methods from the mcitemlib module.
Alias: Snd
Represents a DiamondFire Sound item:
Sound('Wood Break', pitch=1.5, vol=2.0)Example:
# Plays 'Grass Place' sound on join
from dfpyre import *
PlayerEvent.Join([
PlayerAction.PlaySound(Sound('Grass Place'))
])Represents a DiamondFire Particle item:
Particle.Cloud(amount=5, horizontal_spread=0.5, motion=(0, 1, 0), motion_variation=20)Example:
# Plays a upward-moving white cloud particle effect at 5, 50, 5
from dfpyre import *
part = Particle.Cloud(amount=5, horizontal_spread=0.5, motion=(0, 1, 0), motion_variation=20)
PlayerEvent.Join([
PlayerAction.Particle(part, Location(5, 50, 5))
])Alias: Pot
Represents a DiamondFire Potion item:
# Gives speed 1 for 1 minute
Potion('Speed', dur=1200, amp=0)Example:
# Gives the player infinite saturation 10
from dfpyre import *
PlayerEvent.Join([
PlayerAction.GivePotion(Potion('Saturation', amp=10))
])Represents a DiamondFire Game Value item:
GameValue('Player Count')
GameValue('Location' target='Selection')Example:
# Function that prints player count and CPU usage
from dfpyre import *
Function('printData', codeblocks=[
PlayerAction.SendMessage([GameValue('Player Count'), GameValue('CPU Usage')])
])Alias: Vec
Represents a DiamondFire Vector item:
Vector(x=1.1, y=0.0, z=0.5)Example:
# Sets the player's x velocity to 1.0 on join
from dfpyre import *
PlayerEvent.Join([
PlayerAction.SetVelocity(Vector(x=1.0, y=0.0, z=0.0))
])Represents a DiamondFire Parameter item:
Parameter('text', ParameterType.STRING)Example:
# Builds a function that says "Hello, [name]" where `name` is the inputted parameter.
from dfpyre import *
name_parameter = Parameter('name', ParameterType.TEXT)
Function('SayHi', name_parameter, codeblocks=[
PlayerAction.SendMessage(['Hello, ', Variable('name', 'line')])
])