mirror of
https://github.com/evennia/evennia.git
synced 2026-03-28 02:36:32 +01:00
Scripting support is now in! See cmd_look (the end of it), scripthandler.py, and scripts/basicobject.py for very brief examples. I'm not sure how well this is going to scale, I had to kludge the import a bit due to some oddities with __import__. There has to be a better way to do this, hopefully I'll be able to figure it out. In any case, expect basicobject to start fleshing out. You'll be able to use it directly or sub-class it with your own stuff.
This commit is contained in:
parent
27c0e7a873
commit
94ceec3719
5 changed files with 91 additions and 10 deletions
|
|
@ -1,6 +1,9 @@
|
|||
import re
|
||||
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User, Group
|
||||
|
||||
import scripthandler
|
||||
import defines_global
|
||||
import ansi
|
||||
|
||||
|
|
@ -95,6 +98,7 @@ class Object(models.Model):
|
|||
flags = models.TextField(blank=True, null=True)
|
||||
nosave_flags = models.TextField(blank=True, null=True)
|
||||
date_created = models.DateField(editable=False, auto_now_add=True)
|
||||
scriptlink = None
|
||||
|
||||
def __cmp__(self, other):
|
||||
"""
|
||||
|
|
@ -544,6 +548,19 @@ class Object(models.Model):
|
|||
functions_general.log_errmsg("Object '%s(#%d)' has invalid location: #%s" % (self.name,self.id,self.location_id))
|
||||
return False
|
||||
|
||||
def get_scriptlink(self):
|
||||
"""
|
||||
Returns an object's script parent.
|
||||
"""
|
||||
if not self.scriptlink:
|
||||
self.scriptlink = scripthandler.scriptlink(self, self.get_attribute_value('__parent', 'basicobject'))
|
||||
|
||||
if self.scriptlink:
|
||||
# If the scriptlink variable can't be populated, this will fail
|
||||
# silently and let the exception hit in the scripthandler.
|
||||
return self.scriptlink
|
||||
return None
|
||||
|
||||
def get_attribute_value(self, attrib, default=False):
|
||||
"""
|
||||
Returns the value of an attribute on an object. You may need to
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue