Variable formula problem

Started by gabrielsab, Wed 08/02/2006 16:20:06

Previous topic - Next topic

gabrielsab

Hi, I'm having a problem with my formula with variables. what I want to do is have my main character interact with my second character and have him walk to x: 140, y: 170 and when he is interacted for the second time have him walk to x: 140, y: 80 and have this loop so he walks from one place to the other

What I have in the characters interaction :

Script name ELEFUN

Interact character
[-] ? conditional - if a variable is set to a certain value (walk back, 5)
Character - Move Character (ELEFUN, 140, 170, true)
Game - set variable value (Walk back, 10)
Stop running more commands
? Conditional - if a variable is set to a certain value (Walk Back, 10)
Character - Move character (ELEFUN, 140, 80, true)
Game - Set variable value (Walk Back, 5)

When I first interact with him he moves to the x:140 y:80 and the second time he moves to the x: 140 y: 170 but for the third time he dosnt move at all.

Regards Shaun B.

strazer

Could it be that AGS considers "Walk Back", "walk back" and "Walk back" different variables? I don't use the interaction editor so I don't know if it's case-sensitive. Try changing everything to "walk back".

And are the commands child-actions of the conditional statements?
To preserve the indentation when posting here in the forums, you can use the [ pre ] tag.
For example,

Code: ags

[pre]
Interact character
  Conditional - if a variable is set to a certain value (walk back, 5)
    Character - Move Character (ELEFUN, 140, 170, true)
    Game - set variable value (Walk back, 10)
    Stop running more commands
  Conditional - if a variable is set to a certain value (Walk Back, 10)
    Character - Move character (ELEFUN, 140, 80, true)
    Game - Set variable value (Walk Back, 5)
[/pre]


becomes
Interact character
  Conditional - if a variable is set to a certain value (walk back, 5)
    Character - Move Character (ELEFUN, 140, 170, true)
    Game - set variable value (Walk back, 10)
    Stop running more commands
  Conditional - if a variable is set to a certain value (Walk Back, 10)
    Character - Move character (ELEFUN, 140, 80, true)
    Game - Set variable value (Walk Back, 5)

gabrielsab

#2
Hi, when I made the variable I named it "Walk Back" just the one and not as "Walk Back", "walk back" and "Walk back" that was a typing error on my part in my post. So with just the one variable I get the problem. I was thinking if I was to declair the variable as 10 in the room script as first time player enters screen if that would do it but if so how is that typed into the script? Im a newbie so can you explain what you mean by are the commands child-actions of the conditional statements and how to use the
 tag.

Shaun B.

Khris

#3
Right click on the "Conditional"-line and select "Add child action" to add the "Move" and "Set variable" thingies.
Otherwise, AGS would run the commands after the conditional no matter it it was true or not.

I'd recommend learning the script language, though.
The script would look like this:
Code: ags
int walkback;

function blahblah() {
Ã,  if (walkback==5) {
Ã, Ã,  Ã, cElefun.Move(140, 170, eBlock);
Ã, Ã,  Ã, walkback=10;
Ã,  }
Ã,  else if (walkback==10) {
Ã, Ã,  Ã, cElefun.Move(140, 80, eBlock);
Ã, Ã,  Ã, walkback=5;
Ã,  }
}


For use of tags, check the link above the area where you enter your message (How do I post images, smileys and formatting?).

gabrielsab

Thanks Khrismuc the child actions was what I needed it works now but instead of the variable "Walk Back 10" I had to change it to "Walk Back 0" as I have not worked out how to change all the global variables  to what I want without using a script and declairing them 

SMF spam blocked by CleanTalk