mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-22 16:20:19 +01:00
Add drop and take scripts, which add/remove items from the inventory
This commit is contained in:
parent
39577a94a7
commit
007cf764bf
4 changed files with 22 additions and 4 deletions
|
@ -2,7 +2,6 @@ extends Node
|
||||||
|
|
||||||
var tmp_prefix = OS.get_user_data_dir() + "/tmp/"
|
var tmp_prefix = OS.get_user_data_dir() + "/tmp/"
|
||||||
var global_shell
|
var global_shell
|
||||||
var fake_editor
|
|
||||||
|
|
||||||
var dragged_object
|
var dragged_object
|
||||||
var energy = 2
|
var energy = 2
|
||||||
|
@ -15,12 +14,16 @@ 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"))
|
create_verb("fake-editor")
|
||||||
fake_editor = tmp_prefix + "fake-editor"
|
create_verb("take")
|
||||||
global_shell.run("chmod u+x '%s'" % fake_editor)
|
create_verb("drop")
|
||||||
|
|
||||||
load_state()
|
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():
|
func _initial_state():
|
||||||
return {"history": []}
|
return {"history": []}
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,7 @@ func construct():
|
||||||
game.global_shell.cd(repo.path)
|
game.global_shell.cd(repo.path)
|
||||||
game.global_shell.run("git init")
|
game.global_shell.run("git init")
|
||||||
game.global_shell.run("git symbolic-ref HEAD refs/heads/main")
|
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.
|
# Add other repos as remotes.
|
||||||
for r2 in repos:
|
for r2 in repos:
|
||||||
|
|
9
scripts/drop
Executable file
9
scripts/drop
Executable 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
5
scripts/take
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
echo "Taking $1!"
|
||||||
|
mkdir -p ~/inventory
|
||||||
|
mv "$1" ~/inventory
|
Loading…
Reference in a new issue