LucasArts-style status line? (solved)

Started by JuuL, Fri 18/07/2008 12:19:41

Previous topic - Next topic

JuuL

Hi, I'm working on a game for this month's MAGS. I'm trying to make a LucasArts-style status line, but unfortunately I have almost no scripting skills.
I tried updating an obsolete code that I found at http://www.adventuregamestudio.co.uk/yabb/index.php?topic=14369.0 but I couldn't make it work. I figured out how to change the obsolete GetCursorMode to something that worked, but I didn't succeed at replacing the obsolete SetLabelText.
I also tried having a look at SSH's Description Module but that made no sense to me at all (as I said I really don't know much about scripting).
Anyway, I could really use some help here. Also, I forgot to update AGS before starting my new game so I'm still using version 2.72.

edit: Something else I need some help with: I need to make a few characters stand in the background talking while you're playing the game as usual. I know that I should probably write a Dialog and use the repeatedly_execute funtion in the script, but how do I make the dialog run in a loop and how do I avoid making it impossible to do anything while the dialog is on?

TwinMoon

#1
Status line:

What you do is you make a new GUI with a label on it. You give the label an appropriate name (gStatusline or something) and add this to the repeatedly_execute:

Code: ags

String location = Game.GetLocationName(mouse.x, mouse.y);
gStatusline.Text = location;


Talking in background:

SayBackground is the non-blocking version of Say. However, you can't use dialogs with it. I think using timers would be the easiest way. A construction like this: (also in rep_exe)

Code: ags

  if (IsTimerExpired(1) == 1) {
    cGuy.SayBackground("Well, there we are.");
    SetTimer(2, 40);
  }
  if (IsTimerExpired(2) == 1) {
    cOtherGuy.SayBackground("Yup.");
    SetTimer(3, 40);
  }


et cetera...

You'll have to juggle a bit with the amount of delay.

JuuL

Thanks for the help, TwinMoon. I think I begin to understand how this works.
However, I do have some problems with the code:

When trying to make the status line I get this error:
Error (line 14): cannot assign initial value to global pointer.
(Line 14 is the one saying String location = Game.GetLocationName(mouse.x, mouse.y);)

I also had some problems with the second code, but adding SetTimer(1, 1); to the beginning of finally made it work (but for some reason only with the value '1'). However, now I just have the first guy saying his line for a very long time - appearantly indefinately.

TwinMoon

Quote from: JuuL on Fri 18/07/2008 16:36:16
When trying to make the status line I get this error:
Error (line 14): cannot assign initial value to global pointer.
(Line 14 is the one saying String location = Game.GetLocationName(mouse.x, mouse.y);)

You can also just use:
Code: ags
gStatusline.Text = Game.GetLocationName(mouse.x, mouse.y);

instead of
Code: ags
String location = Game.GetLocationName(mouse.x, mouse.y);
gStatusline.Text = location;


I'm always using variables, but I guess it's not necessary here.


Quote from: JuuL on Fri 18/07/2008 16:36:16
I also had some problems with the second code, but adding SetTimer(1, 1); to the beginning of finally made it work (but for some reason only with the value '1'). However, now I just have the first guy saying his line for a very long time - appearantly indefinately.
Yes, I forgot that to start the dialog you have to make IsTimerExpired be true, which you do by putting SetTimer(1,1);

I think the problem is that put SetTimer(1,1) in the repeatedly_execute, so it will be set to true every game cycle.
Move it to room_Load and it should be fine.

SetTimer(2,40) by the way means that the game will wait 40 game loops (about one second) before the second timer gets set to true (or 1).

JuuL

Thanks again, TwinMoon.
After a few difficulties the background conversation works perfectly - I have a nice little loop running now. I even figured out how to make the game run the talk animatin (which it appearantly doesn't do automatically with SayBackground).
But I haven't been able to solve the problem with the status line. With the first method I get the same problem as before and with the second method i get '.Text' is not a member a public member of 'GUI'. Are you sure you spelt it correctly (remember, capital letters are important)?[(i] Any ideas about how to solve that?

Lt. Smash

'.Text' is not a public member of 'GUI'. Are you sure you spelt it correctly (remember, capital letters are important)?
The error message is self-explanatory.
It means that you can't set a .Text for a GUI. If you want to display text on a gui, you first have to create a label (its name normally starts with lbl...) and then use Label.Text.

after creating lblStatusline you can use
Code: ags

lblStatusline.Text = Game.GetLocationName(mouse.x, mouse.y);

in repeatedly_execute.

JuuL

Thanks, Lt. Smash. It finally works now.

SMF spam blocked by CleanTalk