Several problems ErockMahan. The first is your using the rnd function wrong. The second is that when you use 'send to script' your literally sending the commands to an interpreter, so what the interpreter sees is *actually*:
Randomize
Note Int((2) * Rnd + 1)
If Rnd = 1 then
call laugh
If Rnd = 2 then
call sigh
endif
<end of code implies second end if>
In other words, if Rnd ever did come up as 1 or 2, it would attempt to 'call' a function named 'laugh' or 'sigh', instead of sending it to the mud. But this never happens, because you did the random number generation wrong too. Here is literally, in more human terms, what you asked it to do.
1. Seed the generator with the current time code.
2. Generate a random number and adjust it to the 1-2 range, then display it.
3. Start an if-then.
4. Generate a random number between 0 and .9999999, then test it against 1. Fails.
5. Start a new if-then
6. Generate a random number between 0 and .9999999, then test it against 2. Fails.
7. End the 'second' if-then.
8. Script exits, so never tells you that you forgot the 'end if' for the first if-then.
Now, the solution is simple. You need to place the value you generate in the 'note' into an actual variable. Rnd is itself a function call, not a variable. Due to the fact that all script inside a 'send to script' executes in what is called the global scope, you need a unique name. By global I mean that its shared automatically by 'all' script fragments and the main script, if you have one. This means that if you have a variable called 'Fish', which lets say contains the name of a type of fish you are trying to catch, but you also use 'Fish' someplace else, like for your random number, then 'Fish' would suddenly lose the value 'Salmon' and you would find yourself trying to catch a 1 or 2. Its one of the limitations of using 'send to script', which you have to be careful of. "Never" use the same name twice, unless you know you don't need to keep the value. For another example. You might use Count, to count how many times the line, "You see a fuzzy bunny!", comes up, but if you also use Count to do:
for Count = 1 to 5
send "heal"
next
Your going to have problems. So, to fix your current problem, we need to makes some adjustments. First, before showing the note, we need to drop it in a variable, fix your math a bit, then we need to fix the if-thens, so they work right and finally, we need to tell Mushclient to 'send' the words to the mud, so the script system doesn't assume they are names for something in the script itself:
Randomize
ls_num = Int(2 * Rnd) + 1
Note ls_num
If ls_num = 1 then
send "laugh"
end if
If ls_num = 2 then
send "sigh"
end if
And that should do it.
|