Question about using the telephone
Marleen
10 Mar 2013, 11:41Hi everyone,
I'm a Quest beginner, which means that I'm mostly able to use the script 'first time' 'otherwise' and 'print message', which is okay but sometimes not enough, because I guess my game will be a bit boring when it's completely made of 'first time', 'otherwise''s...
So I have made a telephone and it actually works. The player would be able to dial 112 and 911 and he/she'll also get a message when he/she would dial another number, like 'wrong number!' However, I'd like to have something happen when '0402790326' is dialed and this won't work. It does work with 427 though so now I'm thinking: should each telephone number has three numbers at the most? This would be very weird because well, most telephone numbers have more numbers than just three! So what to do?
I have included a print screen so you can see what I have done.
Sorry in advance when I should have known this, but as I already said: I'm a complete beginner...
Thanks,
Marleen

I'm a Quest beginner, which means that I'm mostly able to use the script 'first time' 'otherwise' and 'print message', which is okay but sometimes not enough, because I guess my game will be a bit boring when it's completely made of 'first time', 'otherwise''s...
So I have made a telephone and it actually works. The player would be able to dial 112 and 911 and he/she'll also get a message when he/she would dial another number, like 'wrong number!' However, I'd like to have something happen when '0402790326' is dialed and this won't work. It does work with 427 though so now I'm thinking: should each telephone number has three numbers at the most? This would be very weird because well, most telephone numbers have more numbers than just three! So what to do?
I have included a print screen so you can see what I have done.
Sorry in advance when I should have known this, but as I already said: I'm a complete beginner...
Thanks,
Marleen
levicki
10 Mar 2013, 14:05Welcome to the forum.
Your mistake is twofold.
First, your number starts with "0".
Second, you did not put quotes around case keys.
Each of them on their own does nothing, but if combined it makes the comparison fail.
What happens is that "text" that the player types gets converted into an integer and is then compared as an integer with your case key.
So if you type "dial 040" #text# becomes "040" but since your key 040 does not have quotes (meaning it is treated as an integer by Quest) an implicit conversion is done and leading zero is discarded so text variable becomes 40 which of course cannot be matched.
You can solve this in two ways:
1. Change all your case keys to have quotes around them so that the comparison is always made between two strings. This is better way since you can include leading zeros and have really long numbers should you need them.
2. Use up to 9 digits without leading zeros for the phone numbers and don't put quotes around case keys. This is pretty limiting and error prone so I do not recommend you to use it, I am just including it so you can understand how things work.
Your mistake is twofold.
First, your number starts with "0".
Second, you did not put quotes around case keys.
Each of them on their own does nothing, but if combined it makes the comparison fail.
What happens is that "text" that the player types gets converted into an integer and is then compared as an integer with your case key.
So if you type "dial 040" #text# becomes "040" but since your key 040 does not have quotes (meaning it is treated as an integer by Quest) an implicit conversion is done and leading zero is discarded so text variable becomes 40 which of course cannot be matched.
You can solve this in two ways:
1. Change all your case keys to have quotes around them so that the comparison is always made between two strings. This is better way since you can include leading zeros and have really long numbers should you need them.
2. Use up to 9 digits without leading zeros for the phone numbers and don't put quotes around case keys. This is pretty limiting and error prone so I do not recommend you to use it, I am just including it so you can understand how things work.
Marleen
10 Mar 2013, 15:43levicki wrote:
You can solve this in two ways:
1. Change all your case keys to have quotes around them so that the comparison is always made between two strings. This is better way since you can include leading zeros and have really long numbers should you need them.
2. Use up to 9 digits without leading zeros for the phone numbers and don't put quotes around case keys. This is pretty limiting and error prone so I do not recommend you to use it, I am just including it so you can understand how things work.
Thank you. The first option seems best to me, because I prefer to have my telephone number started with a 0.
What do you mean with quote? These ones: "number"? Or something else?
Asyranok
10 Mar 2013, 17:42Here are some examples.
The first is of an Integer switch and the second is of a text switch. Note the differences. In the "key" area, you have phone numbers. But since you are asking the player for a string input, there must be quotes around those phone numbers. So, yes, you will need quotes around the numbers.


The first is of an Integer switch and the second is of a text switch. Note the differences. In the "key" area, you have phone numbers. But since you are asking the player for a string input, there must be quotes around those phone numbers. So, yes, you will need quotes around the numbers.


