28 posts
Posted 05 April 2015 - 10:45 AM
I have a function that create a "label" with text color and background, but works only text color, what is wrong?
function label(x,y,text,colorStr,colorBck)
if colorStr ~= nil then
term.setTextColor(colorStr)
elseif colorBck ~= nil then
term.setBackgroundColor(colorBck)
end
term.setCursorPos(x,y)
print(text)
end
7083 posts
Location
Tasmania (AU)
Posted 05 April 2015 - 11:07 AM
Your "elseif" will only be processed if your initial "if" is false.
28 posts
Posted 05 April 2015 - 11:16 AM
Oh, I see. Thank you
28 posts
Posted 05 April 2015 - 12:55 PM
Another question:
How to use pastebin runs without shell.run()? Shell.run write a string like a: "Connecting to pastebin". Can I run programs without this message?
7083 posts
Location
Tasmania (AU)
Posted 05 April 2015 - 01:10 PM
If your only goal is to hide that message, then your best bet is the window API - create a hidden window and redirect all terminal output to that while running your pastebin downloads.
Eg:
local myHiddenWindow, originalTerm = window.create(term.current(), 0, 0, 1, 1, false), term.current()
term.redirect(myHiddenWindow)
shell.run("pastebin get cUYTGbpb package")
shell.run("pastebin get nKQZwgtv bbtetris")
term.redirect(originalTerm)
28 posts
Posted 05 April 2015 - 01:15 PM
If your only goal is to hide that message, then your best bet is the window API - create a hidden window and redirect all terminal output to that while running your pastebin downloads.
I'm need not get pastebin, I'm need run. For example,
installer.
7083 posts
Location
Tasmania (AU)
Posted 05 April 2015 - 01:20 PM
Well, you're already downloading and saving files without using the pastebin script. All you need to do is shell.run() those programs, yes?
You only get "connecting to pastebin" when running the pastebin script because the pastebin script writes that message. It's not because of shell.run().
28 posts
Posted 05 April 2015 - 01:22 PM
You only get "connecting to pastebin" when running the pastebin script because the pastebin script writes that message. It's not because of shell.run().
And Can I fix it?
7083 posts
Location
Tasmania (AU)
Posted 05 April 2015 - 01:36 PM
If you want to use "pastebin run", then you can't hide the message pastebin writes without also hiding anything the script you run writes.
But why would you
want to do that? Why not just have your script do what the pastebin script does (
loadstring the downloaded data and run it as a function), but without writing the message?
A primitive example:
local function pastebin(paste, fileName)
local file = http.get("http://pastebin.com/raw.php?i="..paste)
if file then
local myFunc = loadstring(file.readAll())
file.close() -- Web handles should be closed too!
setfenv(myFunc, getfenv())
myFunc()
else
error("Pastebin server is not avaible.")
end
end