Commit 9520ad67 authored by Julia Santos's avatar Julia Santos

Doing some script docs/commenting, also made it so that unjamming the cabinet...

Doing some script docs/commenting, also made it so that unjamming the cabinet doesn't immediately open it yet
parent fe7a1e35
extends Control extends Control
# This script handles the calculation and logic of the food/energy puzzle, and edits the energy level in the UI
signal eaten signal eaten # signals to the
#UI elements #UI elements
onready var dialogue onready var dialogue # dialogue box
onready var energy_bar onready var energy_bar # energy bar
#ingredients #ingredients
onready var bread = get_parent().get_node("Bread") onready var bread = get_parent().get_node("Bread")
...@@ -16,7 +17,6 @@ onready var cook = get_parent().get_node("Cook") ...@@ -16,7 +17,6 @@ onready var cook = get_parent().get_node("Cook")
# an array containing all of the selected ingredients # an array containing all of the selected ingredients
onready var ingredients = [] onready var ingredients = []
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
pass # Replace with function body. pass # Replace with function body.
...@@ -28,13 +28,13 @@ func passEvent(handler): # retrieves energy bar from event handler ...@@ -28,13 +28,13 @@ func passEvent(handler): # retrieves energy bar from event handler
energy_bar = handler.give_energy_bar() energy_bar = handler.give_energy_bar()
connect("eaten",handler,"_eaten") connect("eaten",handler,"_eaten")
func _selected_ing(ingredient): # when an ingredient is selected func _selected_ing(ingredient): # when an ingredient is selected, add it to the list
ingredients.append(ingredient) ingredients.append(ingredient)
print(ingredients.size()) print(ingredients.size())
print(ingredients) print(ingredients)
updateUI() updateUI()
func _unselected_ing(ingredient): # when an ingredient is unselected func _unselected_ing(ingredient): # when an ingredient is unselected, remove it from the list
ingredients.erase(ingredient) ingredients.erase(ingredient)
if ingredients.size() == 0: # reset flavor text if ingredients.size() == 0: # reset flavor text
dialogue.text = "" dialogue.text = ""
...@@ -42,8 +42,8 @@ func _unselected_ing(ingredient): # when an ingredient is unselected ...@@ -42,8 +42,8 @@ func _unselected_ing(ingredient): # when an ingredient is unselected
print(ingredients) print(ingredients)
updateUI() updateUI()
func updateUI(): # whenever there's a change in selections func updateUI(): # whenever there's a change in selections, enables/disables ingredients depending on what food can or cannot be eaten with each other
if ingredients.size() >= 1 and ingredients[0] != "Granola bar": # if anything aside from the granola bar is selected, as it can't be cooked in a recipe if ingredients.size() >= 1 and ingredients[0] != "Granola bar": # if anything aside from the granola bar is selected, disable the granola bar, as the granola bar can only be eaten alone
granola.interactable = false granola.interactable = false
granola.modulate = Color("#616161") # turn grey granola.modulate = Color("#616161") # turn grey
eat.hide() eat.hide()
...@@ -78,14 +78,14 @@ func updateUI(): # whenever there's a change in selections ...@@ -78,14 +78,14 @@ func updateUI(): # whenever there's a change in selections
dialogue.text = "An egg and sausage sandwich. Requires 20 energy and gives 40 energy." dialogue.text = "An egg and sausage sandwich. Requires 20 energy and gives 40 energy."
cook.show() cook.show()
func clearFridge(): # clear out the consumed ingredients func clearFridge(): # clear out the consumed ingredients from the fridge
for ing in ingredients: for ing in ingredients:
get_parent().get_node(ing).queue_free() get_parent().get_node(ing).queue_free()
ingredients.clear() ingredients.clear()
updateUI() updateUI()
dialogue.text = "Delicious!" dialogue.text = "Delicious!"
func _cook(): func _cook(): # calculates the amount of energy gained based on what ingredients were cooked
match ingredients.size(): match ingredients.size():
1: 1:
match ingredients[0]: match ingredients[0]:
...@@ -105,7 +105,7 @@ func _cook(): ...@@ -105,7 +105,7 @@ func _cook():
clearFridge() clearFridge()
cook.hide() cook.hide()
func _eat(): func _eat(): # calculates the amount of energy gained based on what ingredients were eaten
match ingredients[0]: match ingredients[0]:
"Vienna sausage": "Vienna sausage":
energy_bar.value += 12 energy_bar.value += 12
......
...@@ -47,7 +47,7 @@ func _ready(): ...@@ -47,7 +47,7 @@ func _ready():
notepad.hide() notepad.hide()
for item in eventItems: for item in eventItems:
get_node(item).passEvent(self) get_node(item).passEvent(self)
connect_stools() #connect_stools()
lockedNotepad = true lockedNotepad = true
right.hide() right.hide()
left.hide() left.hide()
...@@ -286,9 +286,9 @@ func _out_desk(): ...@@ -286,9 +286,9 @@ func _out_desk():
bedroom.show() bedroom.show()
# ----------------- To be removed ----------------- # ----------------- To be removed -----------------
func connect_stools(): # connecting the two instances of the stool so that one disappears when the other is retrieved #func connect_stools(): # connecting the two instances of the stool so that one disappears when the other is retrieved
get_parent().get_node("Laundry area/Stool").giveStool(get_parent().get_node("Kitchen/Stool")) # get_parent().get_node("Laundry area/Stool").giveStool(get_parent().get_node("Kitchen/Stool"))
get_parent().get_node("Kitchen/Stool").giveStool(get_parent().get_node("Laundry area/Stool")) # get_parent().get_node("Kitchen/Stool").giveStool(get_parent().get_node("Laundry area/Stool"))
# ----------------- Other ----------------- # ----------------- Other -----------------
func give_energy_bar(): # returns energy bar node func give_energy_bar(): # returns energy bar node
......
extends StaticBody2D extends StaticBody2D
# This is a general use script for all items in the game. Items with special uses extend this script, so any changes to this script will still affect everything.
#UI stuff #UI stuff
onready var dialogueBox onready var dialogueBox # the dialogue box node, with a RichTextLabel inside
onready var inventory onready var inventory # the inventory
onready var quests onready var quests # the actual Quests node
#variables that are editable in the Inspector #variables that are editable in the Inspector
export(bool) var retrievable # check if this item can be placed in the inventory export(bool) var retrievable # check if this item can be placed in the inventory
export(bool) var interactable # for environmental objects that are interactable but not retrievable export(bool) var interactable # for environmental objects that are interactable but not retrievable
export(String) var flavorText # the flavor text that appears in the dialogue box when picked up export(String) var flavorText # the flavor text that appears in the dialogue box when picked up
onready var control = get_parent().get_node("Dialogue control") onready var control = get_parent().get_node("Dialogue control") # has a unique control in each room, this is the reference point for generating the flavor text of any interactions that don't have special effects
#other variables #other variables
onready var texture onready var texture # the texture of the items's sprite, for passing to inventory
# some references # some references
# https://docs.godotengine.org/en/stable/getting_started/scripting/gdscript/gdscript_exports.html # https://docs.godotengine.org/en/stable/getting_started/scripting/gdscript/gdscript_exports.html
...@@ -32,20 +34,20 @@ func _input_event(viewport, event, shape_idx): # executes when clicked on ...@@ -32,20 +34,20 @@ func _input_event(viewport, event, shape_idx): # executes when clicked on
if event.button_index == BUTTON_LEFT and event.pressed: if event.button_index == BUTTON_LEFT and event.pressed:
#print("Clicked on " + self.get_name() + " with selected " + str(inventory.is_anything_selected())) #print("Clicked on " + self.get_name() + " with selected " + str(inventory.is_anything_selected()))
if inventory.is_anything_selected() and interactable: # if the player has an item selected and they use it on something interactable if inventory.is_anything_selected() and interactable: # if the player has an item selected and they use it on something interactable
storeInt(inventory.get_selected_items()[0]) storeInt(inventory.get_selected_items()[0]) # sends the data for mouse tracking
objInteraction(inventory.get_selected_items()[0]) objInteraction(inventory.get_selected_items()[0])
elif inventory.is_anything_selected() and retrievable: # use object on something retrievable elif inventory.is_anything_selected() and retrievable: # use object on something retrievable
storeInt(inventory.get_selected_items()[0]) storeInt(inventory.get_selected_items()[0]) # sends the data for mouse tracking
objInteraction(inventory.get_selected_items()[0]) objInteraction(inventory.get_selected_items()[0])
elif !inventory.is_anything_selected() and retrievable: # if they click on something retrievable w/ empty hands elif !inventory.is_anything_selected() and retrievable: # if they click on something retrievable w/ empty hands
storeClick("Picked up") storeClick("Picked up") # sends the data for mouse tracking
pickup() pickup()
elif interactable: #for environment things that arent retrievable, and hands are empty elif interactable: #for environment things that arent retrievable, and hands are empty
storeClick("Clicked on") storeClick("Clicked on") # sends the data for mouse tracking
mouseInteraction() mouseInteraction()
#get_tree().set_input_as_handled() #get_tree().set_input_as_handled()
func storeClick(method): func storeClick(method): # stores the mouse click data to data.save
var save_data = File.new() var save_data = File.new()
if !save_data.file_exists("user://data.save"): if !save_data.file_exists("user://data.save"):
save_data.open("user://data.save",File.WRITE) save_data.open("user://data.save",File.WRITE)
...@@ -58,7 +60,7 @@ func storeClick(method): ...@@ -58,7 +60,7 @@ func storeClick(method):
print("Writing to file") print("Writing to file")
save_data.close() save_data.close()
func storeInt(selected): func storeInt(selected): # specifically for using one item on another, stores mouse click data to data.save
var save_data = File.new() var save_data = File.new()
if !save_data.file_exists("user://data.save"): if !save_data.file_exists("user://data.save"):
save_data.open("user://data.save",File.WRITE) save_data.open("user://data.save",File.WRITE)
...@@ -72,9 +74,9 @@ func storeInt(selected): ...@@ -72,9 +74,9 @@ func storeInt(selected):
save_data.close() save_data.close()
# override the following functions as needed when extending the script:
func mouseInteraction(): # just clicked on it with nothing func mouseInteraction(): # just clicked on it with nothing
dialogueBox.text = flavorText dialogueBox.text = flavorText
func pickup(): # when it's picked up func pickup(): # when it's picked up
dialogueBox.text = flavorText dialogueBox.text = flavorText
...@@ -89,4 +91,3 @@ func objInteraction(selected): # when an object is used on it ...@@ -89,4 +91,3 @@ func objInteraction(selected): # when an object is used on it
else: else:
dialogueBox.text = "No flavor text found" #can replace this later! dialogueBox.text = "No flavor text found" #can replace this later!
inventory.unselect_all() #unselect item inventory.unselect_all() #unselect item
extends "res://Item.gd" extends "res://Item.gd"
signal retrieved signal retrieved
onready var eventHandler onready var eventHandler
# This script is a general use script for the different lab notes, signals to the event handler to add another note to the count
# This script also allows for the lab notes to stack instead of showing up in the inventory one by one
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
...@@ -11,9 +13,9 @@ func passEvent(handler): ...@@ -11,9 +13,9 @@ func passEvent(handler):
connect("retrieved", handler,"_add_lab_note") connect("retrieved", handler,"_add_lab_note")
func pickup(): func pickup():
if (eventHandler.get_lab_notes() == 0): if (eventHandler.get_lab_notes() == 0): # if this is the first lab note, add a generic lab note item to inventory
inventory.add_item("Lab Notes", texture) inventory.add_item("Lab Notes", texture)
if get_name() == "Lab Note - Bathroom": if get_name() == "Lab Note - Bathroom": # if this is specifically the lab note in the bathroom, signal to the mirror that it's been taken
get_parent().get_node("Mirror").gotNote() get_parent().get_node("Mirror").gotNote()
dialogueBox.text = flavorText dialogueBox.text = flavorText
queue_free() queue_free()
......
[gd_scene load_steps=15 format=2] [gd_scene load_steps=14 format=2]
[ext_resource path="res://assets/Placeholder BGs/kitchen area.png" type="Texture" id=1] [ext_resource path="res://assets/Placeholder BGs/kitchen area.png" type="Texture" id=1]
[ext_resource path="res://assets/placeholder item.png" type="Texture" id=2] [ext_resource path="res://assets/placeholder item.png" type="Texture" id=2]
[ext_resource path="res://Item.gd" type="Script" id=3] [ext_resource path="res://Item.gd" type="Script" id=3]
[ext_resource path="res://Scripts/Dialogue control/Dialogue control - Kitchen.gd" type="Script" id=4] [ext_resource path="res://Scripts/Dialogue control/Dialogue control - Kitchen.gd" type="Script" id=4]
[ext_resource path="res://assets/Thesis Clickables/stool.png" type="Texture" id=5] [ext_resource path="res://assets/Thesis Clickables/stool.png" type="Texture" id=5]
[ext_resource path="res://Scripts/Stool.gd" type="Script" id=6]
[ext_resource path="res://Scripts/Fridge.gd" type="Script" id=7] [ext_resource path="res://Scripts/Fridge.gd" type="Script" id=7]
[ext_resource path="res://Scripts/Movement scripts/Cabinet.gd" type="Script" id=8] [ext_resource path="res://Scripts/Movement scripts/Cabinet.gd" type="Script" id=8]
...@@ -117,11 +116,10 @@ visible = false ...@@ -117,11 +116,10 @@ visible = false
position = Vector2( 112.641, 527.75 ) position = Vector2( 112.641, 527.75 )
scale = Vector2( 0.829244, 0.829244 ) scale = Vector2( 0.829244, 0.829244 )
input_pickable = true input_pickable = true
script = ExtResource( 6 ) script = ExtResource( 3 )
__meta__ = { __meta__ = {
"_edit_group_": true "_edit_group_": true
} }
retrievable = true
flavorText = "A sturdy stool." flavorText = "A sturdy stool."
[node name="CollisionShape2D" type="CollisionShape2D" parent="Stool"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Stool"]
......
[gd_scene load_steps=12 format=2] [gd_scene load_steps=11 format=2]
[ext_resource path="res://assets/Placeholder BGs/laundry area.png" type="Texture" id=1] [ext_resource path="res://assets/Placeholder BGs/laundry area.png" type="Texture" id=1]
[ext_resource path="res://Item.gd" type="Script" id=2] [ext_resource path="res://Item.gd" type="Script" id=2]
[ext_resource path="res://assets/Thesis Clickables/stool.png" type="Texture" id=3] [ext_resource path="res://assets/Thesis Clickables/stool.png" type="Texture" id=3]
[ext_resource path="res://Scripts/Stool.gd" type="Script" id=4]
[ext_resource path="res://Scripts/Dialogue control/Dialogue control - Laundry area.gd" type="Script" id=5] [ext_resource path="res://Scripts/Dialogue control/Dialogue control - Laundry area.gd" type="Script" id=5]
[ext_resource path="res://Scripts/Groceries.gd" type="Script" id=6] [ext_resource path="res://Scripts/Groceries.gd" type="Script" id=6]
[sub_resource type="RectangleShape2D" id=1] [sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 35.8254, 43.5967 ) extents = Vector2( 35.8254, 38.2746 )
[sub_resource type="StreamTexture" id=2] [sub_resource type="StreamTexture" id=2]
flags = 4 flags = 4
...@@ -52,7 +51,7 @@ interactable = true ...@@ -52,7 +51,7 @@ interactable = true
flavorText = "Something's in the way." flavorText = "Something's in the way."
[node name="CollisionShape2D" type="CollisionShape2D" parent="Laundry door"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Laundry door"]
position = Vector2( 7.24008, -23.0954 ) position = Vector2( 5.806, -53.2112 )
scale = Vector2( 5, 5 ) scale = Vector2( 5, 5 )
z_index = -1 z_index = -1
shape = SubResource( 1 ) shape = SubResource( 1 )
...@@ -113,7 +112,7 @@ __meta__ = { ...@@ -113,7 +112,7 @@ __meta__ = {
position = Vector2( 642.322, 475.158 ) position = Vector2( 642.322, 475.158 )
scale = Vector2( 0.829244, 0.829244 ) scale = Vector2( 0.829244, 0.829244 )
input_pickable = true input_pickable = true
script = ExtResource( 4 ) script = ExtResource( 2 )
__meta__ = { __meta__ = {
"_edit_group_": true "_edit_group_": true
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
[ext_resource path="res://Scripts/Dialogue control/Dialogue control - Test Room 1.gd" type="Script" id=4] [ext_resource path="res://Scripts/Dialogue control/Dialogue control - Test Room 1.gd" type="Script" id=4]
[ext_resource path="res://assets/Thesis Clickables/trail 1.png" type="Texture" id=5] [ext_resource path="res://assets/Thesis Clickables/trail 1.png" type="Texture" id=5]
[ext_resource path="res://assets/Thesis Clickables/trail 2.png" type="Texture" id=6] [ext_resource path="res://assets/Thesis Clickables/trail 2.png" type="Texture" id=6]
[ext_resource path="res://Scripts/Placeholder 4.gd" type="Script" id=7] [ext_resource path="res://Item.gd" type="Script" id=7]
[ext_resource path="res://assets/Thesis Clickables/clothes pile.png" type="Texture" id=8] [ext_resource path="res://assets/Thesis Clickables/clothes pile.png" type="Texture" id=8]
[ext_resource path="res://Scripts/Laundry basket.gd" type="Script" id=9] [ext_resource path="res://Scripts/Laundry basket.gd" type="Script" id=9]
[ext_resource path="res://Scripts/Movement scripts/Bathroom door.gd" type="Script" id=10] [ext_resource path="res://Scripts/Movement scripts/Bathroom door.gd" type="Script" id=10]
......
...@@ -61,7 +61,7 @@ bg_color = Color( 0.145098, 0.145098, 0.164706, 1 ) ...@@ -61,7 +61,7 @@ bg_color = Color( 0.145098, 0.145098, 0.164706, 1 )
[node name="Bedroom" parent="." instance=ExtResource( 1 )] [node name="Bedroom" parent="." instance=ExtResource( 1 )]
script = ExtResource( 4 ) script = ExtResource( 4 )
items = [ NodePath("Pants"), NodePath("Shirt"), NodePath("Sando"), NodePath("Towel"), NodePath("Laundry basket"), NodePath("Laptop"), NodePath("Pile of clothes"), NodePath("Bathroom door"), NodePath("Terrarium"), NodePath("BG") ] items = [ NodePath("Pants"), NodePath("Shirt"), NodePath("Sando"), NodePath("Towel"), NodePath("Laundry basket"), NodePath("Laptop"), NodePath("Pile of clothes"), NodePath("Bathroom door"), NodePath("Terrarium") ]
[node name="Sprite" parent="Bedroom/BG/CollisionShape2D" index="0"] [node name="Sprite" parent="Bedroom/BG/CollisionShape2D" index="0"]
position = Vector2( 9.0239, 16.168 ) position = Vector2( 9.0239, 16.168 )
......
extends StaticBody2D extends StaticBody2D
onready var inventory onready var inventory
export(bool) var tracking export(bool) var tracking
# This script tracks the coordinates of each mouse click, and saves it to data.save
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
pass # Replace with function body. pass # Replace with function body.
func _unhandled_input(event): func _unhandled_input(event): # for any input that isn't capture by UI or any other items in the scene tree (doesn't count instanced scene trees)
if event is InputEventMouseButton: if event is InputEventMouseButton:
if event.button_index == BUTTON_LEFT and event.pressed: if event.button_index == BUTTON_LEFT and event.pressed:
if tracking: if tracking: # if tracking of coordinates is enabled, turn it off to only track per-item clicks
var save_data = File.new() var save_data = File.new()
if !save_data.file_exists("user://data.save"): if !save_data.file_exists("user://data.save"): # creates a new save file if there is none
save_data.open("user://data.save",File.WRITE) save_data.open("user://data.save",File.WRITE)
save_data.store_string(str(event.position) + ": ") save_data.store_string(str(event.position) + ": ")
print("Created file") print("Created file")
else: else: # appends to existing save file if it does exist
save_data.open("user://data.save",File.READ_WRITE) save_data.open("user://data.save",File.READ_WRITE)
save_data.seek_end() save_data.seek_end()
save_data.store_string("\n"+ str(event.position) + ": ") save_data.store_string("\n"+ str(event.position) + ": ")
print("Writing coordinates to file") print("Writing coordinates to file")
save_data.close() save_data.close()
#print(event.position)
func passUI(inv, dia, que):
inventory = inv
print("Found " + inventory.get_name())
...@@ -3,6 +3,8 @@ signal retrieved ...@@ -3,6 +3,8 @@ signal retrieved
onready var eventHandler onready var eventHandler
onready var clothesTexture = get_parent().get_node("Pile of clothes/CollisionShape2D/Sprite").get_texture() onready var clothesTexture = get_parent().get_node("Pile of clothes/CollisionShape2D/Sprite").get_texture()
# This script allows for the different pieces of clothing on the floor to be stacked, combining into one general pile of dirty clothes
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
pass # Replace with function body. pass # Replace with function body.
...@@ -18,4 +20,3 @@ func pickup(): ...@@ -18,4 +20,3 @@ func pickup():
queue_free() queue_free()
inventory.unselect_all() inventory.unselect_all()
emit_signal("retrieved") emit_signal("retrieved")
#test
...@@ -4,6 +4,9 @@ signal start_lab ...@@ -4,6 +4,9 @@ signal start_lab
onready var started = false onready var started = false
onready var eventHandler onready var eventHandler
# This script signals to the eventHandler to give the player the 2nd phase of quests after finishing the first one
# It will also signal the end of the game once all the lab notes have been collected
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
pass # Replace with function body. pass # Replace with function body.
...@@ -15,7 +18,7 @@ func passEvent(handler): ...@@ -15,7 +18,7 @@ func passEvent(handler):
func mouseInteraction(): func mouseInteraction():
.mouseInteraction() .mouseInteraction()
if !started: if !started: # if the quests have been given yet
emit_signal("start_lab") emit_signal("start_lab")
started = true started = true
else: else:
......
extends "res://Item.gd" extends "res://Item.gd"
onready var number = 0 onready var number = 0
signal selected_ing signal selected_ing # that an ingredient has been selected
signal unselected_ing signal unselected_ing # that an ingredient has been unselected
signal cook signal cook # that the player has selected cook
signal eat signal eat # that the player has selected eat
# booleans # This script is a general use script for food items, and signals to the energy handler what food has been selected. This also includes the "Eat" and "Cook" buttons, which signal to the energy handler to commence eating/cooking the selected items
# booleans, whether or not a specific food has been selected
onready var bread onready var bread
onready var egg onready var egg
onready var granola onready var granola
......
extends "res://Item.gd" extends "res://Item.gd"
signal fridge_opened signal fridge_opened
# This script sends the player to the fridge view when clicked on
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
...@@ -16,6 +12,4 @@ func mouseInteraction(): ...@@ -16,6 +12,4 @@ func mouseInteraction():
func passEvent(handler): func passEvent(handler):
connect("fridge_opened", handler,"_open_fridge") connect("fridge_opened", handler,"_open_fridge")
pass pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
extends "res://Item.gd" extends "res://Item.gd"
signal groceries_put_away signal groceries_put_away
# This script signals to the event handler that the stool has been used on the groceries, then disposes of this node
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
pass # Replace with function body. pass # Replace with function body.
......
extends "res://Item.gd" extends "res://Item.gd"
signal laptop signal laptop
# This script changes to the zoomed in view of the desk when clicked on
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
......
extends "res://Item.gd" extends "res://Item.gd"
signal retrieved signal retrieved
# This script changes the view to the zoomed into the laundry basket when clicked on
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
...@@ -24,12 +20,7 @@ func objInteraction(selected): # when an object is used on it ...@@ -24,12 +20,7 @@ func objInteraction(selected): # when an object is used on it
dialogueBox.text = flavor dialogueBox.text = flavor
else: else:
dialogueBox.text = "No flavor text found" #can replace this later! dialogueBox.text = "No flavor text found" #can replace this later!
var selectedText = inventory.get_item_text(selected)
if selectedText == "Pants" or selectedText == "Shirt" or selectedText == "Sando" or selectedText == "Towel":
inventory.remove_item(selected)
inventory.unselect_all() #unselect item inventory.unselect_all() #unselect item
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func finished(): func finished():
interactable = false interactable = false
extends "res://Item.gd" extends "res://Item.gd"
signal cleaned signal cleaned
onready var eventHandler onready var eventHandler
onready var clean = false
# This script is for changing the flavor text of the mess on floor and tracking if it's been cleaned or not, and prevents it from being cleaned before the bobby pins have been picked up
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
...@@ -13,18 +15,17 @@ func passEvent(handler): ...@@ -13,18 +15,17 @@ func passEvent(handler):
func objInteraction(selected): func objInteraction(selected):
var flavor = control.interaction(inventory.get_item_text(selected), self.get_name()) var flavor = control.interaction(inventory.get_item_text(selected), self.get_name())
if inventory.get_item_text(selected) == "Cleaning mat": if inventory.get_item_text(selected) == "Cleaning mat": # using the cleaning materials on the mess
if inventory.hasItem("Bobby pins") == -1: #if the bobby pins haven't been picked up yet if inventory.hasItem("Bobby pins") == -1: #if the bobby pins haven't been picked up yet
dialogueBox.text = "Ow! I stepped on something!" dialogueBox.text = "Ow! I stepped on something!"
print("Cleaning but bobby pins") else: # if they have been picked up
else: if !clean: #if it hasnt been cleaned yet
if flavorText != "Okay. That wasn't so bad...": #if it hasnt been cleaned yet
dialogueBox.text = "Finally... I can walk around my own bathroom." dialogueBox.text = "Finally... I can walk around my own bathroom."
flavorText = "Okay. That wasn't so bad..." flavorText = "Okay. That wasn't so bad..."
emit_signal("cleaned", "Cleaning mat") emit_signal("cleaned", "Cleaning mat")
else: clean = true
else: # trying to use the cleaning materials when it's already clean
dialogueBox.text = flavorText dialogueBox.text = flavorText
print("already cleaned")
elif typeof(flavor) != 0: #checks if there's coded flavor text for this interaction elif typeof(flavor) != 0: #checks if there's coded flavor text for this interaction
dialogueBox.text = flavor dialogueBox.text = flavor
else: else:
...@@ -33,6 +34,6 @@ func objInteraction(selected): ...@@ -33,6 +34,6 @@ func objInteraction(selected):
func mouseInteraction(): func mouseInteraction():
.mouseInteraction() .mouseInteraction()
if flavorText != "Do I have anything to clean this with?": if flavorText != "Do I have anything to clean this with?": # changing flavor text after the first interaction
flavorText = "Do I have anything to clean this with?" flavorText = "Do I have anything to clean this with?"
...@@ -3,7 +3,8 @@ onready var gotLabNote = false ...@@ -3,7 +3,8 @@ onready var gotLabNote = false
onready var first = true onready var first = true
signal cleaned signal cleaned
onready var eventHandler onready var eventHandler
onready var clean = false onready var clean = false # whether or not the mirror is clean
# This script changes the flavor text of the mirror after clicking on it the first time, and also prevents the mirror from being cleaned before the lab note is retrieved
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
...@@ -17,22 +18,22 @@ func passEvent(handler): ...@@ -17,22 +18,22 @@ func passEvent(handler):
func mouseInteraction(): func mouseInteraction():
.mouseInteraction() .mouseInteraction()
if first: if first: # changes flavor text after first interaction
flavorText = "Do I have anything to clean this with?" flavorText = "Do I have anything to clean this with?"
first = false first = false
func objInteraction(selected): func objInteraction(selected):
var flavor = control.interaction(inventory.get_item_text(selected), self.get_name()) var flavor = control.interaction(inventory.get_item_text(selected), self.get_name())
if inventory.get_item_text(selected) == "Cleaning mat": if inventory.get_item_text(selected) == "Cleaning mat": # if the cleaning materials are used on it
if !clean: # if the mirror is clean yet if !clean: # if the mirror is clean yet
if gotLabNote: # if the note's been removed if gotLabNote: # if the note's been removed
flavorText = "Great! I can see my own face again." flavorText = "Great! I can see my own face again."
dialogueBox.text = flavorText dialogueBox.text = flavorText
emit_signal("cleaned", "Cleaning mat") emit_signal("cleaned", "Cleaning mat") # signals to event handler that another object has been cleaned
clean = true clean = true # mirror is now clean
else: else: # if the mirror is dirty but the lab note hasn't been retrieved
dialogueBox.text = "Hey! Something's still written on the mirror! Looks important..." dialogueBox.text = "Hey! Something's still written on the mirror! Looks important..."
else: else: # if the mirror is already clean
dialogueBox.text = flavorText dialogueBox.text = flavorText
elif typeof(flavor) != 0: #checks if there's coded flavor text for this interaction elif typeof(flavor) != 0: #checks if there's coded flavor text for this interaction
dialogueBox.text = flavor dialogueBox.text = flavor
...@@ -40,6 +41,6 @@ func objInteraction(selected): ...@@ -40,6 +41,6 @@ func objInteraction(selected):
dialogueBox.text = "No flavor text found" #can replace this later! dialogueBox.text = "No flavor text found" #can replace this later!
inventory.unselect_all() #unselect item inventory.unselect_all() #unselect item
func gotNote(): func gotNote(): # once lab note has been retrieved
print("Got lab note") #print("Got lab note")
gotLabNote = true gotLabNote = true
extends "res://Item.gd" extends "res://Item.gd"
signal enter signal enter
# This script moves the player to the bathroom when clicked on
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
......
...@@ -2,6 +2,7 @@ extends "res://Item.gd" ...@@ -2,6 +2,7 @@ extends "res://Item.gd"
signal cabinet signal cabinet
onready var unlocked = false onready var unlocked = false
onready var first = true onready var first = true
# This script sends the player to the Inside Cabinet view once unlocked and then clicked on
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
...@@ -10,7 +11,7 @@ func _ready(): ...@@ -10,7 +11,7 @@ func _ready():
func mouseInteraction(): func mouseInteraction():
if unlocked: if unlocked:
emit_signal("cabinet") emit_signal("cabinet")
elif first: elif first: # changes the flavor text after the first interaction
.mouseInteraction() .mouseInteraction()
flavorText = "I need some tools to get this cabinet open. Maybe I can go out and find some?" flavorText = "I need some tools to get this cabinet open. Maybe I can go out and find some?"
first = false first = false
...@@ -27,9 +28,9 @@ func objInteraction(selected): ...@@ -27,9 +28,9 @@ func objInteraction(selected):
dialogueBox.text = flavor dialogueBox.text = flavor
else: else:
dialogueBox.text = "No flavor text found" #can replace this later! dialogueBox.text = "No flavor text found" #can replace this later!
if inventory.get_item_text(selected) == "Screwdriver": # unlocking the door with a bobby pin if inventory.get_item_text(selected) == "Screwdriver": # unjamming the cabinet with the screwdriver
dialogueBox.text = "Food, you are now free from your prison. You're welcome." dialogueBox.text = "Food, you are now free from your prison. You're welcome."
emit_signal("cabinet")
unlocked = true unlocked = true
inventory.remove_item(selected) inventory.remove_item(selected)
inventory.unselect_all() #unselect item inventory.unselect_all() #unselect item
......
extends "res://Item.gd" extends "res://Item.gd"
signal exit signal exit
# This script moves the player from the bathroom to the bedroom
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
......
extends "res://Item.gd" extends "res://Item.gd"
signal returnFridge signal returnFridge
# This script returns the player to the kitchen, from the fridge view
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
......
extends "res://Item.gd" extends "res://Item.gd"
signal laptop signal laptop
# This script returns the player to the bedroom, from the desk
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
pass # Replace with function body. pass # Replace with function body.
......
extends "res://Item.gd" extends "res://Item.gd"
signal returnLaundry signal returnLaundry
# This script returns the player to the bedroom from the laundry basket view
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
......
extends "res://Item.gd" extends "res://Item.gd"
signal cleaned signal cleaned
onready var eventHandler onready var eventHandler
onready var clean = false
# This script is for changing the flavor text of the sink and tracking if it's been cleaned or not
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
pass # Replace with function body. pass # Replace with function body.
func passEvent(handler): func passEvent(handler):
eventHandler = handler eventHandler = handler
connect("cleaned", handler,"_clean") connect("cleaned", handler,"_clean")
...@@ -14,11 +16,12 @@ func passEvent(handler): ...@@ -14,11 +16,12 @@ func passEvent(handler):
func objInteraction(selected): func objInteraction(selected):
var flavor = control.interaction(inventory.get_item_text(selected), self.get_name()) var flavor = control.interaction(inventory.get_item_text(selected), self.get_name())
if inventory.get_item_text(selected) == "Cleaning mat": if inventory.get_item_text(selected) == "Cleaning mat":
if flavorText != "Okay. That wasn't so bad...": if !clean: # trying to clean the sink when it's dirty
flavorText = "Okay. That wasn't so bad..." flavorText = "Okay. That wasn't so bad..."
dialogueBox.text = flavorText dialogueBox.text = flavorText
emit_signal("cleaned", "Cleaning mat") emit_signal("cleaned", "Cleaning mat")
else: clean = true
else: # trying to clean it again
dialogueBox.text = "I cleaned that already!" dialogueBox.text = "I cleaned that already!"
elif typeof(flavor) != 0: #checks if there's coded flavor text for this interaction elif typeof(flavor) != 0: #checks if there's coded flavor text for this interaction
......
extends "res://Item.gd" extends "res://Item.gd"
signal checked signal checked
# This script changes the flavor text after the first interaction
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
...@@ -7,10 +8,10 @@ func _ready(): ...@@ -7,10 +8,10 @@ func _ready():
func mouseInteraction(): func mouseInteraction():
.mouseInteraction() .mouseInteraction()
if flavorText == "OMG! Where did Banana go??": if flavorText == "OMG! Where did Banana go??": # if it's the first interaction
#emit_signal("checked", "Find Banana")
flavorText = "Okay... if I were a lizard, where would I be?" flavorText = "Okay... if I were a lizard, where would I be?"
func passEvent(handler): func passEvent(handler):
#connect("checked", handler,"_add_quest") #connect("checked", handler,"_add_quest")
# will need handler later maybe but for now its not needed anymore
pass pass
extends "res://Item.gd" extends "res://Item.gd"
onready var first onready var first
onready var clean onready var clean = false
signal cleaned signal cleaned
onready var eventHandler onready var eventHandler
# This script is for changing the flavor text of the toilet and tracking if it's been cleaned or not
func _ready(): func _ready():
pass # Replace with function body. pass # Replace with function body.
...@@ -20,16 +22,13 @@ func objInteraction(selected): # when an object is used on it ...@@ -20,16 +22,13 @@ func objInteraction(selected): # when an object is used on it
dialogueBox.text = "No flavor text found" #can replace this later! dialogueBox.text = "No flavor text found" #can replace this later!
if (inventory.get_item_text(selected) == "Plunger"): if (inventory.get_item_text(selected) == "Plunger"):
if (flavorText != "Okay. That wasn't so bad... "): if !clean: # if toilet isnt clean, and they use the plunger
flavorText = "Okay. That wasn't so bad... " flavorText = "Okay. That wasn't so bad... "
dialogueBox.text = "Time to tango, toilet." dialogueBox.text = "Time to tango, toilet."
emit_signal("cleaned", "Plunger") emit_signal("cleaned", "Plunger")
clean = true
if eventHandler.getClean() == 3: if eventHandler.getClean() == 3:
inventory.remove_item(selected) inventory.remove_item(selected)
else: else: # if they try to use the plunger on a clean toilet
dialogueBox.text = "I can't make it any LESS unclogged.." dialogueBox.text = "I can't make it any LESS unclogged.."
inventory.unselect_all() #unselect item inventory.unselect_all() #unselect item
extends "res://Item.gd" extends "res://Item.gd"
signal notebook_got signal notebook_got
#onready var eventHandler # This script is for picking up the to do list, signals to the event handler that the tutorial can proceed
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
...@@ -17,6 +12,3 @@ func pickup(): ...@@ -17,6 +12,3 @@ func pickup():
func passEvent(handler): func passEvent(handler):
connect("notebook_got", handler, "_get_notebook") connect("notebook_got", handler, "_get_notebook")
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment