mirror of
https://github.com/minetest-mods/MoreMesecons.git
synced 2025-01-01 18:27:35 +01:00
moremesecons_sayer: request an insecure environment
This commit is contained in:
parent
ffe8d5f8c0
commit
b341335d3b
@ -1,10 +1,29 @@
|
|||||||
local MAX_DISTANCE = 8
|
local MAX_DISTANCE = 8
|
||||||
local use_speech_dispatcher = true
|
local use_speech_dispatcher = true
|
||||||
|
|
||||||
|
local popen, execute = io.popen, os.execute
|
||||||
|
if use_speech_dispatcher then
|
||||||
|
if not minetest.is_singleplayer() then
|
||||||
|
minetest.log("warning", "[moremesecons_sayer] use_speech_dispatcher = true, but the speech dispatcher can only be used in singleplayer")
|
||||||
|
use_speech_dispatcher = false
|
||||||
|
else
|
||||||
|
local ie = {}
|
||||||
|
if minetest.request_insecure_environment then
|
||||||
|
ie = minetest.request_insecure_environment()
|
||||||
|
end
|
||||||
|
if not ie then
|
||||||
|
minetest.log("warning", "[moremesecons_sayer] This mod needs access to insecure functions in order to use the speech dispatcher. Please add the moremesecons_sayer mod to your secure.trusted_mods settings or disable the speech dispatcher.")
|
||||||
|
use_speech_dispatcher = false
|
||||||
|
else
|
||||||
|
popen = ie.io.popen
|
||||||
|
execute = ie.os.execute
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local sayer_activate
|
local sayer_activate
|
||||||
if use_speech_dispatcher
|
if use_speech_dispatcher
|
||||||
and minetest.is_singleplayer() -- must! executing commands with it and crashes may be possible
|
and popen("if hash spd-say 2>/dev/null; then printf yes; fi"):read("*all") == "yes" then
|
||||||
and io.popen("if hash spd-say 2>/dev/null; then printf yes; fi"):read("*all") == "yes" then
|
|
||||||
minetest.log("info", "[moremesecons_sayer] using speech dispatcher")
|
minetest.log("info", "[moremesecons_sayer] using speech dispatcher")
|
||||||
local tab = {
|
local tab = {
|
||||||
"spd-say",
|
"spd-say",
|
||||||
@ -46,7 +65,7 @@ and io.popen("if hash spd-say 2>/dev/null; then printf yes; fi"):read("*all") ==
|
|||||||
else
|
else
|
||||||
tab[4] = "-i "..volume
|
tab[4] = "-i "..volume
|
||||||
end
|
end
|
||||||
os.execute(table.concat(tab, " "))
|
execute(table.concat(tab, " "))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
function sayer_activate(pos)
|
function sayer_activate(pos)
|
||||||
|
Loading…
Reference in New Issue
Block a user