Hi everybody.
I declared a struct called "Column" in my Module header :
struct Column {
int x_pos;
int y_pos[9];
int weight_total;
import function update_weight();
};
In my Module script I declared the function "update_weight()":
function Column::update_weight() {
this.weight_total = 0;
}
In my main room script I declared 10 instances of my struct:
Column col_0;
Column col_1;
Column col_2;
...
And here is my problem:
In the room script I want to call
col_X.update_weight();
where "col_X" is the number of the column that the player has selected.
So this should be dynamic. If the player selected column "0" then it should be:
col_0.update_weight();
If the user had selected column "1" it should be:
col_1.update_weight();
and so on.
Is there a way of scripting that without doing:
int selected_column;
if (selected_column == 0) {
col_0.update_weight();
}
else if (selected_column == 1) {
col_1.update_weight();
}
...
I tried something with pointers but as soon as I write
Column* column_selected;
I get an error "Cannot declare pointer to non-managed type".
Thank you for reading.
Any help is greatly appreciated.
Many thanks in advance,
Stefan
How about:
Column col[3];
col[selected_column].some_function();
... :-\ ok, that was embarrassing.
And it works :)
Thanks SSH!