Author Topic: Mapscript documentation  (Read 1722 times)

Offline CFK

  • Squaddie
  • *
  • Posts: 4
    • View Profile
Mapscript documentation
« on: November 29, 2023, 02:08:36 pm »
I'm making a very simple map for learning and I think I've understood how to do it with the help of MapView2. However, when I try to launch it I get "Map failed to fully generate".

I've looked at how several mapscripts are written and done some research, and I have to admit that this is black magic for me. Is there any clear documentation on the subject ?

Offline Nord

  • Commander
  • *****
  • Posts: 1747
  • The Gate is open.
    • View Profile
Re: Mapscript documentation
« Reply #1 on: November 29, 2023, 11:54:01 pm »
Well, no. Best way you can use, is take one existing and modify it.
If you have nothing special on your map, you can use something like
Code: [Select]
  - type: NEWMAPSCRIPTNAME
    commands:
    - type: addUFO
    - type: addCraft
    - type: addBlock
      size: 2
    - type: fillArea
Here you place: alien ufo, x-com craft, one large map piece and all space left with small pieces.

But

If you make new map, you should also create new part of "terrains:"
there you describe each map piece, its size and function. You need at least one piece with
Code: [Select]
groups: 1 as base for xcom craft landing. All other features are unnecessary.

Offline CFK

  • Squaddie
  • *
  • Posts: 4
    • View Profile
Re: Mapscript documentation
« Reply #2 on: November 30, 2023, 10:46:24 am »
Yes, that's what I was afraid of. I generally like to know what I'm doing, which is why I asked the question.

The addUFO and addCraft commands are pretty self-explanatory, but I have no idea what addBlock and fillArea are for. But I'll give it a try, thanks.

EDIT : and it's working, many thanks !
« Last Edit: November 30, 2023, 11:59:36 am by CFK »

Online CrazedHarpooner

  • Colonel
  • ****
  • Posts: 102
    • View Profile
Re: Mapscript documentation
« Reply #3 on: November 30, 2023, 01:19:37 pm »
https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom) in the "Map Scripts" section you will find some, altho not in depth, documentation.

In the example provided by Nord the addblock attempts to place a single mapblock that matches the parameters listed, in this case a size 2 (20x20) mapblock. If you were to specify a size of 1 or leave it empty so it defaults to this size the mapblock used would be a 10x10.

In the same manner, fillarea will start to fill in any 'gaps' in the map with size 1 (default) mapblocks until the map is completely filled. You normally want to use this command as the last one in your script, with certain exceptions, so it fills out remaining blocks with something otherwise the "Map failed to fully generate" will most likely occur.

Note that in both cases and with other commands, by specifying additional parameters for that command you can alter their behaviour like the number of times it attepts to place a block, which blocks are used, size, area within the map to restrict the command to and others.

Offline CFK

  • Squaddie
  • *
  • Posts: 4
    • View Profile
Re: Mapscript documentation
« Reply #4 on: December 01, 2023, 01:56:09 pm »
So, if I understand correctly (but I doubt it), if I want to place a unique 30x30 mapblock, should I set the size parameter to 3 ? What if I want to place a 30x20 or 20x10 mapblock ?

I ask this because I've tried it with a 20x20 mapblock, no problem. But as soon as I want one with a more "exotic" size, it doesn't work. The map is generated but the mapblock doesn't appear. So I copied the method used in X-Piratez by making a UFO appear (addUFO), and it works, but I feel like I'm tinkering.

In any case, thank you for your help as it's really not intuitive. The documentation is clear on many parameters, but not at all on mapscripting.

Online CrazedHarpooner

  • Colonel
  • ****
  • Posts: 102
    • View Profile
Re: Mapscript documentation
« Reply #5 on: December 01, 2023, 03:36:01 pm »
For non square mapblocks try specifying the full dimesion, when you use a single value like '1' or '2' it defaults to a square size (10x10, 20x20). And yes a '3' would be 30x30.
For a 30x20 you can use:
Code: [Select]
size: [3,2,0]For a 30x10:
Code: [Select]
size: [3,1,0]For a 20x10:
Code: [Select]
size: [2,1,0]For a 10x20:
Code: [Select]
size: [1,2,0]As far as I can tell, even tho the resize command is the only one that uses the 3rd value (height) it must still be listed for other commands when using it in this format, even if it's just a 0.

Offline CFK

  • Squaddie
  • *
  • Posts: 4
    • View Profile
Re: Mapscript documentation
« Reply #6 on: December 01, 2023, 05:30:01 pm »
And... it works ! I'm beginning to understand how it works thanks to you.