From b34f7efeec70f576e423ceece8dd09e43ad7d231 Mon Sep 17 00:00:00 2001 From: Joe Shochet Date: Thu, 11 Jan 2007 01:08:30 +0000 Subject: [PATCH] FAQ for PythonRedefine --- direct/src/doc/howto.PythonRedefine | 48 +++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 direct/src/doc/howto.PythonRedefine diff --git a/direct/src/doc/howto.PythonRedefine b/direct/src/doc/howto.PythonRedefine new file mode 100755 index 0000000000..137c5e45c2 --- /dev/null +++ b/direct/src/doc/howto.PythonRedefine @@ -0,0 +1,48 @@ +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. LetÂ’s 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.