Merge pull request #1552 from BlauFeuer/develop-locate
`@locate` alias of CmdFind shows location of find
This commit is contained in:
commit
037932aae2
5 changed files with 20 additions and 5 deletions
|
|
@ -297,7 +297,7 @@ class Command(with_metaclass(CommandMeta, object)):
|
||||||
Args:
|
Args:
|
||||||
srcobj (Object): Object trying to gain permission
|
srcobj (Object): Object trying to gain permission
|
||||||
access_type (str, optional): The lock type to check.
|
access_type (str, optional): The lock type to check.
|
||||||
default (bool, optional): The fallbacl result if no lock
|
default (bool, optional): The fallback result if no lock
|
||||||
of matching `access_type` is found on this Command.
|
of matching `access_type` is found on this Command.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -2238,12 +2238,14 @@ class CmdFind(COMMAND_DEFAULT_CLASS):
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
@find[/switches] <name or dbref or *account> [= dbrefmin[-dbrefmax]]
|
@find[/switches] <name or dbref or *account> [= dbrefmin[-dbrefmax]]
|
||||||
|
@locate - this is a shorthand for using the /loc switch.
|
||||||
|
|
||||||
Switches:
|
Switches:
|
||||||
room - only look for rooms (location=None)
|
room - only look for rooms (location=None)
|
||||||
exit - only look for exits (destination!=None)
|
exit - only look for exits (destination!=None)
|
||||||
char - only look for characters (BASE_CHARACTER_TYPECLASS)
|
char - only look for characters (BASE_CHARACTER_TYPECLASS)
|
||||||
exact- only exact matches are returned.
|
exact- only exact matches are returned.
|
||||||
|
loc - display object location if exists and match has one result
|
||||||
|
|
||||||
Searches the database for an object of a particular name or exact #dbref.
|
Searches the database for an object of a particular name or exact #dbref.
|
||||||
Use *accountname to search for an account. The switches allows for
|
Use *accountname to search for an account. The switches allows for
|
||||||
|
|
@ -2266,6 +2268,9 @@ class CmdFind(COMMAND_DEFAULT_CLASS):
|
||||||
caller.msg("Usage: @find <string> [= low [-high]]")
|
caller.msg("Usage: @find <string> [= low [-high]]")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if "locate" in self.cmdstring: # Use option /loc as a default for @locate command alias
|
||||||
|
switches.append('loc')
|
||||||
|
|
||||||
searchstring = self.lhs
|
searchstring = self.lhs
|
||||||
low, high = 1, ObjectDB.objects.all().order_by("-id")[0].id
|
low, high = 1, ObjectDB.objects.all().order_by("-id")[0].id
|
||||||
if self.rhs:
|
if self.rhs:
|
||||||
|
|
@ -2315,6 +2320,8 @@ class CmdFind(COMMAND_DEFAULT_CLASS):
|
||||||
else:
|
else:
|
||||||
result = result[0]
|
result = result[0]
|
||||||
string += "\n|g %s - %s|n" % (result.get_display_name(caller), result.path)
|
string += "\n|g %s - %s|n" % (result.get_display_name(caller), result.path)
|
||||||
|
if "loc" in self.switches and not is_account and result.location:
|
||||||
|
string += " (|wlocation|n: |g{}|n)".format(result.location.get_display_name(caller))
|
||||||
else:
|
else:
|
||||||
# Not an account/dbref search but a wider search; build a queryset.
|
# Not an account/dbref search but a wider search; build a queryset.
|
||||||
# Searchs for key and aliases
|
# Searchs for key and aliases
|
||||||
|
|
@ -2350,6 +2357,8 @@ class CmdFind(COMMAND_DEFAULT_CLASS):
|
||||||
else:
|
else:
|
||||||
string = "|wOne Match|n(#%i-#%i%s):" % (low, high, restrictions)
|
string = "|wOne Match|n(#%i-#%i%s):" % (low, high, restrictions)
|
||||||
string += "\n |g%s - %s|n" % (results[0].get_display_name(caller), results[0].path)
|
string += "\n |g%s - %s|n" % (results[0].get_display_name(caller), results[0].path)
|
||||||
|
if "loc" in self.switches and nresults == 1 and results[0].location:
|
||||||
|
string += " (|wlocation|n: |g{}|n)".format(results[0].location.get_display_name(caller))
|
||||||
else:
|
else:
|
||||||
string = "|wMatch|n(#%i-#%i%s):" % (low, high, restrictions)
|
string = "|wMatch|n(#%i-#%i%s):" % (low, high, restrictions)
|
||||||
string += "\n |RNo matches found for '%s'|n" % searchstring
|
string += "\n |RNo matches found for '%s'|n" % searchstring
|
||||||
|
|
|
||||||
|
|
@ -486,7 +486,7 @@ class CmdWhisper(COMMAND_DEFAULT_CLASS):
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
whisper <character> = <message>
|
whisper <character> = <message>
|
||||||
whisper <char1>, <char2> = <message?
|
whisper <char1>, <char2> = <message>
|
||||||
|
|
||||||
Talk privately to one or more characters in your current location, without
|
Talk privately to one or more characters in your current location, without
|
||||||
others in the room being informed.
|
others in the room being informed.
|
||||||
|
|
|
||||||
|
|
@ -294,6 +294,12 @@ class TestBuilding(CommandTest):
|
||||||
|
|
||||||
def test_find(self):
|
def test_find(self):
|
||||||
self.call(building.CmdFind(), "Room2", "One Match")
|
self.call(building.CmdFind(), "Room2", "One Match")
|
||||||
|
expect = "One Match(#1#7, loc):\n " +\
|
||||||
|
"Char2(#7) evennia.objects.objects.DefaultCharacter (location: Room(#1))"
|
||||||
|
self.call(building.CmdFind(), "Char2", expect, cmdstring="locate")
|
||||||
|
self.call(building.CmdFind(), "Char2", expect, cmdstring="@locate")
|
||||||
|
self.call(building.CmdFind(), "/loc Char2", expect, cmdstring="find")
|
||||||
|
self.call(building.CmdFind(), "Char2", "One Match", cmdstring="@find")
|
||||||
|
|
||||||
def test_script(self):
|
def test_script(self):
|
||||||
self.call(building.CmdScript(), "Obj = scripts.Script", "Script scripts.Script successfully added")
|
self.call(building.CmdScript(), "Obj = scripts.Script", "Script scripts.Script successfully added")
|
||||||
|
|
|
||||||
|
|
@ -470,7 +470,7 @@ BASE_SCRIPT_TYPECLASS = "typeclasses.scripts.Script"
|
||||||
DEFAULT_HOME = "#2"
|
DEFAULT_HOME = "#2"
|
||||||
# The start position for new characters. Default is Limbo (#2).
|
# The start position for new characters. Default is Limbo (#2).
|
||||||
# MULTISESSION_MODE = 0, 1 - used by default unloggedin create command
|
# MULTISESSION_MODE = 0, 1 - used by default unloggedin create command
|
||||||
# MULTISESSION_MODE = 2,3 - used by default character_create command
|
# MULTISESSION_MODE = 2, 3 - used by default character_create command
|
||||||
START_LOCATION = "#2"
|
START_LOCATION = "#2"
|
||||||
# Lookups of Attributes, Tags, Nicks, Aliases can be aggressively
|
# Lookups of Attributes, Tags, Nicks, Aliases can be aggressively
|
||||||
# cached to avoid repeated database hits. This often gives noticeable
|
# cached to avoid repeated database hits. This often gives noticeable
|
||||||
|
|
@ -545,8 +545,8 @@ INLINEFUNC_MODULES = ["evennia.utils.inlinefuncs",
|
||||||
# 3 - like mode 2, except multiple sessions can puppet one character, each
|
# 3 - like mode 2, except multiple sessions can puppet one character, each
|
||||||
# session getting the same data.
|
# session getting the same data.
|
||||||
MULTISESSION_MODE = 0
|
MULTISESSION_MODE = 0
|
||||||
# The maximum number of characters allowed for MULTISESSION_MODE 2,3. This is
|
# The maximum number of characters allowed for MULTISESSION_MODE 2, 3.
|
||||||
# checked by the default ooc char-creation command. Forced to 1 for
|
# This is checked by the default ooc char-creation command. Forced to 1 for
|
||||||
# MULTISESSION_MODE 0 and 1.
|
# MULTISESSION_MODE 0 and 1.
|
||||||
MAX_NR_CHARACTERS = 1
|
MAX_NR_CHARACTERS = 1
|
||||||
# The access hierarchy, in climbing order. A higher permission in the
|
# The access hierarchy, in climbing order. A higher permission in the
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue