ok, So I am trying to make an FMV game, and this is the very beginnings of my script.
I have a SetTimer function, but it is not changing rooms after the timer is over. any suggestions? Thanks!
// room script file
Theora* video;
float rot = 0.0;
function repeatedly_execute_always() {
if(video) {
video.DrawEx(DsBackground, 160.0, 120.0, 2.0, 1.0, 4.0, RtScreen);
if(System.HardwareAcceleration) video.DrawEx(DsScene, 260.0, 120.0, 0.25, 0.25, rot, RtScreen);
video.NextFrame();
rot += 0.2;
}
}
function room_Load() {
Display("Welcome to Joshua's Interactive movie test!");
}
function TVstand_AnyClick()
{
SetTimer(1, 160);
video = Theora.Open("josh.theora.ogg");
video.loop = false;
SetGameSpeed(24); // you don't need to use the same fps as the video like this, but it's easiest this wa
cjosh.Walk(213, 160, eBlock, eWalkableAreas);
bool loop; // enable/disable automatic looping
}
function room_AfterFadeIn()
{
{
PlaySound(1);
PlayMusic(1);
{
if (IsTimerExpired(1)) {
cjosh.ChangeRoom(2);}
}
}
The IsTimerExpired check should be in repeatedly_execute_always, not room_AfterFadeIn.
also, display is a blocking function and shouldnt be done in room_load.
Ah! I see...When I put it under Repeatedly_execute_always, it gives me an engine error which states:
"This command cannot be used within non-blocking events such as repeatedly_execute_always.
After the movie is up, I want AGS to shift rooms so I can have another interactive screen.
Here is the effect I am trying to acheive:
http://www.youtube.com/watch?v=T3gPKvO6kwI&feature=related
Ah yes, please try repeatedly_execute() instead of repeatedly_execute_always()
Thanks to the both of you, HOWEVER, an issue remains.
It stays on Room 1. Does not make the switch @ all.
To check whether a certain piece of code is called at all, put a Display command in there.
Is cjosh the player character?
Try player.ChangeRoom(2); instead.
DUH! sorry I just did a brain dump.
*FACEPALM*
And I tried Player.ChangeRoop(2); yet, to no avail.
I tried putting a display command in, and it turns out the code isnt being read? What now?
You know, I wonder if you even need a timer. I'm not at all familiar with the theora module, but looking at the documentation I think you could do something like this, if you want the end of the video to be the event triggering room change:
function repeatedly_execute_always() {
if(video) {
if (video.ended) player.ChangeRoom(2); // <---- Added this line
video.DrawEx(DsBackground, 160.0, 120.0, 2.0, 1.0, 4.0, RtScreen);
if(System.HardwareAcceleration) video.DrawEx(DsScene, 260.0, 120.0, 0.25, 0.25, rot, RtScreen);
video.NextFrame();
rot += 0.2;
}
}
Wow! :)
I appreciate your input. :)
I do have a question though, should I rename (VIDEO.ended) to my file name?
No, you've declared "video" as a pointer to a member of the Theora class, and already defined it as pointing to your ogg file in the line "video = Theora.Open("josh.theora.ogg");", so you shouldn't rename it, most likely you would just get an error message.
I'm not very good at explaining technical stuff - try looking up "Pointers in AGS" and "Pointers for programming newbies" (no really, that's the title of the section, not an insult :)) in the manual for a more thorough overview.
;D
No insult taken bud. lol
I understand that concept now, however, I am STILL unable to change rooms!! lol
This is gonna bug me. :P
If you want to take a look, here is my ORIGINAL script before your revisions.
// room script file
Theora* video;
float rot = 0.0;
function repeatedly_execute_always() {
if(video) {
video.DrawEx(DsBackground, 160.0, 120.0, 2.0, 1.0, 4.0, RtScreen);
if(System.HardwareAcceleration) video.DrawEx(DsScene, 260.0, 120.0, 0.25, 0.25, rot, RtScreen);
video.NextFrame();
rot += 0.2;
}
}
function room_Load() {
Display("Welcome to Joshua's Interactive movie test!");
}
function TVstand_AnyClick()
{
TVstand.Enabled = false;
video = Theora.Open("josh.theora.ogg");
video.loop = false;
SetGameSpeed(24); // you don't need to use the same fps as the video like this, but it's easiest this wa
cjosh.Walk(213, 160, eBlock, eWalkableAreas);
bool loop; // enable/disable automatic looping
SetTimer(1, 160);
}
function room_AfterFadeIn()
{
{
PlaySound(1);
PlayMusic(1);
}
}
function repeatedly_execute()
{
if (IsTimerExpired(1)){
TVstand.Enabled = true;}
player.ChangeRoom(2);
}
What is strange is that you say the player doesn't change rooms, because as its currently written, this piece of code should send him to room 2 every game loop.
function repeatedly_execute()
{
if (IsTimerExpired(1)){
TVstand.Enabled = true;}
player.ChangeRoom(2);
}
If I don't misunderstand the intention, I think it should have been
function repeatedly_execute()
{
if (IsTimerExpired(1)){
TVstand.Enabled = true;
player.ChangeRoom(2);
}
}
So, what I'm wondering is whether your rep_exec script is running at all. I seem to remember something about repeatedly_execute() not working if simply added to the script. Try adding a room event (yellow lightening bolt icon) in the room editor and choose Repeatedly Execute, then place your code in the auto-generated function and see if it works now.
I was just about to post this, GG is correct.
Adding repeatedly_execute() will only work for global scripts, not room scripts.
YES!!!!
Thank you! But as I'm guessing will be VERY common in game design, I have a NEW problem. :P
EDIT: BUT I think I may be able to address the issue with a pointer. :)