Looping trough all region - Printable Version +- SphereCommunity (https://forum.spherecommunity.net) +-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d) +--- Forum: Script Help (/Forum-Script-Help) +--- Thread: Looping trough all region (/Thread-Looping-trough-all-region) Pages: 1 2 |
Looping trough all region - admin phoenix - 03-14-2013 07:43 PM 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 gr phoenix RE: Looping trough all region - Skul - 03-15-2013 09:20 PM 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> RE: Looping trough all region - admin phoenix - 03-17-2013 06:25 AM I made it so but it doesn´t work rightfull. Code: serv.newitem=i_gold 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 RE: Looping trough all region - Mordaunt - 03-17-2013 08:07 AM 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] 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 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. 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 RE: Looping trough all region - admin phoenix - 03-17-2013 05:40 PM mordaunt, you are my hero but this help isn´t documented in the revision text Will give a try RE: Looping trough all region - admin phoenix - 03-17-2013 08:50 PM 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] it rain far away from my sector/Region I wish RE: Looping trough all region - Ben - 03-17-2013 10:54 PM This would probably work better PHP Code: [FUNCTION make_weather] It's not tested but should do the trick. RE: Looping trough all region - admin phoenix - 03-18-2013 02:07 AM 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] 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> RE: Looping trough all region - Mordaunt - 03-18-2013 03:45 AM This works.. The locals were not being correctly defined before so it would never match. Code: [FUNCTION make_weather] RE: Looping trough all region - Ben - 03-18-2013 10:45 AM Well, here is a working version (been tested) PHP Code: [FUNCTION make_weather] 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) |