diff --git a/src/controllers/script_controllers/host_bridge.nim b/src/controllers/script_controllers/host_bridge.nim index b12508b5..d8a1bbc4 100644 --- a/src/controllers/script_controllers/host_bridge.nim +++ b/src/controllers/script_controllers/host_bridge.nim @@ -431,6 +431,12 @@ proc tool(self: Unit): int = proc `tool=`(self: Unit, value: int) = state.tool = Tools(value) +proc open_sign(self: Unit): Sign = + state.open_sign + +proc `open_sign=`(self: Unit, value: Sign) = + state.open_sign = value + # Sign bindings proc new_markdown_sign(self: Worker, @@ -524,4 +530,4 @@ proc bridge_to_vm*(worker: Worker) = result.bridged_from_vm "players", playing, `playing=`, god, `god=`, flying, `flying=`, tool, `tool=`, - coding, `coding=`, running, `running=` + coding, `coding=`, running, `running=`, open_sign, `open_sign=` diff --git a/src/game.nim b/src/game.nim index 1dcd4845..56304d3c 100644 --- a/src/game.nim +++ b/src/game.nim @@ -360,28 +360,29 @@ Trying to connect to {state.config.connect_address}. state.set_flag MouseCaptured, MouseCaptured notin state.local_flags self.get_tree().set_input_as_handled() - if event.is_action_pressed("toggle_code_mode"): - if state.tool != CodeMode: - self.last_tool = state.tool + if state.tool != Disabled: + if event.is_action_pressed("toggle_code_mode"): + if state.tool != CodeMode: + self.last_tool = state.tool + state.tool = CodeMode + else: + state.tool = self.last_tool + elif event.is_action_pressed("mode_1"): state.tool = CodeMode - else: - state.tool = self.last_tool - elif event.is_action_pressed("mode_1"): - state.tool = CodeMode - elif event.is_action_pressed("mode_2"): - state.tool = BlueBlock - elif event.is_action_pressed("mode_3"): - state.tool = RedBlock - elif event.is_action_pressed("mode_4"): - state.tool = GreenBlock - elif event.is_action_pressed("mode_5"): - state.tool = BlackBlock - elif event.is_action_pressed("mode_6"): - state.tool = WhiteBlock - elif event.is_action_pressed("mode_7"): - state.tool = BrownBlock - elif event.is_action_pressed("mode_8"): - state.tool = PlaceBot + elif event.is_action_pressed("mode_2"): + state.tool = BlueBlock + elif event.is_action_pressed("mode_3"): + state.tool = RedBlock + elif event.is_action_pressed("mode_4"): + state.tool = GreenBlock + elif event.is_action_pressed("mode_5"): + state.tool = BlackBlock + elif event.is_action_pressed("mode_6"): + state.tool = WhiteBlock + elif event.is_action_pressed("mode_7"): + state.tool = BrownBlock + elif event.is_action_pressed("mode_8"): + state.tool = PlaceBot method on_meta_clicked(url: string) = if url.starts_with("nim://"): diff --git a/src/models/builds.nim b/src/models/builds.nim index 27973ecf..351b1132 100644 --- a/src/models/builds.nim +++ b/src/models/builds.nim @@ -219,7 +219,7 @@ proc remove(self: Build) = proc fire(self: Build) = let global_point = self.target_point.global_from(self) - if state.tool notin {CodeMode, PlaceBot}: + if state.tool notin {Disabled, CodeMode, PlaceBot}: state.skip_block_paint = true draw_normal = self.target_normal let point = (self.target_point + (self.target_normal * 0.5)).floor @@ -446,6 +446,11 @@ method main_thread_joined*(self: Build) = if PrimaryDown.removed or SecondaryDown.removed: state.draw_unit_id = "" last_point = vec3() + if Playing.added: + self.local_flags -= Highlight + elif Playing.removed: + if Hover in self.local_flags: + self.local_flags += Highlight method on_collision*(self: Build, partner: Model, normal: Vector3) = self.collisions.add (partner.id, normal) diff --git a/src/nodes/player_node.nim b/src/nodes/player_node.nim index 230a307a..2765a826 100644 --- a/src/nodes/player_node.nim +++ b/src/nodes/player_node.nim @@ -342,8 +342,7 @@ gdobj PlayerNode of KinematicBody: if event.is_action_pressed("fire"): if EditorVisible in state.local_flags: self.skip_release = true - if Playing notin state.local_flags: - state.push_flag PrimaryDown + state.push_flag PrimaryDown elif event.is_action_released("fire"): self.skip_release = false state.pop_flag PrimaryDown diff --git a/src/types.nim b/src/types.nim index 51e84b9f..cffe3e1f 100644 --- a/src/types.nim +++ b/src/types.nim @@ -33,7 +33,7 @@ type Tools* = enum CodeMode, BlueBlock, RedBlock, GreenBlock, BlackBlock, WhiteBlock, - BrownBlock, PlaceBot + BrownBlock, PlaceBot, Disabled TaskStates* = enum Running, Done, NextTask diff --git a/src/ui/toolbar.nim b/src/ui/toolbar.nim index 290366d1..13cbdb27 100644 --- a/src/ui/toolbar.nim +++ b/src/ui/toolbar.nim @@ -23,13 +23,16 @@ gdobj Toolbar of HBoxContainer: state.local_flags.changes: if Playing.added: self.visible = false + state.tool = Disabled if Playing.removed: self.visible = true + state.tool = BlueBlock self.zid = state.tool_value.changes: if added: let b = self.get_child(int(change.item)) as Button - b.set_pressed true + if ?b: + b.set_pressed true method process*(delta: float) = if self.preview_result.is_some: diff --git a/vmlib/enu/players.nim b/vmlib/enu/players.nim index fdb00fa9..da752cdf 100644 --- a/vmlib/enu/players.nim +++ b/vmlib/enu/players.nim @@ -21,3 +21,6 @@ bridged_to_host: proc coding*(self: PlayerType): Unit = discard proc `coding=`*(self: PlayerType, value: Unit) = discard + + proc open_sign*(self: PlayerType): Sign = discard + proc `open_sign=`*(self: PlayerType, value: Sign) = discard diff --git a/vmlib/worlds/tutorial/tutorial-1/data/build_x7imlkqz4ux9l/build_x7imlkqz4ux9l.json b/vmlib/worlds/tutorial/tutorial-1/data/build_x7imlkqz4ux9l/build_x7imlkqz4ux9l.json index d3358f05..fc03a25e 100644 --- a/vmlib/worlds/tutorial/tutorial-1/data/build_x7imlkqz4ux9l/build_x7imlkqz4ux9l.json +++ b/vmlib/worlds/tutorial/tutorial-1/data/build_x7imlkqz4ux9l/build_x7imlkqz4ux9l.json @@ -6,7 +6,7 @@ [0.0, 1.0, 0.0], [0.0, 0.0, 1.0] ], - "origin": [10.0, 0.0, -15.0] + "origin": [10.0, 3.0, -15.0] }, "start_color": "black", "edits": { diff --git a/vmlib/worlds/tutorial/tutorial-1/level.json b/vmlib/worlds/tutorial/tutorial-1/level.json index da483a7d..aef5ea53 100644 --- a/vmlib/worlds/tutorial/tutorial-1/level.json +++ b/vmlib/worlds/tutorial/tutorial-1/level.json @@ -1,4 +1,4 @@ { - "enu_version": "v0.1.99-190-gd71a4a25", + "enu_version": "v0.1.99-200-gaf9f01a9", "format_version": "v0.9.2" } \ No newline at end of file diff --git a/vmlib/worlds/tutorial/tutorial-1/scripts/build_x7imlkqz4ux9l.nim b/vmlib/worlds/tutorial/tutorial-1/scripts/build_x7imlkqz4ux9l.nim index c633ce7c..b6a13991 100644 --- a/vmlib/worlds/tutorial/tutorial-1/scripts/build_x7imlkqz4ux9l.nim +++ b/vmlib/worlds/tutorial/tutorial-1/scripts/build_x7imlkqz4ux9l.nim @@ -31,10 +31,6 @@ If you're not new, here are some other things to do: a simple game made with Enu. You can see how it was built in [this video](https://youtu.be/9e9sLsmsu_o). -- [Load CodeBots](). `CodeBots` is - an in-progress coding game that - [FrogTower](https://www.youtube.com/@frogtower) is working on. - - [Load default world](). """ diff --git a/vmlib/worlds/tutorial/tutorial-2/data/build_uu8u87ua76wp0/build_uu8u87ua76wp0.json b/vmlib/worlds/tutorial/tutorial-2/data/build_uu8u87ua76wp0/build_uu8u87ua76wp0.json new file mode 100644 index 00000000..d6c73643 --- /dev/null +++ b/vmlib/worlds/tutorial/tutorial-2/data/build_uu8u87ua76wp0/build_uu8u87ua76wp0.json @@ -0,0 +1,15 @@ +{ + "id": "build_uu8u87ua76wp0", + "start_transform": { + "basis": [ + [1.0, 0.0, 0.0], + [0.0, 1.0, 0.0], + [0.0, 0.0, 1.0] + ], + "origin": [-22.0, 0.0, 98.0] + }, + "start_color": "black", + "edits": { + + } +} diff --git a/vmlib/worlds/tutorial/tutorial-2/level.json b/vmlib/worlds/tutorial/tutorial-2/level.json index 83dada82..aef5ea53 100644 --- a/vmlib/worlds/tutorial/tutorial-2/level.json +++ b/vmlib/worlds/tutorial/tutorial-2/level.json @@ -1,4 +1,4 @@ { - "enu_version": "v0.1.99-168-g6dbf6334", + "enu_version": "v0.1.99-200-gaf9f01a9", "format_version": "v0.9.2" } \ No newline at end of file diff --git a/vmlib/worlds/tutorial/tutorial-2/scripts/build_uu8u87ua76wp0.nim b/vmlib/worlds/tutorial/tutorial-2/scripts/build_uu8u87ua76wp0.nim new file mode 100644 index 00000000..99457429 --- /dev/null +++ b/vmlib/worlds/tutorial/tutorial-2/scripts/build_uu8u87ua76wp0.nim @@ -0,0 +1,2 @@ +turn left +level_menu(me, show_restart = false) diff --git a/vmlib/worlds/tutorial/tutorial-2/scripts/build_zdvcvo11pyd20.nim b/vmlib/worlds/tutorial/tutorial-2/scripts/build_zdvcvo11pyd20.nim index 5fab990d..d46b8b2d 100644 --- a/vmlib/worlds/tutorial/tutorial-2/scripts/build_zdvcvo11pyd20.nim +++ b/vmlib/worlds/tutorial/tutorial-2/scripts/build_zdvcvo11pyd20.nim @@ -1,26 +1,67 @@ -let copy = """ +proc restart* = + player.flying = false + sleep() + player.open_sign = nil + player.position = start_spot + player.rotation = 180 + +proc stop_playing* = + player.playing = false + player.running = false - # Inky: Isolation +proc level_menu*(me: Build, show_restart = true) = + let blurb = "`Inky: Isolation` is a simple survivial game created in Enu. You can see how it was made in the video [Inky: Isolation. A 90 minute game built with Enu and Nim](https://youtu.be/9e9sLsmsu_o)" + + let copy = \""" - `Inky: Isolation` is a simple survivial game created in Enu. You can see how it was made in the video [Inky: Isolation. A 90 minute game built with Enu and Nim](https://youtu.be/9e9sLsmsu_o) +# Inky: Isolation - Click to [RESTART](nim://restart()) +{blurb} -""" -right 3 +- CLICK TO OPEN MENU -var sign1 = say(copy, more = copy, width = 4, height = 2, size = 200) -up 1 -left 3 -turn 180 -down 1 + """ + + me.right 3 -var sign2 = say(copy, more = copy, width = 4, height = 2, size = 200) -left 3 + let sign1 = me.say(copy, width = 4, height = 2, size = 200) + me.up 1 + me.left 3 + me.turn 180 + me.down 1 + + let sign2 = me.say(copy, width = 4, height = 2, size = 200) + me.left 3 + + forever: + let return_action = if show_restart: + "- [RETURN TO START]()" + else: + "" + + let toolbar_action = if player.playing: + "- [SHOW TOOLBAR AND STOP PLAYING]()" + else: + "" + + let more = \""" + +# Menu + +{blurb} + +{toolbar_action} + +{return_action} + +- [LOAD TUTORIAL]() + +- [CLEAR CHANGES AND RESET LEVEL]() + + """ + sign1.more = more + sign2.more = more + sleep 1 + +level_menu(me) -proc restart = - sign1.open = false - sign2.open = false - player.position = start_spot - player.rotation = 180 - player.playing = true