Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Tonic Ink on Wed 25/11/2009 10:09:51

Title: GUI button - return to normalgraphic (SOLVED)
Post by: Tonic Ink on Wed 25/11/2009 10:09:51
I'm easily missing something here.

THE CODE -

function bowel_OnClick(GUIControl *control, MouseButton button)
{
bowel.Animate(6, 0, 4, eOnce);
int ran=Random(2);
if (ran==1) aFart2.Play();
else if (ran==2) aFart3.Play();
Wait(80);
int bowel.NormalGraphic);


Error: GlobalScript.asc(462): Error (line 462): Already referenced name as import; you must define it before using it


Essentially, I click the button, it animates, then returns to its original graphic. Animate and random sound work fine. Just having a wee bit of trouble getting the graphic to return to it's original still frame (aka normal graphic).

Bluntly followed the help documentation as you can see by the last line of code. I know i'm missing something here.

Help would be fab :)
Title: Re: GUI button - return to normalgraphic
Post by: Gilbert on Wed 25/11/2009 10:33:06
I'm not sure whether you retyped the codes or copied them directly from your game's script (since there're some brackets and incompleteness problem, like the awkward closed ) in the last line), but I'll assume it's the latter as after you fix one problem you can fix the other problems anyway when you encounter another error message.

When you have a GUI button called bowel the property bowel.NormalGraphic is automagically created, so you don't need to (you cannot) redeclare it by using something like int bowel.NormalGraphic.
The first thing to do is to remove the "int" in the last line.

Also, as mentioned above, that last line has an extra ) at the end and the line does nothing, unless you're going to assign some value to it, something like:

int bowel.NormalGraphic = 12;

Title: Re: GUI button - return to normalgraphic
Post by: Tonic Ink on Wed 25/11/2009 10:36:20
Quote from: Gilbet V7000a on Wed 25/11/2009 10:33:06
I'm not sure whether you retyped the codes or copied them directly from your game's script (since there're some brackets and incompleteness problem, like the awkward closed ) in the last line), but I'll assume it's the latter as after you fix one problem you can fix the other problems anyway when you encounter another error message.

When you have a GUI button called bowel the property bowel.NormalGraphic is automagically created, so you don't need to (you cannot) redeclare it by using something like int bowel.NormalGraphic.
The first thing to do is to remove the "int" in the last line.

Also, as mentioned above, that last line has an extra ) at the end and the line does nothing, unless you're going to assign some value to it, something like:

int bowel.NormalGraphic = 12;



aha, success!

bowel.NormalGraphic = 30;

worked a charm.

I'm sorry for these seemingly absurd questions. The method of how to code in AGS is starting to show context for me now slowly :)