Post by SirMrChris on Jul 17, 2015 21:08:13 GMT
Now lets discuss how to create NPCs that tell you different things every time you talk to them. You can use the script you learned last time and place it in this time if you so desire:
Things You Will Need:
- SetText Script
- IsBlock Script
- NPC Block
- Proper Coordinates
- SetBlock Script
- If, Then, & ElseIf
To start you will have to either find the exact coordinates of the NPCs text you want to change, or their exact name.
1. Find the coordinates of block below where your NPC is going to go. Delete the block of the coordinates you have and place a Light Orange block there instead.
2. Place down the NPC block above the Light Orange block.
3. Begin your script. Go into the Dialogue folder from last time and create a new script called "TalkativeDialogue". (Or whatever you want to call it.)
4. Insert the following into the script:
If
Then
Else
5. Now put this script line between IF and THEN:
IsBlock [x,y,z] [LightOrange] [true]
- This script line checks to see if the block at that coordinate is in face a Light Orange block. Take the coordinates from step ONE and place them in your script line like so:
IsBlock [649,30,531] [LightOrange] [true]
6. After that, place these script lines between THEN and ELSEIF:
SetText [x,y,z] [Hello]
SetBlock [x,y,z] [Orange]
- Use the same tactic from earlier with the SetText line. You can use [rel: 0,0,0] in this situation because the NPC block is already recognized.
- Take the coordinates from step ONE or FIVE and put them in the SetBlock script line.
SetText [rel: 0,0,0] [Hello]
SetBlock [649,30,531] [Orange]
7. Recognize that this is only one variable and they can't say anything else. Let's look at the script all together.
If
IsBlock [649,30,531] [LightOrange]
Then
SetText [rel: 0,0,0] [Hello]
SetBlock [649,30,531] [Orange]
ElseIf
8. To add more variables, press down the left analog stick and drag down the entire script. Then press LB to copy it.
9. Paste the script and change the SetText, IsBlock, and SetBlock script lines.
- You will need to change the text to something different.
- You will need to change the IsBlock to the block that was on the SetBlock line previously (Orange)
- Finally, you will need to change the SetBlock to a different block. (Red)
If
IsBlock [649,30,531] [LightOrange]
Then
SetText [rel: 0,0,0] [Hello]
SetBlock [649,30,531] [Orange]
ElseIf
IsBlock [649,30,531] [Orange]
Then
SetText [rel: 0,0,0] [How are you doing?]
SetBlock [649,30,531] [Red]
ElseIf
Repeating this process will effectively allow you to create your own NPCs with dialogue that's different every time you speak to them! There you go! Now, go forth onto a scripting journey!
Next time we will be talking about how to make it so the NPCs are interactable, and how you can speak with them!
Things You Will Need:
- SetText Script
- IsBlock Script
- NPC Block
- Proper Coordinates
- SetBlock Script
- If, Then, & ElseIf
To start you will have to either find the exact coordinates of the NPCs text you want to change, or their exact name.
1. Find the coordinates of block below where your NPC is going to go. Delete the block of the coordinates you have and place a Light Orange block there instead.
2. Place down the NPC block above the Light Orange block.
3. Begin your script. Go into the Dialogue folder from last time and create a new script called "TalkativeDialogue". (Or whatever you want to call it.)
4. Insert the following into the script:
If
Then
Else
5. Now put this script line between IF and THEN:
IsBlock [x,y,z] [LightOrange] [true]
- This script line checks to see if the block at that coordinate is in face a Light Orange block. Take the coordinates from step ONE and place them in your script line like so:
IsBlock [649,30,531] [LightOrange] [true]
6. After that, place these script lines between THEN and ELSEIF:
SetText [x,y,z] [Hello]
SetBlock [x,y,z] [Orange]
- Use the same tactic from earlier with the SetText line. You can use [rel: 0,0,0] in this situation because the NPC block is already recognized.
- Take the coordinates from step ONE or FIVE and put them in the SetBlock script line.
SetText [rel: 0,0,0] [Hello]
SetBlock [649,30,531] [Orange]
7. Recognize that this is only one variable and they can't say anything else. Let's look at the script all together.
If
IsBlock [649,30,531] [LightOrange]
Then
SetText [rel: 0,0,0] [Hello]
SetBlock [649,30,531] [Orange]
ElseIf
8. To add more variables, press down the left analog stick and drag down the entire script. Then press LB to copy it.
9. Paste the script and change the SetText, IsBlock, and SetBlock script lines.
- You will need to change the text to something different.
- You will need to change the IsBlock to the block that was on the SetBlock line previously (Orange)
- Finally, you will need to change the SetBlock to a different block. (Red)
If
IsBlock [649,30,531] [LightOrange]
Then
SetText [rel: 0,0,0] [Hello]
SetBlock [649,30,531] [Orange]
ElseIf
IsBlock [649,30,531] [Orange]
Then
SetText [rel: 0,0,0] [How are you doing?]
SetBlock [649,30,531] [Red]
ElseIf
Repeating this process will effectively allow you to create your own NPCs with dialogue that's different every time you speak to them! There you go! Now, go forth onto a scripting journey!
Next time we will be talking about how to make it so the NPCs are interactable, and how you can speak with them!