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
1
vote
1 answer

ComputerCraft get Item Id inside Blood Magic altar

I'm trying to automate a Blood Magic Altar in Enigmatica 2 Expert Skyblock (1.12.2). I'm trying to get the ID of the item inside the altar but this does not work. I searched a lot and have not found any solution which worked. So here is my option,…
Smiley444
  • 23
  • 3
1
vote
1 answer

Attempting to connect to a websocket returns "Attempt to call nil" in computer craft

I'm trying to connect to the twitch chat-irc websockets, but when I run my code to test, it returns .temp:7: attempt to call nil. I've heard that it has to do something with functions, but my code has no functions, only strings, and has only 2 other…
Spiring
  • 11
  • 1
1
vote
0 answers

problem with 3d rastarizer in lua z dimension is not working

so basicaly i try to translate olc3d engine from cpp to lua in computercraft in minecraft i can translate the cube in x and y but z does not work this is the original olc3d engine that i try to…
user.karol
  • 21
  • 1
1
vote
2 answers

Trying to run two loops at the same time Minecraft ComputerCrafft

This is my code https://pastebin.com/fnZreFKA I have tried all the coroutine options, I have print statements at the start of each of the two functions, it prints, but it doesn't do anything in the…
Epuuc
  • 53
  • 5
1
vote
2 answers

Time complexity of array manipulations in LUA

I'm discovering Lua with ComputerCraft (for Minecraft), and I need 2 functions : the cardinal function #foo (for a given table named "foo") popping out the last element from a table, for example : foo[#foo] = nil (is there something better ?) What…
Wulfhartus
  • 13
  • 2
1
vote
0 answers

Squeegie Program (Using Thirsty Turtle from PeripheralsPlusOne)

Hey y'all first time using lua in years, and highly inexperienced in it in the first place. I wrote this program to go down a BuildCraft Quarry hole in the nether and remove lava as it finds it, but as I'm inexperienced, I'm getting issues and need…
Yawrf
  • 71
  • 1
  • 7
1
vote
1 answer

(Lua) a while statements stops when an if statement inside stops

I am creating an automated farm in minecraft with computercraft turtles, and I ran into a snag. I have a place where the turtles drop the wheat they collected into a hopper, but as soon as CropData.name == "minecraft:wheat" is false inside the if…
1
vote
2 answers

Separate / count lines in a string

I'm currently programming a proof of concept text editor for computerCraft, in Lua; one feature will be line counting. How would one count the lines in a string, or at least count the newline characters? There would also ideally be line numbers at…
VBW
  • 97
  • 10
1
vote
1 answer

'end' expected (to close 'if' at line 12) in Mining Turtle program

I have been working on a program to make a turtle mine for me. Here it is: local depth = 0 local isJunk = true function fuel() if turtle.getFuelLevel() < 20 then turtle.select(16) turtle.refuel(1) end end function up() …
WatsonBoi
  • 121
  • 11
1
vote
1 answer

Computercraft: Can a coroutine do infinite loops?

I'm trying to do a software which can handle other programs, to start a program I use os.run(...) inside a coroutine, Here is my code: --VARS local os_ver = "0.1" local w,h = term.getSize() --Terminal size local bar_b_color, bar_f_color --Background…
1
vote
2 answers

How to sort inner tables by value?

So, as the title says, I would like to sort a table of tables in Lua. One such example nested table is below. tabl = {2.0={amount=281.0, meta=0.0, displayName=Dirt, name=minecraft:dirt}, 3.0={amount=190103.0, meta=0.0, displayName=Cobblestone,…
1
vote
3 answers

Table with methods, how to handle/inspect them?

So without the context, I have a method that returns a table. Trying to print it out, it seems that the table mainly contains methods to be called. However not being very knowledgeable in LUA, i have no idea how to properly get some information…
Smileynator
  • 677
  • 8
  • 24
1
vote
1 answer

Error with Lua "if then" statements ('end' expected (to close 'if' at line 28))

I got an error that says bios:14: [string "Lighting"]:58: 'end' expected (to close 'if' at line 28) I honestly have no idea what I'm doing since I'm new to Lua and coding in general. I assume that it has something to do with not having an end…
user4231762
1
vote
1 answer

Computercraft bundled cable program not responding

After several revisions, my Lua program still refuses to do anything. --Let's Go! --Program Infos --Mappings --Pink: Gate 1 --Red: East Tower 2 --Orange: West Tower 3 --Lime: Armoury 4 --Blue: Master Bedroom 5 --Grey: Guest Bedroom 6 --Cyan: Power…
RTB779500
  • 13
  • 4
1
vote
2 answers

Iterate over table in order of value

Lets say I have a table like so: { value = 4 }, { value = 3 }, { value = 1 }, { value = 2 } and I want to iterate over this and print the value in order so the output is like so: 1 2 3 4 How do I do this, I understand how to use ipairs…
Harry
  • 304
  • 4
  • 14
1 2
3
9 10