Posted 08 June 2012 - 08:40 AM
I have this code running
function keyPad(void)
local mt = {
{1,2,3},
{4,5,6},
{7,8,9}
};
local mt2 = {0,0,0,0};
local xOffset = 23;
local nX = 1;
local nY = 1;
local n = 1;
while (n<=4) do
term.clear();
for i = 1,3 do
for j = 1,3 do
term.setCursorPos((xOffset + i),(j));
if (nY == j) and (nX == i) then
term.write("*");
else
term.write(mt[j]);
end
end
end
for i = 1,n-1 do
term.setCursorPos((xOffset + i),(4));
term.write("*");
end
r,s = os.pullEvent();
if(r == "key") then
if (s == 205) then
if (nX < 3) then
nX = nX +1;
end
end
if (s == 208) then
if (nY < 3) then
nY = nY +1;
end
end
if (s == 200) then
if (nY > 1) then
nY = nY - 1;
end
end
if (s == 203) then
if (nX > 1) then
nX = nX -1;
end
end
if (s == 28) then
mt2[n] = mt[nY][nX];
n = n+1;
end
end
end
term.clear();
term.setCursorPos((1),(1));
return mt2;
end
name
function: keyPad(hello);
….but when i try to run from the computer i get a string "startup":66: '<name>' expected
Any help? Thanks
function keyPad(void)
local mt = {
{1,2,3},
{4,5,6},
{7,8,9}
};
local mt2 = {0,0,0,0};
local xOffset = 23;
local nX = 1;
local nY = 1;
local n = 1;
while (n<=4) do
term.clear();
for i = 1,3 do
for j = 1,3 do
term.setCursorPos((xOffset + i),(j));
if (nY == j) and (nX == i) then
term.write("*");
else
term.write(mt[j]);
end
end
end
for i = 1,n-1 do
term.setCursorPos((xOffset + i),(4));
term.write("*");
end
r,s = os.pullEvent();
if(r == "key") then
if (s == 205) then
if (nX < 3) then
nX = nX +1;
end
end
if (s == 208) then
if (nY < 3) then
nY = nY +1;
end
end
if (s == 200) then
if (nY > 1) then
nY = nY - 1;
end
end
if (s == 203) then
if (nX > 1) then
nX = nX -1;
end
end
if (s == 28) then
mt2[n] = mt[nY][nX];
n = n+1;
end
end
end
term.clear();
term.setCursorPos((1),(1));
return mt2;
end
name
function: keyPad(hello);
….but when i try to run from the computer i get a string "startup":66: '<name>' expected
Any help? Thanks