r/ComputerCraft • • Jan 15 '22

the third io.read i do, no matter what, always saves as a string

2 Upvotes

doing a basic script, im trying to get back into programming and thought id mix it with minecraft. want turtle to dig a hole to my specs. asked for width, length, height. kept saying i was comparing to a string later in my code, narrowed it down to height which was the third spec i asked for. after trying many things, i tried simply moving it to the first spec. now length (which is now third spec) is said to be compared with a string.

code is here (pastebin)

faq: yes its digging up, my base is at bedrock. yes theres a lot of useless code, most of it is for troubleshooting or ideas i abandoned and forgot to delete. yes there is probably a more efficient way to do some of this but if it doesnt break the code, id like to challenge myself to figure it out on my own. im worried this issue at its core is a lua thing with io.read(). thank you in advance!

edit: realized it saves every read as a string, working around this now. ill edit this again tho if my efforts are fruitless. still dont know why its cool with the other 2 but not the third, though.

edit 2: i figured it out. i read io.read("*n") would work, it didn't. having it save as height = tonumber(read()) did, though.


r/ComputerCraft • • Apr 04 '20

Expected number, got number error

2 Upvotes

I get this strange error: .temp5: bad arguement #2 (expected number, got number)

here is the code: https://imgur.com/a/eadU48o

I cant see what is causing the issue. any help would be great. There are no numbers involved in the second line, how can it not be happy with a number if it expected one?


r/ComputerCraft • • Aug 01 '20

Help with a finding code.

0 Upvotes

Hey, I was wondering if anyone new the code for a farming turtle that could farm a plot of 16x16 (if possible). I've looked around and haven't found much for CC 1.58, the version used for tekkit. Any help is appreciated, thanks.


r/ComputerCraft • • Oct 10 '24

does anybody now where the timeout number is stored because maybe me or somebody else could figure out to edit it

2 Upvotes

r/ComputerCraft • • Jun 21 '20

Simple cobblestone generator code

2 Upvotes

I'm new to ComputerCraft but I know how to code. I have a very simple program here that mines from a vanilla cobblestone generator (lava and water) and places it in an inventory above it.

The code works but I don't like the fact that it is busy waiting for the cobblestone to be generated. Is there any way for the code to sleep until a block is detected with the "detect()" command?


r/ComputerCraft • • Dec 12 '16

Nested programs or functions?

2 Upvotes

I'm writing a utility program that will give me about 20 different functions that the computer can perform all red stone related.

Each function is relatively small, is it better to split them into seperate programs to be called on or have a small api of functions that the main program can use.

Also i need the program to persist after restarts etc so what is the best way to do this.


r/ComputerCraft • • Jan 24 '17

Computercraft code help

2 Upvotes

The code lies here: http://pastebin.com/FcJcPg3s


r/ComputerCraft • • Jan 21 '17

Whats a string?

2 Upvotes

I'm very new to computer craft and lua in general so I don't understand that wiki about it... So can you give a small explanation what it is because it says "bios:14: [string "2"]:13: '=' expected"


r/ComputerCraft • • Jan 24 '17

How do i close programs on advanced computer?

2 Upvotes

I have 4 .temp things and one of my programs running... Also can you get a program to automatically close itself when told to?


r/ComputerCraft • • Oct 29 '24

Updated Draconic Reactor software?

2 Upvotes

Currently looking for updated software for the draconic reactor on 1.20.1


r/ComputerCraft • • Jul 12 '15

I'm have a very large brain fart right now, please help with Big Reactors simple code

2 Upvotes

So, I'm having like the biggest brain fart ever and i dont remember how to do a simple IF THEN statement using CC to read a Reactors RF Amount.

Literally bashing my head on my keyboard, because i know it's easy but i just cannot remember it.

Thanks for the help!


r/ComputerCraft • • May 30 '23

I'm back for more programming help.

2 Upvotes

Looking fo some help on programming as I have no knowledge at all, but think it's fun anyways

I know how to write simple programs like startup, and programs with a redstone signal. That's about it... and the pull raw

