Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ENT:GetWatts(watt)
- local totalwatt = 0
- for k,src in pairs(self.PowerSources) do
- totalwatt = totalwatt + src:MaxWatt() /* returns the bandwidth, or the avaibible power if less than bandwidth */
- end
- if totalwatt < watt then
- return false
- end
- local ret = 0
- for k,src in pairs(self.PowerSources) do
- local max = src:MaxWatt()
- local percent = max / totalwatt
- local watt_used = watt * percent
- self:TakeWatt(watt_used)
- ret = ret + watt_used
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement