0 votes

Hi, I am writing a minmax code for a game, but whenever I run it I get the error Invalid set index 'start' (on base: 'Node (main.gd)') with value of type 'bool'. What does it mean and how do I fix it.

extends Node
var board=[7,5,3,1]
func _ready():
    self.board=board
    self.start=true
    makechilds(self)
func makechilds(pnode):
    for x in range(0,4):
        board=pnode.board
        for y in range (0,pnode.board[x]):
            board[x]-=1
            var child=Node
            child.board=board
            child.done=false
            child.start=false
    pnode.done=true
    nextsubject(pnode)
func nextsubject(pnode):
    for i in range (0,pnode.get_child_count( )):
        if not pnode.get_child(i).board==[0,0,0,0] and pnode.get_child(i).done==false:
            makechilds(pnode.get_child(i))
    if pnode.start==false:
        nextsubject(pnode.get_parent())
    else:
        print('done')
Godot version 3.2.1
in Engine by (19 points)

1 Answer

0 votes

Because You never introduce variable "start" anywhere !

It must exist before You set it in ready function. Do the same thing You did with "board" variable : introduce it with VAR keyword

by (2,560 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.