Jump to content




map reading


  • You cannot reply to this topic
5 replies to this topic

#1 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 28 June 2014 - 04:21 PM

So, I'm creating a wonderful api that allows the user to create a multiline string which will be turned into a series of commands for a turtle. However, my file is currently erroring when I test it.

Edit: stupid me. Forgot that naming my table table will mess things up. Fixing...

mapreader
test code

Edited by KingofGamesYami, 28 June 2014 - 08:56 PM.


#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 28 June 2014 - 07:37 PM

New error! test:9:attempt to call table. I thought that __call would allow me to call the table as a function, but it isn't. Any ideas as to why?

PS: Updated OP with new code

#3 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 28 June 2014 - 07:50 PM

__call is meant to be used as a metatable entry, not a table entry.

#4 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 28 June 2014 - 08:41 PM

...so I need to use setmetatable() at some point? I've seen examples on the internet that do not use it at all, so I didn't think I needed to.
Yep, that fixed it... now:

For some reason it always returns true. I checked this by adding
handle = mapreader.path( map, true ) --#also tried false
print( handle() )
However, the turtle never moves or turns. (Yes, it does have fuel)

PS: updated OP with latest code.

Edited by KingofGamesYami, 28 June 2014 - 08:56 PM.


#5 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 28 June 2014 - 09:11 PM

You will need to learn more about coroutines. The turtle functions all yield internally, so using coroutine.resume once and returning the result will simply tell you that you successfully resumed the coroutine once. You'll need to create an actual coroutine manager, and pass along the turtle movement events, etc.

#6 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 28 June 2014 - 09:39 PM

ah, I did not know the turtle functions yielded. I'll have to look into that a bit more.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users