# Utility

### HTTP

`HTTP.Get(url, headers)`: Performs an HTTP GET request. `headers` is an optional table of key-value pairs. Returns a result table with `Success`, `StatusCode`, `Body`, and `ErrorMessage`.

```lua
local res = HTTP.Get("https://example.com")
if res.Success then
    print(res.Body)
end
```

`HTTP.Post(url, body, headers)`: Performs an HTTP POST request. `body` can be a string or a table (encoded as form data). Returns the same result table as `Get`.

```lua
local res = HTTP.Post("https://example.com/api", '{"key":"value"}', {["Content-Type"] = "application/json"})
print(res.StatusCode)
```

`HTTP.Put(url, body, headers)`: Performs an HTTP PUT request.

```lua
local res = HTTP.Put("https://example.com/api/1", "data")
print(res.Success)
```

`HTTP.Patch(url, body, headers)`: Performs an HTTP PATCH request.

```lua
local res = HTTP.Patch("https://example.com/api/1", "data")
print(res.Success)
```

`HTTP.Delete(url, body, headers)`: Performs an HTTP DELETE request.

```lua
local res = HTTP.Delete("https://example.com/api/1")
print(res.Success)
```

***

**JSON:**

```lua
JSON.Parse(jsonString)
```

Parses a JSON string and returns a Lua table. Returns `nil` on failure.

```lua
JSON.Stringify(table)
```

Converts a Lua table into a JSON string. Returns `"null"` on failure.

***

### String

`String.Split(str, delimiter)`: Returns a table of substrings split by the delimiter.

lua

```lua
local parts = String.Split("a,b,c", ",")
```

`String.StartsWith(str, prefix)`: Returns `true` if `str` starts with `prefix`. `String.EndsWith(str, suffix)`: Returns `true` if `str` ends with `suffix`. `String.Trim(str)`: Strips leading and trailing whitespace. `String.ToLower(str)`: Returns a lowercase copy. `String.ToUpper(str)`: Returns an uppercase copy. `String.Contains(str, substr)`: Returns `true` if `substr` is found anywhere in `str`. `String.Replace(str, from, to)`: Replaces all occurrences of `from` with `to`.

`String.Find(str, substr)`: Returns the 1-based index of the first occurrence of `substr`, or `-1` if not found.

```lua
local i = String.Find("hello world", "world") -- returns 7
```

`String.Repeat(str, n)`: Returns `str` repeated `n` times.

```lua
print(String.Repeat("ab", 3)) -- "ababab"
```

`String.Reverse(str)`: Returns the string reversed.

```lua
print(String.Reverse("hello")) -- "olleh"
```

`String.PadLeft(str, width, padChar)`: Pads `str` on the left to reach `width` characters using `padChar`.

```lua
print(String.PadLeft("5", 3, "0")) -- "005"
```

`String.PadRight(str, width, padChar)`: Pads `str` on the right to reach `width` characters using `padChar`.

```lua
print(String.PadRight("hi", 5, ".")) -- "hi..."
```

`String.Sub(str, start, end)`: Returns a substring using 1-based inclusive indices. Negative `end` counts from the back.

```lua
print(String.Sub("hello", 2, 4)) -- "ell"
```

`String.Count(str, substr)`: Returns the number of non-overlapping occurrences of `substr` in `str`.

```lua
print(String.Count("banana", "an")) -- 2
```

***

### Base64

`Base64.Encode(str)`: Encodes a string to Base64.

```lua
local encoded = Base64.Encode("hello world")
print(encoded) -- "aGVsbG8gd29ybGQ="
```

`Base64.Decode(str)`: Decodes a Base64 string back to its original form.

```lua
local decoded = Base64.Decode("aGVsbG8gd29ybGQ=")
print(decoded)
```

`Base64.IsValid(str)`: Returns `true` if the string is valid Base64.

```lua
if Base64.IsValid(someStr) then
    print(Base64.Decode(someStr))
end
```

`Base64.EncodeFile(path)`: Reads a file from disk and returns its contents as a Base64 string.

```lua
local b64 = Base64.EncodeFile("C:\\Yerb\\V3\\Luas\\image.png")
```

`Base64.DecodeToFile(base64str, path)`: Decodes a Base64 string and writes the result to disk. Returns `true` on success.

```lua
Base64.DecodeToFile(b64data, "C:\\Yerb\\V3\\Luas\\output.png")
```

***

### **Sound**

`sound:SoundId()`: Returns the sound asset ID string.

```lua
local soundInst = someInstance:FindFirstChildOfClass("Sound"):Sound()
print(soundInst:SoundId())
```

`sound:SetSoundId(id)`: Sets the sound asset ID.

```lua
soundInst:SetSoundId("rbxassetid://123456789")
```

`sound:Volume()`: Returns the volume as a float.

```lua
print(soundInst:Volume())
```

`sound:SetVolume(v)`: Sets the volume.

```lua
soundInst:SetVolume(0.5)
```

`sound:PlaybackSpeed()`: Returns the playback speed.

```lua
print(soundInst:PlaybackSpeed())
```

`sound:SetPlaybackSpeed(v)`: Sets the playback speed.

```lua
soundInst:SetPlaybackSpeed(2.0)
```

`sound:Looped()`: Returns true if the sound is set to loop.

```lua
print(soundInst:Looped())
```

`sound:SetLooped(v)`: Sets looping on or off.

```lua
soundInst:SetLooped(true)
```

`sound:RollOffMaxDistance()`: Returns the max rolloff distance.

```lua
print(soundInst:RollOffMaxDistance())
```

`sound:SetRollOffMaxDistance(v)`: Sets the max rolloff distance.

```lua
soundInst:SetRollOffMaxDistance(100)
```

`sound:RollOffMinDistance()`: Returns the min rolloff distance.

```lua
print(soundInst:RollOffMinDistance())
```

`sound:SetRollOffMinDistance(v)`: Sets the min rolloff distance.

```lua
soundInst:SetRollOffMinDistance(10)
```

***

### **SpawnLocation**

`spawn:Enabled()`: Returns whether the spawn is active.

```lua
local spawn = workspace:FindFirstChildOfClass("SpawnLocation"):SpawnLocation()
print(spawn:Enabled())
```

`spawn:SetEnabled(v)`: Sets whether the spawn is active.

```lua
spawn:SetEnabled(false)
```

`spawn:Neutral()`: Returns whether the spawn is set to neutral.

```lua
print(spawn:Neutral())
```

`spawn:SetNeutral(v)`: Sets neutral team state.

```lua
spawn:SetNeutral(true)
```

`spawn:ForcefieldDuration()`: Returns the forcefield duration in seconds.

```lua
print(spawn:ForcefieldDuration())
```

`spawn:SetForcefieldDuration(v)`: Sets the forcefield duration in seconds.

```lua
spawn:SetForcefieldDuration(0)
```

`spawn:AllowTeamChangeOnTouch()`: Returns whether touching the spawn changes team.

```lua
print(spawn:AllowTeamChangeOnTouch())
```

`spawn:SetAllowTeamChangeOnTouch(v)`: Sets whether touching changes team.

```lua
spawn:SetAllowTeamChangeOnTouch(false)
```

`spawn:TeamColor()`: Returns the team color integer.

```lua
print(spawn:TeamColor())
```

`spawn:SetTeamColor(v)`: Sets the team color integer.

```lua
spawn:SetTeamColor(1)
```

***

### **GuiObject**

`gui:Visible()`: Returns whether the element is visible.

```lua
local gui = someInstance:FindFirstChildOfClass("TextLabel"):GuiObject()
print(gui:Visible())
```

`gui:SetVisible(v)`: Sets visibility.

```lua
gui:SetVisible(false)
```

`gui:ZIndex()`: Returns the render order.

```lua
print(gui:ZIndex())
```

`gui:SetZIndex(v)`: Sets the render order.

```lua
gui:SetZIndex(5)
```

