[wpdev-commits] xmlscripts/scripts/wolfpack/commands decoration.py,NONE,1.1
Brought to you by:
rip,
thiagocorrea
|
From: <thi...@us...> - 2003-08-29 17:58:19
|
Update of /cvsroot/wpdev/xmlscripts/scripts/wolfpack/commands
In directory sc8-pr-cvs1:/tmp/cvs-serv32230/wolfpack/commands
Added Files:
decoration.py
Log Message:
added 'decoration command.
Takes RunUO .cfg files to generate the world decoration
--- NEW FILE: decoration.py ---
#===============================================================#
# ) (\_ | WOLFPACK 13.0.0 Scripts #
# (( _/{ "-; | Created by: Correa #
# )).-' {{ ;'` | Revised by: #
# ( ( ;._ \\ ctr | Last Modification: Created #
#===============================================================#
import wolfpack
from wolfpack.utilities import hex2dec
import os
def processFile( filename, map ):
count = 0
file = open( filename, "r")
itemtype = ""
itemid = 0
line = file.readline()
while len(line) != 0:
line = line.strip()
if line.startswith("#"):
line = file.readline()
continue
parts = line.split(" ")
if len( parts ) < 2:
line = file.readline()
continue
else:
if not parts[0].isdigit():
# Type + ID + Junk
itemtype = parts[0]
itemid = parts[1]
elif parts[0].isdigit() and parts[1].isdigit() and parts[2].isdigit:
# position
x = int( parts[0] )
y = int( parts[1] )
z = int( parts[2] )
item = wolfpack.additem( "%x" % hex2dec( itemid ) )
if not item:
print "Ops!"
else:
item.moveto( x, y, z, map )
item.decay = 0;
item.update()
count += 1
line = file.readline()
file.close()
return count
def generate( folder, map ):
count = 0
try:
files = os.listdir( folder )
for filename in files:
if filename.endswith(".cfg"):
count += processFile( folder + filename, map )
return count
except:
return 0
def onLoad():
wolfpack.registercommand("decoration", "wolfpack.commands.decoration")
def onCommand( socket, command, arguments ):
char = socket.player
socket.sysmessage("Generating world decoration, please wait.")
count = 0;
if wolfpack.hasmap( 0 ):
count += generate( "Data/Decoration/Britannia/", 0 )
count += generate( "Data/Decoration/Trammel/", 0 )
if wolfpack.hasmap( 1 ):
count += generate( "Data/Decoration/Britannia/", 1 )
count += generate( "Data/Decoration/Felucca/", 1 )
if wolfpack.hasmap( 2 ):
count += generate( "Data/Decoration/Ilshenar", 2 )
if wolfpack.hasmap( 3 ):
count += generate( "Data/Decoration/Malas", 3 )
socket.sysmessage("World generating complete. %i items were generated." % count )
|