Scripting a gui idea

Started by BlueAngel, Tue 26/04/2011 10:29:34

Previous topic - Next topic

BlueAngel

Hi I hope I’m posting this in the right place but I’m wondering if this is possible to do?

I like the function of the Verbcoin, that you can have different verb but just three buttons but I’m not a fan of the style.
What I would like to do is have gui like the 9-verb/Scumm but just have three button: a eye, a mouth and a hand. And a label for displaying action text.

Sceen:
Ego is in a room with a window.
Player selects the eye icon. When the mouse is over the window the first time action label displays “look at window”. Player clicks window: display”it’s a window”.

Second time the player hold the mouse over the window (the eye icon still selected) display ”look through the window”. Player clicks window (second time), display “outside the window you see only water”


So is this possible to do (if you are a beginner at scripting) and any idea of what things I should be looking for in forum and manual?
I think I should look up mouse.mode but what more?
Thanks for any help!

monkey0506

I'm not entirely sure what you're looking for here..you want to have a GUI at the bottom of the screen with only three buttons on it?

That seems pretty straight-forward if I'm understanding you correctly.

As for the idea of different interactions, you could use a room variable:

Code: ags
// room script
bool lookedAtWindow = false;

function hWindow_Lookat()
{
  if (!lookedAtWindow)
  {
    player.Say("It's a window.");
    lookedAtWindow = true;
  }
  else
  {
    player.Say("Outside the window you see only water.");
  }
}

function room_RepExec()
{
  if (GetLocationType(mouse.x, mouse.y) == eLocationHotspot)
  {
    Hotspot *hat = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
    if (hat == hWindow)
    {
      if (mouse.Mode == eModeLookat)
      {
        lblDescription.Text = "Look ";
        if (lookedAtWindow) lblDescription.Text = lblDescription.Text.Append("through the ");
        else lblDescription.Text = lblDescription.Text.Append("at ");
        lblDescription.Text = lblDescription.Text.Append("window");
      }
    }
  }
}

BlueAngel

#2
Thanks monkey. Seems like it could be easier than I thought. I try this when I get home.  :)
If you got time could you explain what the star (*) does means in the code?

monkey0506

#3
I guess you mean in "Hotspot *hat"? The asterisk there just means that it's a pointer. All of the following are the same:

Code: ags
Hotspot *hat = Hotspot.GetAtScreenXY(mouse.x, mouse.y);

Code: ags
Hotspot* hat = Hotspot.GetAtScreenXY(mouse.x, mouse.y);

Code: ags
Hotspot*hat = Hotspot.GetAtScreenXY(mouse.x, mouse.y);

Code: ags
Hotspot * hat = Hotspot.GetAtScreenXY(mouse.x, mouse.y);


No matter where you put the space(s), the asterisk is, as I said, because it's a pointer. If you're not familiar with pointers in AGS, you can read up on them in the manual, and this tutorial I wrote might also help. ;)

The basic idea is that you're just reusing an existing Hotspot instead of creating a new one (which you can't do from the script anyway, so you have to reuse them).

Edit: Oh, and if you're wondering, I named the pointer "hat" to mean Hotspot AT the given coordinates. You can name it whatever you like of course (whatever makes the most sense to you!!), but this is just the type of name I use when checking what Hotspot the mouse is over.


SMF spam blocked by CleanTalk