From 56ac8a22bb1d2859c478295c6f52e2dbd1a6680c Mon Sep 17 00:00:00 2001 From: heav Date: Tue, 27 Dec 2022 20:42:05 +0000 Subject: added obj.total_energy(). --- obj.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'obj.lua') diff --git a/obj.lua b/obj.lua index 6f69cb1..bdf30dc 100644 --- a/obj.lua +++ b/obj.lua @@ -74,6 +74,14 @@ function obj.all() end) end +function obj.total_energy() + local res = 0 + for obj in obj.all() do + res = res + obj:energy() + end + return res +end + function obj:__index(v) if obj[v] then return obj[v] -- cgit v1.2.3