(The first half is 'Yes/No Questions'.)
Last time, we went over the basics of scripting. I know that first lesson had a lot of stuff to read, but those were the basics. Which means, we will use those lines in lesson 1 over and over again, so I will only introduce the new material you encounter. So, these lessons will be much shorter than the first one. Anyways, after you can make a person talk, we will continue with the 'yes/no' questions.
Last time, we went over the basics of scripting. I know that first lesson had a lot of stuff to read, but those were the basics. Which means, we will use those lines in lesson 1 over and over again, so I will only introduce the new material you encounter. So, these lessons will be much shorter than the first one. Anyways, after you can make a person talk, we will continue with the 'yes/no' questions.
yesno_script.pks | |
File Size: | 0 kb |
File Type: | pks |
My script can be found below the pictures. Open it, and try to understand the script. See any old, familiar lines? See any new, unfamiliar lines?
#dyn 0x740000
#org @main
lock
faceplayer
message @talk
callstd MSG_YESNO
compare LASTRESULT YES
if == jump @yes
jump @no
#org @yes
message @speakyes
callstd MSG_NORMAL
release
end
#org @no
message @speakno
callstd MSG_NORMAL
release
end
#org @talk
= Do you want to learn?
#org @speakyes
= That's great!
#org @speakno
= Then go away.
Now, the beginning is mostly familiar. We have the dynamic offset, the script offset, lock, faceplayer, message, but the callstd value is different. Last time, we used 'NORMAL'. So, in a yes/no question, we need to tell the game that our message is going to be a yes/no style script. This callstd value will make the 'YES' and 'No' options available. But, what about the lines after the callstd?
compare LASTRESULT YES
if == jump @yes
jump @no
In programs like C++ and Java, we can make statements called 'If then statements'. The basic explanation is
If (this happens)
{
do this
}
else
{
do this
}
We use something similar to a 'if then' statement, and that is displayed in these 3 lines. First, you see
compare LASTRESULT YES
When you select 'yes' or 'no' in the game, the game will store the thing you selected into the 'LASTRESULT' value (otherwise known as 0x8001). So, this line will 'compare' the current value of 'LASTRESULT' with the value 'YES'.
if == jump @yes
jump @no
== means 'true', or equals, and '!=' means 'false', or does not equal. So, if the 'LASTRESULT' value was 'YES', then we will jump to '@yes'. However, if it was not 'YES' (in other words, you selected 'NO'), we jump to '@no'.
Notice that the first part of our script does not have a 'release' and 'end'. This is due to the 'jump' command. When we 'jump', we will go to another location of the script, so we will not need a 'release' and 'end' at the end of the first part of the script. We do need it at the end of the parts of the script we do jump to, which is '@yes' and '@no'.
Those are the only new lines in this script. Everything else should be familiar to you. So, let me test your knowledge. Let us write a script. However, I will not explain the format. I want you to write the script yourself. Afterwards, compare your script with my script (or compile the script in game) to see if the script works. Good Luck!
Scenario: A person is asking you if he/she should buy potions or not.
If you say 'yes', he will thank you for your opinion.
If you say 'no', he will ask you if he should buy pokeballs.
If you say 'yes' to his 'pokeballs' question, he will thank you for your opinion (feel free to copy/paste from the first 'yes').
If you say 'no' to his 'pokeballs' question, he will get frustrated, shouting 'AH! This is a hard decision.'
(This scenario may sound a bit complicated, but everything you need has either been explained in this lesson, or the previous lesson. Review any part that you don't quite understand.)
#dyn 0x740000
#org @main
lock
faceplayer
message @talk
callstd MSG_YESNO
compare LASTRESULT YES
if == jump @yes
jump @no
#org @yes
message @speakyes
callstd MSG_NORMAL
release
end
#org @no
message @speakno
callstd MSG_NORMAL
release
end
#org @talk
= Do you want to learn?
#org @speakyes
= That's great!
#org @speakno
= Then go away.
Now, the beginning is mostly familiar. We have the dynamic offset, the script offset, lock, faceplayer, message, but the callstd value is different. Last time, we used 'NORMAL'. So, in a yes/no question, we need to tell the game that our message is going to be a yes/no style script. This callstd value will make the 'YES' and 'No' options available. But, what about the lines after the callstd?
compare LASTRESULT YES
if == jump @yes
jump @no
In programs like C++ and Java, we can make statements called 'If then statements'. The basic explanation is
If (this happens)
{
do this
}
else
{
do this
}
We use something similar to a 'if then' statement, and that is displayed in these 3 lines. First, you see
compare LASTRESULT YES
When you select 'yes' or 'no' in the game, the game will store the thing you selected into the 'LASTRESULT' value (otherwise known as 0x8001). So, this line will 'compare' the current value of 'LASTRESULT' with the value 'YES'.
if == jump @yes
jump @no
== means 'true', or equals, and '!=' means 'false', or does not equal. So, if the 'LASTRESULT' value was 'YES', then we will jump to '@yes'. However, if it was not 'YES' (in other words, you selected 'NO'), we jump to '@no'.
Notice that the first part of our script does not have a 'release' and 'end'. This is due to the 'jump' command. When we 'jump', we will go to another location of the script, so we will not need a 'release' and 'end' at the end of the first part of the script. We do need it at the end of the parts of the script we do jump to, which is '@yes' and '@no'.
Those are the only new lines in this script. Everything else should be familiar to you. So, let me test your knowledge. Let us write a script. However, I will not explain the format. I want you to write the script yourself. Afterwards, compare your script with my script (or compile the script in game) to see if the script works. Good Luck!
Scenario: A person is asking you if he/she should buy potions or not.
If you say 'yes', he will thank you for your opinion.
If you say 'no', he will ask you if he should buy pokeballs.
If you say 'yes' to his 'pokeballs' question, he will thank you for your opinion (feel free to copy/paste from the first 'yes').
If you say 'no' to his 'pokeballs' question, he will get frustrated, shouting 'AH! This is a hard decision.'
(This scenario may sound a bit complicated, but everything you need has either been explained in this lesson, or the previous lesson. Review any part that you don't quite understand.)
Here are my scripts. I wrote 2 versions that give the same outcome.
yesno_script_answer_1.pks | |
File Size: | 1 kb |
File Type: | pks |
yesno_script_answer_2.pks | |
File Size: | 1 kb |
File Type: | pks |
If your script was correct, the result should look something like the images below.
What we learned today:
An extra 'callstd' and dialogue box type
'If-then' statements
Jumping to different parts of the script
Comparing values
How to write a 'YES/NO' question in PKSV-UI (Main Lesson)
So, this ends the 'YES/NO' Question tutorial. This page was much smaller than the first one, because all the basics have already (or should have already) been discussed, so I just talked about the new stuff. If you have 'Dialogue Scripts' down, why don't you go move onto the next stage of scripting: Giving Items?
An extra 'callstd' and dialogue box type
'If-then' statements
Jumping to different parts of the script
Comparing values
How to write a 'YES/NO' question in PKSV-UI (Main Lesson)
So, this ends the 'YES/NO' Question tutorial. This page was much smaller than the first one, because all the basics have already (or should have already) been discussed, so I just talked about the new stuff. If you have 'Dialogue Scripts' down, why don't you go move onto the next stage of scripting: Giving Items?