LucasArts style status bar

Started by Erica McLane, Mon 26/05/2003 13:43:21

Previous topic - Next topic

Erica McLane

Easier way to create the Lucas Arts status line by TK
-----------------------------------------------
Bad link removed by Scummbuddy
----------------------------------------------
Upload of code
-------------------------------------------
I posted this here beacuse those new AGSers who come to ask how to get the LEC statusline to work. The LEC GUI that comes with AGS uses scritp like this:

if (GetLocationType(mouse.x,mouse.y)>0) { // or whatever like that
GetLocationName(mouse.x,mouse.y);
//someting
SetLabelText(0,0,"Walk to...");
}

etc.

But I found an easier way. I dont know how many people have thought of this, and if this is allready posted somewhere in the forum, but anyway:

All the GetThisAt and GetThatName can be replaced with @OVERHOTSPOT@, right?

So, make a new GUI, put it where you want the statusline to be, create a label on it and set the size and position. (In this script the statusline is GUI 0 and the label is object 0.)

Then, put into the global script repeadetly execute function: (add teh stuff beween the line starting "function" and the last })

function repeadetly_execute() {
// the comment line here
if (GetCursorMode()==0) SetLabelText(0,0,"Walk to @OVERHOTSPOT@")
if (GetCursorMode()==1) SetLabelText(0,0,"Look at @OVERHOTSPOT@")
if (GetCursorMode()==2) SetLabelText(0,0,"Interact with @OVERHOTSPOT@")
if (GetCursorMode()==3) SetLabelText(0,0,"Talk to @OVERHOTSPOT@")
if (GetCursorMode()==4) {
string usinginv;
string useinvtxt;
StrCopy (useinvtxt, "Use ");
GetInvName(character[GetPlayerCharacter()].activeinv,usinginv);
StrCat (useinvtxt,usinginv);
StrCat (useinvtxt," with ");
StrCat (useinvtxt,"@OVERHOTSPOT@");
SetLabelText(0,0,useinvtxt);
}
}

Quote:
StrCat (useinvtxt,usinginv);
StrCat (useinvtxt," with ");
StrCat (useinvtxt,"@OVERHOTSPOT@");



Is because when there is no hotspot or char under the mouse, it says "Use XXX with ". This can ofcourse be changed very easy:

StrCat (useinvtxt,usinginv);
StrCat (useinvtxt," with @OVERHOTSPOT@");

Would make it say just the "Use XXX".

Sorry if I cause any trouble to ya all nice moderators, but this just popped into my head and I couldn't hold it all just by myself.

THIS CODE CAN BE USED BY ANYBODY WHO NEEDS, in case it works.

BlackMan890

where in the global script am i suposed to put this?
(very n00b question) and what do you mean by:

Quote from: Erica McLane on Mon 26/05/2003 13:43:21
(add teh stuff beween the line starting "function" and the last })
???
Jonatan Nilsson
860 Iceland

Please go to www.simnet.is/elinnils52 and download my non ags/adventure game :)

Ishmael

Find the line

function repeadetly_execute() {


In your Global Script, then add

  if (GetCursorMode()==0) SetLabelText(0,0,"Walk to @OVERHOTSPOT@")
  if (GetCursorMode()==1) SetLabelText(0,0,"Look at @OVERHOTSPOT@")
  if (GetCursorMode()==2) SetLabelText(0,0,"Interact with @OVERHOTSPOT@")
  if (GetCursorMode()==3) SetLabelText(0,0,"Talk to @OVERHOTSPOT@")
  if (GetCursorMode()==4) {
    string usinginv;
    string useinvtxt;
    StrCopy (useinvtxt, "Use ");
    GetInvName(character[GetPlayerCharacter()].activeinv,usinginv);
    StrCat (useinvtxt,usinginv);
    StrCat (useinvtxt," with ");
    StrCat (useinvtxt,"@OVERHOTSPOT@");
    SetLabelText(0,0,useinvtxt);
  }


just before the last } in that function, in case your rep_ex is empty, it'll be just below the line starting with // inside the repeadetly_execute.

And, for a side not, if you haven't read the scripting tutorials yet, read them now. In the Manual -> Text Scripting IIRC.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

BlackMan890

Thanks but there is a catch cause there comes an error:

There was an error compiling your script, the proplem was in 'main script';

ERROR (line 13): Expected ';'

do you want to....

This is in my script:

