Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripting Support #3

Closed
Griatch opened this issue Jan 21, 2014 · 6 comments
Closed

Scripting Support #3

Griatch opened this issue Jan 21, 2014 · 6 comments
Labels
feature-request A suggestion for new functionality.

Comments

@Griatch
Copy link
Member

Griatch commented Jan 21, 2014

From squishywaffle@gmail.com on April 23, 2007 17:51:37

This is a tough one that will require some thought and discussion. Figure
out how to provide the capability to script individual or groups of object
to behave certain ways via source that is external to the codebase. We want
players to be able to extend and enrich their game with minimal
modifications to the actual base code. This allows us to keep everyone on
the same page and we all benefit from mutual developments rather than
branching off in our own directions.

The scripting should be in python, objects can be pointed at individual
scripts that implement behaviors via some kind of object interface. Players
should be able to execute commands from scripted objects, look at them and
see an external inherited description (if none on the object exists), etc.
It's essentially like MUX/MUSH's parent system, but with python files
instead of parent objects.

Original issue: http://code.google.com/p/evennia/issues/detail?id=3

@Griatch
Copy link
Member Author

Griatch commented Jan 21, 2014

From m.tsal.k...@gmail.com on April 24, 2007 08:18:40

Well what do ya know. You've already started posting issues. :)

Something like tinymux's command objects might be a good way to implement this. We'd
have to either make a new object type or do the same thing Brazil did with TinyMUX -
make a special room that is checked for objects with commands attached to them, a la
the parent system. With the new object type, it means people could make their own
personal command objects, and just carry them around - letting them clone the object
to give others a copy of a command. This way, the command's access is limited to
that of the player object that owns (or perhaps "carries") the object. I could see
both good things (and nightmares, to be fair) coming from a mux/mud that lets players
trade their own neat little commands with each other.

Lots of potential, lots of nightmares. :) I think we'd want a permissions system in
place before implementing this, however.

@Griatch
Copy link
Member Author

Griatch commented Jan 21, 2014

From squishywaffle@gmail.com on April 24, 2007 08:34:31

The big deal here is that instead of softcode, we'll be using an external scripting
language. Evennia as a codebase will side a lot more with extension and development
by admins, rather than building and coding by the entire playerbase (as is the case
with many MUX/MUSH). While privileged players may create rooms, objects, exits, etc.,
they won't be able to script much of anything in-game. I absolutely loath softcode
and really want to stay as far from it as possible with this.

So we basically need a very pluggable architecture to associate certain objects with
certain external scripts. From there we can worry about command propagation, which
shouldn't be terribly hard to address. If we can build it in such a way as to allow
admins to use a number of different languages to script objects, even better. But I'd
like to at least initially make Python the preferred language, as it's really well
suited to this and is also obviously the codebase's native language.

As far as details, I'm thinking we'll have a directory (with sorted sub-directories)
of python files (the equivalent of MUX parent objects). The game will be aware of
these and allow for updating and adding new ones without restarting. Objects can be
associated (parented) with some of these generic object types, and preferably support
sub-classing/overriding. I'd like to eventually tie in a web-based script editor of
some sort so admins can work on things from a web browser so they don't have to have
shell access to work (many head admins are wary of handing access out, myself included).

So things that would need to happen include:

  1. Coming up with a scripting API for the "parent" scripts to interact with the game
    with.
  2. Building this in a manner where we can drop other languages in down the road if
    there's interest.
  3. Making it very robust, as painless as possible, and simple.

@Griatch
Copy link
Member Author

Griatch commented Jan 21, 2014

From m.tsal.k...@gmail.com on April 25, 2007 08:08:18

Ah, I've always associated softcode as a "scripting language" of its own. I also
have never really liked it. It's great for what it does, but it's not exactly a
friendly language (I hope Brazil doesn't read this :).

I've already spoken with Brazil and the tinymux dev community in the past about using
another language or allowing the use of another language for softcode. My
suggestions back then were PHP and Python.

So the API should have a connection to permissions, meaning it will have to tie in
with django somehow (we can use a proxy pattern or something along those lines if we
want to keep it as separate as possible). I think the best bet would be to have a
base "Script" class that they should extend, and base the API around that. It would
mean API changes for a while until it was robust enough for production use. Maybe
have some starter methods that handle basic permission checks/requirements, database
hits (if necessary), and tie-ins to the different kinds of "emit".

Maybe something like:

class Script(object):

Required permission to use this script

__permission_required = None

def init(self):
# Runtime init here

def has_access(self, user):
# check if user has self.__permission_required

The hard question will come later when you add caching to the system as to whether or
not we cache the script objects at all. Since it's desirable to have live changes of
the scripts, caching will probably have to be right-out, but I could see a benefit
for a script running indefinitely in the "background" (say, a weather system), and
only running init once. Maybe we can take some examples from livecoding for this

  • have the API check the files for changes, and re-init them somehow after saving
    state data.

@Griatch
Copy link
Member Author

Griatch commented Jan 21, 2014

From squishywaffle@gmail.com on April 25, 2007 19:59:12

Since this is such a critical issue, I'm going to put this on hold until we get more
people involved in the project to offer input and assist in a sturdy implementation.
We'll get the rest of the API stabilized and work towards this.

Status: Deferred

@Griatch
Copy link
Member Author

Griatch commented Jan 21, 2014

From squishywaffle@gmail.com on May 27, 2007 10:37:28

Labels: Maintainability

@Griatch
Copy link
Member Author

Griatch commented Jan 21, 2014

From squishywaffle@gmail.com on June 06, 2007 06:43:49

The beginnings of this are in and only need refining. See scripthandler.py for the
glue, and cmd_look for a good example of how this hooks in (at the end of the
function). I'm going to close this issue, we'll handle refining and enhancements via
other issues.

Status: Implemented
Labels: Milestone-Alpha

@Griatch Griatch closed this as completed Jan 21, 2014
Griatch pushed a commit that referenced this issue Feb 2, 2014
Fixed player-level commands that were not updated to handle the cmdhandl...
drakmirv added a commit to lumberjacksoftware/evennia that referenced this issue Dec 2, 2017
Griatch pushed a commit that referenced this issue Jun 12, 2018
Merge magic and items branches
Griatch pushed a commit that referenced this issue Jun 26, 2022
Unit tests for search_tag_attribute and additional unit test for search_tag_script
Griatch pushed a commit that referenced this issue Dec 21, 2022
Griatch pushed a commit that referenced this issue Mar 17, 2023
Implemented tests for starting scripts and listing script intervals
through ScriptHandler. Code coverage improved from 72% -> 84%
Griatch pushed a commit that referenced this issue Mar 17, 2023
…ptsscripthandlerpy

feat #3 Implemented ScriptHandler unit tests
Griatch pushed a commit that referenced this issue Oct 19, 2023
Unit tests for search_tag_attribute and additional unit test for search_tag_script
Griatch pushed a commit that referenced this issue Oct 19, 2023
Implemented tests for starting scripts and listing script intervals
through ScriptHandler. Code coverage improved from 72% -> 84%
Griatch pushed a commit that referenced this issue Oct 19, 2023
…ptsscripthandlerpy

feat #3 Implemented ScriptHandler unit tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A suggestion for new functionality.
Projects
None yet
Development

No branches or pull requests

1 participant