Option gui not working properly (potential bug?)

Started by Olleh19, Wed 26/02/2020 15:12:25

Previous topic - Next topic

Olleh19

So i tried to open my project from Ags 2.4.1 in Ags 3.5.0 (Thumbleweed Template).
And a lot of things had obviously changed, so i could not run it. I began copy pasting over scripts re-naming stuff, etc, and finally got the game running again.
However the option buttons are dead, save load, quit, default, resume.

So i went into the actual Gui-Options and clicked the elipse button and "onclick" seems active, so i go into it. To my surprise (or maybe not). It does not jump to any particular code.
And i think that is the issue.  I've run into it before.
it turns out this is exactly the problem i had before with Gui's, simply the elipse button just won't ignite it's code, no matter if you write it in manually, or not.
I wonder if it is possible to solve much more simplier then having to *open a thumbleweed template and export all guis, import into my project*


Edit: Or it's something else, but i'm quite sure i've imported the script parts that are "new" for 3.5

TheManInBoots

#1
I'm just gonna state the obvious thing:

For the elipse button to ignite the code the name to the left of the elipse button needs to be the same as the name in the script.

For example if tothe left of the elipse on click button there is written: "btnSave_Click",
that means you need in the script a function with the exact same name:
Code: ags
function btnSave_Click ...


Secondly, maybe the way guis are assigned (with pointers or not) or something similar has changed over time.
The second part of the function description should say:
Code: ags
(GUIControl *control, MouseButton button)


So together
Code: ags
function btnSave_Click (GUIControl *control, MouseButton button)
{

}


Then you can write whatever you want in the curly brackets and it will be triggered.

So

1.) Check the function name
2.) Write (GUIControl *control, MouseButton button) in the brackets right after.

Is that all correct in your script, or is the probelm something else?

Olleh19

#2
I'm unsure what to answer.

If i type in the function in the script (btnSave_Click (GUIControl *control, MouseButton button)

as per your example, i try a simple "display (");".

Still no success. But then you do a export of gui from a working thumbleweed 3.5 project (just tried it, and just like before, it works).
I really wished i could understand why that is making the button interact with it's code, doing it manually (sometimes with gui's obviously doesnt work) i've done it manually countless of times and had it work (not with most gui's)

TheManInBoots

#3
Quote from: Olleh19 on Wed 26/02/2020 16:14:39
I'm unsure what to answer.

