Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m = peripheral.wrap("top")
- w,h = m.getSize()
- tID = 61
- w = w + 1
- h = h + 1
- col = { ["white"]=1, ["orange"]=2, ["magenta"]=4, ["lightblue"]=8, ["yellow"]=16, ["lime"]=32, ["pink"]=64, ["gray"]=128, ["lightgray"]=256, ["cyan"]=512, ["purple"]=1024, ["blue"]=2048, ["brown"]=4096, ["green"]=8192, ["red"]=16384, ["black"]=32768 }
- rednet.open("right")
- menu = 0
- wait = false
- orders = {}
- function loadmenus()
- menus = {}
- options = { [1]="Efficiency III", [2]="Efficiency IV", [3]="Fortune II", [4]="Fortune III", [5]="Silk Touch I", [6]="Unbreaking III", [7]="Repair I", [8]="Repair II", }
- table.insert(menus,textutils.serialize(options))
- options = { [1]="Sharpness III", [2]="Sharpness IV", [3]="Fire Aspect II", [4]="Vorpal I", [5]="Vorpal II", [6]="Soul Stealer III", [7]="Soul Stealer IV", [8]="Knockback II", [9]="Disjunction II", [10]="Disjunction III", [11]="Bane of Arthropods III", [12]="Bane of Arthropods IV", [13]="Smite III", [14]="Smite IV", }
- table.insert(menus,textutils.serialize(options))
- options = { [1]="Power III", [2]="Power IV", [3]="Flame I", [4]="Infinity I", }
- table.insert(menus,textutils.serialize(options))
- options = { [1]="Potency II", [2]="Potency III", [3]="Frugal III", [4]="Charging I", [5]="Treasure II", }
- table.insert(menus,textutils.serialize(options))
- options = { [1]="Protection III", [2]="Fire Protection III", [3]="Fire Protection IV", [4]="Blast Protection III", [5]="Blast Protection IV", [6]="Projectile Protection IV", [7]="Feather Falling IV", [8]="Haste II", [9]="Haste III", [10]="Aqua Affinity I", [11]="Respiration III", }
- table.insert(menus,textutils.serialize(options))
- end
- function swrite(str,x,y,color)
- m.setCursorPos(x,y)
- m.setTextColor(col[color])
- m.write(str)
- end
- function swritecenter(str,y,color)
- m.setCursorPos((w/2-#str/2)+1,y)
- m.setTextColor(col[color])
- m.write(str)
- end
- function drawbox(str,x1,x2,y1,y2,strcol,color)
- m.setCursorPos(x1,y1)
- m.setBackgroundColor(col[color])
- m.setTextColor(col[strcol])
- local bw = x2-x1
- local bh = y2-y1
- local bstr = " "
- while #bstr < bw do
- bstr = bstr.." "
- end
- for i=1,bh do
- m.setCursorPos(x1,y1+i-1)
- m.write(bstr)
- end
- m.setCursorPos(x1+bw/2-#str/2,y1+bh/2)
- m.write(str)
- m.setBackgroundColor(col["black"])
- return { [1]=x1, [2]=x2, [3]=y1, [4]=y2 }
- end
- function drawtext(str,x,y,color)
- m.setCursorPos(x,y)
- m.setTextColor(col[color])
- m.write(str)
- return { [1]=x, [2]=x+1, [3]=y, [4]=y+#str }
- end
- function press(but)
- if event == "monitor_touch" then
- if pr2 >= but[1] and pr2 < but[2] and pr3 >= but[3] and pr3 < but[4] then
- return true
- else
- return false
- end
- end
- end
- function drawoutline(str,strcol,color)
- m.setBackgroundColor(col[color])
- m.setTextColor(col[strcol])
- drawbox(str,1,w,1,2,strcol,color)
- drawbox("",1,2,1,h,strcol,color)
- drawbox("",w-1,w,1,h,strcol,color)
- drawbox("",1,w,h-1,h,strcol,color)
- end
- function drawmenu()
- m.clear()
- drawoutline("Fair's Enchant System","black","white")
- if menu == 0 then
- cats = {}
- swritecenter("Pick a category.",3,"white")
- table.insert(cats,textutils.serialize(drawbox("Tool Enchants",w/2-15,w/2+15,5,8,"white","lime")))
- table.insert(cats,textutils.serialize(drawbox("Weapon Enchants",w/2-15,w/2+15,9,12,"white","lime")))
- table.insert(cats,textutils.serialize(drawbox("Bow Enchants",w/2-15,w/2+15,13,16,"white","lime")))
- table.insert(cats,textutils.serialize(drawbox("Wand Enchants",w/2-15,w/2+15,17,20,"white","lime")))
- table.insert(cats,textutils.serialize(drawbox("Armor Enchants",w/2-15,w/2+15,21,24,"white","lime")))
- else
- swritecenter("Pick enchants.",3,"white")
- options = textutils.unserialize(menus[menu])
- buttons = {}
- if (#options-6*page) > 6 then
- temp = 6
- else
- temp = (#options-6*page)
- end
- for i=1,temp do
- table.insert(buttons,textutils.serialize(drawbox(options[i+6*page],w/2-15,w/2+15,4+i,5+i,"white","black")))
- end
- swritecenter("Order list:",12,"white")
- orderbuttons = {}
- if #orders > 0 then
- for i=1,#orders do
- swritecenter(orders[i],12+i,"white")
- end
- undo = drawbox("UNDO",w/2+14,w/2+18,12+#orders,13+#orders,"white","red")
- accept = drawbox("Accept",w/2-6,w/2+7,22,25,"white","lime")
- else
- undo = drawbox("UNDO",w/2+14,w/2+18,120,130,"white","red")
- accept = drawbox("Accept",w/2-6,w/2+7,122,125,"white","lime")
- end
- back = drawbox("Back",w/2-17,w/2-7,22,25,"white","red")
- if #options > (page*6+temp) then
- next = drawbox("Next",w/2+8,w/2+18,22,25,"white","red")
- else
- next = drawbox("Next",w/2+8,w/2+18,100,101,"black","black")
- end
- end
- end
- function draworder()
- drawbox("",w/2-16,w/2+16,4,21,"white","white")
- drawbox("",w/2-15,w/2+15,5,20,"white","black")
- swritecenter("Status:",6,"white")
- for i=1,#orders do
- if orderstats[i] then
- swritecenter(orders[i],7+i,"lime")
- else
- swritecenter(orders[i],7+i,"red")
- end
- end
- swritecenter(" ",17,"white")
- swritecenter(ordermsg,17,"white")
- end
- loadmenus()
- drawmenu()
- while true do
- event,pr1,pr2,pr3 = os.pullEvent()
- if not wait then
- if menu == 0 then
- for i=1,5 do
- if press(textutils.unserialize(cats[i])) then
- menu = i
- page = 0
- drawmenu()
- end
- end
- else
- if page == 0 then
- if press(back) then
- menu = 0
- drawmenu()
- end
- else
- if press(back) then
- page = page - 1
- drawmenu()
- end
- end
- if press(next) then
- page = page + 1
- drawmenu()
- elseif press(undo) then
- table.remove(orders,#orders)
- drawmenu()
- elseif press(accept) then
- wait = true
- orderstats = {}
- ordermsg = "Finding enchants.."
- for i=1,#orders do
- table.insert(orderstats,false)
- end
- draworder()
- end
- for i=1,temp do
- if press(textutils.unserialize(buttons[i])) and #orders < 8 then
- table.insert(orders,options[i+6*page])
- drawmenu()
- end
- end
- end
- else
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment