Thank you, I've answered in the French forum as well.
I've asked the question at Stackoverflow, and I got a nice answer
here.
Here's the code that works:
Code: Select all
Void PlaceNESW(Integer X, Integer Y, Integer Z, Integer Val)
{
PB("ArenaSimpleBase", X, Y, Z, ::CardinalDirections::North);
declare Boolean ValBitN = ((Val / 1 ) % 2) > 0;
declare Boolean ValBitE = ((Val / 2 ) % 2) > 0;
declare Boolean ValBitS = ((Val / 4 ) % 2) > 0;
declare Boolean ValBitW = ((Val / 8 ) % 2) > 0;
if (ValBitN) {
PB("ArenaSimpleBase", X, Y, Z-1, ::CardinalDirections::North);
}
if (ValBitE) {
PB("ArenaSimpleBase", X, Y, Z-1, ::CardinalDirections::North);
}
if (ValBitS) {
PB("ArenaSimpleBase", X, Y, Z-1, ::CardinalDirections::North);
}
if (ValBitW) {
PB("ArenaSimpleBase", X, Y, Z-1, ::CardinalDirections::North);
}
}
The goal is to put a square somewhere on the map, and if there's an opening on the north, put a square on the north, same for the west, south and east. But I need the function to be very short, and I needed to have maybe more than one opening... so there's nothing better than using bits (I think so).
I call the funtion like this:
Code: Select all
PlaceNESW(25, CoordYBaseSol+2, 27, 15); // NESW
PlaceNESW(25, CoordYBaseSol+2, 25, 1); // N
PlaceNESW(25, CoordYBaseSol+2, 23, 10); // EW
Thank you very much for your answer, I've learned a lot, even though I didn't follow your suggestion.
Thanks again