Author Topic: Scripting a gui idea  (Read 191 times)  Share 


monkey_05_06

  • AGS Project Admins
  • Has left the building.
Re: Scripting a gui idea
« Reply #1 on: 26 Apr 2011, 22:09 »
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]// 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");
      }
    }
  }
}[/code]
Let's be honest. Most people suck at coding. I suck at coding, but at least my code is readable. To Hell with anyone too lazy to maintain consistent formatting in their code. I could deal with bad interfaces and structure if I could even read your horrible code. And that's putting it nicely. -monkey

Re: Scripting a gui idea
« Reply #2 on: 27 Apr 2011, 08:29 »
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?
« Last Edit: 27 Apr 2011, 08:36 by BlueAngel »

monkey_05_06

  • AGS Project Admins
  • Has left the building.
Re: Scripting a gui idea
« Reply #3 on: 27 Apr 2011, 08:49 »
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]Hotspot *hat = Hotspot.GetAtScreenXY(mouse.x, mouse.y);[/code]
[code]Hotspot* hat = Hotspot.GetAtScreenXY(mouse.x, mouse.y);[/code]
[code]Hotspot*hat = Hotspot.GetAtScreenXY(mouse.x, mouse.y);[/code]
[code]Hotspot * hat = Hotspot.GetAtScreenXY(mouse.x, mouse.y);[/code]

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.
« Last Edit: 27 Apr 2011, 08:51 by monkey_05_06 »
Let's be honest. Most people suck at coding. I suck at coding, but at least my code is readable. To Hell with anyone too lazy to maintain consistent formatting in their code. I could deal with bad interfaces and structure if I could even read your horrible code. And that's putting it nicely. -monkey

Re: Scripting a gui idea
« Reply #4 on: 27 Apr 2011, 08:52 »
Thanks! I shall do that  :)