This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
KaMiKaZeTo's profile picture

Help me please.

Started by KaMiKaZeTo, 07 July 2012 - 07:07 PM
KaMiKaZeTo #1
Posted 07 July 2012 - 09:07 PM
Can someone help me how can I make brackets change their position and when i press Enter they do any command.
Something like this

and when i press down arrow to change its position
KevinW1998 #2
Posted 07 July 2012 - 09:52 PM
use os.pullEvent()
selectmode = 1
done = false
function DrawPos(x,y,str)
term.setCursorPos(x,y)
term.write(str)
end
term.clear()
DrawPos(2,1,"1")
DrawPos(2,2,"2")
DrawPos(2,3,"3")
DrawPos(1,selectmode,"[")
DrawPos(1+2,selectmode,"]")
while done == false do
evt,k = os.pullEvent()
if evt=="key" then
  DrawPos(1,selectmode," ")
  DrawPos(1+2,selectmode," ")
  if k == 200 and selectmode>1 then
   selectmode=selectmode-1
  elseif k== 208 and selectmode < 2 + 1 then
   selectmode = selectmode+1
  elseif k == 28 or k ==57 then
   done=true;
  end
end
DrawPos(1,selectmode,"[")
DrawPos(1+2,selectmode,"]")
end

With selectmode you can get the selection!