Difference between revisions of "ShroudDataWML"

From The Battle for Wesnoth Wiki
 
(Renamed fog section and upped it a level)
(6 intermediate revisions by 4 users not shown)
Line 7: Line 7:
 
* the wesnoth map editor
 
* the wesnoth map editor
 
* your favorite text editor (with a search & replace function)
 
* your favorite text editor (with a search & replace function)
 +
* a spreadsheet like Microsoft Excel or Libreoffice Calc
  
 
== Making your map ==
 
== Making your map ==
First of all you will need a map. This can be made in the wesnoth map editor (see [[WesnothMapEditor]] and [[BuildingMaps]] for more information)
+
First of all you will need a map. This can be made in the wesnoth map editor (see [[BuildingMaps]] for more information)
 
Once you've got that, make a copy. If you like to, you can renaim this copy to eg MapName_Shroud to indicate this file will contain the shroud data.
 
Once you've got that, make a copy. If you like to, you can renaim this copy to eg MapName_Shroud to indicate this file will contain the shroud data.
  
Line 17: Line 18:
 
Now fill your selection with one terrain type, and then select all the other tiles and fill it with another type.
 
Now fill your selection with one terrain type, and then select all the other tiles and fill it with another type.
  
After all that is finished you have to flip the map. (I don't know about the editors before v1.3.3), you can do this by pressing alt+ctrl+f or by selecting the menu Edit->Flip Map. Do this twice, both for the x and y axis.
+
Once that's done, you can save again and quit the editor.
  
Once that's done, you can save again and quit the editor.
+
Import the file in your spreadsheet (in Openoffice.org: Insert->Sheet From File) and select the comma as seperator. You should see an example of what it will look like, if each lettercombination has it's own cell, then things are good.
 +
Select all of the cells and press ctrl+x (Edit->Cut). Then select the top left most cell on the sheet and right click in it. Select 'Paste special'. A dialog window appears. There should be a checkbox name 'transpose', check it.
 +
Now you've switched the rows and columns in the map. Select all of your cells again and press ctrl+c (Edit->Copy).
 +
Open your favorite text editor and press ctrl+v in a new file. Save this file over your MapName_Shroud file.
  
 
== Rewriting the data of the map ==
 
== Rewriting the data of the map ==
Open MapName_Shroud in your text editor. Now you'll see a comma seperated text table containing the map data. You should see only two letter combinations are present, one for the shrouded part and one without. Use search and replace to search for the 'unshroud' letter combination (include leading and trailing spaces) and replace it with a '1' (without quotes). Then do the same for the 'shroud' combination and replace it with a '0'.
+
(Open MapName_Shroud in your text editor if you closed it)
Make sure no comma's or spaces seperate the zeros and ones. (You can either include them in search and replace strings above or replace appart)
+
Now you'll see a (text) table containing the map data. You should see only two letter combinations are present, one for the shrouded part and one without. Use search and replace to search for the 'unshroud' letter combination (include leading and trailing spaces) and replace it with a '1' (without quotes). Then do the same for the 'shroud' combination and replace it with a '0'.
Once All that is done you only need to add a pipe in front of each line in this file. The result should look somthing like this:
+
Make sure nothing separates the zeros from the ones.
 +
Once All that is done you only need to add a pipe in front of each line in this file. The result should look something like this:
  
 
  |000000000000000000
 
  |000000000000000000
Line 35: Line 40:
 
  |000001111111000000
 
  |000001111111000000
  
Save the file and reference it in you scenario .cfg file like this (make sure the quotes are present, if not this will break the file):
+
Save the file and reference it in you scenario .cfg-file like this (make sure the quotes are present, if not this will break the file):
  
 
  [side]
 
  [side]
Line 44: Line 49:
  
 
Happy Unshrouding!
 
Happy Unshrouding!
 +
 +
== Fog Data ==
 +
The same holds true for setting fog in scenarios (though of limited use), just replace ''shroud_data'' with ''fog_data'' in the side definition.
 +
 +
[[Category:Create]]

Revision as of 07:49, 22 April 2015

Making 'shroud_data'

As pointed out in SideWML you can add the key shroud_data to a [side] tag to describe what parts of the map should be shrouded for a side and what parts not. This comes in handy when you need to unshroud a large part of the map from the start of the game. When you would use the [remove_shroud] tag for that purpose (eg in the prestart event) you would have to a list of x,y coordinates and this can become somewhat lengthy, and it's difficult to find out what coordinates need to be set.

This tutorial is going to make a file containing the data that will unshroud those parts of the map you'd like to see unshrouded. All you need is:

  • the wesnoth map editor
  • your favorite text editor (with a search & replace function)
  • a spreadsheet like Microsoft Excel or Libreoffice Calc

Making your map

First of all you will need a map. This can be made in the wesnoth map editor (see BuildingMaps for more information) Once you've got that, make a copy. If you like to, you can renaim this copy to eg MapName_Shroud to indicate this file will contain the shroud data.

Selecting what tiles will be unshrouded + flipping the map

(Open MapName_Shroud again in the editor if you closed it) You can now select the tiles in the editor you want to be unshrouded. Hold shift and click left to (un)select a single tile and hold shift+alt and click left to select adjecent terrain tiles of the same type. Now fill your selection with one terrain type, and then select all the other tiles and fill it with another type.

Once that's done, you can save again and quit the editor.

Import the file in your spreadsheet (in Openoffice.org: Insert->Sheet From File) and select the comma as seperator. You should see an example of what it will look like, if each lettercombination has it's own cell, then things are good. Select all of the cells and press ctrl+x (Edit->Cut). Then select the top left most cell on the sheet and right click in it. Select 'Paste special'. A dialog window appears. There should be a checkbox name 'transpose', check it. Now you've switched the rows and columns in the map. Select all of your cells again and press ctrl+c (Edit->Copy). Open your favorite text editor and press ctrl+v in a new file. Save this file over your MapName_Shroud file.

Rewriting the data of the map

(Open MapName_Shroud in your text editor if you closed it) Now you'll see a (text) table containing the map data. You should see only two letter combinations are present, one for the shrouded part and one without. Use search and replace to search for the 'unshroud' letter combination (include leading and trailing spaces) and replace it with a '1' (without quotes). Then do the same for the 'shroud' combination and replace it with a '0'. Make sure nothing separates the zeros from the ones. Once All that is done you only need to add a pipe in front of each line in this file. The result should look something like this:

|000000000000000000
|000000000000000000
|000000000000000000
|000001111111000000
|000001111111000000
|000001111111000000
|000001111111000000
|000001111111000000

Save the file and reference it in you scenario .cfg-file like this (make sure the quotes are present, if not this will break the file):

[side]
   ...
   shroud_data="{@url/MapName_Shroud}"
   ...
[/side]

Happy Unshrouding!

Fog Data

The same holds true for setting fog in scenarios (though of limited use), just replace shroud_data with fog_data in the side definition.