Jump to content




[Solved] [Lua] Help with parallel and [ctrl] + T


  • You cannot reply to this topic
12 replies to this topic

#1 darkrising

  • Members
  • 234 posts
  • LocationScotland

Posted 05 July 2013 - 07:29 AM

Hello, I'm trying to secure one of my programs from the dreaded [ctrl] + T.

It originally used pcall to stop [ctrl] + T on the read function however in the latest versions of computercraft pcall is not working as it used too.

I have tried to use os.pullEvent = os.pullEventRaw however my program is running in parallel so I get a "parallel: 22 Expected string" error.

I could write a coroutine function myself but I have little understanding (even after reading a tutorial) of how they work.

Any help is much appreciated :)

Edit: I also tried making a loop that listens for the [ctrl] key and shuts down straight away, but it proved to be very unreliable.


----------------------------------------------


The fix for this was quite simple.
  • Declare os.pullEvent = os.pullEventRaw
  • Make sure all your event driven loops check the event they are driven by!
  • £££ Profit!


#2 Zudo

  • Members
  • 800 posts
  • LocationUK

Posted 05 July 2013 - 11:40 AM

I did this too, I have a script here:

Spoiler

It is safe against ctrl-t and works the same as the original parallel api

#3 darkrising

  • Members
  • 234 posts
  • LocationScotland

Posted 05 July 2013 - 12:03 PM

Thank you that looks promising, however something I noticed was by changing the order of the functions passed to the parallel api, [ctrl] + T doesn't have an effect.

I have no idea why.


Edit: Maybe not, on further testing I could not replicate the same outcome

#4 darkrising

  • Members
  • 234 posts
  • LocationScotland

Posted 05 July 2013 - 12:50 PM

View PostZudoHackz, on 05 July 2013 - 11:40 AM, said:

I did this too, I have a script here:

Spoiler

It is safe against ctrl-t and works the same as the original parallel api

Where does this differ from the parallel api?

#5 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 05 July 2013 - 10:24 PM

Please post your code.

#6 darkrising

  • Members
  • 234 posts
  • LocationScotland

Posted 06 July 2013 - 08:06 AM

View PostLyqyd, on 05 July 2013 - 10:24 PM, said:

Please post your code.

https://raw.github.c...security/client

It's one of my base security programs, I used to use pcall but it seems to be the parallel api that is exiting.

#7 Zudo

  • Members
  • 800 posts
  • LocationUK

Posted 06 July 2013 - 10:27 AM

View Postdarkrising, on 05 July 2013 - 12:50 PM, said:

View PostZudoHackz, on 05 July 2013 - 11:40 AM, said:

I did this too, I have a script here:

Spoiler

It is safe against ctrl-t and works the same as the original parallel api

Where does this differ from the parallel api?

There is a line, I can't remember where, which was different. I think it waited for an event, and then checked to see if it was the correct event before terminating.

#8 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 06 July 2013 - 10:39 AM

View PostZudoHackz, on 06 July 2013 - 10:27 AM, said:

There is a line, I can't remember where, which was different. I think it waited for an event, and then checked to see if it was the correct event before terminating.
Nope, looks identical to the parallel API to me! :P

#9 Zudo

  • Members
  • 800 posts
  • LocationUK

Posted 06 July 2013 - 11:32 AM

View Posttheoriginalbit, on 06 July 2013 - 10:39 AM, said:

View PostZudoHackz, on 06 July 2013 - 10:27 AM, said:

There is a line, I can't remember where, which was different. I think it waited for an event, and then checked to see if it was the correct event before terminating.
Nope, looks identical to the parallel API to me! :P

It works for me though!

#10 darkrising

  • Members
  • 234 posts
  • LocationScotland

Posted 06 July 2013 - 11:54 AM

View PostZudoHackz, on 06 July 2013 - 11:32 AM, said:

-snip-

Doesn't work for me, on further testing it seems that it is only when the username and password loop + disk checking loop are running together the program can be [ctrl] + T however when both options are running by themselves the program seems to be quite secure.

I don't know why it is doing this.

#11 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 06 July 2013 - 02:49 PM

Line 54 allows it to terminate. When that function receives a terminate event, line 54 will throw an "expected string" error, since you aren't verifying that you're actually getting a disk event.

#12 Zudo

  • Members
  • 800 posts
  • LocationUK

Posted 07 July 2013 - 02:53 AM

View PostLyqyd, on 06 July 2013 - 02:49 PM, said:

Line 54 allows it to terminate. When that function receives a terminate event, line 54 will throw an "expected string" error, since you aren't verifying that you're actually getting a disk event.

That is weird, because it has always worked for me.

#13 darkrising

  • Members
  • 234 posts
  • LocationScotland

Posted 07 July 2013 - 05:30 AM

View PostLyqyd, on 06 July 2013 - 02:49 PM, said:

Line 54 allows it to terminate. When that function receives a terminate event, line 54 will throw an "expected string" error, since you aren't verifying that you're actually getting a disk event.

Thank you very much, the problem is now solved. I didn't realize os.pullEventRaw responds to the terminate event aswell.

A short loop to check the event later and the probem has been solved.

Thank you to all that helped :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users