Strange GUI/Inventory Items thing (SOLVED)

Started by Krazy, Tue 25/01/2005 09:08:03

Previous topic - Next topic

Krazy

What the hell has just happened, I added a couple of buttons to a GUI then suddenly ags decided it didn't like this line function inventory7_a() { and refused to save until I removed it of course removing it causes further trouble, what have I done and why is it doing this?

It should do this:
  // script for inventory7: Look at inventory item
SetCharacterView(0,10);
AnimateCharacter(0,0,3,0);
while(character[0].animating) Wait(1);
function inventory7_a() {
but without that code it's useless, and removing that script completely then gives me a "Funtion Still Open" message what the hell is going on?

My Stuffs:
Tumblr

Gilbert

It's INSIDE the inventory_click() function right?

You cannot declare a function inside another a function.

Krazy

The full code is:

#sectionstart inventory7_a  // DO NOT EDIT OR REMOVE THIS LINE
function inventory7_a() {
  // script for inventory7: Look at inventory item
SetCharacterView(0,15);
AnimateCharacter(0,0,1,0);
while(character[0].animating) Wait(1);
ReleaseCharacterView(0);
RunDialog (20);
}

And was working fine until I added a Save a Load button to the inventory window, which really doesn't make any sense  ???
My Stuffs:
Tumblr

Gilbert

I'm confused, as this part of code is different from the previous one you posted:
Code: ags

Ã,  // script for inventory7: Look at inventory item
Ã,  SetCharacterView(0,10);
Ã,  AnimateCharacter(0,0,3,0);
Ã,  while(character[0].animating) Wait(1);
function inventory7_a() {

Seeing that the "function inventory7_a() {" line goes after other commands, it's certainly a function declaration within a function (or the otherway round, that some of the commands were put outside of the function, which is not allowed, only static variable declaration and the like are allowed outside).
But with the later code you pasted it looked okay, what had it become after adding the save and load buttons?

Also, what did the error messages say when it refused to save?

Krazy

Oh it's a little different cause there's two scripts following each other which do pretty similar things but so there's no real difference between the two codewise. And I accidently put the first one around the wrong way when I pasted it in.  the message says "Error (line 138): Nested Functions not supported (you may have forgoten a closing brace). But it makes even less sense seeing as it doesn't care about the other almost identical code  :o
My Stuffs:
Tumblr

Gilbert

If it's a nested function error, it's indeed an error generated when there's a function within another, which can happen whenever there's a missing brace.
Noticiably when something like this happens:
Code: ags

function aaa(){
  blah;
  blahblahblah;
function bbb(){
  blahblah;
  blub;
}

(Seeing as a closing brace is missing for aaa(), bbb() is considered to be declared inside of aaa() )

Krazy

My Stuffs:
Tumblr

SMF spam blocked by CleanTalk