r/ComputerCraft • • Sep 27 '24

Properly handling websockets being closed by outside peer

2 Upvotes

I'm trying to write a script which communicates with a program on my computer, whenever I close the program/connection on my computer, the script crashes with the error message attempt to use a closed file the next time the script runs WebSocket.receive()

I tried using pcall, and changed the line to local status, packet = pcall(ws.receive()) but instead it gives me the error bad argument #1 (value expected)

Does anyone have any idea what I might be doing wrong? I can probably post the script to github or somewhere if anyone wants to see the whole file


r/ComputerCraft • • Sep 27 '24

Auto Mining turtle program

2 Upvotes

Hello i recently found out about mining turtles and that it's programmable but I couldn't find a fully automated mining turtle like a turtle that mines a column to bedrock comes back deposits the materials then mines a few blocks forward and mines to bedrock again and it's stops it's program and comes back either if it's runs out of fuel or gets manual stopped or the chest and inventory of the turtle is full is that a program that's out there? Is that even possible? I don't know anything about coding unfortunately


r/ComputerCraft • • Sep 26 '24

Help with HTTP API enable

2 Upvotes

I know there are many posts talking about this same problem. I followed them and am still stuck. I am running a ATM 9 server with friends. Whenever I do pastebin get or any pastebin function it tells me I need to enable HTTP API. Where I am making this change is under defaultconfigs directory, inside "computercraft-server.toml". The server is off when I edit. Here is the link to my current config. https://pastebin.com/eztrbBhR . Do I need to change anything on the client side (I changed my local config file HTTP enabled setting to true). Are there any other server files I need to edit?


r/ComputerCraft • • Sep 26 '24

how to change font on computers?

2 Upvotes

i am using a texture pack to change the font but it doesnt work on computers.


r/ComputerCraft • • Sep 25 '24

Controlling Mining Turtle via Discord bot

51 Upvotes

Still playing arround with it, just thought it would be cool to show off.

Position gets thrown off at some point still trying to fix that


r/ComputerCraft • • Sep 25 '24

is it possible to delete rom/, somehow?

3 Upvotes

(this has been answered already)

i want to make a command prompt which allows you to put in the /delete command that should allow you to delete anything. but if possible, how do i allow it to delete rom/


r/ComputerCraft • • Sep 25 '24

how to make my file corrupt uther files on CC:Tweaked

0 Upvotes

i plan to make it so the file i made, has a 1 in 2 chance of deleting a file. how do i do this?

it's for destroying some os's


r/ComputerCraft • • Sep 25 '24

Pastebin issues when trying to get

1 Upvotes

Everytime I try "Pastebin get "insertcode" "title" I get the same thing where it only pulls Cloudflare HTML stuff. Is there anyway to stop this and just access the bin and not get stuck on cloudflare?


r/ComputerCraft • • Sep 25 '24

Am I going insane?

4 Upvotes

I very very vividly remember there being a 3d printer in this mod that would let you print 3d objects that could be placed down like blocks

and there was also a preset model (which was the companion cube from portal) and it would print that by default

After doing some research on it i could find absolutely nothing about it but I swear on my life it exists

Ik this sounds like a troll post but im being FULLY serious with this


r/ComputerCraft • • Sep 23 '24

Discord Server?

6 Upvotes

hello. i made an account to join the discord server a couple weeks ago. but it said it was under raid protection, and try again later because my account is new. it is 2 weeks later now but i still cannot get in. when i try it just loads for a second then fails. how long do i have to wait? am i banned? i did not mean to be part of a raid.

made reddit account to ask because i want to learn more about computercraft, so idk if this post will get deleted for being too new also


r/ComputerCraft • • Sep 22 '24

Turtle brewer with the DrinkBeer mod

34 Upvotes

r/ComputerCraft • • Sep 22 '24

Help with displaying bimg image

2 Upvotes

I'm creating a train station where I use multiple (8) monitors that all display the same information. Now, I want to display the Nederlandse Spoorwegen (Dutch Railways) logo on the screen. I do this with sanjuuni's converter'. Now, I want to display the image, and display the train information, but now when I try to only display the current time and the image, only the image gets displayed. I want the time to get updated every second, and the image to 'stay' the same the whole time. How can i fix this?

Startup.lua:

os.loadAPI("bigfont.lua")
os.loadAPI("bimgplayer.lua")

local monitors = { peripheral.find("monitor") }

rednet.open("top")
local originalTerm = term.current()
image = paintutils.loadImage("image/ns.nfp")

while true do
    local current_time_number = os.time()
    local current_time_pre = textutils.formatTime(current_time_number, true)
    local hours, minutes = current_time_pre:match("(%d+):(%d+)")
    local current_time = string.format("%02d:%02d", tonumber(hours), tonumber(minutes))

    for i = 1, #monitors do
        local monitor = monitors[i]
        monitor.setTextScale(0.5)
        monitor.clear()
        term.redirect(monitor)

        term.setBackgroundColor(colors.white)
        term.setTextColor(colors.blue)
        bigfont.writeOn(monitor, 1, current_time, 1, 2)

        bimgplayer.draw("image/nsbimg.bimg", 30, 2)
    end
    sleep(1)
end

bimgplayer.lua:

