Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Maulve |
Good day. I’m trying to make “Diaries” you can collect in a game. Just little Texts basically.
However, I’ve been running into some issues trying to “Collect” said Diaries.
This is actually my second attempt trying to do this, as the first had too many issues that I wasn’t able to track down.
Saves.gd
extends Resource
class_name Saves
# for now testing with 4 Diaries
export(Array)var Diaries = [false, false, false, false]
This is the backbone of this, holding the “Diaries” Array to store which Diaries
you’ve collected. Later it will also be used to store and save other data.
DiaryBase.gd
extends Saves
class_name DiaryBase
# for testing
func _ready():
DiaryCollect(1)
func DiaryCollect(Diary):
# gets correct Position in the Array
var Arraypos = Diary - 1
Saves.Diaries[Arraypos] = true
print(Saves.Diaries)
This contains the function DiaryCollect(Diary). Which will be called once the player collects a Diary. (Diary) is just the number of the Diary. Arraypos will be the actual position in the Array, as an Array starts with 0.
Tutorial.gd
extends LevelBase
var DiaryBase = preload("res://src/Resources/DiaryBase.gd")
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
LevelBase is currently just an empty script, will be used later. I tried to preload DiaryBase and use the _ready() function in DiaryBase.gd to simulate collecting a Diary, however it didn’t work.
I am very desperate to finally get some help on this. I’ve tried using a static function in DiaryBase.gd - but I need the Diaries variable in there.
I’ve tried Autoloading Saves.gd to access it easier - but it didn’t work as I intented.
I’ve looked all around for already existing help - yet found nothing useful.
If any additional Info is required, I’m more than willing to provide it.
Thank you for reading, and also thanks in advance for potentially helping.
BTW, I am a beginner with Godot and much of Game Developing and Coding in general.