Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local api = require("GuiH")
- local term = window.create(term.current(),1,1,term.getSize())
- local gui = api.create_gui(term)
- local w,h = term.getSize()
- local cx,cy = math.ceil(w/2-17/2),math.ceil(h/2-6/2)
- local oldPull = os.pullEvent
- os.pullEvent = os.pullEventRaw
- local frame = gui.create.frame({
- name="login_window",
- x=cx,y=cy,width=17,height=6,
- dragger={
- x=1,y=1,width=12,height=1
- }
- })
- local child,window = frame.child,frame.window
- child.create.inputbox({
- name="password_in",
- x=3,y=3,width=12,
- char_limit=20,
- background_color=colors.white,
- text_color=colors.black,
- on_change_select=function(object,event,selected)
- object.background_color=selected and colors.cyan or colors.white
- if object.input == "wrong pass" then
- child.gui.inputbox.password_in.replace_char="*"
- child.gui.inputbox.password_in.input = ""
- child.gui.inputbox.password_in.cursor_pos = 0
- end
- end,
- replace_char="*"
- })
- local button = child.create.button({
- x=11,y=5,width=5,height=1,
- text=gui.text{
- text="enter",
- blit={
- "fffff",
- "ddddd"
- }
- },
- on_click=function(object)
- if child.gui.inputbox.password_in.input == "password123" then
- local term = _G.term
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.yellow)
- term.write(_HOST:match("^%a+ %d-%.%d-%.%d%.-"))
- term.setCursorPos(1,2)
- os.pullEvent = oldPull
- error()
- else
- child.gui.inputbox.password_in.replace_char = nil
- child.gui.inputbox.password_in.input = "wrong pass"
- child.gui.inputbox.password_in.cursor_pos = 10
- child.gui.inputbox.password_in.selected = false
- child.gui.inputbox.password_in.background_color = colors.white
- end
- end
- })
- child.create.button({
- x=3,y=5,width=6,height=1,
- text=gui.text{
- text="cancel",
- blit={
- "ffffff",
- "eeeeee"
- }
- },
- on_click=function()
- os.shutdown()
- end
- })
- window.setBackgroundColor(colors.gray)
- window.clear()
- window.setCursorPos(1,1)
- window.setBackgroundColor(colors.lightGray)
- window.setTextColor(colors.gray)
- window.write("login"..("-"):rep(12))
- gui.update(0)
- child.gui.inputbox.password_in.selected = true
- while true do
- term.setVisible(false)
- term.clear()
- local event = gui.update()
- if event.name == "key" and event.key == keys.enter then
- button.on_click(button)
- end
- term.setVisible(true)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement