1583 posts
Location
Germany
Posted 21 April 2013 - 06:40 AM
Hello comunity,
I work on an OS, but when I want to create an account then It show me the terminal :(/>/>
here is a sniped with the parallel
function button_press()
local Event, Button, sX, sY =
os.pullEvent("mouse_click")
for i = 1, #buttons, 1 do
if sX >= buttons[i][1] and sX <= buttons[i][2] and sY >= buttons[i][3] and sY <= buttons[i][4] then
button = i
end
end
end
function writing()
term.setCursorPos(20,6)
term.setBackgroundColor(colors.gray)
username = read()
term.setCursorPos(20,8)
password = read("*")
term.setCursorPos(20,10)
email = read() --to be sure that one person/email has on account
end
parallel.waitForAny(witing, button_press)
I hope you can help me ^_^/>/>
thanks for reading
-Freack100-
2088 posts
Location
South Africa
Posted 21 April 2013 - 06:47 AM
Have the button press within the infinite loop.
Is it that when you click the spot it has set now in the if statement, it will cancel?
function button_press()
while true do
local Event, Button, sX, sY = os.pullEvent("mouse_click")
for i = 1, #buttons, 1 do
if sX >= buttons[i][1] and sX <= buttons[i][2] and sY >= buttons[i][3] and sY <= buttons[i][4] then
return -- or break...
end
end
end
end
Then it will cause the parallel.waitForAny to return.
At the moment, pulling any event will cause that function to return
645 posts
Location
'Merica
Posted 21 April 2013 - 06:47 AM
You need "os.pullEvent("mouse_click")" on the same line as "local Event, Button, sX, sY ="
1583 posts
Location
Germany
Posted 21 April 2013 - 06:54 AM
Have the button press within the infinite loop.
Is it that when you click the spot it has set now in the if statement, it will cancel?
function button_press()
while true do
local Event, Button, sX, sY = os.pullEvent("mouse_click")
for i = 1, #buttons, 1 do
if sX >= buttons[i][1] and sX <= buttons[i][2] and sY >= buttons[i][3] and sY <= buttons[i][4] then
return -- or break...
end
end
end
end
Then it will cause the parallel.waitForAny to return.
At the moment, pulling any event will cause that function to return
Yes it cancels ^_^/>
1511 posts
Location
Pennsylvania
Posted 21 April 2013 - 06:56 AM
You need "os.pullEvent("mouse_click")" on the same line as "local Event, Button, sX, sY ="
Nope, you can have it on the next line. It is a preference.
1583 posts
Location
Germany
Posted 21 April 2013 - 07:39 AM
I have tested it with the infinite loop, now it complety doesn't work ;(
2088 posts
Location
South Africa
Posted 21 April 2013 - 08:09 AM
I have tested it with the infinite loop, now it complety doesn't work ;(
Well, what happens?
1583 posts
Location
Germany
Posted 21 April 2013 - 08:18 AM
I have tested it with the infinite loop, now it complety doesn't work ;(
Well, what happens?
I can't press the buttons :(/>
2088 posts
Location
South Africa
Posted 21 April 2013 - 09:22 AM
Going to need to see more code then… because the code currently posted looks fine.
1511 posts
Location
Pennsylvania
Posted 21 April 2013 - 09:35 AM
Most likely a variable not being defined properly (buttons would be my guess from the looks of it)
Of course, it could be anything above or below the snippet.
1583 posts
Location
Germany
Posted 21 April 2013 - 10:37 AM
Most likely a variable not being defined properly (buttons would be my guess from the looks of it)
Of course, it could be anything above or below the snippet.
buttons is a table in the head of my code.
It contains two tables. In each of them are "(minX, maxX, minY, maxY, Name)"
Off-topic
I love tables :D/>
1583 posts
Location
Germany
Posted 21 April 2013 - 10:44 AM
Going to need to see more code then… because the code currently posted looks fine.
Ok,
I will post the whole code
tomorrow (just creating script)^_^/>/>/>
why just creating script?
cuz I have one program for each function of.my OS (for example "login, register, CP, config"). In my opinion it's cleaner ;D
2088 posts
Location
South Africa
Posted 21 April 2013 - 11:04 AM
Oh okay, cool :)/>
Will help you then :P/>
1583 posts
Location
Germany
Posted 21 April 2013 - 11:22 AM
Oh okay, cool :)/>/>
Will help you then :P/>/>
Thx a lot!
BTW, Is i safe when this single programs comunicate with arguments like:
Login script:
shell.run("register", ID, API_path, "login_screen") -- login_screen is the mode in them you create the account, the other one is "CP"
and the register program:
local tArgs = {...}
ID = tostring(tArgs[1])
API_path = tostring([2])
mode = tostring([3])
-snip-
--here come the thing with the buttons
-snip-
if button == 2 then
if mode == "CP" then --to go back to the CP
shell.run("CP", ID, API_path)
elseif mode == "login_screen" then
shell.run("login", ID, API_path)
end
end
=D
2088 posts
Location
South Africa
Posted 21 April 2013 - 12:57 PM
Yeah, but ID and API_path need to be variables, obviously.
Wheres the button variable defined in the register program? – Nevermind, within the snipped part.
1511 posts
Location
Pennsylvania
Posted 21 April 2013 - 01:00 PM
Most likely a variable not being defined properly (buttons would be my guess from the looks of it)
Of course, it could be anything above or below the snippet.
buttons is a table in the head of my code.
It contains two tables. In each of them are "(minX, maxX, minY, maxY, Name)"
I meant button – However, remiX just pointed out that it is defined in the snippet, which I poorly read..
2088 posts
Location
South Africa
Posted 21 April 2013 - 01:47 PM
Most likely a variable not being defined properly (buttons would be my guess from the looks of it)
Of course, it could be anything above or below the snippet.
buttons is a table in the head of my code.
It contains two tables. In each of them are "(minX, maxX, minY, maxY, Name)"
I meant button – However, remiX just pointed out that it is defined in the snippet, which I poorly read..
I would guess that's where he would define it. I might be wrong :P/>
1583 posts
Location
Germany
Posted 21 April 2013 - 01:54 PM
What explicit variable do you mean?
1583 posts
Location
Germany
Posted 22 April 2013 - 01:03 AM
I played with my coden and, ehm…. It works :D/>
Thanks to all of you ^_^/>