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

[LUA][NEED HELP] button showing wrong function

Started by Mackan90096, 15 April 2013 - 05:42 AM
Mackan90096 #1
Posted 15 April 2013 - 07:42 AM
Hi! I'm working on a saving/loading thing with a "new" button
for a new game.

But it shows the load function.

Code:



function main()
slc = 0
term.setBackgroundColor(colors.white)
term.setTextColor(colors.black)
term.clear()
term.setCursorPos(1,1)
print("[Load]")
print("      ")
print("[New] ")
 while true do
     event, X, Y = os.pullEvent("mouse_click")
     if slc == 0 then
       if event == "mouse_click" then
          if X >= 1 and X <= 7 and Y == 1 then
            load()
      elseif X >= 1 and X <= 7 and Y == 3 then
             game()
end
end
end
end
end

Whats wrong?
Engineer #2
Posted 15 April 2013 - 08:22 AM
The parameters for 'mouse_click' are:
event, button, x, y
SuicidalSTDz #3
Posted 15 April 2013 - 08:37 AM
The button arguement is an integer. 1 for left click and 2 for right click. Just for future reference.

So in your code, X is either 1 or 2.
Mackan90096 #4
Posted 15 April 2013 - 08:19 PM
Oh.. Thanks