[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ Python ➜ Ok, Weird problem Python + types.

Ok, Weird problem Python + types.

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Chronoti   USA  (27 posts)  Bio
Date Mon 19 Jan 2004 03:46 AM (UTC)
Message
I get this error, when this trigger fires.

Error number: -2147352567
Event: Execution of line 2 column 0
Description: Traceback (innermost last):
File "<Script Block 29>", line 10, in ?
world.doAfter(timeStop, test("Jonathan"))
File "<COMObject world>", line 2, in doAfter
COM Error: Type mismatch. (0x80020005)
Line in error:

Called by: Immediate execution


here is the script here:

import random
number = int(random.randrange(0, 4))
timeStop = int(random.randrange(5, 10))

def test(flow):
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."

world.note("newbie " + testList[number])

world.doAfter(timeStop, test("%1"))


I know it was working fine until I added the timeStop and doafter... so its something to do with that, although I don't see why.. Anyone help with this is much appreciated.
Top

Posted by Nick Gammon   Australia  (23,046 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 19 Jan 2004 05:17 AM (UTC)
Message
I'm not a great Python expert, but I would narrow it down a bit.

Try:

world.Note("timestop is " + timeStop)
world.doAfter(5, "testing doAfter")
world.doAfter(5, test("Jonathan"))


Depending on which one(s) work, you should be able to narrow down the problem.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Ked   Russia  (524 posts)  Bio
Date Reply #2 on Mon 19 Jan 2004 01:03 PM (UTC)

Amended on Mon 19 Jan 2004 01:13 PM (UTC) by Ked

Message
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.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


11,323 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]