levicki
10 Mar 2013, 18:02Marleen wrote:Thank you. The first option seems best to me, because I prefer to have my telephone number started with a 0.
What do you mean with quote? These ones: "number"? Or something else?
You are welcome. Yes, I mean that you have to put quotes around numbers in your switch case statements like this "911", "112", "040xxxx", etc.
HegemonKhan
10 Mar 2013, 20:49here's just a visual of what Levicki is telling you:
(when I first was doing quest, all the terms overwhelmed and confused me, so it can be hard for noobs to understand what you're saying to them about these things)
look at your posted screen shot in your OP (opening post), it looks roughly like this:
Command: dial #text#
Command (Tab) ~ Attributes (Tab)
Pattern: [Command Pattern]
dial #text#
Name:
Unresolved object text:
Script:
Switch (text)
-> cases (add, and its big box below)
->-> key ~ script
->->-> 112 ~ Print (yada yada yada)
->->-> 911 ~ Print (yada yada yada)
->->-> 427 ~ Print (yada yada yada)
->->-> 0402790326 ~ Print (yada yada yada)
you need to change it to this (you'll probably case to delete your cases, and re-add them, to change the keys to having the quotes on them, or maybe you can just add the quotes to the keys without having to make new ones, I can't remember if you can type in a change to your keys or not):
Command: dial #text#
Command (Tab) ~ Attributes (Tab)
Pattern: [Command Pattern]
dial #text#
Name:
Unresolved object text:
Script:
Switch (text)
-> cases (add, and its big box below)
->-> key ~ script
->->-> "112" ~ Print (yada yada yada)
->->-> "911" ~ Print (yada yada yada)
->->-> "427" ~ Print (yada yada yada)
->->-> "0402790326" ~ Print (yada yada yada)
(when I first was doing quest, all the terms overwhelmed and confused me, so it can be hard for noobs to understand what you're saying to them about these things)
look at your posted screen shot in your OP (opening post), it looks roughly like this:
Command: dial #text#
Command (Tab) ~ Attributes (Tab)
Pattern: [Command Pattern]
dial #text#
Name:
Unresolved object text:
Script:
Switch (text)
-> cases (add, and its big box below)
->-> key ~ script
->->-> 112 ~ Print (yada yada yada)
->->-> 911 ~ Print (yada yada yada)
->->-> 427 ~ Print (yada yada yada)
->->-> 0402790326 ~ Print (yada yada yada)
you need to change it to this (you'll probably case to delete your cases, and re-add them, to change the keys to having the quotes on them, or maybe you can just add the quotes to the keys without having to make new ones, I can't remember if you can type in a change to your keys or not):
Command: dial #text#
Command (Tab) ~ Attributes (Tab)
Pattern: [Command Pattern]
dial #text#
Name:
Unresolved object text:
Script:
Switch (text)
-> cases (add, and its big box below)
->-> key ~ script
->->-> "112" ~ Print (yada yada yada)
->->-> "911" ~ Print (yada yada yada)
->->-> "427" ~ Print (yada yada yada)
->->-> "0402790326" ~ Print (yada yada yada)
Marleen
11 Mar 2013, 09:23HegemonKhan wrote:
you need to change it to this (you'll probably case to delete your cases, and re-add them, to change the keys to having the quotes on them, or maybe you can just add the quotes to the keys without having to make new ones, I can't remember if you can type in a change to your keys or not):
I think you can change the keys indeed, I'll definately try that. And indeed, the terms are a bit overwhelming and confusing...
@levicki: Thank you! I'm not a native speaker of English so I was just unaware that quote didn't only mean a quote like I quoted HegemonKhan now but also the punctuation marks...
levicki
11 Mar 2013, 13:12Marleen wrote:I think you can change the keys indeed, I'll definately try that. And indeed, the terms are a bit overwhelming and confusing...
Yes you can edit them, no need to delete and add again.
Marleen wrote:@levicki: Thank you! I'm not a native speaker of English so I was just unaware that quote didn't only mean a quote like I quoted HegemonKhan now but also the punctuation marks...
You are welcome. I am not a native English speaker myself. By the way its quotation marks

Marleen
14 Mar 2013, 14:14It works! Thank you guys/girls! 
