Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- This is a helper program made in ComputerCraft for a mobile game called Cell Lab. Run the program and click on 'Help' for more information.
- -- Before running this program, make sure you have the appropriate API programs by running the following commands:
- -- pastebin get Rac6Jxjg "/API/LibAppend.lua"
- -- pastebin get t2TvSiSU "/API/Class.lua"
- -- pastebin get KA2dK07y "/API/events.lua"
- -- You can get this program from https://pastebin.com/F4gH1cTA
- require("/API/events")
- local types = {
- "Phagocyte",
- "Flagellocyte",
- "Photocyte",
- "Devorocyte",
- "Lipocyte",
- "Keratinocyte",
- "Buoyocyte",
- "Glueocyte",
- "Virocyte",
- "Nitrocyte",
- "Myocyte",
- "Neurocyte",
- "Senseocyte",
- "Stereocyte",
- "Secrocyte",
- "Stemocyte",
- "Gamete",
- "Ciliocyte"
- }
- local modes = {
- init = 1,
- splits = 0
- }
- local tree = {}
- local dragScroll = vector2.new()
- local divider = 24
- local display = {}
- display.size = vector2.new(term.getSize())
- if display.size.x < 42 or display.size.y < 14 then error("error: minimum screen size: 42x14 (current: " .. display.size.x .. "x" .. display.size.y .. ")", 0) end
- display.chart = {size = vector2.new(display.size.x-divider, display.size.y-1)}
- display.chart.win = window.create(term.current(), divider+1, 2, display.chart.size.x, display.chart.size.y)
- display.scroll = {
- mode = 0,
- tree = vector2.new(0, math.floor(display.chart.size.y/-2)+1)
- }
- local buildTree = function()
- local oldPos = 1
- if #tree > 0 then
- oldPos = tree[0][1].padding
- end
- local function makeTree(split, id, cell, parent, upAd, downAd)
- tree[split][id] = {
- cell = cell, parent = parent,
- upAd = upAd, downAd = downAd,
- child = {},
- padding = id*2-1
- }
- if split < modes.splits then
- if not tree[split+1] then tree[split+1] = {} end
- if modes[cell].split then
- makeTree(split+1, #tree[split+1]+1, modes[cell].child[1], id, modes[cell].childA[1] and modes[cell].adhesin, modes[cell].adhesin)
- tree[split][id].child[1] = #tree[split+1]
- makeTree(split+1, #tree[split+1]+1, modes[cell].child[2], id, modes[cell].adhesin, modes[cell].childA[2] and modes[cell].adhesin)
- tree[split][id].child[2] = #tree[split+1]
- tree[split][id].padding = math.floor((tree[split+1][tree[split][id].child[1] ].padding + tree[split+1][tree[split][id].child[2] ].padding) / 2)
- else
- makeTree(split+1, #tree[split+1]+1, cell, id, tree[split][id].upAd, tree[split][id].downAd)
- tree[split][id].child[1] = #tree[split+1]
- tree[split][id].padding = tree[split+1][tree[split][id].child[1] ].padding
- end
- end
- end
- tree = {[0] = {}}
- makeTree(0, 1, modes.init, nil, false, false)
- display.scroll.tree.y = display.scroll.tree.y + (tree[0][1].padding - oldPos)
- end
- display.modesColumn = function()
- term.setCursorPos(1, 1)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.yellow)
- term.write("M Cell Type ASIC1AC2A")
- end
- display.setColor = function(c)
- term.setBackgroundColor(2^c)
- if c == 15 then term.setTextColor(colors.white)
- else term.setTextColor(colors.black) end
- end
- display.mode = function(n)
- local yPos = n+1-display.scroll.mode
- local checkMark = function(b)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.red)
- if b then term.write(string.char(7))
- else term.write(" ") end
- end
- if isBetween(yPos, 1, display.size.y+1) and modes[n] ~= nil then
- term.setCursorPos(1, yPos)
- display.setColor(modes[n].color)
- term.write(string.pad(n, "0", 2))
- display.setColor(modes[n].color)
- if modes[n].color == 7 then term.setTextColor(colors.lightGray)
- else term.setTextColor(colors.gray) end
- term.write(types[modes[n].cellType])
- term.setBackgroundColor(colors.black)
- term.write(string.rep(" ", 12-types[modes[n].cellType]:len()))
- checkMark(modes[n].adhesin)
- checkMark(modes[n].split)
- checkMark(n == modes.init)
- for a = 1, 2 do
- display.setColor(modes[modes[n].child[a]].color)
- term.write(string.pad(modes[n].child[a], "0", 2))
- checkMark(modes[n].childA[a])
- end
- end
- end
- display.modesList = function()
- for y = 1, display.size.y-1 do
- display.mode(y+display.scroll.mode)
- end
- end
- display.envSettings = function()
- term.setCursorPos(divider+1, 1)
- term.setTextColor(colors.yellow)
- term.setBackgroundColor(colors.black)
- term.write("S:")
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.write(string.pad(modes.splits, " ", 2))
- term.setTextColor(colors.yellow)
- term.setBackgroundColor(colors.black)
- term.write(" C:")
- term.setTextColor(colors.white)
- term.write(#tree[#tree] .. " ")
- term.setCursorPos(display.size.x-5, 1)
- term.blit("Help " .. string.char(215), "fffff0", "8888fe")
- end
- display.topLine = function()
- term.setCursorPos(1, 1)
- term.setBackgroundColor(colors.black)
- term.clearLine()
- display.modesColumn()
- term.write(" ")
- display.envSettings()
- end
- display.columnName = function(str, xPos)
- str = tostring(str)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(xPos, 1)
- term.clearLine()
- term.write(str)
- os.pullEvent("mouse_click")
- display.topLine()
- end
- display.tree = function()
- local oldTerm = term.redirect(display.chart.win)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- local drawConnection = function(thisSplit, firstCell, secondCell, yPos)
- local tCol, bCol = "", ""
- if modes[firstCell.cell].color == modes[secondCell.cell].color then
- -- If first and second cell colors are same print cell's background color with default dithering color.
- bCol = string.rep(colors.toBlit(2^modes[firstCell.cell].color), 3)
- if bCol == "fff" then tCol = "000"
- else tCol = "fff" end
- elseif yPos <= firstCell.padding + (secondCell.padding - firstCell.padding)/2 then
- -- If less than or equal to parent's position, print first cell's background color with second cell's dithering color.
- tCol = string.rep(colors.toBlit(2^modes[secondCell.cell].color), 3)
- bCol = string.rep(colors.toBlit(2^modes[firstCell.cell].color), 3)
- else -- If greater than parent's position, print second cell's background color with first cell's dithering color.
- tCol = string.rep(colors.toBlit(2^modes[firstCell.cell].color), 3)
- bCol = string.rep(colors.toBlit(2^modes[secondCell.cell].color), 3)
- end
- term.blit(string.rep(string.char(127), 3), tCol, bCol)
- end
- for x = 1, display.chart.size.x+4, 4 do
- local thisSplit = math.floor((x+display.scroll.tree.x-1)/4)
- local thisCell = 1
- for y = 1, display.chart.size.y do
- local xPos, yPos = x-display.scroll.tree.x%4, y+display.scroll.tree.y
- term.setCursorPos(xPos, y)
- if isBetween(thisSplit, 0, modes.splits, true) and thisCell <= #tree[thisSplit] then
- while thisCell < #tree[thisSplit] and ((thisSplit == modes.splits and yPos > tree[thisSplit][thisCell].padding)
- or (thisSplit < modes.splits and yPos > tree[thisSplit+1][tree[thisSplit][thisCell].child[#tree[thisSplit][thisCell].child] ].padding)) do
- thisCell = thisCell + 1
- end
- if yPos == tree[thisSplit][thisCell].padding then
- -- If cell is here, print mode number.
- display.setColor(modes[tree[thisSplit][thisCell].cell].color)
- term.write("M" .. string.rep("0", 2-string.len(tree[thisSplit][thisCell].cell)) .. tree[thisSplit][thisCell].cell)
- elseif yPos > tree[thisSplit][thisCell].padding and thisCell < #tree[thisSplit] and tree[thisSplit][thisCell].downAd and tree[thisSplit][thisCell+1].upAd then
- -- If above this cell's second child's padding, print connection between this cell and next cell.
- drawConnection(thisSplit, tree[thisSplit][thisCell], tree[thisSplit][thisCell+1], yPos)
- elseif yPos < tree[thisSplit][thisCell].padding and thisCell > 1 and tree[thisSplit][thisCell-1].downAd and tree[thisSplit][thisCell].upAd then
- -- If above this cell's padding, print connection between previous cell and this cell.
- drawConnection(thisSplit, tree[thisSplit][thisCell-1], tree[thisSplit][thisCell], yPos)
- else term.write(" ") end
- term.setBackgroundColor(colors.black)
- if #tree[thisSplit][thisCell].child > 0 then -- If this cell has children...
- if modes[tree[thisSplit][thisCell].cell].split then -- ...and this cell splits...
- if yPos == tree[thisSplit+1][tree[thisSplit][thisCell].child[1] ].padding then
- -- ...print line to first child.
- term.blit(string.char(156), "8", "f")
- elseif yPos == tree[thisSplit+1][tree[thisSplit][thisCell].child[2] ].padding then
- -- ...print line to second child.
- term.blit(string.char(141), "8", "f")
- elseif yPos > tree[thisSplit+1][tree[thisSplit][thisCell].child[1] ].padding and yPos < tree[thisSplit+1][tree[thisSplit][thisCell].child[2] ].padding then
- -- ...print line between children.
- term.blit(string.char(149), "8", "f")
- else term.write(" ") end
- elseif yPos == tree[thisSplit][thisCell].padding then
- -- ... and this cell doesn't split, print straight line from parent to child.
- term.blit(string.char(140), "8", "f")
- else term.write(" ") end
- else term.write(" ") end
- else term.write(" ") end
- end
- end
- term.redirect(oldTerm)
- end
- display.divider = function()
- for y = 1, display.size.y do
- term.setCursorPos(divider, y)
- term.blit(string.char(149), "8", "f")
- end
- end
- display.all = function()
- term.clear()
- display.topLine()
- display.modesList()
- display.divider()
- display.tree()
- end
- display.help = function()
- term.setCursorPos(1, 1)
- local page = 1
- local exitPos = vector2.new()
- local setLeftDivider = function(label, xPos)
- if label == nil then display.modesColumn()
- else
- term.setCursorPos(xPos, 1)
- term.setTextColor(colors.yellow)
- term.write(label)
- end
- display.modesList()
- display.divider()
- return term.redirect(window.create(term.current(), divider+1, 1, display.size.x-divider, display.size.y))
- end
- local setRightDivider = function()
- display.envSettings()
- display.tree()
- display.divider()
- return term.redirect(window.create(term.current(), 1, 1, divider-1, display.size.y))
- end
- local fixTree = function()
- local old = {
- scroll = vector2.new(display.scroll.tree.x, display.scroll.tree.y),
- init = modes.init,
- splits = modes.splits,
- color = {[1] = modes[1].color, [2] = modes[2].color},
- adhesin = {[1] = modes[1].adhesin, [2] = modes[2].adhesin},
- child = {[1] = modes[1].child, [2] = modes[2].child},
- childA = {[1] = modes[1].childA, [2] = modes[2].childA}
- }
- display.scroll.tree = vector2.new(0, math.floor(display.chart.size.y/-2))
- modes.init = 1
- modes.splits = 3
- modes[1].color = 0
- modes[2].color = 1
- modes[1].adhesin = true
- modes[2].adhesin = true
- modes[1].child = {1, 2}
- modes[2].child = {2, 1}
- modes[1].childA = {true, true}
- modes[2].childA = {true, false}
- buildTree()
- return old
- end
- local resetTree = function(old)
- modes.init = old.init
- modes.splits = old.splits
- modes[1].color = old.color[1]
- modes[2].color = old.color[2]
- modes[1].adhesin = old.adhesin[1]
- modes[2].adhesin = old.adhesin[2]
- modes[1].child = old.child[1]
- modes[2].child = old.child[2]
- modes[1].childA = old.childA[1]
- modes[2].childA = old.childA[2]
- buildTree()
- display.scroll.tree = vector2.new(old.scroll.x, old.scroll.y)
- end
- local help = {
- [1] = function() -- Introduction
- term.setCursorPos(1, 1)
- print("This program was made as a helper for the mobile game, Cell Lab. You will need to play that game to understand this program. It's purpose is to help visualize how cells will divide with the given paramaters, without taking survivability into account.")
- term.setTextColor(colors.yellow)
- print("\nTo go to the next page, scroll down on the Scroll Wheel.")
- print("To go to the previous page, scroll up on the Scroll Wheel.")
- write("To return to the program, Left Click on the ")
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.white)
- write(string.char(215))
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.yellow)
- write(".")
- exitPos = vector2.new(term.getCursorPos())
- exitPos.x = exitPos.x - 2
- end,
- [2] = function() -- Left of Divider
- local reset = setLeftDivider()
- write("The left side of the divider is your genome data. You can change these values by using Left or Right Click.")
- term.redirect(reset)
- end,
- [3] = function() -- Column Labels
- local reset = setLeftDivider()
- write(string.char(27) .. " These are the column labels. Left Click any of these to reveal the full name of the label, except for '")
- term.setTextColor(colors.yellow)
- write("Cell Type")
- term.setTextColor(colors.white)
- write("' which is already the full name.")
- term.redirect(reset)
- end,
- [4] = function() -- Mode
- local reset = setLeftDivider("M", 1)
- write("This is the 'Mode' column. It is the mutation id of your genome. Left or Right Click the mode number to change the color of that cell.")
- term.redirect(reset)
- end,
- [5] = function() -- Cell Type
- local reset = setLeftDivider("Cell Type", 3)
- write("This column is the type of cell of the current mode. Left or Right Click to change the type of cell.")
- term.redirect(reset)
- end,
- [6] = function() -- Make Adhesin
- local reset = setLeftDivider("A", 15)
- write("This is the 'Make Adhesin' column. It tells the cell's children to stick together or stay separated when the initial cell splits. This option is disabled by default. Left click to toggle this option.")
- term.redirect(reset)
- end,
- [7] = function() -- Split
- local reset = setLeftDivider("S", 16)
- write("This is the 'Split' column. This determines if the cell actually splits in the next level. If not, it will have one child that is an exact copy of itself. This option is enabled by default. Left click to toggle this option.")
- term.redirect(reset)
- end,
- [8] = function() -- Initial
- local reset = setLeftDivider("I", 17)
- write("This is the 'Initial' column. The mode with this option is the cell that the flow chart starts with. The initial cell is M01 by default. Left click this column to change the initial cell.")
- term.redirect(reset)
- end,
- [9] = function() -- Child 1 Mode
- local reset = setLeftDivider("C1", 18)
- print("This is the 'Child 1' column. This is the mode that this cell's first child will become when it splits. Left or Right Click to change this option.")
- term.redirect(reset)
- end,
- [10] = function() -- Child 1 Keep Adhesin
- local reset = setLeftDivider("A", 20)
- print("This is the 'Keep Adhesin' column for Child 1. This tells the first child cell to stay attached to the cell above it. This option is enabled by default. Left Click to toggle this option.")
- term.redirect(reset)
- end,
- [11] = function() -- Child 2 Mode
- local reset = setLeftDivider("C2", 21)
- print("This is the 'Child 2' column. This is the mode that this cell's second child will become when it splits. Left or Right Click to change this option.")
- term.redirect(reset)
- end,
- [12] = function() -- Child 2 Keep Adhesin
- local reset = setLeftDivider("A", 23)
- print("This is the 'Keep Adhesin' column for Child 2. This tells the second child cell to stay attached to the cell below it. This option is enabled by default. Left Click to toggle this option.")
- term.redirect(reset)
- end,
- [13] = function() -- Right of Divider
- local reset = setRightDivider()
- print("The right side of the divider is the flow chart for the genome you created as well as some additional options at top of the screen.")
- term.redirect(reset)
- end,
- [14] = function() -- Times to Split
- local reset = setRightDivider()
- write("The number after '")
- term.setTextColor(colors.yellow)
- write("S:")
- term.setTextColor(colors.white)
- write("' is how many times your initial cell will split. Left or Right Click the number to change the number of splits. The minimum is 0 and the maximum is automatically adjusted based on how many cells are in your final split.")
- term.redirect(reset)
- end,
- [15] = function() -- Total Cells
- local reset = setRightDivider()
- write("The number after '")
- term.setTextColor(colors.yellow)
- write("C:")
- term.setTextColor(colors.white)
- write("' is how many cells are in your final split. The the maximum number of cells you can have in game is 1000. You will not be able to split anymore if you have 1000 or more cells in your final split.")
- term.redirect(reset)
- end,
- [16] = function() -- Help
- local reset = setRightDivider()
- write("Left Click ")
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.black)
- write("Help")
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- write(" to see this section, and to exit the program, Left Click ")
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.white)
- write(string.char(215))
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- write(".")
- term.redirect(reset)
- end,
- [17] = function() -- Flow Chart 1
- local old = fixTree()
- local reset = setRightDivider()
- print("The flow chart shows how cells will reproduce based on the genome you created on the left side of the divider. Click and drag with Left or Right Click to scroll through the chart with the mouse. Middle Click to reset the scroll position.")
- term.redirect(reset)
- resetTree(old)
- end,
- [18] = function() -- Flow Chart 2
- local old = fixTree()
- local reset = setRightDivider()
- print("You can also scroll up and down using Scroll Wheel, and left and right by holding Shift while using Scroll Wheel. If you hold Ctrl you can scroll the entire height of the screen, and holding Shift and Ctrl scrolls the entire width of the right side of the divider.")
- term.redirect(reset)
- resetTree(old)
- end,
- [19] = function() -- Flow Chart Components
- local old = fixTree()
- local reset = setRightDivider()
- print("'M##' is the mode number. The light gray lines connect the parents to their children. The dithered spaces between cells shows what cells are attached to each other.")
- term.redirect(reset)
- resetTree(old)
- end
- }
- local updateScreen = function()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- help[page]()
- if isBetween(page, 1, 13) then
- exitPos = vector2.new(divider, 1)
- term.setCursorPos(divider, 1)
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.white)
- term.write(string.char(215))
- elseif page > 12 then exitPos = vector2.new(display.size.x, 1) end
- end
- updateScreen(page)
- while true do
- events.getEvent()
- if events.eventIs("mouse_scroll", 1, {"any"}, {"any"}) then
- page = page + 1
- if page > #help then page = 1 end
- updateScreen(page)
- elseif events.eventIs("mouse_scroll", -1, {"any"}, {"any"}) then
- page = page - 1
- if page < 1 then page = #help end
- updateScreen(page)
- elseif events.eventIs("mouse_up", 1, exitPos.x, exitPos.y) then
- break
- end
- end
- end
- local incrementValue = function(v, dir, lower, upper)
- dir = dir % 3
- if dir == 2 then dir = -1 end
- v = v + dir
- if v > upper then v = v - (upper - lower + 1)
- elseif v < lower then v = v + (upper - lower + 1) end
- return v
- end
- local incrementMode = function(m, v, dir, lower, upper)
- local child = 0
- if dir > 3 then
- if dir < 7 then child = 1
- else child = 2 end
- end
- if child > 0 then modes[m][v][child] = incrementValue(modes[m][v][child], dir, lower, upper)
- else modes[m][v] = incrementValue(modes[m][v], dir, lower, upper) end
- if dir%3 ~= 0 then
- display.mode(m)
- buildTree()
- display.envSettings()
- display.tree()
- end
- end
- local toggleCheck = function(m, v)
- local child = 0
- if v == "a" then v = "adhesin"
- elseif v == "s" then v = "split"
- elseif v == "i" then v = "init"
- elseif v:sub(1, 1) == "c" then
- child = tonumber(v:sub(2, 2))
- v = "childA"
- else error("bad argument #2 to 'toggleCheck' (expected 'a', 's', 'i', 'c1' or 'c2', got " .. type(v) .. " '" .. tostring(v) .. "')", 2) end
- if v == "init" then
- local oldInit = modes.init
- modes.init = m
- display.mode(oldInit)
- elseif v == "childA" then
- if modes[m][v][child] then modes[m][v][child] = false
- else modes[m][v][child] = true end
- else
- if modes[m][v] then modes[m][v] = false
- else modes[m][v] = true end
- end
- display.mode(m)
- buildTree()
- display.envSettings()
- display.tree()
- end
- for a = 1, 40 do
- modes[a] = {
- cellType = 1,
- color = (a-1)%16,
- child = {[1] = a, [2] = a},
- childA = {[1] = true, [2] = true},
- adhesin = false,
- split = true
- }
- end
- buildTree()
- display.all()
- while true do
- events.getEvent()
- if events.eventIs("mouse_scroll", {"any"}, {"<", divider}, {"any"}) -- Scroll genome list.
- and ((events[2] == -1 and display.scroll.mode > 0)
- or (events[2] == 1 and display.scroll.mode < #modes-display.size.y+1)) then
- display.scroll.mode = display.scroll.mode + events[2]
- display.modesList()
- elseif events.eventIs("mouse_scroll", {"any"}, {">", divider}, {">", 1}) then -- Scroll flow chart...
- if events.isPressed("key", keys.leftShift) or events.isPressed("key", keys.rightShift) then -- ...horizontally...
- if events.isPressed("key", keys.leftCtrl) or events.isPressed("key", keys.rightCtrl) then -- ...by the width of the chart.
- display.scroll.tree.x = display.scroll.tree.x + events[2] * display.chart.size.x
- else display.scroll.tree.x = display.scroll.tree.x + events[2] end -- ...by one line.
- elseif events.isPressed("key", keys.leftCtrl) or events.isPressed("key", keys.rightCtrl) then -- ...vertically by the height of the chart.
- display.scroll.tree.y = display.scroll.tree.y + events[2] * display.chart.size.y
- else display.scroll.tree.y = display.scroll.tree.y + events[2] end -- ...vertically by one line.
- display.tree()
- elseif events.eventIs("mouse_click", {"any"}, {"<", divider}, {"any"}) then -- Click actions left of the divider.
- if events[4] == 1 and events[2] == 1 then -- Show full column names.
- if isBetween(events[3], 0, 3) then display.columnName("Mode", 1)
- elseif events[3] == 15 then display.columnName("Make Adhesin", 10)
- elseif events[3] == 16 then display.columnName("Split", 16)
- elseif events[3] == 17 then display.columnName("Initial", 17)
- elseif isBetween(events[3], 17, 20) then display.columnName("Child 1", 13)
- elseif events[3] == 20 then display.columnName("Keep Adhesin", 15)
- elseif isBetween(events[3], 20, 23) then display.columnName("Child 2", 16)
- elseif events[3] == 23 then display.columnName("Keep Adhesin", 18)
- end
- else -- Edit genome.
- local clickedMode = events[4]-1+display.scroll.mode
- if isBetween(events[3], 0, 3) then -- Change mode color.
- incrementMode(clickedMode, "color", events[2], 0, 15)
- if events[2] < 3 then
- for a, b in ipairs(modes) do
- local updateMode = false
- for c = 1, 2 do
- if b.child[c] == clickedMode and a ~= clickedMode then updateMode = true end
- end
- display.mode(a)
- end
- end
- elseif isBetween(events[3], 2, 15) then incrementMode(clickedMode, "cellType", events[2], 1, #types) -- Change cell type.
- elseif events[2] == 1 and events[3] == 15 then toggleCheck(clickedMode, "a") -- Toggle 'Make Adhesin'.
- elseif events[2] == 1 and events[3] == 16 then toggleCheck(clickedMode, "s") -- Toggle splitting this cell.
- elseif events[2] == 1 and events[3] == 17 then toggleCheck(clickedMode, "i") -- Change initial cell.
- elseif isBetween(events[3], 17, 20) then incrementMode(clickedMode, "child", events[2]+3, 1, #modes) -- Change child 1 mode.
- elseif events[2] == 1 and events[3] == 20 then toggleCheck(clickedMode, "c1") -- Toggle child 1 'Keep Adhesin'.
- elseif isBetween(events[3], 20, 23) then incrementMode(clickedMode, "child", events[2]+6, 1, #modes) -- Change child 2 mode.
- elseif events[2] == 1 and events[3] == 23 then toggleCheck(clickedMode, "c2") end -- Toggle child 2 'Keep Adhesin'.
- end
- elseif events.eventIs("mouse_click", {"any"}, {">", divider}, {"any"}) then -- Click actions right of the divider.
- if events[4] == 1 then -- Environment options.
- if isBetween(events[3], divider+2, divider+5) then -- Change number of splits.
- if events[2] == 1 and #tree[#tree] < 1000 then
- modes.splits = modes.splits + 1
- buildTree(true)
- display.envSettings()
- display.tree()
- elseif events[2] == 2 and modes.splits > 0 then
- modes.splits = modes.splits - 1
- buildTree(true)
- display.envSettings()
- display.tree()
- end
- elseif isBetween(events[3], display.size.x-6, display.size.x-1) then -- Show help section.
- display.help()
- display.all()
- elseif events[3] == display.size.x then -- Exit program.
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1, 1)
- error()
- end
- else -- Flow chart options.
- if events[2] == 3 then -- Reset scroll position.
- display.scroll.tree = vector2.new(0, tree[0][1].padding-math.floor(display.chart.size.y/2))
- display.tree()
- else dragScroll = vector2.new(events[3], events[4]) end -- Enable scrolling flow chart with mouse drag.
- end
- elseif events[1] == "mouse_up" and events[2] < 3 then dragScroll = vector2.new() -- Disable scrolling flow chart with mouse drag.
- elseif events[1] == "mouse_drag" and events[2] < 3 and dragScroll.x > 0 and dragScroll.y > 0 then -- Scroll flow chart with mouse drag.
- display.scroll.tree.x = display.scroll.tree.x + (dragScroll.x - events[3])
- display.scroll.tree.y = display.scroll.tree.y + (dragScroll.y - events[4])
- dragScroll = vector2.new(events[3], events[4])
- display.tree()
- end
- end
- --[[ Changelog
- 2023/02/23:
- • Changed Vector2 to vector2 to reflect the changes made to "/API/LibAppend.lua".
- ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement