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

[LUA][Help]clearPrint fuction

Started by remiX, 10 October 2012 - 06:36 PM
remiX #1
Posted 10 October 2012 - 08:36 PM
I'm trying to make an argument for my clearPrint fuction, so if you type p in the place of o it will print the string, or if you type w it will write the string. But I can't get it to work. It use to clear the screen but all of a sudden it doesn't anymore ._.


function clearPrint(string, o, x, y)
    if not x or x < 0 then x = 1 end
    if not y or y < 0 then y = 1 end
    term.clear()
    term.setCursorPos(x,y)
    if o == w then
        write(string)
    elseif o == p then
        print(string)
    end
end
Matrixmage #2
Posted 10 October 2012 - 08:46 PM
put quotes around the the "w", the "o", and the "p", so it knows its a string, if I understand what you mean…
Doyle3694 #3
Posted 10 October 2012 - 08:54 PM
only around "w" and "p". o is a variable
Matrixmage #4
Posted 10 October 2012 - 08:55 PM
ya, didn't fully look at the code :P/>/>
remiX #5
Posted 10 October 2012 - 09:07 PM
DERP Can't believe I forgot about that, damn.


function clearPrint(string, o, x, y)
    if not x or x < 0 then x = 1 end
    if not y or y < 0 then y = 1 end
    term.clear()
    term.setCursorPos(x,y)
    if o == "w" then
	    write(string)
    elseif o == "p" then
	    print(string)
    end
end

Now when I use it it clears the string that I have written.


clearPrint("derp", p)

It wouldn't show anything because for something it clears the string? O_o


function clearPrint(s, o, x, y)
    if not x or x < 0 then x = 1 end
    if not y or y < 0 then y = 1 end
    term.clear()
    term.setCursorPos(x,y)
    o(s)
end

Doing this works, but I want the argument to have just 'w' or 'p' not the full words :P/>/> Why?
Lyqyd #6
Posted 10 October 2012 - 11:12 PM
Try passing it "p" instead of p.