Help with Ghosts Tutorial (make a gui)

Started by BlueAngel, Tue 29/12/2009 21:09:44

Previous topic - Next topic

BlueAngel

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:
Code: ags

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


And then I tried this:
Code: ags

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!   :-[  ::)


NsMn

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).

bicilotti

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

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


lines itself.

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




NsMn

Aw, yes, sorry.... I just can't get used to the fact that buttons have their own functions now.

Dualnames

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

BlueAngel

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


And sorry Dualname â€" I haven’t been on Mirc in years and don’t remember how to use it.  :-[  :)

RickJ

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.

Ghost

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.)

BlueAngel

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

SMF spam blocked by CleanTalk