warten-auf-godot/troll.gd
2020-11-07 17:03:35 +01:00

33 lines
927 B
GDScript

extends KinematicBody2D
const MOTION_SPEED = 160 # Pixels/second.
var text = ""
func _physics_process(_delta):
var motion = Vector2()
motion.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
motion.y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
motion.y /= 2
motion = motion.normalized() * MOTION_SPEED
#warning-ignore:return_value_discarded
move_and_slide(motion)
func _on_Button_button_down():
# read textbox
# -> f (state) -> cmd
var cmds = $TextEdit.text
var params = "[]"
# call python script for executing user input
var output = []
var exit_code = OS.execute("python", ["robot_brain.py", cmds, params], true, output)
var response_index = output[0].find('OUTPUT') + 7
var response = output[0].right(response_index)
print(response)
var response_array = response.rsplit(',')
print(len(response_array))
print(response_array)