Jump to content




MagicTurtle v1.38 - Pathfinding! Mapping! Exploration!

turtle api

53 replies to this topic

#1 EatenAlive3

  • New Members
  • 53 posts

Posted 27 May 2012 - 01:17 PM

Hi all. Originally, I found Liraal's MagicTurtle API and started improving on it, and then we started working together. Eventually, I suppose he lost interest, but he did give me permission to post this as my own API. I haven't worked on this in a while, so it is still in the beta stage for a few features, like unmapped pathfinding, although it does work for the most part. Anyway, full feature list below in spoilers, but here are some of the highlights:

> The turtle will record data through a mapping system as it travels; it remembers where it's been and what blocks were there.
> The turtle is able to explore portions of land fairly quickly.
> Turtles are now able to pathfind to given coordinates, so long as it has mapped the area for it.
> ...if the area has not been mapped, it will do its best to get there.
> Ability to render a map of what's been explored, or a given coordinate.
> Tons of features that really should be in turtles, like place(cobblestone), forward(5), or select(wood).
> Tons of even more cool features that make it so you will never have to worry about turtle functions again!

Spoiler

Pastebin:
http://pastebin.com/Yt1u8zAu

If there is enough support for this, then I will go on to finish v1.4, and possibly more beyond that. v1.4 will streamline all code, and fix any bugs that may exist. I'm actually about 40% done with that so far. Post any questions, comments, or suggestions about the API in this thread.

Basic usage guide:
Spoiler

If you would like an example code, here is something that O.S. wrote, as a manual remote control for turtles using a modified graph function:
Spoiler

Smarter turtles for a smarter future!

Enjoy!

#2 professorloz

  • New Members
  • 2 posts

Posted 14 June 2012 - 01:07 AM

Total noob here so this'll probably sound like something really basic but here goes. I am trying to make a program that will go to a specific co-ordinate set given, e.g. 3,5,7 and then do a bunch of stuff, like dig down or place a TNT block etc, then return. Now I had a bit of trouble but so far I have this:

term.clear()
term.setCursorPos(1,1)
print("-------------------------")
print("Where am I [X]?:")
print("-------------------------")
a = io.read()
a = tonumber(a)
print("-------------------------")
term.clear()
term.setCursorPos(1,1)
print("-------------------------")
print("Where am I [Y]?:")
print("-------------------------")
b = io.read()
b = tonumber(-_-/>/>
print("-------------------------")
term.clear()
term.setCursorPos(1,1)
print("-------------------------")
print("Where am I [Z]?:")
print("-------------------------")
c = io.read()
c = tonumber(c)
print("-------------------------")
term.clear()
term.setCursorPos(1,1)
print("-------------------------")
print("Where am I going [X]:")
print("-------------------------")
d = io.read()
d = tonumber(d)
print("-------------------------")
term.clear()
term.setCursorPos(1,1)
print("-------------------------")
print("Where am I going [Y]:")
print("-------------------------")
e = io.read()
e = tonumber(e)
print("-------------------------")
term.clear()
term.setCursorPos(1,1)
print("-------------------------")
print("Where am I going [Z]:")
print("-------------------------")
f = io.read()
f = tonumber(f)
print("-------------------------")
term.clear()
term.setCursorPos(1,1)
print("-------------------------")
print("Setting position as:")
print("-------------------------")
print(a.. "," ..b.. "," ..c)
print("-------------------------")
sleep(1)
term.clear()
term.setCursorPos(1,1)
print("-------------------------")
print("Setting destination as:")
print("-------------------------")
print(d.. "," ..e.. "," ..f)
print("-------------------------")
sleep(1)
magic.setPos(a.. "," ..b.. "," ..c)
magic.goToPos(d.. "," ..e.. "," ..f)
magic.setPos(d.. "," ..e.. "," ..f)
magic.goToPos(a.. "," ..b.. "," ..c)

It seems to have a problem with the setPos and goToPos bit, I did a print of the destination and current position to make sure the output of the a.. "," ..b.. "," ..c and the d.. "," ..e.. "," ..f was in the right layout to function yet for some reason it doesn't like it. I suspect that the layout I have done only works for the print() function. Anyways any help making this work or remaking it or whatever would be helpful thanks :(/>

Also, it's magic.* as I named the api file as magic, also I've attempted to get it to return by grabbing the older location numbers and the destination numbers and simply swapping them. Also would I need to do this setNorth() stuff, it doesn't use the getPos() so I'm not sure if it does?

Thanks Again in advance :)/>

Kieran

#3 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 14 June 2012 - 05:33 PM

Yeah, you shouldn't be trying to concatenate those arguments into a string. Get rid of the quotes around the commas and the concatenation operators and it should work.

#4 kazagistar

  • Members
  • 365 posts

Posted 16 June 2012 - 06:33 AM

This is pretty beast. I am going to have to look into how you do stuff like architecting...

#5 EatenAlive3

  • New Members
  • 53 posts

Posted 17 June 2012 - 02:57 PM

Thanks! Yes, the architect system is pretty clever. I try to make turtles more useful by letting them collect as much information as they possibly can. The more they know, the more they can do!

#6 maxostarr

  • New Members
  • 2 posts

Posted 02 July 2012 - 01:13 AM

when i try mt.setpos(x,y,z) i get "27: [string "lua"]:1: ')' expected". plz help

#7 EatenAlive3

  • New Members
  • 53 posts

Posted 07 July 2012 - 11:02 AM

Remember, Lua is case-sensitive. Use mt.setPos(), not mt.setpos.

#8 rommels

  • New Members
  • 1 posts

Posted 10 July 2012 - 12:42 PM

Having a bit of an odd issue with the .pathfind(x,y,z) function in that it does not apear to work with the error "mt:2495: attempt to index ? (a nill value)" the command: mt.pathfind(89,64,243)

The alternative goToPos works, however as warned will not reach the destination if it comes accross an obsticle, the appropriate .setPos and .setFacing() have been set and the script is located in mt (/rom/apis)

any ideas?

#9 MathManiac

  • Members
  • 60 posts
  • LocationWashington, United States

Posted 14 July 2012 - 05:00 PM

@proffesorloz, rommels: Stop hijacking people's threads. Post your own thread at http://www.computerc...m/14-ask-a-pro/


I'm having trouble with some of your spoilers. Some of them looks like they are three spoilers with one spoiler button, and I can't open them with the button.

#10 maxostarr

  • New Members
  • 2 posts

Posted 20 July 2012 - 10:30 PM

View PostEatenAlive3, on 07 July 2012 - 11:02 AM, said:

Remember, Lua is case-sensitive. Use mt.setPos(), not mt.setpos.
thx from maxostarr

#11 KyleBoyer

  • New Members
  • 4 posts

Posted 24 July 2012 - 08:33 AM

This is pretty nice, but I am completely lost at how to ge this setup, so I did this:
pastebin get Yt1u8zAu startup
It gets the script and installs it as "startup", then I start the script by saying "startup" and it says I need to set the position with setPos. How in the world do I set the Pos?

#12 EatenAlive3

  • New Members
  • 53 posts

Posted 03 August 2012 - 10:35 AM

Read in the original post, "Basic Usage guide." Don't worry, it isn't a long read!

#13 Keaton

  • New Members
  • 8 posts
  • LocationChicago, USA

Posted 03 August 2012 - 02:57 PM

This is very interesting, and I was wondering if you could further explain how the mt.gotoPos works, it would be a really useful thing to include in something I am working on. Nuke dropping gps guided turtles is something I would love to get working on my friends server.


Also, does this work on a server if only one person has installed it, or does the server need to?

#14 EatenAlive3

  • New Members
  • 53 posts

Posted 03 August 2012 - 08:59 PM

It only matters that an ingame turtle has this installed, and then you can redistribute it to other computers via floppy-disks.

#15 Keaton

  • New Members
  • 8 posts
  • LocationChicago, USA

Posted 03 August 2012 - 09:40 PM

Ok so put it into the turtles, but iv never seen the magic. commands, is there anything special about them or anything else i must do to make all of it work? and could i use mt.gotoPos outside of this specific program?

#16 Pharap

  • Members
  • 816 posts
  • LocationEngland

Posted 08 August 2012 - 05:24 PM

View Postprofessorloz, on 14 June 2012 - 01:07 AM, said:

Total noob here so this'll probably sound like something really basic but here goes. I am trying to make a program that will go to a specific co-ordinate set given, e.g. 3,5,7 and then do a bunch of stuff, like dig down or place a TNT block etc, then return. Now I had a bit of trouble but so far I have this:

It seems to have a problem with the setPos and goToPos bit, I did a print of the destination and current position to make sure the output of the a.. "," ..b.. "," ..c and the d.. "," ..e.. "," ..f was in the right layout to function yet for some reason it doesn't like it. I suspect that the layout I have done only works for the print() function. Anyways any help making this work or remaking it or whatever would be helpful thanks ;)/>

Also, it's magic.* as I named the api file as magic, also I've attempted to get it to return by grabbing the older location numbers and the destination numbers and simply swapping them. Also would I need to do this setNorth() stuff, it doesn't use the getPos() so I'm not sure if it does?

Thanks Again in advance :(/>

Kieran

You know you're supposed to start your own thread if you want to ask questions, right?
Hijacking other people's threads to ask questions isn't good.

View PostMathManiac, on 14 July 2012 - 05:00 PM, said:

@proffesorloz, rommels: Stop hijacking people's threads. Post your own thread at http://www.computerc...m/14-ask-a-pro/


I'm having trouble with some of your spoilers. Some of them looks like they are three spoilers with one spoiler button, and I can't open them with the button.

Give him a break, it's his first post.

#17 Pharap

  • Members
  • 816 posts
  • LocationEngland

Posted 08 August 2012 - 05:25 PM

This is everything turtles should do and more. I support the project. In fact, if you ever need an extra pair of hands to help you, I'm prepared to help you out since I had an idea similar to this and it will help me out majorly with my planned turtle project.

I don't know how to make APIs and I'm still fairly new to lua (only been using it for about a week) but I have quite a bit of programming experience (I'm competent in VB, fairly good at C# and have dabbled in C++ as well as knowing the basics of html and css. And yes, I do know about object orientation) and I'm good at solving problems so if you do need help, I'd love to be able to contribute to a project like this.

#18 EatenAlive3

  • New Members
  • 53 posts

Posted 08 August 2012 - 05:59 PM

I'd love to hear your ideas, if you're willing to share them. Send me a PM if you want, and we might be able to code it in. Currently I am unable to improve the API because I've injured my left hand and want to keep it out of use, but I will return to the project soon and I'm open to ideas.

#19 mynameisjpro

  • New Members
  • 1 posts

Posted 13 August 2012 - 08:59 AM

How do I connect this to a remote terminal? :P/> and run commands from the remote terminal. :S

#20 EatenAlive3

  • New Members
  • 53 posts

Posted 17 August 2012 - 01:09 PM

To connect this to a remote terminal, you would have to broadcast the messages from a central turtle/computer, and receive them from your target turtle.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users