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
2 answers

Saving values of variables in files

I'm making a program that uses a lot of variables and changes them constantly. How to save those variables into another file from inside the program?
Happymyself
  • 29
  • 1
  • 3
1
vote
2 answers

Calling a function whos name is stored in a string

I have a function e.g. function run() print("hi") end I have a string called message which contains the word "run": activity = message print(activity) --returns run However I am unable to use the string activity to run the function run(). I…
1
vote
1 answer

For loop inside a function in Lua, Computercraft

I'm learning programming in computercraft (minecraft) and having some trouble with reading some storage cells. The function that I'm working on shall go through all cells and add together the storage capacity to a variable in a for loop. This is…
1
vote
1 answer

ComputerCraft Lua Fake DDOS script

I'm trying to make a Lua program/script on ComputerCraft that acts like a botnet and pretends to DDoS the target input with the IP at the end randomizing every time. However, currently I get an error that says I attempt to call a number. What's the…
1
vote
1 answer

ComputerCraft Turtle mining program

I'd like to create mining program for Turtle from ComputerCraft mod. I've created this: function initVariables() stone = 0 cobblestone = 0 coal = 0 iron = 0 gold = 0 redstone = 0 diamond = 0 lapis = 0 dirt = 0 …
mieciu0077
  • 13
  • 1
  • 5
1
vote
1 answer

Computercraft Lua change nil to 0

I am using Computercraft, a Minecraft mod, and I needed help with something. I am attempting to find all peripherals of a type, get the energy from them, and add them together. However, I get a "attempt to perform arithmetic on nill" or something…
1
vote
3 answers

Using functions as arguments in lua

just messing around in computercraft, trying to use a function as an argument but cant get it to work bla = function() print("bla") end execfunc = function(func) func() end execfunc(bla()) I would like to do something as seen above, but with…
user3837761
  • 17
  • 1
  • 2
1
vote
1 answer

Variable and string concat to select variable in lua

I have a set of variables that holds quantity info and x to select the one I use. How can I concatenate the letter s and var x and have it read as s2 or s3 etc. The code I managed to find does not work. x = 2 s1 = false s2 = 64 s3 = 64 s4 = 64 s5 =…
1
vote
2 answers

ComputerCraft: Using shell.run() command in a program

I am trying to use the (file , parameters) functionality of the shell.run() command by assigning each word in a string to a new variable. The only way I know to do this is with tArgs[#]. Which if at the command line and typing a name of a program…
cmd
  • 563
  • 3
  • 10
  • 26
1
vote
1 answer

Lua Programming with ComputerCraft

I have created a small program that asks for the length width and heights that you wish a mining turtle to mine. When I run it in the advanced computer though, It lets me prompt for the length, width and height but then I get an error. The error is…
cmd
  • 563
  • 3
  • 10
  • 26
1
vote
2 answers

Computercraft variables

I am making a bank on Minecraft. I am having trouble with saving a variable after addition or subtraction has been done to it. For example, if x="balance", x=15, say I want to withdraw from my balance: x = 15 - y(withdrawn money) The variable is…
1
vote
4 answers

Adding a timer to my Lua program

I'm fairly new to Lua and I'm coding a program. The program is letter going around and collecting other letters (kinda like the worm program). However, i want this to be timed. (I'm on computercraft which is a mod for minecraft but still uses Lua,…
user1510082
  • 35
  • 1
  • 3
1
vote
6 answers

Lua "Attempt to index ? (a nil value)

So my friend and I are trying to write a program for ComputerCraft (Minecraft Mod), which uses Lua as a programming language. I haven't done any Lua before and he's played around a bit with it. Basically, we're trying to clear a line of text with…
Wolverine1621
  • 307
  • 2
  • 5
  • 13
1
vote
1 answer

Run script instructions from external source in Lua

Ok, I'm wanting to know if there's a way of running scripts from an external source with Lua. Be it another file in .txt format or from pastebin, what have you, and run the code and wait for said code to finish, and then continue on with the rest of…
BluZero
  • 39
  • 7
1
vote
2 answers

Lua os.date() function not working in Computer Craft

I'm trying to make an analog clock display the time (12-hour) and I have to use Lua. I use the following line to get the time in this format: os.date('%I:%M') This apparently doesn't work as I keep getting a nil error, this is the only thing wrong…
user1588869
  • 641
  • 1
  • 6
  • 8