`gui:LayoutOrder()`: Returns the layout order.

```lua
print(gui:LayoutOrder())
```

`gui:SetLayoutOrder(v)`: Sets the layout order.

```lua
gui:SetLayoutOrder(2)
```

`gui:BackgroundTransparency()`: Returns the background transparency.

```lua
print(gui:BackgroundTransparency())
```

`gui:SetBackgroundTransparency(v)`: Sets the background transparency.

```lua
gui:SetBackgroundTransparency(1)
```

`gui:Rotation()`: Returns the rotation in degrees.

```lua
print(gui:Rotation())
```

`gui:SetRotation(v)`: Sets the rotation in degrees.

```lua
gui:SetRotation(45)
```

`gui:Text()`: Returns the text content.

```lua
print(gui:Text())
```

`gui:SetText(v)`: Sets the text content.

```lua
gui:SetText("Hello")
```

`gui:ScreenGuiEnabled()`: Returns whether the parent ScreenGui is enabled.

```lua
print(gui:ScreenGuiEnabled())
```

`gui:SetScreenGuiEnabled(v)`: Sets the parent ScreenGui enabled state.

```lua
gui:SetScreenGuiEnabled(false)
```

`gui:AbsolutePosition()`: Returns the absolute screen position as a Vector2.

```lua
local pos = gui:AbsolutePosition()
print(pos.x, pos.y)
```

`gui:AbsoluteSize()`: Returns the absolute screen size as a Vector2.

```lua
local size = gui:AbsoluteSize()
print(size.x, size.y)
```

`gui:AbsoluteRotation()`: Returns the absolute rotation as a float.

```lua
print(gui:AbsoluteRotation())
```

***

### **GuiBase2D**

`gui:AbsolutePosition()`: Returns the absolute screen position as a Vector2.

```lua
local base = someInstance:GuiBase2D()
local pos = base:AbsolutePosition()
print(pos.x, pos.y)
```

`gui:AbsoluteSize()`: Returns the absolute screen size as a Vector2.

```lua
local size = base:AbsoluteSize()
print(size.x, size.y)
```

`gui:AbsoluteRotation()`: Returns the absolute rotation as a float.

```lua
print(base:AbsoluteRotation())
```

***

### **ClickDetector**

`cd:MaxActivationDistance()`: Returns the max activation distance.

```lua
local cd = part:FindFirstChildOfClass("ClickDetector"):ClickDetector()
print(cd:MaxActivationDistance())
```

`cd:SetMaxActivationDistance(v)`: Sets the max activation distance.

```lua
cd:SetMaxActivationDistance(10)
```

`cd:MouseIcon()`: Returns the mouse icon asset string.

```lua
print(cd:MouseIcon())
```

`cd:SetMouseIcon(v)`: Sets the mouse icon asset string.

```lua
cd:SetMouseIcon("rbxassetid://123456789")
```

***

### **AnimationTrack**

`track:IsPlaying()`: Returns true if the track is currently playing.

```lua
local track = animator:FindFirstChildOfClass("AnimationTrack"):AnimationTrack()
print(track:IsPlaying())
```

`track:Looped()`: Returns whether the track is set to loop.

```lua
print(track:Looped())
```

`track:SetLooped(v)`: Sets looping on or off.

```lua
track:SetLooped(true)
```

`track:Speed()`: Returns the playback speed.

```lua
print(track:Speed())
```

`track:SetSpeed(v)`: Sets the playback speed.

```lua
track:SetSpeed(2.0)
```

`track:Animation()`: Returns the Animation instance.

```lua
local anim = track:Animation()
print(anim:Name())
```

`track:Animator()`: Returns the Animator instance.

```lua
local animator = track:Animator()
print(animator:Name())
```

***

### **ProximityPrompt**

`pp:ActionText()`: Returns the action label text.

```lua
local pp = part:FindFirstChildOfClass("ProximityPrompt"):ProximityPrompt()
print(pp:ActionText())
```

`pp:SetActionText(v)`: Sets the action label text.

