Questions tagged [computercraft]

ComputerCraft is a Minecraft mod which adds Lua-based scripting.

ComputerCraft (often also called CC) is a modification for the game . It adds new blocks (known as Turtles and Computers) and Items (known as Pocket Computers) to the game. They can be programmed using -based scripting.

141 questions
14
votes
7 answers

How to terminate Lua script?

How would I terminate a Lua script? Right now I'm having problems with exit(), and I don't know why. (This is more of a Minecraft ComputerCraft question, since it uses the APIs included.) Here is my code: while true do if turtle.detect() then …
user1610406
  • 722
  • 1
  • 13
  • 24
6
votes
2 answers

How to remove a string from a table

I've been trying to find a way to remove a string from a table kind of like this: myTable = {'string1', 'string2'} table.remove(myTable, 'string1') but I haven't been able to find anyway to do it. Can someone help?
Lysus
  • 61
  • 1
  • 2
6
votes
1 answer

how do I run a computercraft program like 'excavate 5'

can someone tell me the command so I can make programs like: 'program 19' or 'build house 5 3 10' instead of having to rely on input = read()? I've been hunting this down forever and haven't figured it out or found it yet, so it would be nice if…
Edward Ford
  • 71
  • 1
  • 1
  • 3
5
votes
2 answers

How to redirect stdout to file in Lua?

I'm trying to redirect stdout in Lua (5.1) to a file instead of to console. There is a third-party API (which I cannot modify) containing a function that prints out a serialized set of data (I do not know which function does the printing, assume…
cwbit
  • 88
  • 1
  • 6
4
votes
3 answers

How or Can I pass a function with argument as a parameter to a function in lua?

I am not running straight lua but the CC-Tweaks ComputerCraft version. This is an example of what I am trying to accomplish. It does not work as is. *edited. I got a function to pass, but not one with arguments of its own. function…
marcm
  • 43
  • 4
3
votes
2 answers

How to Put Data Into a Table From an Existing File

I have a program for a turtle in ComputerCraft that is meant to be a storage unit. I input an item, and it should read a file to find where to put the item. If there is a new item, it adds the information to a file. When I do blockTypes = {} local…
WatsonBoi
  • 121
  • 11
3
votes
1 answer

attempt to compare string with number - computercraft

local level = 3 -- Required access level local sideIn = "bottom" -- Keycard Input Side local sideOut = "right" -- Redstone output side local rsTime = 3 -- Redstone time while true do if disk.isPresent(sideIn) then term.clear() …
Lime Dashie
  • 31
  • 1
  • 2
3
votes
1 answer

How to Call a Table from a Variable in Lua?

I'm creating a program for a turtle in ComputerCraft. The program is going to make the turtle control a warehouse of storage for my items in the game. It will check what item I put in, then it will figure out the chest's location, go there, and dump…
WatsonBoi
  • 121
  • 11
3
votes
3 answers

how can I write own functions in turtleOS Minecraft Tekkit

My question is: Is it possible to create a new function or method in turtleOS? And how? At example I want to write a function turnArround() and I want to use it in another programm I know how I can create a new function in Lua. I just dont know how…
Qubilai
  • 31
  • 1
2
votes
1 answer

Minecraft Computercraft Rednet.broadcast() isn't passing the proper value

The full code itself is very convoluted, long, and novice-written; I'm trying to send x and z coordinates via rednet from a computer to a separate receiver turtle. Receiver rednet.broadcast("Awaiting Input!") xAxis = rednet.receive() --Have tried…
user17908559
2
votes
1 answer

can you use a colon in a key for a lua table

So I'm writing a program for the minecraft mod computercraft. I wanted to know if it was possible to do something like this: tbl = {} var = "minecraft:dirt" tbl[var] = {pos ={0,0,0,1}} For some reason I feel it doesnt save this table correctly so…
bcash8
  • 21
  • 1
2
votes
1 answer

What does window:94:arguments must be the same length stand for?

I'm trying to figure out what im doing wrong, but this is the only thing i got as error. Can you give me some tips what i can look for? The error happens when Deutsch is selected, it works fine when Englisch is selected. --Size 51,18 --Zeit: 75 w,…
ReySKR
  • 67
  • 6
2
votes
1 answer

How to fix " '}' expected " with a list

I am making a simple list variable and trying to print it, however I receive an error stating that I am missing an end bracket. I already tried to wrap the entire variable with brackets, but to no avail. Code: local list = {0 = "Alpha", 1 =…
2
votes
1 answer

lua expected near end

I'm trying to make a keycard door in minecraft using computercraft and it gives me an error at line 23 saying expected rs.setOutput("bottom", true) while true do if disk.isPresent("top") then if fs.exists("disk/.cardauth/authkey") then …
Liam Kelly
  • 23
  • 1
  • 3
2
votes
1 answer

Lua (CC) GUI class draws all components in the same window when told to draw them in separate windows

Prelude ComputerCraft is a mod for Minecraft (Forge) that adds a crude lua-based Computer to the game. Using this Computer, one can write programs to interact with the Minecraft world in various ways. Whether a ComputerCraft question is applicable…
Bjonnfesk
  • 298
  • 2
  • 13
1
2 3
9 10