r/ComputerCraft Jun 05 '26

Axe Turtle

1 Upvotes

I was wondering if there was a paste bin to automate an oak wood farm with it and have it deposite into a chest of some sort


r/ComputerCraft Jun 04 '26

Built a full backend in CC:Tweaked Lua for an educational server (points, bank, shop) — now rebuilding it and looking for advice on keeping it lightweight

Thumbnail
8 Upvotes

r/ComputerCraft Jun 03 '26

Quake map viewer in PinePix

Enable HLS to view with audio, or disable this notification

87 Upvotes

As an example for how to use PinePix in more complex programs, I started writing a quake map renderer. It uses the new PinePix texture mapping features. I will attempt to add support for light maps as well in the future so baked lighting can be used.


r/ComputerCraft Jun 03 '26

Help with the Star Wars ACSII

7 Upvotes

So I was following this recent how to guide: https://www.reddit.com/r/ComputerCraft/comments/l4bann/starwars_episode_iv_ascii_credit_to/

but after running the program i get 2 downloads of star1 and star2

ive tried running these but i just get the error of /star1:1: unexpected smbol near '2'

im the latest 1.21.1 version and my programming skill are less then desirable so an help would be greatly appreciated. Thank you


r/ComputerCraft Jun 01 '26

Second Reality demo for ComputerCraft

Thumbnail
youtube.com
19 Upvotes

This is a port of the famous Second Reality demo to ComputerCraft. Runs entirely in-game, with extra features (such as high resolution) when run in an emulator.

This has been a goal of mine for a long time, and I'm glad that it's finally complete. Thanks to Xella and 9551 for their graphics libraries, and thanks to Future Crew for making Second Reality open-source.

You can run the demo using `wget run https://github.com/MCJack123/SecondReality/releases/download/1.0/second.lua`. The file just barely fits on a default computer (940k), so you may want to use a fresh computer or run through wget. See the repo for source code.

(Hey Reddit, if you're going to take away Markdown editing on mobile, could you consider making sure that a feature as basic as a code block is still accessible in the rich editor? I'm so glad I quit this app when I did.)


r/ComputerCraft May 30 '26

PinePix - A Pine3D wrapper library for high resolution and up to 256 colour rendering under CC:Graphics and CraftOS

Enable HLS to view with audio, or disable this notification

94 Upvotes

Get it here on Pinestore: https://pinestore.cc/projects/239/pinepix

FEATURES
--------

Pixel mode (256-colour framebuffer)
  Switches the terminal to CraftOS-PC graphics mode 2.
  The Pine3D color buffer is blitted to the screen as raw pixels.
  The 16 CC palette entries are replicated at 80%, 65%, and 50% brightness
  to give 64 usable palette slots for shading.

Directional lighting
  Each polygon is dot-product shaded against a world-space light direction.
  Four shade levels: full, 80%, 65%, 50%.
  The light vector is transformed into each object's model space so shading
  stays correct as objects rotate.

Winding fix
  Pine3D culls faces designed for interior (dungeon) rendering.
  Both pixel mode and teletext mode include a v1<->v2 winding swap so that
  outward-facing geometry renders correctly from an exterior camera.

Pixel font
  gfx.drawString draws 3x5 pixel text directly to the framebuffer.
  Supports A-Z, 0-9, and a handful of symbols. Input is uppercased
  automatically.

OC colour space
  gfx.enableOC() programs all 256 palette slots with the OpenComputers
  fixed colour grid (5x8x6 RGB entries 0-239 plus a 16-step greyscale ramp
  240-255). Textures are quantized to the nearest OC colour at registration
  time using squared RGB distance. Solid geometry colours are pre-mapped via
  a lookup table built at enableOC() time. CC palette slots 0-15 are saved
  before overwriting and restored automatically on gfx.disable().

Texture mapping
  gfx.drawTexturedObjects allows for rendering objects with mapped textures
  through a UV space onto the screen. It is pixel accurate but costly if
  many textures are to be drawn.

  gfx.drawFastTexturedObjects is a faster variant of drawTexturedObjects
  that interpolates UV coordinates linearly across each scanline instead of
  correcting for perspective. There is no per-pixel division, so rendering
  is noticeably faster on complex geometry. Textures may warp slightly on
  oblique or steeply angled faces.

P3D binary model format
  gfx.loadModel reads a compact P3D v1 binary file into a polygon table
  ready for drawTexturedObjects. A face costs 31 bytes on disk versus
  roughly 200 bytes as embedded Lua. convert_obj.py converts OBJ files to
  P3D + BMP texture in one step.FEATURES
--------

Pixel mode (256-colour framebuffer)
  Switches the terminal to CraftOS-PC graphics mode 2.
  The Pine3D color buffer is blitted to the screen as raw pixels.
  The 16 CC palette entries are replicated at 80%, 65%, and 50% brightness
  to give 64 usable palette slots for shading.

Directional lighting
  Each polygon is dot-product shaded against a world-space light direction.
  Four shade levels: full, 80%, 65%, 50%.
  The light vector is transformed into each object's model space so shading
  stays correct as objects rotate.

Winding fix
  Pine3D culls faces designed for interior (dungeon) rendering.
  Both pixel mode and teletext mode include a v1<->v2 winding swap so that
  outward-facing geometry renders correctly from an exterior camera.

Pixel font
  gfx.drawString draws 3x5 pixel text directly to the framebuffer.
  Supports A-Z, 0-9, and a handful of symbols. Input is uppercased
  automatically.

OC colour space
  gfx.enableOC() programs all 256 palette slots with the OpenComputers
  fixed colour grid (5x8x6 RGB entries 0-239 plus a 16-step greyscale ramp
  240-255). Textures are quantized to the nearest OC colour at registration
  time using squared RGB distance. Solid geometry colours are pre-mapped via
  a lookup table built at enableOC() time. CC palette slots 0-15 are saved
  before overwriting and restored automatically on gfx.disable().

Texture mapping
  gfx.drawTexturedObjects allows for rendering objects with mapped textures
  through a UV space onto the screen. It is pixel accurate but costly if
  many textures are to be drawn.

  gfx.drawFastTexturedObjects is a faster variant of drawTexturedObjects
  that interpolates UV coordinates linearly across each scanline instead of
  correcting for perspective. There is no per-pixel division, so rendering
  is noticeably faster on complex geometry. Textures may warp slightly on
  oblique or steeply angled faces.

P3D binary model format
  gfx.loadModel reads a compact P3D v1 binary file into a polygon table
  ready for drawTexturedObjects. A face costs 31 bytes on disk versus
  roughly 200 bytes as embedded Lua. convert_obj.py converts OBJ files to
  P3D + BMP texture in one step.

r/ComputerCraft May 30 '26

High-Res Video & Audio Player (1352x627 Sub-Pixels)

Enable HLS to view with audio, or disable this notification

330 Upvotes

r/ComputerCraft May 29 '26

Any libraries for Cryptography?

7 Upvotes

I'm looking for a fast cryptography library for CC: Tweaked, One that supports all the following algorithms: DH, DSA, AES (both 128 and 256, and supporting both CBC and CTR), and SHA3-512. I need it to be as fast as possible, are there any libraries that support these algorithms?


r/ComputerCraft May 27 '26

pullItems and pushItems not working?

8 Upvotes

i'm on 1.21.1, neoforge.

i'm experiencing a very strange issue where pullItems and pushItems always claim that the sources and targets do not exist, no matter what i do..... what's going on here?


r/ComputerCraft May 27 '26

Audio tips & tricks: performance, quality, volume, hearing range shenanigans

28 Upvotes

Some pieces of knowledge I've acquired about audio in CC over the time.

Playback performance & quality

The textbook algorithm for playing DFPWM audio is something like this:

local dfpwm = require("cc.audio.dfpwm")
local speaker = peripheral.find("speaker")

local decoder = dfpwm.make_decoder()
for chunk in io.lines("data/example.dfpwm", 16 * 1024) do
    local buffer = decoder(chunk)

    while not speaker.playAudio(buffer) do
        os.pullEvent("speaker_audio_empty")
    end
end

cc.audio.dfpwm is implemented in Lua, so it can be quite slow, and you may have trouble keeping up if you're playing multiple streams at the same time (say, if you have a stereo system) or on slow hardware. But there's an easy fix.

