This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
brainwipe's profile picture

Capabilities and limitations

Started by brainwipe, 29 September 2012 - 08:04 PM
brainwipe #1
Posted 29 September 2012 - 10:04 PM
I'm a minecraft fan (naturally, else I'd be lost) and a coder. I am considering coding neural networks in ComputerCraft but before I do I need to know what the limitations are. I've not coded in Lua in anger before and have skim read the syntax/compiler documentation. I imagine there are additional limitations placed on it given that it's running within a virtual machine (Lua construct) within a virtual machine (MC) within a virtual machine (Java). I've not had any MC mod experience.

Are the following possible:
  • Threads (coroutines in Lua but they amount to the same thing)
  • Passing functions by reference (Lua does it, does CC?)
  • Double floating point maths
  • OOP, (meta methods and meta tables in Lua - I think)
Some other questions:
  • Is the memory limited?
  • Is storage memory limited (when writing ?
  • What's the largest a file can be on a disk?
  • Is it possible to do file IO outside of minecraft without going to the net? (I'd imagine not)
  • Can you coerce garbage collection?
  • Does Lua sit in its own thread or does it run synchronously within Minecraft?
  • How is error handling / crash handling performed?
  • How do you debug? Write to console?
Thanks in advance for your help.
Doyle3694 #2
Posted 29 September 2012 - 10:20 PM
2. yes
5 yes but it's almost impossible to hit the limit
6 yes but it's almost impossible to hit the limit
7 a very high almost non reachable size.
8 no
11 you get a message on the screen that says what the bug is and on what line.
12 type 'lua' for debug.
MysticT #3
Posted 29 September 2012 - 10:54 PM
- Threads (coroutines in Lua but they amount to the same thing)
Yes, you can use coroutines to create something like threads.

- Passing functions by reference (Lua does it, does CC?)
- Double floating point maths
- OOP, (meta methods and meta tables in Lua - I think)
Almost all (if not all) lua features are included. All of this can be done.

- Is storage memory limited (when writing ?
I think there's no memory limit (except for the physical limit of course).

- What's the largest a file can be on a disk?
I think there's no limitation, just the os limit.

- Is it possible to do file IO outside of minecraft without going to the net? (I'd imagine not)
No, you can just read/write to files inside the computer folder.

- Can you coerce garbage collection?
Not anymore, the function was removed (I'm not sure why, but I'm sure they had a reason).

- Does Lua sit in its own thread or does it run synchronously within Minecraft?
It runs in it's own thread (the same for every computer).

- How is error handling / crash handling performed?
Same as lua, using error and pcall.

- How do you debug? Write to console?
Writing to console or a log file.
Cloudy #4
Posted 30 September 2012 - 12:07 AM
- Can you coerce garbage collection?
Not anymore, the function was removed (I'm not sure why, but I'm sure they had a reason)

while true do collectgarbage() end

Yep, good reason :)/>/>
MysticT #5
Posted 30 September 2012 - 01:51 AM
- Can you coerce garbage collection?
Not anymore, the function was removed (I'm not sure why, but I'm sure they had a reason)

while true do collectgarbage() end

Yep, good reason :)/>/>
Yeah, thought it was that. It causes a lot of lag :(/>/>
brainwipe #6
Posted 01 October 2012 - 12:40 PM
Thanks for the answers everyone! It looks like Lua/ComputerCraft has everything I need to get going. :)/>/>