Post new topic    
King Slime
Send private message
If, And, Then, Or, Else? 
 PostFri Feb 10, 2012 3:11 pm
Send private message Reply with quote
I really do hate tag checking and flow control.
I need help with some scripts...

Code:
plotscript, which gender, begin
   if (check tag(6 == ON)) then
   $2 = "he"
   $3 = "him"
   $4 = "He"

        else
       
   $2 = "she"
   $3 = "her"
   $4 = "She"
   
   end
   


It says that else needs to be follow an If or Then.

Also, I want to make a script that sets a heroes picture differently when they step into a certain area based on a tag check, and then turn it off when they're not in a certain area. How can I do that?
Metal Slime
Send private message
 
 PostFri Feb 10, 2012 3:37 pm
Send private message Reply with quote
then and else won't work if you just leave them hanging like that. The proper syntax should be like this:

Code:
plotscript, which gender, begin
   if (check tag(6 == ON)) then, begin
     $2 = "he"
     $3 = "him"
     $4 = "He"
   end

   else, begin
     $2 = "she"
     $3 = "her"
     $4 = "She"
   end
   
end


You can do the latter using zones and an "Each step" script. On each step, check to see if the player's standing in a certain zone (read zone). If he is, then change his walkabout sprite.
Metal King Slime
Send private message
 
 PostSat Feb 11, 2012 1:01 am
Send private message Reply with quote
People keep on mistaking what the syntax of if statements is. I really wonder why. Have you read the Plotscripting Tutorial? Looked at any other articles about scripting on the wiki?

HSpeak also ought to be made better at describing what the error is.

Sephy missed another mistake: "if (check tag(6 == ON))" should be "if (check tag(6) == ON)", which is actually the same as "if (check tag(6))". That one's also very popular, but I blame it on common sense.

Also, you can use ( and ) instead of begin and end. I think it leads to cleaner code:

Code:
plotscript, which gender, begin
   if (check tag(6)) then (
     $2 = "he"
     $3 = "him"
     $4 = "He"
   ) else (
     $2 = "she"
     $3 = "her"
     $4 = "She"
   )
end


Finally, whether or not you want to use a tag or zones ("read zone (id)" returns true or false) to figure out if the player is in the area , you probably wanted to know what command to use. Like this:

Code:
plotscript, update walkabout, begin
  if (check tag ([TAG ID[)) then (   # or read zone ([ZONE ID]), as required
    set walkabout picture (find hero ([HERO ID]), [SPRITE SET ID], outside battle)
    set walkabout palette (find hero ([HERO ID]), [PALETTE ID], outside battle)  # if needed
  ) else (
    # Or use 'set hero picture/palette' instead
    reset walkabout picture (find hero ([HERO ID]), outside battle)
    reset walkabout palette (find hero ([HERO ID]), outside battle)  # if needed
  )
end
King Slime
Send private message
 
 PostSat Feb 11, 2012 4:27 pm
Send private message Reply with quote
Thank you, but by tag check...I mean't one determining which picture to set the hero to. The hero can either be a guy or a girl.

EDIT:

Code:
plotscript, grass animation, begin
  if (read zone(1)) then (   # or read zone ([ZONE ID]), as required
    set hero picture (0, 11, outside battle)
  ) else (
    # Or use 'set hero picture/palette' instead
    reset hero picture (find hero (0), outside battle)
  )
end


I tested this script for the male hero, and it does not work.
Metal Slime
Send private message
 
 PostSat Feb 11, 2012 4:54 pm
Send private message Reply with quote
The syntax for read zone is actually 'read zone (zone id, x, y)'. Try something like 'read zone(1, herox, heroy)'
Metal King Slime
Send private message
 
 PostSun Feb 12, 2012 5:05 am
Send private message Reply with quote
Opps.

Also, "set hero picture (0, 11, outside battle) " should be "set hero picture (find hero(0), 11, outside battle)" although it'll appear to work if hero 0 is in the first party slot.
Display posts from previous: