A Poor Man's Filter by Terrain
Moderator: Forum Moderators
A Poor Man's Filter by Terrain
Well, despairing of filtering by terrain being added to the game, I've come up with a poor man's terrain filter. Attached is the file bfw_filter_by_terrain.pl.
It is a perl script that returns a co-ordinate list that WML undertands and can be placed in a tag like [avoid].
How to use bfw_filter_by_terrain.pl
You must run the script from a command line (the terminal in OS X). The first argument is the name of the map that you want it to look at. The second argument is the letter of the terrain you want to filter by. For example:
will return the x and y co-ordinate of every encampment in the map snowfall.
Some cautions:
* The script must be in the same directory as the map.
* Both the file name and the terrain to filter by are case sensitive (in OS X anyway)
* It'd be nice if you could enter multiple terrain letters. This is my next project.
* There is no error checking whatsoever.
* The script produces an extra comma at the end of the list. I sort of know how to fix this, but I haven't gotten around to it, 'cause I'm too excited playing with it in Wesnoth.
This is my first shell script, so be gentle. It's a step in the right direction.
- b.
It is a perl script that returns a co-ordinate list that WML undertands and can be placed in a tag like [avoid].
How to use bfw_filter_by_terrain.pl
You must run the script from a command line (the terminal in OS X). The first argument is the name of the map that you want it to look at. The second argument is the letter of the terrain you want to filter by. For example:
Code: Select all
bfw_filter_by_terrain.pl Snowfall n
Some cautions:
* The script must be in the same directory as the map.
* Both the file name and the terrain to filter by are case sensitive (in OS X anyway)
* It'd be nice if you could enter multiple terrain letters. This is my next project.
* There is no error checking whatsoever.
* The script produces an extra comma at the end of the list. I sort of know how to fix this, but I haven't gotten around to it, 'cause I'm too excited playing with it in Wesnoth.
This is my first shell script, so be gentle. It's a step in the right direction.
- b.
- Attachments
-
- bfw_filter_by_terrain.pl.zip
- (504 Bytes) Downloaded 162 times
I have attached a C program based on your perl script (I don't know a lot of perl) that accepts multiple terrain letters. Hope this helps
P.S. If you need the output format to be different, let me know
EDIT: added output
P.S. If you need the output format to be different, let me know
EDIT: added output
Code: Select all
pravin@dominion:~/tmp $ ./a.out bitz4p ht
(05, 01)
(17, 01)
(18, 01)
(19, 01)
(03, 02)
(05, 02)
(07, 02)
(18, 02)
(01, 04)
(21, 04)
(01, 07)
(02, 07)
(17, 07)
(05, 08)
(06, 08)
(07, 08)
(16, 14)
(15, 15)
(21, 15)
(05, 16)
(13, 16)
(21, 16)
(20, 17)
(21, 17)
(01, 19)
(02, 20)
(04, 20)
(21, 20)
(03, 21)
(04, 21)
(13, 21)
(16, 21)
(17, 21)
- Attachments
-
- bfw_filter_by_terrain.zip
- Filter by terrain C program
- (916 Bytes) Downloaded 178 times
A warrior may die a thousand deaths,
An empire dies but one.
An empire dies but one.