Sounds like someone needs to fuel the turtle....

There have been 2 items by Molinko (Search limited from 10-June 22)
Posted by
Molinko
on 13 September 2016 - 11:42 PM
in
Turtle Programs
Posted by
Molinko
on 13 September 2016 - 11:26 PM
in
Turtle Programs
--... --------CONFIGURATION-------- channel = ... -- <- this will take a string argument at the start of the program. Now people wont have to edit the file, just start with 'program uuid' --------ACTUAL CODE-------- os.loadAPI("ender")--Created by Sxw on the Computercraft Forums -- os.loadAPI("commands") ?YAY? ender.connect(channel) -- This commands table could even be loaded with os.loadAPI and stored separately in another file... commands = { forward = function(n) n = tonumber(n) -- still a string from being sent over modem and parsed. Maybe parseCmd() can convert string arguments to the proper type when parsing... for i = 1, n do turtle.forward() end end, up = ..., down = ..., select = function(slot) -- this helps readability x16 ;)/> turtle.select(tonumber(slot)) end -- ... and more dig3 = function() -- custom commands are easier to deal with here in my opinion turtle.digUp() turtle.digDown() turtle.dig() end } function parseCmd(message) local f, args, cmd = string.gmatch(message, "%S+"), {}, nil cmd = f() for arg_ in f do args[#args+1] = arg_ end return cmd, args end function slot(num) turtle.select(num) end while true do worked = false while worked == false do worked, command = ender.receive(channel) command, args = parseCmd(command) sleep(0.1) end if commands[command] then commands[command](unpack(args)) else print('invalid command') end end