1234567891011121314151617181920212223242526 |
- extends Node
- var fish_species = []
- func _ready():
- var fish_species_json = load_json_file("res://data/fish_species.json")
- if (fish_species_json != null):
- fish_species = fish_species_json["fish_species_list"]
- func load_json_file(path):
- var file = File.new()
- if (file.open(path, file.READ) != OK):
- return
- var text = file.get_as_text()
- var data_parse = JSON.parse(text)
- if (data_parse.error != OK):
- return
- var data = data_parse.result
- return data
- func get_fish_species(species_id):
- for fish in fish_species:
- if (species_id == fish["species_id"]):
- return fish
- return null
|