map madness

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

Post Reply
quartex
Inactive Developer
Posts: 2258
Joined: December 22nd, 2003, 4:17 am
Location: Boston, MA

map madness

Post by quartex »

Okay, this should be really simple, but I'm having a lot of trouble making scenarios load maps from a seperate file Everything works fine when I just cut and paste the map into the scenario file. But I'd prefer to have the maps stored seperatly so I can easily change which map a scenario uses.

Problem 1: Dynamic links don't seem to work.

Using the tip in the WML campaign help page, I tried typing this in my campaign file:

#define MY_DATA DATA_NAME
{campaigns/My_Campaign/{DATA_NAME}}
{~campaigns/My_Campaign/{DATA_NAME}}
#enddef

Then, in my scenario file I'd type:

map_data="{MY_DATA/maps/MyMap}"

But it never worked, It just displayed a blank map and said, "you were defeated".

I am required to type:
map_data="{campaigns/My_Campaign/maps/MyMap}"

in order for it to work? Why? I've seen the shortcuts work when loading .cfg files. Is my syntax bad somehow?

Problem 2: Using OS X TextEdit, when saving map files as text, Wesnoth can't read them. I save them as text files, I even tried switching the encomidng to unicode 16 or 8, but it made no difference. The mac scenario editor can read the files however, and the maps that it exports can be read by Wesnoth. So to make a map wesnoth can read I have to build it using the editor, or at least import it into the editor, and then export it as a new file.

(This makes using custom terrains a pain, becuase the I haven't figured out how to make the editor load custom terrain files from user campaigns.)

But in short I can't see a reason why text maps created by TextEdit in OS X 10.2.8 shouldn't be able to be read by Wesnoth. It reads the .cfg text files fine.

I've spent the last hour or two wrestling with the combination of these two problems. If anyone has any ideas about what I'm doing wrong, I'd appreciate it.

Thanks.
quartex
Inactive Developer
Posts: 2258
Joined: December 22nd, 2003, 4:17 am
Location: Boston, MA

Post by quartex »

I saw Invisible Philosopher type {MAP filename} to load a map in a scenario file in his wesvoid scenario campaign. So does that mean that this code should work?

#define MAP DATA_NAME
{campaigns/My_Campaign/maps/{DATA_NAME}}
{~campaigns/My_Campaign/maps/{DATA_NAME}}
#enddef

Then, in my scenario file I'd type:

{MAP MyMap}

(I'm not sure how he got the scenaio to realize that this block of text was the map. I guess I must be missing a step)
MadMax
Posts: 1792
Joined: June 6th, 2004, 3:29 pm
Location: Weldyn, Wesnoth

Post by MadMax »

Check and see how I do it in my campaign. I have

Code: Select all

#define MAP NUMBER
map_data="{campaigns/Flight_Freedom/maps/drake{NUMBER}}{~campaigns/Flight_Freedom/maps/drake{NUMBER}}"
#enddef
in Flight_Freedom.cfg, and in each scenario, I have

Code: Select all

{MAP 01}
for map 1.

You'll code won't work, because it will interpret the return as a character in the map.

As for maps not loading, it is because TextEdit does not save in regular text, it saves in Rich Text. You have to make a copy of an existing map, edit it, and save it.
"ILLEGITIMIS NON CARBORUNDUM"

Father of Flight to Freedom
http://www.wesnoth.org/wiki/FlightToFreedom
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

In text edit, select Format > Make Plain Text
Then save. In preferences you can also specify that new documents always are plain text.
quartex
Inactive Developer
Posts: 2258
Joined: December 22nd, 2003, 4:17 am
Location: Boston, MA

Post by quartex »

MadMax wrote:Check and see how I do it in my campaign. I have

Code: Select all

#define MAP NUMBER
map_data="{campaigns/Flight_Freedom/maps/drake{NUMBER}}{~campaigns/Flight_Freedom/maps/drake{NUMBER}}"
#enddef
in Flight_Freedom.cfg, and in each scenario, I have

Code: Select all

{MAP 01}
for map 1.

You'll code won't work, because it will interpret the return as a character in the map.

As for maps not loading, it is because TextEdit does not save in regular text, it saves in Rich Text. You have to make a copy of an existing map, edit it, and save it.
Thanks for the code. I'll try it out and see if it makes a difference.

I knew about text edit saving as rich text normally. With all my maps I converted them into normal text files and the saved them. My point was that Wesnoth 0.8.2 could read text .cfg files, but not my map files, and I wasn't sure why.
Invisible Philosopher
Posts: 873
Joined: July 4th, 2004, 9:14 pm
Location: My imagination
Contact:

Post by Invisible Philosopher »

Actually an extra return doesn't seem to matter. This is how I do it:

Code: Select all

#define WESVOID_DATA DATA_NAME
{campaigns/Wesvoid_Campaign/{DATA_NAME}}
{~campaigns/Wesvoid_Campaign/{DATA_NAME}}
#enddef

#define MAP NAME
map_data="{WESVOID_DATA maps/{NAME}}"
#enddef
So {MAP Lichs_Claw} expands to

Code: Select all

map_data="{WESVOID_DATA maps/Lichs_Claw}"
and then to

Code: Select all

map_data="
{campaigns/Wesvoid_Campaign/maps/Lichs_Claw}
{~campaigns/Wesvoid_Campaign/maps/Lichs_Claw}
"
(although I'm not sure which extra returns actually exist)
and then to

Code: Select all

map_data="
mmmmmmmmmmmcccmmmmmmmmmmm
mmmmmmhhhmmccchhhhmmmmmmm
mmmhhhhhhhhccchhhhhhhhmmm
mhhtCthhhhhccchhhhhtCthhm
mhCCCCChhhhccchhhhCCCCChm
mhtC2CthhggcccgghhtC3Cthm
mhCtCtChgggcccggghCtCtChm
mhhhChhggvgcccvggghhChhhm
mhhhhhhgggccccccvghhhhhhm
mmhhhhhgggccvgccgghhhhhmm
mmhhhhggvcccggcccgghhhhmm
mmmhhhgggcvcgggcccghhhmmm
mmmhhhgggccggggvccvhhhmmm
mmmmhhgggccgggggccccccccc
mmmmhhggcccgggggggccccccc
mmmmmhhgccvggggggghmmmmmm
mmmmmhhvccgggggggghmmmmmm
mmmmmmhcccggggvggghhmmmmm
cccccccccgggggggghhmmmmmm
ccccccchggvgggggghhmmmmmm
mmmmmmhhggggggggvhhhmmmmm
mmmmmmmhhggnnngghhhmmmmmm
mmmmmmhhhggn1ngghmmmmmmmm
mmmmmmmhhgggnggghmmmmmmmm
mmmmmmmmhgvggggghmmmmmmmm

"
Play a Silver Mage in the Wesvoid campaign.
MadMax
Posts: 1792
Joined: June 6th, 2004, 3:29 pm
Location: Weldyn, Wesnoth

Post by MadMax »

What if it is in the user campaign folder? Then the extra return is up top, and you get an illegal map error.
"ILLEGITIMIS NON CARBORUNDUM"

Father of Flight to Freedom
http://www.wesnoth.org/wiki/FlightToFreedom
quartex
Inactive Developer
Posts: 2258
Joined: December 22nd, 2003, 4:17 am
Location: Boston, MA

Post by quartex »

Well to good news is that I tried using the MAP macro to load maps in 0.8.0 and 0.8.1 and it worked in both version. Here's the code I used:


#define MAP DATA_NAME
map_data="{campaigns/Desert_campaign/maps/{DATA_NAME}}"
#enddef

But oddly, when this code is used in 0.8.2, it loads a blank map and says "you have been defeated". I think this is some sort of bug with the mac build.

My continuing problem it is that 0.8.0, 0.8.1 and 0.8.2 won't read my map text files, it will only read the text files that are exported by the mac scenario editor. Yes, i'm saving in regular text, yes the files look exactly the same when I open them, but darned if I know why it doesn't work.

I'm glad that the MAP macro works in older versions, it makes me think it is just a bug in the 0.8.2 OS X build I'm using. Still with all this trouble, I'm starting to think it might be easier just to paste the map in with the scenario, like I used to do.
Invisible Philosopher
Posts: 873
Joined: July 4th, 2004, 9:14 pm
Location: My imagination
Contact:

Post by Invisible Philosopher »

MadMax wrote:What if it is in the user campaign folder? Then the extra return is up top, and you get an illegal map error.
No I don't that error. I tried changing to

Code: Select all

#define WESVOID_DATA DATA_NAME
{~campaigns/Wesvoid_Campaign/{DATA_NAME}}
{campaigns/Wesvoid_Campaign/{DATA_NAME}}
#enddef
(swapping them)
and it still worked. Extra returns at the beginning or end of the map_data do not cause a problem. (however that change broke some other things for reasons I don't understand... If anyone actually complains about any problems with putting it in the "user campaign folder", then I'll try to see what's wrong with it. But the map works fine even with that change.)


quartex wrote:Well to good news is that I tried using the MAP macro to load maps in 0.8.0 and 0.8.1 and it worked in both version. Here's the code I used:


#define MAP DATA_NAME
map_data="{campaigns/Desert_campaign/maps/{DATA_NAME}}"
#enddef

But oddly, when this code is used in 0.8.2, it loads a blank map and says "you have been defeated". I think this is some sort of bug with the mac build.

My continuing problem it is that 0.8.0, 0.8.1 and 0.8.2 won't read my map text files, it will only read the text files that are exported by the mac scenario editor. Yes, i'm saving in regular text, yes the files look exactly the same when I open them, but darned if I know why it doesn't work.

I'm glad that the MAP macro works in older versions, it makes me think it is just a bug in the 0.8.2 OS X build I'm using. Still with all this trouble, I'm starting to think it might be easier just to paste the map in with the scenario, like I used to do.
Try copying the contents of the text file and pasting them into a new text file... that sometimes works for me when things seem randomly broken.
Play a Silver Mage in the Wesvoid campaign.
Post Reply