LOOP code help

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

rnbby
V.I.P.
Posts: 98
Joined: December 4th, 2007, 10:24 am

LOOP code help

Post by rnbby »

I'm just starting with this.

anyone can help show me a code that loops thru all objects in the map?

What i'm trying to do is. Find all location of heroes. Also Find all location of WARDS/SENTRY.

anyone? please thanks.

Edit:
Why am I transferred here?

btw, I forgot to note that I'm looking for a JASS code.

Thanks
Last edited by GeorgeMots on December 8th, 2007, 6:47 pm, edited 1 time in total.
Reason: posts merged
auto-collider for wc3 1.22-- @ http://iliganshack.blogspot.com
GeorgeMots
Crusader
Posts: 4236
Joined: January 27th, 2007, 4:46 pm
Location: Greece, Veria

Re: LOOP code help

Post by GeorgeMots »

Your post was moved here because it wasnt a map cheating/deprotection request.

And remember dont double post, use the Image button at the lower right corner of ur posts.
http://slowbro.org/
`·.,¸,.·*¯`·.,¸,.·*¯[;::;(。◕‿‿­­​­­­­­◕。)
Image
Image
Image
Spoiler:
(03:36:55) xkiska: im too much of a dumbass to understand this
User avatar
Bartimaeus
Tyrannical Drama Queen
Posts: 4445
Joined: November 19th, 2007, 5:05 am
Been thanked: 2 times

Re: LOOP code help

Post by Bartimaeus »

rnbby wrote:I'm just starting with this.

anyone can help show me a code that loops thru all objects in the map?

What i'm trying to do is. Find all location of heroes. Also Find all location of WARDS/SENTRY.

anyone? please thanks.

Edit:
Why am I transferred here?

btw, I forgot to note that I'm looking for a JASS code.

Thanks
Well, you were suppose to get transfered to the JASS Section, but you didn't clearly state that you were looking for a JASS Code instead of a GUI, so my guess is that George kind of leaned toward GUI, since it's more common. And I'm, or perhaps anyone else, are\is not sure what you mean by "finding" the location of heroes and wards/sentries.
Sir-Tanks
Forum Spammer
Posts: 635
Joined: May 29th, 2007, 9:02 am
Title: Strange old man
Location: London, England

Re: LOOP code help

Post by Sir-Tanks »

I think your looking alittle to much into that :D
Sir-Tanks is BACK and working on his new map Acts of War!
Take the best Stupidity test here
rnbby
V.I.P.
Posts: 98
Joined: December 4th, 2007, 10:24 am

Re: LOOP code help

Post by rnbby »

So what function do I need to use?

I try looking at the native functions. I can't get location of a player unit. also looking forward to get a location of a certain item in a map. Is a ward an item or an object? i'm pretty confused.
auto-collider for wc3 1.22-- @ http://iliganshack.blogspot.com
User avatar
Xantan
Honorary wc3edit.net Traitor
Posts: 2507
Joined: February 1st, 2007, 4:11 pm
Location: NEVADA

Re: LOOP code help

Post by Xantan »

rnbby wrote:So what function do I need to use?

I try looking at the native functions. I can't get location of a player unit. also looking forward to get a location of a certain item in a map. Is a ward an item or an object? i'm pretty confused.
depends if its placed or not, if its placed, its a unit.
rnbby
V.I.P.
Posts: 98
Joined: December 4th, 2007, 10:24 am

Re: LOOP code help

Post by rnbby »

The item is placed.

So it's a unit right?

Thanks.
auto-collider for wc3 1.22-- @ http://iliganshack.blogspot.com
HINDYhat
Senior Member
Posts: 101
Joined: June 1st, 2007, 9:05 pm

Re: LOOP code help

Post by HINDYhat »

Since when is an item a unit? All items are widgets. All units are widgets. All widgets are handles. Therefore units are NOT items.

For the items, you can use:

Code: Select all

function True takes nothing returns boolean
    return true
endfunction

function SomeFunction takes nothing returns nothing
    call EnumItemsInRect(bj_mapInitialPlayableArea,Filter(function True),function yourActionFunc)
endfunction
As for the units, you'd need to use groups:

Code: Select all

function SomeFunction takes nothing returns nothing
    local group g=CreateGroup()
    call GroupEnumUnitsInRect(g,bj_mapInitialPlayableArea,Filter(function True))
    call ForGroup(g,function yourActionFunc)
    call DestroyGroup(g)
    set g=null
endfunction
rnbby
V.I.P.
Posts: 98
Joined: December 4th, 2007, 10:24 am

Re: LOOP code help

Post by rnbby »

Thanks for the code snippet. I'm gonna mess around this.
auto-collider for wc3 1.22-- @ http://iliganshack.blogspot.com
User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Re: LOOP code help

Post by Aero »

HINDYhat wrote:Since when is an item a unit? All items are widgets. All units are widgets. All widgets are handles. Therefore units are NOT items.

For the items, you can use:

Code: Select all

function yourActionFunc takes nothing returns nothing
     //Do stuff
endfunction

function SomeFunction takes nothing returns nothing
    call EnumItemsInRect(bj_mapInitialPlayableArea,null,function yourActionFunc)
endfunction
As for the units, you'd need to use groups:

Code: Select all

function SomeFunction takes nothing returns nothing
    local group g=CreateGroup()
    call GroupEnumUnitsInRect(g,bj_mapInitialPlayableArea,null)
    call ForGroup(g,function yourActionFunc)
    call DestroyGroup(g)
    set g=null
endfunction
Just use null as a filter if there's no condition or anything.