xyz it seems to stop complaining the same errors, but now it says:
Invalid get index 'monstruito' (on base: 'Nil').
It is in this function:
func _on_Button_pressed():
$TextureRect.texture = ResourceLoader.load("res://" + Globals.monstruito.imagen)
pass # Replace with function body.
And the Monstruo class is this way:
using System;
[Serializable]
public partial class Monstruo: Reference
{
public int life;
public int maxLife; // vida inicial
public int attack;
public int defense;
public int dexterity;
public string name;
public string imagen;//Imagen de (Image)Resources.
public int level;
public string descripcion;
public string[] ataques;
public enum tipo
{
BESTIA = 1,
REPTIL = 2,
FUEGO = 3,
AGUA = 4,
PARANORMAL = 5,
PERRO = 6,
NOMUERTO = 7,
DEMONIO = 8,
DRAGON = 9
};
public tipo especie; // tipo de monstruo para sonido de encuentro
// nota un monstruo puede ser vulnerable solo a un tipo de magia
public enum magia
{
TODO = 1, // le daña todo
NADA = 2, // no le daña ninguna magia
FUEGO = 3, // solo le daña el fuego
AGUA = 4, // solo el agua
AIRE = 5, // solo el aire
TIERRA = 6, // solo la tierra
ESPACIO = 7 // solo vulnerable a magia espaciotemporal
};
public magia debilidad;
///////////////////////////////////////////////////////////////////////////////////////////////////
// rutina RUTINAS * RUTINAS * RUTINAS * RUTINAS * RUTINAS * RUTINAS * RUTINAS * RUTINAS * RUTINAS
///////////////////////////////////////////////////////////////////////////////////////////////////
public Monstruo
(
int life,
int maxLife,
int attack,
int defense,
int dexterity,
string name,
string imagen ="",
int level=1,
string descripcion="",
string[] ataques = null,
tipo especie = tipo.BESTIA, // el monstruo por defecto es una bestia
magia debilidad = magia.TODO // y es vulnerable a todo tipo de magia
)
{
this.life = life;
this.maxLife = maxLife;
this.attack = attack;
this.defense = defense;
this.dexterity = dexterity;
this.name = name;
this.imagen = imagen;
this.level = level;
this.descripcion = descripcion;
this.ataques = ataques;
this.especie = especie;
this.debilidad = debilidad;
}
///////////////////////////////////////////////// END OF PRINT //////////////////////////// END OF PRINT /////////////////////// END OF PRINT /////////////////////////
} // fin clase
And the Globals.cs is this:
using Godot;
using System;
public partial class Globals : Node
{
// Declare member variables here. Examples:
// private int a = 2;
// private string b = "text";
public static Monstruo monstruito = new Monstruo(10, 10, 30, 20, 10, "Golem", "art/monsters/E_golem.jpeg", 2,
"A golem is a cursed giant made of mud or stone, that follows the commands of a wizard to kill intruders.",
new String[2] {"using his fists to crunch her", "trying to smash her with his brute force" },
Monstruo.tipo.BESTIA, Monstruo.magia.AGUA) ;
string ruta = monstruito.imagen; // coloca este atributo en una variable para poderlo invocar desde gdscript
// porque no se como hacerlo directamente, o bien es que gdscript se lia
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
}