Battery system
QuanticPhone simulates a realistic battery that drains while the phone is in use and recharges at designated charging stations or via the SetCharging export.
Config.Battery.Enabled = false if you don't want battery management.Charge settings
Config.Battery = {
Enabled = true,
ChargeInterval = {5, 10}, -- gain {min, max}% per charging tick
}The ChargeInterval table defines a min/max range; a random value in that range is added each tick. Tick interval is set in Config.ChargePoints.chargeInterval.
Discharge settings
Config.Battery = {
DischargeInterval = {50, 60}, -- seconds per 1% drain (phone open)
DischargeWhenInactiveInterval = {80, 120}, -- seconds per 1% drain (phone closed)
DischargeWhenInactive = true, -- drain even when phone is closed
}| Key | Default | Description |
|---|---|---|
| DischargeInterval | {50, 60} | Seconds to lose 1% battery when the phone is open |
| DischargeWhenInactiveInterval | {80, 120} | Seconds to lose 1% battery when the phone is closed |
| DischargeWhenInactive | true | When false, battery only drains while the phone is open |
Activity drain rates
Certain activities drain the battery faster. Values are in % per minute:
Config.Battery.TypesDrain = {
PhoneOpen = 0.5, -- % / min while phone UI is open
InCall = 1.5, -- % / min during a voice/video call
FlashlightOn = 1.0, -- % / min while flashlight is active
GPSActive = 0.8, -- % / min while Maps app is tracking
Streaming = 2.0, -- % / min during video streaming
LowSignal = 0.5, -- % / min extra drain in a low-signal area
}| Activity | Default (% /min) | Trigger |
|---|---|---|
| PhoneOpen | 0.5 | Phone UI is visible |
| InCall | 1.5 | Active voice or video call |
| FlashlightOn | 1.0 | Camera flashlight is on |
| GPSActive | 0.8 | Maps app is open and tracking GPS |
| Streaming | 2.0 | Video call or live streaming active |
| LowSignal | 0.5 | Player is outside a signal tower range |
Battery depletion
When the battery reaches 0%, the following happens automatically:
Battery exports
GetBattery(source) → numberServerReturns the current battery level (0–100) for a player.
local level = exports.quanticPhone:GetBattery(source)
print("Battery:", level .. "%")SetBattery(source, level)ServerSets the battery level for a player. level must be 0–100.
exports.quanticPhone:SetBattery(source, 50) -- set to 50%GetBatteryLevel() → numberClientReturns the local player's current battery level.
local level = exports.quanticPhone:GetBatteryLevel()SetBatteryLevel(level)ClientSets the local player's battery level.
exports.quanticPhone:SetBatteryLevel(100) -- fully chargeSetCharging(status)ClientTells the phone it is (or isn't) being charged. Pass true to start charging, false to stop.
exports.quanticPhone:SetCharging(true) -- start charging
exports.quanticPhone:SetCharging(false) -- stop charging