Add a script to your spotlight and add this code.
var battery_amount = 100
var drain_rate = 2
var on = true
battery_amount -= drain_rate * delta
light_energy = battery_amount / 100
drain_rate is how fast the battery drains.
You can turn on or of the flashlight by setting the on variable to true or false.