Does the command GetAllUnitsInRange push a list?

Started by Nicant, December 14, 2016, 08:39:46 PM

Previous topic - Next topic

Nicant

I have run into another problem while making my custom module. This time it has to do with the GetAllUnitsInRange Command.

The code below shows that the script is finding all units, but the command only seems to find the PRPLCORE and nothing else. I put my ship next to a stunner, and it does not trigger the trigger. (Tongue twister right there :P ) I think it pushes a list of all of the units it finds, but im not sure since the wiki page for it does not say that yet.

So if anyone knows, or can help in any way please do! Any help will be appriciated! :)


Currentx CurrentY 1 35 GetAllUnitsInRange ->Target
<-Target GetUnitType ->IsStunner
"Stunner" <-IsStunner neq if
0 0 add ->Trigger
else
0 1 add ->Trigger
<-Target GetUnitCoords ->ux ->uy
<-uy <-y sub <-ux <-x sub atan2 ->targetAngle
<-targetAngle <-main ShortestAngle ->dist
<-dist abs 0.08 lt if
<-targetAngle ->main
self "main" <-main SetImageRotation
CW4 hype!!

Sorrontis

I would assume it's similar to GetAllShipsInRange and that pushes a list.
"If you want others to be happy, practice compassion. If you want to be happy, practice compassion."

Relli

All I can say is what I know of the CRPL counterpart. If it's different in PRPL, then this will likely be entirely incorrect. The CRPL version sends back two types of things: the unit IDs of everything it finds, one by one (not in a list, just plunked straight down onto the stack), and then the total number of things it found. Common practice is to pop the number off first in order to make a loop that knows exactly how many times to loop before it runs out of UIDs to work with.

Oblivion

It pushes a list.
Also, if Im not mistaken it looks like your command has a range of 1 and a true/false value of 35 for whether to make the area square or a circle. That might be the problem.
~Memes have been scientifrically proven to be the very essence of life unto itself~

Relli

Quote from: Oblivion on December 14, 2016, 09:58:38 PM
It pushes a list.
Also, if Im not mistaken it looks like your command has a range of 1 and a true/false value of 35 for whether to make the area square or a circle. That might be the problem.
The funny thing is, you could leave the 35 alone and just fix the 1 and it would still work as intended. But probably best you change it back to 1 or TRUE. Readability and all.

GoodMorning

Yes, it's a list. When I get to the wiki, this will be one of the first things I look at.

Speaking of which, the wiki is ready to be built as fast as anyone is willing...
A narrative is a lightly-marked path to another reality.

Oblivion

the wiki is ready to be built as fast as anyone (with capability to alter the wiki) is willing*
~Memes have been scientifrically proven to be the very essence of life unto itself~

GoodMorning

The wiki can be edited by anyone with a forum login, using the same un/pw combination. No changes can be made until logged in.
A narrative is a lightly-marked path to another reality.

Nicant

Quote from: Oblivion on December 14, 2016, 09:58:38 PM
It pushes a list.
Also, if Im not mistaken it looks like your command has a range of 1 and a true/false value of 35 for whether to make the area square or a circle. That might be the problem.

Ok, i will try swapping the notation and also thanks everyone for telling me its a list! ;D
CW4 hype!!

GoodMorning

A narrative is a lightly-marked path to another reality.

Nicant

#10
Quote from: GoodMorning on December 15, 2016, 05:57:35 PM
Good news: This wiki page is done, see here.

Nice! Thanks for updating it! :)

Edit: Well, yet again i've run into another problem. :P  So now i've updated my code to work with the list that the GetAllUnitsInRange pushes. The only thing is that it does not work. Here's the code, is there anything wrong with it or is it fine the way it is and i just need to find the problem elsewhere in the code. (This is kind of my first time working with lists myself) Again, any help will be much appreciated!:)

Edit2: oh sorry silly me forgot to attach the code. :P

CurrentX CurrentY 35 0 GetAllUnitsInRange ->Targets
<-Targets "Stunner" GetListElement ->IsStunner
<-IsStunner "Stunner" neq if
0 0 add ->Trigger
else
0 1 add ->Trigger
<-Target GetUnitCoords ->ux ->uy
<-uy <-y sub <-ux <-x sub atan2 ->targetAngle
<-targetAngle <-main ShortestAngle ->dist
<-dist abs 0.08 lt if
<-targetAngle ->main
self "main" <-main SetImageRotation
endif
endif
endif
CW4 hype!!

GoodMorning

#11
It isn't attached?

Edit: Ouch, ouch, ouch. Fixed below, but...
A narrative is a lightly-marked path to another reality.

Oblivion

#12

CurrentX CurrentY 35 0 GetAllUnitsInRange ->Targets
<-Targets.listcount 0 do
     <-Targets[I] ->TargetX
     <-TargetX GetUnitType ->TargetType
     <-TargetType "Stunner" eq if
                 #Insert If It is Stunner here code
     endif
loop


Should find the Stunner now, should. Never know till you test it. (Its gonna backfire somehow it always has on me)

EDIT: Looking at your code again you don't seem to be looking for stunners, just everything else besides them? if so change to neq and should be fine
~Memes have been scientifrically proven to be the very essence of life unto itself~

Nicant

Quote from: Oblivion on December 15, 2016, 08:27:03 PM

CurrentX CurrentY 35 0 GetAllUnitsInRange ->Targets
<-Targets.listcount 0 do
     <-Targets[I] ->TargetX
     <-TargetX GetUnitType ->TargetType
     <-TargetType "Stunner" eq if
                 #Insert If It is Stunner here code
     endif
loop


Should find the Stunner now, should. Never know till you test it. (Its gonna backfire somehow it always has on me)

EDIT: Looking at your code again you don't seem to be looking for stunners, just everything else besides them? if so change to neq and should be fine

Ok thanks i will try this!  ;D
CW4 hype!!