Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mon = peripheral.wrap("monitor_2")
- debugmon = peripheral.wrap("monitor_3")
- compmon = term.current()
- term.redirect(mon)
- paintutils.drawFilledBox(1,1,100,100,colors.black)
- save = false
- load = false
- play = false
- beat1 = false
- beat2 = false
- beat3 = false
- beat4 = false
- beat5 = false
- beat6 = false
- beat7 = false
- beat8 = false
- beat9 = false
- beat10 = false
- beatx = 4
- beat1y = 2
- beat2y = 4
- beat3y = 6
- beat4y = 8
- beat5y = 10
- beat6y = 12
- beat7y = 14
- beat8y = 16
- beat9y = 18
- beat10y = 20 -- y positions of selectable sounds
- beat1color = colors.white
- beat2color = colors.lime
- beat3color = colors.green
- beat4color = colors.yellow
- beat5color = colors.orange
- beat6color = colors.red
- beat7color = colors.gray
- beat8color = colors.blue
- beat9color = colors.magenta
- beat10color = colors.purple -- colors of selectable sounds
- buttonPlusx = 4
- buttonPlusxEnd = 6
- buttonMinusx = 2
- buttonMinusxEnd = 4
- buttony = 23
- buttonyEnd = 25 -- x,y positions for < > buttons
- timelinePos = 1 -- variable to store current clicked position in the timeline
- timelineStartDisplay = 9 -- defines the start of the timeline on the terminal
- timelineEndDisplay = 72 -- defines the end of the timeline on the terminal
- timelineStart = 0 -- defines the start of the timeline
- timelineIcon = "|"
- timelinePosDisplay = 9 -- variable to store current clicked position on the terminal
- tracky = 0 -- variable to store y position of clicked on the terminal
- keyPos = 0
- number = 1
- abc = 3
- ahstart = timelineStartDisplay
- ah = 0
- selectedBeat = "--"
- track = {}
- x1 = 0
- y1 = 0
- for i=1,10,1 do
- track[i] = {}
- end
- function debugger()
- term.redirect(debugmon)
- term.clear()
- term.setCursorPos(1,1)
- textutils.tabulate(track[],colors.lightBlue)
- print("aaaa")
- --print(track[1][1])
- term.redirect(mon)
- end
- function addKey() -- adding/replacing a key in the table
- local a = x1 - timelineStartDisplay
- timelinePos = timelineStart + a
- drawAddedkey = true
- local t = 1
- for i=3,21,2 do -- go through all tracks
- if y1 == i then
- for key, value in ipairs(track[t]) do -- check if click is on existing key
- if key == timelinePos then
- tracky = y
- if value ~= 0 and beatDelete == true then
- track[t][timelinePos] = 0
- break
- end
- if beat1 == true then
- track[t][timelinePos] = "beat1"
- break
- elseif beat2 == true then
- track[t][timelinePos] = "beat2"
- break
- elseif beat3 == true then
- track[t][timelinePos] = "beat3"
- break
- elseif beat4 == true then
- track[t][timelinePos] = "beat4"
- break
- elseif beat5 == true then
- track[t][timelinePos] = "beat5"
- break
- elseif beat6 == true then
- track[t][timelinePos] = "beat6"
- break
- elseif beat7 == true then
- track[t][timelinePos] = "beat7"
- break
- elseif beat8 == true then
- track[t][timelinePos] = "beat8"
- break
- elseif beat9 == true then
- track[t][timelinePos] = "beat9"
- break
- elseif beat10 == true then
- track[t][timelinePos] = "beat10"
- break
- end
- end
- end
- if beat1 == true then
- track[t][timelinePos] = "beat1"
- break
- elseif beat2 == true then
- track[t][timelinePos] = "beat2"
- break
- elseif beat3 == true then
- track[t][timelinePos] = "beat3"
- break
- elseif beat4 == true then
- track[t][timelinePos] = "beat4"
- break
- elseif beat5 == true then
- track[t][timelinePos] = "beat5"
- break
- elseif beat6 == true then
- track[t][timelinePos] = "beat6"
- break
- elseif beat7 == true then
- track[t][timelinePos] = "beat7"
- break
- elseif beat8 == true then
- track[t][timelinePos] = "beat8"
- break
- elseif beat9 == true then
- track[t][timelinePos] = "beat9"
- break
- elseif beat10 == true then
- track[t][timelinePos] = "beat10"
- break
- else
- track[t][timelinePos] = "nothing"
- end
- end
- t = t + 1
- end
- debugger()
- end
- function drawBeatsPaint() -- drawing the selectable sounds
- term.redirect(mon)
- paintutils.drawFilledBox(1,1,8,25,colors.black)
- paintutils.drawPixel(beatx, beat1y, beat1color)
- paintutils.drawPixel(beatx, beat2y, beat2color)
- paintutils.drawPixel(beatx, beat3y, beat3color)
- paintutils.drawPixel(beatx, beat4y, beat4color)
- paintutils.drawPixel(beatx, beat5y, beat5color)
- paintutils.drawPixel(beatx, beat6y, beat6color)
- paintutils.drawPixel(beatx, beat7y, beat7color)
- paintutils.drawPixel(beatx, beat8y, beat8color)
- paintutils.drawPixel(beatx, beat9y, beat9color)
- paintutils.drawPixel(beatx, beat10y, beat10color)
- term.redirect(compmon)
- end
- function drawBeatsText() -- drawing text for selectable sounds
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- local x = beatx - 2
- term.redirect(mon)
- while true do
- if number > 10 then
- number = 1
- abc = 3
- break
- end
- term.setCursorPos(x, abc)
- print("beat ",number)
- number = number + 1
- abc = abc + 2
- end
- local x2 = beatx - 2
- if beat1 == true then
- term.setCursorPos(x2,beat1y)
- print(selectedBeat)
- elseif beat2 == true then
- term.setCursorPos(x2,beat2y)
- print(selectedBeat)
- elseif beat3 == true then
- term.setCursorPos(x2,beat3y)
- print(selectedBeat)
- elseif beat4 == true then
- term.setCursorPos(x2,beat4y)
- print(selectedBeat)
- elseif beat5 == true then
- term.setCursorPos(x2,beat5y)
- print(selectedBeat)
- elseif beat6 == true then
- term.setCursorPos(x2,beat6y)
- print(selectedBeat)
- elseif beat7 == true then
- term.setCursorPos(x2,beat7y)
- print(selectedBeat)
- elseif beat8 == true then
- term.setCursorPos(x2,beat8y)
- print(selectedBeat)
- elseif beat9 == true then
- term.setCursorPos(x2,beat9y)
- print(selectedBeat)
- elseif beat10 == true then
- term.setCursorPos(x2,beat10y)
- print(selectedbeat)
- end
- term.redirect(compmon)
- end
- function drawSettingsPaint() -- drawing settings menu
- term.redirect(mon)
- if settings == true then
- paintutils.drawLine(59,1,70,1,colors.yellow)
- paintutils.drawFilledBox(59,21,70,25,colors.green)
- paintutils.drawFilledBox(46,21,57,25,colors.blue)
- paintutils.drawFilledBox(33,21,44,25,colors.blue)
- else
- paintutils.drawLine(59,1,70,1,colors.orange)
- end
- term.redirect(compmon)
- end
- function drawSettingsText() -- drawing settings menu text
- term.redirect(mon)
- if settings == true then
- term.setBackgroundColor(colors.green)
- term.setCursorPos(63,23)
- print("Play")
- term.setBackgroundColor(colors.blue)
- term.setCursorPos(50,23)
- print("Save")
- term.setCursorPos(37,23)
- print("Load")
- term.setBackgroundColor(colors.yellow)
- else
- term.setBackgroundColor(colors.orange)
- end
- term.setCursorPos(61,1)
- print("Settings")
- term.redirect(compmon)
- end
- function drawButtons() -- drawing < > buttons
- term.redirect(mon)
- if plus == true then
- paintutils.drawFilledBox(buttonPlusx,buttony,buttonPlusxEnd,buttonyEnd,colors.yellow)
- local x = buttonPlusx + 1
- local y = buttony + 1
- term.setCursorPos(x,y)
- term.setBackgroundColor(colors.yellow)
- print(">")
- sleep(0.1)
- plus = false
- end
- if minus == true then
- paintutils.drawFilledBox(buttonMinusx,buttony,buttonMinusxEnd,buttonyEnd,colors.yellow)
- local x = buttonMinusx + 1
- local y = buttony + 1
- term.setCursorPos(x,y)
- term.setBackgroundColor(colors.yellow)
- print("<")
- sleep(0.1)
- minus = false
- end
- paintutils.drawFilledBox(buttonPlusx,buttony,buttonPlusxEnd,buttonyEnd,colors.orange)
- paintutils.drawFilledBox(buttonMinusx,buttony,buttonMinusxEnd,buttonyEnd,colors.orange)
- local x = buttonPlusx + 1
- local y = buttony + 1
- term.setCursorPos(x,y)
- term.setBackgroundColor(colors.orange)
- print(">")
- local x = buttonMinusx + 1
- term.setCursorPos(x,y)
- print("<")
- term.redirect(compmon)
- end
- function drawTimelinePaint() -- drawing the timeline
- term.redirect(mon)
- local x = beatx + 5
- local y = 3
- paintutils.drawFilledBox(x,2,100,23,colors.black)
- while true do
- if number > 10 then
- y = 2
- number = 1
- break
- end
- paintutils.drawLine(x,y,100,y,colors.brown)
- y = y + 2
- number = number + 1
- end
- if drawAddedkey == true then -- draws/deletes key
- if beatDelete ~= true then
- if beat1 == true then
- paintutils.drawPixel(timelinePosDisplay,tracky,beat1color)
- elseif beat2 == true then
- paintutils.drawPixel(timelinePosDisplay,tracky,beat2color)
- elseif beat3 == true then
- paintuitls.drawPixel(timelinePosDisplay,tracky,beat3color)
- elseif beat4 == teue then
- paintuitls.drawPixel(timelinePosDisplay,tracky,beat4color)
- elseif beat5 == teue then
- paintuitls.drawPixel(timelinePosDisplay,tracky,beat5color)
- elseif beat6 == teue then
- paintuitls.drawPixel(timelinePosDisplay,tracky,beat6color)
- elseif beat7 == teue then
- paintuitls.drawPixel(timelinePosDisplay,tracky,beat7color)
- elseif beat8 == teue then
- paintuitls.drawPixel(timelinePosDisplay,tracky,beat8color)
- elseif beat9 == teue then
- paintuitls.drawPixel(timelinePosDisplay,tracky,beat9color)
- elseif beat10 == teue then
- paintuitls.drawPixel(timelinePosDisplay,tracky,beat10color)
- end
- else
- paintutils.drawPixel(timelinePos,tracky,colors.brown)
- end
- drawAddedkey = false
- beatDelete = false
- end
- term.redirect(compmon)
- end
- function drawTimelineText() -- drawing timeline text and timeslider
- term.redirect(mon)
- term.setBackgroundColor(colors.black)
- local x = ahstart
- local y = 23
- local y2 = 22
- local timelineEnd = timelineStart + 63
- local b = ah
- while true do -- draws timeline numeration
- if x > 70 then
- break
- end
- term.setCursorPos(x,y)
- print(b)
- b = b + 5
- x = x + 5
- end
- local x = timelineStartDisplay
- for i=1,63,1 do
- term.setCursorPos(x,y2)
- print("|")
- x = x + 1
- end
- local y3 = 4
- if timelinePosDisplay > timelineStartDisplay and timelinePosDisplay < timelineEndDisplay then -- draws the timeslider
- for i=1,10,1 do
- term.setCursorPos(timelinePosDisplay,y3)
- print(timelineIcon)
- if y3 >= 22 then
- break
- end
- y3 = y3 + 2
- end
- end
- term.redirect(compmon)
- end
- function clickDetect() -- Detects where you clicked
- while true do
- local event,side,x,y = os.pullEvent("monitor_touch")
- if x == beatx and y >= beat1y and y <= beat10y then -- detects if you clicked on a selectable sound
- if y == beat1y then
- beat1 = true
- break
- elseif y == beat2y then
- beat2 = true
- break
- elseif y == beat3y then
- beat3 = true
- break
- elseif y == beat4y then
- beat4 = true
- break
- elseif y == beat5y then
- beat5 = true
- break
- elseif y == beat6y then
- beat6 = true
- break
- elseif y == beat7y then
- beat7 = true
- break
- elseif y == beat8y then
- beat8 = true
- break
- elseif y == beat9y then
- beat9 = true
- break
- elseif y == beat10y then
- beat10 = true
- break
- end
- end
- if y >= buttony and y <= buttonyEnd then -- scrolls the timeline if you clicked < > buttons
- if x >= buttonPlusx and x <= buttonPlusxEnd then
- minus = true
- timelinePosDisplay = timelinePosDisplay - 1
- timelineStart = timelineStart - 1
- if ahstart == 5 then
- ahstart = ahstart - 5
- ah = ah - 5
- break
- end
- ahstart = ahstart - 1
- break
- end
- if x >= buttonMinusx and x <= buttonMinusxEnd then
- plus = true
- timelinePosDisplay = timelinePosDisplay + 1
- timelineStart = timelineStart + 1
- if ahstart == 5 then
- ahstart = ahstart + 5
- ah = ah + 5
- break
- end
- ahstart = ahstart + 1
- break
- end
- end
- if y >= 21 and y <= 25 and settings == true then -- opens settings menu
- if x >= 59 and x <= 70 then
- play = true
- break
- elseif x >= 46 and x <= 57 then
- save = true
- break
- elseif x >= 33 and x <= 44 then
- load = true
- break
- end
- end
- if x >= 59 and x <= 70 and y == 1 then -- closes settings menu
- if settings == true then
- settings = false
- break
- else
- settings = true
- break
- end
- end
- if x >= timelineStartDisplay and x <= timelineEndDisplay and y >= 3 and y <= 22 then -- detects if you clicked in the timeline
- if y % 2 ~= 0 then
- x1 = x
- y1 = y
- addKey()
- else
- timelinePosDisplay = x
- local a = x - timelineStartDisplay
- timelinePos = timelineStart + a
- end
- end
- settings = false
- beat1 = false
- beat2 = false
- beat3 = false
- beat4 = false
- beat5 = false
- beat6 = false
- beat7 = false
- beat8 = false
- beat9 = false
- beat10 = false -- resets things if you clicked nothing
- break
- end
- end
- while true do -- main loop
- drawBeatsPaint()
- drawBeatsText()
- drawTimelinePaint()
- drawTimelineText()
- drawButtons()
- drawSettingsPaint()
- drawSettingsText()
- clickDetect()
- end
Advertisement
Add Comment
Please, Sign In to add comment