str_width - video not available??

Posted By: 3run

str_width - video not available?? - 05/07/13 09:48

I use 'str_width' to get the width of the displayed string.. I use it in the main function, and I don't load any levels, but why do I get this error??
Quote:
Malfunction W1507: Video functions not available before first frame
I know how can I fix this, but I'm just curios, why does 'str_width' cause this problem?
Posted By: Superku

Re: str_width - video not available?? - 05/07/13 09:51

I am not sure but maybe str_width is calling a DirectX function and thus the error is thrown.
Posted By: 3run

Re: str_width - video not available?? - 05/07/13 09:58

Maybe, I don't know.. But anyway, this looks strange at the first place to me. And it should had something about this in the manual I guess.



Greets
Posted By: joao13pt

Re: str_width - video not available?? - 05/07/13 19:47

The manual in GameStudio has many flaws and LOTS of things aren't described the way they should be, most times i have to google something that the manual should explain
In my experienci, whenever that error ocurred in my scripts i just added a wait(1); to wait 1 frame before the line that was causing this error. So, if it has something to do with the video it may have something to do with DirectX, like Superku said
try googling "lite-c str_width" and search around some websites
Posted By: MasterQ32

Re: str_width - video not available?? - 05/07/13 19:51

Lite-C (and other engines) use DirectX to check how wide a text is. But for this you need a DirectX device so just wait until total_frames is higher than 0 before calling wait(1);
Posted By: 3run

Re: str_width - video not available?? - 05/07/13 19:59

ok, it's clear now, thank you all.
Posted By: PadMalcom

Re: str_width - video not available?? - 05/08/13 06:57

I had the same issue and I prefer MasterQ32's solution:

while(total_frames < 1) wait(1);
© 2024 lite-C Forums