Not logged inOpenClonk Forum
Up Topic Feature Request: Set Material of an Algorithm in Map Script

This board is threaded (i.e. has a tree structure). Please use the Reply button of the specific post you are referring to, not just any random button. If you want to reply to the topic in general, use the Post button near the top and bottom of the page.

Post Reply
In Response to Foaly
Unless I'm mistaken, it is currently not possible to set a material of an Algorithm with map script.

(assume:
var x = [0, 20, 20, 0];
var y = [0, 0, 20, 20];

)

For example, to draw a rectangle of earth, we can currently do this:
map->Draw("Earth", { Algo = MAPALGO_Polygon, X = x, Y = y });

However, it is not possible to draw multiple materials within one Draw call... Or is it?

We can use Blit instead!
The following code will draw two overlapping rectangles, one earth and one gold.
The overlapping part will remain sky, i. e. they are Xored (I chose this, because this would be more complicated to recreate with regular Draw, than operations like Or).
map->Blit(
  { Algo = MAPALGO_Xor, Op = [
    { Algo = MAPALGO_And, Op = [{ Algo = MAPALGO_Polygon, X = x, Y = y }, CreateLayer("Earth")] },
    { Algo = MAPALGO_And, Op = [{ Algo = MAPALGO_Offset, OffX = 10, OffY = 10, Op =
      { Algo = MAPALGO_Polygon, X = x, Y = y }
    }, CreateLayer("Gold")] } 
  ]});


However, setting the material within a Blit call is inconvenient. It involves creating (or having several as local variables) a new dummy layer, just for the material.
I think it would be much nicer to have it this way:
map->Blit(
  { Algo = MAPALGO_Xor, Op = [
    { Material = "Earth", Algo = MAPALGO_Polygon, X = x, Y = y },
    { Material = "Gold", Algo = MAPALGO_Offset, OffX = 10, OffY = 10, Op =
      { Algo = MAPALGO_Polygon, X = x, Y = y }
    }
  ]});


Then, we wouldn't need temporary layers.

tl;dr

I want to add the extra property Material to Algorithms.
If it is set, then the algorithm will set that material.

Oh, and I forgot to mention:
If this would be an "accepted" feature, I could also try to implement this myself.

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill