Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

Archived

This topic is now archived and is closed to further replies.

  • 0
Belial

Detect Delay

Question

Can I delay robot.detect()? At the moment, my robot trying to detect a block in front of it, but as I understand, it does this before it moves. So it detects nothing, this causes bug. Is there any way to delay detecting so it can detect after it moves?

Here is code btw:
https://hastebin.com/itevasanij.lua

Thanks in advance.

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

7 hours ago, Molinko said:

robot.detect is synchronous. meaning it is executed in the order you call() it. Your code prob just has a bug.

I believe it is, but strangely it doesn't work like that. I might made a mistake, but at the moment I can't see it.  Can you configure and check it?

wT0IEhy.png

hNxurFr.png

This is an example configuration. It moves forward when below block is same with the 1st slot, moves right when it is same with the 2nd. Normally it shouldn't move when it detects any block in front. But strangely, it doesn't see the block then moves to the right. That's why I thought it happens before moving is complete. It might be synchronous, but I'm not sure about does it wait for the movement to finish.

EDIT

Okay, I got it fixed. I break the loop after checking the block below, so it doesn't overlap anymore. Thanks!

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.