Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: BrightBulb on Fri 24/08/2012 11:32:44

Title: Two buttons with same script, one works other does not! [Solved]
Post by: BrightBulb on Fri 24/08/2012 11:32:44
Hi everyone,

I made two GUIs with a button each. I copied (exported) the first GUI to make the second one, as all the functions are the same. The problem now is that the button from the first GUI works normally, while the button from the second GUI, which is linked to the same script does not react at all.

The two GUIs are identical (both are clickable). I also tried linking the second button to its own script, but it just doesn't react. My only guess is that it has something to do with the exporting and importing, but that would be a bug then.

Any ideas?
Title: Re: Two buttons with same script, one works other does not! Bug?
Post by: Andail on Fri 24/08/2012 12:16:25
Can you please show us the script you're using?
Title: Re: Two buttons with same script, one works other does not! Bug?
Post by: BrightBulb on Fri 24/08/2012 13:30:55
I used the editor (lightning) to automatically create a script. The buttons have different names, but are linked to the same function below.


function bPortraitParty_OnClick(GUIControl *control, MouseButton button){
    cChar1.ChangeRoom(2);
}
Title: Re: Two buttons with same script, one works other does not! Bug?
Post by: Crimson Wizard on Fri 24/08/2012 13:40:09
Just for information, I made similar thing: exported existing gui and imported it back as a copy. Both have buttons which reference same function. Both buttons call that function when clicked.

There must be something else.
Title: Re: Two buttons with same script, one works other does not! Bug?
Post by: BrightBulb on Fri 24/08/2012 13:43:49
I'm not quite sure if I understand you correctly.

In an old thread I read about the problem of copied GUIs referencing to the same (old) script although they had a new name. Is that what you mean?

In my case I actually want both GUIs/buttons to run the same script.
Title: Re: Two buttons with same script, one works other does not! Bug?
Post by: Crimson Wizard on Fri 24/08/2012 13:53:22
Quote from: BrightBulb on Fri 24/08/2012 13:43:49
I'm not quite sure if I understand you correctly.
I mean I did the same as you did, according to your explanation in the first post, and I have no error. I mean, there is possibly some other factor that causes this error.

Quote from: BrightBulb on Fri 24/08/2012 13:43:49
In my case I actually want both GUIs/buttons to run the same script.
Yes, that's what I did and it worked.

Earlier you said:
Quote
also tried linking the second button to its own script, but it just doesn't react
Do you mean you were unable to link second button to its own script, or that nothing happens when you click on it?
BTW, what version of AGS do you use?
Title: Re: Two buttons with same script, one works other does not! Bug?
Post by: BrightBulb on Fri 24/08/2012 14:01:18
I'm using 3.2.1.111.

Linking the buttons is no problem, but if I click on the second one nothing happens.
Title: Re: Two buttons with same script, one works other does not! Bug?
Post by: Crimson Wizard on Fri 24/08/2012 14:06:09
I am sorry for this may seem a dumb question, but do you click on the second button in the exactly same situation as when you clicked on first?
The script makes character change the room. Do you click on second button when the character is in the other room?
Title: Re: Two buttons with same script, one works other does not! Bug?
Post by: BrightBulb on Fri 24/08/2012 14:11:00
Yes, it is the same situation. I also added a Display command to see if the function is executed at all, but it is not.
Title: Re: Two buttons with same script, one works other does not! Bug?
Post by: Khris on Fri 24/08/2012 14:15:45
Open the button's properties and make sure its "ClickAction" is set to "RunScript".

Why did you create a second GUI that does the same as the first one? What's the difference between them?
Title: Re: Two buttons with same script, one works other does not! [Solved]
Post by: BrightBulb on Fri 24/08/2012 14:20:08
I found the problem. I knew it was something stupid. But those are the things that are most difficult to find.

There was a (leftover) third button (that looked like the second one) that covered the second button.

Thanks for your help anyway.