0 votes

Error: E 0: 00:04.247 createinstance: Condition" rerror. error != Variant::CallError::CALLOK" is true. Returned: __null

extends Node2D

onready var item = preload("res://Scense/Items.tscn")

func get_player():
return $Player

func ready():
var items = ["stick", "twig", "stone", "apple"]
for i in range(16):
randomize()
var a = int(rand
range(0,4))
var newitem = item.instance()
$Items.add
child(newitem)
new
item.setitem(items[a])
new
item.position = Vector2(int(randrange(0,32*31)), int(randrange(0, 32*28)))
pass

Godot version Godot Engine v3.2.3.stable.official
in Engine by (12 points)

please use code-formatting {} for everthing that is code or contains _
Its very hard to read your text like this...

1 Answer

0 votes

Error seems a bit weird, but I can see the line that causes it
You are instancing strings
You forgot about load() or preload()
It usually goes like this :

var stick = preload("res/scenes/stick.tscn")
var ins = stick.instance()
$items.add_child(ins)

By the way, this is how You should have formatted code part of text....

by (2,434 points)
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 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 webmaster@godotengine.org with your username.