Is there any way to lock a computer so that you can only access the files and not edit them? And not make new files either? (Programs? Don't hassitate to correct me, I'd love to learn)

Example:

Having 3 different programs that each can make a redstone signal to each a different thing/usage, is it possible to lock the computer so ONLY thode 3 can be accessed, and can't be editied, and there is no possible way to make a new program/command to bypass and give the redstone signal another way?

Thanks in adnavce


r/ComputerCraft • • Jun 02 '23

Digital Miner Reset time setup

2 Upvotes

Hello! I'm not good at programming and my attempt... well don't work XD, I enter to the peripherals of the digital miner but I don't know how to set an "x" time to reset and start it again, can someone help me?


r/ComputerCraft • • Dec 22 '24

Trying to determine what's in a slot within a turtle's inventory: 1.21, ATM10

2 Upvotes

here the code I've currently got Extremely basic tree harvesting for turtles in CC: Tweaked it's a fork of someone else code but due to the way ATM10 works it seems moving the turtle isn't needed. what I'm trying to do is check if there are saplings in the 2nd slot and if so place one, otherwise just dump the stack on the ground. I haven't changed the code much otherwise. I'm literally using droppers to give the turtle saplings rn


r/ComputerCraft • • May 22 '22

help running code on a computer from another computer

2 Upvotes

r/ComputerCraft • • Nov 18 '22

Cannot Connect to Pastebin

2 Upvotes

I'm trying to use a program from pastebin but when I put the code down, It fails to connect to pastebin itself.

Anyone know how to fix this?


r/ComputerCraft • • Jul 02 '24

Chunk Loader peripheral for CC: Tweaked 1.15.2

2 Upvotes

I need peripheralsplusone but it only supports 1.12.2 and im on 1.15.2 is there any alternatives as i need the chunk loader peripheral for a project im working on


r/ComputerCraft • • Jun 19 '24

Attempting to add more triangles and objects as needed (Toms Peripherals 1.20.1)

2 Upvotes
local tris = {
    -- SOUTH
    { 0.0, 0.0, 0.0,    0.0, 1.0, 0.0,    1.0, 1.0, 0.0 },
    { 0.0, 0.0, 0.0,    1.0, 1.0, 0.0,    1.0, 0.0, 0.0 },
    -- NORTH                                                     
    { 1.0, 0.0, 1.0,    1.0, 1.0, 1.0,    0.0, 1.0, 1.0 },
    { 1.0, 0.0, 1.0,    0.0, 1.0, 1.0,    0.0, 0.0, 1.0 },
    -- EAST                                                      
    { 1.0, 0.0, 0.0,    1.0, 1.0, 0.0,    1.0, 1.0, 1.0 },
    { 1.0, 0.0, 0.0,    1.0, 1.0, 1.0,    1.0, 0.0, 1.0 },
    -- WEST                                                      
    { 0.0, 0.0, 1.0,    0.0, 1.0, 1.0,    0.0, 1.0, 0.0 },
    { 0.0, 0.0, 1.0,    0.0, 1.0, 0.0,    0.0, 0.0, 0.0 },
    -- TOP                                                       
    { 0.0, 1.0, 0.0,    0.0, 1.0, 1.0,    1.0, 1.0, 1.0 },
    { 0.0, 1.0, 0.0,    1.0, 1.0, 1.0,    1.0, 1.0, 0.0 },
    -- BOTTOM                                                    
    { 1.0, 0.0, 1.0,    0.0, 0.0, 1.0,    0.0, 0.0, 0.0 },
    { 1.0, 0.0, 1.0,    0.0, 0.0, 0.0,    1.0, 0.0, 0.0 },
};
local stone = io.open("stone.png", "rb")
local gpu = peripheral.wrap("bottom")
local keyboard = peripheral.wrap("tm_keyboard_0")

gpu.refreshSize()
gpu.setSize(64)
local gl = gpu.createWindow3D(1, 1, 1024, 576)
gl.glFrustum(90, 0.1, 1000)
gl.glDirLight(0, 0, -1)
local zRot = 0
local yRot = 0

local xPos = 0
local zPos = 0

local lastMousePos = {1, 1}


local function updateCursor() 
    local i = 0
    while true do
        i = i + 1
        sleep(0.1)
    end
end

local function pipeEvents()
    while true do
        local event, per, x, y, btn = os.pullEvent()

        if event == "tm_keyboard_key" then
            --W = 87
            --A = 65
            --S = 83
            --D = 68 
            if x == 87 then
                print("Pressed W")
                local mx = math.cos(zRot) / 10
                local mz = math.sin(zRot) / 10

                xPos = xPos + mx
                zPos = zPos + mz

            elseif x == 65 then
                print("Pressed A")

            elseif x == 83 then
                local mx = math.cos(zRot) / 10
                local mz = math.sin(zRot) / 10

                xPos = xPos - mx
                zPos = zPos - mz
            end

        elseif event == "tm_monitor_mouse_move" then
            local ox = lastMousePos[1]
            local oy = lastMousePos[2]
            local cx = x - ox
            local cy = y - oy
            zRot = zRot + cx
            zRot = zRot % 360
            --yRot = yRot + cy
            --yRot = yRot % 360
            lastMousePos = {x, y}
        
        end
   end
end

local function runGraphics()
    while true do
        gl.clear()
        gl.glDisable(0xDE1)
        gl.glTranslate(xPos, 0, zPos + 3)
        --gl.glRotate(45, 0, 1, 0)
        gl.glRotate(zRot, 0, 1, 0)
        gl.glRotate(-yRot, 0, 0, 1)

        gl.glBegin()

        --gl.glColor(0, 0, 255)
        for k,v in pairs(tris) do
            local ci = math.floor((k - 1) / 2)
            gl.glVertex(v[1], v[2], v[3])
            local cv = 255
            if ci % 2 == 0 then
                cv = 127
            end
            if math.floor(ci / 2) == 0 then
                gl.glColor(cv, 0, 0)
            elseif math.floor(ci / 2) == 1 then
                gl.glColor(0, cv, 0)
            else
                gl.glColor(0, 0, cv)
            end
            gl.glVertex(v[4], v[5], v[6])
            gl.glVertex(v[7], v[8], v[9])
        end
        gl.glEnd()
        gl.render()
        gl.sync()
        gpu.sync()
        sleep(0.01)
    end
end

parallel.waitForAny(updateCursor, pipeEvents, runGraphics)

r/ComputerCraft • • Sep 25 '23

Is there a way to make something to calculate the costs of recipes?

2 Upvotes

got into a long crafting tree in a modpack, just wanted to know.


r/ComputerCraft • • Oct 14 '23

SCREW IT INFINIT AMMO | Hound Turrets Progress Log #9

Thumbnail
youtube.com
2 Upvotes

r/ComputerCraft • • Sep 29 '21

Hbm support

2 Upvotes

Does anyone here know if hbm works with computercraft? I want to make a computerised launch system


r/ComputerCraft • • Feb 03 '24

More than 5 peripherals per computer

2 Upvotes

I've worked with CC once or twice so far, and the documentation has carried me super well so far, whenever I worked with it, however, I've now started working on a rather advanced automation/resource management system. I know you can make computers communicate via routers, but is there a way to have one computer have a ton of peripherals, preferably ones that dont have to be adjacent to the computer at all? Im sure this has to be possible, but in my half an hour spent googling I couldn't find anything.

P.S: I'd prefer not having to use several computers, as one computer will do just fine, I simply more possibilities for interaction that's all.


r/ComputerCraft • • Sep 22 '22

Need help using Tapes

2 Upvotes

Can someone send me a good mining code thats prety smart i tried a bunch but nearly all of them crash.Thanks for the help!


r/ComputerCraft • • Aug 27 '19

WebDisplays for iOS?

0 Upvotes

My Windows PC is broken & I can’t afford a new one.

the only thing I have is iPad. Please help