Jump to content




[LUA][Help]clearPrint fuction


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

#1 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 10 October 2012 - 07: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


#2 Matrixmage

  • Members
  • 116 posts
  • LocationAt my Computer coding for the Computer in my Computer

Posted 10 October 2012 - 07: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...

#3 Doyle3694

  • Members
  • 815 posts

Posted 10 October 2012 - 07:54 PM

only around "w" and "p". o is a variable

#4 Matrixmage

  • Members
  • 116 posts
  • LocationAt my Computer coding for the Computer in my Computer

Posted 10 October 2012 - 07:55 PM

ya, didn't fully look at the code :P/>

#5 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 10 October 2012 - 08: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?

#6 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 10 October 2012 - 10:12 PM

Try passing it "p" instead of p.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users