49 lines
2.1 KiB
Plaintext
49 lines
2.1 KiB
Plaintext
Python Redefine FAQ
|
||
|
||
Q: So, what is Ctrl-C-Ctrl-V?
|
||
|
||
A: Since Python is an interpreted language, you can redefine code on the
|
||
fly. Lets say you have a class method that creates and plays a sword slash
|
||
interval, carefully timing an animation, a particle effect, and a sound
|
||
effect. If you could tweak the timing and properties of this interval in
|
||
your code and magically hit a hotkey to see the change immediately in-game,
|
||
it would cut your iteration time from a 5 minute restart down to 1
|
||
second. ctrl-c-ctrl-v is that magic hotkey. Of course it works on arbitrary
|
||
Python classes, not just intervals. If you are show-coding in Emacs, you
|
||
really should try it -- it can save you lots of time!
|
||
|
||
|
||
Q: How do I use it?
|
||
|
||
A: In your Emacs buffer within your class definition, make a change to a
|
||
function and hit control-c-control-v. This will redefine the function, and
|
||
in fact the entire class and thus all objects that are defined by that
|
||
class. Some feedback will be printed out at the Python prompt.
|
||
|
||
|
||
Q: Does it only work in Emacs?
|
||
|
||
A: Yes, unfortunately it only works from inside Emacs right now, but it can
|
||
probably be adapted to any scriptable editor. Most of the code is in
|
||
Python, not in emacs (lisp). Ask if you are curious about getting this
|
||
working in your favorite editor.
|
||
|
||
|
||
Q: Can I redefine code on the client and the AI?
|
||
|
||
A: If you are using multi-python Emacs buffers, it will actually redefine
|
||
this class on the AI, Uberdog, and client simultaneously. Otherwise, you
|
||
must control-c-control-v from the Emacs where you are running the process
|
||
you want the class redefined in. Note, if the class does not exist on the
|
||
AI or client, it will safely ignore.
|
||
|
||
|
||
Q: What about systems that store function callbacks?
|
||
|
||
A: The common systems that store function callbacks are properly searched
|
||
and replaced when you control-c-control-v. This includes the TaskManager,
|
||
FunctionIntervals (new), ClassicFSMs, the Messenger, and DistributedObject
|
||
dc updates. If you are storing a function pointer in your own code ad hoc,
|
||
the Finder will not currently replace that; though I could imagine a brute
|
||
force way to find those too.
|