Python bindings for InkCpp
Allows you to run Inkle's ink narrative scripting language for games from python script.
This is alpha software. DO NOT USE IT IT PRODUCTION.
import inkpython
story = inkpython.Story('ink/sample.bin')
while(1):
while(story.can_continue()):
print(story.getline())
if(story.has_choices()):
for c in story.choices():
print("%s> %s" % (c.index(), c.text()))
i = input("?>")
story.choose(int(i))
continue;
else:
break
The input must be in binary format.
Use inkcpp_cl
inkcpp_cl you_ink_file.ink
# OR
inkcpp_cl you_ink_file.json
A sample player can be found in the python
folder with a sample game file (sample.bin
) in the ink
folder.
$ python python/player.py ink/sample.bin
Once upon a time... #LOCATION: MagicKingdom
1> There were two choices.
2> There were four lines of content.
?>
python3
pybind11
(usepip install pybind11
or your preferred installer)- InkCpp (git clone it in a sister repository)
mkdir build
cd build
cmake ..
If cmake
does not find your pybind11
package you can specify the PYTHON_SITE_PACKAGES
env variable.
(For example if you are using pyenv
, cmake
won't find the current python install.)
PYTHON_SITE_PACKAGES=~/.pyenv/versions/3.9.6/lib/python3.9/site-packages cmake ..
By default, cmake
will try to find InkCpp sources in a inkcpp
directory next to this one, you can override with the INKCCPP_SOURCE_DIR
var
INKCPP_SOURCE_DIR="/somewhere/else" cmake ..
cd build
make
make install
TBD