Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function TextField(settings)
- local C
- if settings[1] == true then C = "*" else C = nil end --censor text
- local E = true
- if settings[2] ~= nil then E = settings[2] end --allow use to cancel?
- local X
- local Y
- local TX, TY = term.getCursorPos()
- if E == true then
- X = TX
- Y = TY + 1
- paintutils.drawPixel(X,Y,colors.red())
- end
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- local input
- while true do
- term.setCursorPos(TX,TY)
- term.clearLine()
- local e, a, b, c = os.pullEvent()
- if e == "mouse_click" and b == X and c == Y and E == true then input = nil break end --cancel
- if e == "key" and a == keys.enter then break elseif e == "key" then input = read(C) end
- end
- return input
- end
- return { TextField = TextField }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement