The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Looping trough all region
Author Message
admin phoenix
Master
**

Posts: 354
Likes Given: 1
Likes Received: 23 in 13 posts
Joined: Mar 2012
Reputation: 3



Post: #1
Looping trough all region
is there a chance to loop trough all region you have in your map script
like

for x 0 <eval <serv.map.region>-1>
your function
endfor

or is there another way like storing the region defname in a sql database and check it via a sql function

I am at work so I can´t test my example Smile

gr

phoenix
03-14-2013 07:43 PM
Find all posts by this user Like Post Quote this message in a reply
Skul
Master
**

Posts: 413
Likes Given: 0
Likes Received: 19 in 15 posts
Joined: Jun 2012
Reputation: 9



Post: #2
RE: Looping trough all region
So you want to apply 'your function' to every region on a map. To what I can think of there is no 'easy' way of doing this, although you could always use an item/character to move around through some while loops, example:
Code:
local.p=<p>
for x 1 <eval <strarg <serv.map(1,1,<argn1>).region.p>> /32>
  for y 1 <eval <streat <strarg <serv.map(1,1,<argn1>).region.p>> /32>
    p=<eval <local.x> *32>,<eval <local.y> *32>,0,<argn1> //change your <p>
    region.'your function'
  endfor
endfor
p=<local.p>

"I ask a question to the answer I already know."

Marchadium :: http://www.marchadium.ca/ :: Join us!
03-15-2013 09:20 PM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
admin phoenix
Master
**

Posts: 354
Likes Given: 1
Likes Received: 23 in 13 posts
Joined: Mar 2012
Reputation: 3



Post: #3
RE: Looping trough all region
I made it so but it doesn´t work rightfull.

Code:
serv.newitem=i_gold
    local.y=1
    local.num=1
    FOR x 1 6173
     IF (<dlocal.y> < 65)
        new.p=<eval <local.num>*64>,<eval <local.y>*64>
         IF (STRMATCH(<new.region.defname>,a_athoria))
                 SERV.MAP.0.SECTOR.<dlocal.x> rain
                 serv.log Got it!!!
         ENDIF
        serv.log Region: <new.region.defname> Sector: <dlocal.x> P: <new.p>
      ELSE
          local.y=0
          local.num +=1
     ENDIF
    local.y +=1
    ENDFOR
        
        new.remove
I Loop through all sectors (I think so) and when I jump to the coordinates where I got the serv.log message "Got it" it doesn´t rain.
I think it´s not the right sector I got with local.x.
At first I loop downstairs (y coordinates) then jump I sector right.
I don´t know how the sectors are counted in which Position like
1,2,3,4 .....6144
65, 66,67.....4096


or
1, 65
2, 66
3, 67
4, 68
5, 69
.
.
.
4096,6144


I think it will be nice if we can read the sector number via
serv.map.(0).sector.number
so you can go ingame and type
.Show sector.number
(This post was last modified: 03-17-2013 06:40 AM by admin phoenix.)
03-17-2013 06:25 AM
Find all posts by this user Like Post Quote this message in a reply
Mordaunt
Super Moderator
****

Posts: 1,237
Likes Given: 26
Likes Received: 55 in 43 posts
Joined: Mar 2012
Reputation: 35



Post: #4
RE: Looping trough all region
You're overthinking it:

Code:
serv.map.<argn>.allsectors rain


Also you could loops through the sectors individually like this:
Code:
[function make_it_rain]
for 1 <serv.maplist.<argn>.sector.qty>
    serv.map.<argn>.sector.<local._for> rain
endfor
This will only work on a server build AFTER 20-02-2013 btw..
This is a feature I am taking personal credit for, not because I added it... but because I bugged the sh*t out of Ben to add it Big Grin

as for reading sectors, you can read the following:

Code:
MAPLIST.map_num.SECTOR.COLS     R     Returns the number of sector columns on a map.
MAPLIST.map_num.SECTOR.QTY     R     Returns the number of sectors on a map.
MAPLIST.map_num.SECTOR.ROWs     R     Returns the number of sector rows on a map.
MAPLIST.map_num.SECTOR.SIZE     R     Returns the size of the sectors on a map.

And with this information you can plot exactly where a sector is and should you wish affect entire rows/columns something I was working on prior to the hardcoded system being fixed

[Image: 2nis46r.jpg]
(This post was last modified: 03-17-2013 08:37 AM by Mordaunt.)
03-17-2013 08:07 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
admin phoenix
Master
**

Posts: 354
Likes Given: 1
Likes Received: 23 in 13 posts
Joined: Mar 2012
Reputation: 3



Post: #5
RE: Looping trough all region
mordaunt, you are my hero Smile
but this help isn´t documented in the revision text
Will give a try
03-17-2013 05:40 PM
Find all posts by this user Like Post Quote this message in a reply
admin phoenix
Master
**

Posts: 354
Likes Given: 1
Likes Received: 23 in 13 posts
Joined: Mar 2012
Reputation: 3



Post: #6
RE: Looping trough all region
still got the Problem that it will rain in another sector and not the sector with the Region defname I declare

PHP Code:
[FUNCTION make_weather]
    
local.map=<dargv[0]> // map, 0
    
local.region_defname=<argv[1]> // your region name you wish that it rain
    
local.weather=<argv[2]> // weather like rain, snow or try
    
serv.newitem=i_gold
    
 
FOR <serv.maplist.<dlocal.map>.sector.qty//
  
IF (<dlocal.y_> == 64)
    new.
p=<eval 32+(64*<local.x_>)>,<eval 32+(64*<local.y_>)>
   IF (
STRMATCH("<local.region_defname>*","<new.region.defname>"))
       
SERV.MAP.<dlocal.map>.SECTOR.<dlocal._for> <local.weather>
   ENDIF
      
local.y_=0
      local
.x_ +=1
   
ELSE
    new.
p=<eval 32+(64*<local.x_>)>,<eval 32+(64*<local.y_>)>
   IF (
STRMATCH("<local.region_defname>*","<new.region.defname>"))
       
SERV.MAP.<dlocal.map>.SECTOR.<dlocal._for> <local.weather>
   ENDIF
    
local.y_ +=1    
  
ENDIF
  ENDFOR
     new.
remove 

it rain far away from my sector/Region I wish
(This post was last modified: 03-17-2013 08:50 PM by admin phoenix.)
03-17-2013 08:50 PM
Find all posts by this user Like Post Quote this message in a reply
Ben
Sphere Developer
*****

Posts: 612
Likes Given: 2
Likes Received: 123 in 70 posts
Joined: Mar 2010
Reputation: 18

SphereCommunity

Post: #7
RE: Looping trough all region
This would probably work better

PHP Code:
[FUNCTION make_weather]
    
local.map=<dargv[0]> // map, 0
    
local.region_defname=<argv[1]> // your region name you wish that it rain
    
local.weather=<argv[2]> // weather like rain, snow or try
    
local.size=<serv.maplist.<dlocal.map>.sector.size>

    
FOR 
<serv.maplist.<dlocal.map>.sector.qty>
  
    
local.secx = (<local.size>/2) + ((<local._for> / <serv.maplist.<dlocal.map>.sector.rows>) * <local.size>)
    
local.secy = (<local.size>/2) + ((<local._for> / <serv.maplist.<dlocal.map>.sector.cols>) * <local.size>)
    
local.secregion = <SERV.MAP(<dlocal.secx>,<dlocal.secy>,<dlocal.map>).region.defname>

    IF (
STRMATCH("<local.region_defname>*","<local.secregion>"))
       
SERV.MAP.<dlocal.map>.SECTOR.<dlocal._for> <local.weather>
    ENDIF
ENDFOR 

It's not tested but should do the trick.

AxisII's current version: 2.0.4j
AxisII SourceCode on Github
AxisII up to date changelog
03-17-2013 10:54 PM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
admin phoenix
Master
**

Posts: 354
Likes Given: 1
Likes Received: 23 in 13 posts
Joined: Mar 2012
Reputation: 3



Post: #8
RE: Looping trough all region
Thanks Ben. I think it´s the right way but it doesn´t work rightfull.
I put two serv.logs inside the code. The first one Shows me th coordination. the second one should appears when the Region ist found. but nothing but an error.
PHP Code:
[FUNCTION make_weather]
    
local.map=<dargv[0]> // map, 0
    
local.region_defname=<argv[1]> // your region name you wish that it rain
    
local.weather=<argv[2]> // weather like rain, snow or try
    
local.size=<serv.maplist.<dlocal.map>.sector.size>
        
FOR 
<eval <serv.maplist.<dlocal.map>.sector.qty>-1//<-- fixed the last bug in my error code with <SERV.MAP(6176>
  
    
local.secx = (<local.size>/2) + ((<local._for> / <serv.maplist.<dlocal.map>.sector.rows>) * <local.size>)
    
