2 posts
Posted 16 November 2014 - 08:32 AM
Hello, I would like it if someone could either make me or teach me how to make a program for a 3x4 touchscreen menu. The menu must have 2 buttons, One would go to a screen with a on-screen number pad to enter a 4 digit password to unlock a iron door linked to the back of the computer, and the other button leads to a screen that will read the power levels of all Resonant Energy Cells(From Thermal Expansion) that is linked to the computer and a button that leads back to the menu. Also if it has the capability to add more buttons easily, that would be awesome. Thank You
-Symmedy
477 posts
Location
Germany
Posted 16 November 2014 - 10:11 AM
I would recommend to save the Buttons in a table:
buttons = {
{button_text,button_start_x,button_y,function},
{"Enter Pin",10,10,pin}
}
So you can easily add Buttons.
This would be the code:
mon = peripheral.wrap("side") --the monitor with the buttons
function pin()
--here you have to enter your function for the Pin code
end
function cells()
--the code for the Energy cells
end
buttons = {
{"Energy cells",10,12,cells},
{"Enter Pin",10,10,pin}
}
while true do
for i = 1,#buttons do
mon.setCursorPos(buttons[i][2],buttons[i][3])
--for advanced monitors you may add color here
mon.write(buttons[i][1])
end
e = {os.pullEvent()}
if e[1] == "monitor_touch" then
for i = 1,#buttons do
if e[3] >= buttons[i][2] and e[3] <= buttons[i][2] + buttons[i][1]:len() and e[4] == buttons[i][3] then --if you want you can add "and e[2] == "side"" this will check if the monitor, the event came from is the monitor you have chosen
buttons[i][4]()
end
end
end
end
Hope i could help you
2 posts
Posted 16 November 2014 - 05:08 PM
So how do I incorporate a password into it and how would i connect it to the energy cells for the levels?
I would recommend to save the Buttons in a table:
buttons = {
{button_text,button_start_x,button_y,function},
{"Enter Pin",10,10,pin}
}
So you can easily add Buttons.
This would be the code:
mon = peripheral.wrap("side") --the monitor with the buttons
function pin()
--here you have to enter your function for the Pin code
end
function cells()
--the code for the Energy cells
end
buttons = {
{"Energy cells",10,12,cells},
{"Enter Pin",10,10,pin}
}
while true do
for i = 1,#buttons do
mon.setCursorPos(buttons[i][2],buttons[i][3])
--for advanced monitors you may add color here
mon.write(buttons[i][1])
end
e = {os.pullEvent()}
if e[1] == "monitor_touch" then
for i = 1,#buttons do
if e[3] >= buttons[i][2] and e[3] <= buttons[i][2] + buttons[i][1]:len() and e[4] == buttons[i][3] then --if you want you can add "and e[2] == "side"" this will check if the monitor, the event came from is the monitor you have chosen
buttons[i][4]()
end
end
end
end
Hope i could help you
Also I have the password coded in and I have the redstone api installed, but what is the actual on-screen touchscreen numpad password function xD