CC: Tweaked · Setup guide · Intermediate

How to Build an Interactive Touchscreen Monitor Dashboard for Base Control

In this guide, you will build a dynamic touchscreen dashboard using CC: Tweaked to monitor your base's energy and fluid storage while toggling generators with a single tap. Centralizing your base controls onto an interactive graphical screen eliminates messy redstone wiring and prevents catastrophic power outages by giving you real-time data at a glance.

What you need

  • 1x Advanced Computer
  • 6x to 12x Advanced Monitors (Standard monitors do not support touch or color)
  • 4x+ Wired Modems and several Networking Cables
  • 1x Forge Energy (FE) storage block (such as an Energy Cell or Capacitor Bank)
  • 1x Fluid Tank (from any compatible tech mod)
  • Redstone dust or bundled cable connecting the computer to your power generators
  • Basic familiarity with the Lua terminal and the built-in 'edit' program

Step by step

  1. 1Construct the Monitor Array and Network

    Place your Advanced Monitors in a 3-wide by 2-high rectangle to form a single large screen. Place your Advanced Computer nearby, then attach a Wired Modem to the computer, the monitor array, your FE energy storage block, and your fluid tank. Connect all the Wired Modems together using Networking Cables, and right-click each modem attached to a machine (not the computer) so its border turns red.

    Tip: When a modem turns red, it prints the exact network name of the attached block into your chat, such as 'thermal:energy_cell_0'. Write these names down.

  2. 2Wrap Peripherals and Redirect Terminal Output

    Open the Advanced Computer interface and type 'edit startup.lua' to create a script that runs automatically when the chunk loads. Start your script by finding the monitor with 'local mon = peripheral.find("monitor")' and wrapping your energy and fluid blocks using 'peripheral.wrap("network_name_here")'. Set the monitor's text scale to make room for graphics using 'mon.setTextScale(0.5)' or '1', then redirect all drawing functions to the big screen using 'term.redirect(mon)'.

    Tip: If you ever need to restore text output back to the main computer screen for debugging, store the original terminal object from 'term.redirect(mon)' or call 'term.redirect(term.native())'.

  3. 3Poll Storage Data via Generic Peripherals

    Create a helper function in your script to read your storage levels. CC: Tweaked provides built-in generic peripheral methods for most modded blocks: call 'energyBlock.getEnergy()' and 'energyBlock.getEnergyCapacity()' to calculate your FE percentage. Similarly, call 'tankBlock.tanks()' which returns a table of fluids; read the first slot's '.amount' and divide it by your tank's known capacity to get a fill ratio between 0 and 1.

    Tip: If you aren't sure what methods a modded block supports, exit the editor and run 'lua' in the terminal, then type 'peripheral.getMethods("network_name")' to see the exact list.

  4. 4Draw the Graphical Progress Bars

    Write a 'drawDashboard()' function that first wipes the screen using 'term.setBackgroundColor(colors.black)' and 'term.clear()'. Use 'paintutils.drawFilledBox(startX, startY, endX, endY, colors.gray)' to draw empty background bars for your energy and fluid readouts. Next, calculate the filled width by multiplying the bar's total pixel length by your fill ratio, and draw a second box over the gray one using 'colors.green' for FE and 'colors.blue' for fluid.

    Tip: Always reset your cursor position with 'term.setCursorPos(x, y)' and set a contrasting text color with 'term.setTextColor(colors.white)' before using 'term.write()' to label your bars.

  5. 5Create the Generator Toggle Button

    At the top of your script, define a boolean variable 'local genActive = false' and a table storing your button's bounding box coordinates, like 'local btn = {x1=2, y1=10, x2=16, y2=12}'. Inside your 'drawDashboard()' function, pick a button color based on the state: 'local btnColor = genActive and colors.IME or colors.red'. Draw the button with 'paintutils.drawFilledBox(btn.x1, btn.y1, btn.x2, btn.y2, btnColor)', position the cursor inside the box, and write 'GEN: ON' or 'GEN: OFF'.

  6. 6Build the Event Loop for Touch and Refresh

    At the bottom of your script, start a refresh timer with 'local timerId = os.startTimer(1)' and open an infinite 'while true do' loop. Inside the loop, call 'drawDashboard()', then wait for system activity using 'local event, p1, p2, p3 = os.pullEvent()'. If 'event == "timer" and p1 == timerId', simply restart the timer with 'timerId = os.startTimer(1)' so the bars update every second without freezing the touchscreen.

    Tip: Never use 'sleep(1)' in a touchscreen program! The sleep function discards all non-timer events while waiting, which makes your buttons completely unresponsive most of the time.

  7. 7Map Touch Coordinates to Redstone Output

    Inside the same 'while true' loop, add an 'elseif event == "monitor_touch" then' block. For a touch event, 'p2' is the X coordinate clicked and 'p3' is the Y coordinate. Check if the click landed inside your button box using 'if p2 >= btn.x1 and p2 <= btn.x2 and p3 >= btn.y1 and p3 <= btn.y2 then'. When true, flip the state with 'genActive = not genActive' and toggle your physical generator line with 'redstone.setOutput("back", genActive)'. Save the file, exit, and run 'reboot' to launch your dashboard.

    Tip: Add an Speaker peripheral to your network and trigger 'speaker.playNote("hat", 1, 12)' inside the touch condition to give your touchscreen satisfying audio feedback.

How it works

The core of this dashboard relies on terminal redirection and coordinate-Space collision detection. Normally, the 'paintutils' API only draws to the Advanced Computer's built-in screen. By calling 'term.redirect(mon)', you hijack the standard terminal output buffer and route every subsequent pixel draw and cursor movement directly to the external Advanced Monitor array.

Because CC: Tweaked doesn't have a built-in 'button' object, buttons are an illusion created by pairing graphics with event listeners. When you right-click an Advanced Monitor, the computer queues a 'monitor_touch' event containing the exact column (X) and row (Y) you clicked. By checking if those X and Y numbers fall between the top-left and bottom-right coordinates of the rectangle you painted via 'paintutils.drawFilledBox', the script knows you pressed the virtual button.

Finally, using 'os.pullEvent()' alongside 'os.startTimer(1)' creates an asynchronous loop. Instead of pausing the processor to wait for data updates, the computer yields until *either* one second passes (triggering a gauge redraw) *or* a player touches the screen (triggering an instant redstone toggle and redraw), resulting in a zero-lag interface.

Common mistakes

  • Crafting regular Monitors instead of Advanced Monitors: Standard gray monitors cannot display multiple colors via paintutils and do not emit 'monitor_touch' events when right-clicked.
  • Using 'sleep()' for screen refreshes: As mentioned in the steps, 'sleep()' eats incoming touch events. Always use 'os.startTimer()' and filter events through 'os.pullEvent()' so touches are registered immediately.
  • Forgetting to restore background colors before clearing: 'term.clear()' fills the screen with whatever color was last passed to 'term.setBackgroundColor()'. If you just drew a green bar using paintutils, calling 'term.clear()' without resetting the background to black will turn your entire monitor bright green.
  • Hardcoding peripheral names when using multiple identical blocks: If you disconnect and reconnect a Wired Modem, the number at the end of the block's network name increments. Use 'peripheral.find("energy_storage")' if you only have one energy cell, or keep a config table at the top of your script to easily update network IDs.

FAQ

Why does 'paintutils.drawFilledBox' draw on my computer screen instead of the big monitor?

The 'paintutils' API only draws to the currently active terminal object. You must call 'term.redirect(mon)' before calling any paintutils functions so the graphics are routed to the external monitor.

How do I toggle a generator that is far away from the computer?

Connect a Redstone Relay peripheral (or another computer) near the generator using Networking Cables and Wired Modems, wrap it on the network, and call its peripheral redstone output method instead of the computer's local 'redstone.setOutput'.

Why is my fluid tank returning an empty table when I call '.tanks()'?

When a fluid tank is completely empty, many modded tanks return an empty table '{}' instead of a fluid with 0 amount. Always check 'if tankData[1] then' before reading 'tankData[1].amount', and default your fill amount to 0 if the slot is nil.

Can I resize the monitor after the program is already running?

If you add more monitor blocks to the array while the script is running, the pixel resolution changes. You can listen for the 'monitor_resize' event in your main loop to recalculate bar widths dynamically, or simply reboot the computer.

By combining terminal redirection, paintutils coordinate boxes, and a non-blocking event loop, you now have a responsive touchscreen dashboard capable of monitoring and controlling your entire base from one screen.

More CC: Tweaked guides

CC: Tweaked · Getting startedCC: Tweaked Getting Started Guide: First Computer, CraftOS & PastebinCC: Tweaked brings fully programmable computers into your Minecraft world, allowing you to automate almost any task using the Lua programming language. In this guide, you will learn how to craft your first computer, navigate the CraftOS terminal, write a simple script, and download community-made programs straight into your game. Mastering these foundational skills is the essential first step before moving on to autonomous mining turtles and complex base networks.Beginner7 steps
CC: Tweaked · ExplainedLua for CC: Tweaked Explained: Variables, Functions & The os.pullEvent LoopWriting your own scripts in CC: Tweaked unlocks total control over your Minecraft world, allowing you to automate everything from simple redstone doors to complex Turtle mining arrays. This guide breaks down the essentials of the Lua language—specifically variables, functions, and the critical event-pulling loop—so you can build reliable programs that never freeze or crash.Beginner6 steps
CC: Tweaked · PowerTurtle Fuel & Progression Guide: From Basic Turtles to Infinite Lava RefuelingTurtles in CC: Tweaked are powerful mobile robots, but they cannot move a single block without fuel. In this guide, you will learn how the internal Turtle fuel economy operates, how to upgrade from basic gray models to high-capacity Advanced Turtles, and how to program a self-sustaining Nether lava refueling loop.Beginner7 steps
CC: Tweaked · AutomationHow to Automate Strip Mining & Quarries with Mining TurtlesManual mining is one of the most time-consuming tasks in survival Minecraft, often taking hours away from complex base building and automation. With CC: Tweaked, you can deploy programmable Mining Turtles to carve out massive quarries and strip mines completely hands-free. This guide will walk you through crafting a Mining Turtle, setting up an automated fueling and chest-dumping station, and running both built-in and custom Lua mining scripts.Intermediate8 steps
CC: Tweaked · ExplainedPeripherals & Wired Networks Explained: Wrapping, Modems & Networking CablesIn CC: Tweaked, a standalone Computer can only do so much on its own; its real power comes from controlling external blocks known as peripherals. This guide will teach you how to connect your Computer to adjacent and distant machines—like Monitors, Speakers, and Chests—using Wired Modems, Networking Cables, and the Lua peripheral API. Mastering wired networks allows you to manage an entire base's inventory and automation from one central terminal.Intermediate8 steps
CC: Tweaked · Setup guideHow to Build a CC: Tweaked Storage Network & Auto-Crafting SystemIn this advanced guide, you will build a centralized item storage network and an on-demand auto-crafting system using CC: Tweaked's Wired Modems, Advanced Computers, and Crafty Turtles. By leveraging the native inventory peripheral methods in Lua, you can create a zero-RF digital storage solution that rivals dedicated logistics mods while giving you total programmable control over every item slot.Advanced8 steps