470,641 Members | 1,567 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,641 developers. It's quick & easy.

How To Uses Modules And Plugins

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.
Apr 6 '08 #1
2 1166
Lie
On Apr 7, 12:28 am, mar...@everautumn.com wrote:
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()

Apr 6 '08 #2
En Sun, 06 Apr 2008 14:28:44 -0300, <ma****@everautumn.comescribió:
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.

--
Gabriel Genellina

Apr 6 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Rob Snyder | last post: by
5 posts views Thread by Jiri Barton | last post: by
1 post views Thread by censored | last post: by
reply views Thread by william | last post: by
6 posts views Thread by Walter Brunswick | last post: by
reply views Thread by Greg Conely via .NET 247 | last post: by
1 post views Thread by Korara | last post: by
???
1 post views Thread by Stoney L | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.