[crossfire] scripts
Alex Schultz
alex_sch at telus.net
Thu May 10 08:24:48 CDT 2007
Mark Wedel wrote:
> Is it possible to run scripts from text that is in memory? If so, then an
> approach similar to the treasures - collect them into a file, read them into
> memory, and when needed, run the script from that information in memory.
>
> I'd think in that case, the slaying is simpler - just something like 'slaying
> smoking_pipe.py' - since the script is in memory, there is effectively no need
> for a pathname.
>
> One advantage of this collection approach is that the scripts themselves sit
> with the arches (same idea behind the treasurelists) - the script would be in
> the same directory as the object itself.
Such running scripts from text in memory is very possible indeed :)
In fact, we could (and should IMHO) go one step further: Run it from the
bytecodes in memory. The python code already has faculties for caching
the bytecode of python scripts in memory (caches up to 16 scripts as
bytecode in memory) and this increases speed of running the same script
over and over VERY dramatically (code for this derived from daimonin's
changes in the python plugin before it moved to lua). So, why store text
in memory as such to run, when one could store the bytecode which would
be much much faster and use less memory :)
Alex Schultz
More information about the crossfire
mailing list