# Godot 3D frontend (0,000001 % complete)

**URL:** <https://discourse.cataclysmdda.org/t/godot-3d-frontend-0-000001-complete/16712>\
**Category:** The Lab\
**Created:** [September 22, 2018, 3:34pm UTC](https://discourse.cataclysmdda.org/t/godot-3d-frontend-0-000001-complete/16712 "2018-09-22T15:34:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdtrooper](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/mdtrooper/32/1524_2.png) [@mdtrooper](https://discourse.cataclysmdda.org/u/mdtrooper)\
**Post date:** [September 22, 2018, 3:34pm UTC](https://discourse.cataclysmdda.org/t/godot-3d-frontend-0-000001-complete/16712/1 "2018-09-22T15:34:30Z")

</div>

I am experimenting with Godot and CataclysmDDA. I think that the structure is:  
CDDA ncurses \<- (stdout + keys pressed ) -\> python script \<- (stdin + stdout, as api) -\> Godot

But the scripts of proof of concept does not run fine…well I put the scripts:

the script to simulate ncurses:

```
#! /usr/bin/python3

import sys,os
import curses

def draw_menu(stdscr):
	k = 0
	while (k != ord('q')):
		stdscr.clear()
		height, width = stdscr.getmaxyx()
		stdscr.addstr(0, 0, "HOLA {}".format(k))
		stdscr.refresh()
		
		k = stdscr.getch()

def main():
	curses.wrapper(draw_menu)

if __name__ == " __main__":
	main()

```

the script to analize the stdout and send keys (there are a lot of proofs disabled with comments):

```
#! /usr /bin/python3

"""
ps -A | grep cata
xdotool search --pid 3819
xdotool key --window 50331670 q
"""

"""
from subprocess import Popen, PIPE

#p = Popen('./test5.py', stdin=PIPE, stdout=PIPE, shell=True)
#p = Popen('./test5.py', shell=True)
p = Popen('./test2.py')

print(p.pid)

sleep(100)

# p.stdin.close()
# p.stdout.close()
# p.wait()

"""

# ~ import pexpect

# ~ child = pexpect.spawn("./test5.py")
# ~ child.send('a')
# ~ child.send('b')
# ~ child.interact()

# ~ import sys
# ~ import pexpect
# ~ child = pexpect.spawn('./test5.py', logfile=open("/tmp/file", "wb"))
# ~ child.logfile = open("/tmp/file", "wb")
# ~ child.expect(pexpect.EOF)
# ~ child.send('a')
# ~ child.send('q')
# ~ child.interact()

"""
https://stackoverflow.com/questions/2575528/simulating-key-press-event-using-python-for-linux
spawn
fout = file('output.txt', 'w') child.logfile = fout
"""

import sys
from time import sleep
import pexpect
child = pexpect.spawn('./test5.py')
child.logfile = open("/tmp/file", "wb")
sleep(2)
child.send('a')
print(child.read())
# ~ child.send('q')

```

Someone can help me.

---

<div class="post-metadata">

**Author:** ![mdtrooper](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/mdtrooper/32/1524_2.png) [@mdtrooper](https://discourse.cataclysmdda.org/u/mdtrooper)\
**Post date:** [September 22, 2018, 3:40pm UTC](https://discourse.cataclysmdda.org/t/godot-3d-frontend-0-000001-complete/16712/2 "2018-09-22T15:40:58Z")

</div>

Sorry for the “HOLA” is the same word in english to “HELLO”. The spanish developers make the hello world programs are “Hola mundo”.

---

<div class="post-metadata">

**Author:** ![dpwb](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/dpwb/32/2609_2.png) [@dpwb](https://discourse.cataclysmdda.org/u/dpwb)\
**Post date:** [September 22, 2018, 5:23pm UTC](https://discourse.cataclysmdda.org/t/godot-3d-frontend-0-000001-complete/16712/3 "2018-09-22T17:23:43Z")

</div>

Interesting concept.  
Confused at the flow, you are reading keypresses from the Cata app, sending it to a python script, which then sends it to Godot?

I know that Godot had a Python native bindings addon developed recently, is that what you are using? - or how does the Python script communicate with Godot?  
Have you considered GDnative C++ bindings for Godot? - removing that intermediate step may improve performance if your trying to create some kind of 3d visualiser.  
Perhaps there is a way that Cataclysm could expose it’s events in a library of sorts… that Godot can pick up on via GDNative.

---

<div class="post-metadata">

**Author:** ![mdtrooper](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/mdtrooper/32/1524_2.png) [@mdtrooper](https://discourse.cataclysmdda.org/u/mdtrooper)\
**Post date:** [September 22, 2018, 6:01pm UTC](https://discourse.cataclysmdda.org/t/godot-3d-frontend-0-000001-complete/16712/4 "2018-09-22T18:01:45Z")

</div>

Well, your response sounds good. But I am stopped in the step to send event keys to CDDA ncurses from a python script,

---

<div class="post-metadata">

**Author:** ![dpwb](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/dpwb/32/2609_2.png) [@dpwb](https://discourse.cataclysmdda.org/u/dpwb)\
**Post date:** [September 22, 2018, 6:49pm UTC](https://discourse.cataclysmdda.org/t/godot-3d-frontend-0-000001-complete/16712/5 "2018-09-22T18:49:26Z")

</div>

Well I know a bit of Python and Godot so I’d love to help with this as it sounds very interesting, but I’m still very confused as to how your project works.

I’m trying to understand the code in terms of how it communicates with CDDA, but I fear it’s beyond me as I’ve never used a similar module to capture and send keypresses.

I can see it greps for cata, I can see that the pexpect module can send keypresses to it’s “child”.  
but Is the script writing the keypresses to a file? and the ncurses emulation script reads it?  
Is Python redrawing the CDDA terminal in it’s own terminal?

I’m probably completely useless to your problem here lol, but I need to know more.