If i type in the function in the script (btnSave_Click (GUIControl *control, MouseButton button)


And to the left of the ellipse button you also have written btnSave_Click, the same thing?

Khris

As far as I know, when the engine tries to call a linked function which doesn't exist, you'll get a runtime error.

So a "dead" button means that either the function is written in a way that doesn't appear to do anything, or it's empty (or you aren't actually clicking the button because the mouse cursor hotspot was displaced or something; I assume the button's mousedown image appears when you click?)

The ellipse button not jumping to the function is something that happened to me once IIRC when I was working with a really long global script. Thousands of lines, and jumping to the function wouldn't work for functions way down near the end.

Olleh19

Quote from: TheManInBoots on Wed 26/02/2020 16:30:38
Quote from: Olleh19 on Wed 26/02/2020 16:14:39
I'm unsure what to answer.

If i type in the function in the script (btnSave_Click (GUIControl *control, MouseButton button)


And to the left of the ellipse button you also have written btnSave_Click, the same thing?

I've tried all those things, yes. Solved it again just exporting the gui's from a working template and there it goes. It's so strange. But no idea spending more thoughts about it. I guess going from one version of the engine to another messes things up.

Olleh19

Quote from: Khris on Wed 26/02/2020 17:06:19
As far as I know, when the engine tries to call a linked function which doesn't exist, you'll get a runtime error.

So a "dead" button means that either the function is written in a way that doesn't appear to do anything, or it's empty (or you aren't actually clicking the button because the mouse cursor hotspot was displaced or something; I assume the button's mousedown image appears when you click?)

The ellipse button not jumping to the function is something that happened to me once IIRC when I was working with a really long global script. Thousands of lines, and jumping to the function wouldn't work for functions way down near the end.

What you explain at the end is exactly it, but yeah i've solved it anyhow using the import export gui solution

TheManInBoots

I would like to be able to learn from this, too, and I'm not sure I understood everything.

So, it was not working because the script was too long, and so the gui/button related functions could not be called anymore on the bottom of the script?
And the solution is to import those functions into a different, shorter script?

Did I get the basic gist right like that more or less?

Cassiebsg

Funny, I have meet this problem before, but I solved it by creating a new ellipse name, and then copy pasting the code into it (either the code that was on the old function or vice versa). I have never exported or re-imported a GUI to solve this. I also assumed that something must have become corrupt or  I introduced a character somewhere that messed it up. Of course, I always solve problems by trial & error... but exporting/importing a GUI have never even occurred to me.
There are those who believe that life here began out there...

TheManInBoots

Yeah, okay, but re-importing the gui does not change the length of the script, which Khris mentioned at the end of his comment as being a potential reason for the ellipse button not jumping to the right point in script.
Olleh, is that project you have something you'd be willing to share or send me in any way?
It's out of pure curiosity for me to explore that problem for the guis as well for myself.
I might not get any great insights, but somehow I would like to try to understand this better still.

Olleh19

Quote from: Cassiebsg on Thu 27/02/2020 21:49:58
Funny, I have meet this problem before, but I solved it by creating a new ellipse name, and then copy pasting the code into it (either the code that was on the old function or vice versa). I have never exported or re-imported a GUI to solve this. I also assumed that something must have become corrupt or  I introduced a character somewhere that messed it up. Of course, I always solve problems by trial & error... but exporting/importing a GUI have never even occurred to me.

Haha, it's probably cause i'm not a programmer. But at least it's good to hear i'm not alone!  (laugh)

Cassiebsg

That's okay, I'm not a programmer either.  ;) Unless you count AGS in, and even then I only "master" the basics.  (laugh)
There are those who believe that life here began out there...

Crimson Wizard

Wait, so, there is a error in the editor, that causes function to not be found by clicking on "..." if the script is too long?

Cassiebsg

I can't neither confirm nor deny... I've always assumed that whenever that happened I made a mistake some place and took it up to figure out where and fix it. Somehow I've always fixed it, but can't say exactly, if only using the above method (creating new ... name and copy/pasting the code into place) or a combination of that with something else. Either way, I never thought it was en editor bug...  (roll)
There are those who believe that life here began out there...

Olleh19

Quote from: Crimson Wizard on Fri 28/02/2020 19:58:12
Wait, so, there is a error in the editor, that causes function to not be found by clicking on "..." if the script is too long?

In my case it had absolutely nothing with length of script to do, at least i don't think so. :-[
I think you probably can recreate my problem by getting a project that uses option gui's in 3.4.1 (new template --> thumbleweed project 3.4.1 --> re-open in ags 3.5)
and there is the issue, at least it happened in my ags.

Consider this, nothing in the code for the gui's seems changed scriptwise (Maybe i am wrong, again i am a beginner, but from copy & pasting, it looked similar, script names changed somewhat, but i didn't see any code that sticked out as completely changed) from 3.4.1  template version VS the 3.5 template version.



Crimson Wizard

Quote from: Olleh19 on Fri 28/02/2020 22:20:30
I think you probably can recreate my problem by getting a project that uses option gui's in 3.4.1 (new template --> thumbleweed project 3.4.1 --> re-open in ags 3.5)

No, unfortunately I was not able to, it still works after importing from 3.4.1 to 3.5.0.

TheManInBoots

Quote from: Khris on Wed 26/02/2020 17:06:19
The ellipse button not jumping to the function is something that happened to me once IIRC when I was working with a really long global script. Thousands of lines, and jumping to the function wouldn't work for functions way down near the end.
Crimson Wizard, so apparently?

TheManInBoots

Concerning scripts that do not work and functions that can't be found, I also noticed this:

When you blend out the end of Global Script.ash with a slash asterisk(/*), but you don't close it and leave it open,
you will get plenty of error messages in other scripts.

For example I got
QuoteUnexpected "{"
in Global Script.asc

Or after I removed something in Global script, then the error message for room_before_load function. It said there was no such function in script for room 9.

So you can completely mess up the scripts, and functions won't be recognized anymore, when you leave an open slash asterisk in Global header.
All problems were gone after closing it with */

Since we were talking about functions not being read properly I thought I'd add this.

SMF spam blocked by CleanTalk