Jump to content




MagicTurtle v1.38 - Pathfinding! Mapping! Exploration!

turtle api

53 replies to this topic

#21 funkey100

  • Members
  • 62 posts
  • LocationMars

Posted 26 August 2012 - 06:08 AM

I think this is awesome and should continue!

#22 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 29 August 2012 - 02:59 PM

View Postfunkey100, on 26 August 2012 - 06:08 AM, said:

I think this is awesome and should continue!

I've been poking at this API recently and have found quite a few improvements to make. I'm not quite ready to bring it to the two authors yet, but the code is being continually worked on!

#23 linuxpro

  • New Members
  • 3 posts

Posted 04 September 2012 - 06:40 AM

I have a program that i made to have my turtles go to a given pos but no logic for if it gets stuck.

I was hopping you could tell me what functions in your code handles this kind of events so I can get some ideas how to move the turtle to get unstuck.

thanks
linuxpro

#24 sneezing panda

  • New Members
  • 1 posts

Posted 04 September 2012 - 09:36 PM

Hi, I am getting "lua:1: attempt to index ? (a nil value)" when I run "mt.setPos(-61,63,1526)" Any idea why?

#25 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 05 September 2012 - 12:47 AM

Do you have the file saved as "mt", no file extension? Did you load the file as an API, or is it in the APIs folder?

#26 EatenAlive3

  • New Members
  • 53 posts

Posted 16 September 2012 - 03:52 PM

You have to use type it using the filename you specify, if you're using it as an API. If you're just running it, use setPos() instead of mt.setPos().

#27 Starwaster

  • New Members
  • 14 posts

Posted 29 September 2012 - 05:11 AM

The version function doesn't work; attempts to call it result in 'attempt to call nil'

The reason is that functions can't share the same name as any variables. (i.e. you can't have a function named version because you already have a variable by that name)

(yeah I know it's not a huge bug but I thought it might be worth knowing)

Oh, and hi all. Love the mod, API looks cool too.

#28 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 29 September 2012 - 11:00 PM

View PostStarwaster, on 29 September 2012 - 05:11 AM, said:

The version function doesn't work; attempts to call it result in 'attempt to call nil'

The reason is that functions can't share the same name as any variables. (i.e. you can't have a function named version because you already have a variable by that name)

(yeah I know it's not a huge bug but I thought it might be worth knowing)

Oh, and hi all. Love the mod, API looks cool too.
Well, the version variable is local, while the version function is global, so there should be no problem. Not sure why you get that error though.

#29 Starwaster

  • New Members
  • 14 posts

Posted 05 October 2012 - 09:16 AM

View PostMysticT, on 29 September 2012 - 11:00 PM, said:

View PostStarwaster, on 29 September 2012 - 05:11 AM, said:

The version function doesn't work; attempts to call it result in 'attempt to call nil'

The reason is that functions can't share the same name as any variables. (i.e. you can't have a function named version because you already have a variable by that name)

(yeah I know it's not a huge bug but I thought it might be worth knowing)

Oh, and hi all. Love the mod, API looks cool too.
Well, the version variable is local, while the version function is global, so there should be no problem. Not sure why you get that error though.

Doesn't matter whether it's global or local. It's a naming restriction. Names (or identifiers in lua) are used for the same purpose in variables OR functions. Once it's declared for something, you can't then turn around and reuse the name for something else.

Renaming the variable eliminates the issue. (which, understand, it's not a huge issue; I doubt anyone out there was depending on the version function for something critical, I only posted as an FYI to the OP and to anyone else who might come across this post)

#30 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 06 October 2012 - 01:09 AM

View PostStarwaster, on 05 October 2012 - 09:16 AM, said:

View PostMysticT, on 29 September 2012 - 11:00 PM, said:

View PostStarwaster, on 29 September 2012 - 05:11 AM, said:

The version function doesn't work; attempts to call it result in 'attempt to call nil'

The reason is that functions can't share the same name as any variables. (i.e. you can't have a function named version because you already have a variable by that name)

(yeah I know it's not a huge bug but I thought it might be worth knowing)

Oh, and hi all. Love the mod, API looks cool too.
Well, the version variable is local, while the version function is global, so there should be no problem. Not sure why you get that error though.

Doesn't matter whether it's global or local. It's a naming restriction. Names (or identifiers in lua) are used for the same purpose in variables OR functions. Once it's declared for something, you can't then turn around and reuse the name for something else.

Renaming the variable eliminates the issue. (which, understand, it's not a huge issue; I doubt anyone out there was depending on the version function for something critical, I only posted as an FYI to the OP and to anyone else who might come across this post)
Well, it turns out that the local variable was the problem, but not for what you said. You can have all the variables you want with the same name if they are in a different scope. The problem is that the version variable is defined and assigned a values, then it's overwrited with the function, but it's still local, so os.loadAPI can't "see" the function.
Anyway, not a big deal, it's just a version check that most people probably won't use :(/>

#31 ikon106

  • Members
  • 23 posts

Posted 09 October 2012 - 07:54 PM

Could you post a mirror? I don't want to use pastebin :P/>

#32 Pharap

  • Members
  • 816 posts
  • LocationEngland

Posted 13 October 2012 - 03:23 AM

View Postikon106, on 09 October 2012 - 07:54 PM, said:

Could you post a mirror? I don't want to use pastebin :)/>
what's wrong with pastebin?

#33 ChunLing

  • Members
  • 2,027 posts

Posted 13 October 2012 - 04:09 PM

I think that Homeland Security puts you on a watch list if you visit the site.

#34 Pharap

  • Members
  • 816 posts
  • LocationEngland

Posted 14 October 2012 - 07:43 PM

View PostChunLing, on 13 October 2012 - 04:09 PM, said:

I think that Homeland Security puts you on a watch list if you visit the site.
Then delete your cookies and use proxies.

#35 ChunLing

  • Members
  • 2,027 posts

Posted 15 October 2012 - 05:22 AM

Oh, but I'm already on the "Target of opportunity" (AKA "Kill if you have plausible deniability") list, so I'm not worried about the watch lists. I'm just positing a reason that ikon might want to avoid pastebin. Of course, having posted on the same forum as me already is a ticket onto the 'very special super secret' watch list. Fortunately, that one is also known as the "@#$% it, we can't even find a legal justification for killing this git, so there's no way we'll be able to commit resources to tracking every contact online" list. It's basically the same as getting taken off of all the other lists.

#36 Pharap

  • Members
  • 816 posts
  • LocationEngland

Posted 16 October 2012 - 12:06 AM

View PostChunLing, on 15 October 2012 - 05:22 AM, said:

Oh, but I'm already on the "Target of opportunity" (AKA "Kill if you have plausible deniability") list, so I'm not worried about the watch lists. I'm just positing a reason that ikon might want to avoid pastebin. Of course, having posted on the same forum as me already is a ticket onto the 'very special super secret' watch list. Fortunately, that one is also known as the "@#$% it, we can't even find a legal justification for killing this git, so there's no way we'll be able to commit resources to tracking every contact online" list. It's basically the same as getting taken off of all the other lists.
Take it from a Neurotic Introvert, you sound Paranoid.

#37 ChunLing

  • Members
  • 2,027 posts

Posted 16 October 2012 - 06:56 PM

If they've already tried to kill you, you officially can't be classified as paranoid. I talked that point over with a number of mental health professionals when they were trying to have me involuntarily committed for my "idiosyncratic" belief that the government should obey the law. See, fortunately for me, they hadn't expected me to be alive to do any talking, so they delivered my body to an actual hospital. Once they realized I was alive and going to stay that way, they managed to force the ICU to release me to the psychiatric ward...but they didn't have a plan for forcing the psychiatric ward to declare me insane. I guess they presumed it wouldn't be too hard, since generally those in a psychiatric ward are presumed insane until they can definitively prove otherwise.

The fact that nobody could deny that I had indeed been subjected to unjustified use of lethal force sorta worked in my favor, I guess. Though the lethal force itself is not something I'm ready to put in my 'fun times' column. It was actually most unpleasant.

#38 Starwaster

  • New Members
  • 14 posts

Posted 18 October 2012 - 11:22 PM

View PostMysticT, on 06 October 2012 - 01:09 AM, said:

View PostStarwaster, on 05 October 2012 - 09:16 AM, said:

View PostMysticT, on 29 September 2012 - 11:00 PM, said:

View PostStarwaster, on 29 September 2012 - 05:11 AM, said:

The version function doesn't work; attempts to call it result in 'attempt to call nil'

The reason is that functions can't share the same name as any variables. (i.e. you can't have a function named version because you already have a variable by that name)

(yeah I know it's not a huge bug but I thought it might be worth knowing)

Oh, and hi all. Love the mod, API looks cool too.
Well, the version variable is local, while the version function is global, so there should be no problem. Not sure why you get that error though.

Doesn't matter whether it's global or local. It's a naming restriction. Names (or identifiers in lua) are used for the same purpose in variables OR functions. Once it's declared for something, you can't then turn around and reuse the name for something else.

Renaming the variable eliminates the issue. (which, understand, it's not a huge issue; I doubt anyone out there was depending on the version function for something critical, I only posted as an FYI to the OP and to anyone else who might come across this post)
Well, it turns out that the local variable was the problem, but not for what you said. You can have all the variables you want with the same name if they are in a different scope. The problem is that the version variable is defined and assigned a values, then it's overwrited with the function, but it's still local, so os.loadAPI can't "see" the function.

Yes, ok, you can have variables with the same name in different scopes, but that's not relevant here because that's not what's happening.

Regarding the locality and its effect on the function, that doesn't happen when you don't reuse a name that you've used elsewhere. What do you think would happen if it WEREN'T local? You'd end up with a function that returns its own table entry instead of a value that had previously been assigned to that name as a variable. Same problem with different symptoms. I apologize if this comes across as argumentative because that's not my intent. Just trying to be helpful.

#39 ChunLing

  • Members
  • 2,027 posts

Posted 19 October 2012 - 01:43 AM

You can have a local identifier covering a global (or higher scope local) identifier, but if you're going to want to use that global identifier while it's covered then you're out of luck.

#40 EatenAlive3

  • New Members
  • 53 posts

Posted 23 October 2012 - 09:54 PM

Original post updated with example code by O.S.

Thanks for letting me use it!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users