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

Overwriting printing in pastebin?

Started by Doyle3694, 19 December 2012 - 06:44 AM
Doyle3694 #1
Posted 19 December 2012 - 07:44 AM
Hi again, got a question. My program uses a autoupdater using pastebin. is there any way to make the pastebin program not print all those lines? I could imagine saving print and write to each a variable, then making 2 empty functions called print and write. after I've autoupdated then, I would just set them back. But there got to be a easier way, or is that my best route?
PixelToast #2
Posted 19 December 2012 - 07:50 AM
do
local print=function() end
shell.run("pastebin","stuff")
end
Doyle3694 #3
Posted 19 December 2012 - 08:06 AM
OK, please motivate doing it like that? How would that make anything better because then i can't print afterwards…
PixelToast #4
Posted 19 December 2012 - 08:08 AM
*facepalm*
thats why i localized it inside a do block >_>
digpoe #5
Posted 19 December 2012 - 08:09 AM
do
local print=function() end
shell.run("pastebin","stuff")
end
Wouldn't a better way of doing it be like this:

local type = print
local print = function() end
--code
local print = type
Then you can restore print() functionality at the end?
Doyle3694 #6
Posted 19 December 2012 - 08:09 AM
oh… You didn't put it inside code tags so thought you ment the word do in plain english…

Well.. thanks for the help!
Lyqyd #7
Posted 19 December 2012 - 08:16 AM
do
local print=function() end
shell.run("pastebin","stuff")
end
Wouldn't a better way of doing it be like this:

local type = print
local print = function() end
--code
local print = type
Then you can restore print() functionality at the end?

No. He's got it localized to that do block, so the overridden print goes out of scope at the end of it, automatically restoring print. Your example, by the way, overrides type(), which would not be good.
digpoe #8
Posted 19 December 2012 - 08:20 AM
do
local print=function() end
shell.run("pastebin","stuff")
end
Wouldn't a better way of doing it be like this:

local type = print
local print = function() end
--code
local print = type
Then you can restore print() functionality at the end?

No. He's got it localized to that do block, so the overridden print goes out of scope at the end of it, automatically restoring print. Your example, by the way, overrides type(), which would not be good.
I didn't know type() was a function, actually. So yeah. But type could be changed for anything. And also, since his code wasn't in
 tags, it was kinda confusing because 'do' has more than one meaning when not using the tags
Doyle3694 #9
Posted 19 December 2012 - 09:22 AM
–snip–