Introduction and question on patrolling enemy
Luceira
24 Jun 2016, 18:42Greetings! My name is Luce and i'm new here and new to Quest, only been using it for just about 24 hours now. I've had previous game engine experience in GameMaker: Studio so I picked this up quite quickly but obviously it's a learning process.
I'm making my first text adventure game as a sort of small demo of an idea I have and right off the bat there is a patrolling enemy. The enemy is in a hallway that is separated into four rooms. Hallway 1, Hallway 2, Hallway 3 and Hallway 4. The player enters the hallway at Hallway 3 which triggers a timer script for the guard at Hallway 1. Every 10 seconds he will move east down the hall. I have that working all fine and dandy. But my issue is getting him to turn round at the end of the hallway and go back.
So far I put an attribute on the guard called "dirright" set to boolean and true. The code detects if the guard has arrived at Hallway 4 and then if dirright is true it sets it to false.
When I run this I get this error:
I cannot for the life of me figure out what is wrong. I tried changing the attribute to Integer and to swap between 1 and 0 but it still gets the same error. Any ideas here? Thanks in advance!!
I'm making my first text adventure game as a sort of small demo of an idea I have and right off the bat there is a patrolling enemy. The enemy is in a hallway that is separated into four rooms. Hallway 1, Hallway 2, Hallway 3 and Hallway 4. The player enters the hallway at Hallway 3 which triggers a timer script for the guard at Hallway 1. Every 10 seconds he will move east down the hall. I have that working all fine and dandy. But my issue is getting him to turn round at the end of the hallway and go back.
So far I put an attribute on the guard called "dirright" set to boolean and true. The code detects if the guard has arrived at Hallway 4 and then if dirright is true it sets it to false.
When I run this I get this error:
Error running script: Error compiling expression 'dirright': Unknown object or variable 'dirright'
I cannot for the life of me figure out what is wrong. I tried changing the attribute to Integer and to swap between 1 and 0 but it still gets the same error. Any ideas here? Thanks in advance!!

jaynabonne
24 Jun 2016, 19:16You probably need something like "guard.dirright". Without an object as reference, something like "dirright" would be a local variable in the script, which you would not have defined.
Luceira
24 Jun 2016, 20:05jaynabonne wrote:You probably need something like "guard.dirright". Without an object as reference, something like "dirright" would be a local variable in the script, which you would not have defined.
I thought it could be that too. And I don't see how that's an issue because of how I have the coding done at the moment. Here's a screenshot of the coding it is having trouble with. This thing is pretty messy but idk if there is a way to just write it as code or not.


jaynabonne
24 Jun 2016, 20:14Those look ok (what is shown). Do you reference dirright anywhere else?
Luceira
24 Jun 2016, 20:47jaynabonne wrote:Those look ok (what is shown). Do you reference dirright anywhere else?
Only here.

It does have an Else statement attached to it though which is what i'm thinking could be the problem.
Luceira
24 Jun 2016, 21:20Nope just swapped it to a else if statement and nothing changed.

jaynabonne
24 Jun 2016, 21:40Would you be able to post your game? (as an attachment). That would make it easiest, if you don't mind sharing 

Luceira
24 Jun 2016, 21:55jaynabonne wrote:Would you be able to post your game? (as an attachment). That would make it easiest, if you don't mind sharing
Certainly, here you go.
(Hope i've done this correctly.)

jaynabonne
24 Jun 2016, 23:17For some reason, when it's doing the "set"s, it's not putting the attribute in quotes. So you're getting:
set (Guard, dirright, 0)
which makes it look for a variable named "dirright" to take the value of for the attribute. It should be coming out like
set (Guard, "dirright", 0)
In your set statements above, trying putting the attribute in quotes, like "dirright" instead of just the word dirright. See if it lets you do that. I don't use the gui script editor very much, so I don't know its nuances.
(Man, it's hard to talk about quotes unambiguously when you're also quoting things. )
set (Guard, dirright, 0)
which makes it look for a variable named "dirright" to take the value of for the attribute. It should be coming out like
set (Guard, "dirright", 0)
In your set statements above, trying putting the attribute in quotes, like "dirright" instead of just the word dirright. See if it lets you do that. I don't use the gui script editor very much, so I don't know its nuances.
(Man, it's hard to talk about quotes unambiguously when you're also quoting things. )
Luceira
24 Jun 2016, 23:51jaynabonne wrote:For some reason, when it's doing the "set"s, it's not putting the attribute in quotes. So you're getting:
set (Guard, dirright, 0)
which makes it look for a variable named "dirright" to take the value of for the attribute. It should be coming out like
set (Guard, "dirright", 0)
In your set statements above, trying putting the attribute in quotes, like "dirright" instead of just the word dirright. See if it lets you do that. I don't use the gui script editor very much, so I don't know its nuances.
(Man, it's hard to talk about quotes unambiguously when you're also quoting things. )
Yep that made it all work perfectly fine. Can't believe it was something silly like that. Thank you so much for your help!

jaynabonne
25 Jun 2016, 00:17Glad it worked. 
