Freiver Freiver - 2 months ago 8
Javascript Question

Java Script function not work

var Structure[undefined]

function run{

Structure[0]

}



function setStructure(structure){
Structure[0]=structure
}

setStructure(House);

function House(){
//nothing
}


Why does the Programm not run the function House() in Structure[0]?
It is for a Minecraft PE mod.

Answer

I suppose you intended this:

function run{
    Structure[0]() // <--- notice the parentheses.
}

Without the parentheses, the function run does not do anything. It just references the function, without invoking it.