Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Lua by Xoandbit ( 14 years ago )
function Decoret(xs,xb,ys,yb,ekrans,teksts)
local i,j
if (ekrans==true) then
term.clear()
else
for i=xs,xb do
for j=ys,yb do
term.setCursorPos(i,j)
write(" ")
end
end
end
term.setCursorPos(xs,ys) write("+")
term.setCursorPos(xb,ys) write("+")
term.setCursorPos(xs,yb) write("+")
term.setCursorPos(xb,yb) write("+")
for i=(xs+1),(xb-1) do
term.setCursorPos(i,ys)
write("-")
term.setCursorPos(i,yb)
write("-")
end
for i=(ys+1),(yb-1) do
term.setCursorPos(xs,i)
write("|")
term.setCursorPos(xb,i)
write("|")
end
if (teksts~=nil) then
term.setCursorPos(xs+3,ys)
write(teksts)
end
end
function Menu(virsraksts,izvelnes,xs,xb,ys,yb)
xs=xs+3
xb=xb-2
ys=ys+1 -- viens vēl nāk klāt ciklā
yb=yb-2
local daudz=#izvelnes
local iespejams=yb-ys
if (daudz<iespejams) then iespejams=daudz end
local pos=1
local i
local izv=true
while izv do
Decoret(xs-3,xb+2,ys-1,yb+2,false,virsraksts)
if (pos>daudz) then pos=1 end
if (pos<1) then pos=daudz end
if (iespejams>=3) then
if (pos==1) then
for i=1,iespejams do
if (i==pos) then
term.setCursorPos(xs-1,ys+i)
write("[")
write(izvelnes[i])
write("]")
else
term.setCursorPos(xs,ys+i)
write(izvelnes[i])
end
end
else if (pos==daudz) then
for i=(daudz-iespejams+1s),daudz do
if (i==pos) then
term.setCursorPos(xs-1,ys+i)
write("[")
write(izvelnes[i])
write("]")
else
term.setCursorPos(xs,ys+i)
write(izvelnes[i])
end
end
else -- visi citi
local s,b
s=pos-(iespejams/2)
if (s<1) then s=1 end
b=(pos+(iespejams/2+iespejams%2)
if (b>daudz) then b=daudz end
for i=s,b do
if (i==pos) then
term.setCursorPos(xs-1,ys+i)
write("[")
write(izvelnes[i])
write("]")
else
term.setCursorPos(xs,ys+i)
write(izvelnes[i])
end
end
end
end
end
while true do
sleep(0)
local event, param=os.pullEventRaw()
if(event == "key") then
if(param == 28) then
izv=false
break
end
if(param == 200) then
pos=pos-1
break
end
if(param == 208) then
pos=pos+1
break
end
end
end
end
return pos
end
term.clear()
x,y=term.getSize()
Decoret(2,x-1,1,y,true," Test ")
sleep(3)
izvelnes={"A3432","asdasd","asdasd","4 izvelne","5 izvelne","afadsfasd","adsafsdf234","8 izvelne","9 izvelne","10 zdsfasfas"}
Menu("Tests",izvelnes,4,x-3,3,y-5)
sleep(10)
Revise this Paste