Take hints on port 1235, hint script in user's PATH

This commit is contained in:
blinry 2020-12-22 16:05:35 +01:00
parent cf10605bf4
commit d8d48c245e
5 changed files with 37 additions and 5 deletions

View file

@ -15,11 +15,14 @@ func _ready():
create_file_in_game_env(".gitconfig", helpers.read_file("res://scripts/gitconfig")) create_file_in_game_env(".gitconfig", helpers.read_file("res://scripts/gitconfig"))
create_file_in_game_env("fake-editor", helpers.read_file("res://scripts/fake-editor")) copy_script_to_game_env("fake-editor")
fake_editor = tmp_prefix + "fake-editor" copy_script_to_game_env("hint")
global_shell.run("chmod u+x '%s'" % fake_editor)
load_state() load_state()
func copy_script_to_game_env(name):
create_file_in_game_env(name, helpers.read_file("res://scripts/%s" % name))
global_shell.run("chmod u+x '%s'" % (tmp_prefix + name))
func _initial_state(): func _initial_state():
return {"history": []} return {"history": []}

View file

@ -20,7 +20,13 @@ onready var cards = $Rows/Controls/Cards
onready var file_browser = $Rows/Columns/RightSide/FileBrowser onready var file_browser = $Rows/Columns/RightSide/FileBrowser
onready var index = $Rows/Columns/RightSide/Index onready var index = $Rows/Columns/RightSide/Index
var _hint_server
var _hint_client_connection
func _ready(): func _ready():
_hint_server = TCP_Server.new()
_hint_server.listen(1235)
var args = helpers.parse_args() var args = helpers.parse_args()
if args.has("sandbox"): if args.has("sandbox"):
@ -45,6 +51,14 @@ func _ready():
# Load first chapter. # Load first chapter.
load_chapter(current_chapter) load_chapter(current_chapter)
input.grab_focus() input.grab_focus()
func _process(delta):
if _hint_server.is_connection_available():
_hint_client_connection = _hint_server.take_connection()
var length = _hint_client_connection.get_u32()
var message = _hint_client_connection.get_string(length)
game.notify(message)
func load_chapter(id): func load_chapter(id):
current_chapter = id current_chapter = id
@ -97,7 +111,6 @@ func load_level(level_id):
terminal.find_node("TextEditor").close() terminal.find_node("TextEditor").close()
update_repos() update_repos()
game.notify("Level loaded!")
# Unmute the audio after a while, so that player can hear pop sounds for # Unmute the audio after a while, so that player can hear pop sounds for
# nodes they create. # nodes they create.

View file

@ -48,6 +48,7 @@ func run_async_thread(shell_command):
var env = {} var env = {}
env["HOME"] = game.tmp_prefix env["HOME"] = game.tmp_prefix
env["PATH"] = game.tmp_prefix+":/usr/bin:/bin"
var hacky_command = "" var hacky_command = ""
for variable in env: for variable in env:

View file

@ -10,7 +10,7 @@ $socket = IO::Socket::INET->new(PeerAddr => "127.0.0.1",
my $absolute_path = File::Spec->rel2abs($ARGV[0]); my $absolute_path = File::Spec->rel2abs($ARGV[0]);
# Send the length of the first argument as a byte. # Send the length of the first argument as four bytes.
$socket->send(pack("L", length($absolute_path))); $socket->send(pack("L", length($absolute_path)));
# Send the first argument as a string. # Send the first argument as a string.
$socket->send($absolute_path); $socket->send($absolute_path);

15
scripts/hint Executable file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env perl
use IO::Socket;
$socket = IO::Socket::INET->new(PeerAddr => "127.0.0.1",
PeerPort => 1235,
Proto => "tcp",
Type => SOCK_STREAM);
my $message = join " ", @ARGV;
# Send the length of the first argument as four bytes.
$socket->send(pack("L", length($message)));
# Send the first argument as a string.
$socket->send($message);