Posted 29 December 2012 - 10:40 AM
Hello.
I have problem understanding mouse click events.
The problem is I that computer ignores Y coordinates but X coordinates works fine. That means I can click on x == 6 and y == 12 etc. and it will execute the code where it should only be executing it on the button (y == 8). The code seems to work fine when I remove all "or" from the code.
So how can I fix this problem and how can I make my code shorter without those "or" and extract them from table all at once or some other way?
Here is code that I'm working on:
I'm sorry for my bad English if you need better explanation then just ask.
I have problem understanding mouse click events.
The problem is I that computer ignores Y coordinates but X coordinates works fine. That means I can click on x == 6 and y == 12 etc. and it will execute the code where it should only be executing it on the button (y == 8). The code seems to work fine when I remove all "or" from the code.
So how can I fix this problem and how can I make my code shorter without those "or" and extract them from table all at once or some other way?
Here is code that I'm working on:
while true do
time = os.time()
time = textutils.formatTime(time, true)
x,y = term.getSize()
term.setCursorPos(x/2-6,1)
print(" :-------------:")
term.setCursorPos(x/2-6,2)
print(" :Exploder's OS:")
term.setCursorPos(x/2-6,3)
print(" :-------------:")
term.setCursorPos(3,4)
print("|---------------------------------------------|")
print(" | Main Screen |")
print(" | |")
print(" | :---------------: :---------------: |")
print(" | :Leave a Message: : Read Messages : |")
print(" | :---------------: :---------------: |")
print(" | |")
print(" | :---------------: :---------------: |")
print(" | : Shutdown : : Exit : |")
print(" | :---------------: :---------------: |")
print(" | |")
print(" | |")
print(" | |")
print(" | Time: "..time.." |")
print(" |---------------------------------------------|")
os.startTimer(0.5)
event, param1, x,y = os.pullEvent()
if event == "mouse_click" and x == 6 or x == 7 or x == 8 and y == 8 then return false -- Here is the important part.
end
end
I'm sorry for my bad English if you need better explanation then just ask.