I learned, right in the beggining, that 'while' instructions tak up more processing than 'if' ones.
In any structure logic, one single 'while' loop calling several functions with 'if' and 'else' statements would take the same amount of time as several 'while' inside various functions, simply because the engine will take a simple frame cicle trought all instructions, and the only difference is that the engine will keep repetaing the 'while', but not the 'if'.
All i wanted to know is if there is a difference in SPEED between several 'while' against only one 'while' and several 'if', but because of the engine structure, NOT code logic.
About the wait(1): remember, this is WDL code and all 'while' need a 'wait(1)' at the end.
let me try being more clear:
Which following function is faster? 'Firstfunction()', or 'functioncaller()'?
Function Firstfunction()
{
While(1){
item_handle.roll +=1*time_step; //rotates item_handle
wait(1);
}
While(item_handle.skill1 != 0)
{
item_handle.pan +=1*time_step; //rotates item_handle
wait(1);
}
While(item_handle.skill1 == 2)
{
item_handle.tilt +=1*time_step; //rotates item_handle
wait(1);
}
While(item_handle.skill1 == 3)
{
item_handle.x +=1*time_step; //moves item_handle
wait(1);
}
}
Second option:
Function Secondfunction()
{
if(item_handle.skill1 != 0)
{
item_handle.pan +=1*time_step; //rotates item_handle
}
if(item_handle.skill1 == 2)
{
item_handle.tilt +=1*time_step; //rotates item_handle
}
if(item_handle.skill1 == 3)
{
item_handle.x +=1*time_step; //moves item_handle
}
wait(1);
}
Function function_caller
{
while(1)
{
Secondfunction();
Thirdfunction();
Fourthfunction();
wait(1);
}
}