From 7ecc55a3fbe111e3c9557a2400d42f1a18f91639 Mon Sep 17 00:00:00 2001 From: blinry Date: Thu, 18 Feb 2021 12:39:18 +0100 Subject: [PATCH] Add cli hints to the first three levels --- levels/branches/branch-create | 4 ++++ levels/branches/checkout-commit | 6 ++++++ levels/branches/fork | 12 ++++++++++++ levels/branches/grow | 6 ++++++ levels/files/files-delete | 6 ++++++ levels/intro/commit | 6 ++++++ levels/intro/init | 7 +++++-- levels/intro/remote | 14 ++++++++++---- scenes/cli_badge.tscn | 12 ++++++------ scenes/level.gd | 17 ++++++++++++++--- 10 files changed, 75 insertions(+), 15 deletions(-) diff --git a/levels/branches/branch-create b/levels/branches/branch-create index 5c84791..110d929 100644 --- a/levels/branches/branch-create +++ b/levels/branches/branch-create @@ -7,6 +7,10 @@ You were invited to two parties! At one of them, your favorite band is playing - To make it easier to tell which timeline is which, you can create time portals! (We call these "branches".) +[cli] + +Branches also make it really easy to travel between different places using the command line! As soon as you have a branch called "birthday", you can type `git checkout birthday` to travel to it! + [setup] echo "You wrap the birthday present, and grab your concert ticket." > you diff --git a/levels/branches/checkout-commit b/levels/branches/checkout-commit index 0651267..28fcf3c 100644 --- a/levels/branches/checkout-commit +++ b/levels/branches/checkout-commit @@ -9,6 +9,12 @@ The grey panel below shows your current environment - click on an object to insp Can you find out what happened here? Then, while on the latest commit, edit the files to fix the problem, and make a new commit! +[cli] + +To checkout a specific commit, type `git checkout`, then a space, and then right click on the commit you want! + +This will insert the commit's unique identifier! + [setup] echo "This piggy bank belongs to the big sister. diff --git a/levels/branches/fork b/levels/branches/fork index 2ca5180..2d86675 100644 --- a/levels/branches/fork +++ b/levels/branches/fork @@ -7,6 +7,18 @@ Did you know that creating parallel timelines is perfectly legal and safe? It's Can you find out when things went wrong in this zoo, and create a parallel universe where everyone is happy? +[cli] + +The blue animal represents a concept known as the "HEAD pointer" in Git: It shows you which commit is the current one. + +Here's a cool trick to go to the previous commit: + + git checkout HEAD^ + +You can also go back two commits by typing, for example: + + git checkout HEAD~2 + [setup] mkdir cage diff --git a/levels/branches/grow b/levels/branches/grow index 82990bd..77fe360 100644 --- a/levels/branches/grow +++ b/levels/branches/grow @@ -9,6 +9,12 @@ First, you can directly travel to the commit, like we've done it before. And second, you can travel to the branch label. In this case, when you make a new commit, the branch will grow with you, and still point at the end of the timeline! +[cli] + +To travel to a branch, type `git checkout name_of_the_branch`. + +And to travel to the last commit, type `git checkout --detach name_of_the_branch`. + [setup] echo "You wrap the birthday present, and grab your concert ticket." > you diff --git a/levels/files/files-delete b/levels/files/files-delete index eafd7e3..7bf33be 100644 --- a/levels/files/files-delete +++ b/levels/files/files-delete @@ -8,6 +8,12 @@ Full of excitement you open the door just to find... spider webs! Spider webs ev Remove all the spider webs you can find with the remove card! +[cli] + +On the command line, you can easily delete all files ending in -web using this command: + + rm *web + [setup] echo A tiny spider web is next to your window. > tiny_web diff --git a/levels/intro/commit b/levels/intro/commit index 56346e9..8f0dc56 100644 --- a/levels/intro/commit +++ b/levels/intro/commit @@ -9,6 +9,12 @@ Here, let's practice this! (Your teacher pours some water into a glass.) +[cli] + +Again, instead of using the card, you can also type the commands which are printed on it into the black terminal below! + +This is totally optional! But this will be a super useful skill in the real world - and it will give you a sparkling golden badge! :) + [setup] echo "The glass is full of water." > glass diff --git a/levels/intro/init b/levels/intro/init index c87f667..7c76983 100644 --- a/levels/intro/init +++ b/levels/intro/init @@ -5,10 +5,13 @@ cards = init You've been accepted to time travel school! Yay! It's your first day! Your teacher explains: -"To do anything with a time machine, you first need to initialize it! Go ahead, try it!" +"To do anything with a time machine, you first need to initialize it!" + +Drag the blue card up to play it! [cli] -Instead of playing a card, you can slo type 'git init' directly into your terminal! + +Instead of using the card, you can also type `git init` into the black box below, and press the enter key! [setup] diff --git a/levels/intro/remote b/levels/intro/remote index 56ebbcc..c3c5e99 100644 --- a/levels/intro/remote +++ b/levels/intro/remote @@ -1,14 +1,20 @@ title = Working together -cards = clone checkout commit-auto pull push +cards = clone commit-auto pull push [description] -Let's add your name to our list of students! - -I already have this list my time machine - let's work together! +Let's add your name to our list of students! I already have this list my time machine - let's work together! Drag the "clone" card to my name to make your own copy of my timeline! +[cli] + +To clone the teacher's repo via the command line, you need this command: + + git clone ../teacher . + +(Don't forget the dot at the end!) + [congrats] Welcome to time travel school! :) I'll see you for your first class tomorrow! diff --git a/scenes/cli_badge.tscn b/scenes/cli_badge.tscn index 86347b8..30f6d15 100644 --- a/scenes/cli_badge.tscn +++ b/scenes/cli_badge.tscn @@ -3,13 +3,13 @@ [ext_resource path="res://images/cli-badge.svg" type="Texture" id=1] [ext_resource path="res://scenes/cli_badge.gd" type="Script" id=2] -[sub_resource type="Curve" id=2] +[sub_resource type="Curve" id=1] _data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), 0.0, 0.0, 0, 0 ] -[sub_resource type="CurveTexture" id=3] -curve = SubResource( 2 ) +[sub_resource type="CurveTexture" id=2] +curve = SubResource( 1 ) -[sub_resource type="ParticlesMaterial" id=1] +[sub_resource type="ParticlesMaterial" id=3] emission_shape = 2 emission_box_extents = Vector3( 20, 20, 1 ) flag_disable_z = true @@ -20,7 +20,7 @@ initial_velocity_random = 0.47 orbit_velocity = 0.0 orbit_velocity_random = 0.0 scale = 7.25 -scale_curve = SubResource( 3 ) +scale_curve = SubResource( 2 ) color = Color( 0.913725, 0.913725, 0.447059, 1 ) [node name="CLIBadge" type="TextureRect"] @@ -42,4 +42,4 @@ position = Vector2( 21.7701, 14.5133 ) z_index = 1 amount = 3 randomness = 0.34 -process_material = SubResource( 1 ) +process_material = SubResource( 3 ) diff --git a/scenes/level.gd b/scenes/level.gd index 8877f1d..97c1746 100644 --- a/scenes/level.gd +++ b/scenes/level.gd @@ -22,14 +22,25 @@ func load(path): title = config.get("title", slug) description = config.get("description", "(no description)") + # Surround all lines indented with four spaces with [code] tags. var monospace_regex = RegEx.new() monospace_regex.compile("\\n ([^\\n]*)") - description = monospace_regex.sub(description, "\n [code]$1[/code]", true) + description = monospace_regex.sub(description, "\n [code][color=#e1e160]$1[/color][/code]", true) description = description.split("---") - var cli_hints = "\n\n[color=#787878]"+config.get("cli", "")+"[/color]" - description[0] = description[0] + cli_hints + var cli_hints = config.get("cli", "") + # Also do this substitution in the CLI hints. + cli_hints = monospace_regex.sub(cli_hints, "\n [code][color=#bbbb5d]$1[/color][/code]", true) + + # Also replace `code` with [code] tags. + var monospace_inline_regex = RegEx.new() + monospace_inline_regex.compile("`([^`]+)`") + description[0] = monospace_inline_regex.sub(description[0], "[code][color=#e1e160]$1[/color][/code]") + cli_hints = monospace_inline_regex.sub(cli_hints, "[code][color=#bbbb5d]$1[/color][/code]", true) + + if cli_hints != "": + description[0] = description[0] + "\n\n[color=#787878]"+cli_hints+"[/color]" congrats = config.get("congrats", "Good job, you solved the level!\n\nFeel free to try a few more things or click 'Next level'.") cards = Array(config.get("cards", "").split(" "))