4
\$\begingroup\$

Say I have a game which has lots objects (NPCs, monsters, etc.), I want a console so I can change the variables of the objects (like changing HP for example), how could I embed python into my program, so that I can change these variables and classes with a few keystrokes in the console? An example of a command would be: /monster 1 1 HP 100 (monster is the object name, 1 1 is the coordinates, and HP 100 is the variable to change, and to what amount)

\$\endgroup\$
4
  • 3
    \$\begingroup\$ Does this link answer your question? wiki.python.org/moin/… \$\endgroup\$
    – Philipp
    Mar 12, 2015 at 8:14
  • \$\begingroup\$ @Philipp It's helpful, but doesn't tell me how to access classes using Python, it just says how I could embed python (which I have already done, using #include <Python.h> with python in the project directory \$\endgroup\$
    – bboy3577
    Mar 12, 2015 at 10:05
  • \$\begingroup\$ @bboy3577 it isn't very easy, but that link does show you quite a few ways of doing it. If you're using C/C++ boost python is probably the easiest way of doing this. \$\endgroup\$
    – mklingen
    Mar 13, 2015 at 0:40
  • \$\begingroup\$ @bboy3577 in particular, this chapter shows how to do it. \$\endgroup\$
    – mklingen
    Mar 13, 2015 at 0:41

0

You must log in to answer this question.

Browse other questions tagged .