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

free text box you can use in your api

Started by ETHANATOR360, 22 February 2013 - 03:25 AM
ETHANATOR360 #1
Posted 22 February 2013 - 04:25 AM
free text box feel free to use it in your ui api
Spoiler


function txtBox (XPos,YPos,length,isCensored)
if isCensored == true then cen = "*"
else cen = nil
end
term.setCursorPos (XPos,YPos)
term.setBackgroundColor (1)
for i = 1,length do
write " "
end
term.setTextColor (32768)
term.setCursorPos(XPos,YPos)
while true do
local event, arg, x,y = os.pullEvent("mouse_click")
if y == YPos and x >= XPos and x <= XPos + length then
local txtBox = read(cen)
term.setBackgroundColor (32768)
term.setTextColor (1)
return txtBox
end
end
end
JokerRH #2
Posted 22 February 2013 - 10:58 AM
So what is the point of this?
The main part is the read("*") line. The rest only waits until you press
Anywhere in it's assigned area, so you will even need to create a new
coroutine for it.
So I'm guessing this is one of your first programs?
ETHANATOR360 #3
Posted 23 February 2013 - 04:50 AM
no actually it was an expirament to see if i could emulate a text box experience that could be felt while using windows or any other operating system with out having to code it in to the OS its self
EDIT: 250 post!! :P/>
Mads #4
Posted 24 February 2013 - 09:55 PM
This does that in now way. Try writing too text. Create a custom read function, and do all of the rendering yourself. Then we're talking.