Lyqyd, on 29 March 2017 - 03:16 AM, said:
You'd want to use less event-specific names for the event parameter variables. I usually just chuck them all in a table and index out what I need, but if you prefer the list:
local event, param1, param2, param3, param4, param5 = t:handleEvents(os.pullEvent())
if event == "button_click" then
print(param1) --# the name of the button clicked
elseif event == "modem_message" then
print(param4) --# the message that arrived
end
But you're definitely on the right track! The ability to handle multiple types of events is exactly what the handleEvents function in Touchpoint was built for.
Ok, now that I'm on the right track, how would I do something like what's in this video:
https://youtu.be/KX9JSjC41uI . The API used here is DW20's Button API, but I'm since learning to use Touchpoint; Touchpoint seems much easier to use. Essentially, when I want the code to check for multiple events, I'd use
t:handleEvents(os.pullEvent())
but how would I check for 3 or 4 inputs; I'm unsure of which loop to use, if any. I want to be able to check for four inputs (button presses) and compare those to a password I set before, but I also want to ensure that if I send a certain command to the computer (for instance, lock) then the computer will clear the screen, print "locked" and not allow monitor input, but also do the inverse and have it so when I send a command to the computer (ex., unlock) then the computer will return to showing the keypad and allow monitor input, just as before. I know I could just check for this input again and again, setting the input to a variable then at the end comparing the variable(s) to my set password, but I'd want to know if there is a more efficient way of doing this.
EDIT: So this is what I currently have for my door. I've left out most of it, leaving only that part I actually need to use.
While true do
Local event, param1, param2, param3, param 4, param5 = t:handleEvents(os.pullEvent())
If event == "button_click" then
Local 1 = param1 --# This can be changed to store inputs as a table, if it's more efficient or 'better'
--# I don't know what to put here
In the area I've marked where I don't know what to put, what I want to happen is after I click a number button, the computer will save the input in a variable. I then want it to go back to the beginning and wait for an input again, with that input being stored in another variable. Is there a way I could do this? If so, how? Also, is storing my inputs as a table a good idea? It seems like it may make it easier to compare the data in the input table to the data in the correct password table. If this is a good idea, how would I do that?
Edited by tycoonlover1359, 29 March 2017 - 06:08 AM.