L3DT users' wiki
Large 3D terrain generator

Scripts > DM_SetLayer

Description Set the contents of a layer of the design map, using another map layer in the project. To be used with the DM_GetLayer script.
Author Aaron
Created 2010/05/24
Updated 2016/05/12
Requires L3DT v2.9 beta 2 or later
Download DM_SetLayer.zs

Script contents

// Author:  A. Torpy
// Updated: 12 May 2016

hvar hDM
set hDM <GetMap "DM">
assert <cast bool <map.GetWidth hDM>> "Design map not initialised!"

// allow user to select layer
combosel CS
combosel.Init &CS "Altitude|PeakNoise|FracNoise|Cliffs|Erosion|Lakes|Climate|SpecType|SpecParam|" "Altitude" NULL
if <not <EditUI &CS "Select DM layer">>
  return 0
endif

// determine layer ID
int LayerID
set LayerID -1
string LayerName
set LayerName <combosel.GetCurSelA &CS>
if <iseq 0 <strcmp LayerName "Altitude">>
  set LayerID 0
elseif <iseq 0 <strcmp LayerName "PeakNoise">>
  set LayerID 1
elseif <iseq 0 <strcmp LayerName "FracNoise">>
  set LayerID 2
elseif <iseq 0 <strcmp LayerName "Cliffs">>
  set LayerID 3
elseif <iseq 0 <strcmp LayerName "Erosion">>
  set LayerID 4
elseif <iseq 0 <strcmp LayerName "Lakes">>
  set LayerID 5
elseif <iseq 0 <strcmp LayerName "Climate">>
  set LayerID 6
elseif <iseq 0 <strcmp LayerName "SpecType">>
  set LayerID 7
elseif <iseq 0 <strcmp LayerName "SpecParam">>
  set LayerID 8
else
  assert false "Invalid layer selection!"
endif

// get or create the map layer
string MapName
set MapName <strcat "DM-" LayerName>
hvar hLayer
set hLayer <GetMap MapName>
if <not hLayer>
  assert hLayer <strcat <strcat "Layer '" MapName> "' does not exist in project!">
endif
assert <cast bool <map.GetWidth hDM>> <strcat <strcat "Layer '" MapName> "' is not initialised!">


assert <calc.DM.SetLayer hDM hLayer LayerID> "Cannot set design map layer!"

// and now show the updated design map
view.ShowMap "DM"
 
scripts/setdesignmaplayer.txt · Last modified: 2017/08/31 05:52 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki