Skip to content

Commit

Permalink
implement intro #4
Browse files Browse the repository at this point in the history
  • Loading branch information
Lamby777 committed Aug 18, 2024
1 parent 351672a commit 46843ce
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 47 deletions.
25 changes: 24 additions & 1 deletion pets-gd/quests/intro1.gd
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,30 @@ func on_house_tp(target):
choicelist.duplicate(),
)

await dbox().say_as("[JUNIPER]", [ choicelist[picked] + "_MOM" ])
var picked_bedcolor_i = await dbox().say_as_with_choices(
"[JUNIPER]",
[choicelist[picked] + "_MOM", "DG_INTRO1_ITSYOURS"],
[
"[color=#BD0000]X[/color]",
"[color=#FF7200]X[/color]",
"[color=#FFE300]X[/color]",
"[color=#00AE06]X[/color]",
"[color=#2500FF]X[/color]",
"[color=#7F0087]X[/color]",
"[color=#E889C4]X[/color]",
]
)

var bedcolors = ["red", "orange", "yellow", "green", "blue", "purple", "pink"]
var picked_bedcolor = bedcolors[picked_bedcolor_i]

DialogueScriptBase.set_ethan_bed_color(picked_bedcolor)

await dbox().say_as("[JUNIPER]", [
"DG_INTRO1_LOOKSBETTER",
"DG_INTRO1_ILLBEDOWNSTAIRS",
"DG_INTRO1_BRINGFUZZY",
])

func on_outdoors_tp(target):
if target.name == "EthanHouseEntrance" and phase == 2:
Expand Down
41 changes: 0 additions & 41 deletions pets-lib/dg/src/intro1.dg
Original file line number Diff line number Diff line change
@@ -1,44 +1,3 @@
% Intro #4
NAME [JUNIPER]

DG_INTRO1_ITSYOURS

> [color=#BD0000]X[/color]
$ set_ethan_bed_color("red")

> [color=#FF7200]X[/color]
$ set_ethan_bed_color("orange")

> [color=#FFE300]X[/color]
$ set_ethan_bed_color("yellow")

> [color=#00AE06]X[/color]
$ set_ethan_bed_color("green")

> [color=#2500FF]X[/color]
$ set_ethan_bed_color("blue")

> [color=#7F0087]X[/color]
$ set_ethan_bed_color("purple")

> [color=#E889C4]X[/color]
$ set_ethan_bed_color("pink")

---
% Intro #4 >> Bed Color Picked
NAME [JUNIPER]

DG_INTRO1_LOOKSBETTER

---

DG_INTRO1_ILLBEDOWNSTAIRS

---

DG_INTRO1_BRINGFUZZY

---
% Intro #5
NAME [CLAY]

Expand Down
12 changes: 9 additions & 3 deletions pets-lib/src/functions.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::prelude::*;
use godot::classes::{Sprite2D, Texture2D};
use godot::classes::{GDScript, Sprite2D, Texture2D};
use godot::prelude::*;

#[derive(GodotClass)]
Expand All @@ -10,10 +10,17 @@ pub struct DialogueScriptBase {

#[godot_api]
impl DialogueScriptBase {
#[func]
pub fn new(script: Gd<GDScript>) -> Gd<Self> {
let mut executor = DialogueScriptBase::new_alloc();
executor.set_script(script.to_variant());
executor
}

/// This is the entry point for all dialogue scripts.
#[allow(non_snake_case)]
#[func(virtual)]
fn _start(&mut self) {}
pub fn _start(&mut self) {}

// Convenience stuff to prevent long lines in embedded dialogue scripts
#[func]
Expand Down Expand Up @@ -44,7 +51,6 @@ impl DialogueScriptBase {
let mut bed =
World::room().get_node_as::<Sprite2D>("%EthanBed/Sprite2D");
bed.callv("set_texture".into(), varray![texture]);
// start_ix("Intro #4 >> Bed Color Picked");
}

#[func]
Expand Down
3 changes: 1 addition & 2 deletions pets-lib/src/world/interaction/zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ impl InteractionZone {
#[func]
pub fn interact(&mut self) {
if let Some(script) = &self.interaction_script {
let mut executor = DialogueScriptBase::new_alloc();
executor.set_script(script.to_variant());
let mut executor = DialogueScriptBase::new(script.clone());
executor.call("_start".into(), &[]);

// Scripts take priority over beacons. You can make the player teleport
Expand Down

0 comments on commit 46843ce

Please sign in to comment.