mirror of
https://github.com/evennia/evennia.git
synced 2026-03-17 21:36:30 +01:00
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
143 lines
5 KiB
Python
143 lines
5 KiB
Python
"""
|
|
This will be the base object type/interface that all scripts are derived from by
|
|
default. It will have the necessary outline for developers to sub-class and override.
|
|
"""
|
|
|
|
import ansi
|
|
|
|
class BasicObject:
|
|
def __init__(self, source_obj):
|
|
"""
|
|
Get our ducks in a row.
|
|
|
|
source_obj: (Object) A reference to the object being scripted (the child).
|
|
"""
|
|
self.source_obj = source_obj
|
|
|
|
def a_desc(self, values):
|
|
"""
|
|
Perform this action when someone uses the LOOK command on the object.
|
|
|
|
values: (Dict) Script arguments with keys:
|
|
* pobject: The object requesting the action.
|
|
"""
|
|
# Un-comment the line below for an example
|
|
#print "SCRIPT TEST: %s looked at %s." % (values["pobject"], self.source_obj)
|
|
pass
|
|
|
|
def return_appearance(self, values):
|
|
"""
|
|
Returns a string representation of an object's appearance when LOOKed at.
|
|
|
|
values: (Dict) Script arguments with keys:
|
|
* pobject: The object requesting the action.
|
|
"""
|
|
target_obj = self.source_obj
|
|
pobject = values["pobject"]
|
|
description = target_obj.get_description()
|
|
if description is not None:
|
|
retval = "%s\r\n%s" % (
|
|
target_obj.get_name(),
|
|
target_obj.get_description(),
|
|
)
|
|
else:
|
|
retval = "%s" % (
|
|
target_obj.get_name(),
|
|
)
|
|
|
|
con_players = []
|
|
con_things = []
|
|
con_exits = []
|
|
|
|
for obj in target_obj.get_contents():
|
|
if obj.is_player():
|
|
if obj != pobject and obj.is_connected_plr():
|
|
con_players.append(obj)
|
|
elif obj.is_exit():
|
|
con_exits.append(obj)
|
|
else:
|
|
con_things.append(obj)
|
|
|
|
if not con_players == []:
|
|
retval += "\n\r%sPlayers:%s" % (ansi.ansi["hilite"], ansi.ansi["normal"],)
|
|
for player in con_players:
|
|
retval +='\n\r%s' %(player.get_name(),)
|
|
if not con_things == []:
|
|
retval += "\n\r%sContents:%s" % (ansi.ansi["hilite"], ansi.ansi["normal"],)
|
|
for thing in con_things:
|
|
retval += '\n\r%s' %(thing.get_name(),)
|
|
if not con_exits == []:
|
|
retval += "\n\r%sExits:%s" % (ansi.ansi["hilite"], ansi.ansi["normal"],)
|
|
for exit in con_exits:
|
|
retval += '\n\r%s' %(exit.get_name(),)
|
|
|
|
return retval
|
|
|
|
def a_get(self, values):
|
|
"""
|
|
Perform this action when someone uses the GET command on the object.
|
|
|
|
values: (Dict) Script arguments with keys:
|
|
* pobject: The object requesting the action.
|
|
"""
|
|
# Un-comment the line below for an example
|
|
#print "SCRIPT TEST: %s got %s." % (values["pobject"], self.source_obj)
|
|
pass
|
|
|
|
def a_drop(self, values):
|
|
"""
|
|
Perform this action when someone uses the GET command on the object.
|
|
|
|
values: (Dict) Script arguments with keys:
|
|
* pobject: The object requesting the action.
|
|
"""
|
|
# Un-comment the line below for an example
|
|
#print "SCRIPT TEST: %s dropped %s." % (values["pobject"], self.source_obj)
|
|
pass
|
|
|
|
def default_lock(self, values):
|
|
"""
|
|
This method returns a True or False boolean value to determine whether
|
|
the actor passes the lock. This is generally used for picking up
|
|
objects or traversing exits.
|
|
|
|
values: (Dict) Script arguments with keys:
|
|
* pobject: The object requesting the action.
|
|
"""
|
|
# Assume everyone passes the default lock by default.
|
|
return True
|
|
|
|
def use_lock(self, values):
|
|
"""
|
|
This method returns a True or False boolean value to determine whether
|
|
the actor passes the lock. This is generally used for seeing whether
|
|
a player can use an object or any of its commands.
|
|
|
|
values: (Dict) Script arguments with keys:
|
|
* pobject: The object requesting the action.
|
|
"""
|
|
# Assume everyone passes the use lock by default.
|
|
return True
|
|
|
|
def enter_lock(self, values):
|
|
"""
|
|
This method returns a True or False boolean value to determine whether
|
|
the actor passes the lock. This is generally used for seeing whether
|
|
a player can enter another object.
|
|
|
|
values: (Dict) Script arguments with keys:
|
|
* pobject: The object requesting the action.
|
|
"""
|
|
# Assume everyone passes the enter lock by default.
|
|
return True
|
|
|
|
def class_factory(source_obj):
|
|
"""
|
|
This method is called any script you retrieve (via the scripthandler). It
|
|
creates an instance of the class and returns it transparently. I'm not
|
|
sure how well this will scale, but we'll find out. We may need to
|
|
re-factor this eventually.
|
|
|
|
source_obj: (Object) A reference to the object being scripted (the child).
|
|
"""
|
|
return BasicObject(source_obj)
|