-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkid_math.lua
73 lines (68 loc) · 3.18 KB
/
kid_math.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
extensions.math = {
["s"] = function(c, e)
app.noop("MATH: Application started")
app.playback("my/math-start")
wrong = 0
while 1 do
readstatus = channel["READSTATUS"]:get() and channel["READSTATUS"]:get() or "empty"
if readstatus == "HANGUP" then
app.noop("User disconected")
break
end
-- Загадываю новое число, если предыдущее было отвечено верно или если три раза ответили неверно
if randdigit == nil or wrong > 3 then randdigit = math.random(1,99) end
md = string.len(tostring(randdigit))
app.saynumber(randdigit)
app.read("readdigit", nil, md)
local readdigit = channel["readdigit"]:get()
app.noop("MATH: rand: " .. randdigit .. " , read: " .. readdigit .. ", wrong: " .. wrong)
if randdigit == tonumber(readdigit) then
app.playback("my/success")
randdigit = nil
wrong = 0
else
app.playback("my/wrong")
wrong = wrong + 1
end
app.wait(1)
end
app.hangup()
end;
["777"] = function(c, e)
app.noop("MATH: Application started " .. channel.CHANNEL("callid"):get())
app.dumpchan()
--app.playback("my/math-start")
wrong = 0
while 1 do
readstatus = channel["READSTATUS"]:get() and channel["READSTATUS"]:get() or "empty"
if readstatus == "HANGUP" then
app.noop("User disconected")
break
end
-- Загадываю новое число, если предыдущее было отвечено верно или если три раза ответили неверно
if randdigit1 == nil or wrong > 3 then randdigit1 = math.random(2,5) end
if randdigit2 == nil or wrong > 3 then randdigit2 = math.random(1,5) end
md = string.len(tostring(randdigit))
app.playback("calcit")
app.saynumber(randdigit1)
app.playback("plus")
app.saynumber(randdigit2)
md = string.len(tostring(randdigit1 + randdigit2))
app.read("readdigit", nil, md)
local readdigit = channel["readdigit"]:get()
app.noop("MATH: rand1: " .. randdigit1 .. " , rand2: " .. randdigit2 .. " , read: " .. readdigit .. ", wrong: " .. wrong)
if randdigit1 + randdigit2 == tonumber(readdigit) then
app.playback("my/success")
app.playback("sugar")
randdigit1 = nil
randdigit2 = nil
wrong = 0
else
app.playback("my/wrong")
wrong = wrong + 1
end
app.wait(1)
end
app.hangup()
end;
};