Anyway, I am new to lua, but not to programming. Currently I am working on a program that will work as a password protected door, but can also accepts redstone input as what you might say are fail safes for the door (or changes in state).
The program is meant to work off a series of events as seen is this beginning version of the code (I am working on a new version and this is the base of it, and where my problem lies).
function main()
while true do
doorColor()
event, param1 = os.pullEvent()
if event == "key" and param1 == 28 then
--(press enter key)
if doorColorLock == false then --(okay to open)
term.clear()
term.setCursorPos(1,1)
end
end
if event == "redstone" and param1 == "top" then
--(reactor problem signal)
doorColor()
end
if event == "redstone" and param1 == "back" then
--(lock down signal)
doorColor()
end
end
end
So what this computer will be doing is the following
- Recieve a signal from a restone source (wireless), if this redstone signal is true, lock the door, and display a message (as well as a few other things).
- Recieve from another redstone source (wireless), with the same function as the first (just triggered by something else).
- Determine the state of the door (open or closed, which is determined by another redstone source) and display a message based on the state. If the door is closed it asks for a password, if opened a y/n command.
- If the the door is closed/opened from the other side then change the message and such as mentioned in bullet point 3.
The first event is suppose to detect when the user presses the Enter key (or Return for our older audiences). The reason I did this was because the read() command has a great nack for pausing the whole system waiting on the user.
So here's where my question lies, I know it took me awhile (sorry). Is there a way to read a line from the screen (the command line)?
The reason I put the Enter event was that I hoped that when the user would press the Enter key I could read in a certain typed line and check to see if the string matched with a password for instance, but if one of the other events were to occur, such as the doors state changing, or one of the other redstone sources changing, it would execute that event instead, and not wait for the user to finish typing and press Enter (which the read() command does).
Again thanks for any help. I do hope that something here is possible (C# has spoiled mean with almost no restrictions to what I want to do in comparison to other languages).