light source finder

Help section from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

macrolover
a ghoul
a ghoul
Posts: 107
Joined: Sun Jul 14, 2002 9:19 am

light source finder

Post by macrolover » Wed Jan 01, 2003 12:37 am

can anyone see what is wrong with this script it locks up and crashes to desktop. what this code should do is when passed a spawn name and type of lightsource should look for the specific spawn and light source. ie called by /macro lightsourcefinder "willowisp" "gls"

Code: Select all

#turbo

Sub Main
   /if "$p0"=="" {
      /echo Usage: /macro light <spawn name> <light source>
  /if "$p2"=="" {
     /echo usage: /macro light <spawn name> <light source>    /return
   }
   /varset l0 $id(0)
   /varset l1 0
   /echo Searching for $p0's with $p2's:
   /echo --------------------------------------------
   :Loop
      /if "$spawn($l0,name)"!~"$p0" /goto :Next
      /if "$spawn($l0,light)"!~"$p2" /goto :Next
      
      /echo [$l0] $spawn($l0,name,clean): $spawn($l0,light) -- range $spawn($l0,distance)
      /varadd l1 1
      :Next
      /varset l0 $spawn($l0,next)
   /if $l0>0 /goto :Loop
   /echo $int($l1) spawn$if(n,$l1==1,"","s") found.
/return

Malachi
a hill giant
a hill giant
Posts: 227
Joined: Tue Nov 19, 2002 1:29 am
Contact:

try...

Post by Malachi » Wed Jan 01, 2003 1:50 am

You might try this:

if you are typing this: /macro lightsourcefinder "willowisp"

try typing this: /macro lightsourcefinder willowisp

Or vice versa.
Just a suggestion.

Oh, yeah, and rename that .mac, lol, too easy to get typos. :)

I didn't really look @ the code, sooooooooooo I dunnoz.

~malachi
~Oh danny boy, the pipes the pipes are calling.~

macrolover
a ghoul
a ghoul
Posts: 107
Joined: Sun Jul 14, 2002 9:19 am

lol

Post by macrolover » Wed Jan 01, 2003 3:26 am

either way it locks up and crashes to desktop as soon as started

Ariain
a ghoul
a ghoul
Posts: 88
Joined: Fri Oct 11, 2002 10:35 am

..

Post by Ariain » Wed Jan 01, 2003 12:19 pm

What is p2? shouldnt it be p1?

macrolover
a ghoul
a ghoul
Posts: 107
Joined: Sun Jul 14, 2002 9:19 am

usage

Post by macrolover » Thu Jan 02, 2003 3:01 am

p1 is the spawn you are looking for p2 is the type of light source you are looking for. this was modified from light.mac that is in the mq distrubution