Random map in Lua?

The place to post your WML questions and answers.

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.
Post Reply
User avatar
Gwledig
Posts: 568
Joined: March 30th, 2009, 5:10 pm
Location: UK

Random map in Lua?

Post by Gwledig »

Hi I notice that random maps of the 'cave' type are not working in 1.14, other normal 'default' random maps still seem to be working... The WML docs and game logs tell you to use some kind of lua random map instead, but I can't find any usable instructions, the lua map guide has some kind of malformed code which doesn't make sense when telling you how to declare the map type
(Version 1.13.6 and later only) scenario_generation=cave and map_generation=cave is no longer supported, instead use map_generation=lua with code = << params = ...; return wesnoth.dofile("lua/cave_map_generator.lua") >>, the [generator] has a similar syntax, the difference is that
When loading my random cave map the map is blank and it says there is an unknown tile, the log says:
20190714 22:03:45 error config: map/scenario_generation=cave is deprecatd and will be removed soon, use map/scenario_generation=lua with lua/cave_map_generator.lua instead.
20190714 22:03:45 error config: map could not be loaded: Unknown tile in map: () ''
it does look like the deprecated message is the reason the cave random map is failing... Does anyone know of a new lua based random cave map (or any lua random map cfg at all?)

My current random map is

Code: Select all

#textdomain wesnoth-multiplayer

[multiplayer]
id=Lazersquad_multiplayer_Random_Caves2
name=_"Lazersquad (2p Random Caves)"
description=_ "Lazersquad (2p Random Caves) - equip and use your squad to defeat enemy squads, inspired by the "Laser Squad" and "Rebelstar" games.
For 2 players"

{INTRO_STORY}
{DEFAULT_SCHEDULE}
{DEFAULT_MUSIC_PLAYLIST}
{LAZER_BASE_CAVES}
{OBJECTIVES_NOTE_MAP_BY (Gwledig)}
{SELECT_LENGTH}
{SPAWN_MOD_COMMANDER}
{REFRESH_SCREEN}
{STARTING_GOLD}
{SELECT_SOUNDS}
{RECRUIT_MENU_MISSILES}
{KILL_PROJECTILE}
{REMOVE_CASTLES}
{OUTPOST_STORE *^V*}
{OUTPOST_MERC_MENU *^V*}
{VICTORY_CONDITIONS}
{ENGINEER_STRUCTURES}
{DEMOLISH}

map_generation=cave 
[generator]
[settings]
id=Lazersquad_multiplayer_Random_Caves2
name=_"Lazersquad (2p Random Caves)"
description=_ "Lazersquad (2p Random Caves) - equip and use your squad to defeat enemy squads, inspired by the "Laser Squad" and "Rebelstar" games.
For 2 players"



#define PASSAGE_NORMAL DESTINATION_NAME WIDTH_NUMBER WINDINESS_NUMBER JAGGED_NUMBER
    [passage]
        destination={DESTINATION_NAME}
        width=2
        windiness={WINDINESS_NUMBER}
        jagged={JAGGED_NUMBER}
    [/passage]
#enddef

#define PASSAGE_CHANCE CHANCE_NUMBER DESTINATION_NAME WIDTH_NUMBER WINDINESS_NUMBER JAGGED_NUMBER
    [passage]
        chance={CHANCE_NUMBER}
        destination={DESTINATION_NAME}
        width=2
        windiness={WINDINESS_NUMBER}
        jagged={JAGGED_NUMBER}
    [/passage]
#enddef

#get rid of grass where the castles are spawned, it may be possible to replace this at the end of the scenario but this fix works for now
[event]
name=prestart
first_time_only=yes
[terrain]
[and]
terrain=Gg* # here is the filter criterion
[/and]
terrain=Uu  # and the new terrain
[/terrain]
fire_event=yes
[/event]

[/settings]
id=Lazersquad_multiplayer_Random_Caves
name=default
map_width=50
map_height=70
flipx_chance=50
village_density=16
players=2

# The chamber with the player. Somewhere in the far south

[chamber]
id=player
x=15-35
y=68
size=8
jagged=50

[items]
{CAVES_SIDE1}
[/items]

[/chamber]


# The antechambers

[chamber]
id=antechamber_1
x=10-25
y=50-60
size=8
jagged=5
{PASSAGE_NORMAL player 2 10 10}
[/chamber]

[chamber]
id=antechamber_2
x=25-40
y=50-60
size=8
jagged=2
{PASSAGE_NORMAL player 2 3 1}
{PASSAGE_CHANCE 40 antechamber_1 1 9 9}
[items]
[/items]
[/chamber]


# The central volcano

[chamber]
id=center
x=25-26
y=35-36
size=8
jagged=1
{PASSAGE_NORMAL antechamber_1 1 20 3}
{PASSAGE_NORMAL antechamber_2 1 20 3}

[/chamber]


# The 5 minichambers encircling the central volcano and a 6th chamber
# to serve as the exit

[chamber]
id=mini_1
x=10-16
y=36-40
size=8
jagged=2
{PASSAGE_NORMAL center 1 5 2}
{PASSAGE_NORMAL antechamber_1 2 5 2}
[/chamber]

[chamber]
id=mini_2
x=8-20
y=17-26
size=8
jagged=3
{PASSAGE_NORMAL center 1 5 2}
{PASSAGE_NORMAL mini_1 1 5 2}


[/chamber]

[chamber]
id=mini_3
x=6-44
y=14-30
size=8
jagged=4
{PASSAGE_NORMAL center 1 5 2}
{PASSAGE_NORMAL mini_2 2 5 2}

[/chamber]
[chamber]
id=mini_4
x=30-42
y=17-26
size=8
jagged=5
{PASSAGE_NORMAL center 1 5 2}
{PASSAGE_NORMAL mini_3 2 5 2}
[/chamber]

[chamber]
id=mini_5
x=34-40
y=36-40
size=5
jagged=5
{PASSAGE_NORMAL mini_4 2 5 2}
{PASSAGE_NORMAL center 1 5 2}
{PASSAGE_NORMAL antechamber_2 2 5 2}
[/chamber]

[chamber]
id=exit
x=25
y=1
size=8
jagged=1
{PASSAGE_NORMAL mini_2 1 5 2}
{PASSAGE_NORMAL mini_3 1 5 2}
{PASSAGE_NORMAL mini_4 1 5 2}


[/chamber]

# There are 4 chambers for enemies randomly scattered on the map

[chamber]
id=enemy_1
x=6-15
y=45-55
size=5
jagged=3
{PASSAGE_NORMAL mini_1 2 5 2}
{PASSAGE_CHANCE 60 mini_2 1 5 2}
{PASSAGE_CHANCE 40 antechamber_2 1 5 2}
[/chamber]

[chamber]
id=enemy_2
x=6-15
y=1-35
size=8
jagged=3
{PASSAGE_NORMAL mini_2 2 5 2}
{PASSAGE_NORMAL enemy_1 2 5 5}
{PASSAGE_CHANCE 60 mini_1 1 5 2}
{PASSAGE_CHANCE 40 mini_3 1 5 2}
[/chamber]

[chamber]
id=enemy_3
x=35-45
y=1-35
size=8
jagged=3
{PASSAGE_NORMAL mini_4 2 5 2}
{PASSAGE_CHANCE 60 mini_5 1 5 2}
{PASSAGE_CHANCE 40 mini_3 1 5 2}


[/chamber]

[chamber]
id=enemy_4
x=35-45
y=45-55
size=8
jagged=3
{PASSAGE_NORMAL mini_5 2 5 2}
{PASSAGE_NORMAL enemy_3 2 5 5}
{PASSAGE_CHANCE 60 mini_4 1 5 2}
{PASSAGE_CHANCE 40 antechamber_2 1 5 2}

[items]
{CAVES_SIDE2}
[/items]
[/chamber]

[castle]
valid_terrain=Uu
min_distance=12
[/castle]

[/generator]

[/multiplayer]
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Random map in Lua?

Post by Ravana »

Have you tried it like campaign uses it?
User avatar
Gwledig
Posts: 568
Joined: March 30th, 2009, 5:10 pm
Location: UK

Re: Random map in Lua?

Post by Gwledig »

sorry which campaign pls?
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Random map in Lua?

Post by gfgtdf »

Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
User avatar
Gwledig
Posts: 568
Joined: March 30th, 2009, 5:10 pm
Location: UK

Re: Random map in Lua?

Post by Gwledig »

Ah thanks I am pretty sure that is the same map I based my current random cave on, if this is the case I just need to snatch the WML and update my own maps...
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)
User avatar
Celtic_Minstrel
Developer
Posts: 2166
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Random map in Lua?

Post by Celtic_Minstrel »

If the old cave generator is not working, I think that's a bug? It's supposed to be only deprecated in 1.14 if I recall correctly.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
Gwledig
Posts: 568
Joined: March 30th, 2009, 5:10 pm
Location: UK

Re: Random map in Lua?

Post by Gwledig »

Thanks I got it working using the lua version from the map updated in core 1.14 mentioned above
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)
Post Reply