Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- local events = {}
- local exist = true
- local record = false
- if #tArgs < 1 then
- print("Usage: cook <recipe>")
- return
- end
- function cookwrite(string,x,y,txtcol,bakcol)
- if txtcol then
- term.setTextColor(txtcol)
- end
- if bakcol then
- term.setBackgroundColor(bakcol)
- end
- if x and y then
- term.setCursorPos(x, y)
- end
- write(string)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.black)
- end
- local w,h = term.getSize()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- function drawCentered(str,height)
- term.setCursorPos((w/2-(#str/2)),height)
- print(str)
- end
- fs.makeDir("RecipeList/"..tArgs[1])
- --[[if fs.isDir("RecipeList/"..tArgs[1]) then
- term.setTextColor(colors.red)
- textutils.slowPrint("Recipe Already Exists")
- term.setTextColor(colors.white)
- error()
- else]]--
- fs.makeDir("RecipeList/"..tArgs[1])
- --end
- --[[local input = read()
- if string.lower(input) == "craft" then
- print("Please put crafting recipe in turtle inventory")
- textutils.slowPrint("Press any key to continue...")
- read()
- else
- print("fail")
- return
- end]]--
- local craftingGrid = {1,2,3,5,6,7,9,10,11}
- function run()
- while true do
- drawCentered("Recipe: "..tArgs[1],1)
- print(string.rep("-",w))
- print(" Step 1 - Craft or Smelt?")
- if not record and exist then
- cookwrite("+",2,4)
- elseif record and exist then
- cookwrite(" ",2,4)
- cookwrite("+",2,5)
- else
- cookwrite(" ",2,4)
- cookwrite(" ",2,5)
- end
- events = {os.pullEvent()}
- if events[1] == "mouse_click" and events[3] > 11 and events[3] < 17 and events[4] == 3 then
- cookwrite(" Record \n",4,4,colors.white,colors.red)
- record = true
- end
- if record and events[1] == "mouse_click" and events[2] == 1 and events[3] > 3 and events[3] < 10 and events[4] == 4 then
- cookwrite(" Record \n",4,4,colors.white,colors.green)
- for i,v in ipairs(craftingGrid) do
- turtle.select(v)
- local data = turtle.getItemDetail()
- local tab = {}
- if data then
- tab[i] = {data.name,data.damage}
- end
- local fa1 = fs.open("RecipeList/"..tArgs[1].."/path1","a")
- fa1.write(textutils.serialize(tab))
- fa1.close()
- end
- cookwrite(" Record \n",4,4,colors.white,colors.red)
- end
- if record and events[1] == "mouse_click" and events[2] == 2 and events[3] > 3 and events[3] < 10 and events[4] == 4 then
- cookwrite(" Record \n",4,4,colors.white,colors.red)
- end
- if record and events[1] == "mouse_click" and events[2] == 1 and events[3] == 2 and (events[4] == 5 or events[4] == 4) then
- cookwrite("Step 2 - Craft or Smelt?",3,6)
- exist = false
- end
- if events[1] == "mouse_click" and events[3] > 11 and events[3] < 17 and events[4] == 6 then
- cookwrite(" Record \n",4,7,colors.white,colors.red)
- record2 = true
- end
- if record2 and events[1] == "mouse_click" and events[2] == 1 and events[3] > 3 and events[3] < 10 and events[4] == 7 then
- cookwrite(" Record \n",4,7,colors.white,colors.green)
- for i,v in ipairs(craftingGrid) do
- turtle.select(v)
- local data = turtle.getItemDetail()
- local tab = {}
- if data then
- tab[i] = {data.name,data.damage}
- end
- local fa1 = fs.open("RecipeList/"..tArgs[1].."/path2","a")
- fa1.write(textutils.serialize(tab))
- fa1.close()
- end
- cookwrite(" Record \n",4,7,colors.white,colors.red)
- end
- if record and events[1] == "mouse_click" and events[2] == 2 and events[3] > 3 and events[3] < 10 and events[4] == 7 then
- cookwrite(" Record \n",4,7,colors.white,colors.red)
- end
- local cdx,cdy = term.getCursorPos()
- term.setCursorPos(1,h-#events)
- for i=1,#events do
- print(events[i].." ")
- end
- term.setCursorPos(cdx,cdy)
- end
- end
- run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement