<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>
sgreig 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.
sgreig 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.
TextingStories 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?
sgreig 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.
<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>
sgreig 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>
<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>