Two buttons with same script, one works other does not! [Solved]

Started by BrightBulb, Fri 24/08/2012 11:32:44

Previous topic - Next topic

BrightBulb

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?

Andail


BrightBulb

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);
}

Crimson Wizard

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.

BrightBulb

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.

Crimson Wizard

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?

BrightBulb

I'm using 3.2.1.111.

Linking the buttons is no problem, but if I click on the second one nothing happens.

Crimson Wizard

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?

BrightBulb

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.

Khris

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?

BrightBulb

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.


SMF spam blocked by CleanTalk