No Module Named 'Characters'

62 views
Skip to first unread message

Literally Mom

unread,
Mar 31, 2020, 9:47:47 AM3/31/20
to Evennia
Hey! So I'm having a blast going through the tutorials and getting a feel of this absolutely awesome engine, but I came upon an issue when trying the 'aggressive NPC' tutorial.

When I go into the rooms.py file and add this: 

# mygame/typeclasses/rooms.py

from evennia import utils
from characters import Character
from npc import Npc

   
# ... inside your Room typeclass ...
   
def at_object_receive(self, obj, source_location):
       
if utils.inherits_from(obj, 'Npc'): # An NPC has entered
           
pass
       
else:
           
if utils.inherits_from(obj, 'Character'):
               
# A PC has entered, NPC is caught above.
               
# Cause the character to look around
                obj
.execute_cmd('look')
               
for item in self.contents:
                   
if utils.inherits_from(item, 'Npc'):
                       
# An NPC is in the room
                        item
.at_char_entered(obj)

I get an error: 

2020-03-30.png

The characters module definitely exists. I've tried everything, but I just can't seem to figure it out. I'd love some help.. ALSO, maybe I'm missing something super simple, but could I get a rough explanation of how to construct a storage item? Like a box or a backpack or jug of water, whatever. I'm sure I'll figure it out pretty quick from there. I did make a couple simple objects with self.db attributes, but I feel like a container needs some sort of dictionary list or something? Somewhere to store the data of what is in there, and then edit it when the item is removed or emptied?

Matt McGlincy

unread,
Mar 31, 2020, 10:19:30 AM3/31/20
to eve...@googlegroups.com
I think you just need to specify the full python module name for your import: 

from typeclasses.characters import Character

wrt container objects, every Object has a .contents field which is a list of stuff inside it. E.g., things inside a room, or stuff your character is carrying. So, a box/backpack/chest/whatever could just be an Object subclass with .contents representing the objects inside it. If the you don't want the container object itself to be pick-up-able, you can restrict who can lock get() access. The tutorial world in evennia/contrib/tutorial_world does this for a barrel object: https://github.com/evennia/evennia/blob/10a6685fdf56c25c3e175df6753506af12f40d11/evennia/contrib/tutorial_world/build.ev#L442

hth,
-matt



--
You received this message because you are subscribed to the Google Groups "Evennia" group.
To unsubscribe from this group and stop receiving emails from it, send an email to evennia+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/evennia/b0a0c6c1-01f9-4146-a959-c8dd9eb67f82%40googlegroups.com.

Matt McGlincy

unread,
Mar 31, 2020, 10:23:49 AM3/31/20
to eve...@googlegroups.com

*restrict who can get it (pick it up) by locking get() access.

Kovitikus

unread,
Mar 31, 2020, 10:39:11 AM3/31/20
to Evennia
Try to change the import to:

from typeclasses import characters.Character

or it might me

from typeclasses.characters import Character

I forget which and I'm on mobile at the moment.


As far as storing items in things, all objects are containers, you just have to search that object for the object inside of it and use move_to.

I wrote an explanation for this to someone else in chat, so I'll just link you to that spot in the chat log.

https://irclogs.jackgrigg.com/irc.freenode.net/evennia/2020-03-22#i_4539538

Zude Onim

unread,
Mar 31, 2020, 3:01:12 PM3/31/20
to eve...@googlegroups.com
It might also be that you've indented the line :

def at_object_receive (blah blah)
everything else

It should be in-line with the line above it :

from evennia import DefaultRoom

I'm no expert, but I know that it goes bananas if the indentations are wrong.
Good luck.
> --
> You received this message because you are subscribed to the Google Groups
> "Evennia" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to evennia+u...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/evennia/276fc83c-85c8-4632-a89c-6277e2c87801%40googlegroups.com.
>
Reply all
Reply to author
Forward
0 new messages