GUI if/else statement gives a parse error

Started by Cordate, Fri 25/09/2020 02:17:10

Previous topic - Next topic

Cordate

Hey! I tried finding other threads and tried following the help manual, but I'm still having trouble with my script. I'm trying to get the button to change the view of a character when pressed.
What I have so far is:
Code: ags

function Button25_OnClick(GUIControl *control, MouseButton button)
{
  if (QDisplay.NormalView == 21)
    QDisplay.NormalView == 23;
}

Whenever I try running it I get the error "parse error at QDisplay" and nothing that I've tried so far to fix it has worked. Am I doing something wrong? Thanks in advance for the help!

Slasher

#1
Code: ags

function Button25_OnClick(GUIControl *control, MouseButton button)
{
 if(QDisplay.View==21){
 QDisplay.ChangeView(23);
// you may also need to change speech view and Idle view
 QDisplay.SpeechView=speechview number;
 QDisplay.SetIdleView(-1,0); // idle view number and delay
  }
}

Cordate

my god it actually worked! Thank you so much!

Gilbert

Just to clarify why the original codes won't work.
In a number of "C-like" programming languages "==" and "=" are completely different. "==" is for comparison and "=" is for assignment, so the second "==" should be the assignment "=".
BUT, as pointed out in the manual, the property NormalView of a character is read-only, so you need to use the ChangeView() function as demonstrated by slasher.

SMF spam blocked by CleanTalk