Hi noremac407,
Welcome to the forum, thanks for the question, and sorry for the poor documentation and general design of ZeoScript.
The map.GetPixel function in ZeoScript is a bit of a throwback to the C programming language, with which I am most familiar, and which was used to write the ZeoScript compiler. Since C is strongly typed, ZeoScript is too. This means that functions like map.SetPixel are a bit tricky, because they need to take pixel arguments with different data types when used with different map types (floats for heightfields, RGB colours for colour maps, bytes for mask maps, etc.) Either I would have had to write a set of functions (one for each data type), or else write one function that took a generic handle to a variable (the usual approach in C). I chose the latter option. Anyhow, 'hvar' is just a generic handle to a variable of any data type, much like a void* in C can be treated as a pointer to any data type. You use it like this:
- Code: Select all
// get a handle to the heightfield
hvar hMap
set hMap <GetMap "HF">
float ExampleFloat // declare a float
set ExampleFloat 20 // set the float value
// set pixel x=125, y=456 to value given by ExampleFloat
map.SetPixel hMap 123 456 &ExampleFloat
Note the use of the ampersand operator in '&ExampleFloat', which gets the handle to ExampleFloat as a hvar (just like C).
I've uploaded an example script (
see here) that uses these functions to generate a sinusoidal heightfield like this:
Please let me know if you find any further problems or have additional questions.
Please also note that ZeoScript can be a little slow for pixel-by-pixel calculations. Although you can do it (as in the above example), ZeoScript is more suited to being the glue between calls to native functions (from L3DT or plugins) which can access map data much more quickly. However, if you're performing an operation that can't be expressed in terms of the available function calls, then ZeoScript (though slow) may be easier than writing a full-blown plugin. It really depends on how large a map you want to process, and how often you want to run the calculation. I'm happy to provide assistance in making a plugin, if that's necessary.
Best regards,
Aaron.