本文整理汇总了Python中wolfpack.utilities.hex2dec函数的典型用法代码示例。如果您正苦于以下问题:Python hex2dec函数的具体用法?Python hex2dec怎么用?Python hex2dec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hex2dec函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: getPlacementData
def getPlacementData(definition, dispid = 0, xoffset = 0, yoffset = 0, zoffset = 0):
node = wolfpack.getdefinition(WPDT_MULTI, definition)
if not node:
return (dispid, xoffset, yoffset, zoffset) # Return, wrong definition
if node.hasattribute('inherit'):
(dispid, xoffset, yoffset, zoffset) = getPlacementData(node.getattribute('inherit'), dispid, xoffset, yoffset, zoffset)
count = node.childcount
for i in range(0, count):
subnode = node.getchild(i)
if subnode.name == 'id': # Found the display id
dispid = hex2dec(subnode.value)
elif subnode.name == 'inherit': # Inherit another definition
if subnode.hasattribute('id'):
(dispid, xoffset, yoffset, zoffset) = getPlacementData(subnode.getattribute('id'), dispid, xoffset, yoffset, zoffset)
else:
(dispid, xoffset, yoffset, zoffset) = getPlacementData(subnode.value, dispid, xoffset, yoffset, zoffset)
elif subnode.name == 'placement': # Placement info
xoffset = hex2dec(subnode.getattribute('xoffset', '0'))
yoffset = hex2dec(subnode.getattribute('yoffset', '0'))
zoffset = hex2dec(subnode.getattribute('zoffset', '0'))
return (dispid, xoffset, yoffset, zoffset)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:25,代码来源:deed.py
示例2: parseTxt
def parseTxt( file, map ):
warnings = ''
count = 0
parseTickCount = 0
createTickCount = 0
propTickCount = 0
moveTickCount = 0
for line in file:
step1 = wolfpack.tickcount()
# Replace \r and \n's
line = line.replace( "\r", "" )
line = line.replace( "\n", "" )
( id, x, y, z, color ) = line.split( ' ' )
id = hex2dec( id )
baseid = '%x' % id
color = hex2dec( color )
x = int( x )
y = int( y )
z = int( z )
step2 = wolfpack.tickcount()
newitem = wolfpack.additem( '%s' % baseid ) # Generate a new serial for us
step3 = wolfpack.tickcount()
newitem.decay = 0
newitem.color = color
newitem.id = id
step4 = wolfpack.tickcount()
newposition = wolfpack.coord( x, y, z, map )
if not isValidPosition( newposition ):
newitem.delete()
continue
newitem.moveto( newposition )
step5 = wolfpack.tickcount()
parseTickCount += step2 - step1
createTickCount += step3 - step2
propTickCount += step4 - step3
moveTickCount += step5 - step4
newitem.update()
count += 1
print "Parsing: %i ticks" % parseTickCount
print "Creating: %i ticks" % createTickCount
print "Prop: %i ticks" % propTickCount
print "Move: %i ticks" % moveTickCount
return ( count, warnings )
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:58,代码来源:import.py
示例3: startElement
def startElement( self, name, atts ):
if name == "item":
self.itemid = str(atts.getValue("id"));
if "hue" in atts:
self.hue = int(hex2dec(str(atts.getValue("hue"))));
else:
self.hue = 0
if "amount" in atts:
self.amount = int(atts.getValue("amount"));
else:
self.amount = 0
self.statements = []
elif name == "attribute":
type = "str"
if "type" in atts:
type = str(atts.getValue("type"))
if "value" in atts and "key" in atts:
self.statements.append( str(atts.getValue("key")) + "," + type + ","+ str(atts.getValue("value")) )
elif name == "pos":
if int(hex2dec( self.itemid )) >= 0x4000:
item = wolfpack.addmulti( "%x" % hex2dec( self.itemid ) )
else:
item = wolfpack.additem( "%x" % hex2dec( self.itemid ) )
if not item or item == None:
return
if self.hue > 0:
item.color = self.hue
if self.amount > 0:
item.amount = self.amount
for p in self.statements:
parts = p.split(",")
if hasattr(item, parts[0]):
if parts[1] == "str":
value = parts[2]
elif parts[1] == "int":
value = int(parts[2])
setattr(item, parts[0], value)
x = int( atts.getValue("x") )
y = int( atts.getValue("y") )
z = int( atts.getValue("z") )
map = int( atts.getValue("map") )
item.moveto( x, y, z, map )
item.movable = 3 # not movable
item.decay = 0 # no decay
item.update()
elif name == "include":
path = atts.getValue("file")
if not os.path.isfile(path):
console.log(LOG_ERROR, tr("File '%s' not found.\n") % (path))
return
parser = xml.sax.make_parser()
handler = DecorationHandler()
parser.setContentHandler(handler)
parser.parse(path)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:56,代码来源:decoration.py
示例4: parseTxt
def parseTxt(file, map):
warnings = ""
count = 0
parseTickCount = 0
createTickCount = 0
propTickCount = 0
moveTickCount = 0
for line in file:
step1 = wolfpack.tickcount()
# Replace \r and \n's
line = line.replace("\r", "")
line = line.replace("\n", "")
(baseid, id, x, y, z, map, color) = line.split(" ")
baseid = baseid
id = hex2dec(id)
color = hex2dec(color)
x = int(x)
y = int(y)
z = int(z)
map = int(map)
step2 = wolfpack.tickcount()
newitem = wolfpack.additem("%s" % baseid) # Generate a new serial for us
step3 = wolfpack.tickcount()
newitem.decay = 0
newitem.color = color
newitem.id = id
step4 = wolfpack.tickcount()
newitem.moveto(x, y, z, map, 1)
step5 = wolfpack.tickcount()
parseTickCount += step2 - step1
createTickCount += step3 - step2
propTickCount += step4 - step3
moveTickCount += step5 - step4
newitem.update()
count += 1
print "Parsing: %i ticks" % parseTickCount
print "Creating: %i ticks" % createTickCount
print "Prop: %i ticks" % propTickCount
print "Move: %i ticks" % moveTickCount
return (count, warnings)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:55,代码来源:import.py
示例5: buildHouse
def buildHouse(house, definition):
node = wolfpack.getdefinition(WPDT_MULTI, definition)
if not node:
return
if node.hasattribute('inherit'):
value = str(node.getattribute('inherit'))
buildHouse(house, value) # Recursion
for i in range(0, node.childcount):
child = node.getchild(i)
# Inherit another definition
if child.name == 'inherit':
if child.hasattribute('id'):
buildHouse(house, child.getattribute('id'))
else:
buildHouse(house, child.value)
# Add a normal item to the house
elif child.name == 'item':
x = int(child.getattribute('x', '0'))
y = int(child.getattribute('y', '0'))
z = int(child.getattribute('z', '0'))
id = str(child.getattribute('id', ''))
item = wolfpack.additem(id)
item.moveto(house.pos.x + x, house.pos.y + y, house.pos.z + z, house.pos.map)
item.update()
# Add a house door to the house
elif child.name == 'door':
x = int(child.getattribute('x', '0'))
y = int(child.getattribute('y', '0'))
z = int(child.getattribute('z', '0'))
id = hex2dec(child.getattribute('id', ''))
item = wolfpack.additem('housedoor')
item.id = id
item.moveto(house.pos.x + x, house.pos.y + y, house.pos.z + z, house.pos.map)
item.update()
# Add a sign to the house
elif child.name == 'sign':
x = int(child.getattribute('x', '0'))
y = int(child.getattribute('y', '0'))
z = int(child.getattribute('z', '0'))
sign = wolfpack.additem('housesign')
if child.hasattribute('id'):
sign.id = hex2dec(child.getattribute('id', ''))
sign.moveto(house.pos.x + x, house.pos.y + y, house.pos.z + z, house.pos.map)
sign.update()
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:54,代码来源:house.py
示例6: createBoat
def createBoat( player, deed, pos ):
boat = wolfpack.addmulti(str(deed.gettag('multisection')))
if boat == None:
player.socket.sysmessage(tr('This deed is broken. Failed to create boat'))
boat.owner = player
boat.settag( 'boat_anchored', 1 )
boat.settag( 'boat_facing', 0 ) # boat is facing north
boat.settag( 'deedid', deed.baseid ) # For DryDock
boat.moveto(pos)
boat.update()
boat.decay = 0
if deed.hastag('hasname'):
boat.name = deed.name
splank = None
pplank = None
# Create special items
node = wolfpack.getdefinition(WPDT_MULTI, str(deed.gettag('multisection')) )
count = node.childcount
for i in range(0, count):
subnode = node.getchild(i)
if subnode.name == 'ids':
boat.settag('boat_id_north', hex2dec( subnode.getattribute( 'north', '0' ) ) )
boat.settag('boat_id_east', hex2dec( subnode.getattribute( 'east', '0' ) ) )
boat.settag('boat_id_south', hex2dec( subnode.getattribute( 'south', '0' ) ) )
boat.settag('boat_id_west', hex2dec( subnode.getattribute( 'west', '0' ) ) )
elif subnode.name == 'special_items': # Found section
subsubnode = subnode.findchild('tillerman')
if subsubnode != None:
tillerman = createBoatSpecialItem( '3e4e', subsubnode, boat )
boat.settag('boat_tillerman', tillerman.serial)
if deed.hastag('hasname'):
tillerman.name = 'Tillerman of ' + boat.name
subsubnode = subnode.findchild('hold')
if subsubnode != None:
hold = createBoatSpecialItem( '3eae', subsubnode, boat )
subsubnode = subnode.findchild('planks')
if subsubnode != None:
portclosed = subsubnode.findchild('port_closed')
pplank = createBoatSpecialItem( '3eb1', portclosed, boat )
starclosed = subsubnode.findchild('star_closed')
splank = createBoatSpecialItem( '3eb2', starclosed, boat )
splank.settag('plank_starboard', 1)
if not deed.hastag('lock'):
createKeys( splank, pplank, hold, boat, player )
else:
applyKeys( splank, pplank, hold, deed )
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:51,代码来源:deed.py
示例7: commandSettag
def commandSettag(socket, command, arguments):
# Split Arguments
if arguments.count(' ') < 2:
socket.sysmessage('Usage: settag name (int|string|float) value...')
return
(name, argtype, value) = arguments.split(' ', 2)
if argtype == 'int':
try:
value = hex2dec(value)
except:
socket.sysmessage('You specified an invalid integer value.')
return
elif argtype == 'float':
try:
value = float(value)
except:
socket.sysmessage('You specified an invalid floating point value.')
return
elif argtype == 'string':
value = unicode(value)
else:
socket.sysmessage('Usage: settag name (int|string|float) value...')
return
socket.attachtarget("commands.tags.settagResponse", [name, value])
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:27,代码来源:tags.py
示例8: parseMulti
def parseMulti( file, pos ):
warnings = ''
count = 0
for line in file:
# Replace \r and \n's
line = line.replace( "\r", "" )
line = line.replace( "\n", "" )
if len(line.split(' ')) != 5:
continue
( id, x, y, z, show ) = line.split(' ')
if not int(show):
continue
id = hex2dec( id )
x = int( x )
y = int( y )
z = int( z )
newitem = wolfpack.newitem(1) # Generate a new serial for us
newitem.decay = 0
newitem.id = id
newitem.moveto( pos.x + x, pos.y + y, pos.z + z, pos.map, 1 )
newitem.update()
count += 1
return ( count, warnings )
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:31,代码来源:import.py
示例9: add
def add(socket, command, arguments):
if len(arguments) > 0:
if wolfpack.getdefinition(WPDT_ITEM, arguments):
socket.sysmessage(tr("Where do you want to place the item '%s'?") % arguments)
socket.attachtarget("commands.add.additem", [arguments, False])
elif wolfpack.getdefinition(WPDT_NPC, arguments):
socket.sysmessage(tr("Where do you want to spawn the npc '%s'?") % arguments)
socket.attachtarget("commands.add.addnpc", [arguments])
elif wolfpack.getdefinition(WPDT_MULTI, arguments):
node = wolfpack.getdefinition(WPDT_MULTI, arguments)
count = node.childcount
for i in range(0, count):
subnode = node.getchild(i)
if subnode.name == "id": # Found the display id
dispid = hex2dec(subnode.value)
socket.sysmessage(tr("Where do you want to place the multi '%s'?") % arguments)
socket.attachmultitarget("commands.add.addmulti", dispid - 0x4000, [arguments, False], 0, 0, 0)
else:
socket.sysmessage(tr("No Item, NPC or Multi definition by that name found."))
return
global generated
if not generated:
generated = True
socket.sysmessage(tr("Generating add menu."))
socket.sysmessage(tr("Please wait..."))
generateAddMenu(socket.player.serial)
return
menu = findmenu("ADDMENU")
if menu:
menu.send(socket.player)
else:
socket.sysmessage(tr("No ADDMENU menu found."))
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:34,代码来源:add.py
示例10: sound
def sound( socket, command, arguments ):
try:
sound = hex2dec( str(arguments) )
socket.player.soundeffect( sound )
except:
socket.sysmessage( 'Usage: sound <sound-id>' )
return
开发者ID:Mutilador,项目名称:Wolfpack,代码行数:7,代码来源:sound.py
示例11: loadMenu
def loadMenu(id, parent = None):
definition = wolfpack.getdefinition(WPDT_MENU, id)
if not definition:
if parent:
console.log(LOG_ERROR, "Unknown submenu %s in menu %s.\n" % (id, parent.id))
else:
console.log(LOG_ERROR, "Unknown menu: %s.\n" % id)
return
name = definition.getattribute('name', '')
menu = TailoringMenu(id, parent, name)
# See if we have any submenus
for i in range(0, definition.childcount):
child = definition.getchild(i)
# Submenu
if child.name == 'menu':
if not child.hasattribute('id'):
console.log(LOG_ERROR, "Submenu with missing id attribute in menu %s.\n" % menu.id)
else:
loadMenu(child.getattribute('id'), menu)
# Craft an item
elif child.name in ['tailor', 'setailor']:
if not child.hasattribute('definition'):
console.log(LOG_ERROR, "Tailor action without definition in menu %s.\n" % menu.id)
else:
itemdef = child.getattribute('definition')
try:
# See if we can find an item id if it's not given
if not child.hasattribute('itemid'):
item = wolfpack.getdefinition(WPDT_ITEM, itemdef)
itemid = 0
if item:
itemchild = item.findchild('id')
if itemchild:
itemid = itemchild.value
else:
console.log(LOG_ERROR, "Tailor action with invalid definition %s in menu %s.\n" % (itemdef, menu.id))
else:
itemid = hex2dec(child.getattribute('itemid', '0'))
if child.hasattribute('name'):
name = child.getattribute('name')
else:
name = generateNamefromDef(itemdef)
if child.name == 'setailor':
action = SeTailorItemAction(menu, name, int(itemid), itemdef)
else:
action = TailorItemAction(menu, name, int(itemid), itemdef)
except:
console.log(LOG_ERROR, "Tailor action with invalid item id in menu %s.\n" % menu.id)
# Process subitems
for j in range(0, child.childcount):
subchild = child.getchild(j)
action.processnode(subchild, menu)
# Sort the menu. This is important for the makehistory to make.
menu.sort()
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:59,代码来源:tailoring.py
示例12: processnode
def processnode(self, node, menu):
global CLOTH
if node.name == 'cloth':
amount = hex2dec(node.getattribute('amount', '1'))
if amount > 0:
self.cloth = amount
else:
CraftItemAction.processnode(self, node, menu)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:8,代码来源:tailoring.py
示例13: commandRemove
def commandRemove(socket, cmd, args):
if len(args) > 0:
serial = hex2dec(args)
doRemoveSerial( socket, serial )
return True
socket.sysmessage( "Please select the object for removal." )
if( socket.account.authorized('Misc', 'May Remove Players') ):
socket.sysmessage( "Caution: This can remove players!" )
socket.attachtarget( "commands.remove.doRemove", [] )
return True
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:10,代码来源:remove.py
示例14: startElement
def startElement( self, name, atts ):
if name == "item":
self.itemid = str(atts.getValue("id"));
if atts.has_key("hue"):
self.hue = int(hex2dec(str(atts.getValue("hue"))));
else:
self.hue = 0
if atts.has_key("amount"):
self.amount = int(atts.getValue("amount"));
else:
self.amount = 0
self.statements = []
elif name == "attribute":
type = "str"
if atts.has_key("type"):
type = str(atts.getValue("type"))
if atts.has_key("value") and atts.has_key("key"):
self.statements.append( str(atts.getValue("key")) + "," + type + ","+ str(atts.getValue("value")) )
elif name == "pos":
item = wolfpack.additem( "%x" % hex2dec( self.itemid ) )
if not item or item == None:
return
if self.hue > 0:
item.color = self.hue
if self.amount > 0:
item.amount = self.amount
for p in self.statements:
parts = p.split(",")
if hasattr(item, parts[0]):
if parts[1] == "str":
value = parts[2]
elif parts[1] == "int":
value = int(parts[2])
setattr(item, parts[0], value)
x = int( atts.getValue("x") )
y = int( atts.getValue("y") )
z = int( atts.getValue("z") )
map = int( atts.getValue("map") )
item.moveto( x, y, z, map )
item.movable = 3 # not movable
item.decay = 0 # no decay
item.update()
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:43,代码来源:decoration.py
示例15: make
def make(self, player, arguments, nodelay=0):
node = wolfpack.getdefinition(WPDT_MULTI, self.definition)
count = node.childcount
for i in range(0, count):
subnode = node.getchild(i)
if subnode.name == "id": # Found the display id
dispid = hex2dec(subnode.value)
player.socket.sysmessage(tr("Where do you want to place the multi '%s'?") % self.definition)
player.socket.attachmultitarget("commands.add.addmulti", dispid - 0x4000, [self.definition, False], 0, 0, 0)
MakeAction.make(self, player, arguments, nodelay)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:10,代码来源:add.py
示例16: gouid
def gouid(socket, command, arguments):
try:
uid = hex2dec(arguments)
except:
socket.symsessage('Usage: gouid <serial>')
return
if uid > 0x40000000:
item = wolfpack.finditem(uid)
if item:
container = item.getoutmostitem()
if container.container:
container = container.container
# Going to container
socket.sysmessage('Going to item 0x%x (%s) [Top: 0x%x].' % (uid, item.getname(), container.serial))
pos = container.pos
socket.player.removefromview()
socket.player.moveto(pos)
socket.player.update()
socket.resendworld()
if item.container:
socket.sendobject(item.container)
if item.container.isitem():
socket.sendcontainer(item.container)
else:
socket.sysmessage('No item with the serial 0x%x could be found.' % uid)
return
elif uid > 0:
char = wolfpack.findchar(uid)
if char and char.rank <= socket.player.rank:
pos = char.pos
if pos.map == 0xFF:
if char.npc:
stablemaster = wolfpack.findobject(char.stablemaster)
else:
stablemaster = None
if not stablemaster:
socket.sysmessage("Not going to character '%s' [Serial: 0x%x]. They are on the internal map." % (char.name, uid))
else:
socket.sysmessage("Character '%s' [Serial: 0x%x] is stabled in object 0x%x." % (char.name, uid, stablemaster.serial))
else:
socket.sysmessage('Going to char 0x%x (%s).' % (uid, char.name))
socket.player.removefromview()
socket.player.moveto(pos)
socket.player.update()
socket.resendworld()
else:
socket.sysmessage('No char with the serial 0x%x could be found.' % uid)
return
socket.sysmessage('You specified an invalid serial: 0x%x.' % uid)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:54,代码来源:__init__.py
示例17: targetitem
def targetitem( char, args, target ):
socket = char.socket
if target.item:
# Find the target item.
finditem = wolfpack.finditem( target.item.serial )
# Safety Checks
if not finditem:
socket.sysmessage("You must target an item!")
return True
if ( finditem.lockeddown ) or ( not char.gm and finditem.movable > 1 ) or ( finditem.movable == 2 and finditem.owner != char ):
socket.sysmessage("This object is not movable by you!")
return True
# Object Exists
if finditem:
# Turnable Furniture
if finditem.id in TURNABLES:
finditem.id = utilities.hex2dec(TURNABLES[finditem.id][0])
finditem.update()
socket.sysmessage("You rotate the object.")
# Turnable Deeds
elif int(finditem.id) == utilities.hex2dec(0x14ef) and str(finditem.baseid) in TURNDEEDS:
if finditem.container != char.getbackpack():
socket.sysmessage("This deed needs to be in your backpack to turn it!")
return True
else:
finditem.settag( 'carpentry_type', str(TURNDEEDS[finditem.baseid][1]) )
finditem.name = str(TURNDEEDS[str(finditem.baseid)][2])
# Update BaseID Last
finditem.baseid = str(TURNDEEDS[finditem.baseid][0])
finditem.update()
socket.sysmessage("You rotate the deed's placement direction.")
return
# Error
else:
socket.sysmessage("This item is not turnable.")
return True
# Error
else:
socket.sysmessage("This item is not turnable.")
return True
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:41,代码来源:turnitem.py
示例18: bankself
def bankself( socket, command, arguments ):
layer = 0x1d
if len( arguments ) > 0:
try:
layer = hex2dec( arguments )
except:
socket.sysmessage( 'Usage: bank <layer-id>' )
return
socket.sysmessage( 'Please choose a target.' )
socket.attachtarget( "commands.bank.callback_bankself", [ layer ] )
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:12,代码来源:bank.py
示例19: dupe
def dupe(socket, command, arguments):
arguments = arguments.strip() # Remove trailing and leading whitespaces
amount = 1
if len( arguments ) > 0:
try:
amount = hex2dec(arguments)
except:
socket.sysmessage( 'Usage: dupe <amount>' )
return False
socket.sysmessage( 'Please choose an item to dupe.' )
socket.attachtarget( "commands.dupe.callback", [amount] )
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:13,代码来源:dupe.py
示例20: bank
def bank( socket, command, arguments ):
arguments = arguments.strip() # Remove trailing and leading whitespaces
layer = 0x1d
if len( arguments ) > 0:
try:
layer = hex2dec( arguments )
except:
socket.sysmessage( 'Usage: bank <layer-id>' )
return
socket.sysmessage( 'Please choose a target.' )
socket.attachtarget( "commands.bank.callback", [ layer ] )
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:13,代码来源:bank.py
注:本文中的wolfpack.utilities.hex2dec函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论