title: Casting a scene to the type of the attached script or instancing with passing a parameter in Godot
body: <p><code>onready var _boardView_scene = load(&quot;res://UrBoardView.tscn&quot;)</code> gets the scene reference.
  Then I try to instance the scene like this <code>_urBoardViewInstance = _boardView_scene.instance()</code>. The UrBoardView scene has a script of type BoardView like this to its topmost node(meaning the scene is of type BoardView)-</p>
  <pre><code>extends Node
  class_name BoardView
  </code></pre>
  <p>The <code>_urBoardViewInstance</code>  get instanced as a Node here. Casting it to BoardView is not working(giving null) here - <code>var boardViewCast  = _urBoardViewInstance as BoardView</code>
  I need to call a custom init method from BoardView script before sending it to <code>add_child(_urBoardViewInstance)</code>.
  Basically, I want to instance the scene not as a node but as the type of script that it has attached.(or just call like this</p>
  <pre><code>_urBoardViewInstance = _boardView_scene.instance().new(board)
  </code></pre>
  <p>which  apparently is not possible in Godot right now.)
  And that casting is not working.
  This is the how I am casting -</p>
  <pre><code>var boardViewCast: BoardView
  _urBoardViewInstance = _boardView_scene.instance()
  boardViewCast = _urBoardViewInstance as BoardView
  boardViewCast.init(gameplay.Board)
  </code></pre>
  <p>the <code>boardViewCast</code> is null after this. It basically does not cast at all.</p>