Minigame Technique help.

Started by Danman, Wed 10/03/2010 16:03:25

Previous topic - Next topic

monkey0506

Because, your braces aren't doing anything. Your code following the conditionals is not included in the braces. What you have written is essentially the same as:

Code: ags
if (Hair == 9) player.Say("Ok All gone");
player.ChangeRoom(8);


Meaning of course that only the Say command is being considered as a conditional command and the ChangeRoom command will be executed every single time that the RemoveHair function is called.

You've already been advised previously as to how these braces work, but I'll reiterate it here:
if (Hair == 9) {
  player.Say("Ok All gone");
  player.ChangeRoom(8);
}
As you can see the lines in red have been reversed from the way you typed them. This is the correct way to enclose multiple commands following a conditional.

Khris

You need to get your if stuff straight.
Look at that piece of code:

Code: ags
  if (Hair == 9) player.Say("Ok All gone");
       
  {
    player.ChangeRoom(8);
  }


The condition check will only affect the execution of the player.Say line.
The curly brackets around the ChangeRoom command don't have any effect at all.

It's supposed to look like this:

Code: ags
  if (Hair == 9)
  {
    player.Say("Ok All gone");
    player.ChangeRoom(8);
  }


Edit: What monkey said :)

Danman

OK I understand that. Now I see what I did. There is one other problem now. When I am at the 8th variable or 8th object that gets removed.
It changes room as if it was Hair == 9  ???

Yet when the variable is on 2,4 and 6 it does all the player.say commands as it should in order. 



monkey0506

Okay if you look at your code then you should see that in the hair3_UseInv function there is a Hair += 1; there in addition to calling RemoveHair. So:
Hair = 0
Use razor on hair 1
RemoveHair function is called
Hair = 1
stop
Use razor on hair 2
RemoveHair function is called
Hair = 2
Player says "This is a Span of hair"
stop
Use razor on hair 3
RemoveHair function is called
Hair = 3
Hair = 4
stop
Use razor on hair 4
RemoveHair function is called
Hair = 5
stop
Use razor on hair 5
RemoveHair function is called
Hair = 6
Player says "Seriously is this own a monkey yo!!"
stop
Use razor on hair 6
RemoveHair function is called
Hair = 7
Display "Ohh a six pack"
stop
Use razor on hair 7
RemoveHair function is called
Hair = 8
stop
Use razor on hair 8
RemoveHair function is called
Hair = 9
Player changes rooms
stop
Use razor on hair 9
RemoveHair function is called
Hair = 9
Player changes rooms
stop
If you don't understand where I came up with that, then I highly suggest you read a scripting tutorial or two, go back, and re-read your own code.

I'm not trying to be rude here, but scripting/programming is about 5% knowing the language and about 95% logic. Your logic is virtually non-existent. Correct your logic and your code will begin working properly.

Danman

OK thanks monkey. What that was, Was the previous way I was going to script the puzzle then I changed it. I think I forgot to change that one.


Sorry I just forgot that I changed it. So I didn't check it again. 

Thanks a lot Monkey.



SMF spam blocked by CleanTalk