Here's the problem. I want to have a character, Barbara, walk from door to door and offer to sell cookie dough. This is the code I have so far. The problem is that she will not walk to the next door after the first walk and the actions won't loop after they are done. I hope this is complicated enough for this forum.
function room_RepExec()
{
if(BarbaraPosition == "Selling"){
if(BarbaraSelling == false){
BarbaraSelling = true;
SetTimer(3, 120);
cBar.Walk(192, 130, eNoBlock);
}
if(IsTimerExpired(3)){
cBar.SayQueued("Hello citizen of Conroid! I have this wonderful cookie dough for sale.");
cBar.SayQueued("It's going to a great cause! This is to support the...");
cBar.SayQueued("Oh sorry boss. I forgot that I was getting this for the Steakhouse.");
cBar.SayQueued("I'll just be going now.");
SetTimer(1, 120);
cBar.Walk(268, 134, eNoBlock);
}
if(IsTimerExpired(1)){
cBar.SayQueued("Hey citizen of Conroid! I'm selling some great chocolate chip cookie dough!");
cBar.SayQueued("It's going to a cause you know. To save the Western Steak House.");
cBar.SayQueued("...");
cBar.SayQueued("No I won't except rat hides as currency! Your discusting Archabald!");
cBar.SayQueued("Goodbye!");
SetTimer(2, 240);
cBar.Walk(126, 131, eNoBlock);
}
if(IsTimerExpired(2)){
cBar.SayQueued("Hello mister. I would like to sell you some cookie dough to support a good cause.");
cBar.SayQueued("It's to save the Western Steak House.");
cBar.SayQueued("...");
cBar.SayQueued("Yes I understand your busy.");
cBar.SayQueued("Thanks anyway. Bye.");
BarbaraSelling = false;
}
}
}
Are you using timers 1, 2 or 3 anywhere else in your game?
When does the BarbaraPosition variable get changed?
I checked and I am not using any of those timers anywhere else. BarbaraPosition just checks were Barbara is in the game. In the restaurant, selling cookie dough, ect. Could the problem possibly be I'm using the queued speech module?
If the Queued Speech module also uses one of those timers, then it could be interfering with what you're trying to do.
Try using timer numbers 10, 11 and 12 instead of 1, 2 and 3 and see if that works.
Well it's looping now but she still won't walk.
I'm assuming you're using my QueuedSpeech module, yes?
The first thing I've done here Joel is that I've corrected the indentation. Sorry if I'm being blunt, but that was a mess. Another thing is that since you only want one of these if clauses run per execution, you could use else if...
And....I see what's happening. Even if Barbara doesn't have a speech view set, the module is still trying to animate her in her current loop. You want her to finish speaking the text in the queue, then walk, right? Try this...
int selling_step;
function room_RepExec()
{
if(BarbaraPosition == "Selling"){
if(BarbaraSelling == false){
BarbaraSelling = true;
SetTimer(3, 120);
cBar.Walk(192, 130, eNoBlock);
}
else if(IsTimerExpired(3)){
selling_step = 3;
cBar.SayQueued("Hello citizen of Conroid! I have this wonderful cookie dough for sale.");
cBar.SayQueued("It's going to a great cause! This is to support the...");
cBar.SayQueued("Oh sorry boss. I forgot that I was getting this for the Steakhouse.");
cBar.SayQueued("I'll just be going now.");
}
else if ((selling_step == 3) && (QueuedSpeech.IsQueueEmpty())) {
SetTimer(1, 120);
cBar.Walk(268, 134, eNoBlock);
}
else if(IsTimerExpired(1)){
selling_step = 1;
cBar.SayQueued("Hey citizen of Conroid! I'm selling some great chocolate chip cookie dough!");
cBar.SayQueued("It's going to a cause you know. To save the Western Steak House.");
cBar.SayQueued("...");
cBar.SayQueued("No I won't except rat hides as currency! Your discusting Archabald!");
cBar.SayQueued("Goodbye!");
}
else if ((selling_step == 1) && (QueuedSpeech.IsQueueEmpty())) {
SetTimer(2, 240);
cBar.Walk(126, 132, eNoBlock);
}
else if(IsTimerExpired(2)){
selling_step = 2;
cBar.SayQueued("Hello mister. I would like to sell you some cookie dough to support a good cause.");
cBar.SayQueued("It's to save the Western Steak House.");
cBar.SayQueued("...");
cBar.SayQueued("Yes I understand your busy.");
cBar.SayQueued("Thanks anyway. Bye.");
}
else if ((selling_step == 2) && (QueuedSpeech.IsQueueEmpty())) {
BarbaraSelling = false;
}
}
}
If you want her to walk around while she's talking that would require me to allow the module to not animate the character while speaking. Currently it animates no matter what. That's probably bad. :D Also, IIRC then Character.Say("...") would just create a pause right? I should bring back the AddDelay function for the queue.
I'm not too sure what the problem is but she keeps turning around in place. I messed around with the script some. Taking off the elses makes her stand in place and do nothing.
I think I was incrementing the step in the wrong spot. Try this and let me know how it goes (I just edited my above post).
I've got another problem. She walks in place at else if ((selling_step == 3) && (QueuedSpeech.IsQueueEmpty())) {
SetTimer(1, 120);
cBar.Walk(268, 134, eNoBlock);
}
I'll keep working on it. If you know the problem please help.
Also I am having a problem with the text. I thought it would just relate to the queued speech module so I posted it there.
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=23806.0
Well, when selling_step is 3 and the queue is empty, it will keep calling that block of script every time. You probably need to set selling_step to something else there so that it doesn't keep coming back round.
Ugh...that's what I get for not testing my code...and trying to work on it when I'm half awake.
I don't have time right now but I'll try to post something that actually works later.... :-[
OK. It's fixed. First I tried to move the selling step up each time but that wouldn't work because the queue is empty before the timer runs out. So I changed it to 0 before that. Here's the completed code.
int selling_step;
function room_RepExec()
{
if(BarbaraPosition == "Selling"){
if(BarbaraSelling == false){
BarbaraSelling = true;
SetTimer(3, 120);
cBar.Walk(192, 130, eNoBlock);
}
else if(IsTimerExpired(3)){
selling_step = 3;
cBar.SayQueued("Hello citizen of Conroid! I have this wonderful cookie dough for sale.");
cBar.SayQueued("It's going to a great cause! This is to support the...");
cBar.SayQueued("Oh sorry boss. I forgot that I was getting this for the Steakhouse.");
cBar.SayQueued("I'll just be going now.");
}
else if ((selling_step == 3) && (QueuedSpeech.IsQueueEmpty())) {
SetTimer(1, 120);
selling_step = 0;
cBar.Walk(268, 134, eNoBlock);
}
else if(IsTimerExpired(1)){
selling_step = 1;
cBar.SayQueued("Hey citizen of Conroid! I'm selling some great chocolate chip cookie dough!");
cBar.SayQueued("It's going to a cause you know. To save the Western Steak House.");
cBar.SayQueued("...");
cBar.SayQueued("No I won't except rat hides as currency! Your discusting Archabald!");
cBar.SayQueued("Goodbye!");
}
else if ((selling_step == 1) && (QueuedSpeech.IsQueueEmpty())) {
SetTimer(2, 240);
cBar.Walk(126, 132, eNoBlock);
selling_step = 0;
}
else if(IsTimerExpired(2)){
selling_step = 2;
cBar.SayQueued("Hello mister. I would like to sell you some cookie dough to support a good cause.");
cBar.SayQueued("It's to save the Western Steak House.");
cBar.SayQueued("...");
cBar.SayQueued("Yes I understand your busy.");
cBar.SayQueued("Thanks anyway. Bye.");
}
else if ((selling_step == 2) && (QueuedSpeech.IsQueueEmpty())) {
selling_step = 0;
BarbaraSelling = false;
}
}
}
Thanks for all the help.
Glad you got it sorted :)