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

[Beta] µTurtle - Programming turtles made quick and easy! - New language (kindof)

Started by jesusthekiller, 17 June 2013 - 12:51 AM
jesusthekiller #1
Posted 17 June 2013 - 02:51 AM
µTurtle

Turtles made easy!





Hi all! That's an program/programming language that I've planned for a while since now, finally created it yesterday. It's shortcut-language for turtles, it includes 53 unique shortcuts (55 total) for all functions from turtle API. It's in beta, expect it to change a bit a lot, add new syntax elements, etc.


Program parses µTurtle code to Lua, as for now it adds " " or "\n" every character separated by space, so it will be changed.





Language construction:

Every µTurtle function starts with semicolon - ';'.


As for beta 0.1 there are 10 shortcuts which require arguments. All arguments have to be provided, if argument is unnecessary, use nil in it's place. Also arguments can not be µTurtle code (It will be fixed).


µTurtle code can be 'mixed' with Lua, i.e.


for i = 1, 5 do
  ;go
end


or



while ;detect do
  ;gol
end

is correct example.





Language syntax:

Basic movement:
  • ;go - turtle.forward()
  • ;back - turtle.back()
  • ;left or ;l - turtle.turnLeft()
  • ;right or ;r - turtle.turnRight()
  • ;up - turtle.up()
  • ;down - turtle.down()
Looped movement (try to go until success):
"l" at the end stands for "Loop"
  • ;gol - while not turtle.forward() do sleep(0.8) end
  • ;backl - while not turtle.back() do sleep(0.8) end
  • ;upl - while not turtle.up() do sleep(0.8) end
  • ;doenl - while not turtle.down() do sleep(0.8) end
Dig:
  • ;dig - turtle.dig()
  • ;digup - turtle.dugUp()
  • ;digdown - turtle.digdown()
Looped go and dig (try to dig and go until success):
"d" at the end stands for "dig"
  • ;god - while not turtle.forward() do turtle.dig() end
  • ;backd - turtle.turnLeft() turtle.turnLeft() while not turtle.forward() do turtle.dig() end turtle.turnLeft() turtle.turnLeft()
  • ;upd - while not turtle.up() do turtle.digUp() end
  • ;downd - while not turtle.down() do turtle.digDown() end
Suck:
  • ;suck - turtle.suck()
  • ;suckup - turtle.suckUp()
  • ;suckdown - turtle.suckDown()
  • ;sucka - turtle.suck() turtle.suckUp() turtle.suckDown()
Attack:
  • ;att - turtle.attack()
  • ;attup - turtle.attackUp()
  • ;attdown - turtle.attackDown()
Attack and suck:
"s" stands for "suck"
  • ;atts - turtle.attack() turtle.suck()
  • ;attups - turtle.attackUp() turtle.suckUp()
  • ;attdowns - turtle.attackDown() turtle.suckDown()
Detect:
  • ;detect - turtle.detect()
  • ;detectup - turtle.detectUp()
  • ;detectdown - turtle.detectDown()
Place:
  • ;pl - turtle.place()
  • ;plup - turtle.placeUp()
  • ;pldown - turtle.placeDown()
Compare:
  • ;comp - turtle.compare()
  • ;compup - turtle.compareUp()
  • ;compdown - turtle.compareDown()
  • ;compto <slot> - turtle.compareTo(<slot>)
Fuel:
  • ;fuel - turtle.getFuelLevel()
  • ;refuel slot - turtle.refuel(<slot>)
Slot:
  • ;sel <slot> - turtle.select(<slot>)
  • ;count <slot> - turtle.getItemCount(<slot>)
  • ;space <slot> - turtle.getItemSpace(<slot>)
  • ;transfer <slot> <qty> - turtle.transferTo(<slot>, <qty>)
Craft:
  • ;craft <qty> - turtle.craft(<qty>)
Drop:
  • ;drop <qty> - turtle.drop(<qty>)
  • ;dropup <qty> - turtle.dropUp(<qty>)
  • ;dropdown <qty> - turtle.dropDown(<qty>)


Download:

pastebin get EybPyxRU uturtle





Usage:


uturtle <file it> <file out> [line]


If "line" added at the end, it will generate "\n" instead of " ".





License:

Spoiler



µTurtle
Copyright © 2013 Jesusthekiller

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
theoriginalbit #2
Posted 17 June 2013 - 02:53 AM
Where is the code?
jesusthekiller #3
Posted 17 June 2013 - 02:58 AM
I derped and posted too quickly, still making post :/
theoriginalbit #4
Posted 17 June 2013 - 03:02 AM
I derped and posted too quickly, still making post :/

Ahh ok. one thing I've noticed already
Spoiler
Looped movement (try to go until success):
"l" at the end stands for "Loop"
  • ;gol - while not turtle.forward() do sleep(0) end
  • ;backl - while not turtle.back() do sleep(0) end
  • ;upl - while not turtle.up() do sleep(0) end
  • ;doenl - while not turtle.down() do sleep(0) end
If you're going to have it loop then either remove the sleep, or have it sleep 0.8 to allow for falling blocks. so either of these.

while not <func> do end
while not <func> do sleep(0.8) end
jesusthekiller #5
Posted 17 June 2013 - 03:17 AM
Fixed and posted :)/>
superaxander #6
Posted 17 June 2013 - 03:26 AM
Nice more macro like but cool!
jesusthekiller #7
Posted 17 June 2013 - 03:28 AM
That's why it's 'kindof' programming language. I'm planning on expanding it a lot tho :P/>
Symmetryc #8
Posted 17 June 2013 - 08:59 AM
Nice, I like this "sort-of-programming-language" thing :P/>. Add's conveniences to Lua, but it's still Lua XD. I think to be a real language though, you'd have to make it actually run through your program, not just convert it to Lua.
jesusthekiller #9
Posted 17 June 2013 - 10:02 AM
Thanks!
First C++ compiler was translating to C, so…
bjornir90 #10
Posted 17 June 2013 - 11:14 AM
Looks cool !
jesusthekiller #11
Posted 17 June 2013 - 11:51 AM
Thanks! :)/>