31 lines
421 B
GDScript
31 lines
421 B
GDScript
extends Node
|
|
|
|
|
|
const FILE_PATH = "user://history"
|
|
|
|
var data:PoolIntArray
|
|
|
|
|
|
func _ready():
|
|
var file = File.new()
|
|
file.open(FILE_PATH,File.READ)
|
|
data = file.get_var()
|
|
file.close()
|
|
|
|
|
|
func save():
|
|
var file = File.new()
|
|
file.open(FILE_PATH,File.WRITE)
|
|
file.store_var(data)
|
|
file.close()
|
|
|
|
|
|
func add(id:int):
|
|
if not id in data:
|
|
data.append(id)
|
|
save()
|
|
|
|
|
|
func clear():
|
|
var dir = Directory.new()
|
|
dir.remove(FILE_PATH)
|