-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
godot-gdscript-run-script fails #2
Comments
Hello, @tavurth , My apologies, these functions were never properly finished, as I left them as stubs from Python mode. In commit c0c9ef5, I have added functions and keybindings to run the project and currently edit files into Godot, as well as to open the script and scene in the editor. Currently, the implementation follows the assumption that there will be a corresponding The console output of Godot will be redirected to Emacs after running a script/scene/project. Either change to its buffer (or use the default To use the new features, you first have to provide the path and filename of Godot binary, either using (setq godot-gdscript-shell-interpreter "godot.x11.tools.64"
godot-gdscript-shell-exec-path '("~/path/to/godot/bin/")) New functions names and keybindings are as follows: (define-key map "\C-c\C-g" 'godot-gdscript-run-godot-editor)
(define-key map "\C-c\C-p" 'godot-gdscript-run-project-in-godot)
(define-key map "\C-c\C-s" 'godot-gdscript-run-current-scene-in-godot)
(define-key map "\C-c\C-e" 'godot-gdscript-edit-current-scene-in-godot)
(define-key map "\C-c\C-r" 'godot-gdscript-run-current-script-in-godot)
(define-key map "\C-c\C-dp" 'godot-gdscript-run-project-in-godot-debug-mode)
(define-key map "\C-c\C-ds" 'godot-gdscript-run-current-scene-in-godot-debug-mode)
(define-key map "\C-c\C-z" 'godot-gdscript-shell-switch-to-shell) They could probably be shortened in future, but I will keep them for this prototype. I use Evil instead of vanilla Emacs keybindings, so please tell me if the assigned ones do not follow keybindings standards or are not ergonomic enough. If you have any other suggestions, please tell me! Best regards, |
Ah, that's interesting, I didn't see those functions. What I've noticed about my workflow with Godot is that the If you'd like to try it out, you can enable Would you have any ideas about functionality already included in this mode which could help with sending the update request to the running |
Hello, @tavurth ,
To be fair, I created them after you mentioned the issue!
This is currently a know issue in Godot tracker: godotengine/godot#10946. There are workarounds for it, such as creating a custom debugger session in command line, connecting to it with a socket, them sending the update request. As far as I know, there are not other alternatives yet. From the command-line side, maybe it is possible if you are willing to use something like https://github.com/neikeq/gd-autocomplete-service, as it would enable external communication with Godot Engine. I used it for Company autocompletion in the past (https://github.com/francogarcia/company-godot-gdscript.el) (which has to be updated to work with Godot 3); perhaps it could also help to trigger the event. Best regards, |
Thanks for the link! Seems like this code would be a good fit to port over into require 'socket'
require 'listen'
cmd = "\x20\x00\x00\x00\x13\x00\x00\x00\x01\x00\x00\x00\x04\x00\x00\x00\x0e\x00\x00\x00reload_scripts\x00\x00"
server = TCPServer.open 6008
puts "Listening on port 6008"
loop do
client = server.accept
listener = Listen.to('scripts') do |modified|
if modified
puts "File modified: #{modified}"
client.write(cmd)
end
end
listener.start
# Read content to avoid using kernel memory
while line = client.recv(1024)
next if line.length < 10
# Debug data packets
#puts "###"
#puts line.each_byte.map { |b| b.to_s(16).rjust(2, '0') }.join(':')
end
end Edit: From that link it looks like they're actively working on a PR to fix it in Godot, which would be preferable than an external script solution. |
I guess we can close this issue for now. When |
Hello, @tavurth ,
Yes, they are. In Windows, this should be simple to do with AutoHotkey. In Linux, with xdotool. I do not have any idea on Mac, though. I think there is a Python library for desktop automation, which could provide a multi-platform solution (a quick search leads to this: https://automatetheboringstuff.com/chapter18/). If going with the automation script route, an even better workflow could be switching to the running game window instead of back to Godot. This way, you could provide input directly to test it. (Of course, you could get creating and write macros to automatically test your game the same way; or, alternatively, write a GDScript with commands and timestamps for replaying). Best regards, |
Thanks for the tip, that's a really useful program! #! /bin/bash
## We're required to send our game's window title to this script
if [ $# -eq 0 ];
then
echo "Game window title required, use:"
echo "$0 My Game Name"
exit 1
fi
GAME_TITLE=$1
## First we'll switch to the godot engine and save the files
## This sends the update information over to the running game-window
WID=`xdotool search "Godot Engine" | head -1`
xdotool windowactivate --sync $WID
xdotool key --clearmodifiers ctrl+s
## Now we'll switch to the users game-window
WID=`xdotool search "$GAME_TITLE" | head -1`
xdotool windowactivate --sync $WID I tried to bind it into by `godot-gdscript-mode hook by doing: (add-hook 'godot-gdscript-mode
#'(lambda () (add-hook 'before-save-hook
#'(lambda () (shell-command "bash ~/.spacemacs.git/update-godot.sh my-game-name"))))) However, it doesn't seem to fire correctly, and so for now I'm using ;; Update the godot engine
(global-set-key
(kbd "M-m o r")
(lambda ()
(interactive)
(shell-command "bash ~/.spacemacs.git/update-godot.sh my-game-name"))) |
Hello, @tavurth , Glad you liked! You have created a neat script. I would change Emacs hook to I have added a function to retrieve the project's name from the configuration file, so you can avoid changing your configuration when working on another project. For auto reloading after saving, you could do something like this: (use-package godot-gdscript
:mode ("\\.gd\\'" . godot-gdscript-mode)
:defer t
:init
(progn
(defun franco/godot-gdscript-mode-default-settings ()
(setq mode-name "Godot-GDScript"
godot-gdscript-shell-interpreter "godot.x11.tools.64"
godot-gdscript-shell-exec-path `(,(franco/projects "C++/Godot/godot/bin/"))
godot-gdscript-shell-interpreter-args ""
indent-tabs-mode nil
tab-width 4)
;; Make C-j work the same way as RET.
(local-set-key (kbd "C-j") 'newline-and-indent))
(defun franco/reload-godot-after-save ()
"Auto-reload the project with `xdotool', then focus on
e game window."
(add-hook
'after-save-hook
#'(lambda ()
(shell-command (concat "bash ~/tmp/update-godot.sh " (godot-gdscript-get-project-name))))
nil 'make-it-local)))
(spacemacs/add-all-to-hook 'godot-gdscript-mode-hook
'franco/godot-gdscript-mode-default-settings
'franco/reload-godot-after-save)
:config
(progn
;; Keybindings.
(spacemacs/declare-prefix-for-mode 'godot-gdscript-mode "mc" "execute")
(spacemacs/declare-prefix-for-mode 'godot-gdscript-mode "md" "debug")
(spacemacs/set-leader-keys-for-major-mode 'godot-gdscript-mode
"," 'godot-gdscript-run-project-in-godot
"cg" 'godot-gdscript-run-godot-editor
"cp" 'godot-gdscript-run-project-in-godot
"ce" 'godot-gdscript-edit-current-scene-in-godot
"cs" 'godot-gdscript-run-current-scene-in-godot
"cs" 'godot-gdscript-run-current-script-in-godot
"dp" 'godot-gdscript-run-project-in-godot-debug-mode
"ds" 'godot-gdscript-run-current-scene-in-godot-debug-mode
"dd" 'godot-gdscript-shell-switch-to-shell
"gi" 'imenu)))) The inner lambda registers the update only on GDScript mode buffers. If you want to update the game when saving any buffers, you may remove it. The remaining of the code is from my personal Spacemacs layer for Godot. You may find Best regards, |
On my machine all of the following fail:
Citing the error:
Wrong type argument: arrayp, nil
This comes from the line 1954 @
shell-quote-argument
Any ideas on how to fix this?
The text was updated successfully, but these errors were encountered: