I have this script:
extends Resource
class_name Monster
export(Texture) var front_sprite
export(Texture) var back_sprite
export(String) var name
export(int) var level
# Gets the types and gives the monster a type
export(TypeData.types) var type_1 = TypeData.types.none
export(TypeData.types) var type_2 = TypeData.types.none
# Base stats the limit the amount of points a monster can get
export(int) var Base_hp
export(int) var Base_attack
export(int) var Base_special_attack
export(int) var Base_defence
export(int) var Base_special_defence
export(int) var Base_speed
# The avaliable moves the monster can use to attack or other actions
export(Array,Resource) var move_slot = [null,null,null,null]
# The monsters stats based on the level
onready var hp = ((float(Base_hp * level) / 100) + 5.0)
onready var attack = ((float(Base_attack * level) / 100.0) + 5.0)
onready var special_attack = ((float(Base_special_attack * level) / 100.0) + 5.0)
onready var defence = ((float(Base_defence * level) / 100.0) + 5.0)
onready var special_defence = ((float(Base_special_defence * level) / 100.0) + 5.0)
onready var speed = ((float(Base_speed * level) / 100.0) + 5.0)
# So when the monster takes damage we can takeaway the hp
onready var current_hp = hp
This script is what values I want to get, I have another script that preloads this resource into the other script but when I try to access its variables it produces nulls, I am not sure why it does this, the funny thing is If I remove the onready it produces a value but not a correct value, it seems to ignore the export when onready isnt available
onready var player = preload("res://Monsters/Gobulk.tres")
func _ready():
print(player.hp)
This is the other script as you can see I preloaded the resource I want to access and in the ready function I am asking it to print the hp of the resource but instead of actually getting a value I get a null, any ideas on getting this to work, thanks