Skip to content

Commit b34f7ef

Browse files
committed
FAQ for PythonRedefine
1 parent 7fefe01 commit b34f7ef

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Python Redefine FAQ
2+
3+
Q: So, what is Ctrl-C-Ctrl-V?
4+
5+
A: Since Python is an interpreted language, you can redefine code on the
6+
fly. Let’s say you have a class method that creates and plays a sword slash
7+
interval, carefully timing an animation, a particle effect, and a sound
8+
effect. If you could tweak the timing and properties of this interval in
9+
your code and magically hit a hotkey to see the change immediately in-game,
10+
it would cut your iteration time from a 5 minute restart down to 1
11+
second. ctrl-c-ctrl-v is that magic hotkey. Of course it works on arbitrary
12+
Python classes, not just intervals. If you are show-coding in Emacs, you
13+
really should try it -- it can save you lots of time!
14+
15+
16+
Q: How do I use it?
17+
18+
A: In your Emacs buffer within your class definition, make a change to a
19+
function and hit control-c-control-v. This will redefine the function, and
20+
in fact the entire class and thus all objects that are defined by that
21+
class. Some feedback will be printed out at the Python prompt.
22+
23+
24+
Q: Does it only work in Emacs?
25+
26+
A: Yes, unfortunately it only works from inside Emacs right now, but it can
27+
probably be adapted to any scriptable editor. Most of the code is in
28+
Python, not in emacs (lisp). Ask if you are curious about getting this
29+
working in your favorite editor.
30+
31+
32+
Q: Can I redefine code on the client and the AI?
33+
34+
A: If you are using multi-python Emacs buffers, it will actually redefine
35+
this class on the AI, Uberdog, and client simultaneously. Otherwise, you
36+
must control-c-control-v from the Emacs where you are running the process
37+
you want the class redefined in. Note, if the class does not exist on the
38+
AI or client, it will safely ignore.
39+
40+
41+
Q: What about systems that store function callbacks?
42+
43+
A: The common systems that store function callbacks are properly searched
44+
and replaced when you control-c-control-v. This includes the TaskManager,
45+
FunctionIntervals (new), ClassicFSMs, the Messenger, and DistributedObject
46+
dc updates. If you are storing a function pointer in your own code ad hoc,
47+
the Finder will not currently replace that; though I could imagine a brute
48+
force way to find those too.

0 commit comments

Comments
 (0)