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

Really nice programming environment setup I've figured out

Started by jackmott, 01 October 2015 - 12:19 PM
jackmott #1
Posted 01 October 2015 - 02:19 PM
First, ZeroBrane Studio is superb. Simple to install, use, has a good editor, run your programs with a click. Only problem of course, any CC api calls will fail since they don't exist. - http://studio.zerobrane.com/

So, make a new file, call it minecraft.lua or whatever you like. At the top of any CC program you are working on, add:

require "minecraft"

At the top, that will pull in the file.
Minecraft.lua can then have a stub for all the API calls you are going to use, like so:

http://pastebin.com/SPBTrBvp


I'm just printing out each api call, which lets me visualize in my head that the turtle is doing the right thing, but it wouldn't be too hard to actually output a 2d graphical representation instead if you wanted as well.

Then when you grab your code into your turtle, all you do is remove the requires line, and you are good to go
Lupus590 #2
Posted 01 October 2015 - 03:06 PM
In computercraft APIs are loaded with os.loadAPI(apiPathAndName), require doesn't exist in computercraft

Edit: oh, didn't notice that
Edited on 01 October 2015 - 02:05 PM
KCat156 #3
Posted 01 October 2015 - 03:17 PM
In computercraft APIs are loaded with os.loadAPI(apiPathAndName), require doesn't exist in computercraft
He's talking about using a lua IDE outside of computercraft.
Bomb Bloke #4
Posted 01 October 2015 - 03:18 PM
Indeed, the idea is that you use it to incorporate your stub file while testing code through the editor, then remove it when you're ready to "go live".
FUNCTION MAN! #5
Posted 01 October 2015 - 11:10 PM
Or better yet..

if require then
   require 'minecraft'
end
jackmott #6
Posted 02 October 2015 - 03:01 PM
oooh nice

I'm also delving now into adding a little bit of simulation to the stubb, so things like getItemCount and .suck and .place actually work

pretty soon I'll have all of minecraft in the stubb =)


Or better yet..

if require then
   require 'minecraft'
end
apemanzilla #7
Posted 03 October 2015 - 10:45 PM
At some point I had written a partial virtual turtle API. It would simulate (almost) everything about a turtle, including it's position, items, fuel, and facing. It didn't simulate the world though. I'll see if I can dig it up.
Edited on 03 October 2015 - 08:46 PM