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

STRG-t deaktiveren, aber Maus aktiv lassen

Started by lindi200000, 09 January 2013 - 08:58 PM
lindi200000 #1
Posted 09 January 2013 - 09:58 PM
Hallo,
ich hoffe wenn ich hier in Deutsch schreibe, dann versteht mich wer.
Ich habe folgendes Problem.
Ich habe ein Touch Code Schloss, da ich es nicht hinbekomme dieses ordentlichen über einen Monitor zum laifen zu bekommen (erkennt die Koordinaten wohl falsch),
lasse ich es direkt auf einen Advance PC laufen.
Das klappt auch alles super.
Nun ist aber das Problem noch mit STRG+T etc.
Also das die Benutzer nicht einfach den Rechner neustarten können, bzw. das Programm abbrechen.

Ich habe aus einen anderen Thread diesen Codeschnipsel genommen und für mich abgeändert.

local event, param, x, y = os.pullEvent()
if event == "key" then
elseif event == "mouse_click" then
end
Somit erfasse ich die Toucheingaben und beim benutzen einer bestimmten Tastenkombination wird das Programm beendet (so das ich an den Code komme).
Wie verhindere ich aber das man STRG+t etc. nicht benutzen kann?
Wenn ich den standart am anfang meines Codes schreibe

os.pullEvent = os.pullEventRaw

Dann klappt das mit dem Touch nicht mehr. Wie kann ich das ganze dann schreiben, das dies klappt?

Gruß Lindi

Translate by Google

Hello,
I hope when I'm writing in German, then who understands me.
I have the following problem.
I have a touch lock code, because I do not hammer out this neat to get a monitor for Laifen (detects the coordinates probably wrong)
I let it run directly on a PC Advance.
Which it does everything great.
But now the problem is with CTRL + T, etc.
So that the user can not simply reset the computer, or cancel the program.
I have taken this from another thread and modified code snippets for me.

local event, param, x, y = os.pullEvent()
if event == "key" then
elseif event == "mouse_click" then
end
Thus, I grasp the touch input and the use of a specific key combination terminates the program (so I'm at the code).
How do I stop it but the CTRL + T, etc. can not use?
If I start on the standart of my code writing

os.pullEvent = os.pullEventRaw
Then it works not with the Touch. How can I write the whole then, it works this?

Greeting Lindi
theoriginalbit #2
Posted 09 January 2013 - 10:05 PM
os.pullEvent() and os.pullEventRaw() do not allow termination. I'm not too sure about this touch issue, I haven't coded any touch yet. Can we see full code? It might be something somewhere allowing termination :)/>

OFF TOPIC: Google really needs to improve Translate :P/>
remiX #3
Posted 09 January 2013 - 10:39 PM
Yeah google translate is not so good.

Are you wanting to stop all os.pullEvents except the termination one?

When you do use os.pullEvent() or os.pullEventRaw(), termination is not allowed, as TheOriginalBit said, but there is an event for it, called "terminate". So if you want it to work, add an elseif within the if something like this:

elseif event == "terminate" then
    term.clear()
    term.setCursorPos(1,1)
    term.setTextColour(colours.red)
    print("Terminated")
    break -- To break the loop or what ever you're using
lindi200000 #4
Posted 09 January 2013 - 10:51 PM
Here is the full Code without the specific key combination to break the Programm


	term.clear()
	term.setCursorPos(1,1)
	
	pos = 1
	zahl = 0
	zahl1 = 0
	zahl2 = 0
	zahl3 = 0
	zahl4 = 0
	zahl5 = 0
	code = 00000
	pass = 22222
	
	local function zahlblock()
	local event, button, X, Y = os.pullEvent("mouse_click")
	XY = X..","..Y
	if XY == "2,7" or XY == "3,7" or XY == "4,7" then							   --1
			zahl = 1
			pos = pos+1
			write("X")
		  
			elseif XY == "6,7" or XY == "7,7" or XY == "8,7" then		   --2
			zahl = 2
			pos = pos+1
			write("X")
		  
			elseif XY == "9,7" or XY == "10,7" or XY == "11,7" then		 --3
			zahl = 3
			pos = pos+1
			write("X")
		  
			elseif XY == "2,9" or XY == "3,9" or XY == "4,9" then		   --4
			zahl = 4
			pos = pos+1
			write("X")	
		  
			elseif XY == "6,9" or XY == "7,9" or XY == "8,9" then		   --5
			zahl = 5
			pos = pos+1
			write("X")
		  
			elseif XY == "9,9" or XY == "10,9" or XY == "11,9" then		 --6
			zahl = 6
			pos = pos+1
			write("X")
		  
			elseif XY == "2,11" or XY == "3,11" or XY == "4,11" then		--7
			zahl = 7
			pos = pos+1
			write("X")	
		  
			elseif XY == "6,11" or XY == "7,11" or XY == "8,11" then		--8
			zahl = 8
			pos = pos+1
			write("X")
		  
			elseif XY == "9,11" or XY == "10,11" or XY == "11,11" then	  --9
			zahl = 9
			pos = pos+1
			write("X")
		  
			elseif XY == "6,13" or XY == "7,13" or XY == "8,13" then		--0
			zahl = 0
			pos = pos+1
			write("X")
		  
			elseif XY == "2,13" or XY == "3,13" or XY == "4,13" then		--clr
			term.setCursorPos(5,3)
			write("	 ")
			pos = 1
		  
			elseif XY == "9,13" or XY == "10,13" or XY == "11,13" then	  --enter
			code=10000*zahl1+1000*zahl2+100*zahl3+10*zahl4+zahl5
			if code == pass then
					pos = 1
					code=00000
					term.setCursorPos(5,3)
					write("	 ")
					rs.setOutput("bottom",true)
					sleep(3)
					rs.setOutput("bottom",false)
					else
					code=00000
					term.setCursorPos(5,3)
					write("	 ")
			end
	else
	end
	end
	
	
	write("-Zugangscode-\n")
	write("-------------\n")
	write("|---	 ---|\n")
	write("-------------\n")
	write(" \n")
	write("-------------\n")
	write("| 1 | 2 | 3 |\n")
	write("-------------\n")
	write("| 4 | 5 | 6 |\n")
	write("-------------\n")
	write("| 7 | 8 | 9 |\n")
	write("-------------\n")
	write("|CLR| 0 |ENT|\n")
	write("-------------\n")
	
	while true do
	
	if pos == 1 then
	term.setCursorPos(5,3)
	zahlblock()
	zahl1=zahl
	
	elseif pos == 2 then
	term.setCursorPos(6,3)
	zahlblock()
	zahl2=zahl
	
	elseif pos == 3 then
	term.setCursorPos(7,3)
	zahlblock()
	zahl3=zahl
	
	elseif pos == 4 then
	term.setCursorPos(8,3)
	zahlblock()
	zahl4=zahl
	
	elseif pos == 5 then
	term.setCursorPos(9,3)
	zahlblock()
	zahl5=zahl
	pos = 1
	
	else
	end
	end
lindi200000 #5
Posted 10 January 2013 - 06:03 AM
Hi, i have a Problem with my Code
Here is the Code:

	term.clear()
	term.setCursorPos(1,1)

	pos = 1
	zahl = 0
	zahl1 = 0
	zahl2 = 0
	zahl3 = 0
	zahl4 = 0
	zahl5 = 0
	code = 00000
	pass = 22222
abbruch = 33333
stop = 0
	
	local function zahlblock()
	local event, button, X, Y = os.pullEventRaw()
	XY = X..","..Y
if event == "mouse_click" then
  if XY == "2,7" or XY == "3,7" or XY == "4,7" then							   --1
			zahl = 1
			pos = pos+1
			write("X")
		  
			elseif XY == "6,7" or XY == "7,7" or XY == "8,7" then		   --2
			zahl = 2
			pos = pos+1
			write("X")
		  
			elseif XY == "9,7" or XY == "10,7" or XY == "11,7" then		 --3
			zahl = 3
			pos = pos+1
			write("X")
		  
			elseif XY == "2,9" or XY == "3,9" or XY == "4,9" then		   --4
			zahl = 4
			pos = pos+1
			write("X")	
		  
			elseif XY == "6,9" or XY == "7,9" or XY == "8,9" then		   --5
			zahl = 5
			pos = pos+1
			write("X")
		  
			elseif XY == "9,9" or XY == "10,9" or XY == "11,9" then		 --6
			zahl = 6
			pos = pos+1
			write("X")
		  
			elseif XY == "2,11" or XY == "3,11" or XY == "4,11" then		--7
			zahl = 7
			pos = pos+1
			write("X")	
		  
			elseif XY == "6,11" or XY == "7,11" or XY == "8,11" then		--8
			zahl = 8
			pos = pos+1
			write("X")
		  
			elseif XY == "9,11" or XY == "10,11" or XY == "11,11" then	  --9
			zahl = 9
			pos = pos+1
			write("X")
		  
			elseif XY == "6,13" or XY == "7,13" or XY == "8,13" then		--0
			zahl = 0
			pos = pos+1
			write("X")
		  
			elseif XY == "2,13" or XY == "3,13" or XY == "4,13" then		--clr
			term.setCursorPos(5,3)
			write("	 ")
			pos = 1
		  
			elseif XY == "9,13" or XY == "10,13" or XY == "11,13" then	  --enter
			code=10000*zahl1+1000*zahl2+100*zahl3+10*zahl4+zahl5
			if code == pass then
					pos = 1
					code=00000
					term.setCursorPos(5,3)
					write("	 ")
					rs.setOutput("bottom",true)
					sleep(3)
					rs.setOutput("bottom",false)
				    elseif code == abbruch then
                    code=00000
                    term.setCursorPos(5,3)
                    term.clear()
                    stop = 1
            else
					code=00000
					term.setCursorPos(5,3)
					write("	 ")
			end
  else
  end
	elseif event == "terminate" then
  sleep(10)
	else

else
end
end
	
	write("-Zugangscode-\n")
	write("-------------\n")
	write("|---	 ---|\n")
	write("-------------\n")
	write(" \n")
	write("-------------\n")
	write("| 1 | 2 | 3 |\n")
	write("-------------\n")
	write("| 4 | 5 | 6 |\n")
	write("-------------\n")
	write("| 7 | 8 | 9 |\n")
	write("-------------\n")
	write("|CLR| 0 |ENT|\n")
	write("-------------\n")
	
	while true do
	
	if pos == 1 then
	term.setCursorPos(5,3)
	zahlblock()
	zahl1=zahl
	
	elseif pos == 2 then
	term.setCursorPos(6,3)
	zahlblock()
	zahl2=zahl
	
	elseif pos == 3 then
	term.setCursorPos(7,3)
	zahlblock()
	zahl3=zahl
	
	elseif pos == 4 then
	term.setCursorPos(8,3)
	zahlblock()
	zahl4=zahl
	
	elseif pos == 5 then
	term.setCursorPos(9,3)
	zahlblock()
	zahl5=zahl
	pos = 1

    elseif stop == 1 then
	break
	
	else
	end
	end

I will terminate the Program with the Pin "33333" and not with STRG+t.
But press STRG, i have this error: "schloss:18:attempt to concatenate string and nil"

Sry for my bad english. Better then google? ^^
Orwell #6
Posted 10 January 2013 - 06:27 AM
Alle Events werden jetzt aufgefangen, anstatt nur das Mouse-Event. Darum kannst du nicht wissen was X und Y sein können.

Veränder darum:

local event, button, X, Y = os.pullEventRaw()
nach

local event, button, X, Y = os.pullEventRaw("mouse_button")
Lyqyd #7
Posted 10 January 2013 - 07:13 AM
Clarification/correction: os.pullEvent does allow termination, os.pullEventRaw does not.

Monitor touches come in as the event "monitor_touch", side, x, y.
remiX #8
Posted 10 January 2013 - 07:25 AM
It will error because you're click ctrl which is a key event and it continued but it wants to concatenate X and Y to X .. "," .. Y but it errors because they are nil.
So move
XY = X..","..Y
within the
if event == "mouse_click" then
block
lindi200000 #9
Posted 10 January 2013 - 08:33 AM
It will error because you're click ctrl which is a key event and it continued but it wants to concatenate X and Y to X .. "," .. Y but it errors because they are nil.
So move
XY = X..","..Y
within the
if event == "mouse_click" then
block

thx with this code dont terminate the computer, but the code 33333 to terminate make a "black Screen" and not the os
remiX #10
Posted 10 January 2013 - 08:39 AM
Within the elseif block for checking if it's 33333:

elseif code == abbruch then
    -- code
    -- add this:
    pos = 6

Add pos = 6, because within the infinite loop, it find's pos as a number but it doesn't check if it's equal to 6 so it should work.
lindi200000 #11
Posted 10 January 2013 - 07:07 PM
Within the elseif block for checking if it's 33333:

elseif code == abbruch then
	-- code
	-- add this:
	pos = 6

Add pos = 6, because within the infinite loop, it find's pos as a number but it doesn't check if it's equal to 6 so it should work.

thx the code is finish
remiX #12
Posted 11 January 2013 - 02:28 AM
If you want a more advanced keypad, that you can move around with set values, check this out.