Expose read-only device power info to mods

This commit is contained in:
AverageConsumer
2026-08-12 22:13:32 +02:00
parent d38faab03c
commit e44769a48a
7 changed files with 130 additions and 3 deletions
+10
View File
@@ -999,6 +999,16 @@ function Loader:_api(mod)
return DateTime.dateTime(game, timestamp)
end,
},
-- The read-only part of love.system that device UIs legitimately need.
-- Do not expose the module: openURL and clipboard access stay sandboxed.
device = {
powerInfo = function()
local getPowerInfo = love and love.system and love.system.getPowerInfo
if not getPowerInfo then return "unknown", nil end
local state, percent = getPowerInfo()
return state, percent
end,
},
-- namespaced per mod; M11 backs these with save.modData /
-- options.modOptions, the shape mods compile against is already final
save = {
+1 -1
View File
@@ -69,7 +69,7 @@ end
-- value is the replacement to name in the error, or true when there is none
local BLOCKED_LOVE = {
filesystem = "mod.storage and mod:read", thread = true,
system = true, event = true,
system = "mod.device:powerInfo() for battery information", event = true,
}
local loveProxy