How To Uses Modules And Plugins

M

marion

I am working on a client/server, computer role-play game using Python.
I want to gradually expand the game world by creating maps as
individual py files in a map directory. I am a little foggy of how to
do this. I have read about the __import__() function. I want to
understand what the difference is between using modules and plugins.
Are they the same thing? How will my root script interact with the
individual modules once it has loaded them? If you can point me to a
web site or tutorial on this subject I would be thankful.
 
L

Lie

I am working on a client/server, computer role-play game using Python.
I want to gradually expand the game world by creating maps as
individual py files in a map directory. I am a little foggy of how to
do this. I have read about the __import__() function. I want to
understand what the difference is between using modules and plugins.
Are they the same thing? How will my root script interact with the
individual modules once it has loaded them? If you can point me to a
web site or tutorial on this subject I would be thankful.

I think you're doing it with the wrong approach, a map is a data so it
should not be placed in a .py file, instead it should be placed in
something like .map files which is read by your program to generate
the map object. To read a file in python, use:

f = file('path/path/file.map', 'r') # for reading
g = file('path/path/file.map', 'rw') # for read and write

m = f.readline() # To read until meeting a '\n'
n = f.read() # To read until EOF (End of File)
for line in g:
#
# To read the file line by line
# using the very convenient for
#

f.close() # Don't forget to close the file after use
g.close()
 
G

Gabriel Genellina

I am working on a client/server, computer role-play game using Python.
I want to gradually expand the game world by creating maps as
individual py files in a map directory. I am a little foggy of how to
do this. I have read about the __import__() function. I want to
understand what the difference is between using modules and plugins.
Are they the same thing? How will my root script interact with the
individual modules once it has loaded them? If you can point me to a
web site or tutorial on this subject I would be thankful.

Look for recent posts about "plugin" in this group.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top