Hi!
You not need to declare the variable var d3d_automaterial, seen that is the professional release of 3dgs, like also in the commercial release, the variable is already in the engine! must be written in the function main!: -->
The main() function is started at game start
function main()
{
// set some common flags and variables
// warn_level = 2; // announce bad texture sizes and bad wdl code
tex_share = on; // map entities share their textures
d3d_automaterial = on; // here is your variable d3d!!
Greetings
Salva