Commit e1a18cc8 authored by Julia Santos's avatar Julia Santos

Clicking on items now logs the click to save.data, will need to log location movement next

parent b419d57e
...@@ -32,18 +32,49 @@ func _input_event(viewport, event, shape_idx): # executes when clicked on ...@@ -32,18 +32,49 @@ 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])
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])
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")
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")
mouseInteraction() mouseInteraction()
func storeClick(method):
var save_data = File.new()
if !save_data.file_exists("user://data.save"):
save_data.open("user://data.save",File.WRITE)
save_data.store_line(to_json(method + " " + get_name()))
print("Created file")
else:
save_data.open("user://data.save",File.READ_WRITE)
save_data.seek_end()
save_data.store_line(to_json(method + " " + get_name()))
print("Writing to file")
save_data.close()
func storeInt(selected):
var save_data = File.new()
if !save_data.file_exists("user://data.save"):
save_data.open("user://data.save",File.WRITE)
save_data.store_line(to_json("Used " + inventory.get_item_text(selected) + " -> " + get_name()))
print("Created file")
else:
save_data.open("user://data.save",File.READ_WRITE)
save_data.seek_end()
save_data.store_line(to_json("Used " + inventory.get_item_text(selected) + " -> " + get_name()))
print("Writing to file")
save_data.close()
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
inventory.add_item(self.get_name(), texture) inventory.add_item(self.get_name(), texture)
......
...@@ -65,7 +65,7 @@ __meta__ = { ...@@ -65,7 +65,7 @@ __meta__ = {
"_edit_group_": true "_edit_group_": true
} }
retrievable = true retrievable = true
flavorText = "Ew... It's so dirty. Is it even water? I'm not feeding that to my plants." flavorText = "A pant plot-- I mean... a plant pot."
[node name="CollisionShape2D" type="CollisionShape2D" parent="Pot"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Pot"]
position = Vector2( -16.8367, -2.11676 ) position = Vector2( -16.8367, -2.11676 )
......
extends "res://Item.gd" extends "res://Item.gd"
signal enter signal enter
onready var first = true
# 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.
...@@ -12,5 +12,9 @@ func passEvent(handler): ...@@ -12,5 +12,9 @@ func passEvent(handler):
func mouseInteraction(): func mouseInteraction():
emit_signal("enter") emit_signal("enter")
if first:
dialogueBox.text = "What is that noise? Sounds like my neighbor's trying to break down their walls."
first = false
#maybe have it repeat until they remove the noise? or would that be repetitive
pass 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