Copy/Paste terrain script for the map editor

Started by eduran, December 24, 2020, 05:10:43 AM

Previous topic - Next topic

eduran

To save a couple of minutes every time when editing a map, I wrote a script to copy/paste terrain in the editor. Since it seems impossible to make enough maps to get the hours of time spent on this script back, I am sharing it in the hopes of saving time for other map makers. Perhaps it will save more time than it took to write it if enough people use it (not likely).

30MB gif
[close]

Important notes:

  • This is meant to be used during editing only. Remove the script before finalizing your map.
  • Changes made to the map by the script can not be undone with the editor's undo function.
  • The script almost certainly contains bugs. Use at your own risk.
  • Requires v1.1.0 of CW4.
  • The script uses a number of units to mark different things on the map. If you delete them, the script will probably break or react in unexpected ways.

Adding the script to a map:

  • Save your map. You might want to create a backup, just in case. If you save after this script makes terrain changes, you won't be able to undo them.
  • Use the Package manager to import CopyTerrain.cpack into your map. Go to the script tab and hit the "compile all scripts" button. Select CopyTerrain.4rpl in the "Global Control" section of the package manager. Have a look at the key bindings and change them to suit your needs. Valid keys can be found here: https://docs.unity3d.com/ScriptReference/KeyCode.html. Avoid overlap with hotkeys used by the editor. Make sure to use valid key identifiers only. There is currently a bug that will freeze your map if you specify invalid keys. To be on the save side you should only use letters.
  • If you see a black square titled CPT to the east of your map the script is ready to use.

How to copy/paste:

  • Press the Enable key (default: U) to switch the script on. The indicator will change color from red to green.
  • Drag your mouse across the area you wish to copy while holding down the Copy key (default: G).
  • Set the position of the paste area with the SetPasteArea key (default: H). You can drag the markers at the corners of either area with Ctrl+LMB to resize and reposition as needed.
  • If you want to paste a rotated or mirrored version of the selected terrain, click on the CPT unit and select the corresponding option in the UI on the left.
  • Press the Paste hotkey (default: J) while both areas are marked to copy terrain from the green to the blue area.
  • You can undo the latest (and only the latest) paste with the Undo hotkey (default: K)
  • Press the Enable hotkey again to switch the script off. The indicator light turns red and all markers are removed from the map.

How to export/import

  • Enable the script.
  • Click the CPT unit and change mode to Export.
  • Mark the area you wish to export (see 2. above)
  • Press the Paste hotkey (K).
  • Open %USERPROFILE%\Documents\My Games\creeperworld4\RPL.txt in a text editor. There should be a line starting with "CPT terrain export", followed by two lines you need to copy.
  • On the map you wish to import the terrain to, select the CPT unit. Hit the "settings" button next to ImportDummy.4rpl, paste the copied lines into the import variable and hit apply.
  • Use the UI on the left to switch to Import mode.
  • Press the Copy hotkey (G) to import, followed by SetPasteArea (H). You should now see a blue area. Move it to where you want the imported terrain to go.
  • Press Paste (J). Done!

Original idea by planetfall, who made LandCopier.prpl for Particle Fleet.