OK, but as I said I don't know in advance the arguments, because they're passed to the script and are not from a 2D array, which has already defined values.
I overwrote the title of the topic, because the issue is a bit more complex than it looks at first sight.
So the task is to create a reusable script for intermittently pushable walls.
I had two scripts for each pushable wall. Here are these:
First one:
Code: Select all
int mapvar0 = 1;
script 1 (void)
{
SetLineTexture(1, SIDE_FRONT, TEXTURE_MIDDLE, "-");
if(mapvar0 <= 24)
{
Polyobj_Move(2, 3, 0, 5);
PolyWait(2);
mapvar0++;
}
}
Second one:
Code: Select all
int tolas = 1;
script 12 (void)
{
if(tolas <= 17)
{
Polyobj_Move(50, 2, 192, 4);
PolyWait(50);
tolas++;
}
}
These worked well, but the general script for these won't work. So here is the script:
Code: Select all
int tolasok[100];
script 1 (int poly, int ttav, int tav, int irany)
{
if(tolasok[poly-1] < ttav/tav)
{
Polyobj_Move(poly, 3, irany, tav);
polywait(poly);
tolasok[poly-1]++;
}
}
This script is invoked by an ACS_Executewithresult special set for a line of a polyobject. The line is pushable, but you have to push it several times to get the poly to its destination. Instead of map variables I defined an array with 100 elements, because I don't know the exact number of these polys on the map. One element of this tolasok array defines the number of pushes. The initial value of these are 0, and if you push one of the walls once, the variable for the actual poly increases by 1. The reason why I used 100 elements in the array is because I cannot "distinguish" (I mean keep them separated from each other) the number of pushes for each polys and keep track of them in other way.
Now about the variables:
poly: the number of the actual poly
ttav: the overall distance where the poly can move
tav: the distance the poly can cover
irany: the direction where the poly moves to
The problem is that it seems as though the zdoom ignores the polywait or somehow the expression standing after if, returns false untimely, although the poly doesn't get to its destination.
If I write another polywait(poly); before the Polyobj_Move(poly, 3, irany, tav); then the problem remains, but the poly passes its destination point if you push it too fast.