summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorheav <hheav3@gmail.com>2022-12-27 20:42:05 +0000
committerheav <hheav3@gmail.com>2022-12-27 20:42:05 +0000
commit56ac8a22bb1d2859c478295c6f52e2dbd1a6680c (patch)
treee58ba42a39749ed9e506ac7d5cef84db0b2e4042
parentc15af7b16c64d0e44393ca30157fc24ded42b310 (diff)
added obj.total_energy().
-rw-r--r--obj.lua8
1 files changed, 8 insertions, 0 deletions
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]