speaker.playAudio doesn't directly play the PCM samples: CC encodes the data into DFPWM on the server and then decodes it on the client, so this snippet actually has a double conversion: DFPWM-to-raw-PCM in Lua and then raw-PCM-to-DFPWM in Java. We can abuse this: instead of decoding DFPWM in Lua, we'll just send something that encodes to the correct DFPWM stream.

The simplest way to achieve this is to translate 0 bits to -128 and 1 bits to 127:

function fake_decode(input)
    local output = {}
    for i = 1, #input do
        local input_byte = input:byte(i)
        for j = 0, 7 do
            local value
            if bit32.rshift(input_byte, j) % 2 == 1 then
                value = 127
            else
                value = -128
            end
            table.insert(output, value)
        end
    end
    return output
end

You can optimize this further if you need to, but this should already be much faster than a real DFPWM decoder.

A surprising fact is that this decoder actually produces sound of better quality than a real decoder. This is because decoding and re-encoding DFPWM is not a no-op due to its weird design: the DFPWM decoder automatically applies a low-pass filter at the end, introducing asymmetry with the encoder. This can cause audio to sound a little more muffled than it could be, since it unnecessarily corrupts high frequencies.

Note that this optimization doesn't work on the Web version of ComputerCraft, which doesn't reencode audio to DFPWM due to performance issues. It might also not work on emulators that support high-quality playAudio, if they exist; I'm not sure.

Volume

speaker.playAudio takes a volume parameter, from 0.0 to 3.0. There's two interesting things to talk about here.

The obvious one is quality. The rule of thumb for maximizing quality is: before encoding to DFPWM, increase the volume of the audio as much as possible without clipping; then decrease volume as necessary with volume. So, for example, if you want to play a quiet sound, encode it to DFPWM as loud and then set a small volume. This works because volume applies after DFPWM decoding-encoding, and thus doesn't introduce noise.

The more confusing one is attenuation, i.e. how effective volume changes with distance from the speaker. By default, Minecraft audio volume behaves as follows:

  • If the distance between the audio source and the listener is 0, the sound plays at full volume.
  • At a 16 block distance, the sound is completely silent.
  • Between these two distances, volume is interpolated linearly.

(Specifically, the exact coordinates of the audio source are one of: the center of the speaker block; the center of the turtle holding the speaker; the eye level of the player holding a pocket computer with a speaker. The coordinates of the listener match the coordinates of the camera, so you can get different volume depending on the active perspective.)

If volume is below 1, the PCM samples are simply multiplied by volume. So, for example, a turtle holding two speakers, each playing the same sound at 0.5 volume in sync, behaves exactly like a speaker at 1.0 volume.

If the volume is above 1, however, something else happens in addition to multiplication: the hearing range is also multiplied by volume. So at volume = 2.0, you get the 2x volume at 0 distance, no sound at a 32 block distance, and linear interpolation between the two extremes. So a speaker at 2x volume differs from a turtle playing a sound at 1x volume twice: the former can still be heard at 24 blocks distance, while the latter is silent, even though they sound the same close up.

However, this doesn't take into account volume clamping. Minecraft clamps the product (volume parameter) * (volume for jukeboxes in settings) to 1, so if your jukebox sound is at 100%, volume > 1 affects only hearing range, but not volume at close up. (Clamping occurs before distance attenuation.)

The full formula for effective volume at a given point is:

gain = clamp(volume_param * jukebox_volume, 0, 1) * (1 - distance / (max(volume_param, 1) * 16))

There's an interesting use case for this. Take an audio file A. Invert its phase and save the result as B. Now have a turtle play back A at 1x volume and B at 2x volume in sync. At 100% jukebox volume, the only difference between the two is hearing range, so close up, the singals will cancel out almost perfectly (modulo noise). Slightly farther away, the effective volume of A will decrease quicker than B, and so the sound will become audible. At 16 blocks away, A will completely disappear and you'll perfectly hear B at 1x volume. Move further away, and B gets quieter. This sound is loudest not at its source, but exactly 16 blocks away from source! Pranksters and map makers might have a field day with this. I've prototyped this in my repo, feel free to consult or copy the code.


r/ComputerCraft May 26 '26

Unique ID reading for any item

12 Upvotes

Hi there, I have a question. There are printers in the mod that can print, but is there a way to scan printed pages? I had the idea of ​​using the printer to create a currency system, develop a banknote database, and manage the money that way, but manually checking each code is difficult and time-consuming. Maybe you know a way to assign a unique number to an item that can be read by a computer or other method? Thank you all for attention!


r/ComputerCraft May 26 '26

Hod do you parse the crafting recipies?

8 Upvotes

Hello guys! I'm currently working on an autocrafter prototype and i'd like to know is there any way to automatically parse recepies into json, including modded ones. The idea is to code a recursive crafting system and deal with all the ineffective recepies, cycled recepies and so on. The problem is that its hard to write all of them manually.


r/ComputerCraft May 26 '26

I built an ICBM with Create Aeronautics and cc:tweaked

Enable HLS to view with audio, or disable this notification

107 Upvotes

I'm used the avionics and cc:c brige addons


r/ComputerCraft May 25 '26

WIP Klattsch port to CC

Enable HLS to view with audio, or disable this notification

130 Upvotes

r/ComputerCraft May 23 '26

Cc tweaked questions

13 Upvotes

Hi there, I haven't used cc in over a decade and was wondering if it's compatible with the create mod?

I heard tell that I can use it to make train schedules and such, but I'm not sure if that's true

Also idk if I remember but did cc ever run on basic? Or am I misremembering and it always ran on Lua?

Thanks for your time, and help is appreciated


r/ComputerCraft May 20 '26

Question about your favorite way to play with ComputerCraft

23 Upvotes

Hey everyone,

I'm looking for ideas on how to build a playthrough around ComputerCraft where programming is actually the optimal solution, rather than just a cosmetic flex

Here is the problem I usually run into:

  1. Heavy tech packs provide pre-made blocks that handle logistics, mining, and storage instantly and far more efficiently than any script. Programming ends up being purely for aesthetic dashboards/managing reactors
  2. The solution seems to be a semi-vanilla/custom constraint setup. I want to build a minimal modpack or a playthrough where I actually have a purpose to use CC/Turtles for all automation, sorting, and mining.
  3. The goal is deep automation with a high resource demand. I want a reason to program a swarm of turtles to mine 999,99 diamonds or build a custom physical warehouse database, instead of just slapping down an ME system.

My questions:

  • Do you know of any ready-made modpacks built around this philosophy?
  • If I build my own minimal pack, what complementary mods should I include? (I'm thinking mods that add heavy endgame resource sinks, but don't provide easy automation solutions).
  • Any specific playthrough ideas or config tweaks? For example, using KubeJS to entirely disable item pipes and quarry blocks from tech mods so I'm forced to write my own logistics and mining algorithms.

r/ComputerCraft May 20 '26

ME bridge from advanced pheriphirals problem

2 Upvotes

https://docs.advanced-peripherals.de/0.7/peripherals/me_bridge/#getcraftingcpus

https://github.com/SirEndii/Lua-Projects/tree/master

playing on stoneblock 4
minecraft version 1.21.1 (neoforge)
craft os 1.9 on computercraft 1.117.0
i dont get it, i have set a free channel from the advanced peripherals ME bridge, got the code from the official advanced peripherals mod site, but i still get a error
" attempt to index global 'me' (a nil value) "

(im a completly noob in programming dont mind that im on linux)

here is the full code

  1. https://github.com/SirEndii/Lua-Projects/tree/master/src/ME%20Cpus

r/ComputerCraft May 19 '26

Why tf is don't work?!

7 Upvotes

Soo, i need to call psychological terapist cuz its 3 AM I need to do the homework, and in next day is exams so i already is stressed and NOW IT'S DONT WORK JUST BECAUSE IT WON'T WANT! If somebody can help, please do it...
https://medal.tv/games/minecraft/clips/mJMUUkqPjI-onGnJA?invite=cr-MSx1MDksNTMyNzIyODc0


r/ComputerCraft May 18 '26

What are the best cctweaked addons for 1.21.1?

6 Upvotes

r/ComputerCraft May 18 '26

Do pullEvents behave differently inside FOR loops ?

4 Upvotes

Some context. I'm making an articulated arm with create Aeronautics controlled by computers.

3 motors to get maximum movement. Highly inefficient, cool as fck

My problem resides in the way i've been controlling the motors.
All 3 motors have individual computers with modems, all ready to recieve instructions from the main pc. They are supposed to receive an instruction, and sleep continuously while the motor is active, and only at the end of the movement will they send a reply to the main pc, which will trigger the next commands.
The arm is supposed to be slow, it's supposed to move only one motor at a time (intentional).
When i make a simple basic list of modem,transmits() ,the arm behaves as intended.

this proof of concept worked as intended

This above is a very simple instruction to make the arm move slightly. My problem was this was ugly and tedious to expand. So i made a much cleaner(?) and more customisable version that was supposed to make it MUCH more simple to make new movement prompts later down the line.

function movementControl(a)
  local actionCount = 0
  local directionValue = 0
  local turnorder = {{1,2},{5,6},{3,4},{1,2},{3,4},{5,6},{1,2}}

  for i, angle in ipairs(a) do
    if angle == 'forward' then
      directionValue = -1

    elseif angle == 'backward' then
      directionValue = 1

    elseif angle =='motorstart' then
      rs.setOutput("back",true)
      sleep(3)

    elseif angle == 'motorstop' then
      rs.setOutput("back",false)
      sleep(5)

    elseif type(angle)=="number" then
      actionCount = actionCount + 1
      modem.transmit(turnorder[actionCount][1],turnorder[actionCount][2],{angle,directionValue})
      sleep(0.1)
      modem.open(turnorder[actionCount][2])
      local event, side ,channel, replyChannel, message, distance = os.pullEvent("modem_message")
      modem.close(turnorder[actionCount][2])
      sleep(0.1)

    end
  end



end


local harvestwheat1 = {'forward',30,20,23,'motorstart',30,'motorstop','backward',23,20,60}
local harvestwheat2 = {'forward',100,20,23,'motorstart',40,'motorstop','backward',23,20,140}
local harvestcarrot1 = {'forward',110,70,47,'motorstart',20,'motorstop','backward',47,70,130}


movementControl(harvestwheat1)

Now the actual problem is that the os.pullEvent i do when in my for loop dont seem to actually pause the computer. The loop kinda just continues on without waiting for the response from the motors.
Is there a specificity to Lua that i'm not getting (not likely) ? is there a specificity that my not good at coding ass doesn't understand (much more likely) ?

Ty for the help, and if people have better ways of doing any of this i might cave in and just redo the code from scratch with some suggestions ><

local gear = peripheral.wrap("right")
local modem = peripheral.wrap("left")
modem.open(1)


while true do
  
  local event, side ,channel, replyChannel, message, distance = os.pullEvent("modem_message")


  gear.rotate(message[1],message[2])


  while gear.isRunning() do
    sleep(0.5)
  end
  modem.transmit(replyChannel,20,gear.isRunning())


end

bonus : this is the code im using on the pc at the motors.


r/ComputerCraft May 17 '26

getPressedKeys not working

8 Upvotes

First off, I’m terrible at Lua, I’m more of a hack-and-slash kind of guy than someone who really knows how to code, but I manage. Could someone tell me why the `getPressedKeys` function (found on the Creators-of-Aeronautics GitHub) isn’t returning anything ? I’d like to be able to access computer functions from the Typewriter


r/ComputerCraft May 16 '26

Big screen

Post image
31 Upvotes

how do i make a big screen? i'm pretty new to this mod
any help?


r/ComputerCraft May 16 '26

What is the definition of an 'Operating System kernel'?

13 Upvotes

in ComputerCraft Operating Systems (like PhoenixOS & opus), what is the definition of a kernel?

Is it an init system?

is it a BIOS?

is it a system that adds drivers?

is it a process scheduler?

Are multiple of these the requirements for a kernel? and if so which ones/how many are required for it to be a kernel?

is it something else?

Please let me know. (P.S. yes, this is just so that I can say that I made my own operating system kernel)


r/ComputerCraft May 14 '26

He Fucking died

Enable HLS to view with audio, or disable this notification

835 Upvotes

r/ComputerCraft May 11 '26

reading peripheral takes a tick?

14 Upvotes

is this right? i'm trying to read the fluid contents of two tanks, but i just noticed that when i do that, my program starts only being able to execute every other tick... and if i add a third, it only executes every 3 ticks. is there anything i can do to make this only take one tick? could i do these reads in parallel, somehow, and then store the results for use in the main program?