Thanks i'll give it a try

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
@15
Bibl:Lo si incontra spesso in giro mentre vaga senza meta leggendo un libro...
Bibl:... con un' espressione da suicidio...
CDG.scroll_from =0;
return
Quote from: monkey_05_06 on Mon 29/12/2014 09:03:30
There are three major problems I see with your code.
Problem 1: You believe that whitespace in code is evil. While it can be overdone, unless your mission statement is to have no one ever see, read, use, or understand your code, then whitespace is a must. As a general rule of thumb, if you're putting more than one command on a single line, you're probably doing it wrong.Code: ags int dialoghi = 0; function room_RepExec() { if (BISTICCIO) { if (dialoghi == 0) { cbibl.LockView(43); cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards); cbibl.SayBackground("asdas"); SetTimer(1, 80); SetTimer(2, 60); dialoghi++; } if (IsTimerExpired(2)) { cbibl.UnlockView(); SetTimer(1, 20); } if (dialoghi == 1 && IsTimerExpired(1)) { cbibl.LockView(43); cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards); cbibl.SayBackground("asdas"); SetTimer(1, 80); SetTimer(2, 60); dialoghi++; } if (dialoghi == 2 && IsTimerExpired(1)) { cbibl.LockView(43); cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards); cbibl.SayBackground("asdas"); SetTimer(1, 80); SetTimer(2, 60); dialoghi++; } if (dialoghi == 3 && IsTimerExpired(1)) { cbibl.LockView(43); cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards); cbibl.SayBackground("asdas"); SetTimer(1, 80); SetTimer(2, 60); dialoghi++; } if (dialoghi == 4 && IsTimerExpired(1)) { cbibl.LockView(43); cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards); cbibl.SayBackground("asdas"); SetTimer(1, 80); SetTimer(2, 60); dialoghi++; } if (dialoghi == 5 && IsTimerExpired(1)) { cbibl.LockView(43); cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards); cbibl.SayBackground("asdas"); SetTimer(1, 80); SetTimer(2, 60); dialoghi++; } if (dialoghi == 6 && IsTimerExpired(1)) { cbibl.LockView(43); cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards); cbibl.SayBackground("asdas"); SetTimer(1, 80); SetTimer(2, 60); dialoghi++; } if (dialoghi == 7 && IsTimerExpired(1)) { cbibl.LockView(43); cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards); cbibl.SayBackground("asdas"); SetTimer(1, 80); SetTimer(2, 60); dialoghi++; } if (dialoghi == 8 && IsTimerExpired(1)) { cbibl.LockView(43); cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards); cbibl.SayBackground("asdas"); SetTimer(1, 80); SetTimer(2, 60); dialoghi++; } if (dialoghi == 9 && IsTimerExpired(1)) { cbibl.LockView(43); cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards); cbibl.SayBackground("asdas"); SetTimer(1, 80); SetTimer(2, 60); dialoghi++; } if (dialoghi == 10 && IsTimerExpired(1)) { cbibl.LockView(43); cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards); cbibl.SayBackground("asdas"); SetTimer(1, 80); SetTimer(2, 60); dialoghi++; } if (dialoghi == 11 && IsTimerExpired(1)) { cbibl.LockView(43); cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards); cbibl.SayBackground("asdas"); SetTimer(1, 80); SetTimer(2, 60); dialoghi++; } if (dialoghi == 12 && IsTimerExpired(1)) { cbibl.LockView(43); cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards); cbibl.SayBackground("asdas"); SetTimer(1, 80); SetTimer(2, 60); dialoghi++; } if (dialoghi == 13 && IsTimerExpired(1)) { dialoghi = 0; } } }
Problem 2: You're breaking one of the first rules of programming: DO NOT repeat yourself. You have the following six lines of code repeated thirteen times:Code: ags cbibl.LockView(43); cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards); cbibl.SayBackground("asdas"); SetTimer(1, 80); SetTimer(2, 60); dialoghi++;
There is no excuse for copypasta like this showing up in your code. If necessary, create a separate function. In your case, however, it's a matter of...
Problem 3: Abusing conditional statements.
If you are checking the same condition (e.g., IsTimerExpired(1)) several times when you have no logical reason to believe that the result may have changed in-between, then you are doing it wrong. If you find yourself checking multiple values of a variable as separate conditions with the same end-result, then you are doing it wrong. If you are checking that a variable value falls within a certain range by using multiple equals checks, then you are doing it wrong.
Here is a more realistic example of what your above code should look like:Code: ags int dialoghi = 0; function room_RepExec() { if (BISTICCIO) { if ((dialoghi == 0) || (IsTimerExpired(1))) // this is SLIGHTLY redundant (if dialoghi is 0), but it saves us duplicating other code { if ((dialoghi >= 0) && (dialoghi < 13)) // 0 <= dialoghi < 13 { // note these lines aren't duplicated 13 times! cbibl.LockView(43); cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards); cbibl.SayBackground("asdas"); SetTimer(1, 80); SetTimer(2, 60); dialoghi++; } else if (dialoghi == 13) // ONLY if the previous condition was FALSE, then check this one { dialoghi = 0; } } // has timer 1 expired if (IsTimerExpired(2)) // no ELSE, we want to check timer 2 whether timer 1 has gone off or not { cbibl.UnlockView(); SetTimer(1, 20); } } }
I realize you are probably fairly new to programming, so please don't take this the wrong way. However, if you look at the expanded version of your code (Problem 1) and compare it to the final version (Problem 3), you'll see that I've cut over 77% of the lines while still maintaining readable code. The benefits of basic programming concepts like these speak for themselves.
As to your actual solution, there isn't really anything that could be done much more eloquently in terms of getting the speech animation to play for background speech aside from making the code more generic*. I've authored a few modules (QueuedSpeech, PersistentSpeech) that manually control the speech animation in-sync with non-standard character speech (e.g., not a blocking Say command). If you're interested, you could look at those modules, or else myself (and others) would be able to show you how to pull that particular feature and use it in your game, but I first feel that it is more important that you understand these more basic programming concepts. Once you have a strong grasp on the basics, then branching out into more advanced topics will be within your reach.
*And for what it's worth, generic programming isn't always simpler, cleaner, or more eloquent than a specialized solution. Instead, I mean that generic code would be more versatile, easily applied to other characters in other situations, adapt to variable game speed, text reading speed, and the like.
Edit: Looking back over this, I realized that the dialoghi == 0 condition actually doesn't depend on the timer, which is what sets everything else in motion. I amended my modified code to reflect this. Again, there are other ways you could accomplish that result, but this is effective enough to show what I am talking about.
Quote from: Monsieur OUXX on Sun 28/12/2014 22:44:52thanks i will take a look
I don't know exactly what's wrong with your code, but the "queued background speech" module (s) should make your life much easier.
This one : QueuedSpeech v3.5 here
Or that one : BgSpeech v2.2 here
int dialoghi=0;
function room_RepExec()
{
if (BISTICCIO==true){
if (dialoghi==0){cbibl.LockView(43);cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards);cbibl.SayBackground("asdas");SetTimer(1,80);SetTimer(2, 60);dialoghi++;}
if (IsTimerExpired(2)){cbibl.UnlockView();SetTimer(1, 20);}
if (dialoghi==1&&IsTimerExpired(1)){cbibl.LockView(43);cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards);cbibl.SayBackground("asdas");SetTimer(1,80);SetTimer(2, 60);dialoghi++;}
if (dialoghi==2&&IsTimerExpired(1)){cbibl.LockView(43);cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards);cbibl.SayBackground("asdas");SetTimer(1,80);SetTimer(2, 60);dialoghi++;}
if (dialoghi==3&&IsTimerExpired(1)){cbibl.LockView(43);cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards);cbibl.SayBackground("asdas");SetTimer(1,80);SetTimer(2, 60);dialoghi++;}
if (dialoghi==4&&IsTimerExpired(1)){cbibl.LockView(43);cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards);cbibl.SayBackground("asdas");SetTimer(1,80);SetTimer(2, 60);dialoghi++;}
if (dialoghi==5&&IsTimerExpired(1)){cbibl.LockView(43);cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards);cbibl.SayBackground("asdas");SetTimer(1,80);SetTimer(2, 60);dialoghi++;}
if (dialoghi==6&&IsTimerExpired(1)){cbibl.LockView(43);cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards);cbibl.SayBackground("asdas");SetTimer(1,80);SetTimer(2, 60);dialoghi++;}
if (dialoghi==7&&IsTimerExpired(1)){cbibl.LockView(43);cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards);cbibl.SayBackground("asdas");SetTimer(1,80);SetTimer(2, 60);dialoghi++;}
if (dialoghi==8&&IsTimerExpired(1)){cbibl.LockView(43);cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards);cbibl.SayBackground("asdas");SetTimer(1,80);SetTimer(2, 60);dialoghi++;}
if (dialoghi==9&&IsTimerExpired(1)){cbibl.LockView(43);cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards);cbibl.SayBackground("asdas");SetTimer(1,80);SetTimer(2, 60);dialoghi++;}
if (dialoghi==10&&IsTimerExpired(1)){cbibl.LockView(43);cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards);cbibl.SayBackground("asdas");SetTimer(1,80);SetTimer(2, 60);dialoghi++;}
if (dialoghi==11&&IsTimerExpired(1)){cbibl.LockView(43);cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards);cbibl.SayBackground("asdas");SetTimer(1,80);SetTimer(2, 60);dialoghi++;}
if (dialoghi==12&&IsTimerExpired(1)){cbibl.LockView(43);cbibl.Animate(0, 6, eRepeat, eNoBlock, eForwards);cbibl.SayBackground("asdas");SetTimer(1,80);SetTimer(2, 60);dialoghi++;}
if (dialoghi==13&&IsTimerExpired(1)){dialoghi=0;}
}
}
Quote from: Cassiebsg on Thu 18/12/2014 22:48:33
You can add the code at the start like this:Code: ags // Dialog script file @S // Dialog startup entry point cUomobar.LockView(33); cDonnabar.LockView(53); return @1 Uomobar:sdfsdfs sdgfsdfsdf sdf sdfgsdfgsdfgs sdgf sdgsdgsdfgs return @2 // exit option Uomobar: Goodbye... cUomobar.UnlockView(); cDonnabar.UnlockView(); stop
You can also do this:Code: ags function cUomobar_Interact() { cUomobar.LockView(33); cDonnabar.LockView(53); dUomobar.Start(); }
And unlock the view inside the dialog... or you can check if the exit option (2) of the dialog has been chosen and if so, then unlock the view.
I would put the code inside the dialog. But maybe someone else has a better suggestion for you.
Quote from: Cassiebsg on Thu 18/12/2014 22:08:20
May I ask what you are trying to do?
If dialog is running and you want something to happen, then your best bet is the just add the commands inside the dialog, if you want some BG stuff going at the same time it's a bit more complex (I don't know exactly how, but do a forum search. It has been answered not too long along... this week I believe).
As for when the dialog is stopped, I normally check for a particular dialog option and to see if it has been selected, but there's about (at least) 3 different ways to check for dialog ending.
// Dialog script file
@S // Dialog startup entry point
return
@1
cUomobar.LockView(33);
cDonnabar.LockView(53);
Uomobar:sdfsdfs sdgfsdfsdf sdf sdfgsdfgsdfgs sdgf sdgsdgsdfgs
cUomobar.UnlockView();
cDonnabar.UnlockView();
stop
if (dPlayer is running) {
do some stuff}
or if (dPlayer is stopped){
do other stuff}
Quote from: abstauber on Tue 09/12/2014 09:08:39sorry, you're right.
From time to time you should utilize the search function
http://www.adventuregamestudio.co.uk/forums/index.php?topic=39407.msg636496285#msg636496285
Quote from: abstauber on Tue 09/12/2014 09:20:41i'll give it a try, thanks
sorry, it seems like I misunderstood what you wanted.
I don't think it's possible to change the frame, once AGS automatically changes the view. But I'm not 100% sure.
A way I can think of is to use two characters as one. One "character" is the body and the other "character" only shows the head and follows the body-character exactly.
Quote from: abstauber on Mon 08/12/2014 14:55:40the module works fine thanks, for aeronuts where i can find the sourcecode?
But you have to admit that now all topics are being shown
This module can provide scrolling dialogs, but it takes some time to get used to it.
http://www.adventuregamestudio.co.uk/forums/index.php?topic=36313.0
I'm also using a scumm style scrolling dialog GUI in AeroNuts, which has been open-sourced.
Quote from: abstauber on Sun 07/12/2014 08:42:50
Yes there's is way but it involves somewhat advanced custom dialog scripting.
For starters you can do remove the current GUI to get AGS' default behavior.
In "General Settings" under "Dialog" set "Use GUI for dialog options" to 0. That way the dialog box scales up to show all the topics.
Quote from: abstauber on Sun 07/12/2014 08:50:17
Have you tried this?Code: ags player.ChangeView(THEVIEW); player.loop = 2; player.frame = 4;
But I'm not sure if the loop is reset to 0 if you change the view. So if that happens, you need to save the frame first:Code: ags int temp_frame = player.frame; player.ChangeView(THEVIEW); player.frame = temp_frame;
int temp;
function room_RepExec()
{temp=cMelvin.Frame;
if (cMelvin.SpeechView==50){cMelvin.Frame=temp;}//50 is the thespeechview
}
Quote from: abstauber on Sun 07/12/2014 22:02:03
For this you need to activate "Run game loops while dialog options are displayed". You'll find it in General Settings.
Then you need to add the function repeatedly_execute_always() manually to the script and add those cloud moving lines thereCode: ags function repeatedly_execute_always() { if (IsTimerExpired(4)) { ocloud.X=ocloud.X - 1; SetTimer(4, 20); } if (IsTimerExpired(5)) { ocloud1.X=ocloud1.X - 1; SetTimer(5, 20); } }
function room_RepExec()
{
if (IsTimerExpired(4)){ocloud.X=ocloud.X - 1;SetTimer(4, 20);}
if (IsTimerExpired(5)){ocloud1.X=ocloud1.X - 1;SetTimer(5, 20);}
}
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.085 seconds with 14 queries.