ScriptSpot home

Forum topic · General Scripting

string as index of array?

By gtafan · 2017-10-11

Description

Is it posible in maxscript to have something like map in C++? I would really like to do something like this in maxscript:

map["name1"]=1
and if I do later something like this:
x=map["name1"]
x should have the value 1.
This is just a simple example.

Comments (4)
Vojtech Cada

Dictionary

See the Dictionary Values topic in the maxscript reference.

Reply to Vojtech Cada
gtafan

This Dictionary looks like exactly what I need, but unfortunately it´s only avaible since Max 2017, which make it useles for me.

Panteleev Sergey

you can access collection members like that, but not the elements of arbitrary array


delete objects
t = teapot()
t.material = standardmaterial name:"abcd"
scenematerials[#abcd] == scenematerials["abcd"] -- returns True

(join #() scenematerials)[#abcd] -- Runtime error: array index must be positive number, got: #abcd

read about bsearch in mxs reference or look for examples at cgsociety.org maxscript related section