To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.spyboticsOpen lugnet.robotics.spybotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Spybotics / 91
90  |  92
Subject: 
Re: target programming
Newsgroups: 
lugnet.robotics.spybotics
Date: 
Thu, 5 Sep 2002 22:20:24 GMT
Viewed: 
5435 times
  
In lugnet.robotics.spybotics, André Koopman writes:
Hello all,
I like to write a program in NQC or ScriptEd wich determine the distance
between the spybot and the controller. Does anybody already figured out wich
syntax to use in order to solve this problem. I had a look in the SDK and de
spybot.h files but until now I didn't find a way to do this.

First, let me just mention that there is no good reason at all to use
ScriptEd for writing programs.  BricxCC seems to be a far better choice in
that regard since it supports both NQC and MindScript (and LASM as well).

What do you mean by distance, exactly.  You can certainly tell what zone the
controller is in (here, there, anywhere, or nowhere).

Below is a MindScript program which writes the range of each controller it
finds to variables 1-7.  If it finds any controllers in the here, there, or
anywhere zone it also makes a heartbeat sound.  I don't think you can use
NQC to do this yet.

Look at the Count*.h files that come with the Spybot software for examples
(which is where I got the information I needed to write this simple program).

program TestRCX2 {
  #include "Spybot.h"

  sub ControllerRangeAndDirection
  {
    local nIndex
    local nRange = cNowhere
    local n = cNoID+1

    // reset variables 1-7 to cNowhere and zero variables 8-14
    while n < cPCID
    {
      n^ = cNowhere
      n += 7
      n^= 0
      n -= 6
    }

    find world[nIndex,iRange] > cNowhere
    {
      n = world[nIndex,iShortID]
      if n > cNoID
      {
        if n < cPCID
        {
          // nIndex is a controller
          // write range to global variable numbered by controller ID
          n^ = world[nIndex,iRange]
          n += 7
          n^ = world[nIndex,iDirection]
          tone 36 for 5 wait 10 tone 36 for 5
        }
      }
    }
  }

  main {
    ControllerRangeAndDirection
  }
}

I've tested this via BricxCC and the Watch window.  As expected, my
controller showed up in the here, there, anywhere, and nowhere ranges
depending on where I positioned it.  The direction also worked exactly as
anticipated (and documented in spybot.h).

Hope this helps.

John Hansen



Message is in Reply To:
  target programming
 
Hello all, I like to write a program in NQC or ScriptEd wich determine the distance between the spybot and the controller. Does anybody already figured out wich syntax to use in order to solve this problem. I had a look in the SDK and de spybot.h (...) (22 years ago, 5-Sep-02, to lugnet.robotics.spybotics)

2 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR