HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Need JASS HELP: set udg_Region[A]=gg_rct_I2S(A)

05-20-2006, 02:50 PM#1
MasterofSickness
In my map, I set regions to a region array in Initialisations.
Example:
Collapse JASS:
set udg_RegionArray[1] = gg_rct_1

All I want is:
Define the different regions
(which are named: "1", "2", ...)
to an array variable, BUT not through simply writing every single line,
but through a loop in where you have a local integer A:
Collapse JASS:
set udg_RegionArray[A] = gg_rct_1

But then, as you can see, I have the problem that I can't change the rct to
Collapse JASS:
gg_rct_A

As far as I read you can work arround this problem with the "Local Handle Variables", but I heared that this system leak performance:
Quote:
that I2S ( H2 I ( ) ) is calculated everytime you Set/Get a handle and that's lame. see what vexorian did with tables. the conersion is done only once and that's preety good. personally i have stopped using the handle vars because of this, and now i use the Caster System since the tables are embeeded there. also i use it since it has some nice casting funcitons.Blade also uses caster system now

So, what about the CasterSystem from Vexorian?
I have read also a bit there and I decided to use this Caster System with Free Attach Variables / Sets and Tables (from 12.7)
(Link: http://www.wc3jass.com/viewtopic.php...r=asc&start=15)

So far so good, but now I really need help!
What exactly do I have to do when I want to set regions through a loop?
Which lines of code from the CSCache do I have to paste in WE triggers and how do I make this loop work?
A detailed example would be very good.
I give you Rep, as far as I can.
This problem is really important for me to be solved...
05-20-2006, 03:25 PM#2
Vexorian
keep doing stuff manually. Handle variables will require you to do things manually as well.

The most automated way is to generate the rects with pure JASS instead of World Editor, but that's a chimaera. Really


Sometimes you need your patience.

Well you can get some program that allows macros and let it do it for yourself

Collapse JASS:
set udg_RegionArray[1] = gg_rct_1
set udg_RegionArray[2] = gg_rct_2
...
set udg_RegionArray[2000] = gg_rct_2000

I am the kind of guy that would take Delphi and do this in seconds. I think that many programs out there like advanced text editors should have a way to do this for you.
05-20-2006, 03:43 PM#3
The)TideHunter(
Im not sure if this would work, because H2S dosent work as well as H2I, anyways il give it a try.

Collapse JASS:
function H2S takes handle h returns string
    return h
    return null
endfunction

function S2Region takes string s returns rect
    return s
    return null
endfunction

function SetYourRegions takes nothing returns nothing
    local integer LoopNumber = 1
    local rect FirstRegion = 'YourFirstRect'
    local rect LastRegion
    local string CurrentRegion
    loop
        exitwhen (LoopNumber == 'YourMaxiumNumberOfRegions')
        if(LoopNumber == 1) then
            set LastRegion = FirstRegion
        endif
        set CurrentRegion = H2S(LastRegion)
        set CurrentRegion = Substring(CurrentRegion, 7, StringLength(CurrentRegion))
        set 'udg_YourRegion[LoopNumber]' = S2Region("gg_rct_" + I2S((S2I((CurrentRegion) + 1))))
        set LoopNumber = LoopNumber + 1
    endloop
    set FirstRegion = null
    set LastRegion = null
endfunction

This will probaly not work, but has the right idea.
Sorry, this post was probally completly useless.
I would stick to vexs method, i would do it myself, takes a while but makes life easier in the long run...
05-20-2006, 03:43 PM#4
Vexorian
type casts involving string will cause you a terrible crash
05-20-2006, 03:47 PM#5
The)TideHunter(
Damnit!
Sorry for making this post and the above post then. False infomation
05-20-2006, 03:51 PM#6
MasterofSickness
It is not only because of having much work to declare every region.
(If you don't use any programm that writes the text for you [by the way good idea!])
The longer the trigger is, the more laggy it will get or?
I mean isn't there a difference between just having a few lines through loop and CSCache declaring everything or hundreds of lines declaring a single region everytime?

EDIT:
Haven't read the posts before, because I posted same time, so have to read first...
EDIT (after read above posts):
1) So, there is no way in using a working code for looping through regions declaring them?
2) And still please answer to question in this post
05-20-2006, 03:56 PM#7
Vexorian
Gamecache is slower than arrays.

The longer a trigger is the more laggy it will, yes.

But it seems you are going to make it so in map initialization?

Also if you made a loop it would be thrice as large considering the exitwhen and the incrementing of the variable
05-20-2006, 04:01 PM#8
MasterofSickness
Quote:
The longer a trigger is the more laggy it will, yes.

But it seems you are going to make it so in map initialization?

Yes, I run the region declarations at map initialisations and remove the trigger afterwards.
So you mean when you use a trigger for just one time it doesn't matter if it is very long?
05-20-2006, 04:03 PM#9
Vexorian
It will affect your map's loading time but not LAG in game (unless you have a lot of leaks there)
05-20-2006, 04:07 PM#10
MasterofSickness
Ok, so then I will go on making my region declarations manually.
Thanks for clearing that up!

EDIT:
Thanks for the idea with creating the regions declaration with a text programm.
It took me a while, but it finally works with Word 2002.
It's cool, fast and wow, it really helps!
05-22-2006, 12:38 PM#11
Thunder_Eye
Isnt there a way to change the rect to a string? With the return bug maybe? If so you could name all the regions like
rect1
rect2
...
rect8

Then do a loop and make it
set udg_RegionArray[loopA] = "gg_rct_" + I2S(loopA)
maybe?
05-22-2006, 12:58 PM#12
The)TideHunter(
Thats exactly what i did above, it would run in a loop, but as vex said, handle to string would result in a juicy fatal error.
So no, you cant unfortunatly convert a region to string