Damn I just bump into these things :P
Anyway I have timed this figure so it would blink images in a certain time:
(btw this works fine, it's for a comparison to my faulty code)
function light_change()
{
while(1)
{
//It also works whn I'd use If statements, but switch is something I don't use all the time and decided to do it here :P
switch (active)
{
case 0: //if active = 0
if (p_tele_light.bmap == lgt_out) //Blink
{
p_tele_light.bmap = lgt_red;
}else{
p_tele_light.bmap = lgt_out;
}
break;
default: //basically if active = 1
p_tele_light.bmap = lgt_active;
}
wait(-0.2); //Delay, which works!
}
}
//this is called in main() like so:
function main()
{
[...]
level_load(""); // load an empty level
wait(2);
light_change(); //Working delay function!
while(1) //that while loop
{
[...] //Other stuff here...
}
}
So this works. But I tried to do delay similar to this and it won't work:
function shoot()
{
while (mouse_left)
{
if ((gun[g_type][1] > 0))
{
[...]
}
wait(-5); //Trying to delay that while, thus when holding mouse_left I'd get intervals for about 5 seconds...
}
}
//In function main().
Well it's more difficult. If I'd
place it next to my earlier light_change() it wouldn't work at all, I think it has something to do with "mouse_left detection". Engine won't update it because out of somekind update... :P
If I'd place it into main()'s "while loop", the delay won't give delay. It happens like it would be "while (1)".Another might be that light_change() has "else statement" which makes the active variable check longer because when in 1.step "active = 0" and suddenly in that step "active = 1" then it takes one whole step to recheck that value to go into else.
I'm not sure which is the case. I have tested it in many ways.
How to work around it? How to get that delay with mouse_left == 1..
Hope I have given enough info...
LiteC Free btw.