local.secy = (<local.size>/2) + ((<local._for> / <serv.maplist.<dlocal.map>.sector.cols>) * <local.size>)
    
serv.log Loc: <dlocal.secx>,<dlocal.secy>
    
    
local.secregion = <SERV.MAP(<dlocal.secx>,<dlocal.secy>,<dlocal.map>).region.defname>

    IF (
STRMATCH("<local.region_defname>*","<local.secregion>"))
       
SERV.MAP.<dlocal.map>.SECTOR.<dlocal._for> <local.weather>
       
serv.log Find the Region.
    ENDIF
ENDFOR 
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 32,32
17:03:(sphere_gm_commands.scp,6872)Loc: 96,32
17:03:(sphere_gm_commands.scp,6872)Loc: 96,32
17:03:(sphere_gm_commands.scp,6872)Loc: 96,32
17:03:(sphere_gm_commands.scp,6872)Loc: 96,32
17:03:ERROR:(sphere_gm_commands.scp,6874)Can't resolve <SERV.MAP(6176>
(This post was last modified: 03-18-2013 02:08 AM by admin phoenix.)
03-18-2013 02:07 AM
Find all posts by this user Like Post Quote this message in a reply
Mordaunt
Super Moderator
****

Posts: 1,237
Likes Given: 26
Likes Received: 55 in 43 posts
Joined: Mar 2012
Reputation: 35



Post: #9
RE: Looping trough all region
This works..
The locals were not being correctly defined before so it would never match.

Code:
[FUNCTION make_weather]
    local.map=<dargv[0]> // map, 0
    local.region_defname=<strarg <streat <args>>> // your region name you wish that it rain
    local.weather=<streat <streat <args>>> // weather like rain, snow or try
    local.size=<serv.maplist.<dlocal.map>.sector.size>
        
FOR 1 <eval <serv.maplist.<dlocal.map>.sector.qty>-1> //<-- fixed the last bug in my error code with <SERV.MAP(6176>
  
    local.secx = (<local.size>/2) + ((<local._for> / <serv.maplist.<dlocal.map>.sector.rows>) * <local.size>)
    local.secy = (<local.size>/2) + ((<local._for> / <serv.maplist.<dlocal.map>.sector.cols>) * <local.size>)
    serv.log Loc: <dlocal.secx>,<dlocal.secy>
    
    local.secregion = <SERV.MAP(<dlocal.secx>,<dlocal.secy>,<dlocal.map>).region.defname>

    IF (strmatch(*<local.region_defname>*,<local.secregion>))
       SERV.MAP.<dlocal.map>.SECTOR.<dlocal._for> <local.weather>
       serv.b Find the Region. <local.secregion>
    ENDIF
ENDFOR

[Image: 2nis46r.jpg]
(This post was last modified: 03-18-2013 03:48 AM by Mordaunt.)
03-18-2013 03:45 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Ben
Sphere Developer
*****

Posts: 612
Likes Given: 2
Likes Received: 123 in 70 posts
Joined: Mar 2010
Reputation: 18

SphereCommunity

Post: #10
RE: Looping trough all region
Well, here is a working version (been tested)

PHP Code:
[FUNCTION make_weather]
    
local.map=<dargv[0]> // map, 0
    
local.region_defname=<argv[1]> // your region name you wish that it rain
    
local.weather=<argv[2]> // weather like rain, snow or try
    
local.size=<serv.maplist.<dlocal.map>.sector.size>

    
FOR 
<eval <serv.maplist.<dlocal.map>.sector.qty>-1>
  
    
local.secx = (<local.size>/2) + ((<local._for> % <serv.maplist.<dlocal.map>.sector.cols>) * <local.size>)
    
local.secy = (<local.size>/2) + ((<local._for> / <serv.maplist.<dlocal.map>.sector.cols>) * <local.size>)
    
local.secregion = <SERV.MAP(<dlocal.secx>,<dlocal.secy>,<dlocal.map>).region.defname>

    IF (
STRMATCH("<local.region_defname>*","<local.secregion>"))
        
SERV.MAP.<dlocal.map>.SECTOR.<eval <local._for>+1> <local.weather>
    ENDIF
ENDFOR 

The problem was the location was not calculated properly

Now I do see potential issues with this... if a region is very small, it could be skiped over since it's only testing every sector.size tiles (64 in this case)

AxisII's current version: 2.0.4j
AxisII SourceCode on Github
AxisII up to date changelog
(This post was last modified: 03-18-2013 10:50 AM by Ben.)
03-18-2013 10:45 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)