-
Notifications
You must be signed in to change notification settings - Fork 0
Global Functions & Statements
These are available globally in every script without needing a type instance.
Imports a reusable Vyn script library from a resource pack. Use this to share common logic across multiple scripts.
-
Parameters:
-
packId—String— The resource pack ID that contains the script -
script—String— The name of the script to import
-
importScript("mypack", "math_utils")
importScript("mypack", "animation_lib")
Disables an active script, preventing it from running.
-
Parameters:
-
packId—String— The resource pack ID that owns the script -
script—String— The name of the script to disable
-
~ Disable a script conditionally
check modLoader.isModLoaded("somemod") do
excludeScript("mypack", "compat_script")
end
Displays a debug string on screen. Only works when Resource Pack Debug Mode is enabled in the mod config (see InteractiveStuffConfig).
-
Parameters:
-
text—String— The text to display
-
debugText("Player health: " + player.getHealth())
debugText("Biome: " + player.getWorld().getBiomeAt(player.getPosition()))
debugText("Velocity Y: " + player.getVelocityY())
Returns the normalized frame delta time. Use this to make animations and transitions framerate-independent — the result scales consistently at any FPS.
-
Returns:
Double
~ Rotate item at a consistent speed regardless of FPS
make item player.getMainHandItem()
item.rotateY(90 * getDelta())
~ Smooth translation using delta
make speed = 0.05
item.translateY(speed * getDelta())
Executes a block of code after a delay of the given number of ticks (20 ticks = 1 second). The rest of the script continues running immediately — the wait block runs in the background.
-
Parameters:
-
ticks—Integer— Number of ticks to wait before executing the body
-
~ Play a sound, then play another sound 1 second later
player.playSound("minecraft:entity.experience_orb.pickup", 1.0, 1.0)
wait 20 do
player.playSound("minecraft:block.note_block.bell", 1.0, 1.2)
end
~ Delayed debug message
debugText("Starting sequence...")
wait 40 do
debugText("2 seconds have passed!")
end
~ Chained waits
wait 10 do
debugText("0.5 seconds")
wait 10 do
debugText("1 second")
wait 20 do
debugText("2 seconds")
end
end
end
Events are special tasks that Vyn calls automatically when something happens in the game. Define them in your script using task and Vyn will invoke them at the right time.
Called every game tick (20 times per second). Use this for logic that needs to run on a fixed tick schedule rather than every render frame.
task onTick do
debugText("XP Level: " + player.getExperienceLevel())
end
Called when the player swings their hand (left-click attack or animation trigger).
task onSwingHand do
player.playSound("minecraft:entity.player.attack.weak", 0.5, 1.2)
end
task onSwingHand do
debugText("Swung! Holding: " + player.getMainHandItem().getName())
end
Called when the game plays a sound. Receives the Sound that is about to play, allowing you to react to or inspect it.
-
Parameters:
-
sound—Sound— The sound being played
-
task onPlaySound takes sound do
debugText("Sound: " + sound.getName())
end
~ React to a specific sound playing
task onPlaySound takes sound do
check sound.getName() == "minecraft:block.note_block.harp" do
player.playSound("minecraft:block.note_block.bell", sound.getVolume(), sound.getPitch())
end
end
Called when the player presses a key. Receives the key code as an integer, allowing you to react to specific key inputs.
-
Parameters:
-
keyInput—Integer— The key code of the pressed key
-
~ Log any key press
task onKeyPress takes keyInput do
debugText("Key pressed: " + keyInput)
end
~ React to a specific key (e.g. key code 69 = E, the default "pick block" / use key)
task onKeyPress takes keyInput do
check keyInput == 69 do
player.playSound("minecraft:ui.button.click", 1.0, 1.0)
end
end
Called every render frame for each item being rendered. This is the primary event for applying visual transforms, physics, color changes, and model overrides to held items.
-
Parameters:
-
itemRendered—ItemModel— The item currently being rendered
-
Always guard with
player.getGamemode() != "spectator"to avoid running logic while spectating.
task onItemUpdate takes itemRendered do
check player.getGamemode() != "spectator" do
check itemRendered.getName() == "minecraft:diamond_sword" do
itemRendered.setColor(100, 180, 255)
end
end
end
~ Physics-based sway on a specific item
importScript("interactivestuff:interactive_resourcepack", "physics_lib")
task onItemUpdate takes itemRendered do
check !modLoader.isModLoaded("holdmyitems") do
check player.getGamemode() != "spectator" do
check itemRendered.getName() == "minecraft:stick" do
runPhysicsEngine(0.01, 0.15, -1.0, 0.3, 0.5, 1.0, 45, 0.1)
itemRendered.setPivot(0.0, -0.01, 0.0)
itemRendered.rotate(angleX, 0, angleZ)
end
end
end
end
GET IN TOUCH - omar@merakistudios.dev
© 2026 Omar Mohamed. All Rights Reserved.