but this COULD be wrong, im not sure at all. Just posting this. If its not wrong, please tell me. I didnt know you could combine these...
term.clear() term.setCursorPos(1,1)
Posted 06 August 2012 - 10:49 PM
term.clear() term.setCursorPos(1,1)
Posted 08 August 2012 - 12:51 AM
Posted 16 August 2012 - 08:19 AM
Posted 04 September 2012 - 06:11 AM
Posted 05 September 2012 - 06:05 AM
Posted 15 September 2012 - 05:04 PM
local options={
"option1",
"option2",
"option3"
}
local n=CUI(options)
print(n)
into this?function CUI(m)
n=1
l=#m
while true do
term.clear()
term.setCursorPos(1,2)
for i=1, l, 1 do
if i==n then print(i, " ["..m[i].."]") else print(i, " ", m[i]) end
end
print("Select a number[arrow up/arrow down]")
a, b= os.pullEventRaw()
if a == "key" then
if b==200 and n>1 then n=n-1 end
if b==208 and n<=l then n=n+1 end
if b==28 then break end
end
end
term.clear() term.setCursorPos(1,1)
return n
end
Because, when I put it just above it all, it gives an "attempt to call nil"-error at linelocal n=CUI(options)
Posted 15 September 2012 - 07:47 PM
Creator13, on 15 September 2012 - 05:04 PM, said:
local options={
"option1",
"option2",
"option3"
}
local n=CUI(options)
print(n)
into this?function CUI(m)
n=1
l=#m
while true do
term.clear()
term.setCursorPos(1,2)
for i=1, l, 1 do
if i==n then print(i, " ["..m[i].."]") else print(i, " ", m[i]) end
end
print("Select a number[arrow up/arrow down]")
a, b= os.pullEventRaw()
if a == "key" then
if b==200 and n>1 then n=n-1 end
if b==208 and n<=l then n=n+1 end
if b==28 then break end
end
end
term.clear() term.setCursorPos(1,1)
return n
end
Because, when I put it just above it all, it gives an "attempt to call nil"-error at linelocal n=CUI(options)
Posted 15 September 2012 - 10:07 PM
function clear()
term.clear()
term.setCursorPos(1,1)
end
function one()
sleep(.5)
clear()
print("Hello")
end
function two()
sleep(.5)
clear()
print("Hey")
end
function three()
sleep(.5)
clear()
print("Hi")
end
local menuOptions = {"1", "2", "3"}
local termX, termY = term.getSize()
local selected = 1
function centerText(text, termY)
term.setCursorPos(termX/2-#text/2,termY)
term.write(text)
return true
end
function start()
while true do
term.clear()
for i,v in ipairs(menuOptions) do
if i == selected then
centerText("["..v.."]", i)
else
centerText(v,i)
end
end
local id, key = os.pullEvent()
if key == 208 and selected < #menuOptions then
selected = selected + 1
elseif key == 200 and selected > 1 then
selected = selected - 1
elseif key == 28 then
return selected
end
end
end
x = start()
print()
if selected == 1 then
one()
end
if selected == 2 then
two()
end
if selected == 3 then
three()
end
Posted 16 September 2012 - 08:19 AM
Posted 16 September 2012 - 11:51 AM
Posted 18 September 2012 - 07:20 AM
Posted 21 September 2012 - 12:02 AM
Posted 24 October 2012 - 12:34 AM
Posted 24 October 2012 - 04:08 AM
Posted 28 March 2013 - 09:09 AM
Posted 28 March 2013 - 09:25 AM
Posted 28 March 2013 - 10:15 AM
Posted 28 March 2013 - 10:19 AM
Posted 31 March 2013 - 11:27 PM
Espen, on 19 March 2012 - 12:00 AM, said:
jtdavis99, on 18 March 2012 - 11:41 PM, said:
while true do
print(os.pullEvent())
end
That's much quicker I think..
Posted 06 April 2013 - 11:18 AM
0 members, 1 guests, 0 anonymous users