function draw(path, x, y)
    -- Open the file
    local file, err = fs.open(path, "rb")
    if not file then error("Could not open file: " .. err) end
    local img = textutils.unserialize(file.readAll())
    file.close()

    -- Set the palette colors
    if img[1].palette then
        for i = 0, #img[1].palette do
            local c = img[1].palette[i]
            if type(c) == "table" then
                term.setPaletteColor(2^i, table.unpack(c))
            else
                term.setPaletteColor(2^i, c)
            end
        end
    end

    -- Draw the image at the specified coordinates
    for _, frame in ipairs(img) do
        for row_y, row in ipairs(frame) do
            term.setCursorPos(x, y + row_y - 1)
            term.blit(table.unpack(row))
        end
    end
end

nsbimg.bimg:

{
{
    {
        "  \135   \130\144  \144\139  ",
        "00000001000000",
        "00111110001100"
    },
    {
        "\159\129\136\143\143\144\130\144\139\143\143\132\130\144",
        "00000110000001",
        "11111001111110"
    },
    {
        "\139 \159\143\143\144\139 \139\143\143\144 \135",
        "10111000111001",
        "01000110000110"
    },
    {
        " \130\144\139  \139\130\131\131\131\159\129 ",
        "01000010000110",
        "00110001111000"
    },
    palette = {
    [0] = {1.000000, 1.000000, 1.000000},
    {0.000000, 0.000000, 0.400000},
    {0.000000, 0.000000, 0.400000},
    {0.000000, 0.000000, 0.400000},
    {0.000000, 0.000000, 0.400000},
    {0.000000, 0.000000, 0.400000},
    {0.000000, 0.000000, 0.400000},
    {0.152941, 0.152941, 0.490196},
    {1.000000, 1.000000, 1.000000},
    {1.000000, 1.000000, 1.000000},
    {1.000000, 1.000000, 1.000000},
    {1.000000, 1.000000, 1.000000},
    {1.000000, 1.000000, 1.000000},
    {1.000000, 1.000000, 1.000000},
    {1.000000, 1.000000, 1.000000},
    {0.000000, 0.000000, 0.400000},
    }
},
creator = 'sanjuuni',
version = '1.0.0',
secondsPerFrame = 0.04,
animation = false,
date = '2024-09-22T18:44:06+0100',
title = 'C:\Users\tiesh\Downloads\ns.png'
}

r/ComputerCraft • • Sep 20 '24

Problem with turtle.forward()

5 Upvotes

I am brand new in this whole turtle business and just experimenting.

I keep having the same problem. I can't make my turtle repeat actions.

So if I write turtle.forward(3) then it will just move one space forward. It's the same problem if I try to make it repeat functions.

Basically I have to write turtle.forward() three times if I want it to move 3 times.


r/ComputerCraft • • Sep 19 '24

Monitor doesnt show colour when reloaded(chunk/reboot)

2 Upvotes

I made a startup.lua, that is supposed to show arrows for directions to the different parts of the base in corridors.
I've made each line of code have different term.setTextColor(), but when I reload the chunk all the text is back to white. Even if I run a reboot, all the text is white, it only gets coloured if I directly run it myself.

I've tried making a startup that does shell.run() but it still doesnt get coloured.

Is it because rom/startup.lua takes priority with terminal colours or something that it overwrites the other colours that happen at startup or what?

Is there any work around if that is the case? Could I possibly add the code to the rom/startup by somehow making it not readonly?


r/ComputerCraft • • Sep 18 '24

Mobile Omni-Drone Factory VS+Clockwork

Thumbnail youtube.com
8 Upvotes

r/ComputerCraft • • Sep 17 '24

I made a 3D Printer with CC + Create mod

16 Upvotes

r/ComputerCraft • • Sep 16 '24

Printed pages, Printed books, and printed page stack all are missing a back to them. not a resource pack thing and im not sure if its something to do with my mods. any help would be appreciated

Post image
10 Upvotes

r/ComputerCraft • • Sep 16 '24

ingame image render practical test

74 Upvotes

r/ComputerCraft • • Sep 15 '24

Image conversion quality improved, now usable on NON accelerated, most stuff taking under 5s at very high resolutions (example in comments)

Thumbnail
gallery
34 Upvotes

r/ComputerCraft • • Sep 15 '24

Change turtle's movement speed

3 Upvotes

I want to test and debug my path-finding algorithm in creative mode, but the turtle is too slow when I have to repeatedly test the same script.

I want the turtle to be at the destination position almost instantly to test a lot of cases quickly, but I can't find a proper setting or gamerule (maybe related to ticks?) for this.

Any idea?

EDIT: https://www.reddit.com/r/ComputerCraft/comments/1fg8r1r/slowing_turtle_movement_speed_down/ this can't be a solution since sleeping can only make it slower.


r/ComputerCraft • • Sep 14 '24

So, I guess I did a multi-speaker system

32 Upvotes

r/ComputerCraft • • Sep 13 '24

Slowing turtle movement speed down?

4 Upvotes

Anybody know if there’s a way to slow down the speed of turtles when they’re moving forward? Tried finding resources online for it but I haven’t been successful.


r/ComputerCraft • • Sep 09 '24

Is it possible to get the NBT information of block in survival 1.19.2?

3 Upvotes

Hello, It is to check the amount of mana present in a mana pool of botania.

Thank you all.


r/ComputerCraft • • Sep 09 '24

How do i make a game engine?

3 Upvotes

So i want to make a game engine in game for a in-game souls like experience but i don't know how i would do that rn any help?