📄 script.lua
字号:
_Dossier_courant= "/"_clavier= 1_image = {Image.load("clavier.png", VRAM), Image.load("clavier2.png", VRAM)}_texte= {"Editeur de Lua v1.0", "Pour acc閐er aux fichiers appuyez sur [select]"}_curseur= {x= 0, y= 0}_decal= {x= 0, y= 1}_couleur= {blanc= Color.new (31,31, 31)}_repetition= 150_nom= ""_statut= "rien"function _Fin_Programme_ () _image= nil _clavier= nil _texte= nil _curseur= nil _decal= nil _couleur= nil _repetition= nil _nom= nil _statut= nil collectgarbage()endfunction _Stylet_ (a) local compteur, x, y= 0 local text= nil if Stylus.held then x= Stylus.X y= Stylus.Y end if Stylus.held then if x~=nil and y~=nil then if x>=48 and x<=91 and y>=135 and y<=155 then if _clavier ==1 then _clavier= 2 else _clavier= 1 end while not Stylus.released do Controls.read () end end if x>=1 and x<231 and y>=19 and y<42 then text= math.floor((x-1)/23+1) if text==10 then text= 0 end end if x>=231 and y>=19 and y<42 then if _statut~="save" then _Effacer_ (1) while not Stylus.released do Controls.read () compteur= compteur+1 if compteur>_repetition then break end end else _statut= "effacer" end end if x>=231 and y>=42 and y<65 then if _clavier==1 then text= '?' else text= '&' end end if x>=231 and y>=65 and y<88 then if _clavier==1 then text= '!' else text= '|' end end if x>=231 and y>=88 and y<111 then if _clavier==1 then text= ')' else text= '}' end end if x<24 and y>=111 and y<134 then if _clavier==1 then text= '+' else text= '^' end end if x>=24 and x<47 and y>=111 and y<134 then if _clavier==1 then text= '-' else text= '_' end end if x>=47 and x<70 and y>=111 and y<134 then if _clavier==1 then text= '*' else text= '#' end end if x>=70 and x<93 and y>=111 and y<134 then if _clavier==1 then text= '/' else text= '\\' end end if x>=93 and x<162 and y>=111 and y<134 then text= ' ' end if x>=162 and x<185 and y>=111 and y<134 then text= '=' end if x>=185 and x<208 and y>=111 and y<134 then if _clavier==1 then text= '<' else text= '[' end end if x>=208 and x<231 and y>=111 and y<134 then if _clavier==1 then text= '>' else text= ']' end end if x>=231 and y>=111 and y<134 and _statut~="save" then _Ajouter_Ligne_ () while not Stylus.released do Controls.read () compteur= compteur+1 if compteur>_repetition then break end end end if x<24 and y>=134 and y<167 then if _clavier==1 then text= '~' else text= '$' end end if x>=24 and x<47 and y>=134 and y<167 then if _clavier==1 then text= '%' else text= '@' end end if x>=1 and x<231 and y>=42 and y<111 then if x<24 then if y< 64 then text= 'a' elseif y>=86 then text= 'w' else text= 'q' end elseif x>=24 and x<47 then if y< 64 then text= 'z' elseif y>=86 then text= 'x' else text= 's' end elseif x>=47 and x<70 then if y< 64 then text= 'e' elseif y>=86 then text= 'c' else text= 'd' end elseif x>=70 and x<93 then if y< 64 then text= 'r' elseif y>=86 then text= 'v' else text= 'f' end elseif x>=93 and x<116 then if y< 64 then text= 't' elseif y>=86 then text= 'b' else text= 'g' end elseif x>=116 and x<139 then if y< 64 then text= 'y' elseif y>=86 then text= 'n' else text= 'h' end elseif x>=139 and x<162 then if y< 64 then text= 'u' elseif y>=86 then if _clavier==1 then text= ',' else text= '\'' end else text= 'j' end elseif x>=162 and x<185 then if y< 64 then text= 'i' elseif y>=86 then if _clavier==1 then text= '.' else text= '\"' end else text= 'k' end elseif x>=185 and x<208 then if y< 64 then text= 'o' elseif y>=86 then if _clavier==1 then text= ':' else text= ';' end else text= 'l' end elseif x>=208 and x<231 then if y< 64 then text= 'p' elseif y>=86 then if _clavier==1 then text= '(' else text= '{' end else text= 'm' end end if not (x>=139 and y>=86) then text= string.char(string.byte(text)+(string.byte('A')-string.byte('a'))*(_clavier-1)) end end end end return textendfunction _Afficher_Texte_ () for i= _decal.y, _decal.y+18 do if i>table.getn (_texte) then break end if string.len ( string.sub (_texte[i], _decal.x+1))>0 then screen.print (SCREEN_UP, 3, 10*(i-_decal.y)+1, string.sub (_texte[i], _decal.x+1, _decal.x+43)) end endendfunction _Supprimer_Ligne_ () if _curseur.y+_decal.y<=1 then return end _curseur.y= _curseur.y-1 _curseur.x= string.len (_texte[_curseur.y+_decal.y]) _decal.x= 0 _texte[_curseur.y+_decal.y]= _texte[_curseur.y+_decal.y].._texte[_curseur.y+_decal.y+1] table.remove (_texte, _curseur.y+_decal.y+1) _Verifier_Y_ (false) _Verifier_X_ (false)endfunction _Effacer_ () local debut, fin= string.sub (_texte[_curseur.y+_decal.y], 1, _curseur.x+_decal.x-1), string.sub (_texte[_curseur.y+_decal.y], _curseur.x+_decal.x+1) if _curseur.x+_decal.x==0 then _Supprimer_Ligne_ () else _texte[_curseur.y+_decal.y]= debut..fin _curseur.x= _curseur.x-1 _Verifier_X_ (false) endendfunction _Inserer_Texte_ (a) local debut, fin= string.sub (_texte[_curseur.y+_decal.y], 1, _curseur.x+_decal.x), string.sub (_texte[_curseur.y+_decal.y], _curseur.x+_decal.x+1) _texte[_curseur.y+_decal.y]= debut..a..fin _curseur.x= _curseur.x+string.len (a) _Verifier_X_ (false)endfunction _Ajouter_Ligne_ () table.insert (_texte, _curseur.y+_decal.y+1, string.sub (_texte[_curseur.y+_decal.y], _curseur.x+_decal.x+1)) _texte[_curseur.y+_decal.y]= string.sub (_texte[_curseur.y+_decal.y], 1, _curseur.x+_decal.x)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -