if (npc.parent = game.pov.parent) {
switch (GetRandomInt(1, 10)) {
case (1) {
msg ("'So what you going to do next?' says the NPC.")
}
case (2) {
msg ("'Well do something then,' says the NPC impatiently.")
}
}
}
<object name="npc">
<inherit name="editor_object" />
<attr name="dialogue" type="script">
hello_function
</attr>
<attr name="displayverbs" type="listextend">dialogue</attr>
</object>
<verb>
<property>dialogue</property>
<pattern>dialogue</pattern>
<defaultexpression>blah blah blah</defaultexpression>
</verb>
<function name="hello_function">
msg ("Hello")
hello_function
</function>
The Pixie wrote:Select Timers on the left hand, then click add to create a new timer, give it a name, tick yes to start at the beginning, and give a suitable interval, say 5 seconds (sounds like you have already done this bit). Then try thisif (npc.parent = game.pov.parent) {
switch (GetRandomInt(1, 10)) {
case (1) {
msg ("'So what you going to do next?' says the NPC.")
}
case (2) {
msg ("'Well do something then,' says the NPC impatiently.")
}
}
}
First line checks the NPC is in the same room as the player. Next line is the random bit. Note that on values 3 to 10 nothing happens, which will make interval of random length. You can add more case/msg sections as you like, and adjust GetRandomInt accordingly.
If you have more than one NPC, use the same timer, but just repeat the code, changing "npc" to the object name, and the texts.
function name="hello_function">
msg ("Hello")
hello_function
</function>
<function name="hello_function">
if (game.flag_1 = true) {
msg ("Hello")
ask ("Do you want to repeat this?") {
if (result = true) {
hello_function
} else if (result = false) {
// see the below comments about the 'else if'
}
}
} else if (game.flag_1 = false) {
// this 'else if' or just 'else' is optional, you don't need it.
// optional: some script: msg ("The looping stops")
}
</function>