计算器支持小数点和科学计数法
This commit is contained in:
@@ -162,11 +162,9 @@ local langList={
|
|||||||
_1="1",_2="2",_3="3",
|
_1="1",_2="2",_3="3",
|
||||||
_4="4",_5="5",_6="6",
|
_4="4",_5="5",_6="6",
|
||||||
_7="7",_8="8",_9="9",
|
_7="7",_8="8",_9="9",
|
||||||
_0="0",["<"]="<",["="]="=",
|
_0="0",["."]=".",e="e",
|
||||||
["+"]="+",
|
["+"]="+",["-"]="-",["*"]="*",["/"]="/",
|
||||||
["-"]="-",
|
["<"]="<",["="]="=",
|
||||||
["*"]="*",
|
|
||||||
["/"]="/",
|
|
||||||
play="开始",
|
play="开始",
|
||||||
},
|
},
|
||||||
main={
|
main={
|
||||||
@@ -689,11 +687,9 @@ local langList={
|
|||||||
_1="1",_2="2",_3="3",
|
_1="1",_2="2",_3="3",
|
||||||
_4="4",_5="5",_6="6",
|
_4="4",_5="5",_6="6",
|
||||||
_7="7",_8="8",_9="9",
|
_7="7",_8="8",_9="9",
|
||||||
_0="0",["<"]="<",["="]="=",
|
_0="0",["."]=".",e="e",
|
||||||
["+"]="+",
|
["+"]="+",["-"]="-",["*"]="*",["/"]="/",
|
||||||
["-"]="-",
|
["<"]="<",["="]="=",
|
||||||
["*"]="*",
|
|
||||||
["/"]="/",
|
|
||||||
play="开始",
|
play="开始",
|
||||||
},
|
},
|
||||||
main={
|
main={
|
||||||
@@ -1206,11 +1202,9 @@ local langList={
|
|||||||
_1="1",_2="2",_3="3",
|
_1="1",_2="2",_3="3",
|
||||||
_4="4",_5="5",_6="6",
|
_4="4",_5="5",_6="6",
|
||||||
_7="7",_8="8",_9="9",
|
_7="7",_8="8",_9="9",
|
||||||
_0="0",["<"]="<",["="]="=",
|
_0="0",["."]=".",e="e",
|
||||||
["+"]="+",
|
["+"]="+",["-"]="-",["*"]="*",["/"]="/",
|
||||||
["-"]="-",
|
["<"]="<",["="]="=",
|
||||||
["*"]="*",
|
|
||||||
["/"]="/",
|
|
||||||
play="Play",
|
play="Play",
|
||||||
},
|
},
|
||||||
main={
|
main={
|
||||||
@@ -1723,11 +1717,9 @@ local langList={
|
|||||||
_1="1",_2="2",_3="3",
|
_1="1",_2="2",_3="3",
|
||||||
_4="4",_5="5",_6="6",
|
_4="4",_5="5",_6="6",
|
||||||
_7="7",_8="8",_9="9",
|
_7="7",_8="8",_9="9",
|
||||||
_0="0",["<"]="<",["="]="=",
|
_0="0",["."]=".",e="e",
|
||||||
["+"]="+",
|
["+"]="+",["-"]="-",["*"]="*",["/"]="/",
|
||||||
["-"]="-",
|
["<"]="<",["="]="=",
|
||||||
["*"]="*",
|
|
||||||
["/"]="/",
|
|
||||||
play="!!!",
|
play="!!!",
|
||||||
},
|
},
|
||||||
main={
|
main={
|
||||||
@@ -2244,11 +2236,9 @@ local langList={
|
|||||||
_1="1",_2="2",_3="3",
|
_1="1",_2="2",_3="3",
|
||||||
_4="4",_5="5",_6="6",
|
_4="4",_5="5",_6="6",
|
||||||
_7="7",_8="8",_9="9",
|
_7="7",_8="8",_9="9",
|
||||||
_0="0",["<"]="<",["="]="=",
|
_0="0",["."]=".",e="e",
|
||||||
["+"]="+",
|
["+"]="+",["-"]="-",["*"]="*",["/"]="/",
|
||||||
["-"]="-",
|
["<"]="<",["="]="=",
|
||||||
["*"]="*",
|
|
||||||
["/"]="/",
|
|
||||||
play="开始",
|
play="开始",
|
||||||
},
|
},
|
||||||
main={
|
main={
|
||||||
|
|||||||
@@ -130,12 +130,14 @@ local Widgets={
|
|||||||
newKey({name="_8", x=250,y=500,w=90, color="white", font=50,code=pressKey("8")}),
|
newKey({name="_8", x=250,y=500,w=90, color="white", font=50,code=pressKey("8")}),
|
||||||
newKey({name="_9", x=350,y=500,w=90, color="white", font=50,code=pressKey("9")}),
|
newKey({name="_9", x=350,y=500,w=90, color="white", font=50,code=pressKey("9")}),
|
||||||
newKey({name="_0", x=150,y=600,w=90, color="white", font=50,code=pressKey("0")}),
|
newKey({name="_0", x=150,y=600,w=90, color="white", font=50,code=pressKey("0")}),
|
||||||
newKey({name="<", x=250,y=600,w=90, color="lRed", font=50,code=pressKey("backspace")}),
|
newKey({name=".", x=250,y=600,w=90, color="lPurple",font=50,code=pressKey(".")}),
|
||||||
newKey({name="=", x=350,y=600,w=90, color="lYellow",font=50,code=pressKey("return")}),
|
newKey({name="e", x=350,y=600,w=90, color="lPurple",font=50,code=pressKey("e")}),
|
||||||
newKey({name="+", x=450,y=300,w=90, color="lBlue", font=50,code=pressKey("+")}),
|
newKey({name="+", x=450,y=300,w=90, color="lBlue", font=50,code=pressKey("+")}),
|
||||||
newKey({name="-", x=450,y=400,w=90, color="lBlue", font=50,code=pressKey("-")}),
|
newKey({name="-", x=450,y=400,w=90, color="lBlue", font=50,code=pressKey("-")}),
|
||||||
newKey({name="*", x=450,y=500,w=90, color="lBlue", font=50,code=pressKey("*")}),
|
newKey({name="*", x=450,y=500,w=90, color="lBlue", font=50,code=pressKey("*")}),
|
||||||
newKey({name="/", x=450,y=600,w=90, color="lBlue", font=50,code=pressKey("/")}),
|
newKey({name="/", x=450,y=600,w=90, color="lBlue", font=50,code=pressKey("/")}),
|
||||||
|
newKey({name="<", x=550,y=300,w=90, color="lRed", font=50,code=pressKey("backspace")}),
|
||||||
|
newKey({name="=", x=550,y=400,w=90, color="lYellow",font=50,code=pressKey("return")}),
|
||||||
newButton({name="play", x=640,y=600,w=180,h=90, color="lGreen", font=40,code=pressKey("space"),hide=function()return not sceneTemp.pass end}),
|
newButton({name="play", x=640,y=600,w=180,h=90, color="lGreen", font=40,code=pressKey("space"),hide=function()return not sceneTemp.pass end}),
|
||||||
},
|
},
|
||||||
main={
|
main={
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ do--calculator
|
|||||||
BG.set("none")
|
BG.set("none")
|
||||||
sceneTemp={
|
sceneTemp={
|
||||||
reg=false,
|
reg=false,
|
||||||
val=0,
|
val="0",
|
||||||
sym=false,
|
sym=false,
|
||||||
pass=false,
|
pass=false,
|
||||||
tip=require("parts/getTip"),
|
tip=require("parts/getTip"),
|
||||||
@@ -47,56 +47,83 @@ do--calculator
|
|||||||
end
|
end
|
||||||
|
|
||||||
mouseDown.calculator=NULL
|
mouseDown.calculator=NULL
|
||||||
|
local function EGG(str)
|
||||||
|
sceneTemp.reg=str
|
||||||
|
sceneTemp.sym="="
|
||||||
|
end
|
||||||
function keyDown.calculator(k)
|
function keyDown.calculator(k)
|
||||||
local S=sceneTemp
|
local S=sceneTemp
|
||||||
if byte(k)>=48 and byte(k)<=57 then
|
if byte(k)>=48 and byte(k)<=57 then
|
||||||
if S.sym=="="then
|
if S.sym=="="then
|
||||||
S.val=tonumber(k)
|
S.val=k
|
||||||
S.sym=false
|
S.sym=false
|
||||||
elseif S.sym then
|
elseif S.sym and not S.reg then
|
||||||
if not S.reg then
|
S.reg=S.val
|
||||||
S.reg=S.val
|
S.val=k
|
||||||
S.val=tonumber(k)
|
|
||||||
elseif S.val<1e13 then
|
|
||||||
S.val=S.val*10+tonumber(k)
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
if S.val<1e13 then
|
if #S.val<14 then
|
||||||
S.val=S.val*10+tonumber(k)
|
if S.val=="0"then S.val=""end
|
||||||
|
S.val=S.val..k
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
elseif k=="."then
|
||||||
|
if not(find(S.val,".",nil,true)or find(S.val,"e"))then
|
||||||
|
S.val=S.val.."."
|
||||||
|
end
|
||||||
|
elseif k=="e"then
|
||||||
|
if not find(S.val,"e")then
|
||||||
|
S.val=S.val.."e"
|
||||||
|
end
|
||||||
elseif k=="backspace"then
|
elseif k=="backspace"then
|
||||||
if S.val>0 then
|
S.val=sub(S.val,1,-2)
|
||||||
S.val=int(S.val/10)
|
if S.val==""then S.val="0"end
|
||||||
end
|
|
||||||
elseif k=="+"or k=="="and kb.isDown("lshift","rshift")then
|
elseif k=="+"or k=="="and kb.isDown("lshift","rshift")then
|
||||||
S.sym="+"
|
S.sym="+"
|
||||||
|
S.reg=false
|
||||||
elseif k=="-"then
|
elseif k=="-"then
|
||||||
S.sym="-"
|
S.sym="-"
|
||||||
|
S.reg=false
|
||||||
elseif k=="*"or k=="8"and kb.isDown("lshift","rshift")then
|
elseif k=="*"or k=="8"and kb.isDown("lshift","rshift")then
|
||||||
S.sym="*"
|
S.sym="*"
|
||||||
|
S.reg=false
|
||||||
elseif k=="/"then
|
elseif k=="/"then
|
||||||
S.sym="/"
|
S.sym="/"
|
||||||
|
S.reg=false
|
||||||
elseif k=="return"then
|
elseif k=="return"then
|
||||||
if S.val then
|
if S.val then
|
||||||
if S.sym and S.reg then
|
if S.sym and S.reg then
|
||||||
S.val=
|
S.val=
|
||||||
S.sym=="+"and S.reg+S.val or
|
S.sym=="+"and (tonumber(S.reg)or 0)+tonumber(S.val)or
|
||||||
S.sym=="-"and S.reg-S.val or
|
S.sym=="-"and (tonumber(S.reg)or 0)-tonumber(S.val)or
|
||||||
S.sym=="*"and S.reg*S.val or
|
S.sym=="*"and (tonumber(S.reg)or 0)*tonumber(S.val)or
|
||||||
S.sym=="/"and S.reg/S.val or
|
S.sym=="/"and (tonumber(S.reg)or 0)/tonumber(S.val)or
|
||||||
-1
|
-1
|
||||||
end
|
end
|
||||||
S.sym="="
|
S.sym="="
|
||||||
S.reg=false
|
S.reg=false
|
||||||
if S.val==600+26 or S.val==196 or S.val==022 or S.val==942 or S.val==238 or S.val==872 or S.val==670 or S.val==114 or S.val==7023 then
|
local v=tonumber(S.val)
|
||||||
S.pass=true
|
if v==600+26 then S.pass=true
|
||||||
elseif S.val==190000+6022 then
|
elseif v==022 then EGG("T022.Teatube")
|
||||||
S.pass=true
|
elseif v==024 then EGG("S024.Sniraite")
|
||||||
marking=nil
|
elseif v==114 then EGG("T114.Flyz")
|
||||||
|
elseif v==127 then EGG("T127.gggf")
|
||||||
|
elseif v==196 then EGG("T196.蕴空之灵")
|
||||||
|
elseif v==238 then EGG("T238.模电")
|
||||||
|
elseif v==274 then EGG("T274.ZZZ")
|
||||||
|
elseif v==512 then EGG("T512.tatianyi")
|
||||||
|
elseif v==616 then EGG("T616.Mifu")
|
||||||
|
elseif v==655 then EGG("T655.ThTsOd")
|
||||||
|
elseif v==665 then EGG("T665.Tinko")
|
||||||
|
elseif v==722 then EGG("T0722")
|
||||||
|
elseif v==872 then EGG("T872.DIAO")
|
||||||
|
elseif v==942 then EGG("T942.思竣")
|
||||||
|
elseif v==1905 then EGG("T1905.Rinnya")
|
||||||
|
elseif v==7023 then EGG("T7023.Miya")
|
||||||
|
elseif v==190000+6022 then
|
||||||
|
S.pass,marking=true
|
||||||
LOG.print("\68\69\86\58\87\97\116\101\114\109\97\114\107\32\82\101\109\111\118\101\100","message")
|
LOG.print("\68\69\86\58\87\97\116\101\114\109\97\114\107\32\82\101\109\111\118\101\100","message")
|
||||||
SFX.play("clear")
|
SFX.play("clear")
|
||||||
elseif S.val==72943816 then
|
elseif v==72943816 then
|
||||||
S.pass=true
|
S.pass=true
|
||||||
for name,M in next,Modes do
|
for name,M in next,Modes do
|
||||||
if not modeRanks[name]then
|
if not modeRanks[name]then
|
||||||
@@ -106,22 +133,22 @@ do--calculator
|
|||||||
FILE.saveUnlock()
|
FILE.saveUnlock()
|
||||||
LOG.print("\68\69\86\58\85\78\76\79\67\75\65\76\76","message")
|
LOG.print("\68\69\86\58\85\78\76\79\67\75\65\76\76","message")
|
||||||
SFX.play("clear_2")
|
SFX.play("clear_2")
|
||||||
elseif S.val==1379e8+2626e4+1379 then
|
elseif v==1379e8+2626e4+1379 then
|
||||||
S.pass=true
|
S.pass=true
|
||||||
SCN.go("debug")
|
SCN.go("debug")
|
||||||
elseif S.val==34494 then
|
elseif v==34494 then
|
||||||
error("This is an error testing message.")
|
error("This is an error testing message.")
|
||||||
elseif S.val==114514 or S.val==1145141919810 then
|
elseif v==114514 or v==1145141919810 then
|
||||||
error("小鬼自裁请")
|
error("小鬼自裁请")
|
||||||
elseif S.val==123456789 then
|
elseif v==123456789 then
|
||||||
S.reg=123456789
|
S.reg=123456789
|
||||||
S.val=987654321
|
v=987654321
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif k=="escape"then
|
elseif k=="escape"then
|
||||||
S.val,S.reg,S.sym=0
|
S.val,S.reg,S.sym="0"
|
||||||
elseif k=="delete"then
|
elseif k=="delete"then
|
||||||
S.val=0
|
S.val="0"
|
||||||
elseif k=="space"and S.pass then
|
elseif k=="space"and S.pass then
|
||||||
SCN.back()
|
SCN.back()
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user