0 votes

Hey guys,
I have a problem creating a Object for my Player Skills. I have a external Script which has a Object for creating new Skills

class createSkill:
    var name: String
    var baseDemage: float

func _init(name: String, baseDemage: float):
    name = name
    baseDemage = baseDemage

and I'm creating a new Skill called Fireball with Base Demage 10.5

var   Skills   = preload("res://Scripts/Skills.gd")
const Fireball = Skills.createSkill.new("Fireball", 10.5)

But if I print out Fireball.name or Fireball.baseDemage i can't see it

print("Name - " + Fireball.name)
print("Demage - " + String(Fireball.baseDemage))


Name - 
Demage - 0

What I'm missing?
Thank you in advance!!

in Engine by (19 points)

2 Answers

0 votes
Best answer

Ok I just found the solution....

If you define a new Class and use _init function to set the variables values you have to use the keyword self.varName = argument

func _init(name: String, baseDemage: float):
    self.name = name
    self.baseDemage = baseDemage
by (19 points)
0 votes

print ("Name - %s" % (Fireball.name))

by (22 points)

It dosn't work. I tried it multiple times. But when i use print Fireball i get back a reference




But print(Fireball.name) or print("Name - %s" % (Fireball.name)) it wont work.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.