getting WML events to work with [generator]
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
getting WML events to work with [generator]
Hi All,
I can't get any events to work if I'm generating the map with [generator]
Here's a stripped down snippet: neither event triggers.
If I replace the "map_generation" and [generator] with "mapdata" and [side] tags, it works fine.
I can't get any events to work if I'm generating the map with [generator]
Here's a stripped down snippet: neither event triggers.
If I replace the "map_generation" and [generator] with "mapdata" and [side] tags, it works fine.
Code: Select all
[multiplayer]
id=ranmap4
name= _ "Random map (Cave)"
description= _ "A random map set in cave."
turns=99
[event]
name=moveto
[filter]
x=5
y=5
[/filter]
[message]
speaker=narrator
message=_ "MOVE TO EVENT WORKS."
[/message]
[/event]
[event]
name=start
[message]
speaker=narrator
message=_ "EVENT START WORKED"
[/message]
[/event]
map_generation=cave
[generator]
map_width=10
map_height=10
[chamber]
id=center
x=2
y=2
size=20
[items]
[side]
side=1
canrecruit=1
[/side]
[side]
side=2
canrecruit=1
[/side]
[/items]
[/chamber]
[/generator]
[/multiplayer]
On further inspection, this seems to be specific to:
map_generation=cave
I found Rhuvaen's code for random morituri maps, and those cfg files have prestart events. I tried it, and could get both prestart and start events to work. I'm assuming moveto and other events will also work. Since that's the case, the problem looks specific to map_generation=cave.
map_generation=cave
I found Rhuvaen's code for random morituri maps, and those cfg files have prestart events. I tried it, and could get both prestart and start events to work. I'm assuming moveto and other events will also work. Since that's the case, the problem looks specific to map_generation=cave.
I've gotten it to work in the past for single-player scenarios. IIRC, the solution is to put all events inside the [chamber] tags.
See the attached file to be sure.
See the attached file to be sure.
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
And I hate stupid people.
The World of Orbivm
Thanks Turin. It's a ton of help.
Second question for anyone who might know?
Is there any way to get the cave generator to use road(R) or some other terrain instead of cave floor(u) ?
I tried putting a huge terrain_mask into the prestart event to convert all u's into R's, but terrain_mask doesn't seem to work with the map generator. terrain does, but not terrain_mask.
Thanks In Advance.
Second question for anyone who might know?
Is there any way to get the cave generator to use road(R) or some other terrain instead of cave floor(u) ?
I tried putting a huge terrain_mask into the prestart event to convert all u's into R's, but terrain_mask doesn't seem to work with the map generator. terrain does, but not terrain_mask.
Thanks In Advance.
I am trying to do the same thing, and terrain mask did nothing for me. I thought to try adding road in random locations, but I haven't done it yet. If you figure it out let me know.Yogin wrote:Thanks Turin. It's a ton of help.
Second question for anyone who might know?
Is there any way to get the cave generator to use road(R) or some other terrain instead of cave floor(u) ?
I tried putting a huge terrain_mask into the prestart event to convert all u's into R's, but terrain_mask doesn't seem to work with the map generator. terrain does, but not terrain_mask.
Thanks In Advance.
Hope springs eternal.
Wesnoth acronym guide.
Wesnoth acronym guide.
Turin,
the following is from your campaign:
What does same_location_as_previous do?
I would've assumed it would act like an x,y filter on [event], but it doesn't seem to. The moveto event in my code seems to activate anywhere my unit finishes moving in that chamber. (I haven't tried outside of that chamber)
I'd like to put a moveto event on the location where that chest appears. In fact, I'd like the x,y coordinates of that chest, if possible.
Thanks in advance.
the following is from your campaign:
Code: Select all
[chamber]
...
[items]
....
[item]
image=misc/chest.png
[/item]
[event]
same_location_as_previous=yes
name=moveto
....
[/event]
....
[/items]
...
[/chamber]
I would've assumed it would act like an x,y filter on [event], but it doesn't seem to. The moveto event in my code seems to activate anywhere my unit finishes moving in that chamber. (I haven't tried outside of that chamber)
I'd like to put a moveto event on the location where that chest appears. In fact, I'd like the x,y coordinates of that chest, if possible.
Thanks in advance.
You need to put the terrain_mask inside a prestart event. The events all go into the settings section of the generator. That's where ALL your events should go, although you can define macros anywhere inside the multiplayer tags. It seems to me that the generator tag (used with any generator) replaces the outer multiplayer or scenario tag when the map has been created, and any events that are located outside of generator will never get called.Yogin wrote:I tried putting a huge terrain_mask into the prestart event to convert all u's into R's, but terrain_mask doesn't seem to work with the map generator. terrain does, but not terrain_mask.
It seems the cave generator doesn't know about the convert tags of the standard generator. That would have been much easier for exchanging cave floor with dirt!
Note: the regenerate button doesn't work with the cave generator. This is probably a bug (maybe the standard generator gets called by default?). Selecting a different map and then going back to this one will do the same thing, however.
Here's a working example:
Code: Select all
[multiplayer]
id=ranmap_cave
name= _ "Random map (Cave)"
description= _ "A random map set in cave."
turns=99
map_generation=cave
[generator]
[settings]
id=ranmap_cave
name= _ "Random map (Cave)"
[event]
name=prestart
[terrain_mask]
x=1
y=1
mask="~~~~r~~r~rrr~~rr~r~~
~~~~rrrrrrr~~~cccr~~
~~~~r~rrrrr~~~~ccr~~
~~~~r~~~rrrr~~~rrrr~
r~rrr~~rrrrcrrrrr~~~
rr~rrrr~~rrrrrr~~~~~
rrrrr~~~~rr~~~rrr~~~
~rr~~rrrr~~~rrrrrr~~
~rrr~~rrr~~~rrrrrr~~
~rr~rrrrr~~~rrr~~r~~
~~r~~rrrr~~~rrrr~rr~
~~rrrrrrr~~~rr~~rrr~
~~rrrrr~~~rr~~rr~rr~
~~~rrrrrrrrr~~rrrrrr
~~~~~rrrcrrrrrrrr~rr
~~~rrr~~~rrrr~~~~~~r
~rrrcc~~~~rrrrrr~~~~
~~rrccc~~~rrrrrr~~~~
~~rrrrrrrrrrrrrr~~~~
~~r~rr~~rrr~r~rr~~~~"
[rule]
old="W"
terrain="W"
[/rule]
[rule]
old="K"
terrain="K"
[/rule]
[rule]
old="o"
terrain="o"
[/rule]
[rule]
old="D"
terrain="D"
[/rule]
[/terrain_mask]
[/event]
[/settings]
map_width=20
map_height=20
flipx_chance=50
village_density=50
#player 1
[chamber]
id=player1
x=2-5
y=2-6
size=6
jagged=40
[items]
[side]
side=1
canrecruit=1
[/side]
[/items]
[/chamber]
#player 2
[chamber]
id=player2
x=16-19
y=15-19
size=6
jagged=40
[items]
[side]
side=2
canrecruit=1
[/side]
[/items]
[/chamber]
#central
[chamber]
id=central
x=7-13
y=6-15
size=7
jagged=80
[passage]
destination=player1
width=1
windiness=14
jagged=5
[/passage]
[passage]
destination=player2
width=1
windiness=14
jagged=5
[/passage]
[/chamber]
#other1
[chamber]
id=other1
x=3-8
y=14-19
size=3
jagged=60
[passage]
destination=player1
width=1
windiness=14
jagged=5
[/passage]
[passage]
destination=central
width=1
windiness=14
jagged=5
[/passage]
[/chamber]
#other2
[chamber]
id=other2
x=13-18
y=2-7
size=3
jagged=60
[passage]
destination=player2
width=1
windiness=14
jagged=5
[/passage]
[passage]
destination=central
width=1
windiness=14
jagged=5
[/passage]
[/chamber]
[/generator]
[/multiplayer]
EDIT: made the terrain mask more interesting.
Try some Multiplayer Scenarios / Campaigns
Thanks to your help, I have added a crude terrain mask to The Scepter of Fire to help you move around and give you more villages near your castle. Here is the file in case anyone wants to have an example or help improve it.
- Attachments
-
- Scepter_of_Fire.cfg.zip
- (3.05 KiB) Downloaded 422 times
Hope springs eternal.
Wesnoth acronym guide.
Wesnoth acronym guide.