Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: plebeo on Wed 14/03/2007 21:27:34

Title: Make Gui CMI style-like
Post by: plebeo on Wed 14/03/2007 21:27:34
I try to create a GUI Monkey Island 3 style-like.

I explain what I need:

if I press left mouse button the character walks but if I press left button for some second into a hotspot (or object) appear a GUI with the cursors (look, interact, talk).
if I press right mouse button suddenly appear inventory screen.

I try for a days to make it but without success!!
Please help me!
Title: Re: Make Gui CMI style-like
Post by: Da_Elf on Wed 14/03/2007 21:35:45
its called a verb coin, check the forum for it
Title: Re: Make Gui CMI style-like
Post by: Ashen on Wed 14/03/2007 23:49:12
The AGS Resources site (http://www.americangirlscouts.org/agsresources/) (as linked in the 'Read before posting' thread) has a couple (I think, at least one...) Verb Coin templates you could use, or at least learn from.

If you want to make it hard on yourself and code your own (I prefer to do it this way  ;)), or if those templates aren't quite what you're after - post the code you've tried, along with what it is/isn't doing that's wrong.
Title: Re: Make Gui CMI style-like
Post by: plebeo on Thu 15/03/2007 10:32:33
Ok I try to show what I made and what I need:
First, I use version 2.72.
In the on_mouse click section I write:


#sectionstart on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(MouseButton button) {
  // called when a mouse button is clicked. button is either LEFT or RIGHT

if (IsGamePaused() == 1) {
    // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button == eMouseLeft) {
    ProcessClick(mouse.x, mouse.y, mouse.Mode );
    mousex = mouse.x;
    mousey = mouse.y;
    guix = mousex - 25;    // so my GUI will appear where I click
    guiy = mousey - 25;    // so my GUI will appear where I click   
   
  }
  else {   // right-click, so cycle cursor
    mouse.SelectNextMode();
    gInventory.Visible = true; // the GUI inventory appear
  }

}
#sectionend on_mouse_click


in the repeatedly_execute section I write:


#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
  // put anything you want to happen every game cycle here



if (mouse.IsButtonDown(eMouseLeft) == 1)
{
  if (timer == 40) {
    gCrystal.Visible = true;  // gCrystal is the GUI
    gCrystal.SetPosition(guix, guiy);  // the GUI appear where I have clicked
   
    timer = 0;
  }
  else {
    timer++;
    }
}

if (mouse.IsButtonDown(eMouseLeft) == 0)
{
 
   else { gCrystal.Visible = false; }  // if I release the left mouse button the GUI disappear
  }

}
}
#sectionend repeatedly_execute 


But now I'm in chaos.I try to study some verb coin scripting but with no result.
Infact now I'm not able to do this:

1) move the pointer over a hotspot (or object)
2) push left-mouse for a while and appear the GUI with the cursors (look, interact, talk)
3) if i release the left mouse button over look cursor, must begin the command "look with hotspot",
then if i release the left mouse button over interact cursor, must begin the command "interact with hotspot"

Can You help me?








Title: Re: Make Gui CMI style-like
Post by: Ali on Fri 16/03/2007 17:56:59
I'm no coding wizard, and I can't open AGS and test your code at the moment. I can see a couple of things that are wrong though.

You don't want a ProcessClick in the on_mouse_click. That should happen when the mouse is released.

In the "if (mouse.IsButtonDown(eMouseLeft) == 0)" bit, you want a condition checking in the verb coin is visible and checking if there are any GUI buttons at the mouse's position. If the verb coin isn't visible (because the player clicked for a short period of time) THEN you should call ProcessClick, with the appropriate mode.

Once you know what button the player released the mouse over you can write the appropriate ProcessClick function.

If I was you though, I'd just download this template:

http://www.americangirlscouts.org/agsresources/AGS%20resources/Templates/ENH_VERBC.zip

And examine the code.