Jump to content




three questions


2 replies to this topic

#1 0099

  • Members
  • 52 posts

Posted 29 June 2013 - 03:21 PM

I have a program that gets a file from rednet and runs it with pcall(function() dofile("file") end). It has the security system that stops program with error() in case of illegal action from program of if user presses F1 button.

1. One error (if user presses F1, error("break key pressed")), instead of sending message to pcall(), prints "break key pressed Press any key to continue" and after pressing any key shuts computer down. Why?

2. term.write() changed into new function: it calls old term.write and saves text into special variable. But: if program uses print(), there aren't newline characters in save variable. If program uses directly term.write with newline character manually added, there aren't newlines at the display, only "?". Why?

3. Security system also includes detection of error() function modifying. But: if program changes error() into other function, or nil, or anything, and at the next linecalls it, it calls the original function! Why?

Full code: http://pastebin.com/Ws1BKVpm

Sorry for my english if I spelled something wrong

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 30 June 2013 - 01:14 AM

Split into new topic.

2. Because term.write() doesn't handle newline characters, write() does. print() calls write(), which breaks up strings as necessary and calls term.write() and term.setCursorPos(), among others, to draw correctly to the screen.

#3 0099

  • Members
  • 52 posts

Posted 30 June 2013 - 01:01 PM

View PostLyqyd, on 30 June 2013 - 01:14 AM, said:

2. Because term.write() doesn't handle newline characters, write() does. print() calls write(), which breaks up strings as necessary and calls term.write() and term.setCursorPos(), among others, to draw correctly to the screen.
I didn't know that term.write() and _G.write() are different functions. Thanks, I will install saving system to term.setCursorPos() too.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users