本文整理汇总了Python中mufsim.gamedb.getobj函数的典型用法代码示例。如果您正苦于以下问题:Python getobj函数的具体用法?Python getobj怎么用?Python getobj使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getobj函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compile_source
def compile_source(self, prog):
comp = CompiledMuf(prog)
self.compiled = comp
self.line = 1
self.word_line = 1
self.stmt_stack = []
self.funcname = None
self.defines = dict(self.builtin_defines)
self.include_defs_from(0, suppress=True)
src = db.getobj(prog).sources
try:
code, src = self.compile_r(src)
if self.funcname:
raise MufCompileError("Function incomplete.")
self.check_for_incomplete_block()
if code:
for inum, inst in enumerate(code):
if type(inst) in [
instfl.InstTry,
instfl.InstJmp,
instfl.InstJmpIfFalse
]:
inst.value += inum
comp.code = code
db.getobj(prog).compiled = comp
return True
return False
except MufCompileError as e:
errlog("Error in line %d: %s" % (self.word_line, e))
return None
示例2: usercmd_at_dig
def usercmd_at_dig(proclist, descr, user, cmd):
if user is None or user == -1:
notify_descr_or_user(descr, user, "Huh?")
return
userobj = db.getobj(user)
roomname, cmd = getword(cmd, '=')
envroom, regname = getword(cmd, '=')
regname = regname.strip()
envref = db.match_from(userobj.dbref, envroom)
if not db.validobj(envref):
userobj.notify("I don't know which room you mean.")
return
envobj = db.getobj(envref)
if envobj.objtype != "room":
userobj.notify("I don't know which room you mean.")
return
newroom = db.DBObject(
name=roomname.strip(),
objtype="room",
location=envobj.dbref,
owner=user,
)
if regname:
db.register_obj(user, regname, newroom.dbref)
userobj.notify("Room created as #%d." % newroom.dbref)
示例3: debug_cmd_break
def debug_cmd_break(self, args):
addr = self.fr.curr_addr()
prog = addr.prog
if ' ' in args:
prg, args = args.split(' ', 1)
prg = prg.strip()
args = args.strip()
obj = db.match_dbref(prg)
if obj == -1:
obj = db.match_registered(db.getobj(0), prg)
obj = db.getobj(obj)
if not db.validobj(obj):
log("Invalid program!")
return
if db.getobj(obj).objtype != "program":
log("Invalid program!")
return
prog = obj
addr = self.fr.program_function_addr(prog, args)
if addr:
line = self.fr.get_inst_line(addr)
bpnum = self.fr.add_breakpoint(prog, line)
log("Added breakpoint %d at #%d line %d." % (bpnum, prog, line))
elif util.is_int(args):
line = int(args)
bpnum = self.fr.add_breakpoint(prog, line)
log("Added breakpoint %d at #%d line %d." % (bpnum, prog, line))
else:
log("Usage: break [PROG] LINE")
log(" or: break [PROG] FUNCNAME")
示例4: usercmd_page
def usercmd_page(proclist, descr, user, cmd):
if user is None or user == -1:
netifc.descr_notify(descr, "Huh?")
return
userobj = db.getobj(user)
targname, mesg = getword(cmd, '=')
targref = db.match_playername(targname)
if targref == -1:
targref = db.match_playername_prefix(targname)
if targref == -1:
userobj.notify("I don't recognize that player.")
return
if targref == -2:
userobj.notify("I don't know which player you mean.")
return
targobj = db.getobj(targref)
if not netifc.is_user_online(targobj.dbref):
targobj.notify('%s is not awake.' % targobj.name)
return
if not mesg:
locname = db.getobj(userobj.location).name
targobj.notify('%s is looking for you in %s.' % (userobj.name, locname))
userobj.notify('You page %s.' % targobj.name)
else:
targobj.notify('%s pages, "%s" to you.' % (userobj.name, mesg))
userobj.notify('You page, "%s" to %s.' % (mesg, targobj.name))
示例5: usercmd_look
def usercmd_look(proclist, descr, user, cmd):
if user is None or user == -1:
notify_descr_or_user(descr, user, "Huh?")
return
userobj = db.getobj(user)
if not cmd:
targobj = db.getobj(userobj.location)
else:
targ = db.match_noisy(user, cmd)
if not db.validobj(targ):
return
targobj = db.getobj(targ)
userobj.notify(targobj.unparse_for(user))
desc = targobj.getprop('_/de')
if not desc:
desc = "You see nothing special."
# TODO: process for MPI
userobj.notify(desc)
lck = targobj.getprop('_/lok')
unlocked = True
if lck and isinstance(lck, lock.LockNode) and not lck.eval(user):
unlocked = False
if unlocked:
db.do_succ(user, targobj.dbref)
else:
db.do_fail(user, targobj.dbref)
if targobj.contents:
userobj.notify('Contents:')
for obj in targobj.contents:
obj = db.getobj(obj)
userobj.notify(obj.unparse_for(user))
示例6: execute
def execute(self, fr):
name = fr.data_pop(str)
obj = db.DBObject(
name=name,
objtype="program",
location=db.getobj(fr.user).dbref,
owner=db.getobj(fr.user).dbref,
)
fr.data_push(si.DBRef(obj.dbref))
示例7: compile
def compile(self, cmplr, code, src):
comp = cmplr.compiled
nam, src = cmplr.get_word(src)
if nam.startswith('\\'):
nam = nam[1:]
if db.getobj(comp.program).getprop("_defs/%s" % nam):
return (False, src)
prog = db.getobj(comp.program)
val = "#%d %s call" % (prog.dbref, util.escape_str(nam))
prog.setprop("_defs/%s" % nam, val)
return (False, src)
示例8: execute
def execute(self, fr):
s = fr.data_pop(str)
msg = "%s [%s] %s: %s\n" % (
db.getobj(fr.user),
db.getobj(fr.program),
time.strftime("%m/%d/%y %H/%M/%S"),
s
)
with open("userlog.log", "a") as f:
f.write(msg)
log("USERLOG: %s" % msg)
示例9: usercmd_at_unlink
def usercmd_at_unlink(proclist, descr, user, cmd):
if user is None or user == -1:
notify_descr_or_user(descr, user, "Huh?")
return
userobj = db.getobj(user)
objname = cmd.strip()
obj = db.match_controlled(user, objname)
if not db.validobj(obj):
return
obj = db.getobj(obj)
obj.links = {}
userobj.notify("Unlinked.")
示例10: execute
def execute(self, fr):
fr.check_underflow(2)
prop = fr.data_pop(str)
obj = fr.data_pop_object().dbref
while obj >= 0:
val = db.getobj(obj).getprop(prop)
if val is not None:
break
obj = db.getobj(obj).location
if val is None:
val = 0
fr.data_push(val)
示例11: usercmd_pose
def usercmd_pose(proclist, descr, user, cmd):
if user is None or user == -1:
netifc.descr_notify(descr, "Huh?")
return
loc = db.getobj(user).location
conts = db.getobj(loc).contents
userobj = db.getobj(user)
for obj in conts:
obj = db.getobj(obj)
if cmd.startswith("'"):
obj.notify("%s%s" % (userobj.name, cmd))
else:
obj.notify("%s %s" % (userobj.name, cmd))
示例12: usercmd_say
def usercmd_say(proclist, descr, user, cmd):
if user is None or user == -1:
netifc.descr_notify(descr, "Huh?")
return
loc = db.getobj(user).location
conts = db.getobj(loc).contents
userobj = db.getobj(user)
for obj in conts:
obj = db.getobj(obj)
if obj.dbref == user:
obj.notify('You say, "%s"' % cmd)
else:
obj.notify('%s says, "%s"' % (userobj.name, cmd))
示例13: execute
def execute(self, fr):
fr.check_underflow(2)
msg = fr.data_pop(str)
who = fr.data_pop_dbref()
where = fr.data_pop_object()
for ref in where.contents:
if ref != who.value:
db.getobj(ref).notify(msg)
if db.validobj(who):
who = db.getobj(who)
log("NOTIFY TO ALL IN %s EXCEPT %s: %s" % (where, who, msg))
else:
log("NOTIFY TO ALL IN %s: %s" % (where, msg))
示例14: execute
def execute(self, fr):
descr = fr.data_pop(int)
who = conn.descr_user(descr)
if who >= 0:
fr.data_push(db.getobj(who).name)
else:
fr.data_push("")
示例15: execute
def execute(self, fr):
con = fr.data_pop(int)
descr = netifc.descr_from_con(con)
if descr >= 0:
who = netifc.descr_dbref(descr)
netifc.descr_disconnect(descr)
log("BOOTED DESCRIPTOR %d: %s" % (descr, db.getobj(who)))