27 Sep, 2010, thaolen wrote in the 1st comment:
Votes: 0
Hello again, I'm working on a trigger that summons or loads a mob. I have a already working trigger for it but I wanted to give modules a shot, however in my efforts I have a error. I'm trying to debug this but I don't know enough about how NM words certain syntax. If anyone can help thanks

import mud, mudsys

def wish_cmd(ch, cmd, arg):

# arg.lower() == "i wish":
mob = load_mob("genie_lamp@examples", "treasure_room@examples", 'standing')
mud.message(ch, None, None, None, True, "to_char",
"Suddenly a Jinn appears waiting to grant your wish")


mudsys.add_cmd("wish", None, wish_cmd, "player", False)


Error:

[LOG: Error running Python command, wish:

Traceback (most recent call last):
File "../lib/pymodules/wish_command.py", line 6, in wish_cmd
mob = load_mob("genie_lamp@examples", "treasure_room@examples", 'standing')
NameError: global name 'load_mob' is not defined

[/code]

The code is setup to use the command wish inside of the mud. All is well until I type the command naturally. Summons my Jinn or it should. If you want to see the working trigger its just about the same. I tried to adapt it to a module.
27 Sep, 2010, Rudha wrote in the 2nd comment:
Votes: 0
load_mob is a member of the char module, and you need to import it. Otherwise, you appear to have called it correctly. The NameError is telling you that you currently have no command of that name loaded in memory; 99% of the time this is because you haven't imported it.

Maya/Rudha
27 Sep, 2010, thaolen wrote in the 3rd comment:
Votes: 0
wow that was fast I just posted that and its night time ;)
Thanks a million Rudha, don't want to sound dull but what is the import name called? load_mob perhaps?

disregard its (char) sorry
27 Sep, 2010, Rudha wrote in the 4th comment:
Votes: 0
from char import load_mob

You have the call right as far as I can see, you just dont have load_mob imported.

Maya/Rudha
27 Sep, 2010, thaolen wrote in the 5th comment:
Votes: 0
Quote
from char import load_mob

You have the call right as far as I can see, you just dont have load_mob imported.

Maya/Rudha


I don't get it I put from char import load_mob in my "module" and the mud won't start.
I tried import mud, mudsys, char : as well
27 Sep, 2010, Rudha wrote in the 6th comment:
Votes: 0
Check your mud logs for error messages; python has some silly things that it will fail on, whitespace incongruities being the infamous one.

Maya/Rudha
27 Sep, 2010, thaolen wrote in the 7th comment:
Votes: 0
I found this is the log

Error:
Traceback (most recent call last):                             
File "../lib/pymodules/wish_command.py", line 11, in <module>
mudsys.add_cmd("wish", None, wish_cmd, "player", False)
NameError: name 'mudsys' is not defined


Sep 27 03:28:25: Bootup aborted. MUD shutting down.



Now it says mudsys.add_cmd is not defined but I know it is, am I missing something?
27 Sep, 2010, Rudha wrote in the 8th comment:
Votes: 0
Make sure you have your imports like so:

from char import load_mob
import mud, mudsys

You were changing them around, you said, so it's possible something got messed. It's worth mentioning that you will only import the commands you explicitly specifiy, if you use FROM. You can go from char import * to import all the commands etc from the module, but this is considered a bad practice.

Maya/Rudha
27 Sep, 2010, thaolen wrote in the 9th comment:
Votes: 0
Quote
Make sure you have your imports like so:

from char import load_mob
import mud, mudsys

You were changing them around, you said, so it's possible something got messed. It's worth mentioning that you will only import the commands you explicitly specifiy, if you use FROM. You can go from char import * to import all the commands etc from the module, but this is considered a bad practice.

Maya/Rudha


Thanks I wasn't doing it that way. Its things like this that really help me out.

Ok, good that works

A place beyond your wildest dreams.

prompt>
wish
Suddenly a Jinn appears waiting to grant your wish

prompt>
l
[treasure_room@examples] [Inside] Treasure room
A place beyond your wildest dreams.
Here stands a Jinn


from char import load_mob
import mud, mudsys


def wish_cmd(ch, cmd, arg):

# arg.lower() == "i wish":
mob = load_mob("genie_lamp@examples", "treasure_room@examples", 'standing')
mud.message(ch, None, None, None, True, "to_char",
"Suddenly a Jinn appears waiting to grant your wish")


mudsys.add_cmd("wish", None, wish_cmd, "player", False)


He has been summoned with the wish command. I think I understand even better now about modules. With the help here and reading I've been doing.
0.0/9