Apologies for so the numerous threads... I prefer keeping each question separated so discussion is focused. :P
First and foremost, I would like to ask one question...
Is there a big difference in the size between trigger[500] or 500 void functions? If there isn't, then I won't bother pursuing this.
The only reason why I'm using trigger[500] right now is because of the ability to execute a trigger based on an array. For example, running trigger a[230].
Is it possible to achieve this with functions? I can't think of any way to run a function based on a dynamically constructed name since you can't have arrays of a function name. Unless you can somehow use strings or something to construct a name of a function then run it... or something...
And there's a crude way of doing it using if then else clauses, but then it gets really slow for the functions at the end.
But if he really has a trigger[500] then this will be a looooooooooooooooooo (insert more o's here) ooong if-then-else.
And probably more efficient (albeit more memory consuming) to use triggers.
In theory trigger[500] should not be any much larger than int[500], as it's only storing a reference to a trigger (which is say different from a record array, which actually allocates your struct). I don't see it as any big memory hogger. The 500 triggers that you assign to it on the other hand...
Apologies for so the numerous threads... I prefer keeping each question separated so discussion is focused. :P
First and foremost, I would like to ask one question... Is there a big difference in the size between trigger[500] or 500 void functions? If there isn't, then I won't bother pursuing this.
The only reason why I'm using trigger[500] right now is because of the ability to execute a trigger based on an array. For example, running trigger a[230].
Is it possible to achieve this with functions? I can't think of any way to run a function based on a dynamically constructed name since you can't have arrays of a function name. Unless you can somehow use strings or something to construct a name of a function then run it... or something...
And there's a crude way of doing it using if then else clauses, but then it gets really slow for the functions at the end.
You're doing it the only way possible. So keep doing so :)
@s3rius: Go One can always use a precompiler to... oh wait -_-
A X-to-Galaxy compiler will write that if-then-else block for you. If one existed (other than Andromeda, which I have ideological differences with).
@moshewe: Go
But if he really has a trigger[500] then this will be a looooooooooooooooooo (insert more o's here) ooong if-then-else.
And probably more efficient (albeit more memory consuming) to use triggers.
In theory trigger[500] should not be any much larger than int[500], as it's only storing a reference to a trigger (which is say different from a record array, which actually allocates your struct). I don't see it as any big memory hogger. The 500 triggers that you assign to it on the other hand...
@SexLethal: Go
Who says there has to be an if-then-else?
I use this method in my own Cortex Engine and there are no ifs.
Hell I don't even use an array anymore.
Just store your triggers in the data table, use a meaningful key for them, and then pull them out and execute them. Fairly simple, eh?
In the execution it'll look something like