ive been looking around both on the net and in my local files.
On how to disabled CTRL+t on a single terminal without install redworks (working on my own OS)
Reason i need this is.. Else you can pass the user logon.
local password = "secret"
repeat
write("Password: ") -- write without line break
local input = read() -- read input
until input == password -- repeat until the input matches the password
… you could encase the read() function within a pcall() and write this:
local password = "secret"
repeat
write("Password: ") -- write without line break
local status, input = pcall( read ) -- read input
until input == password -- repeat until the input matches the password
local input = pcall( read )
… it should've been …local status, input = pcall( read )
Otherwise I'm checking the wrong value and even the correctly entered password wouldn't have worked.function os.pullEvent()
local event, p1, p2, p3, p4, p5 = os.pullEventRaw()
if event == "terminate" then
os.reboot() -- Remove this for do not reboot on Ctrl+T
end
return event, p1, p2, p3, p4, p5
end
local falt, sEvent, param = nil,nil,nil
while not bExit do
if disableTerm then
falt, sEvent, param = pcall(os.pullEvent)
else
sEvent, param = os.pullEvent()
falt=false
end
Another way to stop ctrl+T is to run the program in another program with a loop. The drawback of this is that it resets the program after using ctrl+T.
while true do
shell.run("program")
if programended = true then break end
end
Here the program only ends if somewhere inside the programended is set to true, else it just restarts the program again.
Do note that variables won't get reset.
This is what I use for CookieSystem, there it works pretty good and I don't have to worry about any pcall stuff or other things.
Why would you have to worry about pcall? D:
Why would you have to worry about pcall? D:
Depends on the method you use. I never tried any others myself (never needed to), but I often hear about confusion with pcall :D/>/>
local isSuccessful, returnValue, returnValue2 [...] = pcall(function, arg1, arg2, ...)
if not isSuccessful then
print("Error: ", returnValue)
end
@arongy
Tried that code. and it worked. Just one note. It have to be in the start else it will mess up
@fuzzy that one didnt work for me. But as long it works for redworks its good :D/>/>
Thanks both for the replies. Nice to have community like this
while true do
fault, event, param1, param2, param3 = pcall(os.pullEvent)
if fault == false then
elseif event == "key" and param1 == 2 then
break end
end
function os.pullEvent()
local event, p1, p2, p3, p4, p5 = os.pullEventRaw()
if event == "terminate" then
error( "Terminated" )
end
return event, p1, p2, p3, p4, p5
end
os.pullEvent = os.pullEventRaw