Firstly, the list you are using doesn't seem to be functioning the way it is supposed to. Since the argument
flow is between parenthesis, it should get treated literally as part of a string value, rather than a
variable of its own. But if you amend the list like what follows then it should work fine:
testList = '''Welcome to Evarayn ''' + flow + ''', If you have any questions just ask!''', '''Hello there ''' + flow + ''', If you're in need of help or anything, just ask!''', '''Glad you could make it ''' + flow + ''', need help, just ask!''', '''-bows to ''' + flow + '''- Welcome, Enjoy your stay, and if you need any help... just ask.'''
The problem with the type mismatch is less obvious, but is still visible. The point of this script seems to be to send
a note to the world after a certain time period, however world.doAfter isn't exactly meant for this. It accepts a
string as its second argument, and you are trying to pass an entire function to it. That won't work. If function test
where to return a string then it would in fact work, but still world.doAfter can't do world.note's - it can only do
a world.send on a string you pass to it. Am I making sense?There's a different callback that can do what you seem to
want: world.DoAfterSpecial. That one can execute another function after a specified period of time. Here's what you could do:
import random
def test(flow):
number = int(random.randrange(0, 4))
testList = '''Welcome to Evarayn ''' + flow + ''', If you have any questions just ask!''', '''Hello there ''' + flow + ''', If you're in need of help or anything, just ask!''', '''Glad you could make it ''' + flow + ''', need help, just ask!''', '''-bows to ''' + flow + '''- Welcome, Enjoy your stay, and if you need any help... just ask.'''
return testList[number]
world.DoAfterSpecial(int(random.randrange(5, 10)), 'world.Note("newbie " + test("%1"))')
This wasn't at all tested, so I give no guarantees, however
the general idea should work. The idea of your script is
pretty nice actually, I think some people in my guild (who
should be watching this forum closely *stern look*) could
use it for their own newbie greetings if they manage to port it to vbScript on their own.
P.S.: Hope formatting will come out right.
P.P.S.: Nope, it didn't. Hope this edit works.
P.P.P.S.: Well, it's still ugly but I am tired of tweaking it.
P.P.P.P.S.: Ok, I realized that you were trying to cut the list into several lines with those backslashes too late, so ignore the part about the list not working - the original version will obviously work just fine. Ok, no more editing of this post... honest. |