Error running a get player input script
leftycool
13 Nov 2012, 03:58Hi, I'm trying to run a script which asks the player to enter a number code. if correct, a script runs to move an object, and if incorrect, nothing happens.
I'm working from a vague tutorial and I just need someone to take a quick look at the script and tell me what is incorrect. I'm sure it'll be easy to spot for someone versed in the program.
I dont have a strong scripting background so the answer is hard for me to find.

The error message I get is:
Error running script: Error compiling expression 'code = 4059': CompareElement: Operation 'Equal' is not defined for types 'String' and 'Int32'
thankyou in advance to anyone who helps
I'm working from a vague tutorial and I just need someone to take a quick look at the script and tell me what is incorrect. I'm sure it'll be easy to spot for someone versed in the program.
I dont have a strong scripting background so the answer is hard for me to find.

The error message I get is:
Error running script: Error compiling expression 'code = 4059': CompareElement: Operation 'Equal' is not defined for types 'String' and 'Int32'
thankyou in advance to anyone who helps

sgreig
13 Nov 2012, 04:06Try changing it to
When you store the number in the variable "code", it's stored as a string, but by not putting the numbers in quotes in the if statement, Quest looks for an integer which causes the screw-up.
code = "4509"
When you store the number in the variable "code", it's stored as a string, but by not putting the numbers in quotes in the if statement, Quest looks for an integer which causes the screw-up.
leftycool
13 Nov 2012, 04:33Thanks. the tutorial I was using said to not use quotations if I was entering a number, so I was confused.
sgreig
13 Nov 2012, 07:27Yes, that would be true if you were setting the value of a variable yourself, but user input is automatically made into a string if I'm not mistaken. As a point of interest, you could always use ToInt to convert the variable to an integer before you make the check as well, but it's easier to just add the quotation marks, I think.

Pertex
13 Nov 2012, 07:44Your "else if" is buggy , too. First, you don't need "Else if". Just use an "Else". But if you want to use "Else if" change it to
Else if: [expression] code<>"4059"