Out of date coding (FIXED)

Started by ShadeJackrabbit, Fri 23/12/2005 19:31:18

Previous topic - Next topic

monkey0506

He almost definitely used inventory which is a keyword of AGS as it is the ARRAY of global pointers to the InventoryItems, in which case it would need an array index, hence the opening '[' that would be needed.

I would recommend using something else for the name to prevent confusion between your InventoryWindow and inventory...

Akumayo

Gar.. I never think of things like that....
"Power is not a means - it is an end."

ShadeJackrabbit

But then it says that it is undefined.

Akumayo

Try changing the name of the Inventory Window to "MyInv".  Then change "Inventory.SrollUp()" and "Inventory.ScrollDown()" to "MyInv.ScrollUp()" and "MyInv.ScrollDown()"
"Power is not a means - it is an end."

ShadeJackrabbit

Then "Myinv" is undefined.

Akumayo

Check to see that you Inventory Window is called "Myinv"  capitalization counts!
"Power is not a means - it is an end."

monkey0506

Make sure that you are actually setting the script o-name of the InventoryWindow, not just changing the name of the GUI.

  • Choose the GUI from the list of GUIs in the GUI Editor.
  • Click on the InventoryWindow to select it.
  • In the window with the GUI information (i.e., Script Name, X-Position, Y-Position, Image, etc.), double-click where it says "Script Name."
  • Type the script o-name you wish to give the InventoryWindow, i.e. MyInv.

    Then you should be able to compile your game.  Otherwise...you'll definitely need a more in depth tutorial with photos...so please...try to make this work. :D

    If you can't get it to work, I will try to help you though.

ShadeJackrabbit

Oh I get what you mean! It worked! Wait... DARN!! Why is there another error!!!!!! GUIOFF is undefined now. Here's the code:
Code: ags

  if (interface == SET) {     // They clicked a button on the Settings Tab
    if (button == 0)  {  // save game
      GUIOff(SET);
      SaveGameDialog();}
    else if (button == 1) {  // load game
      GUIOff(SET);
      RestoreGameDialog();}
    else if (button == 2)   // restart game
      RestartGame();
    else if (button == 3) {  // quit
      GUIOff(SET);
      QuitGame(1);}
    else if (button == 4) {   // about
      Display("Adventure Game Studio v2 run-time engine[     Copyright (c) 1999-2003 Chris Jones");}
    else if (button == 5) {  // resume
      GUIOff (SET);
      SetCursorMode (MODE_WALK);
      }

Again, I want to make it clear that I am using somebody else's GUI and did not put these commands in myself.

Ashen

As with a lot of the problems so far, it's because the code was written for an older version and the command (GUIOff()) is obsolete. Assuming SET is still the right name for the GUI, replace every instance of GUIOff(SET); with gSet.Visible = false;. (Check the script-o-name of the GUI in the GUI Editor, just to be sure.)

Next time you get an error like this, try looking up the old, 'undefined' command in the manual - it should link you to the new one you need to use instead, saving you from having to wait for someone to answer before you can move on.
I know what you're thinking ... Don't think that.

ShadeJackrabbit

I've done as Ashen said for a while, yet now I just don't understand this one part of code that is out of date.
Code: ags

      }
    else if (button == 6) {  // volume
      SetDigitalMasterVolume (volume.Value);
      string vol;
      StrFormat (vol, "%d", int Slider.Value;
      SetLabelText(SET, 8, vol);   }
    else if (button == 7) {  // game speed
      SetGameSpeed (GetSliderValue (SET, 7));
      string spe;
      StrFormat (spe, "%d", GetSliderValue(SET, 7));
      SetLabelText(SET, 9, spe);   }
    }  // end if interface SET

P.S. I tried to fix it up, yet now I'm just confused.

Ashen

What have you tried? What is the problem? What particularly has you confused?
Seriously, you need to be a bit more specific about the problem here.

One thing that stands out:
Code: ags

StrFormat (vol, "%d", int Slider.Value;


Firstly, you're missing a closing ')' (when in doubt, it's usually one of these, a }, or a semi-colon). Secondly, you don't need to declare the int there, and thirdly you'll want to use volume.Value, so the line should be:
Code: ags
StrFormat (vol, "%d", volume.Value);


Now, assuming you've set script-o-names for the sliders (like monkey_05_06 showed for the Inventory Window), you should be set for that and the GetSliderValue(SET, 7) bits later on.

The other problem is the SetLabelText() commands. These depend on whether you're using 2.7 or 2.71 (I can't tell from previous posts).

Either way, first you need to name the labels (objects 8 & 9 on SET).
In 2.7, use Label.SetText(...);. Change Label as needed - obviously - and replace ... with either vol or spe, depending on the label.
In 2.71, I think you can delete the string and StrFormat lines, and just use Label.Text = String.Format("%d", Slider.Value); (changing Label and Slider as needed).
I know what you're thinking ... Don't think that.

ShadeJackrabbit

First, I'm using 2.7. Second, there is a problem where it says "else".
Code: ags

    else if (button == 7) {  // game speed
      SetGameSpeed (GetSliderValue (SET, 7));
      string spe;
      StrFormat (spe, "%d", GetSliderValue(SET, 7));
      SetLabelText(SET, 9, spe);   }
    }  // end if interface SET

Says there is a "parse error" of some kind...

Ashen

Oh, OK. In that case - while everything I said is true, it's also totally beside the point ... Sorry about that - but that's where knowing what the problem actually was before I typed a load of useless stuff would've helped.

Is that all the error says? A line number and "parse error at 'else'", or something like that? Now I'm confused. That error usually means there's a problem with braces on the conditions (usually a missing } somewhere - I said they where trouble), but I can't see any in the code you've posted so far. Is it possible you've accidentally deleted one since you posted that version? If so, the mistake is actually before that line - scan backwards and try to match all the braces (use Ctrl-B to make it easier), to check if that's the problem. Otherwise, can you post the whole condition for if (interface == SET)?

(Alternatively, if you really want to, you could try shifting all the code out of interface_click, and into the proper 2.7-style control functions - more work, but it'll eliminate all the else if ... conditions, and so hopefully solve the problem.)
I know what you're thinking ... Don't think that.

ShadeJackrabbit

Nonono. What you sad helped. It helped me find this "else" error. And I made sure I didn't delete any of the "}". Also, here's the error message:
Code: ags

Error (line 93): PE04: parse error at 'else'

Anyways, here's the entire "if" thing you wanted:
Code: ags

70  if (interface == SET) {     // They clicked a button on the Settings Tab
71    if (button == 0)  {  // save game
72      gSet.Visible = false;
73      SaveGameDialog();}
74    else if (button == 1) {  // load game
75      gSet.Visible = false;
76      RestoreGameDialog();}
77    else if (button == 2)   // restart game
78      RestartGame();
79    else if (button == 3) {  // quit
80      gSet.Visible = false;
81      QuitGame(1);}
82    else if (button == 4) {   // about
83      Display("Adventure Game Studio v2 run-time engine[     Copyright (c) 1999-2003 Chris Jones");}
84    else if (button == 5) {  // resume
85      gSet.Visible = false;
86      Mouse.Mode = eModeWalkto;
87      }
88    else if (button == 6) {  // volume
89      SetDigitalMasterVolume (volume.Value);
90      string vol;
91      StrFormat (vol, "%d", volume.Value);
92      volume_number.SetText(vol);
93    else if (button == 7) {  // game speed
94      SetGameSpeed (GetSliderValue (SET, 7));
95      string spe;
96      StrFormat (spe, "%d", GetSliderValue(SET, 7));
97      SetLabelText(SET, 9, spe);   }
98    }  // end if interface SET

Ashen

Code: ags
92      volume_number.SetText(vol);
93    else if (button == 7) {  // game speed


BAM! Right there, missing } at the end of the if (button == 6) condition. It was there a few posts back - you must've deleted it fixing the other bits (That whole line has changed).

For ease of use, I put the closing brace on the next line, as has been done for if (button == 5) in that code you posted (lines 84 - 87). Doesn't always work, but I find it's easier to see what's missing than if it's on the same line as a command. Just a matter of personal preference, though.
I know what you're thinking ... Don't think that.

ShadeJackrabbit

#55
Heh. You know, my friend just looked at it and said almost the same thing. Sorry, I don't know much about C or C++ or any programming.

EDIT:
There! It now works! I'd like to thank everybody who helped to get this game running.

monkey0506

Glad you finally got it working! ;D

Furious that Ashen has beaten me once again. :P  Nah, I'm just kidding, but I'm glad I was able to help (some :D).

SMF spam blocked by CleanTalk