13  if (GetCursorMode()==0) SetLabelText(0,0,"Walk to @OVERHOTSPOT@")
14  if (GetCursorMode()==1) SetLabelText(0,0,"Look at @OVERHOTSPOT@")
15  if (GetCursorMode()==2) SetLabelText(0,0,"Interact with @OVERHOTSPOT@")
16  if (GetCursorMode()==3) SetLabelText(0,0,"Talk to @OVERHOTSPOT@")
17  if (GetCursorMode()==4) {
18    string usinginv;
19    string useinvtxt;
20    StrCopy (useinvtxt, "Use ");
21    GetInvName(character[GetPlayerCharacter()].activeinv,usinginv);
22    StrCat (useinvtxt,usinginv);
23    StrCat (useinvtxt," with ");
24    StrCat (useinvtxt,"@OVERHOTSPOT@");
25    SetLabelText(0,0,useinvtxt);
26  }

Why does this happens?
Jonatan Nilsson
860 Iceland

Please go to www.simnet.is/elinnils52 and download my non ags/adventure game :)

Proskrito

#4
here is another similar way:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=15585.0#msg191420

EDIT: sorry for not reading everything, just add ';' at the end of lines 13-16

Ishmael

#5
I'm sure they were there originally, they've just gone missing at some point. Add the ;'s and it should work.

(This is one of those days I wish I would moderate a tech board...)
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Edwin Xie

I get something saying:

---------------------------
Adventure Game Studio
---------------------------
An error has occured. Please contact the game author for support, as this
is likely to be a scripting error and not a bug in AGS.
(ACI version 2.61.747)

(Global script line 23)
Error: GetInvName: invalid inventory item specified

---------------------------
OK   
---------------------------
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Ishmael

You have

GetInvName(character[GetPlayerCharacter()].activeinv,usinginv);

on line 23? It should be ok, but if you get an error, you'r Player character's activeinv variable is probably set to an invalid number... somehow...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Edwin Xie

I tried before and it worked perfectly. Name some reasons that could be possible.
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Ishmael

That if condition is supposed to be let run only when an inventory item hsa been selected. You sure your script does not set the character's activeinv number to something invalid at some point, or set the inv cursor mode before an inventory item is selected?
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Edwin Xie

if I replace the badcode with the exact same thing it works
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Phemar


Just thought I'd let someone know. This script:
  if (GetCursorMode()==0) {
    SetLabelText (MAINGUI, 13, "WALK TO @OVERHOTSPOT@");
    }
  else if (GetCursorMode()==1) {
    SetLabelText (MAINGUI, 13, "LOOK AT @OVERHOTSPOT@");
    }
  else if (GetCursorMode()==2) {
    SetLabelText (MAINGUI, 13, "USE @OVERHOTSPOT@");
    }
  else if (GetCursorMode()==3) {
    SetLabelText (MAINGUI, 13, "TALK TO @OVERHOTSPOT@");
    }
  else if (GetCursorMode()==4) {
    GetInvName (player.activeinv, inventory);
    StrFormat (buffer, "Use %s with @OVERHOTSPOT@", inventory);
    SetLabelText (MAINGUI, 13, buffer);
    }
  else if (GetCursorMode()==5) {
    SetLabelText (MAINGUI, 13, "PICK UP @OVERHOTSPOT@");
    }
  else if (GetCursorMode()==6) {
    SetLabelText (MAINGUI, 13, "CLICK");
    }
  else if (GetCursorMode()==7) {
    SetLabelText (MAINGUI, 13, "WAIT...");
    }
  else if (GetCursorMode()==8) {
    SetLabelText (MAINGUI, 13, "OPEN @OVERHOTSPOT@");
    }

It works fine, except the hotspot isn't shown while the click is being processed. Instead you should use this script:
  string bunky;string texty; int cursy;
  StrCopy (texty, "");
  cursy=GetCursorMode();
  if (cursy==0){
    StrCat(texty,"Walk to ");}
  else if (cursy==1) {
    StrCat (texty,"Look at ");}
  else if (cursy==2) {
    StrCat(texty,"Use ");}
  else if (cursy==3) {
    StrCat(texty,"Talk to ");}
  else if (cursy==4) {
    StrCat(texty,"Use ");
    GetInvName (player.activeinv, bunky);
    StrCat(texty,bunky);
    StrCat(texty," with ");}
  else if (cursy==5) {
    StrCat(texty, "Pick up ");}
  else if (cursy==8) {
    StrCat(texty, "Open ");}
  GetLocationName(mouse.x,mouse.y,bunky);
  StrCat(texty,bunky);
  SetLabelText (MAINGUI,13,texty);

This updates the hotspot even while the mouse click is being processed.

I hope I'm not being dumb or nothing...

Edwin Xie

#12
Thanks....but can you replace cursy, texty and bunky with something else?
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Edwin Xie

#13

Strange..after I put Zoraphus's Script in it shows this error:

---------------------------
Compile Error
---------------------------
There was an error compiling your script. The problem was in 'Main script':



Error (line 30): Nested functions not supported (you may have forgotten a closing brace)



Do you want to fix the script now? (Your game has not been saved).
---------------------------
YesÃ,  Ã, NoÃ,  Ã, 
---------------------------

Nevermind, Zoraphus forgot the closing brace
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Phemar


Ah, silly me and those braces ... And recently I just had mine taken off.

Of course you can change those cursy thingamabobs as long as you change every occurence of it in your script.
I'm just weird when it comes to naming my data types...

BTW I use a selection of cursors in my game, so if you want to use this in a sierra-type game, you should take away the
if (cursy==5) {
  blablabla}
if (cursy==8) {
  blablabla}


- Cheers

monkey0506

QuoteIt works fine, except the hotspot isn't shown while the click is being processed.

Zoraphus has a good point. Also, for definition of the "right-click mode" as in Proskrito's templates where you can add, for example, ">g" to the end of a hotspot/char/inv item/object name to run the script for give on a right click, you have to use something where you can remove the ">g" extension. So, I would definitely say it's better to use GetLocationName...

Ishmael

I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

six_plus_one

Okay, question.

GetInvName(character[GetPlayerCharacter()].activeinv,usinginv);

...requires that you have set an active inventory item, as evidenced by the error message ("Error: GetInvName: invalid inventory item specified") that you get when no active iventory item is set and you switch to the cursor mode corresponding to that line, right?

Well, to avoid crashing my game, I have set up the inventory part of my script as follows:

function show_inventory_window () {
GUIOn (INVENTORY);
SetActiveInventory(1);
SetCursorMode (MODE_USE);
SetMouseCursor (6);
SetInvDimensions(22,22);
}

...But now I need to make sure that one cannot open the inventory window before they have an inventory item in order to avoid the error message:

"Error: SetActiveInventory: player doesn't have any of that inventory."

My question is: What would the script be to disable the inventory button in the GUI when the player has no inventory items? Is there a non-scripting setting to do this? I remember the default game doing this. Is it bad form to start a game without the player having at least one inventory item?

Ishmael

Set to the Inventory cursor mode AFTER you have selected an inventory item. Set to the Interact mode when the inventory window is opened.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

six_plus_one

I'm sorry, but I'm still very much a newbie and I'm still not firm on this.

I went and set the cursor mode to interact on the opening of the inv window, but now where would I put the code to set the cursor to inventory mode and what would that code be?

I may actually be barking up the wrong tree here. All I REALLY want to do is have a working LucasArtsy status bar without the game error: "Error: GetInvName: invalid inventory item specified" coming up when I set to cursor mode 4 (or 8 in my case).

I may not want to give my player an inventory item to begin with, so my SetActiveInventory(1); "workaround" won't work for me, (and besides, it's really very sloppy), and I can't seem to otherwise guarantee that someone won't change over to that cursor mode before selecting an active inventory item (and thus crashing the game).

I want to apologize for my inexperience with all of this scripting stuff, but what can I do here? Perhaps I should NOT be using cursor mode 8 the way I am. I wanted to use cursor mode 8 only to eat things or put on clothing, y'know "personal uses", with just clicking the use button (mode 8 with "if cursor mode is set to 8" conditional on "other mouse click" interactions), then clicking the inv item in question. I'd use Cursor mode 4, but it doesn't seem to work. When I set the GUI button to set cursor mode to 4 it seems to not respond. Mode 8 seems to work perfectly except with the line:

GetInvName(character[GetPlayerCharacter()].activeinv,usinginv);

and so I don't really know how to proceed from here, and it looks like I may have to abandon the use of the status bar.Ã,  :'(

Sorry for such a lengthy post, but I'm climbing up the walls here, and I would greatly appreciate any help or advice anyone can offer me. Thanks bunches. :)

SMF spam blocked by CleanTalk