Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Japanese Flashcards V0.1_ALPHA
- Written by Torje 20.12.2014
- Enjoy ^^
- --]]
- -- Selection Menu
- local menu_options={
- [1]={text="I",color=colors.red},
- [2]={text="Cute",color=colors.pink},
- [3]={text="Amazing",color=colors.blue},
- [4]={text="Healthy",color=colors.green},
- [5]={text="Black",color=colors.black},
- [6]={text="Red",color=colors.red},
- [7]={text="Eye",color=colors.yellow},
- [8]={text="Human",color=colors.blue},
- [9]={text="Big",color=colors.green},
- [10]={text="Advance", color=colors.black}
- }
- local termX,termY=term.getSize()
- local function menuDraw(selected)
- local yPos = termY/2 - #menu_options/2
- for index, data in pairs(menu_options) do
- menu_options[index].bounds = {
- x1 = termX/2 - (#data.text+4)/2,
- x2 = termX/2 + (#data.text+4)/2,
- y = yPos
- }
- term.setTextColor(data.color)
- term.setCursorPos(data.bounds.x1, data.bounds.y)
- local text =
- index==selected and "["..data.text.."]" or
- " "..data.text.." "
- term.write(text)
- yPos = yPos+1
- end
- end
- local function checkClick(x,y)
- for index, data in pairs(menu_options) do
- if x>= data.bounds.x1 and x<= data.bounds.x2 and y==data.bounds.y then
- return index
- end
- end
- return false
- end
- term.clear()
- local selector = 1
- while true do
- menuDraw(selector)
- local e = {os.pullEvent()}
- if e[1] == "key" then
- if e[2] == keys.down then
- selector = selector < #menu_options and selector+1 or 1
- elseif e[2] == keys.up then
- selector = selector > 1 and selector-1 or 3 or #menu_options
- elseif e[2] == keys.enter then
- break
- end
- elseif e[1] == "mouse_click" then
- local value = checkClick(e[3], e[4])
- if value then
- selector = value
- break
- end
- end
- end
- if selector == 1 then
- term.setBackgroundColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- paintutils.drawImage("/kanji/watashi")
- term.setCursorPos(40,17)
- term.write("watashi")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement