Add drop and take scripts, which add/remove items from the inventory

This commit is contained in:
blinry 2020-11-24 15:11:00 +01:00
parent 39577a94a7
commit 007cf764bf
4 changed files with 22 additions and 4 deletions

View file

@ -2,7 +2,6 @@ extends Node
var tmp_prefix = OS.get_user_data_dir() + "/tmp/"
var global_shell
var fake_editor
var dragged_object
var energy = 2
@ -15,11 +14,15 @@ func _ready():
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"))
fake_editor = tmp_prefix + "fake-editor"
global_shell.run("chmod u+x '%s'" % fake_editor)
create_verb("fake-editor")
create_verb("take")
create_verb("drop")
load_state()
func create_verb(name):
create_file_in_game_env(name, helpers.read_file("res://scripts/%s" % name))
global_shell.run("chmod u+x '%s'" % name)
func _initial_state():
return {"history": []}

View file

@ -87,6 +87,7 @@ func construct():
game.global_shell.cd(repo.path)
game.global_shell.run("git init")
game.global_shell.run("git symbolic-ref HEAD refs/heads/main")
game.global_shell.run("test -f ~/fake-editor && rm -rf ~/inventory || exit 1")
# Add other repos as remotes.
for r2 in repos:

9
scripts/drop Executable file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env bash
echo "Dropping $1!"
mv "$HOME/inventory/$1" .
if [ "$#" -eq 3 ]; then
echo "x = $2" > "$1"
echo "y = $3" >> "$1"
fi

5
scripts/take Executable file
View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
echo "Taking $1!"
mkdir -p ~/inventory
mv "$1" ~/inventory