Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: BlueAngel on Tue 29/12/2009 21:09:44

Title: Help with Ghosts Tutorial (make a gui)
Post by: BlueAngel on Tue 29/12/2009 21:09:44
Hi, I need help again. Sorry for asking so many questions.
I’m trying to make my first gui following Ghosts tutorial but now I’m stuck.

First it says
QuoteThe action verbs are simple. For each one, we write a single line to set the game's cursor into the matching mode. So:

function btnScummLook_OnClick(GUIControl *control, MouseButton button)
{
 mouse.Mode = eModeLookat;
}

Easy as pie- we do not use AGS's shortcut to simply make the button set a mouse mode because later, we will add some spice to our script.
And I got that part working, but then further down it says:
QuoteThe next thing we do: In each of the four action button's scripts, we add the following:

function btnGameLook_OnClick(GUIControl *control, MouseButton button)
{
 mouse.Mode = eModeLookat;
 isVerbSelected = true;
}

Now Im lost where to put this? I get this error: Error (line 67): Undefined token ‘btnGameLook’ (file) GlobalScript.asc (line) 67

This is how my code looked like:

function btnScummLook_OnClick(GUIControl *control, MouseButton button)
{
 mouse.Mode = eModeLookat;
   isVerbSelected = true;
}


And then I tried this:

function btnScummLook_OnClick(GUIControl *control, MouseButton button)
{
 mouse.Mode = eModeLookat;
 function btnGameLook_OnClick(GUIControl*control, MouseButton button)  
 isVerbSelected = true;
}


I guess this is all a bit over my head but I really like to get that gui!   :-[  ::)

Title: Re: Help with Ghosts Tutorial (make a gui): undefined token bntGameLook
Post by: NsMn on Tue 29/12/2009 21:11:43
I recommend to put it on top of the Global Script, not within any function, but under the int declarations that are important for the function (if there are any).
Title: Re: Help with Ghosts Tutorial (make a gui): undefined token bntGameLook
Post by: on Tue 29/12/2009 21:18:37
BlueAngel, have you created the button?

If not, go to your GUI, create a button (or select it if it's already created), click on the little lighting bolt on the right side of the screen (events) and then on the three dots near the "on click" line.

This way the editor will "create" the

function btnScummLook_OnClick(GUIControl *control, MouseButton button)
{
}


lines itself.

Inside those you should put your script (e.g.   mouse.Mode = eModeLookat; )



Title: Re: Help with Ghosts Tutorial (make a gui): undefined token bntGameLook
Post by: NsMn on Tue 29/12/2009 21:34:23
Aw, yes, sorry.... I just can't get used to the fact that buttons have their own functions now.
Title: Re: Help with Ghosts Tutorial (make a gui): undefined token bntGameLook
Post by: Dualnames on Tue 29/12/2009 21:43:32
Stop nagging and enter MIRC!
Title: Re: Help with Ghosts Tutorial (make a gui): undefined token bntGameLook
Post by: BlueAngel on Thu 31/12/2009 09:20:24
Hi all and thanks for trying to help me. I have created the button and function btnScummLook and it work fine.
It’s when I try to create the second function that I run in to trouble.
This is the tutorial I’m trying to follow:

http://www.freewebs.com/daemons-in-the-attic/codefront.htm  (http://www.freewebs.com/daemons-in-the-attic/codefront.htm)


And sorry Dualname â€" I haven’t been on Mirc in years and don’t remember how to use it.  :-[  :)
Title: Re: Help with Ghosts Tutorial (make a gui): undefined token bntGameLook
Post by: RickJ on Thu 31/12/2009 18:49:10
Those functions in the tutorial are connected to the buttons through and are commonly referred to as "event handlers".   The lightning bolt button mentioned by bicilotti provides a means for you to define events to which you would like to connect connect a function.  When these events occur in game the functions to which they are connected are executed.  So you will have to use the lioghtning bolt to create an event for each button the same as you have done on the first one which you say is now working.

Tip: Global Script Organisation
There are no special locations within the global script or any other script.   However, the AGS compiler is of a single pass design.  Because of this variables and functions must be closer to the top of the script than (i.e. defined before) any function that may use them.   So deciding the order of things  within the global script (or any script)  is then dictated by what uses what.   

This can get very confusing rather quickly as the script grows.  So it is important to keep your scripts organized.  Functions can be grouped into categories so that functions in one category do not call each other.  In this way each category or group of functions can be ordered in a way that makes it easy to find and maintain them. 

Since your button event handlers are meant to be called by the engine and not by other functions they can be grouped together and located near the bottom of the script.  This way the button event handlers are able to call other functions you may have defined in the global script.
Title: Re: Help with Ghosts Tutorial (make a gui): undefined token bntGameLook
Post by: on Sat 02/01/2010 15:31:36
The web is scary- when you have forgotten that you wrote something, people start digging it up  ;D

Angel, check your PM box for further help!
(And please tell everyone how awesome that GUI thing is  ;D I need the Egoboo.)
Title: Re: Help with Ghosts Tutorial (make a gui)
Post by: BlueAngel on Mon 11/01/2010 07:53:54
Ok, I solved it, by naming the original button to the same as in the tutorial and assigning that function to those buttons.

I then got a new problem but solved that one by replacing the LOOKDEF, LOOKLIT and so on with spirit numbers.

Now I’m stuck on the auto mode features as AGS says that auto mode is undefined.
I´m gonna look at this again in the evening with fresh eyes and maybe I can get Ghost to help me by PM.  ;)

I’m not giving up on this tutorial!
LOL  ;D