Changed Level description to sh scripts

This commit is contained in:
bleeptrack 2020-09-04 11:40:42 +02:00
parent f2b88d893e
commit 00247318a6
3 changed files with 137 additions and 124 deletions

10
game.gd
View file

@ -51,6 +51,16 @@ func sh(command, wd="/tmp/"):
OS.execute("/bin/sh", ["-c", hacky_command], true, output, true)
return output[0]
func script(filename, wd="/tmp/"):
print("sh script in "+wd+": "+filename)
var cwd = game.run("pwd")
var output = []
var hacky_command = "/bin/sh " + filename
hacky_command = "cd '"+wd+"';"+hacky_command
OS.execute("/bin/sh", ["-c", hacky_command], true, output, true)
return output[0]
func read_file(path):
print("read "+path)
var file = File.new()

View file

@ -1,2 +1,4 @@
git write-tree
git commit-tree 4b82 -m 'We cannot really construct the goal yet :)'
FIRST_COMMIT=$( git commit-tree 4b82 -m 'We cannot really construct the goal yet :)' )
git commit-tree 4b82 -p $FIRST_COMMIT -m 'Second commit :D'

13
main.gd
View file

@ -48,7 +48,7 @@ func load_level(id):
var level = levels[id]
var cwd = game.run("pwd")
var tmp_prefix = "/tmp/"
var level_prefix = "res://levels/"
var level_prefix = cwd + "/levels/"
var goal_repository_path = tmp_prefix+"goal/"
var active_repository_path = tmp_prefix+"active/"
@ -70,11 +70,12 @@ func construct_repo(script, path):
print(path)
game.sh("mkdir "+path)
game.sh("git init", path)
var commands = game.read_file(script).split("\n")
print(commands)
for command in commands:
print(command)
game.sh(command, path)
print(game.script(script, path))
#var commands = game.read_file(script).split("\n")
#print(commands)
#for command in commands:
# print(command)
# game.sh(command, path)
func _process(delta):
if server.is_connection_available():