```lua
pp:SetActionText("Press E")
```

`pp:ObjectText()`: Returns the object label text.

```lua
print(pp:ObjectText())
```

`pp:SetObjectText(v)`: Sets the object label text.

```lua
pp:SetObjectText("Door")
```

`pp:Enabled()`: Returns whether the prompt is active.

```lua
print(pp:Enabled())
```

`pp:SetEnabled(v)`: Sets whether the prompt is active.

```lua
pp:SetEnabled(false)
```

`pp:HoldDuration()`: Returns how long to hold to trigger.

```lua
print(pp:HoldDuration())
```

`pp:SetHoldDuration(v)`: Sets how long to hold to trigger.

```lua
pp:SetHoldDuration(0)
```

`pp:MaxActivationDistance()`: Returns the trigger range.

```lua
print(pp:MaxActivationDistance())
```

`pp:SetMaxActivationDistance(v)`: Sets the trigger range.

```lua
pp:SetMaxActivationDistance(50)
```

`pp:RequiresLineOfSight()`: Returns whether line of sight is required.

```lua
print(pp:RequiresLineOfSight())
```

`pp:SetRequiresLineOfSight(v)`: Sets line of sight requirement.

```lua
pp:SetRequiresLineOfSight(false)
```

`pp:KeyCode()`: Returns the key code integer.

```lua
print(pp:KeyCode())
```

`pp:SetKeyCode(v)`: Sets the key code integer.

```lua
pp:SetKeyCode(69)
```

`pp:GamepadKeyCode()`: Returns the gamepad key code integer.

```lua
print(pp:GamepadKeyCode())
```

***

### **TextLabel**

`label:GetText()`: Returns the current text string.

```lua
local label = someInstance:FindFirstChildOfClass("TextLabel"):TextLabel()
print(label:GetText())
```

`label:SetText(v)`: Sets the text string.

```lua
label:SetText("Hello World")
```

`label:GetTextSize()`: Returns the font size.

```lua
print(label:GetTextSize())
```

`label:SetTextSize(v)`: Sets the font size.

```lua
label:SetTextSize(18)
```

`label:GetLineHeight()`: Returns the line height.

```lua
print(label:GetLineHeight())
```

`label:SetLineHeight(v)`: Sets the line height.

```lua
label:SetLineHeight(1.5)
```

`label:GetRichText()`: Returns whether rich text is enabled.

```lua
print(label:GetRichText())
```

`label:SetRichText(v)`: Sets rich text on or off.

```lua
label:SetRichText(true)
```

`label:GetTextScaled()`: Returns whether text is scaled to fit.

```lua
print(label:GetTextScaled())
```

`label:SetTextScaled(v)`: Sets text scaling on or off.

```lua
label:SetTextScaled(true)
```

`label:GetTextWrapped()`: Returns whether text wrapping is enabled.

```lua
print(label:GetTextWrapped())
```

`label:SetTextWrapped(v)`: Sets text wrapping on or off.

```lua
label:SetTextWrapped(true)
```

`label:GetTextTransparency()`: Returns the text transparency.

```lua
print(label:GetTextTransparency())
```

`label:SetTextTransparency(v)`: Sets the text transparency.

```lua
label:SetTextTransparency(0.5)
```

`label:GetTextStrokeTransparency()`: Returns the text stroke transparency.

```lua
print(label:GetTextStrokeTransparency())
```

`label:SetTextStrokeTransparency(v)`: Sets the text stroke transparency.

```lua
label:SetTextStrokeTransparency(0)
```

`label:GetMaxVisibleGraphemes()`: Returns the max visible graphemes.

```lua
print(label:GetMaxVisibleGraphemes())
```

`label:SetMaxVisibleGraphemes(v)`: Sets the max visible graphemes. Use -1 for unlimited.

```lua
label:SetMaxVisibleGraphemes(10)
```

`label:GetFont()`: Returns the font enum integer.

```lua
print(label:GetFont())
```

`label:SetFont(v)`: Sets the font enum integer.

```lua
label:SetFont(3)
```

`label:GetTextDirection()`: Returns the text direction enum integer.

```lua
print(label:GetTextDirection())
```

`label:SetTextDirection(v)`: Sets the text direction enum integer.

```lua
label:SetTextDirection(0)
```

`label:GetTextTruncate()`: Returns the text truncation enum integer.

```lua
print(label:GetTextTruncate())
```

`label:SetTextTruncate(v)`: Sets the text truncation enum integer.

```lua
label:SetTextTruncate(1)
```

`label:GetTextXAlignment()`: Returns the horizontal alignment enum integer.

```lua
print(label:GetTextXAlignment())
```

`label:SetTextXAlignment(v)`: Sets the horizontal alignment enum integer.

```lua
label:SetTextXAlignment(0)
```

`label:GetTextYAlignment()`: Returns the vertical alignment enum integer.

```lua
print(label:GetTextYAlignment())
```

`label:SetTextYAlignment(v)`: Sets the vertical alignment enum integer.

```lua
label:SetTextYAlignment(0)
```

`label:GetTextColor3()`: Returns the text color as a Color.

```lua
local c = label:GetTextColor3()
print(c.r, c.g, c.b)
```

`label:SetTextColor3(v)`: Sets the text color.

```lua
label:SetTextColor3(Color(255, 0, 0, 255))
```

`label:GetTextStrokeColor3()`: Returns the text stroke color as a Color.

```lua
local c = label:GetTextStrokeColor3()
print(c.r, c.g, c.b)
```

`label:SetTextStrokeColor3(v)`: Sets the text stroke color.

```lua
label:SetTextStrokeColor3(Color(0, 0, 0, 255))
```

***

### **TextButton**

`btn:GetText()`: Returns the current text string.

```lua
local btn = someInstance:FindFirstChildOfClass("TextButton"):TextButton()
print(btn:GetText())
```

`btn:SetText(v)`: Sets the text string.

```lua
btn:SetText("Click Me")
```

`btn:GetAutoButtonColor()`: Returns whether the button auto-changes color on hover.

```lua
print(btn:GetAutoButtonColor())
```

`btn:SetAutoButtonColor(v)`: Sets auto button color on or off.

```lua
btn:SetAutoButtonColor(false)
```

`btn:GetModal()`: Returns whether the button is modal.

```lua
print(btn:GetModal())
```

`btn:SetModal(v)`: Sets modal on or off.

```lua
btn:SetModal(true)
```

`btn:GetSelected()`: Returns whether the button is selected.

```lua
print(btn:GetSelected())
```

`btn:SetSelected(v)`: Sets the selected state.

```lua
btn:SetSelected(true)
```

`btn:GetRichText()`: Returns whether rich text is enabled.

```lua
print(btn:GetRichText())
```

`btn:SetRichText(v)`: Sets rich text on or off.

```lua
btn:SetRichText(true)
```

`btn:GetTextScaled()`: Returns whether text is scaled to fit.

```lua
print(btn:GetTextScaled())
```

`btn:SetTextScaled(v)`: Sets text scaling on or off.

```lua
btn:SetTextScaled(true)
```

`btn:GetTextWrapped()`: Returns whether text wrapping is enabled.

```lua
print(btn:GetTextWrapped())
```

`btn:SetTextWrapped(v)`: Sets text wrapping on or off.

```lua
btn:SetTextWrapped(true)
```

`btn:GetLineHeight()`: Returns the line height.

```lua
print(btn:GetLineHeight())
```

`btn:SetLineHeight(v)`: Sets the line height.

```lua
btn:SetLineHeight(1.5)
```

`btn:GetTextSize()`: Returns the font size.

```lua
print(btn:GetTextSize())
```

`btn:SetTextSize(v)`: Sets the font size.

```lua
btn:SetTextSize(18)
```

`btn:GetTextTransparency()`: Returns the text transparency.

```lua
print(btn:GetTextTransparency())
```

`btn:SetTextTransparency(v)`: Sets the text transparency.

```lua
btn:SetTextTransparency(0.5)
```

`btn:GetTextStrokeTransparency()`: Returns the text stroke transparency.

```lua
print(btn:GetTextStrokeTransparency())
```

`btn:SetTextStrokeTransparency(v)`: Sets the text stroke transparency.

```lua
btn:SetTextStrokeTransparency(0)
```

`btn:GetFont()`: Returns the font enum integer.

```lua
print(btn:GetFont())
```

`btn:SetFont(v)`: Sets the font enum integer.

```lua
btn:SetFont(3)
```

`btn:GetMaxVisibleGraphemes()`: Returns the max visible graphemes.

```lua
print(btn:GetMaxVisibleGraphemes())
```

`btn:SetMaxVisibleGraphemes(v)`: Sets the max visible graphemes. Use -1 for unlimited.

```lua
btn:SetMaxVisibleGraphemes(10)
```

`btn:GetTextDirection()`: Returns the text direction enum integer.

```lua
print(btn:GetTextDirection())
```

`btn:SetTextDirection(v)`: Sets the text direction enum integer.

```lua
btn:SetTextDirection(0)
```

`btn:GetTextTruncate()`: Returns the text truncation enum integer.

```lua
print(btn:GetTextTruncate())
```

`btn:SetTextTruncate(v)`: Sets the text truncation enum integer.

```lua
btn:SetTextTruncate(1)
```

`btn:GetTextXAlignment()`: Returns the horizontal alignment enum integer.

```lua
print(btn:GetTextXAlignment())
```

`btn:SetTextXAlignment(v)`: Sets the horizontal alignment enum integer.

```lua
btn:SetTextXAlignment(0)
```

`btn:GetTextYAlignment()`: Returns the vertical alignment enum integer.

```lua
print(btn:GetTextYAlignment())
```

`btn:SetTextYAlignment(v)`: Sets the vertical alignment enum integer.

```lua
btn:SetTextYAlignment(0)
```

`btn:GetTextColor3()`: Returns the text color as a Color.

```lua
local c = btn:GetTextColor3()
print(c.r, c.g, c.b)
```

`btn:SetTextColor3(v)`: Sets the text color.

```lua
btn:SetTextColor3(Color(255, 0, 0, 255))
```

`btn:GetTextStrokeColor3()`: Returns the text stroke color as a Color.

```lua
local c = btn:GetTextStrokeColor3()
print(c.r, c.g, c.b)
```

`btn:SetTextStrokeColor3(v)`: Sets the text stroke color.

```lua
btn:SetTextStrokeColor3(Color(0, 0, 0, 255))
```

***

### **VehicleSeat**

`seat:GetMaxSpeed()`: Returns the max speed.

```lua
local seat = someInstance:FindFirstChildOfClass("VehicleSeat"):VehicleSeat()
print(seat:GetMaxSpeed())
```

`seat:SetMaxSpeed(v)`: Sets the max speed.

```lua
seat:SetMaxSpeed(100)
```

`seat:GetSteerFloat()`: Returns the current steer value between -1 and 1.

```lua
print(seat:GetSteerFloat())
```

`seat:SetSteerFloat(v)`: Sets the steer value.

```lua
seat:SetSteerFloat(1.0)
```

`seat:GetThrottleFloat()`: Returns the current throttle value between -1 and 1.

```lua
print(seat:GetThrottleFloat())
```

`seat:SetThrottleFloat(v)`: Sets the throttle value.

```lua
seat:SetThrottleFloat(1.0)
```

`seat:GetTorque()`: Returns the torque value.

```lua
print(seat:GetTorque())
```

`seat:SetTorque(v)`: Sets the torque value.

```lua
seat:SetTorque(50)
```

`seat:GetTurnSpeed()`: Returns the turn speed.

```lua
print(seat:GetTurnSpeed())
```

`seat:SetTurnSpeed(v)`: Sets the turn speed.

```lua
seat:SetTurnSpeed(10)
```

`seat:GetOccupant()`: Returns the Humanoid currently sitting in the seat as an Instance, or nil if empty.

```lua
local occupant = seat:GetOccupant()
if occupant then
    print(occupant:Name())
end
```

***

### Audio

`Audio.Load(path, name)`: Loads an audio file from disk under a given alias name. Returns `true` on success.

```lua
Audio.Load("C:\\Yerb\\V3\\Luas\\sound.mp3", "mysound")
```

`Audio.LoadFromURL(url, name, savePath)`: Downloads an audio file from a URL, saves it to `savePath`, and loads it under `name`. Returns `true` on success.

```lua
Audio.LoadFromURL("https://example.com/sound.mp3", "mysound", "C:\\Yerb\\V3\\Luas\\sound.mp3")
```

`Audio.Play(name)`: Plays a loaded audio clip from the beginning.

```lua
Audio.Play("mysound")
```

`Audio.PlayLooped(name)`: Plays a loaded audio clip in a loop.

```lua
Audio.PlayLooped("mysound")
```

`Audio.Stop(name)`: Stops playback and seeks back to the start.

```lua
Audio.Stop("mysound")
```

`Audio.Pause(name)`: Pauses playback at the current position.

```lua
Audio.Pause("mysound")
```

`Audio.Resume(name)`: Resumes paused playback.

```lua
Audio.Resume("mysound")
```

`Audio.Unload(name)`: Closes and removes the audio clip from memory.

```lua
Audio.Unload("mysound")
```

`Audio.SetVolume(name, volume)`: Sets the volume from 0 to 1000.

```lua
Audio.SetVolume("mysound", 500)
```

`Audio.IsPlaying(name)`: Returns `true` if the clip is currently playing.

```lua
print(Audio.IsPlaying("mysound"))
```

`Audio.IsLoaded(name)`: Returns `true` if the clip has been loaded.

```lua
print(Audio.IsLoaded("mysound"))
```

`Audio.GetPosition(name)`: Returns the current playback position in milliseconds.

```lua
print(Audio.GetPosition("mysound"))
```

`Audio.GetDuration(name)`: Returns the total duration in milliseconds.

```lua
print(Audio.GetDuration("mysound"))
```

`Audio.Seek(name, ms)`: Seeks to the given position in milliseconds.

```lua
Audio.Seek("mysound", 3000)
```

`Audio.FadeVolume(name, targetVolume, durationMs)`: Gradually fades the volume to `targetVolume` (0–1000) over `durationMs` milliseconds on a background thread.

```lua
Audio.FadeVolume("mysound", 0, 2000) -- fade out over 2 seconds
```

***

### Image

`Image.Load(path)`: Loads an image from disk into the texture cache. Supports PNG, JPG, and other formats. Must be called before drawing. Returns `true` on success.

```lua
Image.Load("C:\\Yerb\\V3\\Luas\\icon.png")
```

`Image.LoadFromURL(url, savePath)`: Downloads an image from a URL, saves it to `savePath`, and loads it into the texture cache. Returns `true` on success.

```lua
Image.LoadFromURL("https://example.com/image.png", "C:\\Yerb\\V3\\Luas\\image.png")
```

`Image.Unload(path)`: Releases the texture from memory.

```lua
Image.Unload("C:\\Yerb\\V3\\Luas\\icon.png")
```

`Image.Draw(path, position, size, tint)`: Draws a loaded image at `position` with the given `size` and `tint` color. Call this inside a `Paint` event.

```lua
Image.Draw("C:\\Yerb\\V3\\Luas\\icon.png", Vector2(100, 100), Vector2(64, 64), Color(255, 255, 255, 255))
```

`Image.DrawRounded(path, position, size, tint, rounding)`: Draws a loaded image with rounded corners.

```lua
Image.DrawRounded("C:\\Yerb\\V3\\Luas\\icon.png", Vector2(100, 100), Vector2(64, 64), Color(255, 255, 255, 255), 8)
```

`Image.GetSize(path)`: Returns a table with `Width` and `Height` fields for the loaded texture.

```lua
local sz = Image.GetSize("C:\\Yerb\\V3\\Luas\\icon.png")
print(sz.Width, sz.Height)
```

`Image.IsLoaded(path)`: Returns `true` if the image is currently loaded in the texture cache.

```lua
if Image.IsLoaded("C:\\Yerb\\V3\\Luas\\icon.png") then
    Image.Draw(...)
end
```

***

### Async

`Async.Run(callback)`: Runs `callback` immediately on a new background thread.

```lua
Async.Run(function()
    wait(1)
    print("done")
end)
```

`Async.RunAfter(seconds, callback)`: Runs `callback` on a background thread after a delay.

```lua
Async.RunAfter(2.0, function()
    print("2 seconds later")
end)
```

`Async.RunEvery(interval, callback, stopCondition)`: Runs `callback` repeatedly every `interval` seconds on a background thread. Stops when `stopCondition()` returns `true`. Pass `nil` for no stop condition.

```lua
Async.RunEvery(1.0, function()
    print("tick")
end, function()
    return false -- run forever
end)
```

`Async.RunEveryWithCancel(interval, callback)`: Like `RunEvery` but returns a cancel token integer. Pass the token to `Async.Cancel` to stop the loop.

```lua
local token = Async.RunEveryWithCancel(0.5, function()
    print("running")
end)

-- later:
Async.Cancel(token)
```

`Async.Cancel(token)`: Cancels a loop started with `RunEveryWithCancel`.

```lua
Async.Cancel(token)
```

***

### Keyboard

`Keyboard.press(key)`: Sends a key down event for the given key name.

```lua
Keyboard.press("w")
```

`Keyboard.release(key)`: Sends a key up event.

```lua
Keyboard.release("w")
```

`Keyboard.tap(key, delayMs)`: Presses and releases a key with an optional delay in milliseconds between them.

```lua
Keyboard.tap("space", 50)
```

`Keyboard.is_pressed(key)`: Returns `true` if the key is currently held down.

```lua
if Keyboard.is_pressed("shift") then
    print("shift held")
end
```

`Keyboard.is_toggled(key)`: Returns `true` if the key's toggle state is on (e.g. Caps Lock).

```lua
if Keyboard.is_toggled("capslock") then
    print("caps on")
end
```

Supported key name strings include: `"a"`–`"z"`, `"0"`–`"9"`, `"f1"`–`"f12"`, `"shift"`, `"ctrl"`, `"alt"`, `"enter"`, `"space"`, `"tab"`, `"backspace"`, `"escape"`, `"up"`, `"down"`, `"left"`, `"right"`, `"home"`, `"end"`, `"insert"`, `"delete"`, `"num0"`–`"num9"`, and more.

***

### Mouse

`Mouse.isClicked(button)`: Returns `true` if the given button was clicked this frame. `0` = left, `1` = right, `2` = middle.

```lua
if Mouse.isClicked(0) then print("left clicked") end
```

`Mouse.click(button, delayMs)`: Clicks the given button with an optional delay between down and up. Button is `"left"`, `"right"`, or `"middle"`.

```lua
Mouse.click("left", 50)
```

`Mouse.leftClick(delayMs)`, `Mouse.rightClick(delayMs)`, `Mouse.middleClick(delayMs)`: Convenience click functions.

```lua
Mouse.leftClick(0)
```

`Mouse.mouseDown(button)`, `Mouse.mouseUp(button)`: Sends a raw button down or up event. `0` = left, `1` = right, `2` = middle.

```lua
Mouse.mouseDown(0)
wait(0.1)
Mouse.mouseUp(0)
```

`Mouse.scrollUp(clicks)`, `Mouse.scrollDown(clicks)`: Scrolls the mouse wheel up or down by `clicks` notches.

```lua
Mouse.scrollUp(3)
```

`Mouse.scroll(delta)`: Scrolls by a signed delta — positive scrolls up, negative scrolls down.

```lua
Mouse.scroll(-2)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yerba-1.gitbook.io/yerba-docs/api/utility.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
