What is the best way to ...?
Omega001
28 May 2012, 18:31I want to make a character change what room they are in over a period of time, if I use a timer script if it's the best way.
The time lapse would be like:
character in room 1
10 mins
character in room 2
10 mins
character in room 3
10 mins
and I want this to loop so the character is in room 1 again after room 3.
I've not coded this yet. I just want to know the best way to do this since my first attempt broke the entire game.
The time lapse would be like:
character in room 1
10 mins
character in room 2
10 mins
character in room 3
10 mins
and I want this to loop so the character is in room 1 again after room 3.
I've not coded this yet. I just want to know the best way to do this since my first attempt broke the entire game.

Pertex
29 May 2012, 07:40The rooms don't have exits? So I would start a timer when player is entering the rooms
Omega001
29 May 2012, 09:44No, I need a NPC to move to different location.
sgreig
30 May 2012, 04:27I haven't tested this, but if you're wanting the NPC to move in 10 minute intervals you would probably want to set up along these lines:
This code creates a timer that's enabled from the start of the game. Every 10 minutes, it checks the parent of the npc object (what room it's in), and then moves the npc to the next room (i.e. if npc is in room1, move to room2, etc.) and will move the npc back to room1 if the npc is currently in room3.
<timer name="npcMove">
<interval>600</interval>
<enabled />
<script>
if (npc.parent = room1) {
MoveObject (npc, room2)
}
else if (npc.parent = room2) {
MoveObject (npc, room3)
}
else if (npc.parent = room3) {
MoveObject (npc, room1)
}
</script>
</timer>
This code creates a timer that's enabled from the start of the game. Every 10 minutes, it checks the parent of the npc object (what room it's in), and then moves the npc to the next room (i.e. if npc is in room1, move to room2, etc.) and will move the npc back to room1 if the npc is currently in room3.
TextingStories
09 Jun 2012, 05:19sgreig wrote:I haven't tested this, but if you're wanting the NPC to move in 10 minute intervals you would probably want to set up along these lines:
<timer name="npcMove">
<interval>600</interval>
<enabled />
<script>
if (npc.parent = room1) {
MoveObject (npc, room2)
}
else if (npc.parent = room2) {
MoveObject (npc, room3)
}
else if (npc.parent = room3) {
MoveObject (npc, room1)
}
</script>
</timer>
This code creates a timer that's enabled from the start of the game. Every 10 minutes, it checks the parent of the npc object (what room it's in), and then moves the npc to the next room (i.e. if npc is in room1, move to room2, etc.) and will move the npc back to room1 if the npc is currently in room3.
I am extremely ignorant to things of this game. Where exactly and or how do you put that code into the game and how did you know how to do it to begin with? Like where is there a section on just coding for the game or games of this type in general? (And I do not mean like one sentence either, I mean explanations etc. Like why are there so many “{“ and “}” and why are they on separate lines and by themselves etc.?) The help file/tutorial gives the most basic of basics or just throws you in it.
I am actually needing something like this for my own game. I virtually have the entire game mapped out now, 90% of all my rooms with descriptions etc. I just have to put the finishing touches and a whole lot of code work. How would I get what you showed here to not do it later? Like at some point in the game I do not want the NPCs to roam for what ever reason. Is there a way to have them do it and then at a certain point you get to a part of the game and come back and then and ONLY then they are no longer “moving” or are elsewhere in the game?
sgreig
09 Jun 2012, 07:32Some of your questions go beyond the scope of posting in a forum, but I'll try to give you the gist of some of it.
I entered the code using Quest's built-in code editor, which is accessible from the tool bar on the downloadable version. Basically, when you're using the GUI editor in Quest, it's just converting what you put into the dropdown menus and stuff into Quest's native scripting language, called aslx. When you're getting into more complicated stuff in Quest, it's a lot quicker and more efficient to write code that way instead of using the GUI. The GUI is best suited to more simple things.
As for why there are "{" and "}" symbols in the code, that's definitely beyond scope here, but suffice it to say curly braces are common features of programming languages that denote when blocks of code begin and end.
Another advantage of using the code editor is that it's a lot easier to post code into the forum. If I was to try to show how to do it with the GUI, I would have to take a bunch of screen shots and edit/crop them and post them into the message which is a lot more work.
As for your question about how I knew how to do it? It comes with experience. I'm by no means an expert at Quest, but by working on my own projects, and by using the wiki and asking for help when necessary, I've been able to put things together. It helps that I have a bit of a background in programming to begin with, but basically practice makes perfect. If you want to learn how to do actual coding, I'd suggest using the GUI to make some scripts, and then look at the resulting code in the code editor so you can figure out how things are put together.
I entered the code using Quest's built-in code editor, which is accessible from the tool bar on the downloadable version. Basically, when you're using the GUI editor in Quest, it's just converting what you put into the dropdown menus and stuff into Quest's native scripting language, called aslx. When you're getting into more complicated stuff in Quest, it's a lot quicker and more efficient to write code that way instead of using the GUI. The GUI is best suited to more simple things.
As for why there are "{" and "}" symbols in the code, that's definitely beyond scope here, but suffice it to say curly braces are common features of programming languages that denote when blocks of code begin and end.
Another advantage of using the code editor is that it's a lot easier to post code into the forum. If I was to try to show how to do it with the GUI, I would have to take a bunch of screen shots and edit/crop them and post them into the message which is a lot more work.
As for your question about how I knew how to do it? It comes with experience. I'm by no means an expert at Quest, but by working on my own projects, and by using the wiki and asking for help when necessary, I've been able to put things together. It helps that I have a bit of a background in programming to begin with, but basically practice makes perfect. If you want to learn how to do actual coding, I'd suggest using the GUI to make some scripts, and then look at the resulting code in the code editor so you can figure out how things are put together.
TextingStories
10 Jun 2012, 07:19sgreig wrote:As for your question about how I knew how to do it? It comes with experience. I'm by no means an expert at Quest, but by working on my own projects, and by using the wiki and asking for help when necessary, I've been able to put things together. It helps that I have a bit of a background in programming to begin with, but basically practice makes perfect. If you want to learn how to do actual coding, I'd suggest using the GUI to make some scripts, and then look at the resulting code in the code editor so you can figure out how things are put together.
Ok I will try what you suggested. I have looked at the wiki, but to me it looks all gibberish. Half the time they give you a short sentence, but no actual meaning behind it for a function or script. And I searched through all eight or so pages of Quest 5 and then even looked at a page or two of Quest 4. (But figured Quest 4 might be pointless if major changes have taken place and I had read a couple of posts of how things had changed.) The wiki I am assuming is the place where when in game and you go to "Help" and then "View Help" it takes you there or are you talking of another wiki... there are so many wikis now in general it is not even funny.
In the mean time though, with what you have posted, have you actually tried it yet and it works? Do I simply copy and paste it any where in the code section or all the way at the bottom or in the middle or in a certain room? Also do I leave it as you put it exactly or do I change (npc.parent = room1) to the actual name of the guard? (kevin.parent = room1) or <timer name="npcmove"> to <timer name="kevinmove"> etc?
I want to learn and I hate asking questions, especially where others are usually like "this is easy", but to me it is like I have no clue from start to finish.

Ps. We need a Quest 5 For Dummies.


Pertex
10 Jun 2012, 07:47If you really want to learn coding I would suggest starting with learning VBA or VB. VBA is "Visual Basic for Application" and is integrated in Microsoft Office (Winword, Excel..). You can find lots of books how to learn it (even a "for Dummies" version
).
If you do understand the logic and syntax of VBA then you will have no problems to write scripts in Quest.

If you do understand the logic and syntax of VBA then you will have no problems to write scripts in Quest.
sgreig
10 Jun 2012, 11:41TextingStories wrote:
In the mean time though, with what you have posted, have you actually tried it yet and it works? Do I simply copy and paste it any where in the code section or all the way at the bottom or in the middle or in a certain room? Also do I leave it as you put it exactly or do I change (npc.parent = room1) to the actual name of the guard? (kevin.parent = room1) or <timer name="npcmove"> to <timer name="kevinmove"> etc?
I'm pretty sure you can paste the code at the bottom of the document in the code editor without any problems, and yes you'd need to change the script slightly to use the object and room names you're using in your game, but the script will work.
TextingStories
11 Jun 2012, 04:56sgreig wrote:"TextingStories"
In the mean time though, with what you have posted, have you actually tried it yet and it works? Do I simply copy and paste it any where in the code section or all the way at the bottom or in the middle or in a certain room? Also do I leave it as you put it exactly or do I change (npc.parent = room1) to the actual name of the guard? (kevin.parent = room1) or <timer name="npcmove"> to <timer name="kevinmove"> etc?
I'm pretty sure you can paste the code at the bottom of the document in the code editor without any problems, and yes you'd need to change the script slightly to use the object and room names you're using in your game, but the script will work.
Yes it worked! Thank you. However, I was staring at my screen thinking it was not working... I mean Jerry (That is my NPC name.) never left the room. I was like crap, I must have done something wrong then something caught my eye. Jerry was arriving and leaving my "Places and Objects" list on the right. But he never left my actual game screen or it's original place/line on the screen. I kept clicking on him trying to look at him and it was telling me, "I can't see that.", but he stayed clickable. I have seen other games where it informs the player that "NPC has arrived from the N." and then "NPC has departed to the S.". How do I go about doing that? That way my screen is being updated and the lines move up and eventually out of site. I could just keep typing "L" or "Look", but that seems unnatural for the player. Where would I stick a print message in all that code? (Assuming it is a print message... or if dashes or slashes must be used etc.) Also what if I wanted to talk to Jerry. Right now I have him on 10 second intervals of roaming, because I want my reactions quick when testing. But what if I wanted to talk to him? If I tried to interact with him and was actually in a conversation with him, when his 10 seconds are up regardless of what he is doing, will he just leave again? And if so, how do I stop him from leaving when I was in an active conversation with him?
Here is the code that I reworked for my testing game... I do not think I will ever use new testing code on my actual game for fear of damaging it.
<timer name="JerryMove">
<interval>10</interval>
<enabled />
<script>
if (Jerry.parent = lounge) {
MoveObject (Jerry, kitchen)
}
else if (Jerry.parent = kitchen) {
MoveObject (Jerry, bathroom)
}
else if (Jerry.parent = bathroom) {
MoveObject (Jerry, lounge)
}
</script>
</timer>
sgreig
11 Jun 2012, 08:20This is again untested but something along these lines should work.
<timer name="JerryMove">
<interval>10</interval>
<enabled />
<script>
if (Jerry.parent = lounge) {
if (Jerry.parent = player.parent) {
msg ("Jerry goes to the Kitchen.")
MoveObject (Jerry, kitchen)
}
else {
MoveObject (Jerry, kitchen)
if (Jerry.parent = player.parent) {
msg ("Jerry arrives from the lounge.")
}
}
}
else if (Jerry.parent = kitchen) {
if (Jerry.parent = player.parent) {
msg ("Jerry heads to the Bathroom.")
MoveObject (Jerry, bathroom)
}
else {
MoveObject (Jerry, bathroom)
if (Jerry.parent = player.parent) {
msg ("Jerry arrives from the Kitchen.")
}
}
}
else if (Jerry.parent = bathroom) {
if (Jerry.parent = player.parent) {
msg ("Jerry goes to the Lounge.")
MoveObject (Jerry, lounge)
}
else {
MoveObject (Jerry, lounge)
if (Jerry.parent = player.parent) {
msg ("Jerry arrives from the Bathroom.")
}
}
}
</script>
</timer>
TextingStories
11 Jun 2012, 23:42sgreig wrote:This is again untested but something along these lines should work.
<timer name="JerryMove">
<interval>10</interval>
<enabled />
<script>
if (Jerry.parent = lounge) {
if (Jerry.parent = player.parent) {
msg ("Jerry goes to the Kitchen.")
MoveObject (Jerry, kitchen)
}
else {
MoveObject (Jerry, kitchen)
if (Jerry.parent = player.parent) {
msg ("Jerry arrives from the lounge.")
}
}
}
else if (Jerry.parent = kitchen) {
if (Jerry.parent = player.parent) {
msg ("Jerry heads to the Bathroom.")
MoveObject (Jerry, bathroom)
}
else {
MoveObject (Jerry, bathroom)
if (Jerry.parent = player.parent) {
msg ("Jerry arrives from the Kitchen.")
}
}
}
else if (Jerry.parent = bathroom) {
if (Jerry.parent = player.parent) {
msg ("Jerry goes to the Lounge.")
MoveObject (Jerry, lounge)
}
else {
MoveObject (Jerry, lounge)
if (Jerry.parent = player.parent) {
msg ("Jerry arrives from the Bathroom.")
}
}
}
</script>
</timer>
Actually that did work, with one minor issue, he goes from the first room to the second and then to the third room, but skips going back through the second room entirely and magically gets to the first room again and then it repeats 1st, 2nd and 3rd. 1st, 2nd and 3rd. I would like 1st, 2nd, 3rd, 2nd, 1st, 2nd, 3rd etc. The code we have works good in an enviroment where it is out in the open and he makes a complete circle, but not in a string of hallways and or rooms where he has to come back through where he had just come from to make it look realisitc. I tried to add to the last section of code with it going back to the second room and then to the first again, but now he is trapped between the second and the third rooms. Now he never gets back to the first room.

sgreig
12 Jun 2012, 06:50
<timer name="JerryMove">
<interval>10</interval>
<enabled />
<script>
if (Jerry.parent = lounge) {
cycle_back = 0
if (Jerry.parent = player.parent) {
msg ("Jerry goes to the Kitchen.")
MoveObject (Jerry, kitchen)
}
else {
MoveObject (Jerry, kitchen)
if (Jerry.parent = player.parent) {
msg ("Jerry arrives from the lounge.")
}
}
}
else if (Jerry.parent = kitchen) {
if (cycle_back = 0) {
if (Jerry.parent = player.parent) {
msg ("Jerry heads to the Bathroom.")
MoveObject (Jerry, bathroom)
}
else {
MoveObject (Jerry, bathroom)
if (Jerry.parent = player.parent) {
msg ("Jerry arrives from the Kitchen.")
}
}
else {
if (Jerry.parent = player.parent) {
msg ("Jerry heads to the Lounge./")
MoveObject (Jerry, lounge)
}
else {
MoveObject (Jerry, lounge)
if (Jerry.parent = player.parent) {
msg ("Jerry arrives from the Kitchen.")
}
}
}
}
else if (Jerry.parent = bathroom) {
cycle_back = 1
if (Jerry.parent = player.parent) {
msg ("Jerry goes to the Kitchen.")
MoveObject (Jerry, kitchen)
}
else {
MoveObject (Jerry, kitchen)
if (Jerry.parent = player.parent) {
msg ("Jerry arrives from the Bathroom.")
}
}
}
</script>
</timer>
I'm not 100% this will work as I'm kinda tired at the moment, so you might need to tweak it, but essentially a variable called cycle_back is set to 0 when Jerry is in the lounge, and set to 1 when he gets to the Bathroom. When he gets into the kitchen, it checks the value of cycle_back, and if it's 0 it should move him to the bathroom, and if it's 1 it should move him to the lounge.